From bb33e69cd882c24c76e31ed7331d0413d37530fd Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Thu, 1 Aug 2024 23:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=95=B0=E6=8D=AE=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- langguanApi/Model/Device.cs | 2 ++ langguanApi/Model/Dto/RespModel.cs | 2 +- langguanApi/Service/HomeService.cs | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/langguanApi/Model/Device.cs b/langguanApi/Model/Device.cs index bc6d211..2f54d82 100644 --- a/langguanApi/Model/Device.cs +++ b/langguanApi/Model/Device.cs @@ -43,5 +43,7 @@ public string OrgId { get; set; } public int DeviceType { get; set; } public string VideoUrl { get; set; } + public double lng { get; set; } + public double lat { get; set; } } } diff --git a/langguanApi/Model/Dto/RespModel.cs b/langguanApi/Model/Dto/RespModel.cs index 2f993de..0e1fcd4 100644 --- a/langguanApi/Model/Dto/RespModel.cs +++ b/langguanApi/Model/Dto/RespModel.cs @@ -18,7 +18,7 @@ public class Rate { public string key { get; set; } - public string val { get; set; } + public double val { get; set; } } public class alarmList { diff --git a/langguanApi/Service/HomeService.cs b/langguanApi/Service/HomeService.cs index f8a7869..bada33e 100644 --- a/langguanApi/Service/HomeService.cs +++ b/langguanApi/Service/HomeService.cs @@ -5,6 +5,7 @@ using langguanApi.Model; using System.Linq.Expressions; using langguanApi.Common.Proxy; using langguanApi.Model.Dto; +using Npoi.Mapper; namespace langguanApi.Service { @@ -47,7 +48,8 @@ namespace langguanApi.Service /// public async Task View() { - var devices = await _deviceService.GetAsync(); + Expression> exp = x => x.IsDelete == false && x.lng > 0 && x.lat > 0; + var devices = (await _deviceService.GetListWithExp(exp)).ToList(); var cleanData = new { Yesterday = 0.8, @@ -61,7 +63,7 @@ namespace langguanApi.Service var detections = await _detectionService.GetIndexData(); // 获取天气信息,缓存1小时,如果不存在,则调用WeatherService获取 Func> getWeatherFunc = async () => await _weatherService.GetWeather(); - var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60*24*30); + var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60 * 24 * 30); // 获取空气质量,缓存2小时,如果不存在,则调用WeatherService获取 Func> getAriQualityFunc = async () => await _weatherService.GetAirQuality(); var ariQuality = await _cacheManager.GetConvertVale(RedisKeylist.AriQuality, getAriQualityFunc, 60 * 60 * 24 * 30); @@ -70,6 +72,7 @@ namespace langguanApi.Service // 获取远程接口污染物排放率 var rateResp = await _httpProxy.Get>>(null, _configuration.GetValue("Apis:RateUrl")); var rate = rateResp.data.ToList().Take(6); + rate.ForEach(x => x.val = Math.Round( x.val / 100,2)); var AlermResp = await _httpProxy.Get>(null, _configuration.GetValue("Apis:AlertUrl")); if (AlermResp.code == 0 && AlermResp.data.List.Any()) {