From 60ade5154522a042c816abaa1840751011ae0371 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 29 九月 2026 19:15:03 +0800
Subject: [PATCH] 1.省立同德满度问题处理 2.门急诊数据采集优化

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml |  380 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 356 insertions(+), 24 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
index 3d10b0a..1bc14e8 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailTraceMapper.xml
@@ -53,11 +53,42 @@
         <result property="pid" column="pid"/>
         <result property="categoryid" column="categoryid"/>
         <result property="templateType" column="template_type"/>
+        <result property="isMydException" column="is_myd_exception"/>
+        <result property="dimension" column="dimension"/>
+        <result property="dutyDeptPersonName" column="duty_dept_person_name"/>
+        <result property="dutyDeptPersonCode" column="duty_dept_person_code"/>
+        <result property="reportDeptPersonCode" column="report_dept_person_name"/>
+        <result property="reportDeptPersonName" column="report_dept_person_code"/>
+        <result property="circulationDeptPersonCode" column="circulation_dept_person_code"/>
+        <result property="circulationDeptPersonName" column="circulation_dept_person_name"/>
+        <result property="circulationDeptCode" column="circulation_dept_code"/>
+        <result property="circulationDeptName" column="circulation_dept_name"/>
+        <result property="circulationExplain" column="circulation_explain"/>
+        <result property="circulationTime" column="circulation_time"/>
+        <result property="circulationStatus" column="circulation_status"/>
+        <result property="circulationPersonName" column="circulation_person_name"/>
+        <result property="circulationPersonCode" column="circulation_person_code"/>
+
     </resultMap>
 
     <sql id="selectServiceSubtaskDetailTtraceVo">
         select id,
+               circulation_status,
+               circulation_person_name,
+               circulation_person_code,
+               duty_dept_person_name,
+               duty_dept_person_code,
+               report_dept_person_name,
+               report_dept_person_code,
+               circulation_dept_person_code,
+               circulation_dept_person_name,
+               circulation_dept_code,
+               circulation_dept_name,
+               circulation_explain,
+               circulation_time,
                detail_id,
+               is_myd_exception,
+               dimension,
                template_type,
                sub_id,
                taskid,
@@ -108,7 +139,7 @@
         from service_subtask_detail_trace
     </sql>
 
-    <select id="selectServiceSubtaskDetailTtraceList" parameterType="com.smartor.domain.ServiceSubtaskDetailTrace"
+    <select id="selectServiceSubtaskDetailTtraceList" parameterType="com.smartor.domain.VO.ServiceSubtaskDetailTraceVO"
             resultMap="ServiceSubtaskDetailTtraceResult">
         <include refid="selectServiceSubtaskDetailTtraceVo"/>
         where del_flag=0
@@ -160,8 +191,14 @@
         <if test="valueType != null  and valueType != ''">
             and value_type = #{valueType}
         </if>
-        <if test="scriptid != null ">
+        <if test="scriptid != null and scriptids==null ">
             and scriptid = #{scriptid}
+        </if>
+        <if test="scriptids != null ">
+            and scriptid in
+            <foreach item="scriptid" collection="scriptids" open="(" separator="," close=")">
+                #{scriptid}
+            </foreach>
         </if>
         <if test="answerps != null  and answerps != ''">
             and answerps = #{answerps}
@@ -241,36 +278,212 @@
         <if test="type != null  and type != ''">
             and type = #{type}
         </if>
+        <if test="dimension != null  and dimension != ''">
+            and dimension = #{dimension}
+        </if>
+        <if test="isMydException != null ">
+            and is_myd_exception = #{isMydException}
+        </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>
+        <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}
-        </if>
-
-        <if test="type != null  and type != ''">
-            and type = #{type}
+        娉ㄦ剰鍒嗙粍缁村害蹇呴』鏄� 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>
 
+    <!-- 闂鎬绘暟锛堝垎椤� 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>
 
 
     <select id="selectServiceSubtaskDetailTtraceById" parameterType="Long"
@@ -379,6 +592,43 @@
             </if>
             <if test="templateType != null">template_type,
             </if>
