@@ -32,5 +32,13 @@ namespace DataVAPI.Model | |||||
/// IP 地址 | /// IP 地址 | ||||
/// </summary> | /// </summary> | ||||
public string IP { get; set; } | public string IP { get; set; } | ||||
/// <summary> | |||||
/// 状态描述 | |||||
/// </summary> | |||||
public string StatusMS { get; set; } | |||||
/// <summary> | |||||
/// 状态颜色 | |||||
/// </summary> | |||||
public object StatusColor { get; set; } | |||||
} | } | ||||
} | } |
@@ -182,7 +182,7 @@ namespace DataVAPI.ServerDB.MongoDB | |||||
public List<T> QueryClientId(string clientId) | public List<T> QueryClientId(string clientId) | ||||
{ | { | ||||
return collection.Find(a => a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime)?.ToList(); | |||||
return collection.Find(a => a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList(); | |||||
} | } | ||||
public T QueryClientIdMax(string clientId) | public T QueryClientIdMax(string clientId) | ||||
@@ -201,6 +201,11 @@ namespace DataVAPI.ServerDB.MongoDB | |||||
return collection.Find(a => a.State.Equals("y"))?.ToList(); | return collection.Find(a => a.State.Equals("y"))?.ToList(); | ||||
} | } | ||||
public T QueryKeyID(string key) | |||||
{ | |||||
return collection.Find(a => a.KeyID== key)?.ToList().FirstOrDefault(); | |||||
} | |||||
public PaginationListModel<T> BasePagQuery(string clientId, string deviceId, DateTime datesta, DateTime datastop, int PageNumber, int PageSize) | public PaginationListModel<T> BasePagQuery(string clientId, string deviceId, DateTime datesta, DateTime datastop, int PageNumber, int PageSize) | ||||
{ | { | ||||
BasePaginationModel pagination = new BasePaginationModel() | BasePaginationModel pagination = new BasePaginationModel() | ||||
@@ -261,6 +266,10 @@ namespace DataVAPI.ServerDB.MongoDB | |||||
/// </summary> | /// </summary> | ||||
[BsonDateTimeOptions(Kind = DateTimeKind.Local)] | [BsonDateTimeOptions(Kind = DateTimeKind.Local)] | ||||
public DateTime UpdateTime { get; set; } | public DateTime UpdateTime { get; set; } | ||||
/// <summary> | |||||
/// key | |||||
/// </summary> | |||||
public string KeyID { get; set; } | |||||
} | } | ||||
@@ -13,7 +13,7 @@ namespace DataVAPI.Controllers | |||||
/// </summary> | /// </summary> | ||||
public class AlarmController : BaseController | public class AlarmController : BaseController | ||||
{ | { | ||||
MongoDbHelper<AlarmTable> mg = new MongoDbHelper<AlarmTable>(DataBus.connStr, DataBus.dbName); | |||||
public MongoDbHelper<AlarmTable> mg = new MongoDbHelper<AlarmTable>(DataBus.connStr, DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.connStr, DataBus.dbName); | MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.connStr, DataBus.dbName); | ||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
@@ -106,6 +106,12 @@ namespace DataVAPI.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
List<AlarmTable> al = mg.QueryClientId(clientId); | |||||
al?.ForEach(par => | |||||
{ | |||||
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 }; } | |||||
}); | |||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(clientId), st); | return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(clientId), st); | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -224,6 +224,8 @@ namespace DataVAPI.UpAndDown | |||||
}); | }); | ||||
int index = 0; | int index = 0; | ||||
if (receiveModel.status.value == "离线") index = devModel.operatingDeviceStatus.data.Count - 1; | if (receiveModel.status.value == "离线") index = devModel.operatingDeviceStatus.data.Count - 1; | ||||
else index = devModel.operatingDeviceStatus.data.FindLastIndex(0,ar => ar.DeviceMS.Contains("在线"))+1; | |||||
if (index > devModel.operatingDeviceStatus.data.Count - 1) index = devModel.operatingDeviceStatus.data.Count - 1; | |||||
int now = devModel.operatingDeviceStatus.data.IndexOf(dev); | int now = devModel.operatingDeviceStatus.data.IndexOf(dev); | ||||
Swap(devModel.operatingDeviceStatus.data, index, now); | Swap(devModel.operatingDeviceStatus.data, index, now); | ||||
} | } | ||||
@@ -318,12 +320,23 @@ namespace DataVAPI.UpAndDown | |||||
if (message.Contains("AlarmType")) | if (message.Contains("AlarmType")) | ||||
{ | { | ||||
alarmController.Create(Tools.JsonToObjectTools<AlarmTable>(message)); | |||||
AlarmTable alarm= Tools.JsonToObjectTools<AlarmTable>(message); | |||||
if (alarm.State == "n") | |||||
{ | |||||
AlarmTable al = alarmController.mg.QueryKeyID(alarm.KeyID); | |||||
if (al != null) | |||||
{ | |||||
alarmController.mg.Modify(al.Id, "State", "n"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
alarmController.Create(alarm); | |||||
} | |||||
} | } | ||||
else if (message.Contains("LogType")) | else if (message.Contains("LogType")) | ||||
{ | { | ||||
logController.Create(Tools.JsonToObjectTools<LogTable>(message)); | logController.Create(Tools.JsonToObjectTools<LogTable>(message)); | ||||
} | } | ||||
} | } | ||||
//else if (topic == IOTDevServer.TargetStatusSubTopic)//属性变更 | //else if (topic == IOTDevServer.TargetStatusSubTopic)//属性变更 | ||||