From a7de5f44bf83ffa0a5d11b04d16fb4f501ad5ff4 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 20 十月 2026 17:49:48 +0800
Subject: [PATCH] 【丽水】患者档案查询增加时间限制
---
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 860 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 729 insertions(+), 131 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 35aa60f..1948988 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -23,6 +23,7 @@
<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"/>
@@ -72,6 +73,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"/>
@@ -98,6 +100,7 @@
<result property="scheduleDetailId" column="schedule_detail_id"/>
<result property="scheduleSeq" column="schedule_seq"/>
<result property="loopCount" column="loop_count"/>
+ <result property="isManuallyCalled" column="is_manually_called"/>
<result property="campusid" column="campusid"/>
</resultMap>
@@ -181,6 +184,7 @@
long_send_time,
openid,
remark,
+ doctor_opinion,
service_type,
libtemplateid,
libtemplatename,
@@ -201,6 +205,7 @@
senduuid,
result,
finishtime,
+ finish_state,
recordid,
exrecallcount,
pulltime,
@@ -245,8 +250,56 @@
schedule_detail_id,
schedule_seq,
loop_count,
- task_situation
+ 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>
<select id="selectServiceSubtaskBySendstate" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
@@ -254,9 +307,8 @@
<include refid="selectServiceSubtaskVo"/>
where 1=1
and del_flag = 0
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
<if test="taskid != null ">and taskid = #{taskid}</if>
<if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -278,16 +330,11 @@
<include refid="selectServiceSubtaskVo"/>
where 1=1
and del_flag = 0
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="subId != null">
- AND id = #{subId}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
+ <if test="subId != null">and id = #{subId}</if>
<if test="taskid != null ">and taskid = #{taskid}</if>
- <if test="visitTime != null">
- AND date_format(visit_time,'%y%m%d') <= date_format(#{visitTime},'%y%m%d')
- </if>
+ <if test="visitTime != null">and date_format(visit_time,'%y%m%d') <= date_format(#{visitTime},'%y%m%d')</if>
<if test="sendstate != null ">and sendstate = #{sendstate}</if>
<if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -295,6 +342,36 @@
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
</select>
+ <!-- 鍗冲皢瓒呮椂杩囨护锛氭槸鍚﹀嵆灏嗚秴鏃�(soonTimeout=1) + 鍗冲皢瓒呮椂鏃堕棿(soonTimeoutHours锛屽崟浣嶅皬鏃�)銆�
+ 鎴鏃堕棿鍙e緞涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 淇濇寔涓�鑷达細
+ service_subtask.endtime + service_task.send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紱
+ 浠呭綋瀛樺湪鏈夋晥琛ュ伩璁板綍鏃舵墠璁$畻鎴鏃堕棿锛堟棤琛ュ伩璁板綍涓嶅弬涓庡嵆灏嗚秴鏃讹級锛�
+ 浠呯粺璁♀�滃皻鏈秴鏃躲�佷笖鍦� N 灏忔椂鍐呭皢瑕佽秴鏃垛�濈殑鏁版嵁銆� -->
+ <sql id="soonTimeoutDeadlineExpr">
+ (
+ SELECT DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(pf.compensate_days, 0) + 1) DAY
+ )
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ INNER JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) pf ON pf.subid = ss.id
+ WHERE ss.id = service_subtask.id
+ )
+ </sql>
+
+ <sql id="soonTimeoutFilter">
+ <if test="soonTimeout != null and soonTimeout == 1">
+ AND <include refid="soonTimeoutDeadlineExpr"/> > NOW()
+ AND <include refid="soonTimeoutDeadlineExpr"/> <= DATE_ADD(NOW(), INTERVAL COALESCE(#{soonTimeoutHours}, 0) HOUR)
+ </if>
+ </sql>
<select id="selectServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
resultMap="ServiceSubtaskResult">
@@ -410,17 +487,21 @@
</if>
</if>
<if test="deptOrDistrict==2">
- AND (1=1
- <if test="leavehospitaldistrictcodes != null">
- AND leavehospitaldistrictcode IN
+ AND (
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
</if>
- <if test=" leaveldeptcodes != null">
- OR deptcode IN
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
+ <if test=" leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ deptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
@@ -515,10 +596,12 @@
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>
<if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
+ <if test="isManuallyCalled != null">and is_manually_called = #{isManuallyCalled}</if>
<if test="isVisitAgain != null">and is_visit_again = #{isVisitAgain}</if>
<if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0">
AND visit_dept_code IN
@@ -528,6 +611,7 @@
#{visitDeptCode}
</foreach>
</if>
+ <include refid="soonTimeoutFilter"/>
<if test="sort != null and sort==0">order by endtime asc</if>
<if test="sort != null and sort==1">order by endtime desc</if>
<if test="sort != null and sort==2">order by visit_time asc</if>
@@ -537,7 +621,9 @@
<if test="sort != null and sort==7">order by visit_time asc</if>
<if test="sort != null and sort==8">order by visit_time desc</if>
<if test="sort != null and sort==9">order by sendname asc</if>
- <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+ <if test="pageSize != null and pageNum != null">
+ LIMIT ${pageSize} OFFSET ${pageNum}
+ </if>
</select>
<select id="selectSatisfactionSubtaskList" parameterType="com.smartor.domain.VO.PatSatisfactionReqVO"
@@ -579,15 +665,10 @@
<include refid="selectServiceSubtaskVo"/>
where del_flag = 0
and sendstate != 5
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="visitTime != null">
- AND date_format(visit_time,'%y%m%d') <= date_format(#{visitTime},'%y%m%d')
- </if>
- <if test="subId != null">
- AND id = #{subId}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
+ <if test="visitTime != null">and date_format(visit_time,'%y%m%d') <= date_format(#{visitTime},'%y%m%d') </if>
+ <if test="subId != null">and id = #{subId} </if>
<if test="sendstate != null ">and sendstate = #{sendstate}</if>
<if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -597,9 +678,8 @@
<include refid="selectServiceSubtaskVo"/>
where del_flag = 0
and sendstate = 5
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
<if test="visitTime != null">
AND date_format(visit_time,'%y%m%d') <= date_format(DATE_ADD(#{visitTime}, INTERVAL 1 DAY),'%y%m%d')
</if>
@@ -617,9 +697,8 @@
resultMap="ServiceSubtaskResult">
<include refid="selectServiceSubtaskVo"/>
where del_flag = 0
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
<if test="createStartTime != null and createEndTime != null">and create_time BETWEEN #{createStartTime} AND
#{createEndTime}
</if>
@@ -666,7 +745,8 @@
<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>
- <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <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="guid != null and guid != ''">and guid = #{guid}</if>
@@ -701,6 +781,7 @@
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
<if test="continueCount != null ">and continue_count = #{continueCount}</if>
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
+ <include refid="soonTimeoutFilter"/>
</select>
<select id="selectSendstateByCondition" parameterType="com.smartor.domain.ServiceSubtask" resultType="Integer">
@@ -714,9 +795,8 @@
DATE_FORMAT(b.create_time, '%Y-%m-%d') LIKE CONCAT(#{createTimeNew}, '%')
</if>
<if test="sendstate != null ">and b.sendstate = #{sendstate}</if>
- <if test="orgid != null and orgid != ''">
- and b.orgid = #{orgid}
- </if>
+ <if test="orgid != null and orgid != ''">and b.orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if>
</select>
<select id="selectTimelyRate" parameterType="com.smartor.domain.ServiceSubtask" resultType="double">
@@ -733,7 +813,8 @@
AND date_format(visit_time,'%y%m%d') >= date_format(#{starttime},'%y%m%d')
AND date_format(visit_time,'%y%m%d') <= date_format(#{endtime},'%y%m%d')
</if>
- <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <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>
@@ -747,6 +828,12 @@
</if>
<if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
<if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
+ <if test="startOutHospTime != null">
+ AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ </if>
) a
</select>
@@ -779,6 +866,7 @@
</if>
WHERE ss.del_flag = 0
AND ss.visit_time IS NOT NULL
+ AND ss.sendstate != 4
<if test="starttime == null and endtime==null">
AND DATE(ss.visit_time) < DATE(NOW())
</if>
@@ -787,6 +875,7 @@
AND ss.visit_time < DATE_ADD(#{endtime}, INTERVAL 1 DAY)
</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="isabnormal != null">and ss.isabnormal = #{isabnormal}</if>
@@ -810,6 +899,12 @@
close=")">
#{serviceType}
</foreach>
+ </if>
+ <if test="startOutHospTime != null">
+ AND date_format(ss.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(ss.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
<if test="groupKey != null and groupKey != ''">
AND ss.${groupKey} IN
@@ -840,6 +935,7 @@
AND date_format(visit_time,'%y%m%d') <= date_format(#{endtime},'%y%m%d')
</if>
<if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <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="isabnormal != null ">and isabnormal = #{isabnormal}</if>
@@ -870,7 +966,8 @@
<if test="sendname != null">and sendname like concat('%',#{sendname}, '%')</if>
<if test="taskName != null">and task_name like concat('%',#{taskName}, '%')</if>
<if test="sendstate != null">and sendstate = #{sendstate}</if>
- <if test="orgid != null">and orgid =#{orgid}</if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid} </if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</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>
@@ -905,6 +1002,7 @@
<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>
@@ -916,7 +1014,8 @@
<if test="createTime != null">create_time,</if>
<if test="isupload != null">isupload,</if>
<if test="uploadTime != null">upload_time,</if>
- <if test="orgid != null">orgid,</if>
+ <if test="orgid != null and orgid != ''">orgid,</if>
+ <if test="campusid != null and campusid != ''">campusid,</if>
<if test="pid != null">pid,</if>
<if test="guid != null">guid,</if>
<if test="textParam != null">text_param,</if>
@@ -957,6 +1056,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>
@@ -980,11 +1080,11 @@
<if test="continueTimeNext != null ">continue_time_next,</if>
<if test="continueContent != null ">continue_content,</if>
<if test="operationItemId != null ">operation_item_id,</if>
- <if test="campusid != null">campusid,</if>
<if test="scheduleId != null ">schedule_id,</if>
<if test="scheduleDetailId != null ">schedule_detail_id,</if>
<if test="scheduleSeq != null ">schedule_seq,</if>
<if test="loopCount != null ">loop_count,</if>
+ <if test="isManuallyCalled != null ">is_manually_called,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sendname != null">#{sendname},</if>
@@ -1002,6 +1102,7 @@
<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>
@@ -1013,7 +1114,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="isupload != null">#{isupload},</if>
<if test="uploadTime != null">#{uploadTime},</if>
- <if test="orgid != null">#{orgid},</if>
+ <if test="orgid != null and orgid != ''">#{orgid},</if>
+ <if test="campusid != null and campusid != ''">#{campusid},</if>
<if test="pid != null">#{pid},</if>
<if test="guid != null">#{guid},</if>
<if test="textParam != null">#{textParam},</if>
@@ -1054,6 +1156,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>
@@ -1077,13 +1180,22 @@
<if test="continueTimeNext != null ">#{continueTimeNext,jdbcType=TIMESTAMP},</if>
<if test="continueContent != null ">#{continueContent},</if>
<if test="operationItemId != null ">#{operationItemId},</if>
- <if test="campusid != null">#{campusid},</if>
<if test="scheduleId != null ">#{scheduleId},</if>
<if test="scheduleDetailId != null ">#{scheduleDetailId},</if>
<if test="scheduleSeq != null ">#{scheduleSeq},</if>
<if test="loopCount != null ">#{loopCount},</if>
+ <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.smartor.domain.ServiceSubtask">
update service_subtask
@@ -1115,7 +1227,8 @@
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isupload != null">isupload = #{isupload},</if>
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
- <if test="orgid != null">orgid = #{orgid},</if>
+ <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+ <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="guid != null">guid = #{guid},</if>
<if test="textParam != null">text_param = #{textParam},</if>
@@ -1140,6 +1253,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>
@@ -1157,6 +1271,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>
@@ -1179,11 +1294,11 @@
<if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
<if test="continueContent != null ">continue_content = #{continueContent},</if>
<if test="operationItemId != null ">operation_item_id = #{operationItemId},</if>
- <if test="campusid != null">campusid=#{campusid},</if>
<if test="scheduleId != null ">schedule_id = #{scheduleId},</if>
<if test="scheduleDetailId != null ">schedule_detail_id = #{scheduleDetailId},</if>
<if test="scheduleSeq != null ">schedule_seq = #{scheduleSeq},</if>
<if test="loopCount != null ">loop_count = #{loopCount},</if>
+ <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
where id = #{id}
</update>
@@ -1218,7 +1333,8 @@
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isupload != null">isupload = #{isupload},</if>
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
- <if test="orgid != null">orgid = #{orgid},</if>
+ <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+ <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="guid != null">guid = #{guid},</if>
<if test="textParam != null">text_param = #{textParam},</if>
@@ -1243,6 +1359,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>
@@ -1261,6 +1378,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>
@@ -1281,13 +1399,13 @@
<if test="continueCount != null ">continue_count = #{continueCount},</if>
<if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
<if test="continueContent != null ">continue_content = #{continueContent},</if>
+ <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
where 1=1
<if test="patid != null ">and patid = #{patid}</if>
<if test="taskid != null ">and taskid = #{taskid}</if>
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
+ <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
</update>
<update id="updateServiceSubtaskByCondition" parameterType="com.smartor.domain.ServiceSubtask">
@@ -1298,6 +1416,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>
@@ -1321,7 +1440,8 @@
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isupload != null">isupload = #{isupload},</if>
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
- <if test="orgid != null">orgid = #{orgid},</if>
+ <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+ <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="guid != null">guid = #{guid},</if>
<if test="visitCount != null">visit_count = #{visitCount},</if>
@@ -1364,6 +1484,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>
@@ -1383,6 +1504,7 @@
<if test="continueCount != null ">continue_count = #{continueCount},</if>
<if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
<if test="continueContent != null ">continue_content = #{continueContent},</if>
+ <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
<where>
<if test="patid != null ">
@@ -1394,6 +1516,9 @@
<if test="id != null ">
and id = #{id}
</if>
+ <if test="inhospid != null ">
+ and inhospid = #{inhospid}
+ </if>
</where>
</update>
@@ -1404,6 +1529,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>
@@ -1427,7 +1553,8 @@
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isupload != null">isupload = #{isupload},</if>
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
- <if test="orgid != null">orgid = #{orgid},</if>
+ <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+ <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="guid != null">guid = #{guid},</if>
<if test="textParam != null">text_param = #{textParam},</if>
@@ -1470,6 +1597,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>
@@ -1489,6 +1617,7 @@
<if test="continueCount != null ">continue_count = #{continueCount},</if>
<if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
<if test="continueContent != null ">continue_content = #{continueContent},</if>
+ <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
where task_guid = #{taskGuid} and task_name = #{taskName}
</update>
@@ -1551,12 +1680,16 @@
continue_content,
continue_count,
continue_time_next,
- task_situation
+ task_situation,
+ is_manually_called
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>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -1646,12 +1779,9 @@
and a.del_flag = '0'
and b.del_flag = '0'
and a.appltype = '3'
- <if test="orgid != null and orgid != ''">
- and a.orgid = #{orgid}
- </if>
- <if test="taskId != null">
- and a.task_id = #{taskId}
- </if>
+ <if test="orgid != null and orgid != ''">and a.orgid = #{orgid}</if>
+ <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if>
+ <if test="taskId != null">and a.task_id = #{taskId}</if>
<if test="taskName != null and taskName != ''">
and a.task_name like concat('%', #{taskName}, '%')
</if>
@@ -1740,6 +1870,9 @@
and del_flag = 0
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
</if>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -1835,12 +1968,17 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ doctor_opinion,
+ is_manually_called
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>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -1866,6 +2004,10 @@
<if test="startTime != null and endTime!=null">
AND visit_time >= DATE(#{startTime})
AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+ </if>
+ <if test="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>
@@ -1919,6 +2061,9 @@
<if test="deptcode != null and deptcode != ''">
AND deptcode = #{deptcode}
</if>
+ <if test="isManuallyCalled != null">
+ AND is_manually_called = #{isManuallyCalled}
+ </if>
order by endtime desc
<if test="pageSize != null and pageNum != null">
limit ${pageSize} OFFSET ${pageNum}
@@ -1936,6 +2081,9 @@
and del_flag = 0
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
</if>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND leavehospitaldistrictcode IN
@@ -1981,6 +2129,9 @@
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
</if>
+ <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=","
@@ -2012,6 +2163,9 @@
and del_flag = 0
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
</if>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">AND
leavehospitaldistrictcode IN
@@ -2067,6 +2221,9 @@
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>
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
AND t.leavehospitaldistrictcode IN
@@ -2151,6 +2308,9 @@
<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=","
@@ -2207,6 +2367,9 @@
and 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
@@ -2311,6 +2474,7 @@
nurse_id,
nurse_name,
remark,
+ doctor_opinion,
inhospid,
patfrom,
task_guid,
@@ -2365,8 +2529,11 @@
AND DATE_FORMAT(visit_time, '%Y-%m-%d') <= #{endDate}
AND service_type IN (2, 13)
AND del_flag = '0'
- <if test="orgid != null">
+ <if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND campusid = #{campusid}
</if>
GROUP BY deptname
</select>
@@ -2412,10 +2579,12 @@
AND visit_time <= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
- <if test="orgid != null">
+ <if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
</if>
-
+ <if test="campusid != null and campusid != ''">
+ AND campusid = #{campusid}
+ </if>
<if test="deptcodes != null and deptcodes.size() > 0">
AND deptcode IN
<foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
@@ -2469,10 +2638,12 @@
AND endtime <= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
AND inhospstate=1
- <if test="orgid != null">
+ <if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
</if>
-
+ <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="districtcode" open="(" separator="," close=")">
@@ -2519,9 +2690,11 @@
<!-- AND admitdate <= DATE_ADD(#{endDate}, INTERVAL 1 DAY)-->
<!-- </if>-->
<!-- <if test="orgid != null">-->
- <!-- AND orgid = #{orgid}-->
+ <!-- AND orgid = #{orgid}-->
<!-- </if>-->
-
+ <!-- <if test="campusid != null">-->
+ <!-- AND campusid = #{campusid}-->
+ <!-- </if>-->
<!-- <if test="deptcodes != null and deptcodes.size() > 0">-->
<!-- AND deptcode IN-->
<!-- <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">-->
@@ -2546,7 +2719,10 @@
SUM(CASE WHEN sendstate != 4 THEN 1 ELSE 0 END) AS xsf,
SUM(CASE WHEN (sendstate = 1 OR sendstate = 2 OR sendstate = 3 OR sendstate = 5 OR sendstate = 7 ) THEN 1 ELSE 0
END) AS dsf,
+ SUM(CASE WHEN sendstate != 2 THEN 1 ELSE 0 END) AS yfs,
+ SUM(CASE WHEN sendstate = 2 THEN 1 ELSE 0 END) AS wfs,
SUM(CASE WHEN sendstate = 6 THEN 1 ELSE 0 END) AS ywc,
+ SUM(CASE WHEN sendstate = 7 THEN 1 ELSE 0 END) AS cs,
SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS yc,
SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS jg,
COUNT(1) as total
@@ -2558,6 +2734,12 @@
</if>
<if test="phone != null and phone != ''">
AND phone = #{phone}
+ </if>
+ <if test="finishtimeStart != null">
+ AND date_format(finishtime,'%y%m%d') >= date_format(#{finishtimeStart},'%y%m%d')
+ </if>
+ <if test="finishtimeEnd != null">
+ AND date_format(finishtime,'%y%m%d') <= date_format(#{finishtimeEnd},'%y%m%d')
</if>
<if test="deptOrDistrict==1">
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
@@ -2577,17 +2759,21 @@
</if>
</if>
<if test="deptOrDistrict==2">
- AND (1=1
+ AND (
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
#{leavehospitaldistrictcode}
</foreach>
</if>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
<if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- OR deptcode IN
+ deptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
@@ -2745,8 +2931,11 @@
where 1=1
and del_flag = 0
and service_type=3
- <if test="orgid != null">
- and orgid = #{orgid}
+ <if test="orgid != null and orgid != ''">
+ AND orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND campusid = #{campusid}
</if>
<if test="startDate != null">
AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
@@ -2770,29 +2959,73 @@
COUNT(CASE WHEN sendstate = 5 THEN 1 END) AS failedVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS abnormalVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS warnningVisitCount,
- COUNT(*) AS allVisitCount
- FROM service_subtask
- WHERE del_flag = '0'
- AND service_type = '2'
- AND visit_count = 1
+ COUNT(*) AS allVisitCount,
+ <choose>
+ <when test="soonTimeoutHours != null and soonTimeoutHours > 0">
+ COUNT(CASE WHEN t.soon_deadline > NOW()
+ AND t.soon_deadline <= DATE_ADD(NOW(), INTERVAL #{soonTimeoutHours} HOUR)
+ THEN 1 END) AS soonTimeoutCount
+ </when>
+ <otherwise>
+ 0 AS soonTimeoutCount
+ </otherwise>
+ </choose>
+ FROM (
+ SELECT ss.*,
+ <!-- 鍗冲皢瓒呮椂鎴鏃堕棿 = 鍑洪櫌鏃堕棿(endtime) + 鍙戦�佹棩(send_day, 缂虹渷1) + 琛ュ伩澶╂暟(compensate_time 姹傚拰鍚庡啀 +1 澶�)锛�
+ 涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
+ 鏃犳湁鏁堣ˉ鍋胯褰�(cp.subid 涓虹┖)鏃舵埅姝㈡椂闂翠负 NULL锛屼笉鍙備笌鍗冲皢瓒呮椂缁熻 -->
+ CASE
+ WHEN cp.subid IS NULL THEN NULL
+ ELSE DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(cp.compensate_days, 0) + 1) DAY
+ )
+ END AS soon_deadline
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ <!-- 琛ュ伩鏃堕棿锛氬厛鎸夊瓙浠诲姟鑱氬悎鎴愪竴琛屽啀鍏宠仈锛岄伩鍏嶄竴瀵瑰鏀惧ぇ璁℃暟锛�
+ compensate_time 鏄� varchar 涓斿彲鑳藉瓨鎴愮┖涓诧紝闇�鍏堢疆绌哄啀杞暟瀛� -->
+ LEFT JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) cp ON cp.subid = ss.id
+ WHERE ss.del_flag = '0'
+ AND ss.service_type = '2'
+ AND ss.visit_count = 1
<if test="orgid != null and orgid != ''">
- AND orgid = #{orgid}
+ AND ss.orgid = #{orgid}
</if>
- <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
- separator=","
- close=")">
- #{leavehospitaldistrictcode}
- </foreach>
+ <if test="campusid != null and campusid != ''">
+ and ss.campusid = #{campusid}
</if>
- <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- AND deptcode IN
- <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
- close=")">
- #{leaveldeptcode}
- </foreach>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ AND (
+ <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ ss.leavehospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+ separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
+ and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
+ OR
+ </if>
+ <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+ ss.deptcode IN
+ <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+ close=")">
+ #{leaveldeptcode}
+ </foreach>
+ </if>)
</if>
+ ) t
</select>
<select id="querySendCount" parameterType="com.smartor.domain.entity.ServiceSubtaskSatisfactionEntity"
@@ -2865,6 +3098,9 @@
<if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
</if>
+ <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="code" open="(" separator="," close=")">
@@ -2890,6 +3126,9 @@
AND deptcode IS NOT NULL AND deptcode != ''
<if test="orgid != null and orgid != ''">
AND orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND campusid = #{campusid}
</if>
<if test="deptcodes != null and deptcodes.size() > 0">
AND deptcode IN
@@ -2922,6 +3161,9 @@
AND service_type = 4
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
</if>
<if test="sendstate != null">
AND sendstate = #{sendstate}
@@ -2964,6 +3206,117 @@
and loop_count = #{loopCount}
and (del_flag is null or del_flag = '0')
and sendstate in (1, 2, 3)
+ </select>
+
+ <select id="mydTrend" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+ SELECT CASE #{type}
+ WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+ WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+ WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+ WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+ ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+ END AS period,
+ ROUND(avg(d.score), 2) AS totalScore
+ FROM service_subtask_detail d
+ JOIN service_task t ON d.taskid = t.taskid
+ WHERE t.service_type IN (14)
+ AND t.del_flag = 0
+ AND d.del_flag = 0
+ AND d.create_time >= #{startFinishTime}
+ AND d.create_time < DATE_ADD(#{endFinishTime}, INTERVAL 1 DAY)
+ GROUP BY period
+ ORDER BY period;
+ </select>
+
+ <select id="sltdMydTotalByDimension" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+ SELECT
+ p.period,
+ dim.dimension,
+ IFNULL(ROUND(SUM(d.score), 2), 0) AS totalScore
+ FROM (
+ <!-- 鐢熸垚鏌ヨ鑼冨洿鍐呭疄闄呭嚭鐜拌繃鐨勬椂闂存 -->
+ SELECT DISTINCT
+ CASE #{type}
+ WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+ WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+ WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+ WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+ ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+ END AS period
+ FROM service_subtask_detail d
+ WHERE d.del_flag = 0
+ AND d.create_time >= #{startFinishTime}
+ AND d.create_time < #{endFinishTime}
+ ) p
+ CROSS JOIN (
+ <!-- 鎵�鏈夐渶瑕佸睍绀虹殑 dimension -->
+ SELECT DISTINCT dimension
+ FROM service_subtask_detail
+ WHERE del_flag = 0
+ AND dimension IS NOT NULL
+ ) dim
+ LEFT JOIN service_task t
+ ON t.service_type IN (6, 14)
+ AND t.del_flag = 0
+ LEFT JOIN service_subtask_detail d
+ ON d.taskid = t.taskid
+ AND d.del_flag = 0
+ AND d.dimension = dim.dimension
+ AND CASE #{type}
+ WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+ WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+ WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+ WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+ ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+ END = p.period
+ AND d.create_time >= #{startFinishTime}
+ AND d.create_time < #{endFinishTime}
+ GROUP BY p.period, dim.dimension
+ ORDER BY p.period, dim.dimension
+ </select>
+
+ <select id="sltdMydTotalByYQ" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+ SELECT p.period,
+ c.campusid,
+ IFNULL(ROUND(AVG(d.score), 2), 0) AS totalScore
+ FROM (
+ -- 鐢熸垚鏌ヨ鑼冨洿鍐呭疄闄呭嚭鐜拌繃鐨勬椂闂存
+ SELECT DISTINCT CASE #{type}
+ WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+ WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+ WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+ WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+ ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+ END AS period
+ FROM service_subtask_detail d
+ WHERE d.del_flag = 0
+ AND d.create_time >= #{startFinishTime}
+ AND d.create_time < #{endFinishTime}) p
+ CROSS JOIN (
+ -- 鎵�鏈夐渶瑕佸睍绀虹殑闄㈠尯
+ SELECT DISTINCT campusid
+ FROM service_task
+ WHERE service_type IN (6, 14)
+ AND del_flag = 0
+ AND campusid IS NOT NULL) c
+ LEFT JOIN service_task t
+ ON t.campusid = c.campusid
+ AND t.service_type IN (6, 14)
+ AND t.del_flag = 0
+ LEFT JOIN service_subtask_detail d
+ ON d.taskid = t.taskid
+ AND d.del_flag = 0
+ AND CASE #{type}
+ WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+ WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+ WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+ WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+ ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+ END = p.period
+ AND d.create_time >= #{startFinishTime}
+ AND d.create_time < #{endFinishTime}
+ GROUP BY p.period, c.campusid
+ ORDER BY p.period, c.campusid;
</select>
<!-- 浠诲姟缁勶紙appltype=5锛夋粴鍔ㄨ皟搴︾敤锛氭媺鏈疆鍏ㄩ噺 subtask锛屼綔涓轰笅涓�杞殑鍏嬮殕妯℃澘 -->
@@ -3015,13 +3368,17 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ doctor_opinion
from service_subtask
where 1=1
and del_flag = 0
AND service_type = 4
<if test="orgid != null and orgid != ''">
and orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ and campusid = #{campusid}
</if>
<if test="sendstate != null">
AND sendstate = #{sendstate}
@@ -3085,6 +3442,13 @@
#{taskId}
</foreach>
</if>
+ <!-- 浼犱簡 subtaskIds 鍙粺璁¤繖鎵瑰瓙浠诲姟锛堟湰娆″鍑虹殑鎮h�咃級 -->
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
+ </foreach>
+ </if>
<if test="valueType != null">AND d.value_type = #{valueType}</if>
<if test="scoreStart != null">AND d.score >= #{scoreStart}</if>
<if test="scoreEnd != null">AND d.score <= #{scoreEnd}</if>
@@ -3093,6 +3457,19 @@
</if>
and s.sendstate=6
and d.del_flag=0
+ <!-- 鍒嗘瘝蹇呴』鍜屾槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃堕棿鑼冨洿鍚庢瘮渚嬩細鎸夊叏閲忓巻鍙茶绋�閲� -->
+ <if test="startOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ </if>
+ <if test="startFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
+ </if>
+ <if test="endFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d')
+ </if>
GROUP BY
t.taskid,
d.questiontext
@@ -3102,6 +3479,12 @@
AND t.taskid IN
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
#{taskId}
+ </foreach>
+ </if>
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
</foreach>
</if>
<if test="valueType != null">AND d.value_type = #{valueType}</if>
@@ -3118,6 +3501,12 @@
<if test="endOutHospTime != null">
AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
+ <if test="startFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
+ </if>
+ <if test="endFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d')
+ </if>
GROUP BY
t.taskid,
d.questiontext,
@@ -3128,6 +3517,64 @@
ORDER BY
d.questiontext,
t.taskid
+ </select>
+
+ <!--
+ 瀵煎嚭銆岄棶棰樿鎯呭崰姣斻�嶄笓鐢ㄧ粺璁★紙鍙粺璁℃湰娆″鍑虹殑杩欐壒鎮h�咃級
+ 鏁伴噺 = 閫夋嫨璇ラ�夐」鐨勬偅鑰呮暟锛圕OUNT(DISTINCT s.id)锛屽苟鐢� MAX(id) 淇濊瘉鍚屼竴鎮h�呭悓涓�棰樺彧绠楁渶鏂颁竴鏉★級
+ 鍒嗘暟 = 璇ラ�夐」鏄庣粏鐨� score 涔嬪拰
+ 姣斾緥 = 鏁伴噺 / 璇ラ浣滅瓟鎮h�呮暟锛屽湪 Java 渚х粺涓�璁$畻锛屽洜姝ゃ�屽崟棰樺悇閫夐」鏁伴噺涔嬪拰 = 璇ラ浣滅瓟鎮h�呮暟銆�
+ -->
+ <select id="statMydQuestionOptionForExport" resultType="com.smartor.domain.DTO.ServiceSubtaskOptionStatDTO">
+ SELECT
+ t.taskid AS taskid,
+ t.task_name AS taskName,
+ d.questiontext AS questiontext,
+ d.asrtext AS optionresult,
+ d.targetvalue AS targetvalue,
+ d.value_type AS valueType,
+ COUNT(DISTINCT s.id) AS patientCount,
+ SUM(COALESCE(CAST(d.score AS DECIMAL(18,2)), 0)) AS scoreSum
+ FROM
+ service_task t
+ INNER JOIN service_subtask s ON s.taskid = t.taskid
+ INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+ WHERE 1=1
+ AND s.del_flag = '0'
+ AND d.del_flag = 0
+ <if test="subtaskIds != null and subtaskIds.size() > 0">
+ AND s.id IN
+ <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
+ #{subtaskId}
+ </foreach>
+ </if>
+ <!-- 涓嶄紶瀛愪换鍔℃椂鐩存帴鏌ヤ笉鍒版暟鎹紝閬垮厤璇粺璁″叏閲� -->
+ <if test="subtaskIds == null or subtaskIds.size() == 0">
+ AND 1 = 0
+ </if>
+ <if test="questiontext != null and questiontext != ''">
+ AND d.questiontext LIKE CONCAT('%', #{questiontext}, '%')
+ </if>
+ <!-- 鍚屼竴鎮h�呭悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閲嶇瓟涓嶉噸澶嶈鍏ユ暟閲� -->
+ AND d.id = (
+ SELECT MAX(d2.id)
+ FROM service_subtask_detail d2
+ WHERE d2.sub_id = d.sub_id
+ AND d2.questiontext <=> d.questiontext
+ AND d2.del_flag = '0'
+ )
+ GROUP BY
+ t.taskid,
+ t.task_name,
+ d.questiontext,
+ d.asrtext,
+ d.targetvalue,
+ d.value_type
+ <!-- 鎸変换鍔″悕绉板垎缁勫睍绀猴細鍏堜换鍔″悕绉般�佸啀浠诲姟缂栧彿锛屽悓涓�浠诲姟鐨勯鐩�/閫夐」杩炵画鎺掑垪 -->
+ ORDER BY
+ t.task_name,
+ t.taskid,
+ d.questiontext
</select>
<!-- 鏂版柟娉曪細鏍规嵁瀛愪换鍔� ID 缁熻闂閫夐」鐧惧垎姣� (鐢ㄤ簬婊℃剰搴︾粺璁� serviceType=6) -->
@@ -3150,6 +3597,14 @@
service_task t
INNER JOIN service_subtask s ON s.taskid = t.taskid
INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+ <!-- 鍘婚噸锛氬悓涓�瀛愪换鍔″悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閬垮厤閲嶇瓟/閲嶅鍥炶皟鎶婂悓涓�閬撻閲嶅璁″叆椤规暟锛堜笌 mzMydScoreRank 鍙e緞涓�鑷达級 -->
+ AND d.id = (
+ SELECT MAX(d2.id)
+ FROM service_subtask_detail d2
+ WHERE d2.sub_id = d.sub_id
+ AND d2.questiontext <=> d.questiontext
+ AND d2.del_flag = '0'
+ )
INNER JOIN (
SELECT
d.questiontext,
@@ -3158,6 +3613,14 @@
service_task t
INNER JOIN service_subtask s ON s.taskid = t.taskid
INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+ <!-- 鍘婚噸锛氬垎姣嶏紙璇ラ鏈夋晥绛斿嵎鎬绘暟锛変笌鏄庣粏鍙e緞淇濇寔涓�鑷达紝淇濊瘉鍚勯�夐」姣斾緥鍚堣 100% -->
+ AND d.id = (
+ SELECT MAX(d4.id)
+ FROM service_subtask_detail d4
+ WHERE d4.sub_id = d.sub_id
+ AND d4.questiontext <=> d.questiontext
+ AND d4.del_flag = '0'
+ )
WHERE 1=1
<if test="subtaskIds != null and subtaskIds.size() > 0">
AND s.id IN
@@ -3166,16 +3629,37 @@
</foreach>
</if>
<if test="valueType != null">AND d.value_type >= #{valueType}</if>
- <if test="scoreStart != null">AND d.score = #{scoreStart}</if>
+ <if test="scoreStart != null">AND d.score >= #{scoreStart}</if>
<if test="scoreEnd != null">AND d.score <= #{scoreEnd}</if>
<if test="questiontext != null and questiontext != ''">and d.questiontext like concat('%', #{questiontext},
'%')
</if>
AND s.sendstate = 6
AND d.del_flag=0
+ <!-- 鍒嗘瘝涓庢槑缁嗙敤鍚屼竴濂楁椂闂存潯浠讹紝鍚﹀垯閫変簡鏃ユ湡鍖洪棿鍚庡悇閫夐」姣斾緥鍚堣涓嶅埌 100% -->
+ <if test="startOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d')
+ </if>
+ <if test="endOutHospTime != null">
+ AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
+ </if>
+ <if test="startFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
+ </if>
+ <if test="endFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d')
+ </if>
GROUP BY d.questiontext
) t2 ON t2.questiontext = d.questiontext
WHERE 1=1
+ <!-- 鍘婚噸锛氭槑缁嗚鍚屼竴瀛愪换鍔″悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閲嶇瓟涓嶉噸澶嶈鍏ラ」鏁� -->
+ AND d.id = (
+ SELECT MAX(d3.id)
+ FROM service_subtask_detail d3
+ WHERE d3.sub_id = d.sub_id
+ AND d3.questiontext <=> d.questiontext
+ AND d3.del_flag = '0'
+ )
<if test="subtaskIds != null and subtaskIds.size() > 0">
AND s.id IN
<foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
@@ -3196,12 +3680,24 @@
<if test="endOutHospTime != null">
AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d')
</if>
+ <if test="startFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d')
+ </if>
+ <if test="endFinishTime != null">
+ AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d')
+ </if>
GROUP BY
t.taskid,
d.questiontext,
d.score,
d.targetvalue,
- d.asrtext
+ d.asrtext,
+ t.task_name,
+ s.deptcode,
+ s.deptname,
+ s.leavehospitaldistrictcode,
+ s.leavehospitaldistrictname,
+ d.value_type
ORDER BY
d.questiontext,
t.taskid
@@ -3209,50 +3705,61 @@
<select id="statQuestionOptionByKsOrBq" resultType="com.smartor.domain.DTO.QuestionCountKsOrBqDTO"
parameterType="com.smartor.domain.VO.QuestionCountKsOrBqVO">
- SELECT questiontext,
- d.taskid,
- s.deptname,
- d.create_time as createTime,
- s.leavehospitaldistrictname,
- d.targetvalue,
- d.asrtext,
- COUNT(d.asrtext) AS answercount,
- d.score AS singleScore
- FROM service_subtask_detail d,
- service_task s
- WHERE d.taskid = s.taskid
- AND deptname IS NOT NULL
- AND leavehospitaldistrictname IS NOT NULL
+ SELECT
+ s.deptname AS deptname,
+ s.leavehospitaldistrictname AS leavehospitaldistrictname,
+ d.questiontext AS questionText,
+ d.targetvalue AS targetvalue, -- 鎵�鏈夐�夐」鎷兼帴
+ d.asrtext AS asrtext, -- 鐢ㄦ埛瀹為檯閫変腑鐨勯�夐」
+ d.score AS singleScore -- 鍗曟潯璁板綍鐨勫垎鏁�
+ FROM service_subtask_detail d
+ JOIN service_subtask s ON d.sub_id = s.id
+ WHERE s.del_flag = 0
+ AND d.del_flag = 0
+ AND s.service_type IN ('6', '14')
+ <if test="taskTemplateid != null">
+ AND s.templateid = #{taskTemplateid}
+ </if>
<if test="endFinishTime != null">
AND d.create_time < #{endFinishTime}
</if>
<if test="startFinishTime != null">
- AND d.create_time >= #{startFinishTime}
+ AND d.create_time >= #{startFinishTime}
</if>
- <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
- <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
- separator=","
- close=")">
- #{leavehospitaldistrictcode}
- </foreach>
+ <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=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- AND deptcode IN
- <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
- close=")">
- #{leaveldeptcode}
- </foreach>
+ <if test="deptOrDistrict ==2">
+ <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>
- GROUP BY d.questiontext,
- d.taskid,
- d.score,
- s.deptname,
- d.targetvalue,
- d.create_time,
- s.leavehospitaldistrictname,
- d.asrtext
- ORDER BY d.taskid
</select>
<select id="selectServiceSubtaskListDeadLine" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
@@ -3264,5 +3771,96 @@
and endtime
</select>
+ <!-- 闂ㄨ瘖婊℃剰搴︾患鍚堝緱鍒嗘帓鍚嶏紙鎸夌瀹ゆ垨鐥呭尯锛� -->
+ <!-- 缁煎悎婊℃剰搴� = 危(璇勫垎鏄庣粏鏉冮噸) / 璇勫垎鏄庣粏鏉℃暟 脳 100%锛屾潈閲嶅彧鍙� 1銆�0.8銆�0.6銆�0.4銆�0.2 浜旀。 -->
+ <select id="selectMzMydScoreRank" parameterType="com.smartor.domain.VO.MzMydScoreRankVO"
+ resultType="com.smartor.domain.DTO.MzMydScoreRankDTO">
+ SELECT
+ t.code AS code,
+ t.name AS name,
+ ROUND(AVG(t.w) * 100, 2) AS score,
+ COUNT(*) AS itemCount
+ FROM (
+ SELECT
+ <choose>
+ <when test='dimensionType == "2"'>
+ s.leavehospitaldistrictcode AS code,
+ s.leavehospitaldistrictname AS name,
+ </when>
+ <otherwise>
+ s.deptcode AS code,
+ s.deptname AS name,
+ </otherwise>
+ </choose>
+ CAST(d.score AS DECIMAL(10,4)) AS w
+ FROM service_subtask s
+ INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+ WHERE s.del_flag = '0'
+ AND d.del_flag = '0'
+ AND s.sendstate = 6
+ <if test="serviceTypes != null and serviceTypes.size() > 0">
+ AND service_type IN
+ <foreach collection="serviceTypes" item="serviceType" open="(" separator=","
+ close=")">
+ #{serviceType}
+ </foreach>
+ </if>
+<!-- <!– 鍙彇鍏紡閲岀殑浜旀。鏉冮噸锛岀┖鍊�/0/鏈瓟绛夋棦涓嶈繘鍒嗗瓙涔熶笉杩涘垎姣� –>-->
+<!-- AND CAST(d.score AS DECIMAL(10,4)) IN (1, 0.8, 0.6, 0.4, 0.2)-->
+ <!-- 鍚屼竴瀛愪换鍔″悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閬垮厤閲嶇瓟琚噸澶嶈鍏ラ」鏁� -->
+ AND d.id = (
+ SELECT MAX(d2.id)
+ FROM service_subtask_detail d2
+ WHERE d2.sub_id = d.sub_id
+ AND d2.questiontext <=> d.questiontext
+ AND d2.del_flag = '0'
+ )
+ <if test="orgid != null and orgid != ''">
+ AND s.orgid = #{orgid}
+ </if>
+ <if test="campusid != null and campusid != ''">
+ AND s.campusid = #{campusid}
+ </if>
+ <if test="startFinishTime != null">
+ AND s.finishtime >= #{startFinishTime}
+ </if>
+ <if test="endFinishTime != null">
+ AND s.finishtime < DATE_ADD(#{endFinishTime}, INTERVAL 1 DAY)
+ </if>
+ <if test="questionText != null and questionText != ''">and d.questiontext like concat('%', #{questionText},
+ '%')
+ </if>
+ <choose>
+ <when test='dimensionType == "2"'>
+ AND s.leavehospitaldistrictcode IS NOT NULL AND s.leavehospitaldistrictcode <> ''
+ AND s.leavehospitaldistrictname IS NOT NULL AND s.leavehospitaldistrictname <> ''
+ <if test="districtCodes != null and districtCodes.size() > 0">
+ AND s.leavehospitaldistrictcode IN
+ <foreach collection="districtCodes" item="districtCode" open="(" separator="," close=")">
+ #{districtCode}
+ </foreach>
+ </if>
+ </when>
+ <otherwise>
+ AND s.deptcode IS NOT NULL AND s.deptcode <> ''
+ AND s.deptname IS NOT NULL AND s.deptname <> ''
+ <if test="deptCodes != null and deptCodes.size() > 0">
+ AND s.deptcode IN
+ <foreach collection="deptCodes" item="deptCode" open="(" separator="," close=")">
+ #{deptCode}
+ </foreach>
+ </if>
+ </otherwise>
+ </choose>
+ ) t
+ GROUP BY t.code, t.name
+ ORDER BY AVG(t.w) DESC, COUNT(*) DESC
+ <if test="limit != null and limit > 0">
+ LIMIT #{limit}
+ </if>
+ </select>
+
+
+
</mapper>
--
Gitblit v1.9.3