From 3111fafe883b94df6e02a5c62c9a2204fbd5711d Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 24 四月 2026 17:58:32 +0800
Subject: [PATCH] Merge branch 'master' into master-手术随访

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 5a778bf..d75bd6e 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -346,8 +346,9 @@
             </if>
         </if>
         <if test="deptOrDistrict==2">
+            AND (1=1
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-                AND (leavehospitaldistrictcode IN
+                AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
                          separator=","
                          close=")">
@@ -357,14 +358,15 @@
             <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
                 OR deptcode IN
                 <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
-                         close="))">
+                         close=")">
                     #{leaveldeptcode}
                 </foreach>
-            </if>
+            </if>)
         </if>
         <if test="deptOrDistrict==3">
+            AND (1=1
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-                AND (leavehospitaldistrictcode IN
+                AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
                          separator=","
                          close=")">
@@ -372,17 +374,19 @@
                 </foreach>
             </if>
             <if test=" visitDeptCodes != null and visitDeptCodes.size()>0">
-                and visit_dept_code IN
+                AND visit_dept_code IN
                 <foreach collection="visitDeptCodes" item="visitDeptCode" open="(" separator=","
-                         close="))">
+                         close=")">
                     #{visitDeptCode}
                 </foreach>
             </if>
+            )
         </if>
 
         <if test="deptOrDistrict==4">
+            AND (1=1
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-                AND (leavehospitaldistrictcode IN
+                AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
                          separator=","
                          close=")">
@@ -392,10 +396,11 @@
             <if test=" visitDeptCodes != null and visitDeptCodes.size()>0">
                 OR visit_dept_code IN
                 <foreach collection="visitDeptCodes" item="visitDeptCode" open="(" separator=","
-                         close="))">
+                         close=")">
                     #{visitDeptCode}
                 </foreach>
             </if>
+            )
         </if>
 
         <if test="visitTime != null">
@@ -643,6 +648,8 @@
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endtime},'%y%m%d')
         </if>
         <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if>
+        <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if>
         <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
         <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
         <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
@@ -657,25 +664,29 @@
         ) a
     </select>
 
-    <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.ServiceSubtask" resultType="map">
+    <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" resultType="map">
         SELECT
         <if test="groupKey != null and groupKey != ''">
             ${groupKey} as groupKey,
         </if>
-        SUM(CASE WHEN DATE(visit_time) &lt; DATE(IFNULL(finishtime, NOW())) THEN 1 ELSE 0 END) / COUNT(*) as rate
+        SUM(CASE WHEN finishtime IS NOT NULL AND DATE(visit_time) &lt;= DATE(finishtime) THEN 1 ELSE 0 END) / COUNT(*) AS finishRate,
+        <if test="rateDay != null">
+            SUM(CASE WHEN finishtime IS NOT NULL AND DATEDIFF(finishtime, endtime) &lt;= #{rateDay} THEN 1 ELSE 0 END) / COUNT(*) AS rate
+        </if>
+        <if test="rateDay == null">
+            NULL AS rate
+        </if>
         FROM service_subtask
         WHERE del_flag = 0
         AND visit_time IS NOT NULL
-        AND finishtime IS NOT NULL
-        <if test="orgid != null">AND orgid = #{orgid}</if>
         <if test="starttime == null and endtime==null">
-            AND visit_time &lt; NOW()
+            AND DATE(visit_time) &lt; DATE(NOW())
         </if>
         <if test="starttime != null and endtime!=null">
             AND visit_time >= #{starttime}
             AND visit_time &lt; DATE_ADD(#{endtime}, INTERVAL 1 DAY)
         </if>
-        <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="orgid != null and orgid != ''">AND orgid = #{orgid}</if>
         <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
         <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
         <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
@@ -692,6 +703,13 @@
         </if>
         <if test="visitCount != null and visitCount > 1">
             AND visit_count > 1
+        </if>
+        <if test="serviceTypeList != null">
+            AND service_type IN
+            <foreach collection="serviceTypeList" item="serviceType" open="(" separator=","
+                     close=")">
+                #{serviceType}
+            </foreach>
         </if>
         <if test="groupKey != null and groupKey != ''">
             AND ${groupKey} IN
@@ -722,6 +740,8 @@
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endtime},'%y%m%d')
         </if>
         <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if>
+        <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if>
         <if test="isabnormal != null ">and isabnormal = #{isabnormal}</if>
         <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
         <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>

--
Gitblit v1.9.3