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

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index fc77ed8..c09a81c 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,
@@ -301,6 +320,12 @@
         <if test="senderdetail != null  and senderdetail != ''">and senderdetail = #{senderdetail}</if>
         <if test="type != null  and type != ''">and type = #{type}</if>
         <if test="taskid != null ">and taskid = #{taskid}</if>
+        <if test="sendstates != null and sendstates.size() > 0">
+            AND sendstate IN
+            <foreach collection="sendstates" item="state" open="(" separator="," close=")">
+                #{state}
+            </foreach>
+        </if>
         <!-- taskIds绛涢�� -->
         <if test="taskIds != null and taskIds.size() > 0">
             AND taskid IN
@@ -1176,6 +1201,7 @@
             <if test="sendname != null">sendname = #{sendname},</if>
             <if test="phone != null">phone = #{phone},</if>
             <if test="sex != null">sex = #{sex},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="sendstate != null ">sendstate = #{sendstate},</if>
             <if test="age != null">age = #{age},</if>
             <if test="sfzh != null">sfzh = #{sfzh},</if>
@@ -1478,6 +1504,112 @@
             </foreach>
         </if>
     </select>
+
+    <select id="getSpecialSfStatistics" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
+            resultMap="ServiceSubtaskStatisticResult">
+        select
+        a.task_name,
+        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="taskIds != null and taskIds.size() > 0">
+            AND a.task_id IN
+            <foreach collection="taskIds" item="taskIdItem" open="(" separator=","
+                     close=")">
+                #{taskIdItem}
+            </foreach>
+        </if>
+        <if test="taskNames != null and taskNames.size() > 0">
+            AND a.task_name IN
+            <foreach collection="taskNames" item="taskNameItem" open="(" separator=","
+                     close=")">
+                #{taskNameItem}
+            </foreach>
+        </if>
+        <if test="diagTypes != null and diagTypes.size() > 0">
+            AND a.diag_type IN
+            <foreach collection="diagTypes" item="diagTypeItem" open="(" separator=","
+                     close=")">
+                #{diagTypeItem}
+            </foreach>
+        </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>
+        GROUP BY a.task_name
+    </select>
+
     <select id="getSfStatisticsGroupKey" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultType="String">
         select
@@ -1538,6 +1670,134 @@
         <if test="pageSize != null  and pageNum != null">
             limit ${pageSize} OFFSET ${pageNum}
         </if>
+    </select>
+
+    <select id="getSfStatisticsHyperlink" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
+            resultMap="ServiceSubtaskResult">
+            select id,
+            visit_count,
+            is_visit_again,
+            type,
+            orgid,
+            drcode,
+            drname,
+            leavehospitaldistrictcode,
+            leavehospitaldistrictname,
+            deptcode,
+            deptname,
+            sendstate,
+            preachform,
+            current_preachform,
+            excep,
+            nurse_id,
+            nurse_name,
+            taskid,
+            task_name,
+            visit_time,
+            finishtime,
+            endtime,
+            senddate,
+            suggest,
+            result,
+            templateid,
+            templatename,
+            patid,
+            sendname,
+            send_type,
+            recordid,
+            exrecallcount,
+            continue_flag,
+            continue_time_now,
+            continue_content,
+            continue_count,
+            continue_time_next,
+            task_situation
+            from service_subtask
+            where 1=1
+            and del_flag = 0
+            <if test="orgid != null and orgid != ''">
+                and orgid = #{orgid}
+            </if>
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                AND leavehospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{leavehospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="deptcodes != null and deptcodes.size() > 0">
+                AND deptcode IN
+                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+                         close=")">
+                    #{deptcode}
+                </foreach>
+            </if>
+            <if test="serviceType != null and serviceType.size() > 0">
+                AND service_type IN
+                <foreach collection="serviceType" item="serviceType" open="(" separator=","
+                         close=")">
+                    #{serviceType}
+                </foreach>
+            </if>
+            <if test="startTime != null and endTime!=null">
+                AND visit_time >= DATE(#{startTime})
+                AND visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+            </if>
+            <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
+            <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
+            <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
+            <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
+            <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
+            <if test="continueCount != null ">and continue_count = #{continueCount}</if>
+            <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if>
+            <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="visitCount != null and visitCount == 1">
+                AND visit_count = 1
+            </if>
+            <if test="visitCount != null and visitCount > 1">
+                AND visit_count > 1
+            </if>
+            <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0">
+                AND ${groupKey} IN
+                <foreach collection="groupKeyList" item="key" open="(" separator=","
+                         close=")">
+                    #{key}
+                </foreach>
+            </if>
+            AND sendstate IS NOT NULL
+            <if test="sendstates != null and sendstates.size() > 0">
+                AND sendstate IN
+                <foreach collection="sendstates" item="state" open="(" separator="," close=")">
+                    #{state}
+                </foreach>
+            </if>
+            <if test="currentPreachform != null">
+                AND current_preachform = #{currentPreachform}
+                <if test="followUpCountStyle != null and followUpCountStyle = '1'">
+                    AND sendstate != 4
+                </if>
+            </if>
+            <if test="excep != null and excep != ''">
+                AND excep = #{excep}
+            </if>
+            <if test="taskSituation != null">
+                AND task_situation = #{taskSituation}
+            </if>
+            <if test="drcode != null and drcode != ''">
+                AND drcode = #{drcode}
+            </if>
+            <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+                AND leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+            </if>
+            <if test="deptcode != null and deptcode != ''">
+                AND deptcode = #{deptcode}
+            </if>
+            <if test="pageSize != null  and pageNum != null">
+                limit ${pageSize} OFFSET ${pageNum}
+            </if>
     </select>
 
     <select id="getSfStatisticsJoy" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1976,8 +2236,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>
@@ -2019,6 +2281,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)
@@ -2080,7 +2343,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}
@@ -2549,3 +2812,4 @@
     </select>
 
 </mapper>
+

--
Gitblit v1.9.3