From 18f876d637cf1e9b0b264a4586e4a676a21f8166 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 13 十一月 2026 10:30:46 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml |  308 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 305 insertions(+), 3 deletions(-)

diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index c9b4b74..656298d 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -108,6 +108,11 @@
         <result property="loopCount" column="loop_count"/>
         <result property="isManuallyCalled" column="is_manually_called"/>
         <result property="campusid" column="campusid"/>
+        <result property="diagType" column="diag_type"/>
+        <!-- 2026-11锛氶噸瑕佹�ф爣璁扮紪鐮侊紙鏃ラ棿鎵嬫湳/鏃ラ棿璇婄枟/鏃犫�︼級锛屽缓浠诲姟鏃跺彇鑷� pat_med_inhosp -->
+        <result property="importanceFlagCode" column="importance_flag_code"/>
+        <!-- 2026-11锛氱偣浣嶇紪鐮侊紝寤哄瓙浠诲姟鏃跺師鏍锋嫹鑷� service_task.point_location -->
+        <result property="pointLocation" column="point_location"/>
     </resultMap>
 
     <resultMap type="com.ruoyi.task.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -243,6 +248,8 @@
                hospitaldistrictname,
                deptcode,
                deptname,
+               importance_flag_code,
+               point_location,
                stop_state,
                leavehospitaldistrictcode,
                leavehospitaldistrictname,
@@ -372,16 +379,34 @@
     <sql id="filterLeaveDimAnd">
         /* f-v3 */
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-            AND leavehospitaldistrictcode IN
+            AND (
+            leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
                 #{lvWardCodeItem}
             </foreach>
+            <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+                 杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+                 NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+                 鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+            OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+                AND hospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+                    #{lvWardCodeItem}
+                </foreach>)
+            )
         </if>
         <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
-            AND leaveldeptcode IN
+            AND (
+            leaveldeptcode IN
             <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
                 #{lvDeptCodeItem}
             </foreach>
+            OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+                AND deptcode IN
+                <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+                    #{lvDeptCodeItem}
+                </foreach>)
+            )
         </if>
     </sql>
 
@@ -422,20 +447,38 @@
                   or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
             AND (
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                (
                 leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
                     #{lvWardCodeItem}
                 </foreach>
+                <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+                     杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+                     NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+                     鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+                OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+                    AND hospitaldistrictcode IN
+                    <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+                        #{lvWardCodeItem}
+                    </foreach>)
+                )
             </if>
             <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
                       and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
                 OR
             </if>
             <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+                (
                 leaveldeptcode IN
                 <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
                     #{lvDeptCodeItem}
                 </foreach>
+                OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+                    AND deptcode IN
+                    <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+                        #{lvDeptCodeItem}
+                    </foreach>)
+                )
             </if>
             )
         </if>
@@ -672,6 +715,41 @@
         <if test="operatorNo != null  and operatorNo != ''">and operator_no = #{operatorNo}</if>
         <if test="wechat != null  and wechat != ''">and wechat = #{wechat}</if>
         <if test="hospType != null  and hospType != ''">and hosp_type = #{hospType}</if>
