From a890fa7ef468579c800fccb943a6ff45c029f842 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 22 九月 2026 09:58:52 +0800
Subject: [PATCH] 【丽水】随访增加是否打过人工电话标识

---
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml |  931 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 688 insertions(+), 243 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 4db0375..e56443a 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>
 
@@ -213,7 +214,6 @@
                create_time,
                isupload,
                upload_time,
-               orgid,
                pid,
                guid,
                text_param,
@@ -236,8 +236,6 @@
                leaveicd10code,
                orgid,
                visit_type,
-               management_doctor,
-               management_doctor_code,
                continue_flag,
                continue_time_now,
                continue_content,
@@ -248,7 +246,8 @@
                schedule_detail_id,
                schedule_seq,
                loop_count,
-               task_situation
+               task_situation,
+               is_manually_called
         from service_subtask
     </sql>
 
@@ -257,9 +256,8 @@
         <include refid="selectServiceSubtaskVo"/>
         where 1=1
         and del_flag = 0
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="taskid != null ">and taskid = #{taskid}</if>
         <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
         <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -281,37 +279,11 @@
         <include refid="selectServiceSubtaskVo"/>
         where 1=1
         and del_flag = 0
-        and sendstate != 5
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
-        <if test="subId != null">
-            AND id = #{subId}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
+        <if test="subId != null">and id = #{subId}</if>
         <if test="taskid != null ">and taskid = #{taskid}</if>
