From a9d3da5b62ed78a9e4d50e774672b3f0f658fd4a Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 05 六月 2026 00:49:11 +0800
Subject: [PATCH] 【丽水】getSpecialSfStatistics 获取专病随访统计比例

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 0ea8666..effc758 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -121,6 +121,25 @@
         <result property="options" column="options"/>
     </resultMap>
 
+    <resultMap type="com.smartor.domain.ServiceSubtaskStatistic" id="ServiceSubtaskStatisticResult">
+        <result property="dischargeCount" column="discharge_count"/>
+        <result property="nonFollowUp" column="non_follow_up"/>
+        <result property="filterCount" column="filter_count"/>
+        <result property="followUpNeeded" column="follow_up_needed"/>
+        <result property="needFollowUp" column="need_follow_up"/>
+        <result property="pendingFollowUp" column="pending_follow_up"/>
+        <result property="followUpFail" column="follow_up_fail"/>
+        <result property="manual" column="manual"/>
+        <result property="voice" column="voice"/>
+        <result property="sms" column="sms"/>
+        <result property="weChat" column="we_chat"/>
+        <result property="taskSituation1" column="task_situation1"/>
+        <result property="taskSituation2" column="task_situation2"/>
+        <result property="taskSituation3" column="task_situation3"/>
+        <result property="taskSituation4" column="task_situation4"/>
+        <result property="taskSituation5" column="task_situation5"/>
+        <result property="taskSituation6" column="task_situation6"/>
+    </resultMap>
     <sql id="selectServiceSubtaskVo">
         select id,
                hosp_type,
@@ -1485,6 +1504,92 @@
             </foreach>
         </if>
     </select>
+
+    <select id="getSpecialSfStatistics" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
+            resultMap="ServiceSubtaskStatisticResult">
+        select
+        COUNT(1) AS discharge_count,
+        SUM(CASE WHEN b.sendstate = 4 THEN 1 ELSE 0 END) AS non_follow_up,
+        SUM(CASE WHEN b.sendstate = 4 and b.task_situation = 6 THEN 1 ELSE 0 END) AS filter_count,
+        SUM(CASE WHEN b.sendstate != 4 THEN 1 ELSE 0 END) AS follow_up_needed,
+        SUM(CASE WHEN b.sendstate != 4 THEN 1 ELSE 0 END) AS need_follow_up,
+        SUM(CASE WHEN b.sendstate = 2 THEN 1 ELSE 0 END) AS pending_follow_up,
+        SUM(CASE WHEN b.sendstate = 5 or b.sendstate = 7 THEN 1 ELSE 0 END) AS follow_up_fail,
+        SUM(CASE WHEN b.current_preachform = '1' THEN 1 ELSE 0 END) AS manual,
+        SUM(CASE WHEN b.current_preachform = '3' THEN 1 ELSE 0 END) AS voice,
+        SUM(CASE WHEN b.current_preachform = '4' THEN 1 ELSE 0 END) AS sms,
+        SUM(CASE WHEN b.current_preachform = '5' THEN 1 ELSE 0 END) AS we_chat,
+        SUM(CASE WHEN b.task_situation = 1 THEN 1 ELSE 0 END) AS task_situation1,
+        SUM(CASE WHEN b.task_situation = 2 THEN 1 ELSE 0 END) AS task_situation2,
+        SUM(CASE WHEN b.task_situation = 3 THEN 1 ELSE 0 END) AS task_situation3,
+        SUM(CASE WHEN b.task_situation = 4 THEN 1 ELSE 0 END) AS task_situation4,
+        SUM(CASE WHEN b.task_situation = 5 THEN 1 ELSE 0 END) AS task_situation5,
+        SUM(CASE WHEN b.task_situation = 7 THEN 1 ELSE 0 END) AS task_situation7
+        from service_task a
+        JOIN service_subtask b on a.taskid = b.taskid
+        where 1=1
+        and a.del_flag = '0'
+        and b.del_flag = '0'
+        and a.appltype = '3'
+        <if test="orgid != null and orgid != ''">
+            and a.orgid = #{orgid}
+        </if>
+        <if test="taskId != null">
+            and a.task_id = #{taskId}
+        </if>
+        <if test="taskName != null and taskName != ''">
+            and a.task_name like concat('%', #{taskName}, '%')
+        </if>
+        <if test="diagType != null and diagType != ''">
+            and a.diag_type = #{diagType}
+        </if>
+        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            AND b.leavehospitaldistrictcode IN
+            <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                     close=")">
+                #{leavehospitaldistrictcode}
+            </foreach>
+        </if>
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND b.deptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+                     close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+        <if test="serviceType != null and serviceType.size() > 0">
+            AND b.service_type IN
+            <foreach collection="serviceType" item="serviceType" open="(" separator=","
+                     close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime!=null">
+            AND b.visit_time >= DATE(#{startTime})
+            AND b.visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+        </if>
+        <if test="visitDeptCode != null">and b.visit_dept_code = #{visitDeptCode}</if>
+        <if test="visitDeptName != null">and b.visit_dept_name = #{visitDeptName}</if>
+        <if test="isabnormal != null">and b.isabnormal = #{isabnormal}</if>
+        <if test="continueFlag != null ">and b.continue_flag = #{continueFlag}</if>
+        <if test="continueTimeNow != null ">and b.continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
+        <if test="continueCount != null ">and b.continue_count = #{continueCount}</if>
+        <if test="continueTimeNext != null ">and b.continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if>
+        <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
+        <if test="type != null">
+            and b.type = #{type}
+        </if>
+        <if test="visitCount != null and visitCount == 1">
+            AND b.visit_count = 1
+        </if>
+        <if test="visitCount != null and visitCount > 1">
+            AND b.visit_count > 1
+        </if>
+        <if test="groupKey != null and groupKey != ''">
+            GROUP BY ${groupKey}
+        </if>
+    </select>
+
     <select id="getSfStatisticsGroupKey" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultType="String">
         select
@@ -2111,8 +2216,10 @@
         SELECT deptname,
         count(1) AS rc
         FROM service_subtask
-        WHERE DATE_FORMAT(finishtime, '%Y-%m-%d') >= #{startDate}
-        AND DATE_FORMAT(finishtime, '%Y-%m-%d') &lt;= #{endDate}
+        WHERE DATE_FORMAT(visit_time, '%Y-%m-%d') >= #{startDate}
+        AND DATE_FORMAT(visit_time, '%Y-%m-%d') &lt;= #{endDate}
+        AND service_type IN (2, 13)
+        AND del_flag = '0'
         <if test="orgid != null">
             AND orgid = #{orgid}
         </if>
@@ -2154,6 +2261,7 @@
         FROM service_subtask
         WHERE
         del_flag = '0'
+        AND service_type IN (2, 13)
         <if test="startDate != null and endDate != null">
             AND visit_time >= #{startDate}
             AND visit_time &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
@@ -2215,7 +2323,7 @@
             AND endtime >= #{startDate}
             AND endtime &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
         </if>
-
+        AND service_type IN (2, 13)
         AND inhospstate=1
         <if test="orgid != null">
             AND orgid = #{orgid}

--
Gitblit v1.9.3