From 2867cf7076a584a34e63174cec0a8b89cdd03e4c Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 06 十一月 2026 13:42:55 +0800
Subject: [PATCH] Merge branch 'master' into smartor_ls_261103

---
 ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 179 insertions(+), 1 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..89625bb 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -108,6 +108,7 @@
         <result property="loopCount" column="loop_count"/>
         <result property="isManuallyCalled" column="is_manually_called"/>
         <result property="campusid" column="campusid"/>
+        <result property="diagType" column="diag_type"/>
     </resultMap>
 
     <resultMap type="com.ruoyi.task.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -1418,6 +1419,25 @@
         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">
         update service_subtask
         <trim prefix="SET" suffixOverrides=",">
@@ -1806,6 +1826,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 +1877,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 +2130,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 +2210,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 +2264,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 +3151,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,

--
Gitblit v1.9.3