From e180e3a496d6f29d3a3b34016400de9d997c6bd9 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 07 四月 2026 14:42:23 +0800
Subject: [PATCH] 省立同德满意度功能提交

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |  314 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 220 insertions(+), 94 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 5d06cde..6f1c4e8 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -361,6 +361,41 @@
                 </foreach>
             </if>
         </if>
+        <if test="deptOrDistrict==3">
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                AND (leavehospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+                         separator=","
+                         close=")">
+                    #{leavehospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test=" visitDeptCodes != null and visitDeptCodes.size()>0">
+                and visit_dept_code IN
+                <foreach collection="visitDeptCodes" item="visitDeptCode" open="(" separator=","
+                         close="))">
+                    #{visitDeptCode}
+                </foreach>
+            </if>
+        </if>
+
+        <if test="deptOrDistrict==4">
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                AND (leavehospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+                         separator=","
+                         close=")">
+                    #{leavehospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test=" visitDeptCodes != null and visitDeptCodes.size()>0">
+                OR visit_dept_code IN
+                <foreach collection="visitDeptCodes" item="visitDeptCode" open="(" separator=","
+                         close="))">
+                    #{visitDeptCode}
+                </foreach>
+            </if>
+        </if>
 
         <if test="visitTime != null">
             AND date_format(visit_time,'%y%m%d') = date_format(#{visitTime},'%y%m%d')
@@ -425,13 +460,49 @@
         </if>
         <if test="sort != null  and sort==0">order by endtime asc</if>
         <if test="sort != null  and sort==1">order by endtime desc</if>
-        <if test="sort != null  and sort==2">order by long_send_time asc</if>
-        <if test="sort != null  and sort==3">order by long_send_time desc</if>
+        <if test="sort != null  and sort==2">order by visit_time asc</if>
+        <if test="sort != null  and sort==3">order by visit_time desc</if>
         <if test="sort != null  and sort==5">order by admindate asc</if>
         <if test="sort != null  and sort==6">order by admindate desc</if>
         <if test="sort != null  and sort==7">order by visit_time asc</if>
         <if test="sort != null  and sort==8">order by visit_time desc</if>
+        <if test="sort != null  and sort==9">order by sendname asc</if>
         <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+    </select>
+
+    <select id="selectSatisfactionSubtaskList" parameterType="com.smartor.domain.VO.PatSatisfactionReqVO"
+            resultMap="ServiceSubtaskResult">
+        <include refid="selectServiceSubtaskVo"/>
+        where 1=1
+        and 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 date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
+        </if>
     </select>
     <select id="getCompensateServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
@@ -615,6 +686,12 @@
         </if>
         <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
         <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
+        <if test="visitCount != null and visitCount == 1">
+            AND visit_count = 1
+        </if>
+        <if test="visitCount != null and visitCount > 1">
+            AND visit_count > 1
+        </if>
         <if test="groupKey != null and groupKey != ''">
             AND ${groupKey} IN
             <foreach collection="groupKeyList" item="key" open="(" separator=","
@@ -667,6 +744,7 @@
             resultMap="ServiceSubtaskResult">
         select sendstate,starttime,endtime,nurse_name,phone,sex,task_name,sendname,leavediagname,visit_time FROM
         service_subtask WHERE del_flag=0
+        and service_type != 4
         <if test="leavediagname != null">and leavediagname like concat('%',#{leavediagname}, '%')</if>
         <if test="sendname != null">and sendname like concat('%',#{sendname}, '%')</if>
         <if test="taskName != null">and task_name like concat('%',#{taskName}, '%')</if>
@@ -676,8 +754,8 @@
         <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
         <if test="continueCount != null ">and continue_count = #{continueCount}</if>
         <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
-        GROUP BY sendname,sendstate,starttime,endtime,nurse_name,phone,sex,task_name,leavediagname,visit_time ORDER BY
-        visit_time
+        GROUP BY sendname,sendstate,starttime,endtime,nurse_name,phone,sex,task_name,leavediagname,visit_time
+        ORDER BY sendname,visit_time
         <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
     </select>
 
@@ -1357,6 +1435,12 @@
         <if test="type != null">
             and type = #{type}
         </if>
+        <if test="visitCount != null and visitCount == 1">
+            AND visit_count = 1
+        </if>
+        <if test="visitCount != null and visitCount > 1">
+            AND visit_count > 1
+        </if>
         <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0">
             AND ${groupKey} IN
             <foreach collection="groupKeyList" item="key" open="(" separator=","
@@ -1412,6 +1496,12 @@
         <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
         <if test="type != null">
             and type = #{type}
+        </if>
+        <if test="visitCount != null and visitCount == 1">
+            AND visit_count = 1
+        </if>
+        <if test="visitCount != null and visitCount > 1">
+            AND visit_count > 1
         </if>
         <if test="groupKey != null and groupKey != ''">
             group by ${groupKey}
@@ -1855,10 +1945,13 @@
 
     <select id="getDeptRanking" parameterType="com.smartor.domain.PatMedReq" resultType="com.smartor.domain.PatMedRes">
         SELECT deptname,
-               count(1) AS rc
+        count(1) AS rc
         FROM service_subtask
         WHERE DATE_FORMAT(finishtime, '%Y-%m-%d') >= #{startDate}
-          AND DATE_FORMAT(finishtime, '%Y-%m-%d') &lt;= #{endDate}
+        AND DATE_FORMAT(finishtime, '%Y-%m-%d') &lt;= #{endDate}
+        <if test="orgid != null">
+            AND orgid = #{orgid}
+        </if>
         GROUP BY deptname
     </select>
 
@@ -1927,25 +2020,6 @@
             </foreach>
         </if>
 
-        <!--        GROUP BY-->
-        <!--        <choose>-->
-        <!--            <when test="timeType == 'day'">-->
-        <!--                DATE_FORMAT(visit_time, '%Y-%m-%d')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'month'">-->
-        <!--                DATE_FORMAT(visit_time, '%Y-%m')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'year'">-->
-        <!--                DATE_FORMAT(visit_time, '%Y')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'week'">-->
-        <!--                CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0'))-->
-        <!--            </when>-->
-        <!--            <otherwise>-->
-        <!--                DATE_FORMAT(visit_time, '%Y-%m-%d')-->
-        <!--            </otherwise>-->
-        <!--        </choose>-->
-
         UNION ALL
 
         -- 鍑洪櫌浜烘鏁版嵁
@@ -1997,85 +2071,48 @@
             </foreach>
         </if>
 
-        <!--        GROUP BY-->
+        <!--        UNION ALL-->
+
+        <!--        &#45;&#45; 闂ㄨ瘖浜烘鏁版嵁-->
+        <!--        SELECT-->
         <!--        <choose>-->
         <!--            <when test="timeType == 'day'">-->
-        <!--                DATE_FORMAT(endtime, '%Y-%m-%d')-->
+        <!--                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,-->
         <!--            </when>-->
         <!--            <when test="timeType == 'month'">-->
-        <!--                DATE_FORMAT(endtime, '%Y-%m')-->
+        <!--                DATE_FORMAT(admitdate, '%Y-%m') AS timePeriod,-->
         <!--            </when>-->
         <!--            <when test="timeType == 'year'">-->
-        <!--                DATE_FORMAT(endtime, '%Y')-->
+        <!--                DATE_FORMAT(admitdate, '%Y') AS timePeriod,-->
         <!--            </when>-->
         <!--            <when test="timeType == 'week'">-->
-        <!--                CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0'))-->
+        <!--                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod,-->
         <!--            </when>-->
         <!--            <otherwise>-->
-        <!--                DATE_FORMAT(endtime, '%Y-%m-%d')-->
+        <!--                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,-->
         <!--            </otherwise>-->
         <!--        </choose>-->
+        <!--        0 AS dischargeFollowCount,-->
+        <!--        0 AS outpatientFollowCount,-->
+        <!--        0 AS pmiCount,-->
+        <!--        1 AS pmoCount-->
+        <!--        FROM pat_med_outhosp-->
+        <!--        WHERE del_flag = '0'-->
+        <!--        <if test="startDate != null and endDate != null">-->
+        <!--            AND admitdate >= #{startDate}-->
+        <!--            AND admitdate &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)-->
+        <!--        </if>-->
+        <!--        <if test="orgid != null">-->
+        <!--            AND orgid = #{orgid}-->
+        <!--        </if>-->
 
-        UNION ALL
+        <!--        <if test="deptcodes != null and deptcodes.size() > 0">-->
+        <!--            AND deptcode IN-->
+        <!--            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">-->
+        <!--                #{deptcode}-->
+        <!--            </foreach>-->
+        <!--        </if>-->
 
-        -- 闂ㄨ瘖浜烘鏁版嵁
-        SELECT
-        <choose>
-            <when test="timeType == 'day'">
-                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,
-            </when>
-            <when test="timeType == 'month'">
-                DATE_FORMAT(admitdate, '%Y-%m') AS timePeriod,
-            </when>
-            <when test="timeType == 'year'">
-                DATE_FORMAT(admitdate, '%Y') AS timePeriod,
-            </when>
-            <when test="timeType == 'week'">
-                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod,
-            </when>
-            <otherwise>
-                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,
-            </otherwise>
-        </choose>
-        0 AS dischargeFollowCount,
-        0 AS outpatientFollowCount,
-        0 AS pmiCount,
-        1 AS pmoCount
-        FROM pat_med_outhosp
-        WHERE del_flag = '0'
-        <if test="startDate != null and endDate != null">
-            AND admitdate >= #{startDate}
-            AND admitdate &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
-        </if>
-        <if test="orgid != null">
-            AND orgid = #{orgid}
-        </if>
-
-        <if test="deptcodes != null and deptcodes.size() > 0">
-            AND deptcode IN
-            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
-                #{deptcode}
-            </foreach>
-        </if>
-
-        <!--        GROUP BY-->
-        <!--        <choose>-->
-        <!--            <when test="timeType == 'day'">-->
-        <!--                DATE_FORMAT(admitdate, '%Y-%m-%d')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'month'">-->
-        <!--                DATE_FORMAT(admitdate, '%Y-%m')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'year'">-->
-        <!--                DATE_FORMAT(admitdate, '%Y')-->
-        <!--            </when>-->
-        <!--            <when test="timeType == 'week'">-->
-        <!--                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0'))-->
-        <!--            </when>-->
-        <!--            <otherwise>-->
-        <!--                DATE_FORMAT(admitdate, '%Y-%m-%d')-->
-        <!--            </otherwise>-->
-        <!--        </choose>-->
         ) AS combined_data
         GROUP BY timePeriod
         ORDER BY timePeriod DESC
@@ -2134,6 +2171,14 @@
                     #{leaveldeptcode}
                 </foreach>
             </if>
+        </if>
+        <if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0">
+            AND visit_dept_code IN
+            <foreach collection="visitDeptCodes" item="visitDeptCodes" open="("
+                     separator=","
+                     close=")">
+                #{visitDeptCodes}
+            </foreach>
         </if>
         <if test="leavehospitaldistrictname != null and leavehospitaldistrictname != ''">
             AND leavehospitaldistrictname = #{leavehospitaldistrictname}
@@ -2249,6 +2294,9 @@
         <if test="excep != null ">
             AND excep = #{excep}
         </if>
+        <if test="taskName != null  and taskName != ''">
+            AND task_name like concat('%', #{taskName}, '%')
+        </if>
         <if test="visitCount != null and visitCount == 1">
             AND visit_count = 1
         </if>
@@ -2257,12 +2305,42 @@
         </if>
     </select>
 
-    <select id="getCurrentUserServiceSubtaskCount" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" resultType="map">
+
+    <select id="selectVisitCount" parameterType="com.smartor.domain.PatMedReq"
+            resultType="com.smartor.domain.PatMedRes">
+        select
+        0 AS rc,
+        count(1) AS rs
+        FROM
+        service_subtask
+        where 1=1
+        and del_flag = 0
+        and service_type=3
+        <if test="orgid != null">
+            and orgid = #{orgid}
+        </if>
+        <if test="startDate != null">
+            AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
+        </if>
+        <if test="endDate != null">
+            AND date_format( visit_time, '%y%m%d' ) &lt;= 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>
+    </select>
+
+    <select id="getCurrentUserServiceSubtaskCount" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
+            resultType="map">
         SELECT
-        COUNT(CASE WHEN sendstate IN (1, 2) AND date_format(visit_time,'%y%m%d') &lt;= date_format(CURDATE(),'%y%m%d') THEN 1 END) AS pendingVisitCount,
+        COUNT(CASE WHEN sendstate = 2 AND date_format(visit_time,'%y%m%d') &lt;= date_format(CURDATE(),'%y%m%d') THEN 1
+        END) AS pendingVisitCount,
         COUNT(CASE WHEN sendstate = 5 THEN 1 END) AS failedVisitCount,
-        COUNT(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS abnormalVisitCount,
-        COUNT(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS warnningVisitCount,
+        SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS abnormalVisitCount,
+        SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS warnningVisitCount,
         COUNT(*) AS allVisitCount
         FROM service_subtask
         WHERE del_flag = '0'
@@ -2288,4 +2366,52 @@
         </if>
     </select>
 
+    <select id="querySendCount" parameterType="com.smartor.domain.entity.ServiceSubtaskSatisfactionEntity"
+            resultType="Long">
+        select distinct id 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 = #{type}</if>
+        <if test="startTime != null">
+            AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
+        </if>
+        <if test="endTime != null">
+            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
+        </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>
+    </select>
+
 </mapper>

--
Gitblit v1.9.3