From b1b1b15bbf4fd5a4ed21efa91279227fc915e960 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 16 十一月 2026 16:35:48 +0800
Subject: [PATCH] 【丽水】JOIN报错调整

---
 ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml |  293 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 241 insertions(+), 52 deletions(-)

diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index 89625bb..93d3c3d 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -109,6 +109,10 @@
         <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">
@@ -244,6 +248,8 @@
                hospitaldistrictname,
                deptcode,
                deptname,
+               importance_flag_code,
+               point_location,
                stop_state,
                leavehospitaldistrictcode,
                leavehospitaldistrictname,
@@ -267,50 +273,84 @@
     </sql>
 
     <!-- 瓒呮椂瀹屾垚銆佸欢鏈熷畬鎴愰�昏緫 瀹屾垚鏃剁姸鎬�(finish_state)璁$畻锛氫粎褰撴湰娆℃洿鏂版妸 sendstate 缃负 6锛堥殢璁垮畬鎴愶級鏃朵娇鐢ㄣ��
-         鍩哄噯鎴鏃堕棿 base = endtime + send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紝
-         涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
+         鍩哄噯鎴鏃堕棿 base锛�
+           闈炰换鍔$粍(appltype != 5)锛歟ndtime + send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紱
+           浠诲姟缁�(appltype = 5)锛氭寜 schedule_benchmark 瑙f瀽鍩哄噯鏃堕棿
+                                   (1-鍏ラ櫌 2-鍑洪櫌 3-灏辫瘖 4-鍏ョ粍 0/鍏跺畠-鑷畾涔夋椂闂�)
+                                   + day_offset + (危 compensate_time + 1) 澶╋紙涓嶅彔鍔� send_day锛夛紱
+         涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline銆乻electTimelyRateBatch 鍙e緞淇濇寔涓�鑷达紱
          delay = COALESCE(service_task.delay_finish_days, 0)锛�
          finish_time = COALESCE(鍏ュ弬 finishtime, 搴撲腑 finishtime, NOW())锛�
            finish_time <= base                                    -> 1 姝e父瀹屾垚
            delay > 0 涓� finish_time <= base + delay               -> 2 寤舵湡瀹屾垚
            鍏朵綑锛堝惈 delay 涓� 0 鎴� NULL銆佹垨宸茶秴鍑哄欢鏈熺獥鍙o級          -> 3 瓒呮椂瀹屾垚
          finishtime 涓虹┖鏃剁敤 NOW() 鍏滃簳锛屼繚璇佸畬鎴愭椂涓�瀹氬啓鍏ョ姸鎬侊紱
-         浠呭綋 endtime 涓虹┖瀵艰嚧鏃犳硶璁$畻鏃舵墠淇濇寔鍘熷�间笉瑕嗙洊銆� -->
-    <sql id="finishStateExpr">
+         base 涓虹┖锛坋ndtime / schedule / day_offset 缂哄け锛夋椂淇濇寔鍘熷�间笉瑕嗙洊銆� -->
+    <!-- 2026-11-16 淇锛�
+         MySQL 鐨� JOIN ... ON 鍙兘寮曠敤褰撳墠 JOIN 閲屽嚭鐜拌繃鐨勮〃锛屼笉鑳藉紩鐢ㄥ灞� UPDATE 鐨�
+         service_subtask锛涘師鍐欐硶 ON st.taskid = service_subtask.taskid 浼氭姤
+         Unknown column 'service_subtask.taskid' in 'on clause'銆�
+         鐩稿叧鏍囬噺瀛愭煡璇㈢殑 WHERE 鍙互姝e父寮曠敤澶栧眰 UPDATE 琛岋紝鎵�浠ユ妸涓夊紶鍏宠仈琛ㄦ敼鎴�
+         鏍囬噺瀛愭煡璇紱鍏宠仈涓嶅埌鏃惰繑鍥� NULL锛屼笌鍘熷厛 LEFT JOIN 鏈懡涓殑缁撴灉涓�鑷淬��
+         LIMIT 1 浠呯敤浜庡吋瀹� taskid / schedule_id 鐞嗚涓婁笉鍞竴鐨勫巻鍙叉暟鎹�� -->
+    <sql id="finishDeadlineExpr">
+        DATE_ADD(
         CASE
-        WHEN service_subtask.endtime IS NULL THEN finish_state
+            WHEN COALESCE((SELECT st.appltype
+                           FROM service_task st
+                           WHERE st.taskid = service_subtask.taskid
+                           LIMIT 1), '') = '5' THEN
+                DATE_ADD(
+                CASE (SELECT sts.schedule_benchmark
+                      FROM service_task_schedule sts
+                      WHERE sts.id = service_subtask.schedule_id
+                      LIMIT 1)
+                    WHEN 1 THEN service_subtask.starttime
+                    WHEN 2 THEN service_subtask.endtime
+                    WHEN 3 THEN service_subtask.admindate
+                    WHEN 4 THEN service_subtask.create_time
+                    ELSE (SELECT sts.schedule_benchmark_custom_time
+                          FROM service_task_schedule sts
+                          WHERE sts.id = service_subtask.schedule_id
+                          LIMIT 1)
+                END,
+                INTERVAL (SELECT std.day_offset
+                          FROM service_task_schedule_detail std
+                          WHERE std.id = service_subtask.schedule_detail_id
+                          LIMIT 1) DAY)
+            ELSE
+                DATE_ADD(service_subtask.endtime,
+                         INTERVAL COALESCE((SELECT st.send_day
+                                           FROM service_task st
+                                           WHERE st.taskid = service_subtask.taskid
+                                           LIMIT 1), 1) DAY)
+        END,
+        INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED))
+        FROM service_subtask_preachform pf
+        WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY)
+    </sql>
+
+    <sql id="finishStateExpr">
+        COALESCE(
+        CASE
+        WHEN <include refid="finishDeadlineExpr"/> IS NULL THEN NULL
         WHEN COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW())
