<?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.ApsCraftRouteOutMaterRequestDao">

    <resultMap id="BaseResultMap" type="com.rongwei.bsentity.domain.ApsCraftRouteOutMaterRequestDo">
            <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="VARCHAR"/>
            <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="datano" column="DATANO" jdbcType="INTEGER"/>
            <result property="craftrouteid" column="CRAFTROUTEID" jdbcType="VARCHAR"/>
            <result property="craftstepid" column="CRAFTSTEPID" jdbcType="VARCHAR"/>
            <result property="materialcode" column="MATERIALCODE" jdbcType="VARCHAR"/>
            <result property="materialname" column="MATERIALNAME" jdbcType="VARCHAR"/>
            <result property="thickrule" column="THICKRULE" jdbcType="VARCHAR"/>
            <result property="thickchange" column="THICKCHANGE" jdbcType="DECIMAL"/>
            <result property="thickoffset" column="THICKOFFSET" jdbcType="VARCHAR"/>
            <result property="thickstr" column="THICKSTR" jdbcType="DECIMAL"/>
            <result property="thickend" column="THICKEND" jdbcType="DECIMAL"/>
            <result property="thickremark" column="THICKREMARK" jdbcType="VARCHAR"/>
            <result property="widthrule" column="WIDTHRULE" jdbcType="VARCHAR"/>
            <result property="widthchange" column="WIDTHCHANGE" jdbcType="DECIMAL"/>
        <result property="widthoffset" column="WIDTHOFFSET" jdbcType="VARCHAR"/>
        <result property="widthstr" column="WIDTHSTR" jdbcType="DECIMAL"/>
        <result property="widthend" column="WIDTHEND" jdbcType="DECIMAL"/>
        <result property="widthremark" column="WIDTHREMARK" jdbcType="VARCHAR"/>
        <result property="lengthrule" column="LENGTHRULE" jdbcType="VARCHAR"/>
        <result property="lengthchange" column="LENGTHCHANGE" jdbcType="DECIMAL"/>
        <result property="lengthoffset" column="LENGTHOFFSET" jdbcType="VARCHAR"/>
        <result property="lengthstr" column="LENGTHSTR" jdbcType="DECIMAL"/>
        <result property="lengthend" column="LENGTHEND" jdbcType="DECIMAL"/>
        <result property="lengthremark" column="LENGTHREMARK" jdbcType="VARCHAR"/>
        <result property="outval" column="OUTVAL" jdbcType="DECIMAL"/>
        <result property="outmaterrequest" column="OUTMATERREQUEST" jdbcType="VARCHAR"/>
        <result property="producttyperuleid" column="PRODUCTTYPERULEID" jdbcType="VARCHAR"/>
        <result property="producttyperule" column="PRODUCTTYPERULE" jdbcType="VARCHAR"/>
        <result property="producttypeid" column="PRODUCTTYPEID" jdbcType="VARCHAR"/>
        <result property="producttype" column="PRODUCTTYPE" jdbcType="VARCHAR"/>
        <result property="metalrule" column="METALRULE" jdbcType="VARCHAR"/>
        <result property="metal" column="METAL" jdbcType="VARCHAR"/>
        <result property="metalstaterule" column="METALSTATERULE" jdbcType="VARCHAR"/>
        <result property="metalstate" column="METALSTATE" jdbcType="VARCHAR"/>
        <result property="actualthickstr" column="ACTUALTHICKSTR" jdbcType="DECIMAL"/>
        <result property="actualthickend" column="ACTUALTHICKEND" jdbcType="DECIMAL"/>
        <result property="actualwidthstr" column="ACTUALWIDTHSTR" jdbcType="DECIMAL"/>
        <result property="actualwidthend" column="ACTUALWIDTHEND" jdbcType="DECIMAL"/>
        <result property="actuallengthstr" column="ACTUALLENGTHSTR" jdbcType="DECIMAL"/>
        <result property="actuallengthend" column="ACTUALLENGTHEND" jdbcType="DECIMAL"/>
        <result property="actualoutmaterrequest" column="ACTUALOUTMATERREQUEST" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,TENANTID,ROPTION,
        DELETED,REMARK,CREATEDATE,
        CREATEUSERID,MODIFYDATE,MODIFYUSERID,
        CREATEUSERNAME,MODIFYUSERNAME,DATANO,
        CRAFTROUTEID,CRAFTSTEPID,MATERIALCODE,
        MATERIALNAME,THICKRULE,THICKCHANGE,
        THICKOFFSET,THICKSTR,THICKEND,
        THICKREMARK,WIDTHRULE,WIDTHCHANGE,
        WIDTHOFFSET,WIDTHSTR,WIDTHEND,
        WIDTHREMARK,LENGTHRULE,LENGTHCHANGE,
        LENGTHOFFSET,LENGTHSTR,LENGTHEND,
        LENGTHREMARK,OUTVAL,OUTMATERREQUEST,
        PRODUCTTYPERULEID,PRODUCTTYPERULE,PRODUCTTYPEID,
        PRODUCTTYPE,METALRULE,METAL,
        METALSTATERULE,METALSTATE,ACTUALTHICKSTR,
        ACTUALTHICKEND, ACTUALWIDTHSTR,ACTUALWIDTHEND,
        ACTUALLENGTHSTR,ACTUALLENGTHEND,ACTUALOUTMATERREQUEST
    </sql>
    <delete id="removeByIdList">
        DELETE FROM aps_craft_route_out_mater_request
        <where>
            CRAFTROUTEID = #{routeId} AND CRAFTSTEPID IN
            <foreach collection="ids" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </where>
    </delete>
    <insert id="copyDataById">
        <foreach collection="datas" item="data" open="" close="" separator=";">
            INSERT INTO aps_craft_route_out_mater_request (TENANTID, ID, ROPTION, DELETED, REMARK, CREATEDATE,
            CREATEUSERID,
            MODIFYDATE, MODIFYUSERID, CREATEUSERNAME, MODIFYUSERNAME, DATANO, CRAFTROUTEID, CRAFTSTEPID, MATERIALCODE,
            MATERIALNAME, THICKRULE, THICKCHANGE, THICKOFFSET, THICKSTR, THICKEND, THICKREMARK, WIDTHRULE, WIDTHCHANGE,
            WIDTHOFFSET, WIDTHSTR, WIDTHEND, WIDTHREMARK, LENGTHRULE, LENGTHCHANGE, LENGTHOFFSET, LENGTHSTR, LENGTHEND,
            LENGTHREMARK, OUTVAL, OUTMATERREQUEST, PRODUCTTYPERULEID, PRODUCTTYPERULE, PRODUCTTYPEID, PRODUCTTYPE,
            METALRULE,
            METAL, METALSTATERULE, METALSTATE,ACTUALTHICKSTR, ACTUALTHICKEND, ACTUALWIDTHSTR,
            ACTUALWIDTHEND,ACTUALLENGTHSTR,ACTUALLENGTHEND,ACTUALOUTMATERREQUEST)
            SELECT TENANTID, UUID(), ROPTION, DELETED, REMARK, NOW(), CREATEUSERID, NOW(), MODIFYUSERID, CREATEUSERNAME,
            MODIFYUSERNAME, DATANO, #{routeId}, #{data.id} , #{data.outputmaterialcode},#{data.outputmaterialname},
            #{data.actualoutputthickrule}, #{data.actualoutputthickchange}, #{data.actualoutputthickoffset}, #{data.actualoutputthickstr}, #{data.actualoutputthickend},  #{data.actualoutputthickremark},
            #{data.actualoutputwidthrule}, #{data.actualoutputwidthchange}, #{data.actualoutputwidthoffset},#{data.actualoutputwidthstr}, #{data.actualoutputwidthend}, #{data.actualoutputwidthremark},
            #{data.actualoutputlengthrule}, #{data.actualoutputlengthchange}, #{data.actualoutputlengthoffset},  #{data.actualoutputlengthstr}, #{data.actualoutputlengthend}, #{data.actualoutputlengthremark},
            OUTVAL,
            OUTMATERREQUEST, PRODUCTTYPERULEID, PRODUCTTYPERULE, #{data.outputproducttypeid}, #{data.outputproducttype}, METALRULE, #{data.outputmetal},
            METALSTATERULE,
            #{data.outputmetalstate},
            #{data.actualoutputthickstr},
            #{data.actualoutputthickend},
            #{data.actualoutputwidthstr},
            #{data.actualoutputwidthend},
            #{data.actualoutputlengthstr},
            #{data.actualoutputlengthend},
            #{data.actualoutmaterrequest}

            FROM aps_out_mater_request WHERE MAINID = #{data.craftstepid} and deleted='0'
        </foreach>
    </insert>

</mapper>
