<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticByCrmMapper">
    <update id="truncateTable">
        TRUNCATE TABLE t_b_ding_statistic_by_crm
    </update>

    <select id="findStatisticByCrmList" resultType="com.qmth.sop.business.bean.dto.DingStatisticByCrmDto">
        SELECT
            service_name AS serviceName,
            crm_no AS crmNo,
            crm_name AS crmName,
            actual_days AS actualDays,
            weekdays,
            weekends,
            legal_holidays AS legalHolidays,
            scan_period AS scanPeriod,
            mark_paper_period AS markPaperPeriod,
            work_hours AS workHours,
            violation_days AS violationDays
        FROM
            t_b_ding_statistic_by_crm
        <where>
            <if test="serviceId != null">
                AND service_id = #{serviceId}
            </if>
        </where>
    </select>
    <select id="findStatisticByCrmPage" resultType="com.qmth.sop.business.bean.dto.DingStatisticByCrmDto">
        SELECT
            service_name AS serviceName,
            crm_no AS crmNo,
            crm_name AS crmName,
            actual_days AS actualDays,
            weekdays,
            weekends,
            legal_holidays AS legalHolidays,
            scan_period AS scanPeriod,
            mark_paper_period AS markPaperPeriod,
            work_hours AS workHours,
            violation_days AS violationDays
        FROM
            t_b_ding_statistic_by_crm
        <where>
            <if test="serviceId != null">
                AND service_id = #{serviceId}
            </if>
        </where>
    </select>
</mapper>
