From 2a9c68fe5130227d88b71e8eb57aced6b10d4d91 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 17 十二月 2025 15:47:35 +0800
Subject: [PATCH] 【丽水】统计随访数据 增加redis记录结果 提高查询效率
---
smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 106 insertions(+), 5 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 5682971..540e215 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -513,8 +513,9 @@
<select id="selectPatMedInhosp" parameterType="Long" resultMap="PatMedInhospResult">
<include refid="selectPatMedInhospVo"/>
where del_flag=0
- <if test="cry != null and cry == 0 ">and endtime is null</if>
+ <if test="cry != null and cry == 0 ">and inhospstate=0</if>
<if test="cry != null and cry == 1 ">and inhospstate=1</if>
+ <if test="cry != null and cry == 3 ">and inhospstate=3</if>
<if test="serialnum != null">and serialnum = #{serialnum}</if>
<if test="hospitalname != null">and hospitalname = #{hospitalname}</if>
<if test="hospitalcode != null">and hospitalcode = #{hospitalcode}</if>
@@ -919,11 +920,18 @@
<select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq"
resultType="com.smartor.domain.PatMedRes">
SELECT SUM( rs ) AS rs,
- SUM( rc ) AS rc
+ SUM( rc ) AS rc,
+ SUM( scsf ) AS scsf,
+ SUM( zcsf ) AS zcsf,
+ SUM( zbsf ) AS zbsf
FROM (
+ <!-- 鍑洪櫌浜烘-->
SELECT
COUNT(1) AS rc,
- 0 AS rs
+ 0 AS rs,
+ 0 AS scsf,
+ 0 AS zcsf,
+ 0 AS zbsf
FROM
pat_med_inhosp
<where>
@@ -953,12 +961,15 @@
</foreach>
</if>
</if>
-
</where>
+ <!-- 闅忚鏈嶅姟浜烘暟 -->
union all
select
0 AS rc,
- count(1) AS rs
+ count(1) AS rs,
+ 0 AS scsf,
+ 0 AS zcsf,
+ 0 AS zbsf
FROM
service_subtask
<where>
@@ -980,6 +991,96 @@
</foreach>
</if>
</where>
+ <!-- 棣栨闅忚浜烘暟 -->
+ union all
+ select
+ 0 AS rc,
+ 0 AS rs,
+ count(1) AS scsf,
+ 0 AS zcsf,
+ 0 AS zbsf
+ FROM
+ service_subtask
+ <where>
+ del_flag = 0
+ and service_type=2
+ and is_visit_again = 0
+ <if test="orgid != null">
+ AND orgid = #{orgid}
+ </if>
+ <if test="startDate != null">
+ AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
+ </if>
+ <if test="endDate != null">
+ AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
+ </if>
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ and deptcode in
+ <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </where>
+ <!-- 鍐嶆闅忚浜烘暟 -->
+ union all
+ select
+ 0 AS rc,
+ 0 AS rs,
+ 0 AS scsf,
+ count(1) AS zcsf,
+ 0 AS zbsf
+ FROM
+ service_subtask
+ <where>
+ del_flag = 0
+ and service_type=2
+ and is_visit_again = 1
+ <if test="orgid != null">
+ AND orgid = #{orgid}
+ </if>
+ <if test="startDate != null">
+ AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
+ </if>
+ <if test="endDate != null">
+ AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
+ </if>
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ and deptcode in
+ <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </where>
+ <!-- 涓撶梾闅忚浜烘暟 -->
+ union all
+ select
+ 0 AS rc,
+ 0 AS rs,
+ 0 AS scsf,
+ 0 AS zcsf,
+ count(1) AS zbsf
+ FROM
+ service_subtask
+ <where>
+ del_flag = 0
+ and service_type=13
+ <if test="orgid != null">
+ AND orgid = #{orgid}
+ </if>
+ <if test="startDate != null">
+ AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
+ </if>
+ <if test="endDate != null">
+ AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
+ </if>
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ and deptcode in
+ <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </where>
) AS combined_data
</select>
+
</mapper>
--
Gitblit v1.9.3