From 214a7b3afeba1f345b43220151c0f4e70f603fb2 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 30 May 2022 12:37:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=A2=E5=8D=95=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataVAPI/Controllers/DeviceStatsController.cs | 6 +++--- DataVApi.Order/OrderProvider.cs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) 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 {