Ver a proveniência

更新告警消息

master
fyf há 2 anos
ascendente
cometimento
cea29256c2
4 ficheiros alterados com 40 adições e 4 eliminações
  1. +8
    -0
      DataVAPI.Model/AlarmTable.cs
  2. +10
    -1
      DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
  3. +7
    -1
      DataVAPI/Controllers/AlarmController.cs
  4. +15
    -2
      DataVAPI/UpAndDown/ProcessServer.cs

+ 8
- 0
DataVAPI.Model/AlarmTable.cs Ver ficheiro

@@ -32,5 +32,13 @@ namespace DataVAPI.Model
/// IP 地址
/// </summary>
public string IP { get; set; }
/// <summary>
/// 状态描述
/// </summary>
public string StatusMS { get; set; }
/// <summary>
/// 状态颜色
/// </summary>
public object StatusColor { get; set; }
}
}

+ 10
- 1
DataVAPI.ServerDB/MongoDB/MongodbHelper.cs Ver ficheiro

@@ -182,7 +182,7 @@ namespace DataVAPI.ServerDB.MongoDB

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)
@@ -201,6 +201,11 @@ namespace DataVAPI.ServerDB.MongoDB
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)
{
BasePaginationModel pagination = new BasePaginationModel()
@@ -261,6 +266,10 @@ namespace DataVAPI.ServerDB.MongoDB
/// </summary>
[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
public DateTime UpdateTime { get; set; }
/// <summary>
/// key
/// </summary>
public string KeyID { get; set; }
}




+ 7
- 1
DataVAPI/Controllers/AlarmController.cs Ver ficheiro

@@ -13,7 +13,7 @@ namespace DataVAPI.Controllers
/// </summary>
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);

string st = System.Reflection.MethodBase.GetCurrentMethod().Name;
@@ -106,6 +106,12 @@ namespace DataVAPI.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
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);
}
catch (Exception ex)


+ 15
- 2
DataVAPI/UpAndDown/ProcessServer.cs Ver ficheiro

@@ -224,6 +224,8 @@ namespace DataVAPI.UpAndDown
});
int index = 0;
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);
Swap(devModel.operatingDeviceStatus.data, index, now);
}
@@ -318,12 +320,23 @@ namespace DataVAPI.UpAndDown

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"))
{
logController.Create(Tools.JsonToObjectTools<LogTable>(message));

}
}
//else if (topic == IOTDevServer.TargetStatusSubTopic)//属性变更


Carregando…
Cancelar
Guardar