ソースを参照

增加告警排序与设备状态数量统计

master
fyf 2年前
コミット
1b1991be19
3個のファイルの変更46行の追加12行の削除
  1. +5
    -0
      DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
  2. +1
    -0
      DataVAPI/Controllers/AlarmController.cs
  3. +40
    -12
      DataVAPI/Controllers/DeviceStatsController.cs

+ 5
- 0
DataVAPI.ServerDB/MongoDB/MongodbHelper.cs ファイルの表示

@@ -206,6 +206,11 @@ namespace DataVAPI.ServerDB.MongoDB
return collection.Find(a => a.KeyID== key)?.ToList().FirstOrDefault();
}

public List<T> ALLData(string key)
{
return collection.Find(a => a.ClientId == key)?.ToList();
}

public PaginationListModel<T> BasePagQuery(string clientId, string deviceId, DateTime datesta, DateTime datastop, int PageNumber, int PageSize)
{
BasePaginationModel pagination = new BasePaginationModel()


+ 1
- 0
DataVAPI/Controllers/AlarmController.cs ファイルの表示

@@ -112,6 +112,7 @@ namespace DataVAPI.Controllers
if (par.State == "y") { par.StatusMS = "未处理"; par.StatusColor = new { r = 255, g = 0, b = 0, a = 1 }; }
else { par.StatusMS = "已处理"; par.StatusColor = new { r = 51, g = 232, b = 34, a = 1 }; }
});
al.Sort((a, b) => -a.State.CompareTo(b.State));
return JsonMsg<List<AlarmTable>>.OK(al, st);
}
catch (Exception ex)


+ 40
- 12
DataVAPI/Controllers/DeviceStatsController.cs ファイルの表示

@@ -29,16 +29,16 @@ namespace DataVAPI.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
string gj_time="未知";
string gj_time = "未知";
string sx_time = "未知";
string xx_time = "未知";

AlarmTable alarmTable = mggj.QueryClientIdMax(clientId);
List<LogTable> log = mglog.QueryClientId(clientId);
if (alarmTable != null) gj_time = alarmTable.AlarmTime;
LogTable logTable1= log.Find(par => par.LogMessage.Contains("设备在线了"));
LogTable logTable1 = log.Find(par => par.LogMessage.Contains("设备在线了"));
LogTable logTable2 = log.Find(par => par.LogMessage.Contains("设备离线了"));
if(logTable1!=null) sx_time = logTable1.LogTime;
if (logTable1 != null) sx_time = logTable1.LogTime;
if (logTable2 != null) xx_time = logTable2.LogTime;

List<object> list = new List<object>();
@@ -48,7 +48,7 @@ namespace DataVAPI.Controllers
OnlineTime = sx_time,
OfflineTime = xx_time
});
return JsonMsg<object>.OK(list, st);
}
catch (Exception ex)
@@ -63,7 +63,7 @@ namespace DataVAPI.Controllers
/// <param name="clientId"></param>
/// <returns></returns>
[HttpGet]
public JsonMsg<object> StatsTargetStatus(string clientId,string deviceId)
public JsonMsg<object> StatsTargetStatus(string clientId, string deviceId)
{
object obj; List<returnStatus> returns = new List<returnStatus>();
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
@@ -76,10 +76,10 @@ namespace DataVAPI.Controllers
if (largeScreen.json != null && largeScreen.json.Contains("data"))
{
TargetStatus _Target = Tools.JsonToObjectTools<TargetStatus>(largeScreen.json);
TargetStatusList statusList= _Target?.data?.Find(ar => ar.DeviceId.ToString()== deviceId);
TargetStatusList statusList = _Target?.data?.Find(ar => ar.DeviceId.ToString() == deviceId);
if (statusList != null)
{
foreach (var item in statusList.Status)
{
//PLC.MorksMachine.IsConnected
@@ -88,17 +88,17 @@ namespace DataVAPI.Controllers
string Ms = string.Empty;
if (item.Key.Contains("."))
{
string sta = item.Key.Split('.')[0];
string sta = item.Key.Split('.')[0];
string sop = item.Key.Split('.')[item.Key.Split('.').Length - 1]; name = sop;
string value = item.Value.ToString();
if (keyValues.ContainsKey(sta)) sta = keyValues[sta];
if (keyValues.ContainsKey(sta)) sta = keyValues[sta];
if (keyValues.ContainsKey(sop)) sop = keyValues[sop];
if (keyValues.ContainsKey(value)) value = keyValues[value];

Ms = $"[{sta}]-[{sop}]-[{value}]";
}

returns.Add(new returnStatus { Name = name, Status = item.Value.ToString(),Ms=Ms});
returns.Add(new returnStatus { Name = name, Status = item.Value.ToString(), Ms = Ms });
}
}
}
@@ -115,7 +115,35 @@ namespace DataVAPI.Controllers
}
}

public Dictionary<string, string> keyValues = new Dictionary<string, string>()
/// <summary>
/// 统计数量
/// </summary>
/// <param name="clientId"></param>
/// <returns></returns>
[HttpGet]
public JsonMsg<object> StatsConut(string clientId)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
List<LogTable> log = mglog.ALLData(clientId);
List<AlarmTable> alarm = mggj.ALLData(clientId);
List<object> list = new List<object>();

list.Add(new { Name = "运行次数", Count = log?.FindAll(par => par.LogMessage.Contains("设备在线了")).Count.ToString() });
list.Add(new { Name = "故障次数", Count = alarm?.Count.ToString() });
list.Add(new { Name = "故障率", Count = $"{(alarm?.Count * 100) / 100}%" });

return JsonMsg<object>.OK(list, st);
}
catch (Exception ex)
{
return JsonMsg<object>.Error(null, st, ex.Message);
}
}


public Dictionary<string, string> keyValues = new Dictionary<string, string>()
{
{"PLC","煮面机机器人" },
{"Lebai","乐白机器人" },
@@ -169,7 +197,7 @@ namespace DataVAPI.Controllers
_status = value;
if (_status == "False" || _status == "True")
{
if(_status== "True")
if (_status == "True")
StatusColor = new ALYColor { r = 51, g = 232, b = 34, a = 1 };
else
StatusColor = new ALYColor { r = 255, g = 0, b = 0, a = 1 };


読み込み中…
キャンセル
保存