From cd03aabe3016a19a44c0b6a4b953a3fd8795c20b Mon Sep 17 00:00:00 2001 From: guoyuepeng <770272267@qq.com> Date: Tue, 27 Feb 2024 16:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=85=AC=E5=8F=B8=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E9=A3=8E=E5=90=91=E7=9B=91=E6=B5=8B=E7=AB=99sql?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=80=9F=E5=BA=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zcloud/controller/map/MapController.java | 24 ++++++++++++++- .../dsno2/map/MeteorologicalinfoMapper.java | 3 ++ .../map/MeteorologicalinfoService.java | 5 +++- .../impl/MeteorologicalinfoServiceImpl.java | 30 ++++++++++++++++++- .../dsno2/map/MeteorologicalinfoMapper.xml | 21 ++++++++++++- 5 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zcloud/controller/map/MapController.java b/src/main/java/com/zcloud/controller/map/MapController.java index 99296de5..24459ab8 100644 --- a/src/main/java/com/zcloud/controller/map/MapController.java +++ b/src/main/java/com/zcloud/controller/map/MapController.java @@ -983,5 +983,27 @@ public class MapController extends BaseController { r.put("pd", pd); return r; } - + /** + * 企业端地图优化 + * 原有的地图查询速度太慢,达到5s以上,通过索引的方式暂时无法解决,所有使用业务优化sql,提升速度 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/listbymeteorologicalByCorpinfo") + @ResponseBody + public Object listbymeteorologicalByCorpinfo() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + //根据条件增加参数或减少参数 都没有 直接返回空 + if (StringUtils.isBlank(pd.getString("CORPINFO_ID"))) { + map.put("result", errInfo); + return map; + } + pd = meteorologicalinfoService.listbymeteorologicalByCorpinfoId(pd); //列出meteorological列表 + map.put("pd", pd); + map.put("result", errInfo); + return map; + } } diff --git a/src/main/java/com/zcloud/mapper/dsno2/map/MeteorologicalinfoMapper.java b/src/main/java/com/zcloud/mapper/dsno2/map/MeteorologicalinfoMapper.java index c51056b7..c85402d0 100644 --- a/src/main/java/com/zcloud/mapper/dsno2/map/MeteorologicalinfoMapper.java +++ b/src/main/java/com/zcloud/mapper/dsno2/map/MeteorologicalinfoMapper.java @@ -100,5 +100,8 @@ public interface MeteorologicalinfoMapper { * @return */ List tensList(PageData pd); + + PageData listbymeteorologicalByCodes(PageData pd); + } diff --git a/src/main/java/com/zcloud/service/map/MeteorologicalinfoService.java b/src/main/java/com/zcloud/service/map/MeteorologicalinfoService.java index 8b80b9d2..35f71254 100644 --- a/src/main/java/com/zcloud/service/map/MeteorologicalinfoService.java +++ b/src/main/java/com/zcloud/service/map/MeteorologicalinfoService.java @@ -98,6 +98,9 @@ public interface MeteorologicalinfoService { * @throws Exception */ Integer updateMeteorologicalinfo(PageData pageData); - + /**列表 + * @throws Exception + */ + public PageData listbymeteorologicalByCorpinfoId(PageData pd)throws Exception; } diff --git a/src/main/java/com/zcloud/service/map/impl/MeteorologicalinfoServiceImpl.java b/src/main/java/com/zcloud/service/map/impl/MeteorologicalinfoServiceImpl.java index 42c149a5..df1a3c83 100644 --- a/src/main/java/com/zcloud/service/map/impl/MeteorologicalinfoServiceImpl.java +++ b/src/main/java/com/zcloud/service/map/impl/MeteorologicalinfoServiceImpl.java @@ -2,6 +2,7 @@ package com.zcloud.service.map.impl; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; +import com.zcloud.mapper.dsno2.map.MeteorologicalMapper; import com.zcloud.mapper.dsno2.map.MeteorologicalinfoMapper; import com.zcloud.service.map.DataDockingLogService; import com.zcloud.service.map.MeteorologicalinfoService; @@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -27,7 +29,8 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService @Autowired private MeteorologicalinfoMapper meteorologicalinfoMapper; - + @Autowired + private MeteorologicalMapper meteorologicalMapper; @Autowired private DataDockingLogService dataDockingLogService; @@ -218,5 +221,30 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService public Integer updateMeteorologicalinfo(PageData pageData) { return meteorologicalinfoMapper.updateMeteorologicalinfo(pageData); } + + /**列表 + * @throws Exception + */ + public PageData listbymeteorologicalByCorpinfoId(PageData pd)throws Exception{ + /** + * 暂时使用in优化速度 + * 1.获取这个企业下的所有天气站信息 + * 2.根据这些天气站的信息,获取最新的数据 + */ + pd.put("OUTSOURCED_ID",pd.getString("CORPINFO_ID")); + List getListByCorpinfoId = meteorologicalMapper.listAll(pd); + if(getListByCorpinfoId.size() > 0){ + String codes = ""; + for (PageData met : getListByCorpinfoId){ + codes += "'" + met.getString("CODE")+"',"; + } + System.out.println(); + codes = codes.substring(0,codes.length()-1); + pd.put("codes",codes); + return meteorologicalinfoMapper.listbymeteorologicalByCodes(pd); + } + + return null; + } } diff --git a/src/main/resources/mybatis/dsno2/map/MeteorologicalinfoMapper.xml b/src/main/resources/mybatis/dsno2/map/MeteorologicalinfoMapper.xml index 3a2e2c88..a2b3204c 100644 --- a/src/main/resources/mybatis/dsno2/map/MeteorologicalinfoMapper.xml +++ b/src/main/resources/mybatis/dsno2/map/MeteorologicalinfoMapper.xml @@ -510,5 +510,24 @@ where f.CODE = #{CODE} and ABS(TIMESTAMPDIFF(SECOND, f.OPERATTIME, #{OPERATTIME})) < 10; - +