From 132cb0d089c7734f3eb3e858bd741fbc60dbdc9d Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 20 一月 2026 16:46:25 +0800
Subject: [PATCH] 【丽水】获取随访统计比例 查询优化
---
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 47 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 6385d61..312e13a 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -278,6 +278,14 @@
<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>
+ <!-- taskIds绛涢�� -->
+ <if test="taskIds != null and taskIds.size() > 0">
+ AND taskid IN
+ <foreach collection="taskIds" item="itemTaskId" open="(" separator=","
+ close=")">
+ #{itemTaskId}
+ </foreach>
+ </if>
<if test="templateid != null and templateid != ''">and templateid = #{templateid}</if>
<if test="templatename != null and templatename != ''">and templatename like concat('%', #{templatename},
'%')
@@ -552,6 +560,21 @@
<if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
) a
</select>
+
+ <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.ServiceSubtask" resultType="map">
+ SELECT
+ <if test="deptcode != null">deptcode as groupKey,</if>
+ <if test="leavehospitaldistrictcode != null">leavehospitaldistrictcode as groupKey,</if>
+ <if test="drcode != null">drcode as groupKey,</if>
+ SUM(CASE WHEN DATE(visit_time) < DATE(IFNULL(finishtime, NOW())) THEN 1 ELSE 0 END) / COUNT(*) as rate
+ FROM service_subtask
+ WHERE del_flag = 0
+ AND visit_time >= #{starttime}
+ AND visit_time < DATE_ADD(#{endtime}, INTERVAL 1 DAY)
+ <if test="orgid != null">AND orgid = #{orgid}</if>
+ GROUP BY groupKey
+ </select>
+
<select id="selectTimelyRateDetail" parameterType="com.smartor.domain.ServiceSubtask"
resultMap="ServiceSubtaskResult">
@@ -1198,16 +1221,19 @@
#{serviceType}
</foreach>
</if>
- <if test="startTime != null and endTime!=null">
- AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
- AND date_format(visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
- </if>
- <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
+ <if test="startTime != null and endTime!=null">
+ AND visit_time >= DATE(#{startTime})
+ AND visit_time < 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="type != null">
and type = #{type}
+ </if>
+ <if test="pageSize != null and pageNum != null">
+ limit ${pageSize} OFFSET ${pageNum}
</if>
</select>
@@ -1341,8 +1367,8 @@
</if>
<if test="configValue != null and configValue != ''">
SUM(CASE WHEN a.categoryid IN(${configValue})
- AND a.matchedtext is not null
- AND a.matchedtext != ''
+ AND IFNULL(a.matchedtext,a.asrtext) is not null
+ AND IFNULL(a.matchedtext,a.asrtext) != ''
THEN 1 ELSE 0 END) AS joyCount,
</if>
a.sub_id as subTaskId
@@ -1368,6 +1394,13 @@
#{deptcode}
</foreach>
</if>
+ <if test="subTaskIds != null and subTaskIds.size() > 0">
+ AND t.id IN
+ <foreach collection="subTaskIds" item="subTaskId" open="(" separator=","
+ close=")">
+ #{subTaskId}
+ </foreach>
+ </if>
<if test="serviceType != null and serviceType.size() > 0">
AND t.service_type IN
<foreach collection="serviceType" item="serviceType" open="(" separator=","
--
Gitblit v1.9.3