diff --git a/DataVAPI/Controllers/DeviceStatsController.cs b/DataVAPI/Controllers/DeviceStatsController.cs index 64869e2..eeac4c3 100644 --- a/DataVAPI/Controllers/DeviceStatsController.cs +++ b/DataVAPI/Controllers/DeviceStatsController.cs @@ -129,10 +129,10 @@ namespace DataVAPI.Controllers List log = mglog.ALLData(clientId); List alarm = mggj.ALLData(clientId); List list = new List(); - - list.Add(new { Name = "运行次数", Count = log?.FindAll(par => par.LogMessage.Contains("设备在线了")).Count.ToString() }); + int? count = log?.FindAll(par => par.LogMessage.Contains("设备在线了")).Count; + list.Add(new { Name = "运行次数", Count = count?.ToString()}); list.Add(new { Name = "故障次数", Count = alarm?.Count.ToString() }); - list.Add(new { Name = "故障率", Count = $"{(alarm?.Count * 100) / 100}%" }); + list.Add(new { Name = "故障率", Count = $"{(alarm?.Count * 100) / 400}%" }); return JsonMsg.OK(list, st); } diff --git a/DataVApi.Order/OrderProvider.cs b/DataVApi.Order/OrderProvider.cs index 7477567..8d8a4db 100644 --- a/DataVApi.Order/OrderProvider.cs +++ b/DataVApi.Order/OrderProvider.cs @@ -51,7 +51,7 @@ WHERE { Total = data.Sum(t => t.Money).ToString(), OrderCount = data.Count().ToString(), - MoneyM = data.Where(t => t.Time.Month == DateTime.Now.Month).Sum(t => t.Money).ToString(), + MoneyM = data.Where(t => t.Time.Year == DateTime.Now.Year && t.Time.Month == DateTime.Now.Month).Sum(t => t.Money).ToString(), MoneyD = data.Where(t => t.Time >= DateTime.Parse(DateTime.Now.ToShortDateString()) && t.Time < DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(1)).Sum(t => t.Money).ToString(), StoreCount = data.GroupBy(t => t.Id).Count() }; @@ -193,11 +193,11 @@ WHERE var sql = sb.ToString(); var data = db.SqlQueryable(sql).ToList(); int Year = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year).Count(); - int Month = data.Where(t => t.CreatedAt.Month == DateTime.Now.Month).Count(); - int Day = data.Where(t => t.CreatedAt.Day == DateTime.Now.Day).Count(); + int Month = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year && t.CreatedAt.Month == DateTime.Now.Month).Count(); + int Day = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year && t.CreatedAt.Month == DateTime.Now.Month && t.CreatedAt.Day == DateTime.Now.Day).Count(); int L_Year = data.Where(t => t.CreatedAt.Year == DateTime.Now.AddYears(-1).Year).Count(); - int L_Month = data.Where(t => t.CreatedAt.Month == DateTime.Now.AddMonths(-1).Month).Count(); - int L_Day = data.Where(t => t.CreatedAt.Day == DateTime.Now.AddDays(-1).Day).Count(); + int L_Month = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year && t.CreatedAt.Month == DateTime.Now.AddMonths(-1).Month).Count(); + int L_Day = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year && t.CreatedAt.Month == DateTime.Now.Month && t.CreatedAt.Day == DateTime.Now.AddDays(-1).Day).Count(); return new {