From 34f78281cf395a24e1f3f1c3b861186ff8a03b7b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 16 十月 2026 11:09:40 +0800
Subject: [PATCH] 出入院模块、门急诊模块、模块模块、宣教模块、其它模块

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml |  222 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 153 insertions(+), 69 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
index 79943e7..1bc14e8 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
@@ -326,79 +326,163 @@
         <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
     </select>
 
-    <select id="tracedeallist" parameterType="com.smartor.domain.VO.DetailTraceDealVO"
-            resultMap="ServiceSubtaskDetailTtraceResult">
-        <include refid="selectServiceSubtaskDetailTtraceVo"/>
-        where del_flag=0
+    <!--
+        寮傚父闂澶勭悊鎯呭喌鏌ヨ锛坱racedeallist锛夌殑鍏叡杩囨护鏉′欢銆�
+        涓嬮潰 5 鏉� SQL 鍏辩敤鏈墖娈碉紝淇濊瘉銆屽垎椤垫暟鎹�侀棶棰樻�绘暟銆佸叏閲忔眹鎬汇�嶇殑鍙e緞瀹屽叏涓�鑷淬��
+        娉ㄦ剰锛歲uestiontext 涓虹┖鐨勮鍘熷疄鐜伴噷琚� stream().filter(questiontext != null) 涓㈡帀浜嗭紝
+        鎵�浠ヨ繖閲岀粺涓�鎺掗櫎锛屾眹鎬绘暟鎵嶅拰鍘熸潵涓�鑷淬��
+    -->
+    <sql id="traceDealWhere">
+        and del_flag = 0
+        and questiontext is not null
+        <if test="vo.templateid != null  and vo.templateid != ''">
+            and templateid = #{vo.templateid}
+        </if>
+        <if test="vo.todeptcode != null  and vo.todeptcode != ''">
+            and FIND_IN_SET(#{vo.todeptcode}, todeptcode)
+        </if>
+        <if test="vo.todeptname != null  and vo.todeptname != ''">
+            and todeptname like concat('%', #{vo.todeptname}, '%')
+        </if>
+        <if test="vo.handleStartTime != null and vo.handleEndTime != null">
+            and handle_time between #{vo.handleStartTime} and #{vo.handleEndTime}
+        </if>
+        <if test="vo.orgid != null  and vo.orgid != ''">
+            and orgid = #{vo.orgid}
+        </if>
+        <if test="vo.type != null  and vo.type != ''">
+            and type = #{vo.type}
+        </if>
+        <if test="vo.templateType != null">
+            and template_type = #{vo.templateType}
+        </if>
+        <if test="vo.isMydException != null ">
+            and is_myd_exception = #{vo.isMydException}
+        </if>
+        <if test="vo.dimension != null  and vo.dimension != ''">
+            and dimension = #{vo.dimension}
+        </if>
+        <if test="vo.dutyDeptPersonName != null  and vo.dutyDeptPersonName != ''">
+            and duty_dept_person_name like concat('%', #{vo.dutyDeptPersonName}, '%')
+        </if>
+        <if test="vo.dutyDeptPersonCode != null  and vo.dutyDeptPersonCode != ''">
+            and duty_dept_person_code like concat('%', #{vo.dutyDeptPersonCode}, '%')
+        </if>
+        <if test="vo.reportDeptPersonName != null  and vo.reportDeptPersonName != ''">
+            and report_dept_person_name like concat('%', #{vo.reportDeptPersonName}, '%')
+        </if>
+        <if test="vo.reportDeptPersonCode != null  and vo.reportDeptPersonCode != ''">
+            and report_dept_person_code like concat('%', #{vo.reportDeptPersonCode}, '%')
+        </if>
+        <if test="vo.circulationDeptPersonCode != null  and vo.circulationDeptPersonCode != ''">
+            and circulation_dept_person_code like concat('%', #{vo.circulationDeptPersonCode}, '%')
+        </if>
+        <if test="vo.circulationDeptPersonName != null  and vo.circulationDeptPersonName != ''">
+            and circulation_dept_person_name like concat('%', #{vo.circulationDeptPersonName}, '%')
+        </if>
+        <if test="vo.circulationDeptCode != null  and vo.circulationDeptCode != ''">
+            and circulation_dept_code like concat('%', #{vo.circulationDeptCode}, '%')
+        </if>
+        <if test="vo.circulationDeptName != null  and vo.circulationDeptName != ''">
+            and circulation_dept_name like concat('%', #{vo.circulationDeptName}, '%')
+        </if>
+        <if test="vo.circulationExplain != null  and vo.circulationExplain != ''">
+            and circulation_explain like concat('%', #{vo.circulationExplain}, '%')
+        </if>
+        <if test="vo.circulationTime != null ">
+            and circulation_time = #{vo.circulationTime}
+        </if>
+        <if test="vo.circulationStatus != null ">
+            and circulation_status = #{vo.circulationStatus}
+        </if>
+        <if test="vo.circulationPersonName != null  and vo.circulationPersonName != ''">
+            and circulation_person_name like concat('%', #{vo.circulationPersonName}, '%')
+        </if>
+        <if test="vo.circulationPersonCode != null  and vo.circulationPersonCode != ''">
+            and circulation_person_code = #{vo.circulationPersonCode}
+        </if>
+    </sql>
 
-        <if test="templateid != null  and templateid != ''">
-            and templateid = #{templateid}
-        </if>
-        <if test="todeptcode != null  and todeptcode != ''">
-            and FIND_IN_SET(#{todeptcode}, todeptcode)
-        </if>
-        <if test="todeptname != null  and todeptname != ''">
-            and todeptname like concat('%', #{todeptname}, '%')
-        </if>
-        <if test="handleStartTime != null and handleEndTime != null">
-            and handle_time between #{handleStartTime} and #{handleEndTime}
-        </if>
+    <!--
+        褰撳墠椤电殑闂鍒嗙粍鑱氬悎锛氬垎椤垫寜闂缁村害涓嬫帹鍒� SQL銆�
+        鍘熸潵鏄妸 service_subtask_detail_trace 鍏ㄨ〃锛堝惈 patdesc/recordurl 绛夊ぇ瀛楁锛夋媺鍥� Java 鍐嶅垎缁勶紝
+        pageSize 瀹屽叏娌$敓鏁堬紱鐜板湪 DB 鍙鐞嗗綋鍓嶉〉鐨勯鐩��
 
-        <if test="orgid != null  and orgid != ''">
-            and orgid = #{orgid}
+        娉ㄦ剰鍒嗙粍缁村害蹇呴』鏄� questiontext锛堟帴鍙f枃妗g害瀹氥�屾瘡涓棶棰樺搴斾竴鏉¤褰曘�嶏級锛�
+        涓�涓� questiontext 鍙兘瀵瑰簲澶氫釜 scriptid锛岃繖鏃惰鎶婅闂鎵�鏈� scriptid 鐨勬湁鏁堝~鍐欐暟鍔犺捣鏉ワ紝
+        鎵�浠ヨ繖閲岀敤 group_concat(distinct scriptid) 鎶� scriptid 鍒楄〃甯﹀洖 Java锛坰criptid 鍙栨渶灏忓�肩敤浜庡睍绀猴級銆�
+        濡傛灉鏀规垚 group by questiontext, scriptid锛屽悓涓�涓棶棰樹細鎷嗘垚澶氳锛�
+        涓� countTraceDealQuestions锛堟寜 questiontext 鍘婚噸锛夈�乼otal銆佽礋璐g瀹ゃ�佹渶鏂板鐞嗕汉鐨勫彛寰勯兘浼氫笉涓�鑷淬��
+    -->
+    <select id="selectTraceDealGroups" resultType="java.util.Map">
+        select questiontext                                        as questiontext,
+               min(scriptid)                                       as scriptid,
+               group_concat(distinct scriptid)                      as scriptids,
+               min(template_type)                                  as templateType,
+               count(*)                                            as exceptionFillNum,
+               sum(case when handle_flag = '1' then 1 else 0 end)   as yesDeal,
+               sum(case when handle_flag = '1' then 0 else 1 end)   as noDeal
+        from service_subtask_detail_trace
+        where 1 = 1
+        <include refid="traceDealWhere"/>
+        group by questiontext
+        order by questiontext
+        <if test="vo.pageSize != null and vo.pageNum != null">
+            limit ${vo.pageSize} offset ${vo.pageNum}
         </if>
+    </select>
 
-        <if test="type != null  and type != ''">
-            and type = #{type}
-        </if>
-        <if test="templateType != null">
-            and template_type = #{templateType}
-        </if>
-        <if test="isMydException != null ">
-            and is_myd_exception = #{isMydException}
-        </if>
-        <if test="dimension != null  and dimension != ''">
-            and dimension = #{dimension}
-        </if>
-        <if test="dutyDeptPersonName != null  and dutyDeptPersonName != ''">
-            and duty_dept_person_name like concat('%', #{dutyDeptPersonName}, '%')
-        </if>
-        <if test="dutyDeptPersonCode != null  and dutyDeptPersonCode != ''">
-            and duty_dept_person_code like concat('%', #{dutyDeptPersonCode}, '%')
-        </if>
-        <if test="reportDeptPersonName != null  and reportDeptPersonName != ''">
-            and report_dept_person_name like concat('%', #{reportDeptPersonName}, '%')
-        </if>
-        <if test="reportDeptPersonCode != null  and reportDeptPersonCode != ''">
-            and report_dept_person_code like concat('%', #{reportDeptPersonCode}, '%')
-        </if>
-        <if test="circulationDeptPersonCode != null  and circulationDeptPersonCode != ''">
-            and circulation_dept_person_code like concat('%', #{circulationDeptPersonCode}, '%')
-        </if>
-        <if test="circulationDeptPersonName != null  and circulationDeptPersonName != ''">
-            and circulation_dept_person_name like concat('%', #{circulationDeptPersonName}, '%')
-        </if>
-        <if test="circulationDeptCode != null  and circulationDeptCode != ''">
-            and circulation_dept_code like concat('%', #{circulationDeptCode}, '%')
-        </if>
-        <if test="circulationDeptName != null  and circulationDeptName != ''">
-            and circulation_dept_name like concat('%', #{circulationDeptName}, '%')
-        </if>
-        <if test="circulationExplain != null  and circulationExplain != ''">
-            and circulation_explain like concat('%', #{circulationExplain}, '%')
-        </if>
-        <if test="circulationTime != null ">
-            and circulation_time = #{circulationTime}
-        </if>
-        <if test="circulationStatus != null ">
-            and circulation_status = #{circulationStatus}
-        </if>
-        <if test="circulationPersonName != null  and circulationPersonName != ''">
-            and circulation_person_name like concat('%', #{circulationPersonName}, '%')
-        </if>
-        <if test="circulationPersonCode != null  and circulationPersonCode != ''">
-            and circulation_person_code =#{circulationPersonCode}
-        </if>
+    <!-- 闂鎬绘暟锛堝垎椤� total锛屾寜闂缁村害锛� -->
+    <select id="countTraceDealQuestions" resultType="long">
+        select count(distinct questiontext)
+        from service_subtask_detail_trace
+        where 1 = 1
+        <include refid="traceDealWhere"/>
+    </select>
+
+    <!-- 鍏ㄩ噺姹囨�伙紙涓嶅彈鍒嗛〉褰卞搷锛夛細鎬绘暟 + 宸插鐞嗘暟锛屾湭澶勭悊鏁板湪 Java 閲岀浉鍑� -->
+    <select id="sumTraceDeal" resultType="java.util.Map">
+        select count(*)                                          as totalException,
+               sum(case when handle_flag = '1' then 1 else 0 end) as yesDeal
+        from service_subtask_detail_trace
+        where 1 = 1
+        <include refid="traceDealWhere"/>
+    </select>
+
+    <!-- 褰撳墠椤甸棶棰樼殑璐熻矗绉戝锛堟寜绉戝缂栧彿鍘婚噸锛屽悕绉板彇缁勫唴闈炵┖鐨勪竴涓級 -->
+    <select id="selectTraceDealDepts" resultType="java.util.Map">
+        select questiontext      as questiontext,
+               todeptcode        as deptCode,
+               min(todeptname)   as deptName
+        from service_subtask_detail_trace
+        where 1 = 1
+        <include refid="traceDealWhere"/>
+        and todeptcode is not null and todeptcode != ''
+        and questiontext in
+        <foreach collection="questiontexts" item="qt" open="(" separator="," close=")">
+            #{qt}
+        </foreach>
+        group by questiontext, todeptcode
+    </select>
+
+    <!-- 褰撳墠椤甸棶棰樼殑鏈�鏂板鐞嗕汉鍜屽鐞嗘椂闂达紙handle_time 鏈�澶х殑涓�鏉★級 -->
+    <select id="selectTraceDealLatestHandle" resultType="java.util.Map">
+        select t.questiontext as questiontext,
+               t.handle_by    as handleBy,
+               t.handle_time  as handleTime
+        from service_subtask_detail_trace t
+                 inner join (select questiontext, max(handle_time) as maxHandleTime
+                             from service_subtask_detail_trace
+                             where 1 = 1
+                             <include refid="traceDealWhere"/>
+                             and handle_time is not null
+                             and questiontext in
+                             <foreach collection="questiontexts" item="qt" open="(" separator="," close=")">
+                                 #{qt}
+                             </foreach>
+                             group by questiontext) m
+                            on m.questiontext = t.questiontext and m.maxHandleTime = t.handle_time
+        where t.del_flag = 0
     </select>
 
 

--
Gitblit v1.9.3