From 44f9b71dc492f1e60f33d18bc8d3c619da44618e Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 24 十一月 2026 17:19:26 +0800
Subject: [PATCH] Merge branch 'smartor_ls_merge' into 20261118市一随访

---
 ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml |   80 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index 93d3c3d..fbf683c 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -358,6 +358,17 @@
         COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1)))
     </sql>
 
+    <!-- 绱鍙戦�佹柟寮忕粺璁$敤锛氬綊涓�鍖� preachform 椤哄簭锛堝幓绌烘牸銆佺粺涓�涓枃閫楀彿锛� -->
+    <sql id="normalizedPreachformExpr">
+        REPLACE(REPLACE(IFNULL(preachform, ''), ' ', ''), '锛�', ',')
+    </sql>
+
+    <!-- 绱鍙戦�佹柟寮忕粺璁$敤锛氬綊涓�鍖栧悗鐨勬湁鏁� current_preachform锛堜负绌烘椂鍙� preachform 绗竴涓級 -->
+    <sql id="normalizedEffectiveCurrentPreachformExpr">
+        COALESCE(NULLIF(TRIM(current_preachform), ''),
+                 TRIM(SUBSTRING_INDEX(<include refid="normalizedPreachformExpr"/>, ',', 1)))
+    </sql>
+
     <select id="selectServiceSubtaskBySendstate" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
@@ -2130,10 +2141,28 @@
         where 1=1
         and a.del_flag = '0'
         and b.del_flag = '0'
-        and a.appltype = '3'
+        <!-- 涓撶梾缁熻锛氬崟鐥呯浠诲姟(appltype=3) + 涓撶梾浠诲姟缁�(appltype=5) -->
+        and (
+            a.appltype = '3'
+            or (
+                a.appltype = '5'
+                and (
+                    a.hosp_type = '3'
+                    or (a.diag_type is not null and a.diag_type &lt;&gt; '')
+                    or exists (
+                        select 1
+                        from service_task_schedule s
+                        where s.taskid = a.taskid
+                          and s.del_flag = '0'
+                          and s.icd10_codes is not null
+                          and s.icd10_codes &lt;&gt; ''
+                    )
+                )
+            )
+        )
         <if test="orgid != null and orgid != ''">and a.orgid = #{orgid}</if>
         <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if>
-        <if test="taskId != null">and a.task_id = #{taskId}</if>
+        <if test="taskId != null">and a.taskid = #{taskId}</if>
         <if test="taskName != null and taskName != ''">
             and a.task_name like concat('%', #{taskName}, '%')
         </if>
@@ -2141,7 +2170,7 @@
             and a.diag_type = #{diagType}
         </if>
         <if test="taskIds != null and taskIds.size() > 0">
-            AND a.task_id IN
+            AND a.taskid IN
             <foreach collection="taskIds" item="taskIdItem" open="(" separator=","
                      close=")">
                 #{taskIdItem}
@@ -2873,9 +2902,52 @@
         </if>
         <if test="currentPreachform != null and currentPreachform != '' ">
             AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform}
-            <if test="followUpCountStyle != null and followUpCountStyle = '1'">
+            <!-- 娉ㄦ剰锛歄GNL 閲屽崟寮曞彿 '1' 鏄� Character锛孲tring 涓庝箣鐢� = 姣旇緝浼氬緱鍒伴潪 0 鏁板瓧锛堟亽鐪燂級锛屽繀椤荤敤 =="1" -->
+            <if test='followUpCountStyle != null and followUpCountStyle == "1"'>
                 AND sendstate != 4
             </if>
+            <if test='followUpCountStyle != null and followUpCountStyle == "3"'>
+                AND sendstate = 6
+            </if>
+        </if>
+        <!--
+          绱鍙戦�佹柟寮忎笅閽伙細
+          preachform 鏄墽琛岄『搴忥紙濡� 3,5,4,1锛夛紝current_preachform 鏄綋鍓嶆墽琛屽埌鐨勪綅缃��
+          鑻ヨ鍦ㄢ�滆闊斥�濅笅閽伙紝鍒� current 浣嶄簬璇煶鍙婁箣鍚庣殑鎵�鏈夎閮借杩斿洖銆�
+          浠ヤ笅鏉′欢涓� ServiceSubtaskServiceImpl#applyFirstCumulativePreachformStatistics 鍙e緞涓�鑷达細
+            current 涓虹┖   -> 鎸� preachform 绗竴涓柟寮�
+            current = -1   -> 鎸夋渶鍚庝竴涓綅缃紙鍏ㄩ儴鏂瑰紡閮借繘鍏ヨ繃锛�
+            current 涓嶅湪椤哄簭涓� -> 鍙仛绮剧‘鍖归厤鍏滃簳
+        -->
+        <if test="cumulativePreachform != null and cumulativePreachform != ''">
+            AND (
+                CASE
+                    WHEN <include refid="normalizedPreachformExpr"/> = '' THEN
+                        <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform}
+
+                    WHEN <include refid="normalizedEffectiveCurrentPreachformExpr"/> = '-1' THEN
+                        FIND_IN_SET(#{cumulativePreachform},
+                            <include refid="normalizedPreachformExpr"/>) &gt; 0
+
+                    WHEN FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>,
+                            <include refid="normalizedPreachformExpr"/>) = 0 THEN
+                        <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform}
+
+                    ELSE
+                        FIND_IN_SET(#{cumulativePreachform},
+                            <include refid="normalizedPreachformExpr"/>) &gt; 0
+                        AND FIND_IN_SET(#{cumulativePreachform},
+                            <include refid="normalizedPreachformExpr"/>)
+                            &lt;= FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>,
+                            <include refid="normalizedPreachformExpr"/>)
+                END
+            )
+            <if test='followUpCountStyle != null and followUpCountStyle == "1"'>
+                AND sendstate != 4
+            </if>
+            <if test='followUpCountStyle != null and followUpCountStyle == "3"'>
+                AND sendstate = 6
+            </if>
         </if>
         <if test="excep != null and excep != ''">
             AND excep = #{excep}

--
Gitblit v1.9.3