From d963031435c593b761436d819268f5493923c41d Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 22 九月 2026 18:37:52 +0800
Subject: [PATCH] 1.导出新增图表

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 1603d17..e5ae35f 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -3258,6 +3258,13 @@
                 #{taskId}
             </foreach>
         </if>
+        <!-- 浼犱簡 subtaskIds 鍙粺璁¤繖鎵瑰瓙浠诲姟锛堟湰娆″鍑虹殑鎮h�咃級 -->
+        <if test="subtaskIds != null and subtaskIds.size() > 0">
+            AND s.id IN
+            <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+                #{subtaskId}
+            </foreach>
+        </if>
         <if test="valueType != null">AND d.value_type = #{valueType}</if>
         <if test="scoreStart != null">AND d.score &gt;= #{scoreStart}</if>
         <if test="scoreEnd != null">AND d.score &lt;= #{scoreEnd}</if>
@@ -3266,6 +3273,19 @@
         </if>
         and s.sendstate=6
         and d.del_flag=0
+        <!-- 鍒嗘瘝蹇呴』鍜屾槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃堕棿鑼冨洿鍚庢瘮渚嬩細鎸夊叏閲忓巻鍙茶绋�閲� -->
+        <if test="startOutHospTime != null">
+            AND date_format(s.endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
+        </if>
+        <if test="endOutHospTime != null">
+            AND date_format(s.endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
+        </if>
+        <if test="startFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &gt;= date_format(#{startFinishTime},'%y%m%d')
+        </if>
+        <if test="endFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &lt;= date_format(#{endFinishTime},'%y%m%d')
+        </if>
         GROUP BY
         t.taskid,
         d.questiontext
@@ -3275,6 +3295,12 @@
             AND t.taskid IN
             <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
                 #{taskId}
+            </foreach>
+        </if>
+        <if test="subtaskIds != null and subtaskIds.size() > 0">
+            AND s.id IN
+            <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+                #{subtaskId}
             </foreach>
         </if>
         <if test="valueType != null">AND d.value_type = #{valueType}</if>
@@ -3309,6 +3335,64 @@
         t.taskid
     </select>
 
+    <!--
+      瀵煎嚭銆岄棶棰樿鎯呭崰姣斻�嶄笓鐢ㄧ粺璁★紙鍙粺璁℃湰娆″鍑虹殑杩欐壒鎮h�咃級
+      鏁伴噺 = 閫夋嫨璇ラ�夐」鐨勬偅鑰呮暟锛圕OUNT(DISTINCT s.id)锛屽苟鐢� MAX(id) 淇濊瘉鍚屼竴鎮h�呭悓涓�棰樺彧绠楁渶鏂颁竴鏉★級
+      鍒嗘暟 = 璇ラ�夐」鏄庣粏鐨� score 涔嬪拰
+      姣斾緥 = 鏁伴噺 / 璇ラ浣滅瓟鎮h�呮暟锛屽湪 Java 渚х粺涓�璁$畻锛屽洜姝ゃ�屽崟棰樺悇閫夐」鏁伴噺涔嬪拰 = 璇ラ浣滅瓟鎮h�呮暟銆�
+    -->
+    <select id="statMydQuestionOptionForExport" resultType="com.smartor.domain.DTO.ServiceSubtaskOptionStatDTO">
+        SELECT
+        t.taskid AS taskid,
+        t.task_name AS taskName,
+        d.questiontext AS questiontext,
+        d.asrtext AS optionresult,
+        d.targetvalue AS targetvalue,
+        d.value_type AS valueType,
+        COUNT(DISTINCT s.id) AS patientCount,
+        SUM(COALESCE(CAST(d.score AS DECIMAL(18,2)), 0)) AS scoreSum
+        FROM
+        service_task t
+        INNER JOIN service_subtask s ON s.taskid = t.taskid
+        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+        WHERE 1=1
+        AND s.del_flag = '0'
+        AND d.del_flag = 0
+        <if test="subtaskIds != null and subtaskIds.size() > 0">
+            AND s.id IN
+            <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+                #{subtaskId}
+            </foreach>
+        </if>
+        <!-- 涓嶄紶瀛愪换鍔℃椂鐩存帴鏌ヤ笉鍒版暟鎹紝閬垮厤璇粺璁″叏閲� -->
+        <if test="subtaskIds == null or subtaskIds.size() == 0">
+            AND 1 = 0
+        </if>
+        <if test="questiontext != null and questiontext != ''">
+            AND d.questiontext LIKE CONCAT('%', #{questiontext}, '%')
+        </if>
+        <!-- 鍚屼竴鎮h�呭悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閲嶇瓟涓嶉噸澶嶈鍏ユ暟閲� -->
+        AND d.id = (
+        SELECT MAX(d2.id)
+        FROM service_subtask_detail d2
+        WHERE d2.sub_id = d.sub_id
+        AND d2.questiontext &lt;=&gt; d.questiontext
+        AND d2.del_flag = '0'
+        )
+        GROUP BY
+        t.taskid,
+        t.task_name,
+        d.questiontext,
+        d.asrtext,
+        d.targetvalue,
+        d.value_type
+        <!-- 鎸変换鍔″悕绉板垎缁勫睍绀猴細鍏堜换鍔″悕绉般�佸啀浠诲姟缂栧彿锛屽悓涓�浠诲姟鐨勯鐩�/閫夐」杩炵画鎺掑垪 -->
+        ORDER BY
+        t.task_name,
+        t.taskid,
+        d.questiontext
+    </select>
+
     <!-- 鏂版柟娉曪細鏍规嵁瀛愪换鍔� ID 缁熻闂閫夐」鐧惧垎姣� (鐢ㄤ簬婊℃剰搴︾粺璁� serviceType=6) -->
     <select id="statQuestionOptionBySubtaskIds" resultType="com.smartor.domain.ServiceSubtaskDetailRatioExport">
         SELECT

--
Gitblit v1.9.3