Browse Source

嗡嗡嗡

master
fyf 2 years ago
parent
commit
b161484f5f
2 changed files with 30 additions and 0 deletions
  1. +5
    -0
      DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
  2. +25
    -0
      DataVAPI/Controllers/AlarmController.cs

+ 5
- 0
DataVAPI.ServerDB/MongoDB/MongodbHelper.cs View File

@@ -204,6 +204,11 @@ namespace DataVAPI.ServerDB.MongoDB
return collection.Find(a => a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
}

public List<T> QueryClientIdNameO(string clientId, string name)
{
return collection.Find(a => a.ClientId == clientId && a.devicename==name && a.CreateTime >= DateTime.Now.Date)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
}

public List<T> QueryClientIdName(string clientId,string name)
{
return collection.Find(a => a.ClientId == clientId && a.devicename==name)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();


+ 25
- 0
DataVAPI/Controllers/AlarmController.cs View File

@@ -121,6 +121,31 @@ namespace DataVAPI.Controllers
}
}
/// <summary>
/// 根据客户端ID 设备名称查询当日未处理信息
/// </summary>
/// <param name="clientId"></param>
/// <returns></returns>
[HttpGet]
public JsonMsg<List<AlarmTable>> QueryClientIdName(string clientId,string name)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
List<AlarmTable> al = mg.QueryClientIdNameO(clientId, name);
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 }; }
});
al.Sort((a, b) => -a.State.CompareTo(b.State));
return JsonMsg<List<AlarmTable>>.OK(al, st);
}
catch (Exception ex)
{
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message);
}
}
/// <summary>
/// 根据客户端ID查询最近告警
/// </summary>
/// <param name="clientId"></param>


Loading…
Cancel
Save