<?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.aucma.report.mapper.GeneralReportMapper">


    <select id="inventoryRateReportList" resultType="java.util.HashMap" parameterType="java.util.HashMap">
        SELECT boi.ORDER_CODE,
        boi.BEGIN_DATE,
        boi.MATERIAL_CODE,
        boi.MATERIAL_NAME,
        boi.ORDER_AMOUNT,
        NVL(boi.COMPLETE_AMOUNT, 0) COMPLETE_AMOUNT,
        ROUND(NVL(boi.COMPLETE_AMOUNT, 0) / boi.ORDER_AMOUNT, 2) * 100 || '%' ORDER_RATE,
        PL.WORK_CENTER_CODE,
        PL.PRODUCT_LINE_NAME
        FROM BASE_ORDERINFO boi
        LEFT JOIN BASE_PRODUCTLINE PL ON PL.WORK_CENTER_CODE = boi.WORK_CENTER_CODE
        WHERE boi.MATERIAL_CODE LIKE '90%'
        <if test="WORK_CENTER_CODE != null and WORK_CENTER_CODE != ''">
            AND boi.WORK_CENTER_CODE = #{WORK_CENTER_CODE}
        </if>
        <if test="MATERIAL_CODE != null  and MATERIAL_CODE != ''">
            and boi.MATERIAL_CODE like concat(#{MATERIAL_CODE}, '%')
        </if>
        <if test="MATERIAL_NAME != null  and MATERIAL_NAME != ''">
            and boi.MATERIAL_NAME like concat(concat('%',#{MATERIAL_NAME}), '%')
        </if>
        <if test="ORDER_CODE != null  and ORDER_CODE != ''">
            and boi.ORDER_CODE like concat(concat('%',#{ORDER_CODE}), '%')
        </if>
        <if test="beginBeginTime != null  and beginBeginTime != '' and endBeginTime != null  and endBeginTime != ''">
            AND TO_CHAR(boi.BEGIN_DATE, 'YYYY-MM-DD') BETWEEN #{beginBeginTime} AND #{endBeginTime}
        </if>
        ORDER BY ORDER_RATE
    </select>

    <select id="productionExecutionReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>

    <select id="WIPInquiryReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>

    <select id="qualityDefectsStatisticalAnalysisList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>
    <select id="fewerMistakesReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>
    <select id="qualityIssuesReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>
    <select id="productTraceabilityReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_MATERIAL_COMPLETION
    </select>
    <select id="ScanOfflineRecordReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_PRODUCT_OFFLINE
    </select>
    <select id="temperatureRecordReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_RECORD_TEMPERATURE
    </select>
    <select id="pourRecordReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_PERFUSION_RECORD
    </select>
    <select id="foamFillingRecordReportList" resultType="java.util.HashMap">
        SELECT *
        FROM VIEW_BOX_FOAMDATARECORD
    </select>


</mapper>
