diff --git a/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs b/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs index 72cba28..71c208c 100644 --- a/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs +++ b/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs @@ -246,6 +246,11 @@ namespace DataVAPI.ServerDB.MongoDB return collection.Find(a => a.ClientId == key)?.ToList(); } + public List ALLDataName(string key,string name) + { + return collection.Find(a => a.ClientId == key && a.devicename==name)?.ToList(); + } + public PaginationListModel BasePagQuery(string clientId, string deviceId, DateTime datesta, DateTime datastop, int PageNumber, int PageSize) { BasePaginationModel pagination = new BasePaginationModel() diff --git a/DataVAPI/Controllers/DeviceStatsController.cs b/DataVAPI/Controllers/DeviceStatsController.cs index 226d8fe..48f274c 100644 --- a/DataVAPI/Controllers/DeviceStatsController.cs +++ b/DataVAPI/Controllers/DeviceStatsController.cs @@ -131,15 +131,26 @@ namespace DataVAPI.Controllers /// 统计数量 /// /// + /// /// [HttpGet] - public JsonMsg StatsConut(string clientId) + public JsonMsg StatsConut(string clientId,string name) { st = System.Reflection.MethodBase.GetCurrentMethod().Name; try { - List log = mglog.ALLData(clientId); - List alarm = mggj.ALLData(clientId); + List log = new List(); + List alarm = new List(); + if (string.IsNullOrEmpty(name)) + { + log = mglog.ALLData(clientId); + alarm = mggj.ALLData(clientId); + } + else + { + log = mglog.ALLDataName(clientId,name); + alarm = mggj.ALLDataName(clientId, name); + } List list = new List(); int? count = log?.FindAll(par => par.LogMessage.Contains("设备在线了")).Count; list.Add(new { Name = "运行次数", Count = count?.ToString()});