<?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.FbsAbnormalWorkingHoursDescribeMapper">
    <select id="getMonthExceptionByCategory" resultType="org.jeecg.modules.fbsAbnormalWorkingHours.entity.FbsAbnormalWorkingHoursDescribe">
        SELECT
            count( fawh.id ) AS total,
            fawhd.product
        FROM
            fbs_abnormal_working_hours_describe fawhd
            LEFT JOIN fbs_abnormal_working_hours fawh ON fawhd.abnormal_working_hours_id = fawh.id
        WHERE
            fawhd.del_flag = '0'
            AND fawhd.del_flag = '0'
            AND type='物料'
            AND date_format( fawh.date, '%Y-%m' ) = DATE_FORMAT( now( ), '%Y-%m' )
        GROUP BY
            fawhd.product
    </select>

    <select id="getMonthExceptionByCategoryTwo" resultType="java.util.HashMap">
        SELECT
        fawhd.product label,
        sum( fawhd.rejects_number ) sum1,
        fawhd.planned_quantity sum2
        FROM
        fbs_abnormal_working_hours_describe fawhd
        LEFT JOIN fbs_abnormal_working_hours fawh ON fawhd.abnormal_working_hours_id = fawh.id
        WHERE
        fawhd.del_flag = '0'
        AND fawhd.del_flag = '0'
        AND fawhd.product IS NOT NULL
        AND fawhd.type='物料'
        AND fawhd.planned_quantity >0
        AND date_format( fawh.date, '%Y-%m' ) = DATE_FORMAT( now( ), '%Y-%m' )
        GROUP BY
        fawhd.product,fawhd.planned_quantity
    </select>

    <select id="getListAndMain" resultType="org.jeecg.modules.fbsAbnormalWorkingHours.entity.FbsAbnormalWorkingHoursDescribe">
        SELECT
            fawhd.*
        FROM
            fbs_abnormal_working_hours_describe fawhd
            LEFT JOIN fbs_abnormal_working_hours fawh ON fawh.id = fawhd.abnormal_working_hours_id
        WHERE
            fawh.del_flag = '0'
            AND fawhd.del_flag = '0'
            AND DATE_FORMAT( fawh.date, '%Y-%m-%d' ) <![CDATA[ >= ]]> DATE_FORMAT( #{fbsAbnormalWorkingHoursDescribe.start}, '%Y-%m-%d' )
            AND DATE_FORMAT( fawh.date, '%Y-%m-%d' ) <![CDATA[ <= ]]> DATE_FORMAT( #{fbsAbnormalWorkingHoursDescribe.end}, '%Y-%m-%d' )
            ORDER BY
            fawh.date DESC
    </select>
</mapper>