<?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="org.jeecg.modules.fbsAbnormalWorkingHours.mapper.FbsAbnormalWorkingHoursMapper">
    <select id="getQualityType" resultType="org.jeecg.modules.fbsAbnormalWorkingHours.entity.FbsAbnormalWorkingHours">
        SELECT
            sum( quality ) AS quality,
            type_name as typeName
        FROM
            fbs_abnormal_working_hours
        WHERE
            del_flag = '0' and type_name is not null
        GROUP BY
            type_name
    </select>

    <select id="getRejectsNumber" resultType="org.jeecg.modules.fbsAbnormalWorkingHours.entity.FbsAbnormalWorkingHours">
        SELECT
            fawh.product,
            sum( fawh.rejects_number ) as rejectsNumberTotal
        FROM
            fbs_abnormal_working_hours fawh
            LEFT JOIN fbs_workshop_dispatch_list fwdl ON fawh.workshop_dispatch_list_id = fwdl.id
        WHERE
            fawh.del_flag = '0'
            AND fawh.product IS NOT NULL
            AND date_format( fawh.date, #{dateString} ) = DATE_FORMAT( now( ), #{dateString} )
        GROUP BY
            fawh.product
    </select>

    <select id="getRejectsNumberSameDay" resultType="org.jeecg.modules.fbsAbnormalWorkingHours.entity.FbsAbnormalWorkingHours">
        SELECT
        fawh.product,
        sum( fawh.rejects_number ) as rejectsNumberTotal
        FROM
        fbs_abnormal_working_hours fawh
        LEFT JOIN fbs_workshop_dispatch_list fwdl ON fawh.workshop_dispatch_list_id = fwdl.id
        WHERE
        fawh.del_flag = '0'
        AND fawh.product IS NOT NULL
        AND date_format( fawh.date, '%Y-%m-%d' ) = DATE_FORMAT( now( ), '%Y-%m-%d' )
        GROUP BY
        fawh.product
    </select>
</mapper>