<?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.rongwei.bscommon.sys.dao.ApsReportRecordsDao">

    <resultMap id="BaseResultMap" type="com.rongwei.bsentity.domain.ApsReportRecordsDo">
        <id property="id" column="ID" jdbcType="VARCHAR"/>
        <result property="tenantid" column="TENANTID" jdbcType="VARCHAR"/>
        <result property="roption" column="ROPTION" jdbcType="VARCHAR"/>
        <result property="deleted" column="DELETED" jdbcType="CHAR"/>
        <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
        <result property="createdate" column="CREATEDATE" jdbcType="TIMESTAMP"/>
        <result property="createuserid" column="CREATEUSERID" jdbcType="VARCHAR"/>
        <result property="modifydate" column="MODIFYDATE" jdbcType="TIMESTAMP"/>
        <result property="modifyuserid" column="MODIFYUSERID" jdbcType="VARCHAR"/>
        <result property="createusername" column="CREATEUSERNAME" jdbcType="VARCHAR"/>
        <result property="modifyusername" column="MODIFYUSERNAME" jdbcType="VARCHAR"/>
        <result property="processoperationid" column="PROCESSOPERATIONID" jdbcType="VARCHAR"/>
        <result property="batchnumber" column="BATCHNUMBER" jdbcType="VARCHAR"/>
        <result property="actualinputmaterial" column="ACTUALINPUTMATERIAL" jdbcType="VARCHAR"/>
        <result property="chiefoperatorid" column="CHIEFOPERATORID" jdbcType="VARCHAR"/>
        <result property="chiefoperatorname" column="CHIEFOPERATORNAME" jdbcType="VARCHAR"/>
        <result property="startworktime" column="STARTWORKTIME" jdbcType="TIMESTAMP"/>
        <result property="reportworktime" column="REPORTWORKTIME" jdbcType="TIMESTAMP"/>
        <result property="reportworkstatus" column="REPORTWORKSTATUS" jdbcType="VARCHAR"/>
        <result property="checkstatus" column="CHECKSTATUS" jdbcType="VARCHAR"/>
        <result property="needcheckbatchnumber" column="NEEDCHECKBATCHNUMBER" jdbcType="VARCHAR"/>
        <result property="checkid" column="CHECKID" jdbcType="VARCHAR"/>
        <result property="checkdate" column="CHECKDATE" jdbcType="TIMESTAMP"/>
        <result property="checkfile" column="CHECKFILE" jdbcType="VARCHAR"/>
        <result property="ingredient" column="INGREDIENT" jdbcType="VARCHAR"/>
        <result property="checkusername" column="CHECKUSERNAME" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,TENANTID,ROPTION,
        DELETED,REMARK,CREATEDATE,
        CREATEUSERID,MODIFYDATE,MODIFYUSERID,
        CREATEUSERNAME,MODIFYUSERNAME,PROCESSOPERATIONID,
        BATCHNUMBER,ACTUALINPUTMATERIAL,CHIEFOPERATORID,
        CHIEFOPERATORNAME,STARTWORKTIME,REPORTWORKTIME,
        REPORTWORKSTATUS,CHECKSTATUS,NEEDCHECKBATCHNUMBER,
        CHECKID,CHECKDATE,CHECKFILE,
        INGREDIENT,CHECKUSERNAME
    </sql>
    <select id="selectInputAndOutputNumByProcessId" resultType="com.rongwei.bsentity.vo.ProcessOutputAndInputNumber">
        SELECT
            arr.PROCESSOPERATIONID as processId,
        IFNULL(CONCAT(GROUP_CONCAT(DISTINCT arr.BATCHNUMBER ),"-;-",GROUP_CONCAT( DISTINCT aro.OUTPUTNUMBER )),'') as number
        FROM
            aps_report_records arr
            LEFT JOIN aps_report_output aro ON arr.ID = aro.MAINID
        <where>
            arr.DELETED = '0'
            AND aro.DELETED = '0'
            AND arr.PROCESSOPERATIONID in
            <foreach collection="processIds" open="(" close=")" item="id" separator=",">
                #{id}
            </foreach>
        </where>
        GROUP BY
            arr.PROCESSOPERATIONID
    </select>
</mapper>