-        <if test="visitTime != null">
-            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{visitTime},'%y%m%d')
-        </if>
-        <if test="sendstate != null ">and sendstate = #{sendstate}</if>
-        <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
-        <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>
-        UNION ALL
-        <include refid="selectServiceSubtaskVo"/>
-        where 1=1
-        and del_flag = 0
-        and sendstate = 5
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
-        <if test="subId != null">
-            AND id = #{subId}
-        </if>
-        <if test="taskid != null ">and taskid = #{taskid}</if>
-        <if test="visitTime != null">
-            AND date_format(visit_time,'%y%m%d') &lt;= date_format(DATE_ADD(#{visitTime}, INTERVAL 1 DAY),'%y%m%d')
-        </if>
+        <if test="visitTime != null">and date_format(visit_time,'%y%m%d') &lt;= date_format(#{visitTime},'%y%m%d')</if>
         <if test="sendstate != null ">and sendstate = #{sendstate}</if>
         <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
         <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -379,6 +351,18 @@
                 #{itemTaskId}
             </foreach>
         </if>
+        <if test="operationItemIds != null and operationItemIds.size() > 0">
+            AND operation_item_id IN
+            <foreach collection="operationItemIds" item="operationItemIdItem" open="(" separator="," close=")">
+                #{operationItemIdItem}
+            </foreach>
+        </if>
+        <if test="inhospids != null and inhospids.size() > 0">
+            AND inhospid IN
+            <foreach collection="inhospids" item="inhospidItem" open="(" separator="," close=")">
+                #{inhospidItem}
+            </foreach>
+        </if>
         <if test="templateid != null  and templateid != ''">and templateid = #{templateid}</if>
         <if test="templatename != null  and templatename != ''">and templatename like concat('%', #{templatename},
             '%')
@@ -394,6 +378,12 @@
         </if>
         <if test="endSendDateTime != null">
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endSendDateTime},'%y%m%d')
+        </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="longSendTime != null">
             AND date_format(long_send_time,'%y%m%d') &lt;= date_format(#{longSendTime},'%y%m%d')
@@ -417,7 +407,7 @@
         </if>
         <if test="deptOrDistrict==2">
             AND (1=1
-            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            <if test="leavehospitaldistrictcodes != null">
                 AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
                          separator=","
@@ -425,7 +415,7 @@
                     #{leavehospitaldistrictcode}
                 </foreach>
             </if>
-            <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+            <if test=" leaveldeptcodes != null">
                 OR deptcode IN
                 <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
                          close=")">
@@ -504,6 +494,7 @@
         <if test="libtemplatename != null ">and libtemplatename = #{libtemplatename}</if>
         <if test="openid != null ">and openid = #{openid}</if>
         <if test="sendstate != null ">and sendstate = #{sendstate}</if>
+        <if test="operationItemId != null ">and operation_item_id = #{operationItemId}</if>
         <if test="drname != null  and drname != ''">and drname like concat('%', #{drname}, '%')</if>
         <if test="taskName != null  and taskName != ''">and task_name like concat('%', #{taskName}, '%')</if>
         <if test="drcode != null and drcode != ''">and (drcode = #{drcode}</if>
@@ -524,13 +515,14 @@
         <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
-            <foreach collection="visitDeptCodes" item="visitDeptCodes" open="("
+            <foreach collection="visitDeptCodes" item="visitDeptCode" open="("
                      separator=","
                      close=")">
-                #{visitDeptCodes}
+                #{visitDeptCode}
             </foreach>
         </if>
         <if test="sort != null  and sort==0">order by endtime asc</if>
@@ -584,15 +576,10 @@
         <include refid="selectServiceSubtaskVo"/>
         where del_flag = 0
         and sendstate != 5
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
-        <if test="visitTime != null">
-            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{visitTime},'%y%m%d')
-        </if>
-        <if test="subId != null">
-            AND id = #{subId}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
+        <if test="visitTime != null">and date_format(visit_time,'%y%m%d') &lt;= date_format(#{visitTime},'%y%m%d') </if>
+        <if test="subId != null">and id = #{subId} </if>
         <if test="sendstate != null ">and sendstate = #{sendstate}</if>
         <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
         <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
@@ -602,9 +589,8 @@
         <include refid="selectServiceSubtaskVo"/>
         where del_flag = 0
         and sendstate = 5
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="visitTime != null">
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(DATE_ADD(#{visitTime}, INTERVAL 1 DAY),'%y%m%d')
         </if>
@@ -622,9 +608,8 @@
             resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where del_flag = 0
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="createStartTime != null  and createEndTime != null">and create_time BETWEEN #{createStartTime} AND
             #{createEndTime}
         </if>
@@ -671,7 +656,8 @@
         <if test="labelstatus != null ">and labelstatus = #{labelstatus}</if>
         <if test="isupload != null ">and isupload = #{isupload}</if>
         <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
-        <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="pid != null ">and pid = #{pid}</if>
         <if test="preachform != null ">and preachform = #{preachform}</if>
         <if test="guid != null  and guid != ''">and guid = #{guid}</if>
@@ -719,9 +705,8 @@
             DATE_FORMAT(b.create_time, '%Y-%m-%d') LIKE CONCAT(#{createTimeNew}, '%')
         </if>
         <if test="sendstate != null ">and b.sendstate = #{sendstate}</if>
-        <if test="orgid != null and orgid != ''">
-            and b.orgid = #{orgid}
-        </if>
+        <if test="orgid != null and orgid != ''">and b.orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if>
     </select>
 
     <select id="selectTimelyRate" parameterType="com.smartor.domain.ServiceSubtask" resultType="double">
@@ -738,7 +723,8 @@
             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>
-        <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if>
         <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if>
         <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
@@ -760,7 +746,8 @@
         <if test="groupKey != null and groupKey != ''">
             ss.${groupKey} as groupKey,
         </if>
-        SUM(CASE WHEN ss.finishtime IS NOT NULL AND DATE(ss.visit_time) &lt;= DATE(ss.finishtime) THEN 1 ELSE 0 END) / COUNT(*) AS finishRate,
+        SUM(CASE WHEN ss.finishtime IS NOT NULL AND DATE(ss.visit_time) &lt;= DATE(ss.finishtime) THEN 1 ELSE 0 END) /
+        COUNT(*) AS finishRate,
         <if test="rateDay != null">
             SUM(CASE WHEN ss.finishtime IS NOT NULL
             AND DATEDIFF(ss.finishtime, ss.endtime) &lt;= #{rateDay} + COALESCE(cp.compensate_days, 0)
@@ -791,6 +778,7 @@
             AND ss.visit_time &lt; DATE_ADD(#{endtime}, INTERVAL 1 DAY)
         </if>
         <if test="orgid != null and orgid != ''">AND ss.orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and ss.campusid = #{campusid}</if>
         <if test="deptcode != null  and deptcode != ''">and ss.deptcode = #{deptcode}</if>
         <if test="deptname != null  and deptname != ''">and ss.deptname = #{deptname}</if>
         <if test="isabnormal != null">and ss.isabnormal = #{isabnormal}</if>
@@ -844,6 +832,7 @@
             AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endtime},'%y%m%d')
         </if>
         <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if>
         <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if>
         <if test="isabnormal != null ">and isabnormal = #{isabnormal}</if>
@@ -874,7 +863,8 @@
         <if test="sendname != null">and sendname like concat('%',#{sendname}, '%')</if>
         <if test="taskName != null">and task_name like concat('%',#{taskName}, '%')</if>
         <if test="sendstate != null">and sendstate = #{sendstate}</if>
-        <if test="orgid != null">and orgid =#{orgid}</if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid} </if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
         <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
         <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
         <if test="continueCount != null ">and continue_count = #{continueCount}</if>
@@ -920,7 +910,8 @@
             <if test="createTime != null">create_time,</if>
             <if test="isupload != null">isupload,</if>
             <if test="uploadTime != null">upload_time,</if>
-            <if test="orgid != null">orgid,</if>
+            <if test="orgid != null and orgid != ''">orgid,</if>
+            <if test="campusid != null and campusid != ''">campusid,</if>
             <if test="pid != null">pid,</if>
             <if test="guid != null">guid,</if>
             <if test="textParam != null">text_param,</if>
@@ -984,11 +975,11 @@
             <if test="continueTimeNext != null ">continue_time_next,</if>
             <if test="continueContent != null ">continue_content,</if>
             <if test="operationItemId != null ">operation_item_id,</if>
-            <if test="campusid != null">campusid,</if>
             <if test="scheduleId != null ">schedule_id,</if>
             <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>
@@ -1017,7 +1008,8 @@
             <if test="createTime != null">#{createTime},</if>
             <if test="isupload != null">#{isupload},</if>
             <if test="uploadTime != null">#{uploadTime},</if>
-            <if test="orgid != null">#{orgid},</if>
+            <if test="orgid != null and orgid != ''">#{orgid},</if>
+            <if test="campusid != null and campusid != ''">#{campusid},</if>
             <if test="pid != null">#{pid},</if>
             <if test="guid != null">#{guid},</if>
             <if test="textParam != null">#{textParam},</if>
@@ -1081,11 +1073,11 @@
             <if test="continueTimeNext != null ">#{continueTimeNext,jdbcType=TIMESTAMP},</if>
             <if test="continueContent != null ">#{continueContent},</if>
             <if test="operationItemId != null ">#{operationItemId},</if>
-            <if test="campusid != null">#{campusid},</if>
             <if test="scheduleId != null ">#{scheduleId},</if>
             <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>
 
@@ -1119,7 +1111,8 @@
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
-            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+            <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
             <if test="pid != null">pid = #{pid},</if>
             <if test="guid != null">guid = #{guid},</if>
             <if test="textParam != null">text_param = #{textParam},</if>
@@ -1183,11 +1176,11 @@
             <if test="continueTimeNext != null ">continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP},</if>
             <if test="continueContent != null ">continue_content = #{continueContent},</if>
             <if test="operationItemId != null ">operation_item_id = #{operationItemId},</if>
-            <if test="campusid != null">campusid=#{campusid},</if>
             <if test="scheduleId != null ">schedule_id = #{scheduleId},</if>
             <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>
@@ -1222,7 +1215,8 @@
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
-            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+            <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
             <if test="pid != null">pid = #{pid},</if>
             <if test="guid != null">guid = #{guid},</if>
             <if test="textParam != null">text_param = #{textParam},</if>
@@ -1285,13 +1279,13 @@
             <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="taskid != null ">and taskid = #{taskid}</if>
-        <if test="orgid != null and orgid != ''">
-            and orgid = #{orgid}
-        </if>
+        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
     </update>
 
     <update id="updateServiceSubtaskByCondition" parameterType="com.smartor.domain.ServiceSubtask">
@@ -1325,7 +1319,8 @@
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
-            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+            <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
             <if test="pid != null">pid = #{pid},</if>
             <if test="guid != null">guid = #{guid},</if>
             <if test="visitCount != null">visit_count = #{visitCount},</if>
@@ -1387,17 +1382,22 @@
             <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 ">
-            patid = #{patid}
-        </if>
-        <if test="taskid != null ">
-            and taskid = #{taskid}
-        </if>
-        <if test="id != null ">
-            and id = #{id}
-        </if>
+        <where>
+            <if test="patid != null ">
+                patid = #{patid}
+            </if>
+            <if test="taskid != null ">
+                and taskid = #{taskid}
+            </if>
+            <if test="id != null ">
+                and id = #{id}
+            </if>
+            <if test="inhospid != null ">
+                and inhospid = #{inhospid}
+            </if>
+        </where>
     </update>
 
     <update id="updateServiceSubtaskByTaskGuid" parameterType="com.smartor.domain.ServiceSubtask">
@@ -1430,7 +1430,8 @@
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
-            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="orgid != null and orgid != ''">orgid = #{orgid},</if>
+            <if test="campusid != null and campusid != ''">campusid = #{campusid},</if>
             <if test="pid != null">pid = #{pid},</if>
             <if test="guid != null">guid = #{guid},</if>
             <if test="textParam != null">text_param = #{textParam},</if>
@@ -1492,6 +1493,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 task_guid = #{taskGuid} and task_name = #{taskName}
     </update>
@@ -1560,6 +1562,9 @@
         and 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="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
@@ -1649,12 +1654,9 @@
         and a.del_flag = '0'
         and b.del_flag = '0'
         and a.appltype = '3'
-        <if test="orgid != null and orgid != ''">
-            and a.orgid = #{orgid}
-        </if>
-        <if test="taskId != null">
-            and a.task_id = #{taskId}
-        </if>
+        <if test="orgid != null and orgid != ''">and a.orgid = #{orgid}</if>
+        <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if>
+        <if test="taskId != null">and a.task_id = #{taskId}</if>
         <if test="taskName != null and taskName != ''">
             and a.task_name like concat('%', #{taskName}, '%')
         </if>
@@ -1744,6 +1746,9 @@
         <if test="orgid != null and orgid != ''">
             and orgid = #{orgid}
         </if>
+        <if test="campusid != null and campusid != ''">
+            and campusid = #{campusid}
+        </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
@@ -1800,131 +1805,135 @@
 
     <select id="getSfStatisticsHyperlink" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultMap="ServiceSubtaskResult">
-            select id,
-            visit_count,
-            is_visit_again,
-            type,
-            orgid,
-            drcode,
-            drname,
-            leavehospitaldistrictcode,
-            leavehospitaldistrictname,
-            deptcode,
-            deptname,
-            sendstate,
-            preachform,
-            current_preachform,
-            excep,
-            nurse_id,
-            nurse_name,
-            taskid,
-            task_name,
-            visit_time,
-            finishtime,
-            endtime,
-            senddate,
-            suggest,
-            result,
-            templateid,
-            templatename,
-            patid,
-            sendname,
-            send_type,
-            recordid,
-            exrecallcount,
-            continue_flag,
-            continue_time_now,
-            continue_content,
-            continue_count,
-            continue_time_next,
-            task_situation
-            from service_subtask
-            where 1=1
-            and del_flag = 0
-            <if test="orgid != null and orgid != ''">
-                and orgid = #{orgid}
+        select id,
+        visit_count,
+        is_visit_again,
+        type,
+        orgid,
+        drcode,
+        drname,
+        leavehospitaldistrictcode,
+        leavehospitaldistrictname,
+        deptcode,
+        deptname,
+        sendstate,
+        preachform,
+        current_preachform,
+        excep,
+        nurse_id,
+        nurse_name,
+        taskid,
+        task_name,
+        visit_time,
+        finishtime,
+        endtime,
+        senddate,
+        suggest,
+        result,
+        templateid,
+        templatename,
+        patid,
+        sendname,
+        send_type,
+        recordid,
+        exrecallcount,
+        continue_flag,
+        continue_time_now,
+        continue_content,
+        continue_count,
+        continue_time_next,
+        task_situation,
+        remark
+        from service_subtask
+        where 1=1
+        and 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="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            AND leavehospitaldistrictcode IN
+            <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                     close=")">
+                #{leavehospitaldistrictcode}
+            </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="serviceType != null and serviceType.size() > 0">
+            AND service_type IN
+            <foreach collection="serviceType" item="serviceType" open="(" separator=","
+                     close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime!=null">
+            AND visit_time >= DATE(#{startTime})
+            AND visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
+        </if>
+        <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
+        <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
+        <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
+        <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
+        <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,jdbcType=TIMESTAMP}</if>
+        <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
+        <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=","
+                     close=")">
+                #{key}
+            </foreach>
+        </if>
+        AND sendstate IS NOT NULL
+        <if test="sendstates != null and sendstates.size() > 0">
+            AND sendstate IN
+            <foreach collection="sendstates" item="state" open="(" separator="," close=")">
+                #{state}
+            </foreach>
+        </if>
+        <if test="currentPreachform != null">
+            AND current_preachform = #{currentPreachform}
+            <if test="followUpCountStyle != null and followUpCountStyle = '1'">
+                AND sendstate != 4
             </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="deptcodes != null and deptcodes.size() > 0">
-                AND deptcode IN
-                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
-                         close=")">
-                    #{deptcode}
-                </foreach>
-            </if>
-            <if test="serviceType != null and serviceType.size() > 0">
-                AND service_type IN
-                <foreach collection="serviceType" item="serviceType" open="(" separator=","
-                         close=")">
-                    #{serviceType}
-                </foreach>
-            </if>
-            <if test="startTime != null and endTime!=null">
-                AND visit_time >= DATE(#{startTime})
-                AND visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
-            </if>
-            <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
-            <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
-            <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
-            <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if>
-            <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,jdbcType=TIMESTAMP}</if>
-            <!-- 鐩墠鍙粺璁¤闊冲拰闂嵎 -->
-            <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=","
-                         close=")">
-                    #{key}
-                </foreach>
-            </if>
-            AND sendstate IS NOT NULL
-            <if test="sendstates != null and sendstates.size() > 0">
-                AND sendstate IN
-                <foreach collection="sendstates" item="state" open="(" separator="," close=")">
-                    #{state}
-                </foreach>
-            </if>
-            <if test="currentPreachform != null">
-                AND current_preachform = #{currentPreachform}
-                <if test="followUpCountStyle != null and followUpCountStyle = '1'">
-                    AND sendstate != 4
-                </if>
-            </if>
-            <if test="excep != null and excep != ''">
-                AND excep = #{excep}
-            </if>
-            <if test="taskSituation != null">
-                AND task_situation = #{taskSituation}
-            </if>
-            <if test="drcode != null and drcode != ''">
-                AND drcode = #{drcode}
-            </if>
-            <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
-                AND leavehospitaldistrictcode = #{leavehospitaldistrictcode}
-            </if>
-            <if test="deptcode != null and deptcode != ''">
-                AND deptcode = #{deptcode}
-            </if>
-            order by endtime desc
-            <if test="pageSize != null  and pageNum != null">
-                limit ${pageSize} OFFSET ${pageNum}
-            </if>
+        </if>
+        <if test="excep != null and excep != ''">
+            AND excep = #{excep}
+        </if>
+        <if test="taskSituation != null">
+            AND task_situation = #{taskSituation}
+        </if>
+        <if test="drcode != null and drcode != ''">
+            AND drcode = #{drcode}
+        </if>
+        <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">
+            AND leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+        </if>
+        <if test="deptcode != null and deptcode != ''">
+            AND deptcode = #{deptcode}
+        </if>
+        order by endtime desc
+        <if test="pageSize != null  and pageNum != null">
+            limit ${pageSize} OFFSET ${pageNum}
+        </if>
     </select>
 
     <select id="getSfStatisticsJoy" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1938,6 +1947,9 @@
         and 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="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
@@ -1983,6 +1995,9 @@
         <if test="orgid != null and orgid != ''">
             and orgid = #{orgid}
         </if>
+        <if test="campusid != null and campusid != ''">
+            and campusid = #{campusid}
+        </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
@@ -2014,6 +2029,9 @@
         and 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="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">AND
             leavehospitaldistrictcode IN
@@ -2069,6 +2087,9 @@
         AND t.del_flag=0
         <if test="orgid != null and orgid != ''">
             and t.orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            and t.campusid = #{campusid}
         </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND t.leavehospitaldistrictcode IN
@@ -2153,6 +2174,9 @@
         <if test="orgid != null and orgid != ''">
             AND ss.orgid = #{orgid}
         </if>
+        <if test="campusid != null and campusid != ''">
+            AND ss.campusid = #{campusid}
+        </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND ss.leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
@@ -2209,6 +2233,9 @@
         and ss.del_flag=0
         <if test="orgid != null and orgid != ''">
             and ss.orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            and ss.campusid = #{campusid}
         </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND ss.leavehospitaldistrictcode IN
@@ -2367,8 +2394,11 @@
         AND DATE_FORMAT(visit_time, '%Y-%m-%d') &lt;= #{endDate}
         AND service_type IN (2, 13)
         AND del_flag = '0'
-        <if test="orgid != null">
+        <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
         </if>
         GROUP BY deptname
     </select>
@@ -2414,10 +2444,12 @@
             AND visit_time &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
         </if>
 
-        <if test="orgid != null">
+        <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
         </if>
-
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
+        </if>
         <if test="deptcodes != null and deptcodes.size() > 0">
             AND deptcode IN
             <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
@@ -2471,10 +2503,12 @@
             AND endtime &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
         </if>
         AND inhospstate=1
-        <if test="orgid != null">
+        <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
         </if>
-
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
+        </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
@@ -2521,9 +2555,11 @@
         <!--            AND admitdate &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)-->
         <!--        </if>-->
         <!--        <if test="orgid != null">-->
-        <!--            AND orgid = #{orgid}-->
+        <!--             AND orgid = #{orgid}-->
         <!--        </if>-->
-
+        <!--        <if test="campusid != null">-->
+        <!--             AND campusid = #{campusid}-->
+        <!--        </if>-->
         <!--        <if test="deptcodes != null and deptcodes.size() > 0">-->
         <!--            AND deptcode IN-->
         <!--            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">-->
@@ -2561,6 +2597,12 @@
         <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">
                 AND leavehospitaldistrictcode IN
@@ -2579,8 +2621,9 @@
             </if>
         </if>
         <if test="deptOrDistrict==2">
+            AND (1=1
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-                AND (leavehospitaldistrictcode IN
+                AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
                          separator=","
                          close=")">
@@ -2590,17 +2633,18 @@
             <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
                 OR deptcode IN
                 <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
-                         close="))">
+                         close=")">
                     #{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="("
+            <foreach collection="visitDeptCodes" item="visitDeptCode" open="("
                      separator=","
                      close=")">
-                #{visitDeptCodes}
+                #{visitDeptCode}
             </foreach>
         </if>
         <if test="leavehospitaldistrictname != null and leavehospitaldistrictname != ''">
@@ -2745,8 +2789,11 @@
         where 1=1
         and del_flag = 0
         and service_type=3
-        <if test="orgid != null">
-            and orgid = #{orgid}
+        <if test="orgid != null and orgid != ''">
+            AND orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
         </if>
         <if test="startDate != null">
             AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
@@ -2777,6 +2824,9 @@
         AND visit_count = 1
         <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            and campusid = #{campusid}
         </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
@@ -2865,6 +2915,9 @@
         <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
         </if>
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
+        </if>
         <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
             AND leavehospitaldistrictcode IN
             <foreach collection="leavehospitaldistrictcodes" item="code" open="(" separator="," close=")">
@@ -2890,6 +2943,9 @@
         AND deptcode IS NOT NULL AND deptcode != ''
         <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            AND campusid = #{campusid}
         </if>
         <if test="deptcodes != null and deptcodes.size() > 0">
             AND deptcode IN
@@ -2922,6 +2978,9 @@
         AND service_type = 4
         <if test="orgid != null and orgid != ''">
             and orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            and campusid = #{campusid}
         </if>
         <if test="sendstate != null">
             AND sendstate = #{sendstate}
@@ -2966,12 +3025,123 @@
           and sendstate in (1, 2, 3)
     </select>
 
+    <select id="mydTrend" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+        SELECT CASE #{type}
+                   WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+                   WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+                   WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+                   WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+                   ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+                   END                AS period,
+               ROUND(avg(d.score), 2) AS totalScore
+        FROM service_subtask_detail d
+                 JOIN service_task t ON d.taskid = t.taskid
+        WHERE t.service_type IN (6, 14)
+          AND t.del_flag = 0
+          AND d.del_flag = 0
+          AND d.create_time >= #{startFinishTime}
+          AND d.create_time &lt; DATE_ADD(#{endFinishTime}, INTERVAL 1 DAY)
+        GROUP BY period
+        ORDER BY period;
+    </select>
+
+    <select id="sltdMydTotalByDimension" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+        SELECT
+        p.period,
+        dim.dimension,
+        IFNULL(ROUND(SUM(d.score), 2), 0) AS totalScore
+        FROM (
+        <!-- 鐢熸垚鏌ヨ鑼冨洿鍐呭疄闄呭嚭鐜拌繃鐨勬椂闂存 -->
+        SELECT DISTINCT
+        CASE #{type}
+        WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+        WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+        WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+        WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+        ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+        END AS period
+        FROM service_subtask_detail d
+        WHERE d.del_flag = 0
+        AND d.create_time >= #{startFinishTime}
+        AND d.create_time &lt; #{endFinishTime}
+        ) p
+        CROSS JOIN (
+        <!-- 鎵�鏈夐渶瑕佸睍绀虹殑 dimension -->
+        SELECT DISTINCT dimension
+        FROM service_subtask_detail
+        WHERE del_flag = 0
+        AND dimension IS NOT NULL
+        ) dim
+        LEFT JOIN service_task t
+        ON t.service_type IN (6, 14)
+        AND t.del_flag = 0
+        LEFT JOIN service_subtask_detail d
+        ON d.taskid = t.taskid
+        AND d.del_flag = 0
+        AND d.dimension = dim.dimension
+        AND CASE #{type}
+        WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+        WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+        WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+        WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+        ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+        END = p.period
+        AND d.create_time >= #{startFinishTime}
+        AND d.create_time &lt; #{endFinishTime}
+        GROUP BY p.period, dim.dimension
+        ORDER BY p.period, dim.dimension
+    </select>
+
+    <select id="sltdMydTotalByYQ" resultType="com.smartor.domain.DTO.MydTrendReqDTO">
+        SELECT p.period,
+               c.campusid,
+               IFNULL(ROUND(AVG(d.score), 2), 0) AS totalScore
+        FROM (
+                 -- 鐢熸垚鏌ヨ鑼冨洿鍐呭疄闄呭嚭鐜拌繃鐨勬椂闂存
+                 SELECT DISTINCT CASE #{type}
+                                     WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+                                     WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+                                     WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+                                     WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+                                     ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+                                     END AS period
+                 FROM service_subtask_detail d
+                 WHERE d.del_flag = 0
+                   AND d.create_time >= #{startFinishTime}
+                   AND d.create_time &lt; #{endFinishTime}) p
+                 CROSS JOIN (
+            -- 鎵�鏈夐渶瑕佸睍绀虹殑闄㈠尯
+            SELECT DISTINCT campusid
+            FROM service_task
+            WHERE service_type IN (6, 14)
+              AND del_flag = 0
+              AND campusid IS NOT NULL) c
+                 LEFT JOIN service_task t
+                           ON t.campusid = c.campusid
+                               AND t.service_type IN (6, 14)
+                               AND t.del_flag = 0
+                 LEFT JOIN service_subtask_detail d
+                           ON d.taskid = t.taskid
+                               AND d.del_flag = 0
+                               AND CASE #{type}
+                                       WHEN 'year' THEN DATE_FORMAT(d.create_time, '%Y')
+                                       WHEN 'quarter' THEN CONCAT(YEAR(d.create_time), '-Q', QUARTER(d.create_time))
+                                       WHEN 'month' THEN DATE_FORMAT(d.create_time, '%Y-%m')
+                                       WHEN 'week' THEN FLOOR(DATEDIFF(d.create_time, #{startFinishTime}) / 7) + 1
+                                       ELSE DATE_FORMAT(d.create_time, '%Y-%m-%d')
+                                       END = p.period
+                               AND d.create_time >= #{startFinishTime}
+                               AND d.create_time &lt; #{endFinishTime}
+        GROUP BY p.period, c.campusid
+        ORDER BY p.period, c.campusid;
+    </select>
+
     <!-- 浠诲姟缁勶紙appltype=5锛夋粴鍔ㄨ皟搴︾敤锛氭媺鏈疆鍏ㄩ噺 subtask锛屼綔涓轰笅涓�杞殑鍏嬮殕妯℃澘 -->
     <select id="selectByScheduleIdAndLoop" resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
         where schedule_id = #{scheduleId}
-          and loop_count = #{loopCount}
-          and (del_flag is null or del_flag = '0')
+        and loop_count = #{loopCount}
+        and (del_flag is null or del_flag = '0')
         order by schedule_seq asc, id asc
     </select>
 
@@ -3014,13 +3184,17 @@
         continue_content,
         continue_count,
         continue_time_next,
-        task_situation
+        task_situation,
+        remark
         from service_subtask
         where 1=1
         and del_flag = 0
         AND service_type = 4
         <if test="orgid != null and orgid != ''">
             and orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            and campusid = #{campusid}
         </if>
         <if test="sendstate != null">
             AND sendstate = #{sendstate}
@@ -3057,7 +3231,11 @@
         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
@@ -3073,34 +3251,301 @@
         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 t.taskid IN
-        <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
-            #{taskId}
-        </foreach>
+        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 t.taskid IN
-        <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
-            #{taskId}
-        </foreach>
+        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
-      <if test="startOutHospTime != null">
-        AND date_format(s.endtime,'%y%m%d') &gt;= date_format(#{startOutHospTime},'%y%m%d')
-    </if>
+        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>
+        <if test="startFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &gt;= date_format(#{startFinishTime},'%y%m%d')
+        </if>
+        <if test="endFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &lt;= date_format(#{endFinishTime},'%y%m%d')
         </if>
         GROUP BY
         t.taskid,
         d.questiontext,
-        d.asrtext
+        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>
+        <if test="startFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &gt;= date_format(#{startFinishTime},'%y%m%d')
+        </if>
+        <if test="endFinishTime != null">
+            AND date_format(s.finishtime,'%y%m%d') &lt;= date_format(#{endFinishTime},'%y%m%d')
+        </if>
+        GROUP BY
+        t.taskid,
+        d.questiontext,
+        d.score,
+        d.targetvalue,
+        d.asrtext,
+        t.task_name,
+        s.deptcode,
+        s.deptname,
+        s.leavehospitaldistrictcode,
+        s.leavehospitaldistrictname,
+        d.value_type
+        ORDER BY
+        d.questiontext,
+        t.taskid
+    </select>
+
+    <select id="statQuestionOptionByKsOrBq" resultType="com.smartor.domain.DTO.QuestionCountKsOrBqDTO"
+            parameterType="com.smartor.domain.VO.QuestionCountKsOrBqVO">
+        SELECT
+        s.deptname AS deptname,
+        s.leavehospitaldistrictname AS leavehospitaldistrictname,
+        d.questiontext AS questionText,
+        d.targetvalue AS targetvalue, -- 鎵�鏈夐�夐」鎷兼帴
+        d.asrtext AS asrtext, -- 鐢ㄦ埛瀹為檯閫変腑鐨勯�夐」
+        d.score AS singleScore -- 鍗曟潯璁板綍鐨勫垎鏁�
+        FROM service_subtask_detail d
+        JOIN service_subtask s ON d.sub_id = s.id
+        WHERE s.del_flag = 0
+        AND d.del_flag = 0
+        AND s.service_type IN ('6', '14')
+        <if test="taskTemplateid != null">
+            AND s.templateid = #{taskTemplateid}
+        </if>
+        <if test="endFinishTime != null">
+            AND d.create_time &lt; #{endFinishTime}
+        </if>
+        <if test="startFinishTime != null">
+            AND d.create_time &gt;= #{startFinishTime}
+        </if>
+        <if test="deptOrDistrict ==1">
+            <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>
+        </if>
+        <if test="deptOrDistrict ==2">
+            <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">
+                OR deptcode IN
+                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+                         close=")">
+                    #{leaveldeptcode}
+                </foreach>
+            </if>
+        </if>
+    </select>
+
+    <select id="selectServiceSubtaskListDeadLine" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
+            resultMap="ServiceSubtaskResult">
+        <include refid="selectServiceSubtaskVo"/>
+        where 1=1
+        and del_flag = 0
+        and visit_count = 1
+        and endtime
+    </select>
+
+    <!-- 闂ㄨ瘖婊℃剰搴︾患鍚堝緱鍒嗘帓鍚嶏紙鎸夌瀹ゆ垨鐥呭尯锛� -->
+    <!-- 缁煎悎婊℃剰搴� = 危(璇勫垎鏄庣粏鏉冮噸) / 璇勫垎鏄庣粏鏉℃暟 脳 100%锛屾潈閲嶅彧鍙� 1銆�0.8銆�0.6銆�0.4銆�0.2 浜旀。 -->
+    <select id="selectMzMydScoreRank" parameterType="com.smartor.domain.VO.MzMydScoreRankVO"
+            resultType="com.smartor.domain.DTO.MzMydScoreRankDTO">
+        SELECT
+        t.code                   AS code,
+        t.name                   AS name,
+        ROUND(AVG(t.w) * 100, 2) AS score,
+        COUNT(*)                 AS itemCount
+        FROM (
+        SELECT
+        <choose>
+            <when test='dimensionType == "2"'>
+                s.leavehospitaldistrictcode AS code,
+                s.leavehospitaldistrictname AS name,
+            </when>
+            <otherwise>
+                s.deptcode AS code,
+                s.deptname AS name,
+            </otherwise>
+        </choose>
+        CAST(d.score AS DECIMAL(10,4)) AS w
+        FROM service_subtask s
+        INNER JOIN service_subtask_detail d ON d.sub_id = s.id
+        WHERE s.del_flag = '0'
+        AND d.del_flag = '0'
+        AND s.sendstate = 6
+        AND s.service_type = #{serviceType}
+<!--        &lt;!&ndash; 鍙彇鍏紡閲岀殑浜旀。鏉冮噸锛岀┖鍊�/0/鏈瓟绛夋棦涓嶈繘鍒嗗瓙涔熶笉杩涘垎姣� &ndash;&gt;-->
+<!--        AND CAST(d.score AS DECIMAL(10,4)) IN (1, 0.8, 0.6, 0.4, 0.2)-->
+        <!-- 鍚屼竴瀛愪换鍔″悓涓�棰樼洰鍙繚鐣欐渶鏂颁竴鏉★紝閬垮厤閲嶇瓟琚噸澶嶈鍏ラ」鏁� -->
+        AND d.id = (
+        SELECT MAX(d2.id)
+        FROM service_subtask_detail d2
+        WHERE d2.sub_id = d.sub_id
+        AND d2.questiontext &lt;=&gt; d.questiontext
+        AND d2.del_flag = '0'
+        )
+        <if test="orgid != null and orgid != ''">
+            AND s.orgid = #{orgid}
+        </if>
+        <if test="campusid != null and campusid != ''">
+            AND s.campusid = #{campusid}
+        </if>
+        <if test="startFinishTime != null">
+            AND s.finishtime &gt;= #{startFinishTime}
+        </if>
+        <if test="endFinishTime != null">
+            AND s.finishtime &lt; DATE_ADD(#{endFinishTime}, INTERVAL 1 DAY)
+        </if>
+        <choose>
+            <when test='dimensionType == "2"'>
+                AND s.leavehospitaldistrictcode IS NOT NULL AND s.leavehospitaldistrictcode &lt;&gt; ''
+                AND s.leavehospitaldistrictname IS NOT NULL AND s.leavehospitaldistrictname &lt;&gt; ''
+                <if test="districtCodes != null and districtCodes.size() > 0">
+                    AND s.leavehospitaldistrictcode IN
+                    <foreach collection="districtCodes" item="districtCode" open="(" separator="," close=")">
+                        #{districtCode}
+                    </foreach>
+                </if>
+            </when>
+            <otherwise>
+                AND s.deptcode IS NOT NULL AND s.deptcode &lt;&gt; ''
+                AND s.deptname IS NOT NULL AND s.deptname &lt;&gt; ''
+                <if test="deptCodes != null and deptCodes.size() > 0">
+                    AND s.deptcode IN
+                    <foreach collection="deptCodes" item="deptCode" open="(" separator="," close=")">
+                        #{deptCode}
+                    </foreach>
+                </if>
+            </otherwise>
+        </choose>
+        ) t
+        GROUP BY t.code, t.name
+        ORDER BY AVG(t.w) DESC, COUNT(*) DESC
+        <if test="limit != null and limit > 0">
+            LIMIT #{limit}
+        </if>
+    </select>
+
+
 </mapper>
 

--
Gitblit v1.9.3