From 15fad6a0122b0757399885c4232056da64996013 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期六, 25 四月 2026 17:06:23 +0800
Subject: [PATCH] 添加一下   @DateTimeFormat

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

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 81d7ede..dfe8dfd 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -344,8 +344,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=")">
@@ -355,14 +356,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=")">
@@ -370,17 +372,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=")">
@@ -390,10 +394,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">
@@ -641,6 +646,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>
@@ -655,25 +662,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>
@@ -690,6 +701,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
@@ -720,6 +738,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>
@@ -1238,6 +1258,9 @@
             <if test="continueContent != null ">continue_content = #{continueContent},</if>
         </trim>
         where patid = #{patid} and taskid = #{taskid}
+        <if test="id != null ">
+            and id = #{id}
+        </if>
     </update>
 
     <update id="updateServiceSubtaskByTaskGuid" parameterType="com.smartor.domain.ServiceSubtask">
@@ -2472,4 +2495,50 @@
         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