陈昶聿
6 小时以前 4f1618f0df5c8ac19970f3bf0efa218b770cfb61
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -121,6 +121,25 @@
        <result property="options" column="options"/>
    </resultMap>
    <resultMap type="com.smartor.domain.ServiceSubtaskStatistic" id="ServiceSubtaskStatisticResult">
        <result property="dischargeCount" column="discharge_count"/>
        <result property="nonFollowUp" column="non_follow_up"/>
        <result property="filterCount" column="filter_count"/>
        <result property="followUpNeeded" column="follow_up_needed"/>
        <result property="needFollowUp" column="need_follow_up"/>
        <result property="pendingFollowUp" column="pending_follow_up"/>
        <result property="followUpFail" column="follow_up_fail"/>
        <result property="manual" column="manual"/>
        <result property="voice" column="voice"/>
        <result property="sms" column="sms"/>
        <result property="weChat" column="we_chat"/>
        <result property="taskSituation1" column="task_situation1"/>
        <result property="taskSituation2" column="task_situation2"/>
        <result property="taskSituation3" column="task_situation3"/>
        <result property="taskSituation4" column="task_situation4"/>
        <result property="taskSituation5" column="task_situation5"/>
        <result property="taskSituation6" column="task_situation6"/>
    </resultMap>
    <sql id="selectServiceSubtaskVo">
        select id,
               hosp_type,
@@ -1485,6 +1504,112 @@
            </foreach>
        </if>
    </select>
    <select id="getSpecialSfStatistics" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
            resultMap="ServiceSubtaskStatisticResult">
        select
        a.task_name,
        COUNT(1) AS discharge_count,
        SUM(CASE WHEN b.sendstate = 4 THEN 1 ELSE 0 END) AS non_follow_up,
        SUM(CASE WHEN b.sendstate = 4 and b.task_situation = 6 THEN 1 ELSE 0 END) AS filter_count,
        SUM(CASE WHEN b.sendstate != 4 THEN 1 ELSE 0 END) AS follow_up_needed,
        SUM(CASE WHEN b.sendstate != 4 THEN 1 ELSE 0 END) AS need_follow_up,
        SUM(CASE WHEN b.sendstate = 2 THEN 1 ELSE 0 END) AS pending_follow_up,
        SUM(CASE WHEN b.sendstate = 5 or b.sendstate = 7 THEN 1 ELSE 0 END) AS follow_up_fail,
        SUM(CASE WHEN b.current_preachform = '1' THEN 1 ELSE 0 END) AS manual,
        SUM(CASE WHEN b.current_preachform = '3' THEN 1 ELSE 0 END) AS voice,
        SUM(CASE WHEN b.current_preachform = '4' THEN 1 ELSE 0 END) AS sms,
        SUM(CASE WHEN b.current_preachform = '5' THEN 1 ELSE 0 END) AS we_chat,
        SUM(CASE WHEN b.task_situation = 1 THEN 1 ELSE 0 END) AS task_situation1,
        SUM(CASE WHEN b.task_situation = 2 THEN 1 ELSE 0 END) AS task_situation2,
        SUM(CASE WHEN b.task_situation = 3 THEN 1 ELSE 0 END) AS task_situation3,
        SUM(CASE WHEN b.task_situation = 4 THEN 1 ELSE 0 END) AS task_situation4,
        SUM(CASE WHEN b.task_situation = 5 THEN 1 ELSE 0 END) AS task_situation5,
        SUM(CASE WHEN b.task_situation = 7 THEN 1 ELSE 0 END) AS task_situation7
        from service_task a
        JOIN service_subtask b on a.taskid = b.taskid
        where 1=1
        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="taskName != null and taskName != ''">
            and a.task_name like concat('%', #{taskName}, '%')
        </if>
        <if test="diagType != null and diagType != ''">
            and a.diag_type = #{diagType}
        </if>
        <if test="taskIds != null and taskIds.size() > 0">
            AND a.task_id IN
            <foreach collection="taskIds" item="taskIdItem" open="(" separator=","
                     close=")">
                #{taskIdItem}
            </foreach>
        </if>
        <if test="taskNames != null and taskNames.size() > 0">
            AND a.task_name IN
            <foreach collection="taskNames" item="taskNameItem" open="(" separator=","
                     close=")">
                #{taskNameItem}
            </foreach>
        </if>
        <if test="diagTypes != null and diagTypes.size() > 0">
            AND a.diag_type IN
            <foreach collection="diagTypes" item="diagTypeItem" open="(" separator=","
                     close=")">
                #{diagTypeItem}
            </foreach>
        </if>
        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
            AND b.leavehospitaldistrictcode IN
            <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
                     close=")">
                #{leavehospitaldistrictcode}
            </foreach>
        </if>
        <if test="deptcodes != null and deptcodes.size() > 0">
            AND b.deptcode IN
            <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                     close=")">
                #{deptcode}
            </foreach>
        </if>
        <if test="serviceType != null and serviceType.size() > 0">
            AND b.service_type IN
            <foreach collection="serviceType" item="serviceType" open="(" separator=","
                     close=")">
                #{serviceType}
            </foreach>
        </if>
        <if test="startTime != null and endTime!=null">
            AND b.visit_time >= DATE(#{startTime})
            AND b.visit_time &lt; DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY)
        </if>
        <if test="visitDeptCode != null">and b.visit_dept_code = #{visitDeptCode}</if>
        <if test="visitDeptName != null">and b.visit_dept_name = #{visitDeptName}</if>
        <if test="isabnormal != null">and b.isabnormal = #{isabnormal}</if>
        <if test="continueFlag != null ">and b.continue_flag = #{continueFlag}</if>
        <if test="continueTimeNow != null ">and b.continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
        <if test="continueCount != null ">and b.continue_count = #{continueCount}</if>
        <if test="continueTimeNext != null ">and b.continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if>
        <!-- 目前只统计语音和问卷 -->
        <if test="type != null">
            and b.type = #{type}
        </if>
        <if test="visitCount != null and visitCount == 1">
            AND b.visit_count = 1
        </if>
        <if test="visitCount != null and visitCount > 1">
            AND b.visit_count > 1
        </if>
        GROUP BY a.task_name
    </select>
    <select id="getSfStatisticsGroupKey" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
            resultType="String">
        select
@@ -2111,8 +2236,10 @@
        SELECT deptname,
        count(1) AS rc
        FROM service_subtask
        WHERE DATE_FORMAT(finishtime, '%Y-%m-%d') >= #{startDate}
        AND DATE_FORMAT(finishtime, '%Y-%m-%d') &lt;= #{endDate}
        WHERE DATE_FORMAT(visit_time, '%Y-%m-%d') >= #{startDate}
        AND DATE_FORMAT(visit_time, '%Y-%m-%d') &lt;= #{endDate}
        AND service_type IN (2, 13)
        AND del_flag = '0'
        <if test="orgid != null">
            AND orgid = #{orgid}
        </if>
@@ -2154,6 +2281,7 @@
        FROM service_subtask
        WHERE
        del_flag = '0'
        AND service_type IN (2, 13)
        <if test="startDate != null and endDate != null">
            AND visit_time >= #{startDate}
            AND visit_time &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
@@ -2215,7 +2343,6 @@
            AND endtime >= #{startDate}
            AND endtime &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
        </if>
        AND inhospstate=1
        <if test="orgid != null">
            AND orgid = #{orgid}