From 26d1f59f0266672398975ba0337bb3d8267c2d95 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 12 十月 2026 15:36:52 +0800
Subject: [PATCH] 满意度扫码BUG修改

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |  335 ++++++-------------------------------------------------
 1 files changed, 41 insertions(+), 294 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 0c32669..a8e5304 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -98,6 +98,7 @@
         <result property="scheduleDetailId" column="schedule_detail_id"/>
         <result property="scheduleSeq" column="schedule_seq"/>
         <result property="loopCount" column="loop_count"/>
+        <result property="isManuallyCalled" column="is_manually_called"/>
         <result property="campusid" column="campusid"/>
     </resultMap>
 
@@ -245,7 +246,8 @@
                schedule_detail_id,
                schedule_seq,
                loop_count,
-               task_situation
+               task_situation,
+               is_manually_called
         from service_subtask
     </sql>
 
@@ -288,7 +290,6 @@
         <if test="continueCount != null ">and continue_count = #{continueCount}</if>
         <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
     </select>
-
 
     <select id="selectServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
@@ -513,6 +514,7 @@
         <if test="createBy != null">and create_by = #{createBy}</if>
         <if test="taskGuid != null">and task_guid = #{taskGuid}</if>
         <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
+        <if test="isManuallyCalled != null">and is_manually_called = #{isManuallyCalled}</if>
         <if test="isVisitAgain != null">and is_visit_again = #{isVisitAgain}</if>
         <if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0">
             AND visit_dept_code IN
@@ -534,41 +536,7 @@
         <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"
+            <select id="getCompensateServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where del_flag = 0
@@ -629,7 +597,6 @@
         <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
 
     </select>
-
 
     <select id="selectServiceSubtaskListAgain" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
