From a2dd5b42824eff9626d1f48e1561be85f17f6107 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 23 十月 2026 16:36:19 +0800
Subject: [PATCH] 【丽水】指标统计查看详情里面问题重复了,本来应该只有3条,里面18条

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 1948988..d9513ec 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -255,7 +255,7 @@
         from service_subtask
     </sql>
 
-    <!-- 瀹屾垚鏃剁姸鎬�(finish_state)璁$畻锛氫粎褰撴湰娆℃洿鏂版妸 sendstate 缃负 6锛堥殢璁垮畬鎴愶級鏃朵娇鐢ㄣ��
+    <!-- 瓒呮椂瀹屾垚銆佸欢鏈熷畬鎴愰�昏緫 瀹屾垚鏃剁姸鎬�(finish_state)璁$畻锛氫粎褰撴湰娆℃洿鏂版妸 sendstate 缃负 6锛堥殢璁垮畬鎴愶級鏃朵娇鐢ㄣ��
          鍩哄噯鎴鏃堕棿 base = endtime + send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紝
          涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
          delay = COALESCE(service_task.delay_finish_days, 0)锛�
@@ -1681,6 +1681,7 @@
         continue_count,
         continue_time_next,
         task_situation,
+        finish_state,
         is_manually_called
         from service_subtask
         where 1=1
@@ -1970,6 +1971,7 @@
         task_situation,
         remark,
         doctor_opinion,
+        finish_state,
         is_manually_called
         from service_subtask
         where 1=1
@@ -2051,6 +2053,9 @@
         </if>
         <if test="taskSituation != null">
             AND task_situation = #{taskSituation}
+        </if>
+        <if test="finishState != null">
+            AND finish_state = #{finishState}
         </if>
         <if test="drcode != null and drcode != ''">
             AND drcode = #{drcode}
@@ -2276,14 +2281,14 @@
     <select id="getSfStatisticsScriptDetails" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultMap="ServiceSubtaskScriptCountResult">
         SELECT
-        a.id as scriptid,
-        a.templateid as templateid,
-        a.script_type,
+        MIN(a.id) as scriptid,
+        MIN(a.templateid) as templateid,
+        MIN(a.script_type) as script_type,
         a.script_content,
         b.subtask_type,
-        b.completed_quantity,
-        b.all_quantity,
-        ROUND(b.completed_quantity/b.all_quantity,2) as completed_percentage
+        SUM(b.completed_quantity) as completed_quantity,
+        SUM(b.all_quantity) as all_quantity,
+        ROUND(SUM(b.completed_quantity)/SUM(b.all_quantity),2) as completed_percentage
         FROM
         <if test="type == 1">
             ivr_task_template_script a
@@ -2346,25 +2351,37 @@
         group by ssd.scriptid) b
         ON a.id = b.scriptid
         <!-- 閫傜敤鍗曟潯鏌ヨ -->
-        <if test="scriptids != null">
+        <if test="scriptids != null and scriptids != ''">
             AND a.scriptid in
             (SELECT lib_script.scriptid FROM
             svy_lib_template_script lib_script
             WHERE lib_script.scriptid in (${scriptids}))
         </if>
+        <!-- 鍚屼竴閬撻浼氳澶嶅埗鍒板涓换鍔℃ā鏉匡紝鎸夐鐩唴瀹瑰悎骞讹紝淇濊瘉涓�閬撻鍙繑鍥炰竴鏉� -->
+        GROUP BY a.script_content, b.subtask_type
+        ORDER BY MIN(a.id)
     </select>
 
     <select id="getSfStatisticsScriptItemDetails" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultMap="ServiceSubtaskScriptCountResult">
         SELECT
-        ssd.scriptid,
+        a.script_content,
+        ss.type as subtask_type,
         IFNULL(ssd.matchedtext,ssd.asrtext) AS option_text,
         COUNT(*) AS chosen_quantity
         FROM
         service_subtask_detail ssd
         INNER JOIN service_subtask ss ON ssd.sub_id = ss.id
+        INNER JOIN
+        <if test="type == 1">
+            ivr_task_template_script a ON a.id = ssd.scriptid
+        </if>
+        <if test="type == 2">
+            svy_task_template_script a ON a.id = ssd.scriptid
+        </if>
         where 1=1
         and ss.del_flag=0
+        and ssd.del_flag=0
         <if test="orgid != null and orgid != ''">
             and ss.orgid = #{orgid}
         </if>
@@ -2403,7 +2420,7 @@
         <if test="configValue != null and configValue != ''">
             AND ssd.categoryid IN (${configValue})
         </if>
-        group by ssd.scriptid, IFNULL(ssd.matchedtext,ssd.asrtext)
+        group by a.script_content, ss.type, IFNULL(ssd.matchedtext,ssd.asrtext)
     </select>
 
     <select id="getDataByTime" resultMap="ServiceSubtaskResult">

--
Gitblit v1.9.3