From 6427886a12c3c6cd56c5dde2e3437d0d608da59c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 09 十一月 2026 14:23:48 +0800
Subject: [PATCH] 修复管理员科室病区为空与延续护理任务出院维度过滤
---
ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml | 1648 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 1,386 insertions(+), 262 deletions(-)
diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index f9d3a27..1eca03b 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -23,10 +23,11 @@
<result property="senduuid" column="senduuid"/>
<result property="result" column="result"/>
<result property="finishtime" column="finishtime"/>
+ <result property="finishState" column="finish_state"/>
<result property="recordid" column="recordid"/>
<result property="exrecallcount" column="exrecallcount"/>
<result property="pulltime" column="pulltime"/>
- <result property="deptcode" column="deptcode"/>
+ <result property="leaveldeptcode" column="leaveldeptcode"/>
<result property="labelstatus" column="labelstatus"/>
<result property="delFlag" column="del_flag"/>
<result property="updateBy" column="update_by"/>
@@ -53,6 +54,11 @@
<result property="leaveicd10code" column="leaveicd10code"/>
<result property="leavediagname" column="leavediagname"/>
<result property="diagname" column="diagname"/>
+ <result property="leaveldeptname" column="leaveldeptname"/>
+ <!-- 2026-11锛氬師 sendlimit* 鍥涗釜绌洪棽鍒楀鐢ㄤ负銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrict* = 鍦ㄩ櫌鐥呭尯锛宒eptcode/name = 鍦ㄩ櫌绉戝锛� -->
+ <result property="hospitaldistrictcode" column="hospitaldistrictcode"/>
+ <result property="hospitaldistrictname" column="hospitaldistrictname"/>
+ <result property="deptcode" column="deptcode"/>
<result property="deptname" column="deptname"/>
<result property="admindate" column="admindate"/>
<result property="roomno" column="roomno"/>
@@ -72,6 +78,7 @@
<result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/>
<result property="excep" column="excep"/>
<result property="remark" column="remark"/>
+ <result property="doctorOpinion" column="doctor_opinion"/>
<result property="suggest" column="suggest"/>
<result property="sendstate" column="sendstate"/>
<result property="inhospid" column="inhospid"/>
@@ -80,6 +87,7 @@
<result property="visitCount" column="visit_count"/>
<result property="isVisitAgain" column="is_visit_again"/>
<result property="upid" column="upid"/>
+ <result property="visitType" column="visit_type"/>
<result property="visitTime" column="visit_time"/>
<result property="visitDeptName" column="visit_dept_name"/>
<result property="visitDeptCode" column="visit_dept_code"/>
@@ -100,6 +108,7 @@
<result property="loopCount" column="loop_count"/>
<result property="isManuallyCalled" column="is_manually_called"/>
<result property="campusid" column="campusid"/>
+ <result property="diagType" column="diag_type"/>
</resultMap>
<resultMap type="com.ruoyi.task.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -182,6 +191,7 @@
long_send_time,
openid,
remark,
+ doctor_opinion,
service_type,
libtemplateid,
libtemplatename,
@@ -202,10 +212,11 @@
senduuid,
result,
finishtime,
+ finish_state,
recordid,
exrecallcount,
pulltime,
- deptcode,
+ leaveldeptcode,
labelstatus,
del_flag,
update_by,
@@ -228,6 +239,10 @@
sendname,
roomno,
admindate,
+ leaveldeptname,
+ hospitaldistrictcode,
+ hospitaldistrictname,
+ deptcode,
deptname,
stop_state,
leavehospitaldistrictcode,
@@ -249,6 +264,58 @@
task_situation,
is_manually_called
from service_subtask
+ </sql>
+
+ <!-- 瓒呮椂瀹屾垚銆佸欢鏈熷畬鎴愰�昏緫 瀹屾垚鏃剁姸鎬�(finish_state)璁$畻锛氫粎褰撴湰娆℃洿鏂版妸 sendstate 缃负 6锛堥殢璁垮畬鎴愶級鏃朵娇鐢ㄣ��
+ 鍩哄噯鎴鏃堕棿 base = endtime + send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紝
+ 涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
+ delay = COALESCE(service_task.delay_finish_days, 0)锛�
+ finish_time = COALESCE(鍏ュ弬 finishtime, 搴撲腑 finishtime, NOW())锛�
+ finish_time <= base -> 1 姝e父瀹屾垚
+ delay > 0 涓� finish_time <= base + delay -> 2 寤舵湡瀹屾垚
+ 鍏朵綑锛堝惈 delay 涓� 0 鎴� NULL銆佹垨宸茶秴鍑哄欢鏈熺獥鍙o級 -> 3 瓒呮椂瀹屾垚
+ finishtime 涓虹┖鏃剁敤 NOW() 鍏滃簳锛屼繚璇佸畬鎴愭椂涓�瀹氬啓鍏ョ姸鎬侊紱
+ 浠呭綋 endtime 涓虹┖瀵艰嚧鏃犳硶璁$畻鏃舵墠淇濇寔鍘熷�间笉瑕嗙洊銆� -->
+ <sql id="finishStateExpr">
+ CASE
+ WHEN service_subtask.endtime IS NULL THEN finish_state
+ WHEN COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW())
+ <= DATE_ADD(
+ DATE_ADD(
+ service_subtask.endtime,
+ INTERVAL COALESCE((SELECT st.send_day FROM service_task st
+ WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY
+ ),
+ INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED))
+ FROM service_subtask_preachform pf
+ WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY
+ )
+ THEN 1
+ WHEN COALESCE((SELECT st.delay_finish_days FROM service_task st
+ WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) > 0
+ AND COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW())
+ <= DATE_ADD(
+ DATE_ADD(
+ DATE_ADD(
+ service_subtask.endtime,
+ INTERVAL COALESCE((SELECT st.send_day FROM service_task st
+ WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY
+ ),
+ INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED))
+ FROM service_subtask_preachform pf
+ WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY
+ ),
+ INTERVAL COALESCE((SELECT st.delay_finish_days FROM service_task st
+ WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) DAY
+ )
+ THEN 2
+ ELSE 3
+ END
+ </sql>
+
+ <!-- 褰撳墠鎵ц鏂瑰紡锛氶娆¢殢璁� current_preachform 涓虹┖鏃讹紝鍙� preachform 鐨勭涓�涓墽琛屾柟寮忓厹搴� -->
+ <sql id="effectiveCurrentPreachformExpr">
+ COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1)))
</sql>
<select id="selectServiceSubtaskBySendstate" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
@@ -291,9 +358,178 @@
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
</select>
- <select id="selectServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
- resultMap="ServiceSubtaskResult">
- <include refid="selectServiceSubtaskVo"/>
+ <!-- ======================================================================
+ 绉戝 / 鐥呭尯绛涢�夛紙2026-11 淇鐗堬級
+ 涓ょ粍鏉′欢銆愬悇鑷嫭绔嬨�戯紝浜掍笉鐗佃繛锛堝湪闄㈢梾鍖轰笌绂婚櫌鐥呭尯涓嶄細鍚屾椂瀛樺湪锛夛細
+ 绂婚櫌缁勶細leavehospitaldistrictcodes 鈫� leavehospitaldistrictcode
+ leaveldeptcodes 鈫� leaveldeptcode
+ 鍦ㄩ櫌缁勶細hospitaldistrictcodes 鈫� hospitaldistrictcode锛堝湪闄㈢梾鍖猴級
+ deptcodes 鈫� deptcode锛堝湪闄㈢瀹わ級
+ 缁勫唴缁勫悎鏂瑰紡鐢� deptOrDistrict 鍐冲畾锛�'1' = AND锛�'2' = OR銆�
+ 锛�'3'/'4' 鏄�岀闄㈢梾鍖� + 闅忚绉戝 visit_dept_code銆嶉偅濂楋紝鍗曠嫭鍒嗘敮锛屼笉璧拌繖閲岋級
+ 涓ょ粍涔嬮棿鏄� AND锛氬彧浼犱竴缁勬椂鍙︿竴缁勮嚜鍔ㄤ笉鎷笺��
+ 绌烘暟缁� [] 涓�寰嬭涓�"娌′紶"锛屼笉浼氭嫾鍑� IN ()銆�
+ ====================================================================== -->
+ <sql id="filterLeaveDimAnd">
+ /* f-v3 */
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (
+ leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </foreach>
+ <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+ 杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+ NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+ 鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+ OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+ AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </foreach>)
+ )
+ </if>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND (
+ leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>
+ OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+ AND deptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>)
+ )
+ </if>
+ </sql>
+
+ <!-- 鍗冲皢瓒呮椂杩囨护锛氭槸鍚﹀嵆灏嗚秴鏃�(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>
+
+ <sql id="filterLeaveDimOr">
+ /* f-v3 */
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ AND (
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ (
+ leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </foreach>
+ <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+ 杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+ NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+ 鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+ OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+ AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </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">
+ (
+ leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>
+ OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+ AND deptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>)
+ )
+ </if>
+ )
+ </if>
+ </sql>
+
+ <sql id="filterInhospDimAnd">
+ /* f-v3 */
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="inWardCodeItem" open="(" separator="," close=")">
+ #{inWardCodeItem}
+ </foreach>
+ </if>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND deptcode IN
+ <foreach collection="deptcodes" item="inDeptCodeItem" open="(" separator="," close=")">
+ #{inDeptCodeItem}
+ </foreach>
+ </if>
+ </sql>
+
+ <sql id="filterInhospDimOr">
+ /* f-v3 */
+ <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0)
+ or (deptcodes != null and deptcodes.size() > 0)">
+ AND (
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="inWardCodeItem" open="(" separator="," close=")">
+ #{inWardCodeItem}
+ </foreach>
+ </if>
+ <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0)
+ and (deptcodes != null and deptcodes.size() > 0)">
+ OR
+ </if>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ deptcode IN
+ <foreach collection="deptcodes" item="inDeptCodeItem" open="(" separator="," close=")">
+ #{inDeptCodeItem}
+ </foreach>
+ </if>
+ )
+ </if>
+ </sql>
+
+ <!-- ==================================================================
+ service_subtask 鍒楄〃鏌ヨ鐨勫叕鍏� where 鐗囨
+ ==================================================================
+ patItem 璧般�屼袱闃舵鍒嗛〉銆嶏細
+ 鈶� selectServiceSubtaskIdsPage 鈥斺�� 鍙煡 id锛岃蛋瑕嗙洊绱㈠紩锛屼笉涓鸿 offset
+ 璺宠繃鐨勬瘡涓�琛屽洖琛ㄨ 100 鍒楋紱
+ 鈶� selectServiceSubtaskList + subIdList 鈥斺�� 鎸� id 鍥炶〃锛屽彧璇讳竴椤电殑閲忋��
+ 涓ゆ潯璇彞鐨� where 蹇呴』銆愰�愬瓧涓�鑷淬�戯紝鍚﹀垯绗憽姝ヤ細鎶婄鈶犳閫夊嚭鐨勮杩囨护鎺夛紝
+ 瀵艰嚧涓�椤佃繑鍥炰笉瓒� pageSize 鏉°�傛墍浠ユ敹鎴愬叕鍏辩墖娈碉紝鏉滅粷涓や唤鍙e緞婕傜Щ銆�
+ ================================================================== -->
+ <sql id="serviceSubtaskWhere">
where del_flag = 0
<if test="subId != null ">and id = #{subId}</if>
<if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
@@ -367,63 +603,43 @@
'%')
</if>
<if test="startOutHospTime != null">
- AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND endtime >= DATE(#{startOutHospTime})
</if>
<if test="endOutHospTime != null">
- AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY)
</if>
<if test="startSendDateTime != null">
- AND date_format(visit_time,'%y%m%d') >= date_format(#{startSendDateTime},'%y%m%d')
+ AND visit_time >= DATE(#{startSendDateTime})
</if>
<if test="endSendDateTime != null">
- AND date_format(visit_time,'%y%m%d') <= date_format(#{endSendDateTime},'%y%m%d')
+ AND visit_time < DATE_ADD(DATE(#{endSendDateTime}), INTERVAL 1 DAY)
</if>
<if test="finishtimeStart != null">
- AND date_format(finishtime,'%y%m%d') >= date_format(#{finishtimeStart},'%y%m%d')
+ AND finishtime >= DATE(#{finishtimeStart})
</if>
<if test="finishtimeEnd != null">
- AND date_format(finishtime,'%y%m%d') <= date_format(#{finishtimeEnd},'%y%m%d')
+ AND finishtime < DATE_ADD(DATE(#{finishtimeEnd}), INTERVAL 1 DAY)
</if>
<if test="longSendTime != null">
- AND date_format(long_send_time,'%y%m%d') <= date_format(#{longSendTime},'%y%m%d')
+ AND long_send_time < DATE_ADD(DATE(#{longSendTime}), INTERVAL 1 DAY)
</if>
- <if test="deptOrDistrict==1">
- <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>
+ <!--
+ 绉戝/鐥呭尯绛涢�夛紙2026-11 淇锛夛細
+ 绂婚櫌缁勶紙leaveldeptcodes / leavehospitaldistrictcodes锛変繚鎸佸師閫昏緫锛�
+ 鍦ㄩ櫌缁勶紙deptcodes / hospitaldistrictcodes 鈫� deptcode / hospitaldistrictcode锛夋槸鏂板鐨勪竴缁勶紱
+ 缁勫唴鎸� deptOrDistrict 鍙� AND('1') / OR('2')锛屼袱缁勪箣闂� AND锛堝彧浼犱竴缁勬椂鍙︿竴缁勪笉鎷硷級銆�
+ -->
+ <if test='deptOrDistrict == "1"'>
+ <include refid="filterLeaveDimAnd"/>
+ <include refid="filterInhospDimAnd"/>
</if>
- <if test="deptOrDistrict==2">
- AND (1=1
- <if test="leavehospitaldistrictcodes != null">
- AND leavehospitaldistrictcode IN
- <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
- separator=","
- close=")">
- #{leavehospitaldistrictcode}
- </foreach>
- </if>
- <if test=" leaveldeptcodes != null">
- OR deptcode IN
- <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
- close=")">
- #{leaveldeptcode}
- </foreach>
- </if>
- )
+ <if test='deptOrDistrict == "2"'>
+ <include refid="filterLeaveDimOr"/>
+ <include refid="filterInhospDimOr"/>
</if>
- <if test="deptOrDistrict==3">
+ <!-- 鈿狅笍 deptOrDistrict 鏄� String锛歄GNL 閲� '1'锛堝崟寮曞彿鍗曞瓧绗︼級鏄� char锛孲tring != char 鎭� false锛�
+ 蹇呴』鍐欐垚鍙屽紩鍙峰瓧绗︿覆锛圶ML 灞炴�х敤鍗曞紩鍙峰寘浣忥級锛屾垨鐩存帴鍜屾暟瀛楁瘮锛圤GNL 浼氬仛 String鈫扤umber 杞崲锛夈�� -->
+ <if test='deptOrDistrict == "3"'>
AND (1=1
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -442,7 +658,7 @@
</if>
)
</if>
- <if test="deptOrDistrict==4">
+ <if test='deptOrDistrict == "4"'>
AND (1=1
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -462,7 +678,8 @@
)
</if>
<if test="visitTime != null">
- AND date_format(visit_time,'%y%m%d') = date_format(#{visitTime},'%y%m%d')
+ AND visit_time >= DATE(#{visitTime})
+ AND visit_time < DATE_ADD(DATE(#{visitTime}), INTERVAL 1 DAY)
</if>
<if test="senddate != null ">and senddate = #{senddate}</if>
<if test="senduuid != null and senduuid != ''">and senduuid = #{senduuid}</if>
@@ -471,8 +688,8 @@
<if test="recordid != null ">and recordid = #{recordid}</if>
<if test="exrecallcount != null ">and exrecallcount = #{exrecallcount}</if>
<if test="pulltime != null ">and pulltime = #{pulltime}</if>
- <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if>
- <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if>
+ <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if>
<if test="labelstatus != null ">and labelstatus = #{labelstatus}</if>
<if test="isupload != null ">and isupload = #{isupload}</if>
<if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
@@ -480,7 +697,10 @@
<if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
<if test="pid != null ">and pid = #{pid}</if>
<if test="preachform != null ">and preachform = #{preachform}</if>
- <if test="currentPreachform != null ">and current_preachform = #{currentPreachform}</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if>
+ <if test="currentPreachforms != null and currentPreachforms != ''">
+ and FIND_IN_SET(<include refid="effectiveCurrentPreachformExpr"/>, #{currentPreachforms})
+ </if>
<if test="guid != null and guid != ''">and guid = #{guid}</if>
<if test="textParam != null and textParam != ''">and text_param = #{textParam}</if>
<if test="bedNo != null">and bed_no = #{bedNo}</if>
@@ -510,6 +730,7 @@
AND visit_count > 1
</if>
<if test="remark != null">and remark = #{remark}</if>
+ <if test="doctorOpinion != null and doctorOpinion != ''">and doctor_opinion like concat('%', #{doctorOpinion}, '%')</if>
<if test="suggest != null">and suggest = #{suggest}</if>
<if test="createBy != null">and create_by = #{createBy}</if>
<if test="taskGuid != null">and task_guid = #{taskGuid}</if>
@@ -524,6 +745,12 @@
#{visitDeptCode}
</foreach>
</if>
+ <include refid="soonTimeoutFilter"/>
+ </sql>
+
+ <!-- 鎺掑簭鐗囨锛氫繚鎸佸師璇箟锛屽彧鍦ㄨ皟鐢ㄦ柟鏄惧紡浼� sort 鏃舵墠鎷� order by
+ 锛堝鍑虹瓑涓嶅垎椤电殑璋冪敤鏂硅涓哄畬鍏ㄤ笉鍙橈級 -->
+ <sql id="serviceSubtaskOrderBy">
<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>
@@ -533,7 +760,37 @@
<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>
+ </sql>
+
+ <!-- 鍒嗛〉鍦烘櫙涓撶敤鎺掑簭锛歴ort 涓虹┖鏃跺厹搴� order by id desc銆�
+ 鍘熸潵 sort 涓虹┖鏃舵暣鏉� SQL 娌℃湁 order by锛宭imit/offset 鍙栧埌鐨勬槸銆屼笉纭畾椤哄簭銆嶏紝
+ 缈婚〉浼氶噸澶嶆垨婕忚锛涜繖閲岀粰涓�涓ǔ瀹氶『搴忥紙鎯虫敼鎴� id asc 鍙敼杩欎竴琛岋級銆� -->
+ <sql id="serviceSubtaskOrderByPaged">
+ <include refid="serviceSubtaskOrderBy"/>
+ <if test="sort == null">order by id desc</if>
+ </sql>
+
+ <select id="selectServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
+ resultMap="ServiceSubtaskResult">
+ <include refid="selectServiceSubtaskVo"/>
+ <include refid="serviceSubtaskWhere"/>
+ <include refid="serviceSubtaskOrderBy"/>
<if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+ </select>
+
+ <!--
+ 涓ら樁娈靛垎椤电 1 姝ワ細鍙彇 id銆�
+ select 鍒楄〃鍙湁 id锛寃here/order 娑夊強鐨勫垪閮藉湪 idx_ss_org_cam_del_* 涓婏紝
+ 鍥犳鑳借蛋銆岃鐩栫储寮� + 鎻愬墠鎴柇銆嶏紱琚� offset 璺宠繃鐨勯偅鍑犲崈琛屼笉鍐嶅洖琛ㄨ 100 鍒椼��
+ 绗� 2 姝ョ敱璋冪敤鏂圭敤 subIdList 鍥炶〃鍙栨暣琛岋紙瑙� ServiceSubtaskServiceImpl#selectServiceSubtaskPage锛夈��
+ -->
+ <select id="selectServiceSubtaskIdsPage" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
+ resultType="java.lang.Long">
+ select id
+ from service_subtask
+ <include refid="serviceSubtaskWhere"/>
+ <include refid="serviceSubtaskOrderByPaged"/>
+ limit ${pageSize} OFFSET ${pageNum}
</select>
<select id="getCompensateServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
@@ -589,7 +846,7 @@
<if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
<if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
<if test="managementDoctor != null">and management_doctor = #{managementDoctor}</if>
- <if test="currentPreachform != null">and current_preachform = #{currentPreachform}</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if>
<if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
<if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -615,8 +872,8 @@
<if test="recordid != null ">and recordid = #{recordid}</if>
<if test="exrecallcount != null ">and exrecallcount = #{exrecallcount}</if>
<if test="pulltime != null ">and pulltime = #{pulltime}</if>
- <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if>
- <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if>
+ <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if>
<if test="labelstatus != null ">and labelstatus = #{labelstatus}</if>
<if test="isupload != null ">and isupload = #{isupload}</if>
<if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
@@ -648,7 +905,7 @@
<if test="visitTime != null ">and visit_time = #{visitTime}</if>
<if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
<if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
- <if test="currentPreachform != null">and current_preachform = #{currentPreachform}</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if>
<if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
<if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
<if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
@@ -656,6 +913,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.ruoyi.task.domain.ServiceSubtask" resultType="Integer">
@@ -691,8 +949,8 @@
<if test="campusid != null and campusid != ''">and campusid = #{campusid}</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="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if>
<if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
<if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and
leavehospitaldistrictcode = #{leavehospitaldistrictcode}
@@ -703,10 +961,10 @@
<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')
+ AND endtime >= DATE(#{startOutHospTime})
</if>
<if test="endOutHospTime != null">
- AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY)
</if>
) a
</select>
@@ -750,8 +1008,8 @@
</if>
<if test="orgid != null and orgid != ''">AND ss.orgid = #{orgid}</if>
<if test="campusid != null and campusid != ''">and ss.campusid = #{campusid}</if>
- <if test="deptcode != null and deptcode != ''">and ss.deptcode = #{deptcode}</if>
- <if test="deptname != null and deptname != ''">and ss.deptname = #{deptname}</if>
+ <if test="leaveldeptcode != null and leaveldeptcode != ''">and ss.leaveldeptcode = #{leaveldeptcode}</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">and ss.leaveldeptname = #{leaveldeptname}</if>
<if test="isabnormal != null">and ss.isabnormal = #{isabnormal}</if>
<if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and
ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
@@ -781,7 +1039,7 @@
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
+ AND IFNULL(ss.${groupKey}, 'Unknown') IN
<foreach collection="groupKeyList" item="key" open="(" separator=","
close=")">
#{key}
@@ -812,8 +1070,8 @@
<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>
+ <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if>
<if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and
leavehospitaldistrictcode = #{leavehospitaldistrictcode}
</if>
@@ -822,6 +1080,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 where a.finished =1)
</select>
@@ -846,10 +1110,10 @@
<if test="continueCount != null ">and continue_count = #{continueCount}</if>
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
<if test="startOutHospTime != null">
- AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND endtime >= DATE(#{startOutHospTime})
</if>
<if test="endOutHospTime != null">
- AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY)
</if>
GROUP BY sendname,sendstate,starttime,endtime,nurse_name,phone,sex,task_name,leavediagname,visit_time
ORDER BY sendname,visit_time
@@ -875,10 +1139,16 @@
<if test="senduuid != null">senduuid,</if>
<if test="result != null">result,</if>
<if test="finishtime != null">finishtime,</if>
+ <if test="finishState != null">finish_state,</if>
<if test="recordid != null">recordid,</if>
<if test="exrecallcount != null">exrecallcount,</if>
<if test="pulltime != null">pulltime,</if>
- <if test="deptcode != null">deptcode,</if>
+ <if test="leaveldeptcode != null">leaveldeptcode,</if>
+ <!-- 2026-11锛氬師 sendlimit* 澶嶇敤鍒楋紙鍦ㄩ櫌缁村害锛氬湪闄㈢梾鍖�/鍦ㄩ櫌绉戝锛夛紝浠呭嚭闄㈤殢璁夸細濉�� -->
+ <if test="hospitaldistrictcode != null and hospitaldistrictcode != ''">hospitaldistrictcode,</if>
+ <if test="hospitaldistrictname != null and hospitaldistrictname != ''">hospitaldistrictname,</if>
+ <if test="deptcode != null and deptcode != ''">deptcode,</if>
+ <if test="deptname != null and deptname != ''">deptname,</if>
<if test="labelstatus != null">labelstatus,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
@@ -903,9 +1173,13 @@
<if test="wechat != null and wechat != ''">wechat,</if>
<if test="roomno != null and roomno != ''">roomno,</if>
<if test="admindate != null">admindate,</if>
- <if test="deptname != null and deptname != ''">deptname,</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname,</if>
<if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code,</if>
<if test="leavediagname != null and leavediagname != ''">leavediagname,</if>
+ <!-- diagname锛氬叆闄㈣瘖鏂悕绉般�傚師 insert 婕忎簡杩欎竴鍒楋紝鑰屽嚭闄㈤摼璺殑
+ boxedServiceSubtask 涓�鐩村湪 setDiagname(patMedInhosp.diagname)锛�
+ 浜庢槸 service_subtask.diagname 姘歌繙涓� NULL锛坰elect 渚у嵈涓�鐩村湪璇诲畠锛夈�� -->
+ <if test="diagname != null and diagname != ''">diagname,</if>
<if test="libtemplateid != null ">libtemplateid,</if>
<if test="libtemplatename != null ">libtemplatename,</if>
<if test="patid != null ">patid,</if>
@@ -928,6 +1202,7 @@
<if test="nurseName != null ">nurse_name,</if>
<if test="nurseId != null ">nurse_id,</if>
<if test="remark != null ">remark,</if>
+ <if test="doctorOpinion != null ">doctor_opinion,</if>
<if test="suggest != null ">suggest,</if>
<if test="sendstate != null ">sendstate,</if>
<if test="inhospid != null ">inhospid,</if>
@@ -942,7 +1217,7 @@
<if test="visitDeptName != null">visit_dept_name,</if>
<if test="managementDoctorCode != null">management_doctor_code,</if>
<if test="managementDoctor != null">management_doctor,</if>
- <if test="currentPreachform != null">current_preachform,</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">current_preachform,</if>
<if test="taskSituation != null">task_situation,</if>
<if test="isabnormal != null">isabnormal,</if>
<if test="continueFlag != null ">continue_flag,</if>
@@ -973,10 +1248,16 @@
<if test="senduuid != null">#{senduuid},</if>
<if test="result != null">#{result},</if>
<if test="finishtime != null">#{finishtime},</if>
+ <if test="finishState != null">#{finishState},</if>
<if test="recordid != null">#{recordid},</if>
<if test="exrecallcount != null">#{exrecallcount},</if>
<if test="pulltime != null">#{pulltime},</if>
- <if test="deptcode != null">#{deptcode},</if>
+ <if test="leaveldeptcode != null">#{leaveldeptcode},</if>
+ <!-- 2026-11锛氬師 sendlimit* 澶嶇敤鍒楋紙鍏ラ櫌/鍦ㄩ櫌缁村害锛夛紝浠呭嚭闄㈤殢璁夸細濉�� -->
+ <if test="hospitaldistrictcode != null and hospitaldistrictcode != ''">#{hospitaldistrictcode},</if>
+ <if test="hospitaldistrictname != null and hospitaldistrictname != ''">#{hospitaldistrictname},</if>
+ <if test="deptcode != null and deptcode != ''">#{deptcode},</if>
+ <if test="deptname != null and deptname != ''">#{deptname},</if>
<if test="labelstatus != null">#{labelstatus},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@@ -1001,9 +1282,10 @@
<if test="wechat != null and wechat != ''">#{wechat},</if>
<if test="roomno != null and roomno != ''">#{roomno},</if>
<if test="admindate != null ">#{admindate},</if>
- <if test="deptname != null and deptname != ''">#{deptname},</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">#{leaveldeptname},</if>
<if test="leaveicd10code != null and leaveicd10code != ''">#{leaveicd10code},</if>
<if test="leavediagname != null and leavediagname != ''">#{leavediagname},</if>
+ <if test="diagname != null and diagname != ''">#{diagname},</if>
<if test="libtemplateid != null ">#{libtemplateid},</if>
<if test="libtemplatename != null ">#{libtemplatename},</if>
<if test="patid != null ">#{patid},</if>
@@ -1026,6 +1308,7 @@
<if test="nurseName != null ">#{nurseName},</if>
<if test="nurseId != null ">#{nurseId},</if>
<if test="remark != null ">#{remark},</if>
+ <if test="doctorOpinion != null ">#{doctorOpinion},</if>
<if test="suggest != null ">#{suggest},</if>
<if test="sendstate != null ">#{sendstate},</if>
<if test="inhospid != null ">#{inhospid},</if>
@@ -1040,7 +1323,7 @@
<if test="visitDeptName != null">#{visitDeptName},</if>
<if test="managementDoctorCode != null">#{managementDoctorCode},</if>
<if test="managementDoctor != null">#{managementDoctor},</if>
- <if test="currentPreachform != null">#{currentPreachform},</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">#{currentPreachform},</if>
<if test="taskSituation != null">#{taskSituation},</if>
<if test="isabnormal != null">#{isabnormal},</if>
<if test="continueFlag != null ">#{continueFlag},</if>
@@ -1056,6 +1339,15 @@
<if test="isManuallyCalled != null ">#{isManuallyCalled},</if>
</trim>
</insert>
+
+ <!-- 浜屾闅忚骞傜瓑锛氫粎褰� is_visit_again 涓嶆槸鐩爣鍊兼椂鏇存柊锛岃繑鍥炲彈褰卞搷琛屾暟 -->
+ <update id="updateIsVisitAgainById">
+ update service_subtask
+ set is_visit_again = #{isVisitAgain},
+ update_time = now()
+ where id = #{id}
+ and (is_visit_again is null or is_visit_again <> #{isVisitAgain})
+ </update>
<update id="updateServiceSubtask" parameterType="com.ruoyi.task.domain.ServiceSubtask">
update service_subtask
@@ -1079,7 +1371,7 @@
<if test="recordid != null">recordid = #{recordid},</if>
<if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if>
<if test="pulltime != null">pulltime = #{pulltime},</if>
- <if test="deptcode != null">deptcode = #{deptcode},</if>
+ <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if>
<if test="labelstatus != null">labelstatus = #{labelstatus},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@@ -1104,7 +1396,7 @@
<if test="wechat != null and wechat != ''">wechat = #{wechat},</if>
<if test="roomno != null and roomno != ''">roomno = #{roomno},</if>
<if test="admindate != null ">admindate = #{admindate},</if>
- <if test="deptname != null and deptname != ''">deptname = #{deptname},</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if>
<if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if>
<if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if>
<if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if>
@@ -1113,6 +1405,7 @@
<if test="openid != null ">openid = #{openid},</if>
<if test="longSendTime != null ">long_send_time = #{longSendTime},</if>
<if test="sendstate != null ">sendstate = #{sendstate},</if>
+ <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
<if test="serviceType != null ">service_type = #{serviceType},</if>
<if test="score != null ">score = #{score},</if>
<if test="submit != null ">submit = #{submit},</if>
@@ -1130,6 +1423,7 @@
<if test="nurseName != null ">nurse_name=#{nurseName},</if>
<if test="nurseId != null ">nurse_id=#{nurseId},</if>
<if test="remark != null ">remark=#{remark},</if>
+ <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if>
<if test="suggest != null ">suggest=#{suggest},</if>
<if test="inhospid != null ">inhospid=#{inhospid},</if>
<if test="patfrom != null ">patfrom=#{patfrom},</if>
@@ -1143,7 +1437,7 @@
<if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
<if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
<if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
- <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if>
<if test="taskSituation != null">task_situation=#{taskSituation},</if>
<if test="isabnormal != null">isabnormal=#{isabnormal},</if>
<if test="continueFlag != null ">continue_flag = #{continueFlag},</if>
@@ -1159,6 +1453,25 @@
<if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
where id = #{id}
+ </update>
+
+ <!-- 寰俊鍏紬鍙峰凡棰嗗彇鏈~鍐欐寜榛樿閫夐」瀹屾垚锛氬彧鏇存柊褰撳墠瀛愪换鍔°��
+ 鏉′欢 sendstate=1 + 鏈彁浜わ紝淇濊瘉鍙鐞嗗綋鍓嶈棰嗗彇涓旀湭濉啓鐨勫瓙浠诲姟锛屼笉娉㈠強鍏朵粬浠诲姟銆� -->
+ <update id="updateWechatDefaultComplete" parameterType="com.ruoyi.task.domain.ServiceSubtask">
+ update service_subtask
+ set sendstate = 6,
+ finishtime = #{finishtime},
+ result = #{result},
+ remark = case
+ when remark is null or remark = '' then #{remark}
+ else concat(remark, ',', #{remark})
+ end,
+ update_time = now(),
+ finish_state = <include refid="finishStateExpr"/>
+ where id = #{id}
+ and orgid = #{orgid}
+ and sendstate = 1
+ and (submit is null or submit != 1)
</update>
<update id="updateServiceSubtaskByPatId" parameterType="com.ruoyi.task.domain.ServiceSubtask">
@@ -1183,7 +1496,7 @@
<if test="recordid != null">recordid = #{recordid},</if>
<if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if>
<if test="pulltime != null">pulltime = #{pulltime},</if>
- <if test="deptcode != null">deptcode = #{deptcode},</if>
+ <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if>
<if test="labelstatus != null">labelstatus = #{labelstatus},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@@ -1208,7 +1521,7 @@
<if test="wechat != null and wechat != ''">wechat = #{wechat},</if>
<if test="roomno != null and roomno != ''">roomno = #{roomno},</if>
<if test="admindate != null">admindate = #{admindate},</if>
- <if test="deptname != null and deptname != ''">deptname = #{deptname},</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if>
<if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if>
<if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if>
<if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if>
@@ -1217,6 +1530,7 @@
<if test="openid != null ">openid = #{openid},</if>
<if test="longSendTime != null ">long_send_time = #{longSendTime},</if>
<if test="sendstate != null ">sendstate = #{sendstate},</if>
+ <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
<if test="serviceType != null ">service_type = #{serviceType},</if>
<if test="score != null ">score = #{score},</if>
<if test="visitCount != null ">visit_count = #{visitCount},</if>
@@ -1235,6 +1549,7 @@
<if test="nurseName != null ">nurse_name=#{nurseName},</if>
<if test="nurseId != null ">nurse_id=#{nurseId},</if>
<if test="remark != null ">remark=#{remark},</if>
+ <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if>
<if test="suggest != null ">suggest=#{suggest},</if>
<if test="inhospid != null ">inhospid=#{inhospid},</if>
<if test="patfrom != null ">patfrom=#{patfrom},</if>
@@ -1247,7 +1562,7 @@
<if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
<if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
<if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
- <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if>
<if test="taskSituation != null">task_situation=#{taskSituation},</if>
<if test="isabnormal != null">isabnormal=#{isabnormal},</if>
<if test="continueFlag != null ">continue_flag = #{continueFlag},</if>
@@ -1273,6 +1588,7 @@
<if test="sex != null">sex = #{sex},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="sendstate != null ">sendstate = #{sendstate},</if>
+ <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
<if test="age != null">age = #{age},</if>
<if test="sfzh != null">sfzh = #{sfzh},</if>
<if test="addr != null">addr = #{addr},</if>
@@ -1288,7 +1604,7 @@
<if test="recordid != null">recordid = #{recordid},</if>
<if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if>
<if test="pulltime != null">pulltime = #{pulltime},</if>
- <if test="deptcode != null">deptcode = #{deptcode},</if>
+ <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if>
<if test="labelstatus != null">labelstatus = #{labelstatus},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@@ -1315,7 +1631,7 @@
<if test="wechat != null and wechat != ''">wechat = #{wechat},</if>
<if test="roomno != null and roomno != ''">roomno = #{roomno},</if>
<if test="admindate != null">admindate = #{admindate},</if>
- <if test="deptname != null and deptname != ''">deptname = #{deptname},</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if>
<if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if>
<if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if>
<if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if>
@@ -1340,6 +1656,7 @@
<if test="nurseName != null ">nurse_name=#{nurseName},</if>
<if test="nurseId != null ">nurse_id=#{nurseId},</if>
<if test="remark != null ">remark=#{remark},</if>
+ <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if>
<if test="suggest != null ">suggest=#{suggest},</if>
<if test="inhospid != null ">inhospid=#{inhospid},</if>
<if test="patfrom != null ">patfrom=#{patfrom},</if>
@@ -1351,7 +1668,7 @@
<if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
<if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
<if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
- <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if>
<if test="taskSituation != null">task_situation=#{taskSituation},</if>
<if test="isabnormal != null">isabnormal=#{isabnormal},</if>
<if test="continueFlag != null ">continue_flag = #{continueFlag},</if>
@@ -1384,6 +1701,7 @@
<if test="phone != null">phone = #{phone},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="sendstate != null ">sendstate = #{sendstate},</if>
+ <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if>
<if test="age != null">age = #{age},</if>
<if test="sfzh != null">sfzh = #{sfzh},</if>
<if test="addr != null">addr = #{addr},</if>
@@ -1399,7 +1717,7 @@
<if test="recordid != null">recordid = #{recordid},</if>
<if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if>
<if test="pulltime != null">pulltime = #{pulltime},</if>
- <if test="deptcode != null">deptcode = #{deptcode},</if>
+ <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if>
<if test="labelstatus != null">labelstatus = #{labelstatus},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@@ -1426,7 +1744,7 @@
<if test="admindate != null ">admindate = #{admindate},</if>
<if test="visitCount != null ">visit_count = #{visitCount},</if>
<if test="isVisitAgain != null ">is_visit_again = #{isVisitAgain},</if>
- <if test="deptname != null and deptname != ''">deptname = #{deptname},</if>
+ <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if>
<if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if>
<if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if>
<if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if>
@@ -1451,6 +1769,7 @@
<if test="nurseName != null ">nurse_name=#{nurseName},</if>
<if test="nurseId != null ">nurse_id=#{nurseId},</if>
<if test="remark != null ">remark=#{remark},</if>
+ <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if>
<if test="suggest != null ">suggest=#{suggest},</if>
<if test="inhospid != null ">inhospid=#{inhospid},</if>
<if test="patfrom != null ">patfrom=#{patfrom},</if>
@@ -1462,7 +1781,7 @@
<if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
<if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
<if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
- <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if>
+ <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if>
<if test="taskSituation != null">task_situation=#{taskSituation},</if>
<if test="isabnormal != null">isabnormal=#{isabnormal},</if>
<if test="continueFlag != null ">continue_flag = #{continueFlag},</if>
@@ -1491,6 +1810,35 @@
where patid = #{patid} and taskid = #{taskid}
</update>
+ <!-- 浜哄伐闅忚锛氳蒋鍒犻櫎鎮h�呭嚭闄㈣褰曞搴旂殑鏈畬鎴愰殢璁夸换鍔� -->
+ <update id="deleteUnfinishedServiceSubtaskByInhospids">
+ update service_subtask
+ set del_flag = 1
+ where del_flag = 0
+ and patid = #{patid}
+ and sendstate in
+ <foreach collection="sendstates" item="sendstate" open="(" separator="," close=")">
+ #{sendstate}
+ </foreach>
+ and inhospid in
+ <foreach collection="inhospids" item="inhospid" open="(" separator="," close=")">
+ #{inhospid}
+ </foreach>
+ </update>
+
+ <!-- 浜哄伐闅忚閲嶅鏍¢獙锛氬悓涓�鎮h�呭悓涓�浠诲姟涓嬫槸鍚﹀凡鏈夋湭瀹屾垚闅忚浠诲姟 -->
+ <select id="countUnfinishedServiceSubtaskByPatidAndTaskid" resultType="int">
+ select count(1)
+ from service_subtask
+ where del_flag = 0
+ and patid = #{patid}
+ and taskid = #{taskid}
+ and sendstate in
+ <foreach collection="sendstates" item="sendstate" open="(" separator="," close=")">
+ #{sendstate}
+ </foreach>
+ </select>
+
<select id="getSfStatistics" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
resultMap="ServiceSubtaskResult">
select id,
@@ -1504,17 +1852,21 @@
management_doctor,
leavehospitaldistrictcode,
leavehospitaldistrictname,
- deptcode,
- deptname,
+ leaveldeptcode,
+ leaveldeptname,
sendstate,
preachform,
- current_preachform,
+ <include refid="effectiveCurrentPreachformExpr"/> AS current_preachform,
excep,
nurse_id,
nurse_name,
taskid,
task_name,
+ <if test="groupKey != null and groupKey == 'taskid'">
+ (SELECT st.diag_type FROM service_task st WHERE st.taskid = service_subtask.taskid LIMIT 1) AS diag_type,
+ </if>
visit_time,
+ visit_dept_code,
finishtime,
endtime,
senddate,
@@ -1532,7 +1884,9 @@
continue_content,
continue_count,
continue_time_next,
- task_situation
+ task_situation,
+ finish_state,
+ is_manually_called
from service_subtask
where 1=1
and del_flag = 0
@@ -1542,18 +1896,30 @@
<if test="campusid != null and campusid != ''">
and campusid = #{campusid}
</if>
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"
+ 鍗楀崕婊℃剰搴﹀瓙浠诲姟鐨� leavehospitaldistrictcode 鏈� 83%锛�3236/3811锛変负 NULL锛�
+ 鍘熸潵銆岀瀹� AND 鐥呭尯銆嶄袱涓潯浠舵案杩滀笉鍙兘鍚屾椂鎴愮珛 鈫� 鏁村紶缁熻琛ㄧ┖銆�
+ 鍒ょ┖鏀捐鍙奖鍝嶇梾鍖轰负绌虹殑璁板綍锛屾湁鐥呭尯鐨勬暟鎹涓轰笉鍙樸�� -->
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ )
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
+ </foreach>
+ </if>
+ <if test="taskIds != null and taskIds.size() > 0">
+ AND taskid IN
+ <foreach collection="taskIds" item="taskId" open="(" separator=","
+ close=")">
+ #{taskId}
</foreach>
</if>
<if test="serviceType != null and serviceType.size() > 0">
@@ -1563,9 +1929,10 @@
#{serviceType}
</foreach>
</if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖锛堝崡鍗庢弧鎰忓害 3811/3811 鍏ㄤ负 NULL锛夋椂鎸夊畬鎴�/鍒涘缓鏃堕棿鍏滃簳 -->
<if test="startTime != null and endTime!=null">
- AND visit_time >= DATE(#{startTime})
- AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime})
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
</if>
<if test="hospitalStartTime != null and hospitalEndTime!=null">
AND endtime >= DATE(#{hospitalStartTime})
@@ -1589,7 +1956,7 @@
AND visit_count > 1
</if>
<if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0">
- AND ${groupKey} IN
+ AND IFNULL(${groupKey}, 'Unknown') IN
<foreach collection="groupKeyList" item="key" open="(" separator=","
close=")">
#{key}
@@ -1668,7 +2035,7 @@
</foreach>
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND b.deptcode IN
+ AND b.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -1713,9 +2080,17 @@
<select id="getSfStatisticsGroupKey" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
resultType="String">
select
- <if test="groupKey != null and groupKey != ''">
- ${groupKey} as groupKey
- </if>
+ <choose>
+ <when test="groupColumn != null and groupColumn != ''">
+ ${groupColumn} as groupKey
+ </when>
+ <when test="groupKey != null and groupKey != ''">
+ ${groupKey} as groupKey
+ </when>
+ <otherwise>
+ NULL as groupKey
+ </otherwise>
+ </choose>
from service_subtask
where 1=1
and del_flag = 0
@@ -1725,18 +2100,77 @@
<if test="campusid != null and campusid != ''">
and campusid = #{campusid}
</if>
- <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"
+ 鍗楀崕婊℃剰搴﹀瓙浠诲姟鐨� leavehospitaldistrictcode 鏈� 83%锛�3236/3811锛変负 NULL锛�
+ 鍘熸潵銆岀瀹� AND 鐥呭尯銆嶄袱涓潯浠舵案杩滀笉鍙兘鍚屾椂鎴愮珛 鈫� 鏁村紶缁熻琛ㄧ┖銆�
+ 鍒ょ┖鏀捐鍙奖鍝嶇梾鍖轰负绌虹殑璁板綍锛屾湁鐥呭尯鐨勬暟鎹涓轰笉鍙樸�� -->
+ <choose>
+ <!-- 婊℃剰搴︾粺璁★紙getSfStatisticsScript锛夛細鏀圭敤鈥滄湁鏁堢梾鍖衡�濆垪锛�
+ 鍑洪櫌鐥呭尯涓虹┖鍒欏洖閫�鍒板湪闄㈢梾鍖恒�傜瓫閫夊洜姝ょ湡姝g敓鏁堬紝
+ 绌虹梾鍖虹殑璁板綍涔熶細褰掑埌瀹冪湡瀹炵殑鍦ㄩ櫌鐥呭尯锛岃�屼笉鏄贩杩涚敤鎴烽�変腑鐨勭梾鍖恒�� -->
+ <when test="districtColumn != null and districtColumn != ''">
+ <!-- 鍑洪櫌鐥呭尯涓虹┖鍥為��鍒板湪闄㈢梾鍖恒�傝繖閲屽埢鎰忓啓鎴� OR 灞曞紑鑰屼笉鏄� IFNULL(a,b) IN (...)锛�
+ 鍒楄鍑芥暟鍖呬綇灏辩敤涓嶄簡绱㈠紩锛�56 涓囪鏄庣粏琛ㄤ笂鏄叏琛ㄦ壂锛堝疄娴� 5.1s 鈫� 0.7s锛夈��
+ 涓や釜鍒嗘敮鍒嗗埆鍛戒腑 idx_ss_district_pair 鐨� (leave..., hospital...) 鍓嶇紑銆� -->
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ OR (leavehospitaldistrictcode IS NULL AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
+ </if>
+ </when>
+ <otherwise>
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ )
+ </if>
+ </otherwise>
+ </choose>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
- #{leavehospitaldistrictcode}
+ #{leaveldeptcode}
</foreach>
</if>
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND (hospitaldistrictcode IS NULL OR hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ )
+ </if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
+ </foreach>
+ </if>
+ <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0">
+ AND deptcode IN
+ <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator=","
+ close=")">
+ #{hospitaldeptcode}
+ </foreach>
+ </if>
+ <if test="taskIds != null and taskIds.size() > 0">
+ AND taskid IN
+ <foreach collection="taskIds" item="taskId" open="(" separator=","
+ close=")">
+ #{taskId}
</foreach>
</if>
<if test="serviceType != null and serviceType.size() > 0">
@@ -1746,9 +2180,10 @@
#{serviceType}
</foreach>
</if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖锛堝崡鍗庢弧鎰忓害 3811/3811 鍏ㄤ负 NULL锛夋椂鎸夊畬鎴�/鍒涘缓鏃堕棿鍏滃簳 -->
<if test="startTime != null and endTime!=null">
- AND visit_time >= DATE(#{startTime})
- AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime})
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
</if>
<if test="hospitalStartTime != null and hospitalEndTime!=null">
AND endtime >= DATE(#{hospitalStartTime})
@@ -1771,12 +2206,405 @@
<if test="visitCount != null and visitCount > 1">
AND visit_count > 1
</if>
- <if test="groupKey != null and groupKey != ''">
- group by ${groupKey}
- </if>
+ <choose>
+ <when test="groupColumn != null and groupColumn != ''">
+ group by ${groupColumn}
+ order by ${groupColumn}
+ </when>
+ <when test="groupKey != null and groupKey != ''">
+ group by ${groupKey}
+ order by ${groupKey}
+ </when>
+ </choose>
+ <!-- pageNum 鏄� 1 璧峰鐨勶紝OFFSET 蹇呴』鐢� (pageNum-1)*pageSize锛�
+ 浠ュ墠鐩存帴鍐� OFFSET ${pageNum}锛岀涓�椤典細璺虫帀绗竴鏉″垎缁勩�� -->
<if test="pageSize != null and pageNum != null">
- limit ${pageSize} OFFSET ${pageNum}
+ limit ${pageSize} OFFSET ${pageOffset}
</if>
+ </select>
+
+ <!--
+ ==================================================================
+ 闅忚鍒嗙被缁熻锛�/smartor/serviceSubtask/getSfStatisticsCount锛夋�ц兘浼樺寲
+ ==================================================================
+ 鏀归�犲墠锛歡etSfStatisticsScript 鍏堟妸 service_subtask 鍛戒腑鐨�**鍏ㄩ儴鏄庣粏琛�**
+ 锛坓etSfStatistics 鍏� select 39 涓瓧娈碉紝鍚� continue_content / result / suggest 绛夊ぇ瀛楁锛�
+ 鎹炲洖 JVM锛屽啀鍦ㄥ唴瀛橀噷鎸� drcode/绉戝/鐥呭尯 閫愯 if 绱姞锛涙澶栬繕瑕佹妸杩欐鍛戒腑鐨�
+ **鍏ㄩ儴瀛愪换鍔� id** 鐏岃繘 getSfStatisticsCategory 鐨� IN 鍒楄〃鍐嶆煡涓�閬嶃��
+ 鍛戒腑鍑犲崈琛屾椂锛岀綉缁滀紶杈擄紙杩滅鐨勫簱灏ゅ叾鏄庢樉锛�+ 鍐呭瓨閬嶅巻 + 瓒呭ぇ IN 鍒楄〃灏辨槸鎺ュ彛鎱㈢殑涓诲洜銆�
+
+ 鏀归�犲悗锛氱疮鍔犱笅鎺ㄥ埌鏁版嵁搴擄紝涓�娆� GROUP BY 鍙繑鍥炩�滃垎缁勬暟鈥濓紙閫氬父鍑犲崄琛岋級鐨勭粺璁$粨鏋滐紱
+ 婊℃剰搴﹂鐩噺涔熷悓鏍锋寜鍒嗙粍鍦ㄥ簱閲岃仛鍚堛�傜粺璁″彛寰勪笌鍘熸潵鐨� getStatisticCategory 閫愭潯瀵归綈銆�
+ 杩欎袱涓鍙ョ殑 where 鏉′欢涓� getSfStatistics 淇濇寔涓�鑷达紝淇濊瘉缁撴灉闆嗕笉鍙樸��
+
+ 鍒嗙粍鍒楋紙2026-10 璧凤級锛�
+ 绂婚櫌缁村害 鈥斺�� groupKey = leaveldeptcode / leavehospitaldistrictcode锛�
+ 鍦ㄩ櫌缁村害 鈥斺�� groupKey = deptcode / hospitaldistrictcode锛�
+ 杩囨护涓庡垎缁勪娇鐢ㄥ悓涓�鍒楋紙groupColumn = groupKey锛夛紝閬垮厤鍒嗙粍閿笌鑱氬悎琛屽彛寰勪笉涓�鑷淬��
+ ==================================================================
+ -->
+ <resultMap type="com.ruoyi.task.domain.ServiceSubtaskStatistic" id="ServiceSubtaskScriptStatisticResult">
+ <result property="groupCode" column="group_code"/>
+ <result property="groupName" column="group_name"/>
+ <result property="taskId" column="taskid"/>
+ <result property="taskName" column="task_name"/>
+ <result property="dischargeCount" column="discharge_count"/>
+ <result property="firstVisitCount" column="first_visit_count"/>
+ <result property="againVisitCount" column="again_visit_count"/>
+ <result property="drcode" column="drcode"/>
+ <result property="drname" column="drname"/>
+ <result property="deptcode" column="deptcode"/>
+ <result property="deptname" column="deptname"/>
+ <result property="leavehospitaldistrictcode" column="leavehospitaldistrictcode"/>
+ <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/>
+ <result property="hospitaldistrictcode" column="hospitaldistrictcode"/>
+ <result property="hospitaldistrictname" column="hospitaldistrictname"/>
+ <result property="hospitaldeptcode" column="hospitaldeptcode"/>
+ <result property="hospitaldeptname" column="hospitaldeptname"/>
+ <result property="nonFollowUp" column="non_follow_up"/>
+ <result property="followUpNeeded" column="follow_up_needed"/>
+ <result property="needFollowUp" column="need_follow_up"/>
+ <result property="pendingFollowUp" column="pending_follow_up"/>
+ <result property="followUpSuccess" column="follow_up_success"/>
+ <result property="followUpFail" column="follow_up_fail"/>
+ <result property="manual" column="manual"/>
+ <result property="voice" column="voice"/>
+ <result property="sms" column="sms"/>
+ <result property="weChat" column="we_chat"/>
+ <result property="abnormal" column="abnormal"/>
+ <result property="needFollowUpAgain" column="need_follow_up_again"/>
+ <result property="pendingFollowUpAgain" column="pending_follow_up_again"/>
+ <result property="followUpSuccessAgain" column="follow_up_success_again"/>
+ <result property="followUpFailAgain" column="follow_up_fail_again"/>
+ <result property="manualAgain" column="manual_again"/>
+ <result property="voiceAgain" column="voice_again"/>
+ <result property="smsAgain" column="sms_again"/>
+ <result property="weChatAgain" column="we_chat_again"/>
+ <result property="abnormalAgain" column="abnormal_again"/>
+ </resultMap>
+
+ <!--
+ 鎸夊垎缁勮仛鍚堥殢璁跨粺璁★紙鏇夸唬鈥滃叏閲忔槑缁嗗洖鍐呭瓨鍐嶇疮鍔犫�濓級銆�
+ 鍙e緞璇存槑锛堜笌鍘� ServiceSubtaskServiceImpl.getStatisticCategory 瀹屽叏涓�鑷达級锛�
+ * 鏃犻渶闅忚锛歴endstate = 4
+ * 搴旈殢璁匡細sendstate 闈炵┖涓� != 4
+ * 棣栨(visit_count = 1) / 鍐嶆(visit_count > 1) 涓や釜鍒嗘敮浜掓枼锛屼笌鍘熸潵鐨� if / else if 涓�鑷�
+ * 浜哄伐/璇煶/鐭俊/寰俊锛氶娆″垎鏀�**涓�**鎺掗櫎 sendstate = 4锛堝師浠g爜濡傛锛夛紝鍐嶆鍒嗘敮鍚屾牱
+ * 寮傚父锛歟xcep = '1' 涓� sendstate 闈炵┖
+ * 棣栨闅忚鐜� / 鍐嶆闅忚鐜囧湪 Java 閲屾寜鍘熷叕寮忥紙鍚師鏉ョ殑鍒嗘瘝鍒ゆ柇锛夎绠�
+ -->
+ <select id="getSfStatisticsScriptSum" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
+ resultMap="ServiceSubtaskScriptStatisticResult">
+ select
+ IFNULL(${groupColumn}, 'Unknown') as group_code,
+ <!-- 鍒嗙粍閿搴旂殑鏄剧ず鍚嶏細鐥呭尯缁熻鏃跺氨鏄繖涓�缁勭殑鐥呭尯鍚嶃��
+ 浠ュ墠杩欎竴鍒楁槸 MAX(hospitaldistrictname)锛屼竴涓粍娣蜂簡澶氫釜鐥呭尯鏃朵細闅忔満鏄剧ず鍏朵腑涓�涓紝
+ 浜庢槸鍑虹幇鈥滈�夎娑插唴绉戠梾鍖哄嵈鏄剧ず楠ㄧ涓績涓夌梾鍖衡�濄�� -->
+ <choose>
+ <when test="groupKey != null and groupKey == 'taskid'">
+ MAX(task_name) as group_name,
+ </when>
+ <otherwise>
+ MAX(IFNULL(leavehospitaldistrictname, hospitaldistrictname)) as group_name,
+ </otherwise>
+ </choose>
+ MAX(taskid) as taskid,
+ MAX(task_name) as task_name,
+ MAX(drcode) as drcode,
+ MAX(drname) as drname,
+ MAX(leaveldeptcode) as deptcode,
+ MAX(leaveldeptname) as deptname,
+ MAX(leavehospitaldistrictcode) as leavehospitaldistrictcode,
+ MAX(leavehospitaldistrictname) as leavehospitaldistrictname,
+ MAX(hospitaldistrictcode) as hospitaldistrictcode,
+ MAX(hospitaldistrictname) as hospitaldistrictname,
+ MAX(deptcode) as hospitaldeptcode,
+ MAX(deptname) as hospitaldeptname,
+ SUM(CASE WHEN visit_count = 1 THEN 1 ELSE 0 END) as first_visit_count,
+ SUM(CASE WHEN visit_count > 1 THEN 1 ELSE 0 END) as again_visit_count,
+ SUM(CASE WHEN sendstate = 4 THEN 1 ELSE 0 END) as non_follow_up,
+ SUM(CASE WHEN sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as follow_up_needed,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as need_follow_up,
+ SUM(CASE WHEN visit_count = 1 and sendstate = 2 THEN 1 ELSE 0 END) as pending_follow_up,
+ SUM(CASE WHEN visit_count = 1 and sendstate = 6 THEN 1 ELSE 0 END) as follow_up_success,
+ SUM(CASE WHEN visit_count = 1 and (sendstate = 5 or sendstate = 7) THEN 1 ELSE 0 END) as follow_up_fail,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '1' THEN 1 ELSE 0 END) as manual,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '3' THEN 1 ELSE 0 END) as voice,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '4' THEN 1 ELSE 0 END) as sms,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '5' THEN 1 ELSE 0 END) as we_chat,
+ SUM(CASE WHEN visit_count = 1 and sendstate is not null and excep = '1' THEN 1 ELSE 0 END) as abnormal,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as need_follow_up_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate = 2 THEN 1 ELSE 0 END) as pending_follow_up_again,
+ SUM(CASE WHEN visit_count > 1 and (sendstate = 1 or sendstate = 3 or sendstate = 6) THEN 1 ELSE 0 END) as follow_up_success_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate = 5 THEN 1 ELSE 0 END) as follow_up_fail_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '1' THEN 1 ELSE 0 END) as manual_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '3' THEN 1 ELSE 0 END) as voice_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '4' THEN 1 ELSE 0 END) as sms_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '5' THEN 1 ELSE 0 END) as we_chat_again,
+ SUM(CASE WHEN visit_count > 1 and sendstate is not null and excep = '1' THEN 1 ELSE 0 END) as abnormal_again,
+ <!-- 鍑洪櫌浜烘锛氬師鏉ョ殑鍐呭瓨瀹炵幇鏄� serviceSubtaskList.size()锛屽嵆鍒嗙粍鍐呭懡涓殑瀛愪换鍔℃潯鏁般��
+ 鏀规垚鏈鍙ュ悗涓�鐩存病鏈夎仛鍚堣繖涓�鍒楋紝椤甸潰涓娾�滃嚭闄汉娆♀�濇亽涓� 0锛屼笌搴旈殢璁夸汉娆¤嚜鐩哥煕鐩俱�� -->
+ COUNT(*) as discharge_count
+ from service_subtask
+ where 1=1
+ and del_flag = 0
+ <if test="orgid != null and orgid != ''">
+ and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
+ </if>
+ <choose>
+ <!-- 婊℃剰搴︾粺璁★細鏀圭敤鈥滄湁鏁堢梾鍖衡�濆垪锛堝嚭闄㈢梾鍖轰负绌哄洖閫�鍦ㄩ櫌鐥呭尯锛夛紝绛涢�夋墠鐪熸鐢熸晥 -->
+ <when test="districtColumn != null and districtColumn != ''">
+ <!-- 鍑洪櫌鐥呭尯涓虹┖鍥為��鍒板湪闄㈢梾鍖恒�傝繖閲屽埢鎰忓啓鎴� OR 灞曞紑鑰屼笉鏄� IFNULL(a,b) IN (...)锛�
+ 鍒楄鍑芥暟鍖呬綇灏辩敤涓嶄簡绱㈠紩锛�56 涓囪鏄庣粏琛ㄤ笂鏄叏琛ㄦ壂锛堝疄娴� 5.1s 鈫� 0.7s锛夈��
+ 涓や釜鍒嗘敮鍒嗗埆鍛戒腑 idx_ss_district_pair 鐨� (leave..., hospital...) 鍓嶇紑銆� -->
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ OR (leavehospitaldistrictcode IS NULL AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
+ </if>
+ </when>
+ <otherwise>
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ )
+ </if>
+ </otherwise>
+ </choose>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND leaveldeptcode IN
+ <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+ close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND (hospitaldistrictcode IS NULL OR hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ )
+ </if>
+ <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0">
+ AND deptcode IN
+ <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator=","
+ close=")">
+ #{hospitaldeptcode}
+ </foreach>
+ </if>
+ <if test="serviceType != null and serviceType.size() > 0">
+ AND service_type IN
+ <foreach collection="serviceType" item="serviceType" open="(" separator=","
+ close=")">
+ #{serviceType}
+ </foreach>
+ </if>
+ <if test="startTime != null and endTime!=null">
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime})
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ </if>
+ <if test="hospitalStartTime != null and hospitalEndTime!=null">
+ AND endtime >= DATE(#{hospitalStartTime})
+ AND endtime < DATE_ADD(DATE(#{hospitalEndTime}), 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="continueFlag != null ">and continue_flag = #{continueFlag}</if>
+ <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,jdbcType=TIMESTAMP}</if>
+ <if test="type != null">
+ and type = #{type}
+ </if>
+ <if test="visitCount != null and visitCount == 1">
+ AND visit_count = 1
+ </if>
+ <if test="visitCount != null and visitCount > 1">
+ AND visit_count > 1
+ </if>
+ <!-- 杩囨护鍒楀繀椤讳笌 GROUP BY 鐨勫垪涓�鑷达細閮界敤 groupColumn锛堟弧鎰忓害鐥呭尯缁熻鏃跺畠鏄�
+ IFNULL(鍑洪櫌鐥呭尯, 鍦ㄩ櫌鐥呭尯) 杩欐牱鐨勮〃杈惧紡锛夛紝鍚﹀垯鑱氬悎鍑烘潵鐨勫垎缁勯敭杩囨护涓嶄笂锛岄鐩噺浼氬叏鍙� 0銆� -->
+ <if test="groupColumn != null and groupColumn != '' and groupKeyList != null and groupKeyList.size>0">
+ AND IFNULL(${groupColumn}, 'Unknown') IN
+ <foreach collection="groupKeyList" item="key" open="(" separator=","
+ close=")">
+ #{key}
+ </foreach>
+ </if>
+ group by IFNULL(${groupColumn}, 'Unknown')
+ </select>
+
+ <!--
+ 鎸夊垎缁勮仛鍚堟弧鎰忓害棰樼洰閲忥紙鏇夸唬 getSfStatisticsCategory 鐨勨�滈�愬瓙浠诲姟 IN 鏌ヨ + 鍐呭瓨 N*M 杩囨护鈥濓級銆�
+ where 鏉′欢 = 涓婇潰鑱氬悎鏌ヨ鐨勬潯浠� + 鍘� getSfStatisticsCategory 鐨勬槑缁嗘潯浠讹紝
+ 鍥犳鍛戒腑鐨勬槑缁嗛泦鍚堜笌鏀归�犲墠锛坓etSfStatisticsCategory 缁撴灉鍐嶆寜瀛愪换鍔′笌鍒嗙粍姹備氦锛夊畬鍏ㄤ竴鑷淬��
+ configValue 涓虹┖鏃朵笉璋冪敤鏈鍙ワ紙鍘熷疄鐜板湪杩欑鍦烘櫙涓嬮鐩噺涓�寰嬩负 0锛夈��
+ -->
+ <select id="getSfStatisticsScriptJoySum" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
+ resultType="map">
+ select
+ <choose>
+ <when test="districtColumn != null and districtColumn != ''">
+ IFNULL(${districtColumn}, 'Unknown') as groupCode,
+ </when>
+ <otherwise>
+ IFNULL(t.${groupColumn}, 'Unknown') as groupCode,
+ </otherwise>
+ </choose>
+ SUM(CASE WHEN a.categoryid IN(${configValue})
+ THEN 1 ELSE 0 END) as joyAllCount,
+ SUM(CASE WHEN a.categoryid IN(${configValue})
+ AND IFNULL(a.matchedtext,a.asrtext) is not null
+ AND IFNULL(a.matchedtext,a.asrtext) != ''
+ THEN 1 ELSE 0 END) as joyCount
+ from service_subtask_detail a
+ INNER JOIN service_subtask t on a.sub_id = t.id
+ where 1=1
+ and a.del_flag = 0
+ and t.del_flag = 0
+ <if test="orgid != null and orgid != ''">
+ and t.orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and t.campusid = #{campusid}
+ </if>
+ <choose>
+ <!-- 婊℃剰搴︾粺璁★細涓庤仛鍚堜富鏌ヨ涓�鑷达紝鐢ㄢ�滄湁鏁堢梾鍖衡�濆垪杩囨护锛�
+ 鍚﹀垯棰樼洰閲忎細鍜屼富鏌ヨ鐨勮瀵逛笉涓婏紙鍒嗙粍閿笉涓�鏍凤紝杩囨护涓嶄笂灏卞叏鍙� 0锛夈�� -->
+ <when test="districtColumn != null and districtColumn != ''">
+ <!-- 鍑洪櫌鐥呭尯涓虹┖鍥為��鍒板湪闄㈢梾鍖恒�傝繖閲屽埢鎰忓啓鎴� OR 灞曞紑鑰屼笉鏄� IFNULL(a,b) IN (...)锛�
+ 鍒楄鍑芥暟鍖呬綇灏辩敤涓嶄簡绱㈠紩锛�56 涓囪鏄庣粏琛ㄤ笂鏄叏琛ㄦ壂锛堝疄娴� 5.1s 鈫� 0.7s锛夈��
+ 涓や釜鍒嗘敮鍒嗗埆鍛戒腑 idx_ss_district_pair 鐨� (leave..., hospital...) 鍓嶇紑銆� -->
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ OR (leavehospitaldistrictcode IS NULL AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
+ </if>
+ </when>
+ <otherwise>
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (t.leavehospitaldistrictcode IS NULL OR t.leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ )
+ </if>
+ </otherwise>
+ </choose>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND t.leaveldeptcode IN
+ <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+ close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND t.leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND (t.hospitaldistrictcode IS NULL OR t.hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ )
+ </if>
+ <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0">
+ AND t.deptcode IN
+ <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator=","
+ close=")">
+ #{hospitaldeptcode}
+ </foreach>
+ </if>
+ <if test="serviceType != null and serviceType.size() > 0">
+ AND t.service_type IN
+ <foreach collection="serviceType" item="serviceType" open="(" separator=","
+ close=")">
+ #{serviceType}
+ </foreach>
+ </if>
+ <if test="startTime != null and endTime!=null">
+ AND IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)) >= DATE(#{startTime})
+ AND IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ </if>
+ <if test="hospitalStartTime != null and hospitalEndTime!=null">
+ AND t.endtime >= DATE(#{hospitalStartTime})
+ AND t.endtime < DATE_ADD(DATE(#{hospitalEndTime}), INTERVAL 1 DAY)
+ </if>
+ <if test="visitDeptCode != null">and t.visit_dept_code = #{visitDeptCode}</if>
+ <if test="visitDeptName != null">and t.visit_dept_name = #{visitDeptName}</if>
+ <if test="isabnormal != null">and t.isabnormal = #{isabnormal}</if>
+ <if test="continueFlag != null ">and t.continue_flag = #{continueFlag}</if>
+ <if test="continueTimeNow != null ">and t.continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
+ <if test="continueCount != null ">and t.continue_count = #{continueCount}</if>
+ <if test="continueTimeNext != null ">and t.continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if>
+ <if test="type != null">
+ and t.type = #{type}
+ </if>
+ <if test="visitCount != null and visitCount == 1">
+ AND t.visit_count = 1
+ </if>
+ <if test="visitCount != null and visitCount > 1">
+ AND t.visit_count > 1
+ </if>
+ <if test="districtColumn != null and districtColumn != '' and groupKeyList != null and groupKeyList.size>0">
+ AND IFNULL(${districtColumn}, 'Unknown') IN
+ <foreach collection="groupKeyList" item="key" open="(" separator=","
+ close=")">
+ #{key}
+ </foreach>
+ </if>
+ <if test="(districtColumn == null or districtColumn == '') and groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0">
+ AND IFNULL(t.${groupKey}, 'Unknown') IN
+ <foreach collection="groupKeyList" item="key" open="(" separator=","
+ close=")">
+ #{key}
+ </foreach>
+ </if>
+ <choose>
+ <when test="districtColumn != null and districtColumn != ''">
+ group by IFNULL(${districtColumn}, 'Unknown')
+ </when>
+ <otherwise>
+ group by IFNULL(t.${groupColumn}, 'Unknown')
+ </otherwise>
+ </choose>
</select>
<select id="getSfStatisticsHyperlink" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
@@ -1790,17 +2618,19 @@
drname,
leavehospitaldistrictcode,
leavehospitaldistrictname,
- deptcode,
- deptname,
+ leaveldeptcode,
+ leaveldeptname,
sendstate,
preachform,
- current_preachform,
+ <include refid="effectiveCurrentPreachformExpr"/> AS current_preachform,
excep,
nurse_id,
nurse_name,
taskid,
task_name,
visit_time,
+ visit_dept_code,
+ visit_dept_name,
finishtime,
endtime,
senddate,
@@ -1819,7 +2649,10 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ doctor_opinion,
+ finish_state,
+ is_manually_called
from service_subtask
where 1=1
and del_flag = 0
@@ -1829,15 +2662,24 @@
<if test="campusid != null and campusid != ''">
and campusid = #{campusid}
</if>
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"锛堝崡鍗庢弧鎰忓害 83% 瀛愪换鍔℃棤鐥呭尯锛夛紝鏈夌梾鍖虹殑鏁版嵁琛屼负涓嶅彉 -->
+ <!-- 涓� getSfStatisticsScript 鐨勬眹鎬昏淇濇寔涓�鑷达細鍑洪櫌鐥呭尯涓虹┖鍒欏洖閫�鍒板湪闄㈢梾鍖猴紝
+ 鍚﹀垯鐐光�滄煡鐪嬭鎯呪�濇煡鍑烘潵鐨勬潯鏁颁細鍜屾眹鎬昏鐨勬暟瀛楀涓嶄笂銆� -->
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ AND (leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ OR (leavehospitaldistrictcode IS NULL AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -1850,9 +2692,14 @@
#{serviceType}
</foreach>
</if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖鏃舵寜瀹屾垚/鍒涘缓鏃堕棿鍏滃簳 -->
<if test="startTime != null and endTime!=null">
- AND visit_time >= DATE(#{startTime})
- AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime})
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ </if>
+ <if test="hospitalStartTime != null and hospitalEndTime!=null">
+ AND endtime >= DATE(#{hospitalStartTime})
+ AND endtime < DATE_ADD(DATE(#{hospitalEndTime}), INTERVAL 1 DAY)
</if>
<if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
<if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
@@ -1865,14 +2712,19 @@
<if test="type != null">
and type = #{type}
</if>
- <if test="visitCount != null and visitCount == 1">
+ <!-- 棣栦釜鍐嶆闅忚锛氱簿纭煡 visit_count = 2锛屼笌缁熻鍙e緞涓�鑷� -->
+ <if test="hyperLinkInfoType == 'againFollowUpPushCountInfo'">
+ AND visit_count = 2
+ </if>
+ <!-- 鍏朵粬绫诲瀷淇濇寔鍘熻涔夛細1 棣栨锛�>1 鍐嶆 -->
+ <if test="hyperLinkInfoType != 'againFollowUpPushCountInfo' and visitCount != null and visitCount == 1">
AND visit_count = 1
</if>
- <if test="visitCount != null and visitCount > 1">
+ <if test="hyperLinkInfoType != 'againFollowUpPushCountInfo' and visitCount != null and visitCount > 1">
AND visit_count > 1
</if>
<if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0">
- AND ${groupKey} IN
+ AND IFNULL(${groupKey}, 'Unknown') IN
<foreach collection="groupKeyList" item="key" open="(" separator=","
close=")">
#{key}
@@ -1885,8 +2737,8 @@
#{state}
</foreach>
</if>
- <if test="currentPreachform != null">
- AND current_preachform = #{currentPreachform}
+ <if test="currentPreachform != null and currentPreachform != '' ">
+ AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform}
<if test="followUpCountStyle != null and followUpCountStyle = '1'">
AND sendstate != 4
</if>
@@ -1897,6 +2749,9 @@
<if test="taskSituation != null">
AND task_situation = #{taskSituation}
</if>
+ <if test="finishState != null">
+ AND finish_state = #{finishState}
+ </if>
<if test="drcode != null and drcode != ''">
AND drcode = #{drcode}
</if>
@@ -1904,7 +2759,13 @@
AND leavehospitaldistrictcode = #{leavehospitaldistrictcode}
</if>
<if test="deptcode != null and deptcode != ''">
- AND deptcode = #{deptcode}
+ AND leaveldeptcode = #{deptcode}
+ </if>
+ <if test="isManuallyCalled != null">
+ AND is_manually_called = #{isManuallyCalled}
+ </if>
+ <if test="suggest != null and suggest != ''">
+ AND TRIM(suggest) = #{suggest}
</if>
order by endtime desc
<if test="pageSize != null and pageNum != null">
@@ -1927,15 +2788,17 @@
<if test="campusid != null and campusid != ''">
and campusid = #{campusid}
</if>
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"锛堝崡鍗庢弧鎰忓害 83% 瀛愪换鍔℃棤鐥呭尯锛夛紝鏈夌梾鍖虹殑鏁版嵁琛屼负涓嶅彉 -->
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ )
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -1949,8 +2812,8 @@
</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')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
<if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
@@ -1974,15 +2837,17 @@
<if test="campusid != null and campusid != ''">
and campusid = #{campusid}
</if>
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"锛堝崡鍗庢弧鎰忓害 83% 瀛愪换鍔℃棤鐥呭尯锛夛紝鏈夌梾鍖虹殑鏁版嵁琛屼负涓嶅彉 -->
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ )
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -1996,8 +2861,8 @@
</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')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
) AND targetid=a.id) joyCount , (SELECT COUNT(*) from (select sub_id FROM service_subtask_detail
WHERE sub_id IN(SELECT id FROM service_subtask t
@@ -2018,7 +2883,7 @@
</foreach>
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -2032,8 +2897,8 @@
</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')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
GROUP BY sub_id ) ) ta ) joyAllCount
FROM ivr_liba_target a
@@ -2067,15 +2932,20 @@
<if test="campusid != null and campusid != ''">
and t.campusid = #{campusid}
</if>
+ <!-- 2026-10-21锛氱梾鍖轰负绌烘椂瑙嗕负"涓嶉檺"
+ 鍗楀崕婊℃剰搴﹀瓙浠诲姟鐨� leavehospitaldistrictcode 鏈� 83%锛�3236/3811锛変负 NULL锛�
+ 鍘熸潵銆岀瀹� AND 鐥呭尯銆嶄袱涓潯浠舵案杩滀笉鍙兘鍚屾椂鎴愮珛 鈫� 鏁村紶缁熻琛ㄧ┖銆�
+ 鍒ょ┖鏀捐鍙奖鍝嶇梾鍖轰负绌虹殑璁板綍锛屾湁鐥呭尯鐨勬暟鎹涓轰笉鍙樸�� -->
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND t.leavehospitaldistrictcode IN
+ AND (t.leavehospitaldistrictcode IS NULL OR t.leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ )
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND t.deptcode IN
+ AND t.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
@@ -2095,9 +2965,10 @@
#{serviceType}
</foreach>
</if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖鏃舵寜瀹屾垚/鍒涘缓鏃堕棿鍏滃簳 -->
<if test="startTime != null and endTime!=null">
- AND date_format(t.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
- AND date_format(t.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ AND date_format(IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="visitDeptCode != null">
and t.visit_dept_code = #{visitDeptCode}
@@ -2118,14 +2989,14 @@
<select id="getSfStatisticsScriptDetails" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
resultMap="ServiceSubtaskScriptCountResult">
SELECT
- a.id as scriptid,
- a.templateid as templateid,
- a.script_type,
+ MIN(a.id) as scriptid,
+ MIN(a.templateid) as templateid,
+ MIN(a.script_type) as script_type,
a.script_content,
b.subtask_type,
- b.completed_quantity,
- b.all_quantity,
- ROUND(b.completed_quantity/b.all_quantity,2) as completed_percentage
+ SUM(b.completed_quantity) as completed_quantity,
+ SUM(b.all_quantity) as all_quantity,
+ ROUND(SUM(b.completed_quantity)/SUM(b.all_quantity),2) as completed_percentage
FROM
<if test="type == 1">
ivr_task_template_script a
@@ -2154,17 +3025,44 @@
AND ss.campusid = #{campusid}
</if>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND ss.leavehospitaldistrictcode IN
+ AND (ss.leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
+ OR (ss.leavehospitaldistrictcode IS NULL AND ss.hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND ss.deptcode IN
+ AND ss.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
+ </foreach>
+ </if>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND ss.leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND ss.hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0">
+ AND ss.deptcode IN
+ <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator=","
+ close=")">
+ #{hospitaldeptcode}
</foreach>
</if>
<if test="serviceType != null and serviceType.size() > 0">
@@ -2174,9 +3072,10 @@
#{serviceType}
</foreach>
</if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖锛堝崡鍗庢弧鎰忓害 3811/3811 鍏ㄤ负 NULL锛夋椂鎸夊畬鎴�/鍒涘缓鏃堕棿鍏滃簳 -->
<if test="startTime != null and endTime!=null">
- AND date_format(ss.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
- AND date_format(ss.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
<if test="type != null">
@@ -2188,30 +3087,121 @@
group by ssd.scriptid) b
ON a.id = b.scriptid
<!-- 閫傜敤鍗曟潯鏌ヨ -->
- <if test="scriptids != null">
+ <if test="scriptids != null and scriptids != ''">
AND a.scriptid in
(SELECT lib_script.scriptid FROM
svy_lib_template_script lib_script
WHERE lib_script.scriptid in (${scriptids}))
</if>
+ <!-- 鍚屼竴閬撻浼氳澶嶅埗鍒板涓换鍔℃ā鏉匡紝鎸夐鐩唴瀹瑰悎骞讹紝淇濊瘉涓�閬撻鍙繑鍥炰竴鏉� -->
+ GROUP BY a.script_content, b.subtask_type
+ ORDER BY MIN(a.id)
</select>
<select id="getSfStatisticsScriptItemDetails" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
resultMap="ServiceSubtaskScriptCountResult">
SELECT
- ssd.scriptid,
+ a.script_content,
+ ss.type as subtask_type,
IFNULL(ssd.matchedtext,ssd.asrtext) AS option_text,
COUNT(*) AS chosen_quantity
FROM
service_subtask_detail ssd
INNER JOIN service_subtask ss ON ssd.sub_id = ss.id
+ INNER JOIN
+ <if test="type == 1">
+ ivr_task_template_script a ON a.id = ssd.scriptid
+ </if>
+ <if test="type == 2">
+ svy_task_template_script a ON a.id = ssd.scriptid
+ </if>
where 1=1
and ss.del_flag=0
+ and ssd.del_flag=0
<if test="orgid != null and orgid != ''">
and ss.orgid = #{orgid}
</if>
<if test="campusid != null and campusid != ''">
and ss.campusid = #{campusid}
+ </if>
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ AND (ss.leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ OR (ss.leavehospitaldistrictcode IS NULL AND ss.hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ ))
+ </if>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND ss.leaveldeptcode IN
+ <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+ close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ AND ss.leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND ss.hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0">
+ AND ss.deptcode IN
+ <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator=","
+ close=")">
+ #{hospitaldeptcode}
+ </foreach>
+ </if>
+ <if test="serviceType != null and serviceType.size() > 0">
+ AND ss.service_type IN
+ <foreach collection="serviceType" item="serviceType" open="(" separator=","
+ close=")">
+ #{serviceType}
+ </foreach>
+ </if>
+ <!-- 2026-10-21锛歷isit_time 涓虹┖锛堝崡鍗庢弧鎰忓害 3811/3811 鍏ㄤ负 NULL锛夋椂鎸夊畬鎴�/鍒涘缓鏃堕棿鍏滃簳 -->
+ <if test="startTime != null and endTime!=null">
+ AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+ AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ </if>
+ <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
+ <if test="type != null">
+ and ss.type = #{type}
+ </if>
+ <if test="configValue != null and configValue != ''">
+ AND ssd.categoryid IN (${configValue})
+ </if>
+ group by a.script_content, ss.type, IFNULL(ssd.matchedtext,ssd.asrtext)
+ </select>
+
+ <!--
+ 闂閫夐」鏁板瓧涓嬮捇锛氳繑鍥為�夋嫨浜嗘寚瀹氶�夐」鐨� service_subtask 鍒楄〃銆�
+ 杩囨护鍙e緞涓� getSfStatisticsScriptDetails / getSfStatisticsScriptItemDetails 淇濇寔涓�鑷达紝
+ 棰濆鏀寔 statisticaltype锛�1-鐥呭尯銆�2-绉戝銆�3-鐥呯銆�
+ -->
+ <select id="getSfStatisticsScriptDetailsHyperlink" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq"
+ resultMap="ServiceSubtaskResult">
+ SELECT ss.*
+ FROM service_subtask ss
+ WHERE ss.del_flag = 0
+ <if test="orgid != null and orgid != ''">
+ AND ss.orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND ss.campusid = #{campusid}
</if>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND ss.leavehospitaldistrictcode IN
@@ -2222,30 +3212,109 @@
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
AND ss.deptcode IN
- <foreach collection="deptcodes" item="deptcode" open="(" separator=","
- close=")">
+ <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
</foreach>
</if>
<if test="serviceType != null and serviceType.size() > 0">
AND ss.service_type IN
- <foreach collection="serviceType" item="serviceType" open="(" separator=","
- close=")">
+ <foreach collection="serviceType" item="serviceType" open="(" separator="," close=")">
#{serviceType}
</foreach>
</if>
- <if test="startTime != null and endTime!=null">
- AND date_format(ss.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
- AND date_format(ss.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ <if test="startTime != null and endTime != null">
+ AND ss.visit_time >= DATE(#{startTime})
+ AND ss.visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
</if>
- <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
- <if test="type != null">
- and ss.type = #{type}
+ <if test="type != null and type != ''">
+ AND ss.type = #{type}
</if>
- <if test="configValue != null and configValue != ''">
- AND ssd.categoryid IN (${configValue})
+
+ <!-- 缁熻缁村害锛�1-鎸夌梾鍖� 2-鎸夌瀹� 3-鎸塼askid -->
+ <if test="statisticaltype != null and statisticaltype == 1">
+ <choose>
+ <when test="deptcode != null and deptcode != ''">
+ AND ss.leavehospitaldistrictcode = #{deptcode}
+ </when>
+ <when test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+ AND ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+ </when>
+ </choose>
</if>
- group by ssd.scriptid, IFNULL(ssd.matchedtext,ssd.asrtext)
+ <if test="statisticaltype != null and statisticaltype == 2 and deptcode != null and deptcode != ''">
+ AND ss.deptcode = #{deptcode}
+ </if>
+ <if test="statisticaltype != null and statisticaltype == 3 and taskId != null">
+ AND ss.taskid = #{taskId}
+ </if>
+ <!-- 鍏煎涓嶄紶 statisticaltype 鏃舵寜鍗曞�兼潯浠惰繃婊� -->
+ <if test="statisticaltype == null">
+ <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+ AND ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+ </if>
+ <if test="deptcode != null and deptcode != ''">
+ AND ss.deptcode = #{deptcode}
+ </if>
+ <if test="taskId != null">
+ AND ss.taskid = #{taskId}
+ </if>
+ </if>
+
+ <!-- 棰樼洰 + 閫夐」鍖归厤锛氬彧淇濈暀鍥炵瓟涓�夋嫨浜嗚閫夐」鐨勫瓙浠诲姟 -->
+ AND EXISTS (
+ SELECT 1
+ FROM service_subtask_detail ssd
+ WHERE ssd.sub_id = ss.id
+ AND ssd.del_flag = 0
+ <if test="configValue != null and configValue != ''">
+ AND ssd.categoryid IN (${configValue})
+ </if>
+ <choose>
+ <when test="optionText != null">
+ AND IFNULL(ssd.matchedtext, ssd.asrtext) = #{optionText}
+ </when>
+ <otherwise>
+ AND 1 = 0
+ </otherwise>
+ </choose>
+ <choose>
+ <!-- 浼樺厛鎸夐鐩唴瀹瑰尮閰嶏細鍚屼竴閬撻澶嶅埗鍒板涓换鍔℃ā鏉挎椂 scriptid 涓嶅悓锛屼絾 script_content 鐩稿悓 -->
+ <when test="scriptContent != null and scriptContent != ''">
+ AND ssd.scriptid IN (
+ <choose>
+ <when test="type == '1'">
+ SELECT its.id FROM ivr_task_template_script its
+ WHERE its.script_content = #{scriptContent}
+ </when>
+ <when test="type == '2'">
+ SELECT sts.id FROM svy_task_template_script sts
+ WHERE sts.script_content = #{scriptContent}
+ </when>
+ <otherwise>
+ SELECT its.id FROM ivr_task_template_script its
+ WHERE its.script_content = #{scriptContent}
+ UNION
+ SELECT sts.id FROM svy_task_template_script sts
+ WHERE sts.script_content = #{scriptContent}
+ </otherwise>
+ </choose>
+ )
+ </when>
+ <when test="scriptid != null">
+ AND ssd.scriptid = #{scriptid}
+ </when>
+ <otherwise>
+ AND 1 = 0
+ </otherwise>
+ </choose>
+ )
+ ORDER BY ss.endtime DESC, ss.id DESC
+ <if test="pageSize != null and pageSize > 0">
+ LIMIT #{pageSize}
+ <if test="pageNum != null and pageNum >= 0">
+ OFFSET #{pageNum}
+ </if>
+ </if>
</select>
<select id="getDataByTime" resultMap="ServiceSubtaskResult">
@@ -2274,7 +3343,7 @@
recordid,
exrecallcount,
pulltime,
- deptcode,
+ leaveldeptcode,
labelstatus,
del_flag,
upid,
@@ -2304,7 +3373,7 @@
admindate,
patid,
service_type,
- deptname,
+ leaveldeptname,
score,
drname,
drcode,
@@ -2316,6 +3385,7 @@
nurse_id,
nurse_name,
remark,
+ doctor_opinion,
inhospid,
patfrom,
task_guid,
@@ -2363,7 +3433,7 @@
</select>
<select id="getDeptRanking" parameterType="com.ruoyi.common.core.service.dto.PatMedReq" resultType="com.ruoyi.common.core.service.dto.PatMedRes">
- SELECT deptname,
+ SELECT leaveldeptname AS deptname,
count(1) AS rc
FROM service_subtask
WHERE DATE_FORMAT(visit_time, '%Y-%m-%d') >= #{startDate}
@@ -2376,7 +3446,7 @@
<if test="campusid != null and campusid != ''">
AND campusid = #{campusid}
</if>
- GROUP BY deptname
+ GROUP BY leaveldeptname
</select>
<!-- 鏈嶅姟缁熻鏌ヨ - 鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁 -->
@@ -2427,7 +3497,7 @@
AND campusid = #{campusid}
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
</foreach>
@@ -2558,11 +3628,12 @@
SUM(CASE WHEN sendstate = 1 THEN 1 ELSE 0 END) AS blq,
SUM(CASE WHEN sendstate = 4 THEN 1 ELSE 0 END) AS wxsf,
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
+ SUM(CASE WHEN (sendstate = 1 OR sendstate = 2 OR sendstate = 3 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
@@ -2576,46 +3647,24 @@
AND phone = #{phone}
</if>
<if test="finishtimeStart != null">
- AND date_format(finishtime,'%y%m%d') >= date_format(#{finishtimeStart},'%y%m%d')
+ AND finishtime >= DATE(#{finishtimeStart})
</if>
<if test="finishtimeEnd != null">
- AND date_format(finishtime,'%y%m%d') <= date_format(#{finishtimeEnd},'%y%m%d')
+ AND finishtime < DATE_ADD(DATE(#{finishtimeEnd}), INTERVAL 1 DAY)
</if>
- <if test="deptOrDistrict==1">
- <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>
+ <!--
+ 绉戝/鐥呭尯绛涢�夛紙2026-11 淇锛夛細
+ 绂婚櫌缁勶紙leaveldeptcodes / leavehospitaldistrictcodes锛変繚鎸佸師閫昏緫锛�
+ 鍦ㄩ櫌缁勶紙deptcodes / hospitaldistrictcodes 鈫� deptcode / hospitaldistrictcode锛夋槸鏂板鐨勪竴缁勶紱
+ 缁勫唴鎸� deptOrDistrict 鍙� AND('1') / OR('2')锛屼袱缁勪箣闂� AND锛堝彧浼犱竴缁勬椂鍙︿竴缁勪笉鎷硷級銆�
+ -->
+ <if test='deptOrDistrict == "1"'>
+ <include refid="filterLeaveDimAnd"/>
+ <include refid="filterInhospDimAnd"/>
</if>
- <if test="deptOrDistrict==2">
- AND (1=1
- <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">
- OR deptcode IN
- <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
- close=")">
- #{leaveldeptcode}
- </foreach>
- </if>
- )
+ <if test='deptOrDistrict == "2"'>
+ <include refid="filterLeaveDimOr"/>
+ <include refid="filterInhospDimOr"/>
</if>
<if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0">
AND visit_dept_code IN
@@ -2689,37 +3738,24 @@
AND templatename LIKE CONCAT('%', #{templatename}, '%')
</if>
<if test="startOutHospTime != null">
- AND DATE_FORMAT(endtime,'%y%m%d') >= DATE_FORMAT(#{startOutHospTime},'%y%m%d')
+ AND endtime >= DATE(#{startOutHospTime})
</if>
<if test="endOutHospTime != null">
- AND DATE_FORMAT(endtime,'%y%m%d') <= DATE_FORMAT(#{endOutHospTime},'%y%m%d')
+ AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY)
</if>
<if test="startSendDateTime != null">
- AND DATE_FORMAT(visit_time,'%y%m%d') >= DATE_FORMAT(#{startSendDateTime},'%y%m%d')
+ AND visit_time >= DATE(#{startSendDateTime})
</if>
<if test="endSendDateTime != null">
- AND DATE_FORMAT(visit_time,'%y%m%d') <= DATE_FORMAT(#{endSendDateTime},'%y%m%d')
+ AND visit_time < DATE_ADD(DATE(#{endSendDateTime}), INTERVAL 1 DAY)
</if>
<if test="longSendTime != null">
- AND DATE_FORMAT(long_send_time,'%y%m%d') <= DATE_FORMAT(#{longSendTime},'%y%m%d')
+ AND long_send_time < DATE_ADD(DATE(#{longSendTime}), INTERVAL 1 DAY)
</if>
- <if test="deptOrDistrict == 1">
- <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>
- </if>
- <if test="deptcode != null and deptcode != ''">
- AND deptcode = #{deptcode}
+ <!-- 2026-11锛氳繖閲屽師鏈繕鏈変竴浠戒笌涓婃柟 deptOrDistrict==1 瀹屽叏閲嶅鐨勭梾鍖�/绉戝鏉′欢锛�
+ 宸插垹闄わ紙鏉′欢鏀圭敤 filterSubtaskWardDim / filterSubtaskDeptDim 鐗囨锛岄伩鍏嶄袱浠藉彛寰勪笉涓�鑷达級 -->
+ <if test="leaveldeptcode != null and leaveldeptcode != ''">
+ AND leaveldeptcode = #{leaveldeptcode}
</if>
<if test="sendstate != null">
AND sendstate = #{sendstate}
@@ -2729,6 +3765,9 @@
<foreach collection="sendstates" item="state" open="(" separator="," close=")">
#{state}
</foreach>
+ </if>
+ <if test="currentPreachforms != null and currentPreachforms != ''">
+ AND FIND_IN_SET(<include refid="effectiveCurrentPreachformExpr"/>, #{currentPreachforms})
</if>
<if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
@@ -2779,11 +3818,53 @@
AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
</if>
<if test="deptcodeList != null and deptcodeList.size()>0">
- and deptcode in
+ and leaveldeptcode in
<foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
#{deptcode}
</foreach>
</if>
+ </select>
+
+ <!--
+ 褰撳墠鐧诲綍浜恒�屽緟澶勭悊銆嶉殢璁夸换鍔★紝鎸夊嚭闄㈠勾鏈堬紙endtime锛夊垎缁勭粺璁★紝鍑洪櫌闅忚 / 闂ㄨ瘖闅忚鍒嗗紑璁℃暟銆�
+ 鍙e緞锛堜笌闅忚鍒楄〃銆屽緟闅忚銆嶉〉绛句竴鑷达級锛�
+ 1) 鍑洪櫌闅忚 service_type = '2'锛岄棬璇婇殢璁� service_type = '3'
+ 2) 缁熻鐘舵�� 鈫� sendstate IN (1,2,3,7)锛�1 琚鍙� / 2 寰呭彂閫� / 3 宸插彂閫� / 7 瓒呮椂
+ 锛堜笉鍚� 4 涓嶆墽琛屻��5 鍙戦�佸け璐ャ��6 宸插畬鎴愶級
+ 3) 鍑洪櫌婊� 7 澶� 鈫� endtime < (浠婂ぉ - 7 澶�) + 1 澶╋紝
+ 鍗炽��7 澶╁墠閭d竴澶┿�嶅嚭闄㈢殑涔熻鍏ワ紙鐢� <= DATE_SUB(...) 鍙細鎴埌褰撳ぉ 0 鐐癸紝浼氭紡鎺� 9 鏉★級
+ 4) 鍙湅鏈�杩� 4 涓嚭闄㈡湀浠斤紙鍚綋鏈堬級鈫� endtime >= 褰撴湀寰�鍓嶆帹 3 涓湀鐨� 1 鍙�
+ 5) 绉戝/鐥呭尯鏉冮檺鐢� OR锛堜笌鍒楄〃 deptOrDistrict=2 涓�鑷达級锛�
+ 鍙湁鐥呭尯鏉冮檺鐨勭敤鎴凤紝浠诲姟 leaveldeptcode 涓庢湰浜虹瀹ゅ涓嶄笂鏃朵篃鑳介噺鍒帮紝
+ 鍚﹀垯浼氭妸鏁存湀鏁版嵁杩囨护鎴� 0銆�
+ 璇存槑锛欸ROUP BY 鍙骇鍑烘湁鏁版嵁鐨勬湀浠斤紝鍓嶇鎸夈�屽綋鏈� + 鍓� 3 涓湀銆嶈ˉ榻愶紝娌℃暟鎹氨鏄剧ず 0 涓��
+ 涓嶅啀闄愬埗 current_preachform锛堜汉宸ワ級锛氳瀛楁鍙槸鎵ц鏂瑰紡锛�
+ 寰呴殢璁夸换鍔¢噷杩樻湁鐭俊绛夋柟寮忥紝闄愬畾 '1' 浼氭紡鏁般��
+ -->
+ <select id="countPendingManualTaskByMonth"
+ parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
+ resultType="java.util.Map">
+ SELECT DATE_FORMAT(endtime, '%Y-%m') AS month,
+ SUM(CASE WHEN service_type = '2' THEN 1 ELSE 0 END) AS dischargeCnt,
+ SUM(CASE WHEN service_type = '3' THEN 1 ELSE 0 END) AS outpatientCnt
+ FROM service_subtask
+ WHERE del_flag = '0'
+ AND service_type IN ('2', '3')
+ <!-- 娴獥銆屽緟澶勭悊闅忚浠诲姟銆嶅彛寰勶細1 琚鍙� / 2 寰呭彂閫� / 3 宸插彂閫� / 7 瓒呮椂 -->
+ AND sendstate IN (1, 2, 3, 7)
+ AND endtime IS NOT NULL
+ AND endtime < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL 7 DAY), INTERVAL 1 DAY)
+ AND endtime >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m-01')
+ <if test="orgid != null and orgid != ''">
+ AND orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND campusid = #{campusid}
+ </if>
+ <!-- 绂婚櫌绉戝/鐥呭尯锛氭湁绉戝鎸夌瀹ゃ�佹湁鐥呭尯鎸夌梾鍖猴紝涓よ�呴兘鏈夋椂鍙� OR -->
+ <include refid="filterLeaveDimOr"/>
+ GROUP BY DATE_FORMAT(endtime, '%Y-%m')
+ ORDER BY month
</select>
<select id="getCurrentUserServiceSubtaskCount" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
@@ -2794,32 +3875,74 @@
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>
+ <!-- 绂婚櫌绉戝/鐥呭尯锛氭湁绉戝鎸夌瀹ゃ�佹湁鐥呭尯鎸夌梾鍖猴紝涓よ�呴兘鏈夋椂鍙� OR锛堝師鍐欐硶 1=1 浼氳绛涢�夊け鏁堬級 -->
+ <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.leaveldeptcode 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>
<!--
@@ -2862,14 +3985,14 @@
parameterType="com.ruoyi.task.domain.VO.ServiceSubtaskCotinueCountVO"
resultType="java.util.Map">
SELECT
- deptcode AS groupCode,
- deptname AS groupName,
+ leaveldeptcode AS groupCode,
+ leaveldeptname AS groupName,
SUM(CASE WHEN continue_flag = 1 THEN 1 ELSE 0 END) AS noContinueCnt,
SUM(CASE WHEN continue_flag = 2 THEN 1 ELSE 0 END) AS continueCnt
FROM service_subtask
WHERE del_flag = 0
AND continue_flag IN (1, 2)
- AND deptcode IS NOT NULL AND deptcode != ''
+ AND leaveldeptcode IS NOT NULL AND leaveldeptcode != ''
<if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
</if>
@@ -2877,12 +4000,12 @@
AND campusid = #{campusid}
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</if>
- GROUP BY deptcode, deptname
+ GROUP BY leaveldeptcode, leaveldeptname
ORDER BY groupCode
</select>
@@ -2895,8 +4018,8 @@
leavehospitaldistrictname AS groupName,
</when>
<otherwise>
- deptcode AS groupCode,
- deptname AS groupName,
+ leaveldeptcode AS groupCode,
+ leaveldeptname AS groupName,
</otherwise>
</choose>
COUNT(*) AS totalCount,
@@ -2933,12 +4056,12 @@
</when>
<otherwise>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</if>
- GROUP BY deptcode, deptname
+ GROUP BY leaveldeptcode, leaveldeptname
ORDER BY groupCode
</otherwise>
</choose>
@@ -2974,8 +4097,8 @@
drname,
leavehospitaldistrictcode,
leavehospitaldistrictname,
- deptcode,
- deptname,
+ leaveldeptcode,
+ leaveldeptname,
sendstate,
preachform,
current_preachform,
@@ -3003,7 +4126,8 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ doctor_opinion
from service_subtask
where 1=1
and del_flag = 0
@@ -3028,7 +4152,7 @@
</foreach>
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator=","
close=")">
#{deptcode}
--
Gitblit v1.9.3