From a77bf9fb4718d1b657f8ef8c6edfaffa1a53683f Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 06 二月 2026 17:01:20 +0800
Subject: [PATCH] 处理数据查询慢的问题

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java |   32 ++++++---------
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java            |    1 
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskPreachformMapper.xml             |   74 +++++++++++++++++++++++--------------
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml                       |    3 +
 4 files changed, 62 insertions(+), 48 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
index 3b82483..993d800 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -89,8 +89,8 @@
     //@PreAuthorize("@ss.hasPermi('system:taskcall:list')")
 //    @Cacheable(value = "patItem", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskVO.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
     @PostMapping("/patItem")
-    public TableDataInfo patItem(@RequestBody ServiceSubtaskVO serviceSubtaskVO) {
-        PageUtils.startPageByPost(serviceSubtaskVO.getPageNum(), serviceSubtaskVO.getPageSize());
+    public Map<String, Object> patItem(@RequestBody ServiceSubtaskVO serviceSubtaskVO) {
+        serviceSubtaskVO.setPageNum(PageUtils.getOffset(serviceSubtaskVO.getPageNum(), serviceSubtaskVO.getPageSize()));
         List<ServiceSubtask> serviceSubtaskList = null;
         LoginUser loginUser = getLoginUser();
         SysUser user = loginUser.getUser();
@@ -111,21 +111,16 @@
         }
 
 //      patItemCount 璋冪敤redisCache璁板綍缁熻鏁版嵁
-//      Map<String, Object> map = patItemCount(serviceSubtaskVO);
         Map<String, Object> map = serviceSubtaskService.patItemCount(serviceSubtaskVO);
         map.put("serviceSubtaskList", serviceSubtaskList);
         List<Map<String, Object>> list = new ArrayList<>();
         list.add(map);
-        //鑾峰彇total
-        long total = PageUtils.count(new ISelect() {
-            @Override
-            public void doSelect() {
-                serviceSubtaskVO.setPageNum(null);
-                serviceSubtaskVO.setPageSize(null);
-                serviceSubtaskService.patItem(serviceSubtaskVO);
-            }
-        });
-        return getDataTable2(total, list);
+
+        serviceSubtaskVO.setPageNum(null);
+        serviceSubtaskVO.setPageSize(null);
+        List<ServiceSubtask> serviceSubtasks = serviceSubtaskService.patItem(serviceSubtaskVO);
+
+        return getDataTable3(CollectionUtils.isNotEmpty(serviceSubtasks) ? serviceSubtasks.size() : 0L, list);
     }
 
     /**
@@ -490,11 +485,10 @@
         if (CollectionUtils.isEmpty(serviceSubtaskCountReq.getServiceType())) {
             return error("鏈嶅姟绫诲瀷涓嶈兘涓虹┖");
         }
-        String followUpCountStyle = configService.selectConfigByKey("followUpCountStyle",
-                serviceSubtaskCountReq.getOrgid());
-        if (ObjectUtils.isNotEmpty(followUpCountStyle)){
+        String followUpCountStyle = configService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
+        if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
             serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
-        }else {
+        } else {
             serviceSubtaskCountReq.setFollowUpCountStyle("1");
         }
         return success(serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq));
@@ -574,7 +568,7 @@
         }
         String configKey = serviceSubtaskCountReq.getConfigKey();
         if (StringUtils.isNotEmpty(configKey)) {
-            String configValue = configService.selectConfigByKey(configKey,serviceSubtaskCountReq.getOrgid());
+            String configValue = configService.selectConfigByKey(configKey, serviceSubtaskCountReq.getOrgid());
             serviceSubtaskCountReq.setConfigValue(configValue);
             if (StringUtils.isEmpty(configValue)) {
                 String logInfo = "getSfStatisticsCount-鍙傛暟 " + configKey + " 鏈厤缃�, 璇烽厤缃ソ鍚庨噸璇�";
@@ -599,7 +593,7 @@
         //澶嶈瘖缁熻
         String configKey = serviceSubtaskCountReq.getConfigKey();
         if (StringUtils.isNotEmpty(configKey)) {
-            String configValue = configService.selectConfigByKey(configKey,serviceSubtaskCountReq.getOrgid());
+            String configValue = configService.selectConfigByKey(configKey, serviceSubtaskCountReq.getOrgid());
             if (StringUtils.isEmpty(configValue)) {
                 String logInfo = "getSfStatisticsCountDetails-鍙傛暟 " + configKey + " 鏈厤缃�, 璇烽厤缃ソ鍚庨噸璇�";
                 log.error(logInfo);
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 96f9a1e..5842e9d 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -386,6 +386,7 @@
         result.putIfAbsent("wzx", 0);
         result.putIfAbsent("ysf", 0);
         result.putIfAbsent("yc", 0);
+        result.putIfAbsent("jg", 0);
         result.putIfAbsent("fssb", 0);
         result.putIfAbsent("yfs", 0);
         result.putIfAbsent("blq", 0);
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 65db861..2ed1573 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -2017,7 +2017,8 @@
         SUM(CASE WHEN sendstate >= 3 OR sendstate = 1 THEN 1 ELSE 0 END) AS yfs,
         SUM(CASE WHEN sendstate = 2 THEN 1 ELSE 0 END) AS dsf,
         SUM(CASE WHEN sendstate = 1 THEN 1 ELSE 0 END) AS blq,
-        SUM(CASE WHEN excep IS NOT NULL AND excep != '0' THEN 1 ELSE 0 END) AS yc
+        SUM(CASE WHEN excep IS NOT NULL AND excep != '0' THEN 1 ELSE 0 END) AS yc,
+        SUM(CASE WHEN isabnormal IS NOT NULL AND isabnormal = 2 THEN 1 ELSE 0 END) AS jg
         FROM service_subtask
         where 1=1
         and del_flag = 0
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskPreachformMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskPreachformMapper.xml
index be414c3..05b062e 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskPreachformMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskPreachformMapper.xml
@@ -19,6 +19,7 @@
         <result property="updateBy" column="update_by"/>
         <result property="sort" column="sort"/>
         <result property="compensateTime" column="compensate_time"/>
+        <result property="currentSendTime" column="current_send_time"/>
     </resultMap>
 
     <sql id="selectServiceSubtaskPreachformVo">
@@ -27,6 +28,7 @@
                taskid,
                preachform,
                sendstate,
+               current_send_time,
                remark,
                orgid,
                del_flag,
@@ -43,28 +45,31 @@
             resultMap="ServiceSubtaskPreachformResult">
         <include refid="selectServiceSubtaskPreachformVo"/>
         where 1=1
-            and del_flag = 0
-            <if test="subid != null ">
-                and subid = #{subid}
-            </if>
-            <if test="taskid != null ">
-                and taskid = #{taskid}
-            </if>
-            <if test="preachform != null  and preachform != ''">
-                and preachform = #{preachform}
-            </if>
-            <if test="sendstate != null  and sendstate != ''">
-                and sendstate = #{sendstate}
-            </if>
-            <if test="orgid != null  and orgid != ''">
-                and orgid = #{orgid}
-            </if>
-            <if test="sort != null ">
-                and sort = #{sort}
-            </if>
-            <if test="compensateTime != null ">
-                and compensate_time = #{compensateTime}
-            </if>
+        and del_flag = 0
+        <if test="subid != null ">
+            and subid = #{subid}
+        </if>
+        <if test="taskid != null ">
+            and taskid = #{taskid}
+        </if>
+        <if test="currentSendTime != null ">
+            and current_send_time = #{currentSendTime}
+        </if>
+        <if test="preachform != null  and preachform != ''">
+            and preachform = #{preachform}
+        </if>
+        <if test="sendstate != null  and sendstate != ''">
+            and sendstate = #{sendstate}
+        </if>
+        <if test="orgid != null  and orgid != ''">
+            and orgid = #{orgid}
+        </if>
+        <if test="sort != null ">
+            and sort = #{sort}
+        </if>
+        <if test="compensateTime != null ">
+            and compensate_time = #{compensateTime}
+        </if>
     </select>
 
     <select id="selectServiceSubtaskPreachformById" parameterType="Long"
@@ -106,6 +111,9 @@
             </if>
             <if test="compensateTime != null">compensate_time,
             </if>
+            <if test="currentSendTime != null ">
+                current_send_time,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},
@@ -135,6 +143,9 @@
             <if test="sort != null">#{sort},
             </if>
             <if test="compensateTime != null">#{compensateTime},
+            </if>
+            <if test="currentSendTime != null ">
+                #{currentSendTime},
             </if>
         </trim>
     </insert>
@@ -180,6 +191,9 @@
             </if>
             <if test="compensateTime != null">compensate_time =
                 #{compensateTime},
+            </if>
+            <if test="currentSendTime != null ">
+                current_send_time = #{currentSendTime},
             </if>
         </trim>
         where id = #{id}
@@ -227,22 +241,25 @@
             <if test="compensateTime != null">compensate_time =
                 #{compensateTime},
             </if>
+            <if test="currentSendTime != null ">
+                current_send_time = #{currentSendTime},
+            </if>
         </trim>
         where 1=1
             <if test="subid != null">and subid =
-                #{subid}
+                #{subid},
             </if>
             <if test="taskid != null">and taskid =
-                #{taskid}
+                #{taskid},
             </if>
             <if test="preachform != null">and preachform =
-                #{preachform}
+                #{preachform},
             </if>
             <if test="remark != null">and remark =
-                #{remark}
+                #{remark},
             </if>
             <if test="orgid != null">and orgid =
-                #{orgid}
+                #{orgid},
             </if>
     </update>
 
@@ -274,7 +291,8 @@
         </foreach>
     </update>
 
-    <select id="selectBySubtask" parameterType="com.smartor.domain.ServiceSubtask" resultMap="ServiceSubtaskPreachformResult">
+    <select id="selectBySubtask" parameterType="com.smartor.domain.ServiceSubtask"
+            resultMap="ServiceSubtaskPreachformResult">
         <include refid="selectServiceSubtaskPreachformVo"/>
         WHERE del_flag = 0
         <!-- 鍏朵粬鏉′欢 -->

--
Gitblit v1.9.3