@@ -735,6 +702,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="startOutHospTime != null">
+            AND date_format(endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
+        </if>
+        <if test="endOutHospTime != null">
+            AND date_format(endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
+        </if>
         ) a
     </select>
 
@@ -767,6 +740,7 @@
         </if>
         WHERE ss.del_flag = 0
         AND ss.visit_time IS NOT NULL
+        AND ss.sendstate != 4
         <if test="starttime == null and endtime==null">
             AND DATE(ss.visit_time) &lt; DATE(NOW())
         </if>
@@ -800,6 +774,12 @@
                 #{serviceType}
             </foreach>
         </if>
+        <if test="startOutHospTime != null">
+            AND date_format(ss.endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
+        </if>
+        <if test="endOutHospTime != null">
+            AND date_format(ss.endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
+        </if>
         <if test="groupKey != null and groupKey != ''">
             AND ss.${groupKey} IN
             <foreach collection="groupKeyList" item="key" open="(" separator=","
@@ -809,7 +789,6 @@
             GROUP BY ss.${groupKey}
         </if>
     </select>
-
 
     <select id="selectTimelyRateDetail" parameterType="com.smartor.domain.ServiceSubtask"
             resultMap="ServiceSubtaskResult">
@@ -976,6 +955,7 @@
             <if test="scheduleDetailId != null ">schedule_detail_id,</if>
             <if test="scheduleSeq != null ">schedule_seq,</if>
             <if test="loopCount != null ">loop_count,</if>
+            <if test="isManuallyCalled != null ">is_manually_called,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="sendname != null">#{sendname},</if>
@@ -1073,6 +1053,7 @@
             <if test="scheduleDetailId != null ">#{scheduleDetailId},</if>
             <if test="scheduleSeq != null ">#{scheduleSeq},</if>
             <if test="loopCount != null ">#{loopCount},</if>
+            <if test="isManuallyCalled != null ">#{isManuallyCalled},</if>
         </trim>
     </insert>
 
@@ -1175,6 +1156,7 @@
             <if test="scheduleDetailId != null ">schedule_detail_id = #{scheduleDetailId},</if>
             <if test="scheduleSeq != null ">schedule_seq = #{scheduleSeq},</if>
             <if test="loopCount != null ">loop_count = #{loopCount},</if>
+            <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
         </trim>
         where id = #{id}
     </update>
@@ -1273,9 +1255,11 @@
             <if test="continueCount != null ">continue_count = #{continueCount},</if>
             <if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
             <if test="continueContent != null ">continue_content = #{continueContent},</if>
+            <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
         </trim>
         where 1=1
         <if test="patid != null ">and patid = #{patid}</if>
+        <if test="id != null ">and id = #{id}</if>
         <if test="taskid != null ">and taskid = #{taskid}</if>
         <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
         <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
@@ -1375,6 +1359,7 @@
             <if test="continueCount != null ">continue_count = #{continueCount},</if>
             <if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
             <if test="continueContent != null ">continue_content = #{continueContent},</if>
+            <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
         </trim>
         <where>
             <if test="patid != null ">
@@ -1385,6 +1370,9 @@
             </if>
             <if test="id != null ">
                 and id = #{id}
+            </if>
+            <if test="inhospid != null ">
+                and inhospid = #{inhospid}
             </if>
         </where>
     </update>
@@ -1482,10 +1470,10 @@
             <if test="continueCount != null ">continue_count = #{continueCount},</if>
             <if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
             <if test="continueContent != null ">continue_content = #{continueContent},</if>
+            <if test="isManuallyCalled != null ">is_manually_called = #{isManuallyCalled},</if>
         </trim>
         where task_guid = #{taskGuid} and task_name = #{taskName}
     </update>
-
 
     <update id="deleteServiceSubtaskById" parameterType="Long">
         update service_subtask
@@ -2572,6 +2560,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,
@@ -2584,6 +2574,12 @@
         </if>
         <if test="phone != null and phone != ''">
             AND phone = #{phone}
+        </if>
+        <if test="finishtimeStart != null">
+            AND date_format(finishtime,'%y%m%d') &gt;= date_format(#{finishtimeStart},'%y%m%d')
+        </if>
+        <if test="finishtimeEnd != null">
+            AND date_format(finishtime,'%y%m%d') &lt;= date_format(#{finishtimeEnd},'%y%m%d')
         </if>
         <if test="deptOrDistrict==1">
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
@@ -2760,7 +2756,6 @@
         </if>
     </select>
 
-
     <select id="selectVisitCount" parameterType="com.smartor.domain.PatMedReq"
             resultType="com.smartor.domain.PatMedRes">
         select
@@ -2827,55 +2822,7 @@
         </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>
-
-    <!--
+            <!--
         鎸夌梾鍖烘垨绉戝鍒嗙粍缁熻 continue_flag 鏁伴噺
         浼犱簡 leavehospitaldistrictcodes 鈫� 鎸夌梾鍖虹淮搴�
         浼犱簡 deptcodes              鈫� 鎸夌瀹ょ淮搴�
@@ -3007,7 +2954,7 @@
           and sendstate in (1, 2, 3)
     </select>
 
-    <!-- 浠诲姟缁勶紙appltype=5锛夋粴鍔ㄨ皟搴︾敤锛氭媺鏈疆鍏ㄩ噺 subtask锛屼綔涓轰笅涓�杞殑鍏嬮殕妯℃澘 -->
+                <!-- 浠诲姟缁勶紙appltype=5锛夋粴鍔ㄨ皟搴︾敤锛氭媺鏈疆鍏ㄩ噺 subtask锛屼綔涓轰笅涓�杞殑鍏嬮殕妯℃澘 -->
     <select id="selectByScheduleIdAndLoop" resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where schedule_id = #{scheduleId}
@@ -3098,208 +3045,7 @@
         </if>
     </select>
 
-    <select id="statQuestionOption" resultType="com.smartor.domain.ServiceSubtaskDetailRatioExport">
-        SELECT
-        d.questiontext AS questiontext,
-        t.taskid AS taskid,
-        t.task_name AS taskName,
-        d.asrtext AS optionresult,
-        d.score AS score,
-        d.targetvalue AS targetvalue,
-        d.value_type AS valueType,
-        COUNT(*) AS count,
-        CONCAT(ROUND(COUNT(*) * 100.0 / t2.total_count, 2), '%') AS ratio
-        FROM
-        service_task t
-        INNER JOIN service_subtask s ON s.taskid = t.taskid
-        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
-        INNER JOIN (
-        SELECT
-        t.taskid,
-        d.questiontext,
-        COUNT(*) AS total_count
-        FROM
-        service_task t
-        INNER JOIN service_subtask s ON s.taskid = t.taskid
-        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
-        WHERE 1=1
-        <if test="taskIds != null and taskIds.size() > 0">
-            AND t.taskid IN
-            <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
-                #{taskId}
-            </foreach>
-        </if>
-        <if test="valueType != null">AND d.value_type = #{valueType}</if>
-        <if test="scoreStart != null">AND d.score &gt;= #{scoreStart}</if>
-        <if test="scoreEnd != null">AND d.score &lt;= #{scoreEnd}</if>
-        <if test="questiontext != null  and questiontext != ''">and d.questiontext like concat('%', #{questiontext},
-            '%')
-        </if>
-        and s.sendstate=6
-        and d.del_flag=0
-        GROUP BY
-        t.taskid,
-        d.questiontext
-        ) t2 ON t2.taskid = t.taskid AND t2.questiontext = d.questiontext
-        WHERE 1=1
-        <if test="taskIds != null and taskIds.size() > 0">
-            AND t.taskid IN
-            <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
-                #{taskId}
-            </foreach>
-        </if>
-        <if test="valueType != null">AND d.value_type = #{valueType}</if>
-        <if test="scoreStart != null">AND d.score &gt;= #{scoreStart}</if>
-        <if test="scoreEnd != null">AND d.score &lt;= #{scoreEnd}</if>
-        <if test="questiontext != null  and questiontext != ''">and d.questiontext like concat('%', #{questiontext},
-            '%')
-        </if>
-        AND s.sendstate = 6
-        and d.del_flag=0
-        <if test="startOutHospTime != null">
-            AND date_format(s.endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
-        </if>
-        <if test="endOutHospTime != null">
-            AND date_format(s.endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
-        </if>
-        GROUP BY
-        t.taskid,
-        d.questiontext,
-        d.score,
-        d.targetvalue,
-        d.asrtext,
-        d.value_type
-        ORDER BY
-        d.questiontext,
-        t.taskid
-    </select>
-
-    <!-- 鏂版柟娉曪細鏍规嵁瀛愪换鍔� ID 缁熻闂閫夐」鐧惧垎姣� (鐢ㄤ簬婊℃剰搴︾粺璁� serviceType=6) -->
-    <select id="statQuestionOptionBySubtaskIds" resultType="com.smartor.domain.ServiceSubtaskDetailRatioExport">
-        SELECT
-        d.questiontext AS questiontext,
-        t.taskid AS taskid,
-        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,
-        d.targetvalue AS targetvalue,
-        d.value_type AS valueType,
-        COUNT(*) AS count,
-        CONCAT(ROUND(COUNT(*) * 100.0 / t2.total_count, 2), '%') AS ratio
-        FROM
-        service_task t
-        INNER JOIN service_subtask s ON s.taskid = t.taskid
-        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
-        INNER JOIN (
-        SELECT
-        d.questiontext,
-        COUNT(*) AS total_count
-        FROM
-        service_task t
-        INNER JOIN service_subtask s ON s.taskid = t.taskid
-        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
-        WHERE 1=1
-        <if test="subtaskIds != null and subtaskIds.size() > 0">
-            AND s.id IN
-            <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
-                #{subtaskId}
-            </foreach>
-        </if>
-        <if test="valueType != null">AND d.value_type &gt;= #{valueType}</if>
-        <if test="scoreStart != null">AND d.score = #{scoreStart}</if>
-        <if test="scoreEnd != null">AND d.score &lt;= #{scoreEnd}</if>
-        <if test="questiontext != null  and questiontext != ''">and d.questiontext like concat('%', #{questiontext},
-            '%')
-        </if>
-        AND s.sendstate = 6
-        AND d.del_flag=0
-        GROUP BY d.questiontext
-        ) t2 ON t2.questiontext = d.questiontext
-        WHERE 1=1
-        <if test="subtaskIds != null and subtaskIds.size() > 0">
-            AND s.id IN
-            <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")">
-                #{subtaskId}
-            </foreach>
-        </if>
-        AND s.sendstate = 6
-        AND d.del_flag=0
-        <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>
-        <if test="questiontext != null  and questiontext != ''">and d.questiontext like concat('%', #{questiontext},
-            '%')
-        </if>
-        <if test="startOutHospTime != null">
-            AND date_format(s.endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
-        </if>
-        <if test="endOutHospTime != null">
-            AND date_format(s.endtime,'%y%m%d') &lt;= date_format(#{endOutHospTime},'%y%m%d')
-        </if>
-        GROUP BY
-        t.taskid,
-        d.questiontext,
-        d.score,
-        d.targetvalue,
-        d.asrtext
-        ORDER BY
-        d.questiontext,
-        t.taskid
-    </select>
-
-    <select id="statQuestionOptionByKsOrBq" resultType="com.smartor.domain.DTO.QuestionCountKsOrBqDTO"
-            parameterType="com.smartor.domain.VO.QuestionCountKsOrBqVO">
-        SELECT questiontext,
-        d.taskid,
-        s.deptname,
-        d.create_time as createTime,
-        s.leavehospitaldistrictname,
-        d.targetvalue,
-        d.asrtext,
-        COUNT(d.asrtext) AS answercount,
-        d.score AS singleScore
-        FROM service_subtask_detail d,
-        service_task s
-        WHERE d.taskid = s.taskid
-        AND deptname IS NOT NULL
-        AND leavehospitaldistrictname IS NOT NULL
-        <if test="endFinishTime != null">
-            AND d.create_time &lt; #{endFinishTime}
-        </if>
-        <if test="startFinishTime != null">
-            AND  d.create_time &gt;= #{startFinishTime}
-        </if>
-        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-            AND leavehospitaldistrictcode IN
-            <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
-                     separator=","
-                     close=")">
-                #{leavehospitaldistrictcode}
-            </foreach>
-        </if>
-        <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
-            AND deptcode IN
-            <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
-                     close=")">
-                #{leaveldeptcode}
-            </foreach>
-        </if>
-        GROUP BY d.questiontext,
-        d.taskid,
-        d.score,
-        s.deptname,
-        d.targetvalue,
-        d.create_time,
-        s.leavehospitaldistrictname,
-        d.asrtext
-        ORDER BY d.taskid
-    </select>
-
-    <select id="selectServiceSubtaskListDeadLine" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
+                    <select id="selectServiceSubtaskListDeadLine" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where 1=1
@@ -3308,5 +3054,6 @@
         and endtime
     </select>
 
-</mapper>
+    <!-- 闂ㄨ瘖婊℃剰搴︾患鍚堝緱鍒嗘帓鍚嶏紙鎸夌瀹ゆ垨鐥呭尯锛� -->
+    </mapper>
 

--
Gitblit v1.9.3