From c24d16a37523a49080392610357872ce580cbc38 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 26 十月 2026 14:03:33 +0800
Subject: [PATCH] 代码提交
---
ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionMapper.xml | 464 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 404 insertions(+), 60 deletions(-)
diff --git a/ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionMapper.xml b/ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionMapper.xml
index e17a7b9..05ae104 100644
--- a/ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionMapper.xml
+++ b/ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionMapper.xml
@@ -26,10 +26,10 @@
</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="startTime != null">
- and visit_time >= #{startTime}
+ and IFNULL(visit_time, IFNULL(finishtime, create_time)) >= #{startTime}
</if>
<if test="endTime != null">
- and visit_time < date_add(#{endTime}, interval 1 day)
+ and IFNULL(visit_time, IFNULL(finishtime, create_time)) < date_add(#{endTime}, interval 1 day)
</if>
<if test="libTemplateIds != null and libTemplateIds.size() > 0">
and libtemplateid IN
@@ -51,9 +51,29 @@
OR
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- deptcode IN
+ leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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="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">
+ leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
+ #{leaveldeptcode}
</foreach>
</if>
)
@@ -67,18 +87,57 @@
from service_subtask
where del_flag = 0
<if test="questionType != null">and type = #{questionType}</if>
- <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
- close=")">
- #{hospitaldistrictcode}
- </foreach>
+ <!--
+ 2026-10-21 淇锛堝崡鍗� /statistics 鏌ヤ笉鍒版暟鎹級锛�
+ 鍘熸潵鏄�宭eavehospitaldistrictcode IN(...) AND deptcode IN(...)銆嶄袱鏉$嫭绔嬫潯浠讹紝
+ 鑰屾弧鎰忓害瀛愪换鍔★紙service_subtask.type=2 + service_type 6/14/15/16锛�
+ 閫氬父鍙啓 deptcode銆乴eavehospitaldistrictcode 涓� NULL锛堝崡鍗� 3803 鏉″叏閮ㄤ负 NULL锛夛紝
+ 涓や釜鏉′欢姘歌繙涓嶅彲鑳藉悓鏃舵弧瓒� 鈫� 璇ユ柟娉曡繑鍥炵┖ 鈫� 鍚庨潰 hasVoice/hasQuestionnaire 閮戒负 false
+ 鈫� 鏁翠釜缁熻鎺ュ彛杩斿洖绌恒��
+
+ 杩欓噷鏀规垚涓� selectSatisfactionSendCount / selectSatisfactionFillPersonCountByQuestion
+ 瀹屽叏涓�鑷寸殑銆岀瀹� OR 鐥呭尯銆嶅彛寰勶紙鍚屼竴涓〉闈紝鍥涘 SQL 蹇呴』鍚屽彛寰勶紝鍚﹀垯浼氬嚭鐜�
+ "鏈夌被鍨嬫病鏁版嵁"鎴�"鏈夋暟鎹病绫诲瀷"鐨勫壊瑁傦級銆�
+ -->
+ <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0) or (deptcodes != null and deptcodes.size() > 0)">
+ AND (
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ leavehospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="("
+ separator="," close=")">
+ #{hospitaldistrictcode}
+ </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">
+ leaveldeptcode IN
+ <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ )
</if>
- <if test="deptcodes != null and deptcodes.size() > 0">
- AND deptcode IN
- <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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="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">
+ leaveldeptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ )
</if>
<if test="serviceTypes != null and serviceTypes.size() > 0">
AND service_type IN
@@ -86,9 +145,83 @@
#{serviceType}
</foreach>
</if>
+ <!--
+ 鏃堕棿鍙e緞锛氭弧鎰忓害瀛愪换鍔★紙type=2锛夌殑 visit_time 缁忓父涓虹┖锛堝崡鍗� 3803 鏉″叏涓� NULL锛夛紝
+ 鍙寜 visit_time 杩囨护浼氭妸杩欎簺鏁版嵁鏁存壒鎺掗櫎銆傝繖閲屾寜
+ visit_time -> finishtime -> create_time 渚濇鍏滃簳锛屼笌鍏朵綑涓夋潯缁熻 SQL 淇濇寔涓�鑷淬��
+ -->
<if test="startTime != null and endTime != null">
- AND visit_time >= #{startTime}
- AND visit_time < date_add(#{endTime}, interval 1 day)
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= #{startTime}
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < date_add(#{endTime}, interval 1 day)
+ </if>
+ </select>
+
+ <!-- ================================================
+ 鏈鏉′欢涓嬨�岀湡姝d笅鍙戣繃浠诲姟銆嶇殑妯℃澘 id锛堝幓閲嶏級
+
+ 鐢ㄩ�旓細鎶婇搴撻鐩紙svy_lib_template_script / ivr_liba_template_script锛�
+ 瑁佸壀鎴愭湰鏈熺湡姝e湪鐢ㄧ殑妯℃澘锛岄伩鍏嶃�岄搴撻噷鎸傜潃涓�鍫嗕粠鏉ユ病涓嬪彂杩囩殑鍘嗗彶妯℃澘銆�
+ 瀵艰嚧 /statistics 澶氬嚭涓�鏁存壒 0 鍒嗗尯闂寸殑琛岋紙瀹炴祴 69 琛� 鈫� 搴斿彧鏈� 25 琛岋級銆�
+
+ 鈿狅笍 鏉′欢蹇呴』涓� selectSatisfactionSubtaskTypes 閫愭潯涓�鑷达紙鍙槸澶氫簡 type 涓� libtemplateid 涓ゅ垪锛夛紝
+ 鍚﹀垯浼氬嚭鐜般�屾湁绫诲瀷鐨勬ā鏉胯瑁佹帀 / 瑁佸壀鍚庢病鏈夋暟鎹�嶇殑鍓茶銆�
+ ================================================ -->
+ <select id="selectSatisfactionActiveTemplateIds" resultType="java.lang.Long">
+ select distinct libtemplateid
+ from service_subtask
+ where del_flag = 0
+ and libtemplateid is not null
+ <if test="type != null and type != ''">and type = #{type}</if>
+ <if test="(q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0) or (q.deptcodes != null and q.deptcodes.size() > 0)">
+ AND (
+ <if test="q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0">
+ leavehospitaldistrictcode IN
+ <foreach collection="q.hospitaldistrictcodes" item="hospitaldistrictcode" open="("
+ separator="," close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0 and q.deptcodes != null and q.deptcodes.size() > 0">
+ OR
+ </if>
+ <if test="q.deptcodes != null and q.deptcodes.size() > 0">
+ leaveldeptcode IN
+ <foreach collection="q.deptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <if test="(q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0) or (q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0)">
+ AND (
+ <if test="q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0">
+ leavehospitaldistrictcode IN
+ <foreach collection="q.leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="(q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0) and (q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0)">
+ OR
+ </if>
+ <if test="q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0">
+ leaveldeptcode IN
+ <foreach collection="q.leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <if test="q.serviceTypes != null and q.serviceTypes.size() > 0">
+ AND service_type IN
+ <foreach collection="q.serviceTypes" item="serviceType" open="(" separator="," close=")">
+ #{serviceType}
+ </foreach>
+ </if>
+ <!-- 鏃堕棿鍙e緞锛歷isit_time -> finishtime -> create_time 渚濇鍏滃簳锛屼笌鍏朵綑鍥涙潯缁熻 SQL 淇濇寔涓�鑷� -->
+ <if test="q.startTime != null and q.endTime != null">
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= #{q.startTime}
+ AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < date_add(#{q.endTime}, interval 1 day)
</if>
</select>
@@ -303,10 +436,10 @@
and d.del_flag=0
<!-- 鍒嗘瘝蹇呴』鍜屾槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃堕棿鑼冨洿鍚庢瘮渚嬩細鎸夊叏閲忓巻鍙茶绋�閲� -->
<if test="startOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
</if>
<if test="endOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="startFinishTime != null">
AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
@@ -340,10 +473,10 @@
AND s.sendstate = 6
and d.del_flag=0
<if test="startOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
</if>
<if test="endOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="startFinishTime != null">
AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
@@ -371,8 +504,8 @@
MAX(t.task_name) AS taskName,
d.asrtext AS optionresult,
d.score AS score,
- MAX(s.deptcode) AS deptcode,
- MAX(s.deptname) AS deptname,
+ MAX(s.leaveldeptcode) AS deptcode,
+ MAX(s.leaveldeptname) AS deptname,
MAX(s.leavehospitaldistrictcode) AS leavehospitaldistrictcode,
MAX(s.leavehospitaldistrictname) AS leavehospitaldistrictname,
d.targetvalue AS targetvalue,
@@ -430,10 +563,10 @@
AND d.del_flag=0
<!-- 鍒嗘瘝涓庢槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃ユ湡鍖洪棿鍚庡悇閫夐」姣斾緥鍚堣涓嶅埌 100% -->
<if test="startOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
</if>
<if test="endOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="startFinishTime != null">
AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
@@ -473,10 +606,10 @@
'%')
</if>
<if test="startOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
</if>
<if test="endOutHospTime != null">
- AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(s.endtime, IFNULL(s.finishtime, s.create_time)),'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="startFinishTime != null">
AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
@@ -500,8 +633,8 @@
<select id="statQuestionOptionByKsOrBq" resultType="com.ruoyi.satisfaction.domain.dto.QuestionCountKsOrBqDTO"
parameterType="com.ruoyi.satisfaction.domain.vo.QuestionCountKsOrBqVO">
SELECT
- s.deptname AS deptname,
- s.leavehospitaldistrictname AS leavehospitaldistrictname,
+ IFNULL(s.leaveldeptname, s.deptname) AS deptname,
+ IFNULL(s.leavehospitaldistrictname, s.hospitaldistrictname) AS leavehospitaldistrictname,
d.questiontext AS questionText,
d.targetvalue AS targetvalue, -- 鎵�鏈夐�夐」鎷兼帴
d.asrtext AS asrtext, -- 鐢ㄦ埛瀹為檯閫変腑鐨勯�夐」
@@ -530,29 +663,59 @@
</foreach>
</if>
<if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- AND deptcode IN
+ AND leaveldeptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
</foreach>
</if>
+ <!-- 鍦ㄩ櫌婊℃剰搴︼細鎸夊湪闄㈢梾鍖�/鍦ㄩ櫌绉戝鍒楄繃婊わ紙鍙湪浼犱簡杩欑粍鍙傛暟鏃剁敓鏁堬級 -->
+ <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+ AND hospitaldistrictcode IN
+ <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="("
+ separator=","
+ close=")">
+ #{hospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND deptcode IN
+ <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+ close=")">
+ #{deptcode}
+ </foreach>
+ </if>
</if>
+ <!--
+ 2026-10-21 淇锛氬師鏉� deptOrDistrict==2 鏃跺啓鐨勬槸
+ 銆孉ND leavehospitaldistrictcode IN (...) OR deptcode IN (...)銆嶏紝
+ 娌℃湁鎷彿 鈥斺�� SQL 閲� AND 浼樺厛绾ч珮浜� OR锛屽疄闄呯瓑浠蜂簬
+ (鍏ㄩ儴 AND 鏉′欢 AND 鐥呭尯 IN ...) OR 绉戝 IN ...
+ 浜庢槸銆岀瀹ゅ懡涓�嶉偅涓�鏀畬鍏ㄧ粫杩囦簡 service_type / 鏃ユ湡 / del_flag 绛夋墍鏈夋潯浠讹紝
+ 鍗楀崕锛堢梾鍖轰负绌恒�佹寜绉戝鏌ワ級浼氭崬鍥炲叏搴撳巻鍙叉暟鎹� 鈫� 鏁版嵁鏄庢樉涓嶅銆�
+ 杩欓噷琛ラ綈鎷彿锛岃 2 = 绉戝 OR 鐥呭尯銆�
+ -->
<if test="deptOrDistrict ==2">
+ AND (
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
</if>
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0 and leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ OR
+ </if>
<if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- OR deptcode IN
+ leaveldeptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
</foreach>
</if>
+ )
</if>
</select>
@@ -571,8 +734,8 @@
s.leavehospitaldistrictname AS name,
</when>
<otherwise>
- s.deptcode AS code,
- s.deptname AS name,
+ s.leaveldeptcode AS code,
+ s.leaveldeptname AS name,
</otherwise>
</choose>
CAST(d.score AS DECIMAL(10,4)) AS w
@@ -625,10 +788,10 @@
</if>
</when>
<otherwise>
- AND s.deptcode IS NOT NULL AND s.deptcode <> ''
- AND s.deptname IS NOT NULL AND s.deptname <> ''
+ AND s.leaveldeptcode IS NOT NULL AND s.leaveldeptcode <> ''
+ AND s.leaveldeptname IS NOT NULL AND s.leaveldeptname <> ''
<if test="deptCodes != null and deptCodes.size() > 0">
- AND s.deptcode IN
+ AND s.leaveldeptcode IN
<foreach collection="deptCodes" item="deptCode" open="(" separator="," close=")">
#{deptCode}
</foreach>
@@ -661,10 +824,10 @@
</if>
<if test="type != null and type != ''">and ss.type = #{type}</if>
<if test="startTime != null">
- and ss.visit_time >= #{startTime}
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) >= #{startTime}
</if>
<if test="endTime != null">
- and ss.visit_time < date_add(#{endTime}, interval 1 day)
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) < date_add(#{endTime}, interval 1 day)
</if>
<if test="libTemplateIds != null and libTemplateIds.size() > 0">
and ss.libtemplateid IN
@@ -686,9 +849,29 @@
OR
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- ss.deptcode IN
+ ss.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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>
)
@@ -716,10 +899,10 @@
</if>
<if test="type != null and type != ''">and ss.type = #{type}</if>
<if test="startTime != null">
- and ss.visit_time >= #{startTime}
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) >= #{startTime}
</if>
<if test="endTime != null">
- and ss.visit_time < date_add(#{endTime}, interval 1 day)
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) < date_add(#{endTime}, interval 1 day)
</if>
<if test="libTemplateIds != null and libTemplateIds.size() > 0">
and ss.libtemplateid IN
@@ -741,9 +924,29 @@
OR
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- ss.deptcode IN
+ ss.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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>
)
@@ -767,10 +970,10 @@
</if>
<if test="type != null and type != ''">and ss.type = #{type}</if>
<if test="startTime != null">
- and ss.visit_time >= #{startTime}
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) >= #{startTime}
</if>
<if test="endTime != null">
- and ss.visit_time < date_add(#{endTime}, interval 1 day)
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) < date_add(#{endTime}, interval 1 day)
</if>
<if test="libTemplateIds != null and libTemplateIds.size() > 0">
and ss.libtemplateid IN
@@ -792,9 +995,29 @@
OR
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- ss.deptcode IN
+ ss.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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>
)
@@ -832,10 +1055,10 @@
</if>
<if test="type != null and type != ''">and ss.type = #{type}</if>
<if test="startTime != null">
- and ss.visit_time >= #{startTime}
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) >= #{startTime}
</if>
<if test="endTime != null">
- and ss.visit_time < date_add(#{endTime}, interval 1 day)
+ and IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)) < date_add(#{endTime}, interval 1 day)
</if>
<if test="libTemplateIds != null and libTemplateIds.size() > 0">
and ss.libtemplateid IN
@@ -857,9 +1080,29 @@
OR
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
- ss.deptcode IN
+ ss.leaveldeptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
#{deptcode}
+ </foreach>
+ </if>
+ )
+ </if>
+ <!-- 绂婚櫌婊℃剰搴︼細鎸夌闄㈢瀹�/鐥呭尯杩囨护锛堢瀹� OR 鐥呭尯锛屼笌椤甸潰鍙e緞涓�鑷达級 -->
+ <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>
)
@@ -918,24 +1161,125 @@
AND service_type = #{q.serviceType}
</if>
<if test="q.startOutHospTime != null">
- AND date_format(endtime,'%y%m%d') >= date_format(#{q.startOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(endtime, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{q.startOutHospTime},'%y%m%d')
</if>
<if test="q.endOutHospTime != null">
- AND date_format(endtime,'%y%m%d') <= date_format(#{q.endOutHospTime},'%y%m%d')
+ AND date_format(IFNULL(endtime, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{q.endOutHospTime},'%y%m%d')
</if>
+ <!--
+ 2026-10-21 鏂板锛氭寜銆屽畬鎴愭椂闂淬�嶈繃婊わ紙椤甸潰鎻愪氦鐨� startFinishTime / endFinishTime锛夈��
+ 鍙e緞涓� statQuestionOptionBySubtaskIds 閲岀殑
+ date_format(s.finishtime,'%y%m%d') 鍖洪棿瀹屽叏绛変环锛堝弬鏁伴兘鏄� yyyy-MM-dd 闆剁偣锛夛紝
+ 浣嗚繖閲屽埢鎰忓啓鎴� finishtime 鐨勮8鍖洪棿鑰屼笉鐢� date_format()锛�
+ 鍒椾笂濂楀嚱鏁颁細璁╃储寮曞け鏁堬紝瑁稿尯闂存墠鑳借蛋 (鈥�, finishtime) 绱㈠紩銆�
+ 涓婄嚎鍓嶈繖閲屽畬鍏ㄦ病鏈夋椂闂存潯浠讹紝service_subtask 浼氳鏁磋〃鎵弿锛�
+ 涓嬫父鍐嶆妸鎵�鏈夊巻鍙叉弧鎰忓害瀛愪换鍔� id 鐏岃繘 IN 鍒楄〃 鈥斺�� 杩欐槸璇ユ帴鍙f參鐨勪富鍥犮��
+ -->
+ <if test="q.startFinishTime != null">
+ AND finishtime >= #{q.startFinishTime}
+ </if>
+ <if test="q.endFinishTime != null">
+ AND finishtime < DATE_ADD(#{q.endFinishTime}, INTERVAL 1 DAY)
+ </if>
+ <!--
+ 绉戝 / 鐥呭尯鍙e緞锛�2026-10-21 閲嶆瀯锛氳繃婊ゅ摢涓�鍒楃敱鍏ュ弬鍐冲畾锛�
+ ==================================================================
+ 鍥涗釜鍙傛暟鍚勮嚜瀵瑰簲涓�鍒楋紝璋佷紶杩涙潵灏辫繃婊よ皝锛屼笉鍐嶄竴寰嬫寜銆岀闄㈢梾鍖恒�嶈繃婊わ細
+ hospitaldistrictcodes 鈫� hospitaldistrictcode 鍦ㄩ櫌/褰撳墠鐥呭尯
+ leavehospitaldistrictcodes 鈫� leavehospitaldistrictcode 绂婚櫌鐥呭尯
+ deptcodes 鈫� deptcode 鍦ㄩ櫌/褰撳墠绉戝
+ leaveldeptcodes 鈫� leaveldeptcode 绂婚櫌绉戝
+ 鍚屼竴缁村害閲屼袱涓弬鏁伴兘浼狅紙灏戣锛夋椂鎸� OR 鈥斺�� 瀹冧滑鏄悓涓�浠朵簨鐨勪袱涓垪鍐欐硶锛�
+ 鐥呭尯缁村害涓庣瀹ょ淮搴︿箣闂寸敱 deptOrDistrict 鍐冲畾锛�1/3 = AND锛�2/4 = OR銆�
+ 鑳屾櫙锛氬崡鍗庤繖鎵规暟鎹殑鐥呭尯鍐欏湪 hospitaldistrictcode锛堝疄娴� 40003514 鏈� 409 鏉★級锛�
+ leavehospitaldistrictcode 鍩烘湰涓虹┖锛涘彧璁ょ闄㈢梾鍖轰細璁╃粺璁″彧鍓� 5 鏉°��
+ -->
+ <!-- 1/3锛氱梾鍖� AND 绉戝 -->
<if test="q.deptOrDistrict==1">
- <if test="q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="q.leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
- #{districtcode}
- </foreach>
+ <if test="(q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0) or (q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0)">
+ AND (
+ <trim prefixOverrides="OR">
+ <if test="q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0">
+ hospitaldistrictcode IN
+ <foreach collection="q.hospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+ #{districtcode}
+ </foreach>
+ </if>
+ <if test="q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0">
+ OR leavehospitaldistrictcode IN
+ <foreach collection="q.leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+ #{districtcode}
+ </foreach>
+ </if>
+ </trim>
+ )
+ </if>
+ <if test="(q.deptcodes != null and q.deptcodes.size() > 0) or (q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0)">
+ AND (
+ <trim prefixOverrides="OR">
+ <if test="q.deptcodes != null and q.deptcodes.size() > 0">
+ deptcode IN
+ <foreach collection="q.deptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0">
+ OR leaveldeptcode IN
+ <foreach collection="q.leaveldeptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </trim>
+ )
</if>
</if>
- <if test="q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0">
- AND deptcode IN
- <foreach collection="q.leaveldeptcodes" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
+ <!-- 2/4锛氱梾鍖� OR 绉戝 -->
+ <if test="q.deptOrDistrict==2">
+ <if test="(q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0) or (q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0) or (q.deptcodes != null and q.deptcodes.size() > 0) or (q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0)">
+ AND (
+ <trim prefixOverrides="OR">
+ <if test="q.hospitaldistrictcodes != null and q.hospitaldistrictcodes.size() > 0">
+ hospitaldistrictcode IN
+ <foreach collection="q.hospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+ #{districtcode}
+ </foreach>
+ </if>
+ <if test="q.leavehospitaldistrictcodes != null and q.leavehospitaldistrictcodes.size() > 0">
+ OR leavehospitaldistrictcode IN
+ <foreach collection="q.leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+ #{districtcode}
+ </foreach>
+ </if>
+ <if test="q.deptcodes != null and q.deptcodes.size() > 0">
+ OR deptcode IN
+ <foreach collection="q.deptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0">
+ OR leaveldeptcode IN
+ <foreach collection="q.leaveldeptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </trim>
+ )
+ </if>
+ </if>
+ <!-- 鍏跺畠鍙栧�硷細淇濇寔鏃ц涓猴紝鍙湅绉戝锛堝垪鍚屾牱鎸夊叆鍙傚尯鍒嗭級 -->
+ <if test="q.deptOrDistrict != null and q.deptOrDistrict != '1' and q.deptOrDistrict != '2'">
+ <if test="q.deptcodes != null and q.deptcodes.size() > 0">
+ AND deptcode IN
+ <foreach collection="q.deptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ <if test="q.leaveldeptcodes != null and q.leaveldeptcodes.size() > 0">
+ AND leaveldeptcode IN
+ <foreach collection="q.leaveldeptcodes" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
</if>
</select>
--
Gitblit v1.9.3