From ecbb6791ae00a8a4076715b87a941c0a8557fa03 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 13 一月 2026 11:31:34 +0800
Subject: [PATCH] 【市一】采集出入院增加院区id

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index ea1985a..6385d61 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -1203,8 +1203,12 @@
                 AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
             </if>
             <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
-            <if test="visitDeptName != null">abd visit_dept_name = #{visitDeptName}</if>
-            <if test="isabnormal != null">abd isabnormal = #{isabnormal}</if>
+            <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
+            <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
+            <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
+            <if test="type != null">
+                and type = #{type}
+            </if>
     </select>
 
     <select id="getSfStatisticsJoy" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1330,19 +1334,25 @@
 
     <select id="getSfStatisticsCategory" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultMap="ServiceSubtaskResult2">
-        SELECT a.sub_id as subTaskId,
+        SELECT
         <if test="configValue != null and configValue != ''">
             SUM(CASE WHEN a.categoryid IN(${configValue})
             THEN 1 ELSE 0 END) AS joyAllCount,
         </if>
-        COUNT(sub_id) joyCount
+        <if test="configValue != null and configValue != ''">
+            SUM(CASE WHEN a.categoryid IN(${configValue})
+                AND a.matchedtext is not null
+                AND a.matchedtext != ''
+            THEN 1 ELSE 0 END) AS joyCount,
+        </if>
+        a.sub_id as subTaskId
         FROM service_subtask_detail a
         INNER JOIN service_subtask t ON a.sub_id = t.id
         where 1=1
             and a.del_flag=0
             AND t.del_flag=0
             <if test="orgid != null and orgid != ''">
-                and a.orgid = #{orgid}
+                and t.orgid = #{orgid}
             </if>
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
                 AND t.leavehospitaldistrictcode IN
@@ -1414,8 +1424,8 @@
         FROM
         service_subtask_detail ssd
         INNER JOIN service_subtask ss ON ssd.sub_id = ss.id
-        WHERE
-        ss.del_flag=0
+        WHERE 1=1
+        AND ss.del_flag=0
         AND ssd.del_flag = 0
         <if test="orgid != null and orgid != ''">
             AND ss.orgid = #{orgid}
@@ -1452,12 +1462,15 @@
         <if test="configValue != null and configValue != ''">
             AND ssd.categoryid IN (${configValue})
         </if>
-        <!-- 閫傜敤鍗曟潯鏌ヨ -->
-        <if test="scriptids != null">
-            AND ssd.scriptid in (${scriptids})
-        </if>
         group by ssd.scriptid) b
         ON a.id = b.scriptid
+        <!-- 閫傜敤鍗曟潯鏌ヨ -->
+        <if test="scriptids != null">
+            AND a.scriptid in
+            (SELECT lib_script.scriptid FROM
+            svy_lib_template_script lib_script
+            WHERE lib_script.scriptid in (${scriptids}))
+        </if>
     </select>
 
     <select id="getSfStatisticsScriptItemDetails" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1474,8 +1487,6 @@
             <if test="orgid != null and orgid != ''">
                 and ss.orgid = #{orgid}
             </if>
-            AND IFNULL(ssd.matchedtext,ssd.asrtext) IS NOT NULL
-            AND IFNULL(ssd.matchedtext,ssd.asrtext) != ''
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
                 AND ss.leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","

--
Gitblit v1.9.3