-        &lt;= DATE_ADD(
-        DATE_ADD(
-        service_subtask.endtime,
-        INTERVAL COALESCE((SELECT st.send_day FROM service_task st
-        WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY
-        ),
-        INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED))
-        FROM service_subtask_preachform pf
-        WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY
-        )
+        &lt;= <include refid="finishDeadlineExpr"/>
         THEN 1
-        WHEN COALESCE((SELECT st.delay_finish_days FROM service_task st
-        WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) &gt; 0
+        WHEN COALESCE((SELECT st.delay_finish_days
+                       FROM service_task st
+                       WHERE st.taskid = service_subtask.taskid
+                       LIMIT 1), 0) &gt; 0
         AND COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW())
-        &lt;= DATE_ADD(
-        DATE_ADD(
-        DATE_ADD(
-        service_subtask.endtime,
-        INTERVAL COALESCE((SELECT st.send_day FROM service_task st
-        WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY
-        ),
-        INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED))
-        FROM service_subtask_preachform pf
-        WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY
-        ),
-        INTERVAL COALESCE((SELECT st.delay_finish_days FROM service_task st
-        WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) DAY
-        )
+        &lt;= DATE_ADD(<include refid="finishDeadlineExpr"/>,
+        INTERVAL COALESCE((SELECT st.delay_finish_days
+                           FROM service_task st
+                           WHERE st.taskid = service_subtask.taskid
+                           LIMIT 1), 0) DAY)
         THEN 2
         ELSE 3
         END
+        , finish_state)
     </sql>
 
     <!-- 褰撳墠鎵ц鏂瑰紡锛氶娆¢殢璁� current_preachform 涓虹┖鏃讹紝鍙� preachform 鐨勭涓�涓墽琛屾柟寮忓厹搴� -->
@@ -373,16 +413,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>
 
@@ -423,20 +481,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>
@@ -673,6 +749,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>
@@ -940,26 +1051,57 @@
         </if>
         SUM(CASE WHEN ss.finishtime IS NOT NULL AND DATE(ss.visit_time) &lt;= DATE(ss.finishtime) THEN 1 ELSE 0 END) /
         COUNT(*) AS finishRate,
