From 6cb6d9ed6df1c50557f6b4b9f2c888261244df05 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 25 五月 2026 15:33:23 +0800
Subject: [PATCH] 【丽水】getSfStatisticsCount 优化

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index d75bd6e..4eb5221 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -266,6 +266,7 @@
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where del_flag = 0
+        <if test="subId != null ">and id = #{subId}</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>
@@ -300,6 +301,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
@@ -1175,6 +1182,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>
@@ -1396,6 +1404,7 @@
         deptname,
         sendstate,
         preachform,
+        current_preachform,
         excep,
         nurse_id,
         nurse_name,
@@ -2500,4 +2509,51 @@
         ORDER BY groupCode
     </select>
 
+    <!-- 瀹f暀缁熻锛氭寜鐥呭尯鎴栫瀹ゅ垎缁勶紝缁熻鍙戦�佹�婚噺銆佸彂閫佹垚鍔熼噺锛坰endstate=6锛夈�佸凡璇婚噺锛坒inishtime涓嶄负绌猴級 -->
+    <select id="getHeLibraryCount" parameterType="com.smartor.domain.VO.HeLibraryCountVO" resultType="map">
+        SELECT
+        <choose>
+            <when test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+                leavehospitaldistrictcode AS groupCode,
+                leavehospitaldistrictname AS groupName,
+            </when>
+            <otherwise>
+                deptcode AS groupCode,
+                deptname AS groupName,
+            </otherwise>
+        </choose>
+        COUNT(*) AS totalCount,
+        SUM(CASE WHEN sendstate = 6 THEN 1 ELSE 0 END) AS sendSuccessCount,
+        SUM(CASE WHEN finishtime IS NOT NULL THEN 1 ELSE 0 END) AS readCount
+        FROM service_subtask
+        WHERE del_flag = 0
+        AND service_type = 4
+        <if test="starttime != null">AND starttime &gt;= #{starttime}</if>
+        <if test="endtime != null">AND endtime &lt;= #{endtime}</if>
+        <if test="visittime != null">AND DATE(visit_time) = DATE(#{visittime})</if>
+        <if test="finishtime != null">AND DATE(finishtime) = DATE(#{finishtime})</if>
+        <if test="hospType != null and hospType != ''">AND hosp_type = #{hospType}</if>
+        <choose>
+            <when test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+                AND leavehospitaldistrictcode IN
+                <foreach collection="hospitaldistrictcodes" item="code" open="(" separator="," close=")">
+                    #{code}
+                </foreach>
+                GROUP BY leavehospitaldistrictcode, leavehospitaldistrictname
+                ORDER BY groupCode
+            </when>
+            <otherwise>
+                <if test="deptcodes != null and deptcodes.size() > 0">
+                    AND deptcode IN
+                    <foreach collection="deptcodes" item="code" open="(" separator="," close=")">
+                        #{code}
+                    </foreach>
+                </if>
+                GROUP BY deptcode, deptname
+                ORDER BY groupCode
+            </otherwise>
+        </choose>
+    </select>
+
 </mapper>
+

--
Gitblit v1.9.3