|
|
@@ -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 }; |
|
|
|