From eb845e8be695ed1280a7cbf854a4d1dedf9db30d Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 30 十月 2026 15:02:55 +0800
Subject: [PATCH] 【丽水】/smartor/serviceSubtask/getSfStatisticsHyperlink 和 /smartor/serviceSubtask/getSfStatistics 统计的时候,对于 service_subtask.current_preachForm 为空的数据 当成 service_subtask.preachform 字符串的第一个执行方式、首次待随访全部(visitCount = 1 && sendstate in (1、2、3、7)) 区别于原先的待随访,这个是给市一使用的 再次待随访全部(visitCount > 1 && sendstate in (1、2、3、7)) 区别于原先的待随访,这个是给市一使用的 首次待随访待发送(visitCount = 1 && sendstate in (1、2)) 再次待随访待发送(visitCount > 1 && sendstate in (1、2)) 首次待随访已发送(visitCount = 1 && sendstate = in (3、7)) 再次待随访已发送(visitCount > 1 && sendstate = in (3、7)) 首次已发送(visitCount = 1 && sendstate = 3) 再次已发送(visitCount > 1 && sendstate = 3)
---
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 94 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 81 insertions(+), 13 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 1948988..c67e8c4 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -82,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"/>
@@ -255,7 +256,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)锛�
@@ -300,6 +301,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"
@@ -404,6 +410,7 @@
<if test="managementDoctorCode != null ">and management_doctor_code = #{managementDoctorCode}</if>
<if test="submit != null ">and submit = #{submit}</if>
<if test="upid != null ">and upid = #{upid}</if>
+ <if test="visitCount != null ">and visit_count = #{visitCount}</if>
<if test="patfrom != null ">and patfrom = #{patfrom}</if>
<if test="serviceType != null ">and service_type = #{serviceType}</if>
<if test="patid != null ">and patid = #{patid}</if>
@@ -567,6 +574,9 @@
<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="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>
@@ -949,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>
@@ -1639,6 +1655,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,
@@ -1656,13 +1701,14 @@
deptname,
sendstate,
preachform,
- current_preachform,
+ <include refid="effectiveCurrentPreachformExpr"/> AS current_preachform,
excep,
nurse_id,
nurse_name,
taskid,
task_name,
visit_time,
+ visit_dept_code,
finishtime,
endtime,
senddate,
@@ -1681,6 +1727,7 @@
continue_count,
continue_time_next,
task_situation,
+ finish_state,
is_manually_called
from service_subtask
where 1=1
@@ -1943,13 +1990,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,
@@ -1970,6 +2019,7 @@
task_situation,
remark,
doctor_opinion,
+ finish_state,
is_manually_called
from service_subtask
where 1=1
@@ -2041,7 +2091,7 @@
</foreach>
</if>
<if test="currentPreachform != null">
- AND current_preachform = #{currentPreachform}
+ AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform}
<if test="followUpCountStyle != null and followUpCountStyle = '1'">
AND sendstate != 4
</if>
@@ -2051,6 +2101,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}
@@ -2276,14 +2329,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
@@ -2346,25 +2399,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>
@@ -2403,7 +2468,7 @@
<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>
<select id="getDataByTime" resultMap="ServiceSubtaskResult">
@@ -2894,6 +2959,9 @@
#{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}
</if>
--
Gitblit v1.9.3