陈昶聿
2026-01-23 26c20d898eb2ae196e1585f245608c59f17959ff
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -278,6 +278,14 @@
            <if test="senderdetail != null  and senderdetail != ''">and senderdetail = #{senderdetail}</if>
            <if test="type != null  and type != ''">and type = #{type}</if>
            <if test="taskid != null ">and taskid = #{taskid}</if>
            <!-- taskIds筛选 -->
            <if test="taskIds != null and taskIds.size() > 0">
                AND taskid IN
                <foreach collection="taskIds" item="itemTaskId" open="(" separator=","
                         close=")">
                    #{itemTaskId}
                </foreach>
            </if>
            <if test="templateid != null  and templateid != ''">and templateid = #{templateid}</if>
            <if test="templatename != null  and templatename != ''">and templatename like concat('%', #{templatename},
                '%')
@@ -552,6 +560,45 @@
        <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
        ) a
    </select>
    <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.ServiceSubtask" resultType="map">
        SELECT
        <if test="groupKey != null and groupKey != ''">
            ${groupKey} as groupKey,
        </if>
        SUM(CASE WHEN DATE(visit_time) &lt; DATE(IFNULL(finishtime, NOW())) THEN 1 ELSE 0 END) / COUNT(*) as rate
        FROM service_subtask
        WHERE del_flag = 0
        <if test="orgid != null">AND orgid = #{orgid}</if>
        <if test="starttime == null and endtime==null">
            AND visit_time &lt; NOW()
        </if>
        <if test="starttime != null and endtime!=null">
            AND visit_time >= #{starttime}
            AND visit_time &lt; DATE_ADD(#{endtime}, INTERVAL 1 DAY)
        </if>
        <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
        <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
        <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
        <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
        <if test="leavehospitaldistrictcode != null  and leavehospitaldistrictcode != ''">and
            leavehospitaldistrictcode = #{leavehospitaldistrictcode}
        </if>
        <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
            leavehospitaldistrictname = #{leavehospitaldistrictname}
        </if>
        <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
        <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
        <if test="groupKey != null and groupKey != ''">
            AND ${groupKey} IN
            <foreach collection="groupKeyList" item="key" open="(" separator=","
                     close=")">
                #{key}
            </foreach>
            GROUP BY ${groupKey}
        </if>
    </select>
    <select id="selectTimelyRateDetail" parameterType="com.smartor.domain.ServiceSubtask"
            resultMap="ServiceSubtaskResult">
@@ -1198,13 +1245,75 @@
                    #{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="type != null">
                and type = #{type}
        </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>
    </select>
    <select id="getSfStatisticsGroupKey" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
            resultType="String">
            select
            <if test="groupKey != null and groupKey != ''">
                ${groupKey} as groupKey
            </if>
            from service_subtask
            where 1=1
            and del_flag = 0
            <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </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 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')
            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">abd visit_dept_name = #{visitDeptName}</if>
            <if test="isabnormal != null">abd isabnormal = #{isabnormal}</if>
            <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
            <if test="isabnormal != null">and isabnormal = #{isabnormal}</if>
            <!-- 目前只统计语音和问卷 -->
            <if test="type != null">
            and type = #{type}
            </if>
            <if test="groupKey != null and groupKey != ''">
                group by ${groupKey}
            </if>
            <if test="pageSize != null  and pageNum != null">
                limit ${pageSize} OFFSET ${pageNum}
            </if>
    </select>
    <select id="getSfStatisticsJoy" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1330,19 +1439,25 @@
    <select id="getSfStatisticsCategory" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
            resultMap="ServiceSubtaskResult2">
        SELECT a.sub_id as subTaskId,
        SELECT
        <if test="configValue != null and configValue != ''">
            SUM(CASE WHEN a.categoryid IN(${configValue})
            THEN 1 ELSE 0 END) AS joyAllCount,
        </if>
        COUNT(sub_id) joyCount
        <if test="configValue != null and configValue != ''">
            SUM(CASE WHEN a.categoryid IN(${configValue})
                AND IFNULL(a.matchedtext,a.asrtext) is not null
                AND IFNULL(a.matchedtext,a.asrtext) != ''
            THEN 1 ELSE 0 END) AS joyCount,
        </if>
        a.sub_id as subTaskId
        FROM service_subtask_detail a
        INNER JOIN service_subtask t ON a.sub_id = t.id
        where 1=1
            and a.del_flag=0
            AND t.del_flag=0
            <if test="orgid != null and orgid != ''">
                and a.orgid = #{orgid}
                and t.orgid = #{orgid}
            </if>
            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
                AND t.leavehospitaldistrictcode IN
@@ -1356,6 +1471,13 @@
                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                         close=")">
                    #{deptcode}
                </foreach>
            </if>
            <if test="subTaskIds != null and subTaskIds.size() > 0">
                AND t.id IN
                <foreach collection="subTaskIds" item="subTaskId" open="(" separator=","
                         close=")">
                    #{subTaskId}
                </foreach>
            </if>
            <if test="serviceType != null and serviceType.size() > 0">
@@ -1414,8 +1536,8 @@
        FROM
        service_subtask_detail ssd
        INNER JOIN service_subtask ss ON ssd.sub_id = ss.id
        WHERE
        ss.del_flag=0
        WHERE 1=1
        AND ss.del_flag=0
        AND ssd.del_flag = 0
        <if test="orgid != null and orgid != ''">
            AND ss.orgid = #{orgid}
@@ -1454,6 +1576,13 @@
        </if>
        group by ssd.scriptid) b
        ON a.id = b.scriptid
        <!-- 适用单条查询 -->
        <if test="scriptids != null">
            AND a.scriptid in
            (SELECT lib_script.scriptid FROM
            svy_lib_template_script lib_script
            WHERE lib_script.scriptid in (${scriptids}))
        </if>
    </select>
    <select id="getSfStatisticsScriptItemDetails" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
@@ -1470,8 +1599,6 @@
            <if test="orgid != null and orgid != ''">
                and ss.orgid = #{orgid}
            </if>
            AND IFNULL(ssd.matchedtext,ssd.asrtext) IS NOT NULL
            AND IFNULL(ssd.matchedtext,ssd.asrtext) != ''
            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
                AND ss.leavehospitaldistrictcode IN
                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","