From 93078044580c2781cb8cf3ac18d2ab90513267de Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 28 九月 2026 17:13:36 +0800
Subject: [PATCH] 处理患者再入院状态代码提交

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |  135 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 119 insertions(+), 16 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index e5ae35f..fc3e5da 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -571,6 +571,43 @@
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
         </if>
     </select>
+    <!--
+        婊℃剰搴︾粺璁★細鍙煡鏈鏉′欢涓嬪疄闄呭瓨鍦ㄥ摢浜� type銆�
+        杩囨护鏉′欢涓� selectSatisfactionSubtaskList 瀹屽叏涓�鑷达紝鍙槸锛�
+          1) 鍙� select distinct type锛堝師鏉ユ槸鎶婁笂鐧句釜瀛楁鍏ㄦ煡鍥炴潵锛夛紱
+          2) visit_time 鏀规垚鍙蛋绱㈠紩鐨勮寖鍥存潯浠讹紙鍘熸潵瀵瑰垪濂� date_format锛岀储寮曠敤涓嶄笂锛夈��
+    -->
+    <select id="selectSatisfactionSubtaskTypes" parameterType="com.smartor.domain.VO.PatSatisfactionReqVO"
+            resultType="java.lang.String">
+        select distinct type
+        from service_subtask
+        where del_flag = 0
+        <if test="questionType != null">and type = #{questionType}</if>
+        <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+            AND leavehospitaldistrictcode IN
+            <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+                     close=")">
+                #{hospitaldistrictcode}
+            </foreach>
+        </if>
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND deptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+        <if test="serviceTypes != null and serviceTypes.size() > 0">
+            AND service_type IN
+            <foreach collection="serviceTypes" item="serviceType" open="(" separator="," close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            AND visit_time &gt;= #{startTime}
+            AND visit_time &lt; date_add(#{endTime}, interval 1 day)
+        </if>
+    </select>
+
     <select id="getCompensateServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
@@ -2584,6 +2621,8 @@
         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 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,
@@ -2891,6 +2930,60 @@
             </if>
             )
         </if>
+    </select>
+
+    <!--
+        婊℃剰搴︽煴鐘跺浘锛氫竴娆℃�х粺璁℃湰娆¤姹傚叏閮ㄦā鏉跨殑鍙戦�侀噺銆�
+        涓� querySendCount 鐨勮繃婊ゆ潯浠跺畬鍏ㄤ竴鑷达紝鍖哄埆鏄細
+          1) 鎸� libtemplateid 鍒嗙粍锛屼竴娆¤繑鍥炴墍鏈夋ā鏉匡紙鏇夸唬閫愪釜妯℃澘鏌ヨ锛夛紱
+          2) visit_time 鏀规垚鍙蛋绱㈠紩鐨勮寖鍥存潯浠讹紙鍘熸潵瀵瑰垪濂� date_format锛岀储寮曠敤涓嶄笂锛夈��
+    -->
+    <select id="selectSatisfactionSendCount" parameterType="com.smartor.domain.entity.SatisfactionStatQuery"
+            resultType="java.util.Map">
+        select libtemplateid as libtemplateid, count(distinct id) as cnt
+        from service_subtask
+        where 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="type != null and type != ''">and type = #{type}</if>
+        <if test="startTime != null">
+            and visit_time &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            and visit_time &lt; date_add(#{endTime}, interval 1 day)
+        </if>
+        <if test="libTemplateIds != null and libTemplateIds.size() > 0">
+            and libtemplateid IN
+            <foreach collection="libTemplateIds" item="libTemplateId" open="(" separator="," close=")">
+                #{libTemplateId}
+            </foreach>
+        </if>
+        <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0) or (deptcodes != null and deptcodes.size() > 0)">
+            AND (
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0">
+                leavehospitaldistrictcode IN
+                <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="("
+                         separator=","
+                         close=")">
+                    #{hospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0 and deptcodes != null and deptcodes.size() > 0">
+                OR
+            </if>
+            <if test="deptcodes != null and deptcodes.size() > 0">
+                deptcode IN
+                <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                    #{deptcode}
+                </foreach>
+            </if>
+            )
+        </if>
+        group by libtemplateid
     </select>
 
     <!--
@@ -3397,14 +3490,15 @@
     <select id="statQuestionOptionBySubtaskIds" resultType="com.smartor.domain.ServiceSubtaskDetailRatioExport">
         SELECT
         d.questiontext AS questiontext,
-        t.taskid AS taskid,
-        t.task_name AS taskName,
+        <!-- 鏄庣粏宸叉寜銆岄鐩� + 閫夐」銆嶆眹鎬伙紝浠诲姟/绉戝/鐥呭尯鍙槸闄勫甫淇℃伅锛屽繀椤荤敤鑱氬悎鍑芥暟鍙栧�硷紙MySQL ONLY_FULL_GROUP_BY锛� -->
+        MAX(t.taskid) AS taskid,
+        MAX(t.task_name) AS taskName,
         d.asrtext AS optionresult,
         d.score AS score,
