From c771ba20bf45ebc7be74ebe3ee7f76fb159e7ed3 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 04 十一月 2026 14:37:58 +0800
Subject: [PATCH] 【丽水】填充手术随访 serviceSubtask.leaveDiagname
---
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 309 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 280 insertions(+), 29 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 40a1c34..a8960d6 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -73,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"/>
@@ -81,6 +82,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"/>
@@ -101,6 +103,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.smartor.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -183,6 +186,7 @@
long_send_time,
openid,
remark,
+ doctor_opinion,
service_type,
libtemplateid,
libtemplatename,
@@ -253,7 +257,7 @@
from service_subtask
</sql>
- <!-- 瀹屾垚鏃剁姸鎬�(finish_state)璁$畻锛氫粎褰撴湰娆℃洿鏂版妸 sendstate 缃负 6锛堥殢璁垮畬鎴愶級鏃朵娇鐢ㄣ��
+ <!-- 瓒呮椂瀹屾垚銆佸欢鏈熷畬鎴愰�昏緫 瀹屾垚鏃剁姸鎬�(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)锛�
@@ -298,6 +302,11 @@
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.smartor.domain.entity.ServiceSubtaskEntity"
@@ -564,7 +573,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>
@@ -594,6 +606,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>
@@ -710,7 +723,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>
@@ -770,7 +783,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>
@@ -946,6 +959,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>
@@ -1053,6 +1072,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>
@@ -1067,7 +1087,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>
@@ -1152,6 +1172,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>
@@ -1166,7 +1187,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>
@@ -1266,6 +1287,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>
@@ -1279,7 +1301,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>
@@ -1295,6 +1317,25 @@
<if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
</trim>
where id = #{id}
+ </update>
+
+ <!-- 寰俊鍏紬鍙峰凡棰嗗彇鏈~鍐欐寜榛樿閫夐」瀹屾垚锛氬彧鏇存柊褰撳墠瀛愪换鍔°��
+ 鏉′欢 sendstate=1 + 鏈彁浜わ紝淇濊瘉鍙鐞嗗綋鍓嶈棰嗗彇涓旀湭濉啓鐨勫瓙浠诲姟锛屼笉娉㈠強鍏朵粬浠诲姟銆� -->
+ <update id="updateWechatDefaultComplete" parameterType="com.smartor.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.smartor.domain.ServiceSubtask">
@@ -1372,6 +1413,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>
@@ -1384,7 +1426,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>
@@ -1477,6 +1519,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>
@@ -1488,7 +1531,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>
@@ -1589,6 +1632,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>
@@ -1600,7 +1644,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>
@@ -1630,6 +1674,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.smartor.domain.ServiceSubtaskCountReq"
resultMap="ServiceSubtaskResult">
select id,
@@ -1647,13 +1720,17 @@
deptname,
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,
@@ -1672,6 +1749,7 @@
continue_count,
continue_time_next,
task_situation,
+ finish_state,
is_manually_called
from service_subtask
where 1=1
@@ -1694,6 +1772,13 @@
<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">
@@ -1879,6 +1964,13 @@
#{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">
AND service_type IN
<foreach collection="serviceType" item="serviceType" open="(" separator=","
@@ -1914,9 +2006,6 @@
<if test="groupKey != null and groupKey != ''">
group by ${groupKey}
</if>
- <if test="pageSize != null and pageNum != null">
- limit ${pageSize} OFFSET ${pageNum}
- </if>
</select>
<select id="getSfStatisticsHyperlink" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1934,13 +2023,15 @@
deptname,
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,
@@ -1960,6 +2051,8 @@
continue_time_next,
task_situation,
remark,
+ doctor_opinion,
+ finish_state,
is_manually_called
from service_subtask
where 1=1
@@ -2010,10 +2103,15 @@
<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">
@@ -2030,8 +2128,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>
@@ -2041,6 +2139,9 @@
</if>
<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}
@@ -2053,6 +2154,9 @@
</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">
@@ -2266,14 +2370,14 @@
<select id="getSfStatisticsScriptDetails" parameterType="com.smartor.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
@@ -2336,25 +2440,37 @@
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.smartor.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>
@@ -2393,7 +2509,137 @@
<if test="configValue != null and configValue != ''">
AND ssd.categoryid IN (${configValue})
</if>
- group by ssd.scriptid, IFNULL(ssd.matchedtext,ssd.asrtext)
+ 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.smartor.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
+ <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+ close=")">
+ #{leavehospitaldistrictcode}
+ </foreach>
+ </if>
+ <if test="deptcodes != null and deptcodes.size() > 0">
+ AND ss.deptcode IN
+ <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=")">
+ #{serviceType}
+ </foreach>
+ </if>
+ <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 type != ''">
+ AND ss.type = #{type}
+ </if>
+
+ <!-- 缁熻缁村害锛�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>
+ <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">
@@ -2464,6 +2710,7 @@
nurse_id,
nurse_name,
remark,
+ doctor_opinion,
inhospid,
patfrom,
task_guid,
@@ -2882,6 +3129,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}
@@ -3357,7 +3607,8 @@
continue_count,
continue_time_next,
task_situation,
- remark
+ remark,
+ doctor_opinion
from service_subtask
where 1=1
and del_flag = 0
--
Gitblit v1.9.3