-        <if test="rateDay != null">
-            SUM(CASE WHEN ss.finishtime IS NOT NULL
-            AND DATEDIFF(ss.finishtime, ss.endtime) &lt;= #{rateDay} + COALESCE(cp.compensate_days, 0)
-            THEN 1 ELSE 0 END) / COUNT(*) AS rate
-        </if>
-        <if test="rateDay == null">
-            NULL AS rate
-        </if>
+        <!-- 鍙婃椂鐜囧熀鍑嗭細
+             1) 闈炰换鍔$粍(appltype != 5)锛歟ndtime + send_day(缂虹渷1) + 危琛ュ伩澶╂暟 + 1 澶╋紱
+             2) 浠诲姟缁�(appltype = 5)锛氭寜 schedule_benchmark 瑙f瀽鍩哄噯鏃堕棿
+                (1-鍏ラ櫌鏃堕棿 2-鍑洪櫌鏃堕棿 3-灏辫瘖鏃堕棿 4-鍏ョ粍鏃堕棿 0/鍏跺畠-鑷畾涔夋椂闂�)
+                + day_offset + 危琛ュ伩澶╂暟 + 1 澶╋紙涓嶅啀鍙犲姞 send_day锛夛紱
+             瀹屾垚鏃堕棿 finishtime <= 鍩哄噯鏃堕棿璁′负鍙婃椂锛屽垎姣嶄粛涓哄簲闅忚鏁般��
+             琛ュ伩澶╂暟鍙彇 service_subtask_preachform.compensate_time 鐨勬眹鎬诲�间竴娆★紝
+             閬垮厤涓庤ˉ鍋挎槑缁嗙浉鍔犻�犳垚閲嶅琛ュ伩鎴栦竴瀵瑰鏀惧ぇ鍒嗘瘝銆� -->
+        SUM(CASE
+            WHEN ss.finishtime IS NOT NULL
+             AND COALESCE(st.appltype, '') != '5'
+             AND ss.endtime IS NOT NULL
+             AND ss.finishtime &lt;= DATE_ADD(
+                   DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+                   INTERVAL (COALESCE(cp.compensate_days, 0) + 1) DAY)
+            THEN 1
+            WHEN ss.finishtime IS NOT NULL
+             AND st.appltype = '5'
+             AND std.day_offset IS NOT NULL
+             AND ss.finishtime &lt;= DATE_ADD(
+                   DATE_ADD(
+                       CASE sts.schedule_benchmark
+                         WHEN 1 THEN ss.starttime
+                         WHEN 2 THEN ss.endtime
+                         WHEN 3 THEN ss.admindate
+                         WHEN 4 THEN ss.create_time
+                         ELSE sts.schedule_benchmark_custom_time
+                       END, INTERVAL std.day_offset DAY),
+                   INTERVAL (COALESCE(cp.compensate_days, 0) + 1) DAY)
+            THEN 1
+            ELSE 0
+        END) / COUNT(*) AS rate
         FROM service_subtask ss
-        <if test="rateDay != null">
-            <!-- 琛ュ伩鏃堕棿锛氬厛鎸夊瓙浠诲姟鑱氬悎鎴愪竴琛屽啀鍏宠仈锛岄伩鍏嶄竴瀵瑰鏀惧ぇ COUNT(*) 鍒嗘瘝銆�
-                 compensate_time 鏄� varchar 涓斿彲鑳藉瓨鎴愮┖涓诧紝闇�鍏堢疆绌哄啀杞暟瀛� -->
-            LEFT JOIN (
-            SELECT subid,
-            SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
-            FROM service_subtask_preachform
-            WHERE del_flag = 0
-            GROUP BY subid
-            ) cp ON cp.subid = ss.id
-        </if>
+        <!-- 杩欓噷鎸� taskid / 鍘嗗彶 schedule 蹇収鍏宠仈锛屼笉鎸� del_flag 杩囨护锛�
+             浠诲姟鎴栬鍒掕缂栬緫鍚庢棫 schedule/detail 浼氱疆涓� del_flag=1锛�
+             浣嗗巻鍙� subtask 浠嶅紩鐢ㄦ棫 ID锛岃繃婊や細涓㈠け鍘嗗彶鍙婃椂鐜囧熀鍑嗐�� -->
+        LEFT JOIN service_task st
+               ON st.taskid = ss.taskid
+        LEFT JOIN service_task_schedule sts
+               ON sts.id = ss.schedule_id
+        LEFT JOIN service_task_schedule_detail std
+               ON std.id = ss.schedule_detail_id
+        <!-- 琛ュ伩鏃堕棿锛氬厛鎸夊瓙浠诲姟鑱氬悎鎴愪竴琛屽啀鍏宠仈锛岄伩鍏嶄竴瀵瑰鏀惧ぇ COUNT(*) 鍒嗘瘝銆�
+             compensate_time 鏄� varchar 涓斿彲鑳藉瓨鎴愮┖涓诧紝闇�鍏堢疆绌哄啀杞暟瀛� -->
+        LEFT JOIN (
+        SELECT subid,
+        SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+        FROM service_subtask_preachform
+        WHERE del_flag = 0
+        GROUP BY subid
+        ) cp ON cp.subid = ss.id
         WHERE ss.del_flag = 0
         AND ss.visit_time IS NOT NULL
         AND ss.sendstate != 4
@@ -1113,6 +1255,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>
@@ -1222,6 +1368,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>
@@ -1369,6 +1517,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>
@@ -1415,6 +1568,8 @@
             <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>
@@ -1494,6 +1649,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>
@@ -1552,6 +1712,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>
@@ -1665,6 +1830,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>
@@ -3607,6 +3777,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