From 37d8d7dbbcd259e281f6279938ab6491f41e057c Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 18 三月 2026 17:51:29 +0800
Subject: [PATCH] 【丽水】获取当前用户随访数量统计 补充

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index c9698fc..40e437c 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -318,10 +318,10 @@
             AND date_format(endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
         </if>
         <if test="startSendDateTime != null">
-            AND date_format(long_send_time,'%y%m%d') &gt;= date_format(#{startSendDateTime},'%y%m%d')
+            AND date_format(visit_time,'%y%m%d') &gt;= date_format(#{startSendDateTime},'%y%m%d')
         </if>
         <if test="endSendDateTime != null">
-            AND date_format(long_send_time,'%y%m%d') &lt;= date_format(#{endSendDateTime},'%y%m%d')
+            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endSendDateTime},'%y%m%d')
         </if>
 
         <if test="longSendTime != null">
@@ -2205,10 +2205,10 @@
             AND DATE_FORMAT(endtime,'%y%m%d') &lt;= DATE_FORMAT(#{endOutHospTime},'%y%m%d')
         </if>
         <if test="startSendDateTime != null">
-            AND DATE_FORMAT(long_send_time,'%y%m%d') &gt;= DATE_FORMAT(#{startSendDateTime},'%y%m%d')
+            AND DATE_FORMAT(visit_time,'%y%m%d') &gt;= DATE_FORMAT(#{startSendDateTime},'%y%m%d')
         </if>
         <if test="endSendDateTime != null">
-            AND DATE_FORMAT(long_send_time,'%y%m%d') &lt;= DATE_FORMAT(#{endSendDateTime},'%y%m%d')
+            AND DATE_FORMAT(visit_time,'%y%m%d') &lt;= DATE_FORMAT(#{endSendDateTime},'%y%m%d')
         </if>
         <if test="longSendTime != null">
             AND DATE_FORMAT(long_send_time,'%y%m%d') &lt;= DATE_FORMAT(#{longSendTime},'%y%m%d')
@@ -2257,4 +2257,34 @@
         </if>
     </select>
 
+    <select id="getCurrentUserServiceSubtaskCount" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" resultType="map">
+        SELECT
+        COUNT(CASE WHEN sendstate IN (1, 2) AND date_format(visit_time,'%y%m%d') &lt;= date_format(CURDATE(),'%y%m%d') THEN 1 END) AS pendingVisitCount,
+        COUNT(CASE WHEN sendstate = 5 THEN 1 END) AS failedVisitCount,
+        COUNT(CASE WHEN isabnormal IN (1, 2) THEN 1 END) AS abnormalVisitCount,
+        COUNT(*) AS allVisitCount
+        FROM service_subtask
+        WHERE del_flag = '0'
+        AND service_type = '2'
+        AND visit_count = 1
+        <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=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+            AND deptcode IN
+            <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+                     close=")">
+                #{leaveldeptcode}
+            </foreach>
+        </if>
+    </select>
+
 </mapper>

--
Gitblit v1.9.3