+            <if test="dimension != null">dimension,
+            </if>
+            <if test="isMydException != null">is_myd_exception,
+            </if>
+            <if test="dutyDeptPersonName != null">duty_dept_person_name,
+            </if>
+            <if test="dutyDeptPersonCode != null">duty_dept_person_code,
+            </if>
+            <if test="reportDeptPersonName != null">report_dept_person_name,
+            </if>
+            <if test="reportDeptPersonCode != null">report_dept_person_code,
+            </if>
+            <if test="circulationDeptPersonCode != null">circulation_dept_person_code,
+            </if>
+            <if test="circulationDeptPersonName != null">circulation_dept_person_name,
+            </if>
+            <if test="circulationDeptCode != null ">
+                circulation_dept_code,
+            </if>
+            <if test="circulationDeptName != null">
+                circulation_dept_name,
+            </if>
+            <if test="circulationExplain != null ">
+                circulation_explain,
+            </if>
+            <if test="circulationTime != null ">
+                circulation_time,
+            </if>
+            <if test="circulationStatus != null ">
+                circulation_status,
+            </if>
+            <if test="circulationPersonName != null  and circulationPersonName != ''">
+                circulation_person_name,
+            </if>
+            <if test="circulationPersonCode != null  and circulationPersonCode != ''">
+                circulation_person_code,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="detailId != null">#{detailId},
@@ -476,6 +726,43 @@
             <if test="type != null">#{type},
             </if>
             <if test="templateType != null">#{templateType},
+            </if>
+            <if test="dimension != null">#{dimension},
+            </if>
+            <if test="isMydException != null">#{isMydException},
+            </if>
+            <if test="dutyDeptPersonName != null">#{dutyDeptPersonName},
+            </if>
+            <if test="dutyDeptPersonCode != null">#{dutyDeptPersonCode},
+            </if>
+            <if test="reportDeptPersonName != null">#{reportDeptPersonName},
+            </if>
+            <if test="reportDeptPersonCode != null">#{reportDeptPersonCode},
+            </if>
+            <if test="circulationDeptPersonCode != null">#{circulationDeptPersonCode},
+            </if>
+            <if test="circulationDeptPersonName != null">#{circulationDeptPersonName},
+            </if>
+            <if test="circulationDeptCode != null">
+                #{circulationDeptCode},
+            </if>
+            <if test="circulationDeptName != null">
+                #{circulationDeptName},
+            </if>
+            <if test="circulationExplain != null">
+                #{circulationExplain},
+            </if>
+            <if test="circulationTime != null ">
+                #{circulationTime},
+            </if>
+            <if test="circulationStatus != null ">
+               #{circulationStatus},
+            </if>
+            <if test="circulationPersonName != null  and circulationPersonName != ''">
+               #{circulationPersonName},
+            </if>
+            <if test="circulationPersonCode != null  and circulationPersonCode != ''">
+              #{circulationPersonCode},
             </if>
         </trim>
     </insert>
@@ -627,6 +914,51 @@
             <if test="templateType != null">template_type =
                 #{templateType},
             </if>
+            <if test="dimension != null">dimension =
+                #{dimension},
+            </if>
+            <if test="isMydException != null">is_myd_exception =
+                #{isMydException},
+            </if>
+            <if test="dutyDeptPersonName != null">duty_dept_person_name =
+                #{dutyDeptPersonName},
+            </if>
+            <if test="dutyDeptPersonCode != null">duty_dept_person_code =
+                #{dutyDeptPersonCode},
+            </if>
+            <if test="reportDeptPersonName != null">report_dept_person_name =
+                #{reportDeptPersonName},
+            </if>
+            <if test="reportDeptPersonCode != null">report_dept_person_code =
+                #{reportDeptPersonCode},
+            </if>
+            <if test="circulationDeptPersonCode != null">circulation_dept_person_code =
+                #{circulationDeptPersonCode},
+            </if>
+            <if test="circulationDeptPersonName != null">circulation_dept_person_name =
+                #{circulationDeptPersonName},
+            </if>
+            <if test="circulationDeptCode != null">circulation_dept_code =
+                #{circulationDeptCode},
+            </if>
+            <if test="circulationDeptName != null">circulation_dept_name =
+                #{circulationDeptName},
+            </if>
+            <if test="circulationExplain != null">circulation_explain =
+                #{circulationExplain},
+            </if>
+            <if test="circulationTime != null">circulation_time =
+                #{circulationTime},
+            </if>
+            <if test="circulationStatus != null ">
+                circulation_status = #{circulationStatus},
+            </if>
+            <if test="circulationPersonName != null  and circulationPersonName != ''">
+                circulation_person_name =#{circulationPersonName},
+            </if>
+            <if test="circulationPersonCode != null  and circulationPersonCode != ''">
+                circulation_person_code =#{circulationPersonCode},
+            </if>
         </trim>
         where id = #{id}
     </update>

--
Gitblit v1.9.3