-        s.deptcode AS deptcode,
-        s.deptname AS deptname,
-        s.leavehospitaldistrictcode AS leavehospitaldistrictcode,
-        s.leavehospitaldistrictname AS leavehospitaldistrictname,
+        MAX(s.deptcode) AS deptcode,
+        MAX(s.deptname) AS deptname,
+        MAX(s.leavehospitaldistrictcode) AS leavehospitaldistrictcode,
+        MAX(s.leavehospitaldistrictname) AS leavehospitaldistrictname,
         d.targetvalue AS targetvalue,
         d.value_type AS valueType,
         COUNT(*) AS count,
@@ -3422,9 +3516,15 @@
         AND d2.del_flag = '0'
         )
         INNER JOIN (
+        <!-- 鍒嗘瘝 = 璇ラ鍚勯�夐」椤规暟涔嬪拰锛堟湭浣滅瓟鐨勭┖ asrtext 涓嶈繘鍒嗘瘝锛夛紝杩欐牱涓�閬撻鍚勯�夐」姣斾緥鍚堣鎵嶆槸 100% -->
+        SELECT
+        x.questiontext AS questiontext,
+        SUM(x.option_count) AS total_count
+        FROM (
         SELECT
         d.questiontext,
-        COUNT(*) AS total_count
+        d.asrtext,
+        COUNT(*) AS option_count
         FROM
         service_task t
         INNER JOIN service_subtask s ON s.taskid = t.taskid
@@ -3465,7 +3565,11 @@
         <if test="endFinishTime != null">
             AND date_format(s.finishtime,'%y%m%d') &lt;= date_format(#{endFinishTime},'%y%m%d')
         </if>
-        GROUP BY d.questiontext
+        <!-- 鏈綔绛旓紙asrtext 涓虹┖锛夌殑鏄庣粏涓嶈鍏ュ垎姣� -->
+        AND d.asrtext IS NOT NULL AND TRIM(d.asrtext) &lt;&gt; ''
+        GROUP BY d.questiontext, d.asrtext
+        ) x
+        GROUP BY x.questiontext
         ) t2 ON t2.questiontext = d.questiontext
         WHERE 1=1
         <!-- 鍘婚噸锛氭槑缁嗚鍚屼竴瀛愪换鍔″悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閲嶇瓟涓嶉噸澶嶈鍏ラ」鏁� -->
@@ -3484,6 +3588,8 @@
         </if>
         AND s.sendstate = 6
         AND d.del_flag=0
+        <!-- 鏈綔绛旓紙asrtext 涓虹┖锛変笉绠椾换浣曢�夐」锛屾槑缁嗛噷鐩存帴鎺掗櫎锛岄伩鍏嶅嚭鐜扮┖閫夐」琛� -->
+        AND d.asrtext IS NOT NULL AND TRIM(d.asrtext) &lt;&gt; ''
         <if test="valueType != null">AND d.value_type &gt;= #{valueType}</if>
         <if test="scoreStart != null">AND d.score &gt;= #{scoreStart}</if>
         <if test="scoreEnd != null">AND d.score &lt;= #{scoreEnd}</if>
@@ -3502,21 +3608,17 @@
         <if test="endFinishTime != null">
             AND date_format(s.finishtime,'%y%m%d') &lt;= date_format(#{endFinishTime},'%y%m%d')
         </if>
+        <!-- 鍙寜銆岄鐩� + 閫夐」銆嶆眹鎬伙細鍘熸潵 GROUP BY 甯︿笂 taskid/绉戝/鐥呭尯锛屽悓涓�涓�夐」琚媶鎴愬琛屻�佹瘡琛屾暟閲忛兘鏄� 1锛�
+             鍓嶇/瀵煎嚭鎷垮埌鐨勩�屾暟閲忋�嶅氨姘歌繙鍋氫笉浜嗙疮鍔� -->
         GROUP BY
-        t.taskid,
         d.questiontext,
+        d.asrtext,
         d.score,
         d.targetvalue,
-        d.asrtext,
-        t.task_name,
-        s.deptcode,
-        s.deptname,
-        s.leavehospitaldistrictcode,
-        s.leavehospitaldistrictname,
         d.value_type
         ORDER BY
         d.questiontext,
-        t.taskid
+        MIN(t.taskid)
     </select>
 
     <select id="statQuestionOptionByKsOrBq" resultType="com.smartor.domain.DTO.QuestionCountKsOrBqDTO"
@@ -3677,5 +3779,6 @@
     </select>
 
 
+
 </mapper>
 

--
Gitblit v1.9.3