From c0988ce95ab6a518aefe843d9cfd84d1515cdc00 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 15 十月 2026 16:18:40 +0800
Subject: [PATCH] 【丽水】1. /smartor/serviceSubtask/getCurrentUserServiceSubtaskCount工作台里加即将超时数量字段 2. /smartor/serviceSubtask/querySubtaskList 给一个列表可以查询多少小时(可选)即将超时的随访服务,如:48小时内即将超时任务(今天15号10.40到17号10.40这段时间会到达超时时间的任务)
---
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 253 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 221 insertions(+), 32 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 1603d17..6c428cf 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -291,6 +291,36 @@
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
</select>
+ <!-- 鍗冲皢瓒呮椂杩囨护锛氭槸鍚﹀嵆灏嗚秴鏃�(soonTimeout=1) + 鍗冲皢瓒呮椂鏃堕棿(soonTimeoutHours锛屽崟浣嶅皬鏃�)銆�
+ 鎴鏃堕棿鍙e緞涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 淇濇寔涓�鑷达細
+ service_subtask.endtime + service_task.send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紱
+ 浠呭綋瀛樺湪鏈夋晥琛ュ伩璁板綍鏃舵墠璁$畻鎴鏃堕棿锛堟棤琛ュ伩璁板綍涓嶅弬涓庡嵆灏嗚秴鏃讹級锛�
+ 浠呯粺璁♀�滃皻鏈秴鏃躲�佷笖鍦� N 灏忔椂鍐呭皢瑕佽秴鏃垛�濈殑鏁版嵁銆� -->
+ <sql id="soonTimeoutDeadlineExpr">
+ (
+ SELECT DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(pf.compensate_days, 0) + 1) DAY
+ )
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ INNER JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) pf ON pf.subid = ss.id
+ WHERE ss.id = service_subtask.id
+ )
+ </sql>
+
+ <sql id="soonTimeoutFilter">
+ <if test="soonTimeout != null and soonTimeout == 1">
+ AND <include refid="soonTimeoutDeadlineExpr"/> > NOW()
+ AND <include refid="soonTimeoutDeadlineExpr"/> <= DATE_ADD(NOW(), INTERVAL COALESCE(#{soonTimeoutHours}, 0) HOUR)
+ </if>
+ </sql>
<select id="selectServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
resultMap="ServiceSubtaskResult">
@@ -406,17 +436,21 @@
</if>
</if>
<if test="deptOrDistrict==2">
- AND (1=1
- <if test="leavehospitaldistrictcodes != null">
- AND leavehospitaldistrictcode IN
+ AND (
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
</if>
- <if test=" leaveldeptcodes != null">
- OR deptcode IN
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
+ <if test=" leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ deptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
@@ -525,6 +559,7 @@
#{visitDeptCode}
</foreach>
</if>
+ <include refid="soonTimeoutFilter"/>
<if test="sort != null and sort==0">order by endtime asc</if>
<if test="sort != null and sort==1">order by endtime desc</if>
<if test="sort != null and sort==2">order by visit_time asc</if>
@@ -534,7 +569,9 @@
<if test="sort != null and sort==7">order by visit_time asc</if>
<if test="sort != null and sort==8">order by visit_time desc</if>
<if test="sort != null and sort==9">order by sendname asc</if>
- <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+ <if test="pageSize != null and pageNum != null">
+ LIMIT ${pageSize} OFFSET ${pageNum}
+ </if>
</select>
<select id="selectSatisfactionSubtaskList" parameterType="com.smartor.domain.VO.PatSatisfactionReqVO"
@@ -692,6 +729,7 @@
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
<if test="continueCount != null ">and continue_count = #{continueCount}</if>
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
+ <include refid="soonTimeoutFilter"/>
</select>
<select id="selectSendstateByCondition" parameterType="com.smartor.domain.ServiceSubtask" resultType="Integer">
@@ -738,6 +776,12 @@
</if>
<if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
<if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
+ <if test="startOutHospTime != null">
+ AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ </if>
) a
</select>
@@ -770,6 +814,7 @@
</if>
WHERE ss.del_flag = 0
AND ss.visit_time IS NOT NULL
+ AND ss.sendstate != 4
<if test="starttime == null and endtime==null">
AND DATE(ss.visit_time) < DATE(NOW())
</if>
@@ -802,6 +847,12 @@
close=")">
#{serviceType}
</foreach>
+ </if>
+ <if test="startOutHospTime != null">
+ AND date_format(ss.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(ss.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="groupKey != null and groupKey != ''">
AND ss.${groupKey} IN
@@ -1556,7 +1607,8 @@
continue_content,
continue_count,
continue_time_next,
- task_situation
+ task_situation,
+ is_manually_called
from service_subtask
where 1=1
and del_flag = 0
@@ -1843,7 +1895,8 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ is_manually_called
from service_subtask
where 1=1
and del_flag = 0
@@ -1929,6 +1982,9 @@
</if>
<if test="deptcode != null and deptcode != ''">
AND deptcode = #{deptcode}
+ </if>
+ <if test="isManuallyCalled != null">
+ AND is_manually_called = #{isManuallyCalled}
</if>
order by endtime desc
<if test="pageSize != null and pageNum != null">
@@ -2584,7 +2640,10 @@
SUM(CASE WHEN sendstate != 4 THEN 1 ELSE 0 END) AS xsf,
SUM(CASE WHEN (sendstate = 1 OR sendstate = 2 OR sendstate = 3 OR sendstate = 5 OR sendstate = 7 ) THEN 1 ELSE 0
END) AS dsf,
+ SUM(CASE WHEN sendstate != 2 THEN 1 ELSE 0 END) AS yfs,
+ SUM(CASE WHEN sendstate = 2 THEN 1 ELSE 0 END) AS wfs,
SUM(CASE WHEN sendstate = 6 THEN 1 ELSE 0 END) AS ywc,
+ SUM(CASE WHEN sendstate = 7 THEN 1 ELSE 0 END) AS cs,
SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS yc,
SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS jg,
COUNT(1) as total
@@ -2621,17 +2680,21 @@
</if>
</if>
<if test="deptOrDistrict==2">
- AND (1=1
+ AND (
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
</if>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
<if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- OR deptcode IN
+ deptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
@@ -2817,32 +2880,73 @@
COUNT(CASE WHEN sendstate = 5 THEN 1 END) AS failedVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS abnormalVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS warnningVisitCount,
- COUNT(*) AS allVisitCount
- FROM service_subtask
- WHERE del_flag = '0'
- AND service_type = '2'
- AND visit_count = 1
+ COUNT(*) AS allVisitCount,
+ <choose>
+ <when test="soonTimeoutHours != null and soonTimeoutHours > 0">
+ COUNT(CASE WHEN t.soon_deadline > NOW()
+ AND t.soon_deadline <= DATE_ADD(NOW(), INTERVAL #{soonTimeoutHours} HOUR)
+ THEN 1 END) AS soonTimeoutCount
+ </when>
+ <otherwise>
+ 0 AS soonTimeoutCount
+ </otherwise>
+ </choose>
+ FROM (
+ SELECT ss.*,
+ <!-- 鍗冲皢瓒呮椂鎴鏃堕棿 = 鍑洪櫌鏃堕棿(endtime) + 鍙戦�佹棩(send_day, 缂虹渷1) + 琛ュ伩澶╂暟(compensate_time 姹傚拰鍚庡啀 +1 澶�)锛�
+ 涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
+ 鏃犳湁鏁堣ˉ鍋胯褰�(cp.subid 涓虹┖)鏃舵埅姝㈡椂闂翠负 NULL锛屼笉鍙備笌鍗冲皢瓒呮椂缁熻 -->
+ CASE
+ WHEN cp.subid IS NULL THEN NULL
+ ELSE DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(cp.compensate_days, 0) + 1) DAY
+ )
+ END AS soon_deadline
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ <!-- 琛ュ伩鏃堕棿锛氬厛鎸夊瓙浠诲姟鑱氬悎鎴愪竴琛屽啀鍏宠仈锛岄伩鍏嶄竴瀵瑰鏀惧ぇ璁℃暟锛�
+ compensate_time 鏄� varchar 涓斿彲鑳藉瓨鎴愮┖涓诧紝闇�鍏堢疆绌哄啀杞暟瀛� -->
+ LEFT JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) cp ON cp.subid = ss.id
+ WHERE ss.del_flag = '0'
+ AND ss.service_type = '2'
+ AND ss.visit_count = 1
<if test="orgid != null and orgid != ''">
- AND orgid = #{orgid}
+ AND ss.orgid = #{orgid}
</if>
<if test="campusid != null and campusid != ''">
- and campusid = #{campusid}
+ and ss.campusid = #{campusid}
</if>
- <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
- separator=","
- close=")">
- #{leavehospitaldistrictcode}
- </foreach>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ AND (
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ ss.leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+ separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
+ <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+ ss.deptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>)
</if>
- <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- AND deptcode IN
- <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
- close=")">
- #{leaveldeptcode}
- </foreach>
- </if>
+ ) t
</select>
<select id="querySendCount" parameterType="com.smartor.domain.entity.ServiceSubtaskSatisfactionEntity"
@@ -3258,6 +3362,13 @@
#{taskId}
</foreach>
</if>
+ <!-- 浼犱簡 subtaskIds 鍙粺璁¤繖鎵瑰瓙浠诲姟锛堟湰娆″鍑虹殑鎮h�咃級 -->
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
+ </foreach>
+ </if>
<if test="valueType != null">AND d.value_type = #{valueType}</if>
<if test="scoreStart != null">AND d.score >= #{scoreStart}</if>
<if test="scoreEnd != null">AND d.score <= #{scoreEnd}</if>
@@ -3266,6 +3377,19 @@
</if>
and s.sendstate=6
and d.del_flag=0
+ <!-- 鍒嗘瘝蹇呴』鍜屾槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃堕棿鑼冨洿鍚庢瘮渚嬩細鎸夊叏閲忓巻鍙茶绋�閲� -->
+ <if test="startOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ </if>
+ <if test="startFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
+ </if>
+ <if test="endFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d')
+ </if>
GROUP BY
t.taskid,
d.questiontext
@@ -3275,6 +3399,12 @@
AND t.taskid IN
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
#{taskId}
+ </foreach>
+ </if>
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
</foreach>
</if>
<if test="valueType != null">AND d.value_type = #{valueType}</if>
@@ -3307,6 +3437,64 @@
ORDER BY
d.questiontext,
t.taskid
+ </select>
+
+ <!--
+ 瀵煎嚭銆岄棶棰樿鎯呭崰姣斻�嶄笓鐢ㄧ粺璁★紙鍙粺璁℃湰娆″鍑虹殑杩欐壒鎮h�咃級
+ 鏁伴噺 = 閫夋嫨璇ラ�夐」鐨勬偅鑰呮暟锛圕OUNT(DISTINCT s.id)锛屽苟鐢� MAX(id) 淇濊瘉鍚屼竴鎮h�呭悓涓�棰樺彧绠楁渶鏂颁竴鏉★級
+ 鍒嗘暟 = 璇ラ�夐」鏄庣粏鐨� score 涔嬪拰
+ 姣斾緥 = 鏁伴噺 / 璇ラ浣滅瓟鎮h�呮暟锛屽湪 Java 渚х粺涓�璁$畻锛屽洜姝ゃ�屽崟棰樺悇閫夐」鏁伴噺涔嬪拰 = 璇ラ浣滅瓟鎮h�呮暟銆�
+ -->
+ <select id="statMydQuestionOptionForExport" resultType="com.smartor.domain.DTO.ServiceSubtaskOptionStatDTO">
+ SELECT
+ t.taskid AS taskid,
+ t.task_name AS taskName,
+ d.questiontext AS questiontext,
+ d.asrtext AS optionresult,
+ d.targetvalue AS targetvalue,
+ d.value_type AS valueType,
+ COUNT(DISTINCT s.id) AS patientCount,
+ SUM(COALESCE(CAST(d.score AS DECIMAL(18,2)), 0)) AS scoreSum
+ FROM
+ service_task t
+ INNER JOIN service_subtask s ON s.taskid = t.taskid
+ INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+ WHERE 1=1
+ AND s.del_flag = '0'
+ AND d.del_flag = 0
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
+ </foreach>
+ </if>
+ <!-- 涓嶄紶瀛愪换鍔℃椂鐩存帴鏌ヤ笉鍒版暟鎹紝閬垮厤璇粺璁″叏閲� -->
+ <if test="subtaskIds == null or subtaskIds.size() == 0">
+ AND 1 = 0
+ </if>
+ <if test="questiontext != null and questiontext != ''">
+ AND d.questiontext LIKE CONCAT('%', #{questiontext}, '%')
+ </if>
+ <!-- 鍚屼竴鎮h�呭悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閲嶇瓟涓嶉噸澶嶈鍏ユ暟閲� -->
+ AND d.id = (
+ SELECT MAX(d2.id)
+ FROM service_subtask_detail d2
+ WHERE d2.sub_id = d.sub_id
+ AND d2.questiontext <=> d.questiontext
+ AND d2.del_flag = '0'
+ )
+ GROUP BY
+ t.taskid,
+ t.task_name,
+ d.questiontext,
+ d.asrtext,
+ d.targetvalue,
+ d.value_type
+ <!-- 鎸変换鍔″悕绉板垎缁勫睍绀猴細鍏堜换鍔″悕绉般�佸啀浠诲姟缂栧彿锛屽悓涓�浠诲姟鐨勯鐩�/閫夐」杩炵画鎺掑垪 -->
+ ORDER BY
+ t.task_name,
+ t.taskid,
+ d.questiontext
</select>
<!-- 鏂版柟娉曪細鏍规嵁瀛愪换鍔� ID 缁熻闂閫夐」鐧惧垎姣� (鐢ㄤ簬婊℃剰搴︾粺璁� serviceType=6) -->
@@ -3593,5 +3781,6 @@
</select>
+
</mapper>
--
Gitblit v1.9.3