From 3d2350a16eaf71c67d1de4cfa82751e775961aab Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 19 五月 2023 09:44:18 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/IWarningAnalyseService.java         |    3 +++
 src/main/resources/mapping/QxshMapper.xml                          |   10 +++++++++-
 src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java |   25 ++++++++++++++++---------
 src/main/java/com/yssh/dao/QxshMapper.java                         |    2 ++
 src/main/java/com/yssh/controller/WarningAnalyseController.java    |    8 +++++---
 5 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/yssh/controller/WarningAnalyseController.java b/src/main/java/com/yssh/controller/WarningAnalyseController.java
index eb9d9e4..930e7ae 100644
--- a/src/main/java/com/yssh/controller/WarningAnalyseController.java
+++ b/src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -1,5 +1,6 @@
 package com.yssh.controller;
 
+import com.yssh.entity.Qxsh;
 import com.yssh.utils.CacheUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -98,12 +99,13 @@
 
         String key = dateFormat.format(new Date()) + "_top10";
         Object obj = CacheUtils.get(key);
-        List<Map<String, Object>> list;
+        List<Qxsh> list;
 
         if (null != obj) {
-            list = (List<Map<String, Object>>) obj;
+            list = (List<Qxsh>) obj;
         } else {
-            list = warningService.selectThisMonthLocationValueDataTop10();
+            //list = warningService.selectThisMonthLocationValueDataTop10();
+            list = warningService.selectMonthTop10();
             if (null != list && list.size() > 0) {
                 CacheUtils.put(key, list);
             }
diff --git a/src/main/java/com/yssh/dao/QxshMapper.java b/src/main/java/com/yssh/dao/QxshMapper.java
index bfe548f..2ce717b 100644
--- a/src/main/java/com/yssh/dao/QxshMapper.java
+++ b/src/main/java/com/yssh/dao/QxshMapper.java
@@ -13,4 +13,6 @@
 @Mapper
 public interface QxshMapper {
     public List<Qxsh> selectByTime(String time);
+
+    public List<Qxsh> selectMonthTop10(String time);
 }
diff --git a/src/main/java/com/yssh/service/IWarningAnalyseService.java b/src/main/java/com/yssh/service/IWarningAnalyseService.java
index 0639467..d19aa53 100644
--- a/src/main/java/com/yssh/service/IWarningAnalyseService.java
+++ b/src/main/java/com/yssh/service/IWarningAnalyseService.java
@@ -4,6 +4,7 @@
 import java.util.List;
 import java.util.Map;
 
+import com.yssh.entity.Qxsh;
 import com.yssh.entity.WarningDetail;
 import com.yssh.entity.vo.WarningVo;
 
@@ -25,5 +26,7 @@
 
 	List<Map<String, Object>> selectThisMonthLocationValueDataTop10();
 
+	List<Qxsh> selectMonthTop10();
+
 	List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end);
 }
diff --git a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
index ef8932c..1aff2ff 100644
--- a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
+++ b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -10,21 +10,14 @@
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 
+import com.yssh.dao.*;
+import com.yssh.entity.*;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import com.google.common.collect.Lists;
-import com.yssh.dao.AlertConfigMapper;
-import com.yssh.dao.DictRecordMapper;
-import com.yssh.dao.SuYuanMapper;
-import com.yssh.dao.WarningDetailMapper;
-import com.yssh.entity.DictRecord;
-import com.yssh.entity.MonitorPointPosition;
-import com.yssh.entity.SuYuan2d;
-import com.yssh.entity.SuYuanMonitorData;
-import com.yssh.entity.WarningDetail;
 import com.yssh.entity.vo.WarningVo;
 import com.yssh.service.IAsyncService;
 import com.yssh.service.ICommonService;
@@ -57,6 +50,11 @@
 
     @Resource
     private IAsyncService asyncService;
+
+    @Resource
+    private QxshMapper qxshMapper;
+
+    private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%");
 
     private SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH");
 
@@ -366,6 +364,15 @@
     }
 
     @Override
+    public List<Qxsh> selectMonthTop10() {
+        String time = ym.format(new Date());
+
+        List<Qxsh> list = qxshMapper.selectMonthTop10(time);
+
+        return list;
+    }
+
+    @Override
     public List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end) {
         List<WarningVo> list = new ArrayList<>();
         List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d());
diff --git a/src/main/resources/mapping/QxshMapper.xml b/src/main/resources/mapping/QxshMapper.xml
index 75e1ed4..162fbd6 100644
--- a/src/main/resources/mapping/QxshMapper.xml
+++ b/src/main/resources/mapping/QxshMapper.xml
@@ -4,7 +4,15 @@
     <select id="selectByTime" resultType="com.yssh.entity.Qxsh">
         select id, name, lon, lat, value, time
         from yssh_qxsh
-        where time =#{time}
+        where time = #{time}
         order by name;
     </select>
+
+    <select id="selectMonthTop10" resultType="com.yssh.entity.Qxsh">
+        select id, name, format(value, 2) "value", time
+        from yssh_qxsh
+        where time like #{time} and name like 'AI-%'
+        order by value desc
+        limit 10;
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3