更新 评测前bug修复

This commit is contained in:
dell
2023-03-20 22:54:52 +08:00
parent a3a51fd6e2
commit 02c976e460
28 changed files with 1584 additions and 42 deletions

View File

@ -0,0 +1,124 @@
using HT.Cloud.Code;
using HT.Cloud.Domain.DevicesManage;
using HT.Cloud.Domain.ReportManage;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HT.Cloud.Service.ReportManage
{
public class MetaTagAlarmService : BaseService<MetaTagAlarmEntity>, IDenpendency
{
public MetaTagAlarmService(ISqlSugarClient context) : base(context)
{
}
public async Task<string> GetAllSubsystemTag()
{
List<SubsysytemNameList> subsystems = new List<SubsysytemNameList>();
var grouped = repository.IQueryable().ToList();
List<string> list_name_two = grouped.Select(t => t.Subsystem).GroupBy(c => c).Select(c => c.First()).ToList();
int i = 0;
foreach (var Meta_Tag in list_name_two)
{
subsystems.Add(new SubsysytemNameList() { Lable = "a" + i, Value = Meta_Tag });
i++;
}
return subsystems.ToJson();
}
public async Task<string> GetSubsystemAllTag(string subsysytemName)
{
var subsysname = subsysytemName;
var response = repository.IQueryable().Where(x => x.Subsystem == subsysname).Select(x => new { x.TagID, x.Description, x.Units }).ToList();
var reList = new List<SubAllTagReturn>();
foreach (var subsystem in response)
{
reList.Add(
new SubAllTagReturn()
{
TagID = (short)subsystem.TagID,
Description = subsystem.Description + $"({subsystem.Units})",
Units = subsystem.Units
}
);
}
return reList.ToJson();
}
public async Task<string> GetAlarmRecord(short tagid, string startdt, string enddt)
{
SugarParameter[] sqlParameters =
{
new SugarParameter("@Henddt",enddt),
new SugarParameter("@Hstartdt",startdt),
new SugarParameter("@Htagid",tagid)
};
var dt = _context.Ado.UseStoredProcedure().GetDataTable("Query_Tag_Alarm", sqlParameters);
var valuelist = DataTableConvertModel<AlarmValue>.ConvertDataTableToList(dt);
return valuelist.ToJson();
// var testdata = new List<AlarmValue>
// {
// new AlarmValue() {
// Description= "测试标题",
// StartTime = "08点37分",
// EndTime = "08点38分"
// },
// new AlarmValue() {
// Description= "测试标题",
// StartTime = "08点37分",
// EndTime = "08点38分"
// },
// new AlarmValue() {
// Description= "测试标题",
// StartTime = "08点37分",
// EndTime = "08点38分"
// },
// new AlarmValue() {
// Description= "测试标题",
// StartTime = "08点37分",
// EndTime = "08点38分"
// }
//};
// return testdata.ToJson();
//var resultlist = new List<ChartData>();
//foreach (var value in valuelist)
//{
// resultlist.Add(new ChartData()
// {
// name = value.HDATETIME,
// value = value.VALUE
// });
//}
//return resultlist.ToJson();
}
private class AlarmValue
{
public string Description { get; set; }
public string startdt { get; set; }
public string enddt { get; set; }
}
private class SubsysytemNameList
{
public string Lable { get; set; }
public string Value { get; set; }
}
private class SubAllTagReturn
{
//x.TagID, x.Description, x.Units
public short TagID { get; set; }
public string Description { get; set; }
public string Units { get; set; }
}
}
}