瀏覽代碼

嗡嗡嗡

master
fyf 2 年之前
父節點
當前提交
b161484f5f
共有 2 個文件被更改,包括 30 次插入0 次删除
  1. +5
    -0
      DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
  2. +25
    -0
      DataVAPI/Controllers/AlarmController.cs

+ 5
- 0
DataVAPI.ServerDB/MongoDB/MongodbHelper.cs 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存