+        <!--
+          2026-11锛氶噸瑕佹�ф爣璁扮瓫閫夛紙瀵瑰簲 service_subtask.importance_flag_code锛屽缓浠诲姟鏃跺彇鑷�
+          pat_med_inhosp.importance_flag_code锛夈��
+            鈶� 妯$硦锛�/patItem 鐢ㄨ繖涓級  importanceFlagCode    鈫� LIKE '%鍊�%'
+               浼犮�屾棩闂淬�嶅嵆鍙懡涓�屾棩闂存墜鏈�嶃�屾棩闂磋瘖鐤椼�嶃�屾棤,鏃ラ棿鎵嬫湳銆嶅鍊艰锛�
+               浼犲畬鏁村�硷紙銆屾棩闂存墜鏈��/銆孎H0165.01銆嶏級閫�鍖栦负绮剧‘鍖归厤銆�
+            鈶� 绮剧‘澶氬��                 importanceFlagCodes 鈫� IN
+          璇ュ垪閲囬泦鏃跺氨琚嫾鎴�**鎻忚堪涓�**锛圛mportFlagEnum 鐨� desc锛夛紝澶氬�肩敤鑻辨枃閫楀彿鎷兼帴锛�
+          鎵�浠ャ�屾棩闂淬�嶈繖绫昏法鍙栧�兼煡璇㈠彧鑳介潬妯$硦锛涙弿杩颁笌 FH0165.xx 缂栫爜涓ょ鍙e緞閮芥寜鍘熷�兼瘮锛�
+          涓嶅仛鍊煎煙褰掍竴銆�
+          鈿狅笍 鍚屼竴鏉′欢蹇呴』鍚屾鍔犲埌 countByCondition锛堝垪琛� total / 鍚勭姸鎬佺粺璁¤蛋閭f潯 SQL锛夛紝
+             鍚﹀垯浼氬嚭鐜般�屽垪琛ㄧ瓫鍑� N 琛屻�佹�绘暟杩樻槸鍏ㄩ噺銆嶇殑閿欓厤銆�
+        -->
+        <if test="importanceFlagCode != null  and importanceFlagCode != ''">
+            and importance_flag_code like concat('%', #{importanceFlagCode}, '%')
+        </if>
+        <if test="importanceFlagCodes != null and importanceFlagCodes.size() > 0">
+            AND importance_flag_code IN
+            <foreach collection="importanceFlagCodes" item="impFlagItem" open="(" separator="," close=")">
+                #{impFlagItem}
+            </foreach>
+        </if>
+        <!--
+          2026-11锛氱偣浣嶇瓫閫夛紙瀵瑰簲 service_subtask.point_location锛屽缓瀛愪换鍔℃椂浠� service_task 蹇収杩囨潵锛夈��
+          鍙湁涓�鏉� IN 鏉′欢锛氬崟閫�/澶氶�夐兘鍦� ServiceSubtaskEntity#getPointLocations() 閲屽綊涓�
+          锛堝彧浼� pointLocation 浼氳嚜鍔ㄥ寘鎴愬崟鍏冪礌闆嗗悎锛夛紝鎵�浠ヤ笉鍐嶅啓绛夊�煎垎鏀��
+          鈿狅笍 鍚屼竴鏉′欢蹇呴』鍚屾鍔犲埌 countByCondition锛堝垪琛� total / 鍚勭姸鎬佺粺璁¤蛋閭f潯 SQL锛夛紝
+             鍚﹀垯浼氬嚭鐜般�屽垪琛ㄧ瓫鍑� N 琛屻�佹�绘暟杩樻槸鍏ㄩ噺銆嶇殑閿欓厤銆�
+        -->
+        <if test="pointLocations != null and pointLocations.size() > 0">
+            AND point_location IN
+            <foreach collection="pointLocations" item="pointLocItem" open="(" separator="," close=")">
+                #{pointLocItem}
+            </foreach>
+        </if>
         <if test="libtemplateid != null ">and libtemplateid = #{libtemplateid}</if>
         <if test="libtemplatename != null ">and libtemplatename = #{libtemplatename}</if>
         <if test="openid != null ">and openid = #{openid}</if>
@@ -1112,6 +1190,10 @@
             <if test="hospitaldistrictname != null  and hospitaldistrictname != ''">hospitaldistrictname,</if>
             <if test="deptcode != null  and deptcode != ''">deptcode,</if>
             <if test="deptname != null  and deptname != ''">deptname,</if>
+            <!-- 2026-11锛氶噸瑕佹�ф爣璁扮紪鐮侊紙鏃ラ棿鎵嬫湳/鏃ラ棿璇婄枟鈥︼級锛屽缓浠诲姟鏃朵粠 pat_med_inhosp 鍚屾 -->
+            <if test="importanceFlagCode != null  and importanceFlagCode != ''">importance_flag_code,</if>
+            <!-- 2026-11锛氱偣浣嶇紪鐮侊紝寤哄瓙浠诲姟鏃朵粠 service_task.point_location 鍚屾 -->
+            <if test="pointLocation != null  and pointLocation != ''">point_location,</if>
             <if test="labelstatus != null">labelstatus,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
@@ -1221,6 +1303,8 @@
             <if test="hospitaldistrictname != null  and hospitaldistrictname != ''">#{hospitaldistrictname},</if>
             <if test="deptcode != null  and deptcode != ''">#{deptcode},</if>
             <if test="deptname != null  and deptname != ''">#{deptname},</if>
+            <if test="importanceFlagCode != null  and importanceFlagCode != ''">#{importanceFlagCode},</if>
+            <if test="pointLocation != null  and pointLocation != ''">#{pointLocation},</if>
             <if test="labelstatus != null">#{labelstatus},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
@@ -1368,6 +1452,11 @@
             <if test="openid != null ">openid = #{openid},</if>
             <if test="longSendTime != null ">long_send_time = #{longSendTime},</if>
             <if test="sendstate != null ">sendstate = #{sendstate},</if>
+            <!-- 瀹屾垚鏃堕棿涓嶅彉閲忥紙2026-11锛夛細鐘舵�佷竴鏃︿笉鏄�"瀹屾垚(6)"锛屽氨鏄惧紡娓呯┖瀹屾垚鏃堕棿涓庡畬鎴愭椂鐘舵�併��
+                 涓婇潰 finishtime 閭d竴娈垫槸 if(finishtime != null)锛屼紶 null 浼氳鏁存璺宠繃锛�
+                 鎵�浠�"娓呯┖"蹇呴』鍦ㄨ繖閲岀敤 SQL 鐨� NULL 鍐欏嚭鏉ワ紱鍚﹀垯 3 宸插彂閫� / 5 鍙戦�佸け璐� / 7 瓒呮椂
+                 鐨勮浼氫竴鐩村甫鐫�鍘嗗彶瀹屾垚鏃堕棿锛�"瓒呮椂鍗存湁瀹屾垚鏃堕棿銆佸強鏃剁巼铏氶珮"灏辨槸杩欎箞鏉ョ殑锛夈�� -->
+            <if test="sendstate != null and sendstate != 6">finishtime = NULL, finish_state = NULL,</if>
             <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
             <if test="serviceType != null ">service_type = #{serviceType},</if>
             <if test="score != null ">score = #{score},</if>
@@ -1414,8 +1503,29 @@
             <if test="scheduleSeq != null ">schedule_seq = #{scheduleSeq},</if>
             <if test="loopCount != null ">loop_count = #{loopCount},</if>
             <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
+            <!-- 2026-11锛氱偣浣嶇紪鐮侊紙寤哄瓙浠诲姟鏃剁殑蹇収锛涗换鍔′笂鏀圭偣浣嶄笉浼氳嚜鍔ㄥ洖鍐欙級 -->
+            <if test="pointLocation != null  and pointLocation != ''">point_location = #{pointLocation},</if>
         </trim>
         where id = #{id}
+    </update>
+
+    <!-- 寰俊鍏紬鍙峰凡棰嗗彇鏈~鍐欐寜榛樿閫夐」瀹屾垚锛氬彧鏇存柊褰撳墠瀛愪换鍔°��
+         鏉′欢 sendstate=1 + 鏈彁浜わ紝淇濊瘉鍙鐞嗗綋鍓嶈棰嗗彇涓旀湭濉啓鐨勫瓙浠诲姟锛屼笉娉㈠強鍏朵粬浠诲姟銆� -->
+    <update id="updateWechatDefaultComplete" parameterType="com.ruoyi.task.domain.ServiceSubtask">
+        update service_subtask
+        set sendstate = 6,
+            finishtime = #{finishtime},
+            result = #{result},
+            remark = case
+                         when remark is null or remark = '' then #{remark}
+                         else concat(remark, ',', #{remark})
+                     end,
+            update_time = now(),
+            finish_state = <include refid="finishStateExpr"/>
+        where id = #{id}
+          and orgid = #{orgid}
+          and sendstate = 1
+          and (submit is null or submit != 1)
     </update>
 
     <update id="updateServiceSubtaskByPatId" parameterType="com.ruoyi.task.domain.ServiceSubtask">
@@ -1474,6 +1584,11 @@
             <if test="openid != null ">openid = #{openid},</if>
             <if test="longSendTime != null ">long_send_time = #{longSendTime},</if>
             <if test="sendstate != null ">sendstate = #{sendstate},</if>
+            <!-- 瀹屾垚鏃堕棿涓嶅彉閲忥紙2026-11锛夛細鐘舵�佷竴鏃︿笉鏄�"瀹屾垚(6)"锛屽氨鏄惧紡娓呯┖瀹屾垚鏃堕棿涓庡畬鎴愭椂鐘舵�併��
+                 涓婇潰 finishtime 閭d竴娈垫槸 if(finishtime != null)锛屼紶 null 浼氳鏁存璺宠繃锛�
+                 鎵�浠�"娓呯┖"蹇呴』鍦ㄨ繖閲岀敤 SQL 鐨� NULL 鍐欏嚭鏉ワ紱鍚﹀垯 3 宸插彂閫� / 5 鍙戦�佸け璐� / 7 瓒呮椂
+                 鐨勮浼氫竴鐩村甫鐫�鍘嗗彶瀹屾垚鏃堕棿锛�"瓒呮椂鍗存湁瀹屾垚鏃堕棿銆佸強鏃剁巼铏氶珮"灏辨槸杩欎箞鏉ョ殑锛夈�� -->
+            <if test="sendstate != null and sendstate != 6">finishtime = NULL, finish_state = NULL,</if>
             <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
             <if test="serviceType != null ">service_type = #{serviceType},</if>
             <if test="score != null ">score = #{score},</if>
@@ -1532,6 +1647,11 @@
             <if test="sex != null">sex = #{sex},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="sendstate != null ">sendstate = #{sendstate},</if>
+            <!-- 瀹屾垚鏃堕棿涓嶅彉閲忥紙2026-11锛夛細鐘舵�佷竴鏃︿笉鏄�"瀹屾垚(6)"锛屽氨鏄惧紡娓呯┖瀹屾垚鏃堕棿涓庡畬鎴愭椂鐘舵�併��
+                 涓婇潰 finishtime 閭d竴娈垫槸 if(finishtime != null)锛屼紶 null 浼氳鏁存璺宠繃锛�
+                 鎵�浠�"娓呯┖"蹇呴』鍦ㄨ繖閲岀敤 SQL 鐨� NULL 鍐欏嚭鏉ワ紱鍚﹀垯 3 宸插彂閫� / 5 鍙戦�佸け璐� / 7 瓒呮椂
+                 鐨勮浼氫竴鐩村甫鐫�鍘嗗彶瀹屾垚鏃堕棿锛�"瓒呮椂鍗存湁瀹屾垚鏃堕棿銆佸強鏃剁巼铏氶珮"灏辨槸杩欎箞鏉ョ殑锛夈�� -->
+            <if test="sendstate != null and sendstate != 6">finishtime = NULL, finish_state = NULL,</if>
             <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
             <if test="age != null">age = #{age},</if>
             <if test="sfzh != null">sfzh = #{sfzh},</if>
@@ -1645,6 +1765,11 @@
             <if test="phone != null">phone = #{phone},</if>
             <if test="sex != null">sex = #{sex},</if>
             <if test="sendstate != null ">sendstate = #{sendstate},</if>
+            <!-- 瀹屾垚鏃堕棿涓嶅彉閲忥紙2026-11锛夛細鐘舵�佷竴鏃︿笉鏄�"瀹屾垚(6)"锛屽氨鏄惧紡娓呯┖瀹屾垚鏃堕棿涓庡畬鎴愭椂鐘舵�併��
+                 涓婇潰 finishtime 閭d竴娈垫槸 if(finishtime != null)锛屼紶 null 浼氳鏁存璺宠繃锛�
+                 鎵�浠�"娓呯┖"蹇呴』鍦ㄨ繖閲岀敤 SQL 鐨� NULL 鍐欏嚭鏉ワ紱鍚﹀垯 3 宸插彂閫� / 5 鍙戦�佸け璐� / 7 瓒呮椂
+                 鐨勮浼氫竴鐩村甫鐫�鍘嗗彶瀹屾垚鏃堕棿锛�"瓒呮椂鍗存湁瀹屾垚鏃堕棿銆佸強鏃剁巼铏氶珮"灏辨槸杩欎箞鏉ョ殑锛夈�� -->
+            <if test="sendstate != null and sendstate != 6">finishtime = NULL, finish_state = NULL,</if>
             <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
             <if test="age != null">age = #{age},</if>
             <if test="sfzh != null">sfzh = #{sfzh},</if>
@@ -1806,6 +1931,9 @@
         nurse_name,
         taskid,
         task_name,
+        <if test="groupKey != null and groupKey == 'taskid'">
+            (SELECT st.diag_type FROM service_task st WHERE st.taskid = service_subtask.taskid LIMIT 1) AS diag_type,
+        </if>
         visit_time,
         visit_dept_code,
         finishtime,
@@ -1854,6 +1982,13 @@
             <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                      close=")">
                 #{deptcode}
+            </foreach>
+        </if>
+        <if test="taskIds != null and taskIds.size() > 0">
+            AND taskid IN
+            <foreach collection="taskIds" item="taskId" open="(" separator=","
+                     close=")">
+                #{taskId}
             </foreach>
         </if>
         <if test="serviceType != null and serviceType.size() > 0">
@@ -2100,6 +2235,13 @@
                 #{hospitaldeptcode}
             </foreach>
         </if>
+        <if test="taskIds != null and taskIds.size() > 0">
+            AND taskid IN
+            <foreach collection="taskIds" item="taskId" open="(" separator=","
+                     close=")">
+                #{taskId}
+            </foreach>
+        </if>
         <if test="serviceType != null and serviceType.size() > 0">
             AND service_type IN
             <foreach collection="serviceType" item="serviceType" open="(" separator=","
@@ -2173,6 +2315,8 @@
     <resultMap type="com.ruoyi.task.domain.ServiceSubtaskStatistic" id="ServiceSubtaskScriptStatisticResult">
         <result property="groupCode" column="group_code"/>
         <result property="groupName" column="group_name"/>
+        <result property="taskId" column="taskid"/>
+        <result property="taskName" column="task_name"/>
         <result property="dischargeCount" column="discharge_count"/>
         <result property="firstVisitCount" column="first_visit_count"/>
         <result property="againVisitCount" column="again_visit_count"/>
@@ -2225,7 +2369,16 @@
         <!-- 鍒嗙粍閿搴旂殑鏄剧ず鍚嶏細鐥呭尯缁熻鏃跺氨鏄繖涓�缁勭殑鐥呭尯鍚嶃��
              浠ュ墠杩欎竴鍒楁槸 MAX(hospitaldistrictname)锛屼竴涓粍娣蜂簡澶氫釜鐥呭尯鏃朵細闅忔満鏄剧ず鍏朵腑涓�涓紝
              浜庢槸鍑虹幇鈥滈�夎娑插唴绉戠梾鍖哄嵈鏄剧ず楠ㄧ涓績涓夌梾鍖衡�濄�� -->
-        MAX(IFNULL(leavehospitaldistrictname, hospitaldistrictname)) as group_name,
+        <choose>
+            <when test="groupKey != null and groupKey == 'taskid'">
+                MAX(task_name) as group_name,
+            </when>
+            <otherwise>
+                MAX(IFNULL(leavehospitaldistrictname, hospitaldistrictname)) as group_name,
+            </otherwise>
+        </choose>
+        MAX(taskid) as taskid,
+        MAX(task_name) as task_name,
         MAX(drcode) as drcode,
         MAX(drname) as drname,
         MAX(leaveldeptcode) as deptcode,
@@ -3103,6 +3256,136 @@
         group by a.script_content, ss.type, IFNULL(ssd.matchedtext,ssd.asrtext)
     </select>
 
+    <!--
+      闂閫夐」鏁板瓧涓嬮捇锛氳繑鍥為�夋嫨浜嗘寚瀹氶�夐」鐨� service_subtask 鍒楄〃銆�
+      杩囨护鍙e緞涓� getSfStatisticsScriptDetails / getSfStatisticsScriptItemDetails 淇濇寔涓�鑷达紝
+      棰濆鏀寔 statisticaltype锛�1-鐥呭尯銆�2-绉戝銆�3-鐥呯銆�
+    -->
+    <select id="getSfStatisticsScriptDetailsHyperlink" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
+            resultMap="ServiceSubtaskResult">
+        SELECT ss.*
+        FROM service_subtask ss
+        WHERE ss.del_flag = 0
+        <if test="orgid != null and orgid != ''">
+            AND ss.orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            AND ss.campusid = #{campusid}
+        </if>
+        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            AND ss.leavehospitaldistrictcode IN
+            <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                     close=")">
+                #{leavehospitaldistrictcode}
+            </foreach>
+        </if>
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND ss.deptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+        <if test="serviceType != null and serviceType.size() > 0">
+            AND ss.service_type IN
+            <foreach collection="serviceType" item="serviceType" open="(" separator="," close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            AND ss.visit_time >= DATE(#{startTime})
+            AND ss.visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+        </if>
+        <if test="type != null and type != ''">
+            AND ss.type = #{type}
+        </if>
+
+        <!-- 缁熻缁村害锛�1-鎸夌梾鍖� 2-鎸夌瀹� 3-鎸塼askid -->
+        <if test="statisticaltype != null and statisticaltype == 1">
+            <choose>
+                <when test="deptcode != null and deptcode != ''">
+                    AND ss.leavehospitaldistrictcode = #{deptcode}
+                </when>
+                <when test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+                    AND ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+                </when>
+            </choose>
+        </if>
+        <if test="statisticaltype != null and statisticaltype == 2 and deptcode != null and deptcode != ''">
+            AND ss.deptcode = #{deptcode}
+        </if>
+        <if test="statisticaltype != null and statisticaltype == 3 and taskId != null">
+            AND ss.taskid = #{taskId}
+        </if>
+        <!-- 鍏煎涓嶄紶 statisticaltype 鏃舵寜鍗曞�兼潯浠惰繃婊� -->
+        <if test="statisticaltype == null">
+            <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+                AND ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+            </if>
+            <if test="deptcode != null and deptcode != ''">
+                AND ss.deptcode = #{deptcode}
+            </if>
+            <if test="taskId != null">
+                AND ss.taskid = #{taskId}
+            </if>
+        </if>
+
+        <!-- 棰樼洰 + 閫夐」鍖归厤锛氬彧淇濈暀鍥炵瓟涓�夋嫨浜嗚閫夐」鐨勫瓙浠诲姟 -->
+        AND EXISTS (
+            SELECT 1
+            FROM service_subtask_detail ssd
+            WHERE ssd.sub_id = ss.id
+              AND ssd.del_flag = 0
+            <if test="configValue != null and configValue != ''">
+                AND ssd.categoryid IN (${configValue})
+            </if>
+            <choose>
+                <when test="optionText != null">
+                    AND IFNULL(ssd.matchedtext, ssd.asrtext) = #{optionText}
+                </when>
+                <otherwise>
+                    AND 1 = 0
+                </otherwise>
+            </choose>
+            <choose>
+                <!-- 浼樺厛鎸夐鐩唴瀹瑰尮閰嶏細鍚屼竴閬撻澶嶅埗鍒板涓换鍔℃ā鏉挎椂 scriptid 涓嶅悓锛屼絾 script_content 鐩稿悓 -->
+                <when test="scriptContent != null and scriptContent != ''">
+                    AND ssd.scriptid IN (
+                        <choose>
+                            <when test="type == '1'">
+                                SELECT its.id FROM ivr_task_template_script its
+                                WHERE its.script_content = #{scriptContent}
+                            </when>
+                            <when test="type == '2'">
+                                SELECT sts.id FROM svy_task_template_script sts
+                                WHERE sts.script_content = #{scriptContent}
+                            </when>
+                            <otherwise>
+                                SELECT its.id FROM ivr_task_template_script its
+                                WHERE its.script_content = #{scriptContent}
+                                UNION
+                                SELECT sts.id FROM svy_task_template_script sts
+                                WHERE sts.script_content = #{scriptContent}
+                            </otherwise>
+                        </choose>
+                    )
+                </when>
+                <when test="scriptid != null">
+                    AND ssd.scriptid = #{scriptid}
+                </when>
+                <otherwise>
+                    AND 1 = 0
+                </otherwise>
+            </choose>
+        )
+        ORDER BY ss.endtime DESC, ss.id DESC
+        <if test="pageSize != null and pageSize > 0">
+            LIMIT #{pageSize}
+            <if test="pageNum != null and pageNum >= 0">
+                OFFSET #{pageNum}
+            </if>
+        </if>
+    </select>
+
     <select id="getDataByTime" resultMap="ServiceSubtaskResult">
 
         select id,
@@ -3429,6 +3712,25 @@
         <if test="sendname != null and sendname != ''">
             AND sendname LIKE CONCAT('%', #{sendname}, '%')
         </if>
+        <!--
+          2026-11锛氶噸瑕佹�ф爣璁版ā绯婄瓫閫� 鈥斺�� 蹇呴』涓� serviceSubtaskWhere 閲岀殑鍚屽悕鏉′欢銆愬畬鍏ㄤ竴鑷淬�戯紝
+          鍚﹀垯 /patItem 鐨勫垪琛ㄤ笌 total/鍚勭姸鎬佺粺璁′細閿欓厤锛堝垪琛ㄧ瓫浜嗐�佹�绘暟娌$瓫锛夈��
+          鍙e緞瑙� serviceSubtaskWhere 澶勭殑娉ㄩ噴銆�
+        -->
+        <if test="importanceFlagCode != null  and importanceFlagCode != ''">
+            AND importance_flag_code LIKE CONCAT('%', #{importanceFlagCode}, '%')
+        </if>
+        <!--
+          2026-11锛氱偣浣嶇瓫閫� 鈥斺�� 蹇呴』涓� serviceSubtaskWhere 閲岀殑鍚屽悕鏉′欢銆愬畬鍏ㄤ竴鑷淬�戯紝
+          鍚﹀垯 /patItem 鐨勫垪琛ㄤ笌 total/鍚勭姸鎬佺粺璁′細閿欓厤锛堝垪琛ㄧ瓫浜嗐�佹�绘暟娌$瓫锛夈��
+          鍗曢��/澶氶�夊綊涓�鍦� ServiceSubtaskEntity#getPointLocations()锛岃繖閲屽彧鏈変竴鏉� IN銆�
+        -->
+        <if test="pointLocations != null and pointLocations.size() > 0">
+            AND point_location IN
+            <foreach collection="pointLocations" item="pointLocItem" open="(" separator="," close=")">
+                #{pointLocItem}
+            </foreach>
+        </if>
         <if test="phone != null and phone != ''">
             AND phone = #{phone}
         </if>

--
Gitblit v1.9.3