陈昶聿
2 天以前 5cbcb6cce6349c81defb99ef1c178affe38e81f8
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -662,25 +662,29 @@
        ) a
    </select>
    <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.ServiceSubtask" resultType="map">
    <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" 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
        SUM(CASE WHEN finishtime IS NOT NULL AND DATE(visit_time) &lt;= DATE(finishtime) THEN 1 ELSE 0 END) / COUNT(*) AS finishRate,
        <if test="rateDay != null">
            SUM(CASE WHEN finishtime IS NOT NULL AND DATEDIFF(finishtime, endtime) &lt;= #{rateDay} THEN 1 ELSE 0 END) / COUNT(*) AS rate
        </if>
        <if test="rateDay == null">
            NULL AS rate
        </if>
        FROM service_subtask
        WHERE del_flag = 0
        AND visit_time IS NOT NULL
        AND finishtime IS NOT NULL
        <if test="orgid != null">AND orgid = #{orgid}</if>
        <if test="starttime == null and endtime==null">
            AND visit_time &lt; NOW()
            AND DATE(visit_time) &lt; DATE(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="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>
@@ -698,6 +702,13 @@
        <if test="visitCount != null and visitCount > 1">
            AND visit_count > 1
        </if>
        <if test="serviceTypeList != null">
            AND service_type IN
            <foreach collection="serviceTypeList" item="serviceType" open="(" separator=","
                     close=")">
                #{serviceType}
            </foreach>
        </if>
        <if test="groupKey != null and groupKey != ''">
            AND ${groupKey} IN
            <foreach collection="groupKeyList" item="key" open="(" separator=","