<?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.ximai.mes.pro.mapper.prototypeMake.ProPrototypeMakeMapper">

    <resultMap type="proPrototypeMakeVo" id="ProPrototypeMakeResult">
        <result property="prototypeMakeId" column="prototype_make_id"/>
        <result property="prototypeMakeCode" column="prototype_make_code"/>
        <result property="prototypeRequestId" column="prototype_request_id"/>
        <result property="routeId" column="route_id"/>
        <result property="routeName" column="route_name"/>
        <result property="itemId" column="item_id"/>
        <result property="itemName" column="item_name"/>
        <result property="screenItem" column="screen_item"/>
        <result property="pibanItem" column="piban_item"/>
        <result property="diecuttingItem" column="diecutting_item"/>
        <result property="standardColor" column="standard_color"/>
        <result property="module" column="module"/>
        <result property="colNum" column="col_num"/>
        <result property="rowNum" column="row_num"/>
        <result property="buttstrapNum" column="buttstrap_num"/>
        <result property="coldoubleCutspacing" column="coldouble_cutspacing"/>
        <result property="rowdoubleCutspacing" column="rowdouble_cutspacing"/>
        <result property="sendworkMultiple" column="sendwork_multiple"/>
        <result property="printingPaperlenth" column="printing_paperlenth"/>
        <result property="printPaperwidth" column="print_paperwidth"/>
        <result property="frontColorId" column="front_color_id"/>
        <result property="oppositeColorId" column="opposite_color_id"/>
        <result property="frontColorName" column="front_color_name"/>
        <result property="oppositeColorName" column="opposite_color_name"/>
        <result property="ngReason" column="ng_reason"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="plannedFinishDate" column="planned_finish_date"/>
        <result property="length"    column="length"    />
        <result property="width"    column="width"    />
        <result property="height"    column="height"    />
        <result property="thick"    column="thick"    />
        <result property="weight"    column="weight"    />
        <result property="angleType"    column="angle_type"    />
        <result property="isAllotype"    column="is_allotype"    />
        <result property="isRightAngle"    column="is_right_angle"    />
        <result property="fillet"    column="fillet"    />
        <result property="angle"    column="angle"    />
        <result property="aperture"    column="aperture"    />
        <result property="singleLayerThick"    column="single_layer_thick"    />
        <result property="singleWeight"    column="single_weight"    />
        <result property="layerNum"    column="layer_num"    />
        <result property="isMould"    column="is_mould"    />
        <result property="isCoding"    column="is_coding"    />
        <result property="certification"    column="certification"    />
        <result property="shape"    column="shape"    />
        <result property="shapeSize"    column="shape_size"    />
        <result property="frontImg"    column="front_img"    />
        <result property="backImg"    column="back_img"    />
        <result property="abbreviation" column="abbreviation"/>
        <result property="enName" column="en_name"/>
        <result property="num" column="num"/>
        <result property="type" column="type"/>
        <result property="modality" column="modality"/>
        <result property="surfaceTreatment" column="surface_treatment"/>
        <result property="plannedFinishDate" column="planned_finish_date"/>
        <result property="plannedLayoutDate" column="planned_layout_date"/>
<!--        <result property="plannedLayoutDate" column="planned_layout_date"/>-->
<!--        <result property="prototypeMakeStatus" column="prototype_make_status"/>-->
    </resultMap>

    <sql id="selectProPrototypeMakeVo">
        select ppm.*,
               pr.route_name,
               mi.item_name,
               mc1.color_name as front_color_name,
               mc2.color_name as opposite_color_name
        from pro_prototype_make ppm
                 left join md_item mi on ppm.item_id = mi.item_id
                 left join pro_route pr on ppm.route_id = pr.route_id
        left join md_color mc1 on ppm.front_color_id = mc1.color_id
        left join md_color mc2 on ppm.opposite_color_id = mc2.color_id
    </sql>

    <select id="selectProPrototypeMakeList" parameterType="ProPrototypeMake" resultMap="ProPrototypeMakeResult">
        <include refid="selectProPrototypeMakeVo"/>
        <where>
            <if test="prototypeMakeCode != '' and prototypeMakeCode != null">and ppm.prototype_make_code =
                #{prototypeMakeCode}
            </if>
            <if test="prototypeRequestId != null ">and ppm.prototype_request_id = #{prototypeRequestId}</if>
            <if test="routeId != null ">and ppm.route_id = #{routeId}</if>
            <if test="itemId != null ">and ppm.item_id = #{itemId}</if>
            <if test="screenItem != null  and screenItem != ''">and ppm.screen_item = #{screenItem}</if>
            <if test="pibanItem != null  and pibanItem != ''">and ppm.piban_item = #{pibanItem}</if>
            <if test="diecuttingItem != null  and diecuttingItem != ''">and ppm.diecutting_item = #{diecuttingItem}</if>
            <if test="standardColor != null  and standardColor != ''">and ppm.standard_color = #{standardColor}</if>
            <if test="module != null  and module != ''">and ppm.module = #{module}</if>
            <if test="colNum != null ">and ppm.col_num = #{colNum}</if>
            <if test="rowNum != null ">and ppm.row_num = #{rowNum}</if>
            <if test="buttstrapNum != null ">and ppm.buttstrap_num = #{buttstrapNum}</if>
            <if test="coldoubleCutspacing != null  and coldoubleCutspacing != ''">and ppm.coldouble_cutspacing =
                #{coldoubleCutspacing}
            </if>
            <if test="rowdoubleCutspacing != null  and rowdoubleCutspacing != ''">and ppm.rowdouble_cutspacing =
                #{rowdoubleCutspacing}
            </if>
            <if test="sendworkMultiple != null ">and ppm.sendwork_multiple = #{sendworkMultiple}</if>
            <if test="printingPaperlenth != null ">and ppm.printing_paperlenth = #{printingPaperlenth}</if>
            <if test="printPaperwidth != null ">and ppm.print_paperwidth = #{printPaperwidth}</if>
            <if test="frontColorId != null ">and ppm.front_color_id = #{frontColorId}</if>
            <if test="oppositeColorId != null ">and ppm.opposite_color_id = #{oppositeColorId}</if>
            <if test="ngReason != null  and ngReason != ''">and ppm.ng_reason = #{ngReason}</if>
            <if test="prototypeMakeStatus != null ">and ppm.prototype_make_status = #{prototypeMakeStatus}</if>
        </where>
    </select>

    <select id="selectProPrototypeMakeByPrototypeMakeId" parameterType="Long" resultMap="ProPrototypeMakeResult">
        <include refid="selectProPrototypeMakeVo"/>
        where ppm.prototype_make_id = #{prototypeMakeId}
    </select>

    <insert id="insertProPrototypeMake" parameterType="ProPrototypeMake" useGeneratedKeys="true"
            keyProperty="prototypeMakeId">
        insert into pro_prototype_make
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="prototypeMakeCode != null">prototype_make_code,</if>
            <if test="prototypeRequestId != null">prototype_request_id,</if>
            <if test="routeId != null">route_id,</if>
            <if test="itemId != null">item_id,</if>
            <if test="screenItem != null">screen_item,</if>
            <if test="pibanItem != null">piban_item,</if>
            <if test="diecuttingItem != null">diecutting_item,</if>
            <if test="standardColor != null">standard_color,</if>
            <if test="module != null">module,</if>
            <if test="colNum != null">col_num,</if>
            <if test="rowNum != null">row_num,</if>
            <if test="buttstrapNum != null">buttstrap_num,</if>
            <if test="coldoubleCutspacing != null">coldouble_cutspacing,</if>
            <if test="rowdoubleCutspacing != null">rowdouble_cutspacing,</if>
            <if test="sendworkMultiple != null">sendwork_multiple,</if>
            <if test="printingPaperlenth != null">printing_paperlenth,</if>
            <if test="printPaperwidth != null">print_paperwidth,</if>
            <if test="frontColorId != null">front_color_id,</if>
            <if test="oppositeColorId != null">opposite_color_id,</if>
            <if test="ngReason != null">ng_reason,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="prototypeMakeStatus != null">prototype_make_status</if>
            <if test="length != null">length,</if>
            <if test="width != null">width,</if>
            <if test="height != null">height,</if>
            <if test="thick != null">thick,</if>
            <if test="weight != null">weight,</if>
            <if test="angleType != null">angle_type,</if>
            <if test="isAllotype != null">is_allotype,</if>
            <if test="isRightAngle != null">is_right_angle,</if>
            <if test="fillet != null">fillet,</if>
            <if test="angle != null">angle,</if>
            <if test="aperture != null">aperture,</if>
            <if test="singleLayerThick != null">single_layer_thick,</if>
            <if test="singleWeight != null">single_weight,</if>
            <if test="layerNum != null">layer_num,</if>
            <if test="isMould != null">is_mould,</if>
            <if test="isCoding != null">is_coding,</if>
            <if test="certification != null">certification,</if>
            <if test="shape != null">shape,</if>
            <if test="shapeSize != null">shape_size,</if>
            <if test="frontImg != null">front_img,</if>
            <if test="backImg != null">back_img,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="prototypeMakeCode != null">#{prototypeMakeCode},</if>
            <if test="prototypeRequestId != null">#{prototypeRequestId},</if>
            <if test="routeId != null">#{routeId},</if>
            <if test="itemId != null">#{itemId},</if>
            <if test="screenItem != null">#{screenItem},</if>
            <if test="pibanItem != null">#{pibanItem},</if>
            <if test="diecuttingItem != null">#{diecuttingItem},</if>
            <if test="standardColor != null">#{standardColor},</if>
            <if test="module != null">#{module},</if>
            <if test="colNum != null">#{colNum},</if>
            <if test="rowNum != null">#{rowNum},</if>
            <if test="buttstrapNum != null">#{buttstrapNum},</if>
            <if test="coldoubleCutspacing != null">#{coldoubleCutspacing},</if>
            <if test="rowdoubleCutspacing != null">#{rowdoubleCutspacing},</if>
            <if test="sendworkMultiple != null">#{sendworkMultiple},</if>
            <if test="printingPaperlenth != null">#{printingPaperlenth},</if>
            <if test="printPaperwidth != null">#{printPaperwidth},</if>
            <if test="frontColorId != null">#{frontColorId},</if>
            <if test="oppositeColorId != null">#{oppositeColorId},</if>
            <if test="ngReason != null">#{ngReason},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="prototypeMakeStatus != null">#{prototypeMakeStatus},</if>
            <if test="length != null">#{length},</if>
            <if test="width != null">#{width},</if>
            <if test="height != null">#{height},</if>
            <if test="thick != null">#{thick},</if>
            <if test="weight != null">#{weight},</if>
            <if test="angleType != null">#{angleType},</if>
            <if test="isAllotype != null">#{isAllotype},</if>
            <if test="isRightAngle != null">#{isRightAngle},</if>
            <if test="fillet != null">#{fillet},</if>
            <if test="angle != null">#{angle},</if>
            <if test="aperture != null">#{aperture},</if>
            <if test="singleLayerThick != null">#{singleLayerThick},</if>
            <if test="singleWeight != null">#{singleWeight},</if>
            <if test="layerNum != null">#{layerNum},</if>
            <if test="isMould != null">#{isMould},</if>
            <if test="isCoding != null">#{isCoding},</if>
            <if test="certification != null">#{certification},</if>
            <if test="shape != null">#{shape},</if>
            <if test="shapeSize != null">#{shapeSize},</if>
            <if test="frontImg != null">#{frontImg},</if>
            <if test="backImg != null">#{backImg},</if>
        </trim>
    </insert>

    <update id="updateProPrototypeMake" parameterType="ProPrototypeMake">
        update pro_prototype_make
        <trim prefix="SET" suffixOverrides=",">
            <if test="prototypeMakeCode != null">prototype_make_code = #{prototypeMakeCode},</if>
            <if test="prototypeRequestId != null">prototype_request_id = #{prototypeRequestId},</if>
            <if test="routeId != null">route_id = #{routeId},</if>
            <if test="itemId != null">item_id = #{itemId},</if>
            <if test="screenItem != null">screen_item = #{screenItem},</if>
            <if test="pibanItem != null">piban_item = #{pibanItem},</if>
            <if test="diecuttingItem != null">diecutting_item = #{diecuttingItem},</if>
            <if test="standardColor != null">standard_color = #{standardColor},</if>
            <if test="module != null">module = #{module},</if>
            <if test="colNum != null">col_num = #{colNum},</if>
            <if test="rowNum != null">row_num = #{rowNum},</if>
            <if test="buttstrapNum != null">buttstrap_num = #{buttstrapNum},</if>
            <if test="coldoubleCutspacing != null">coldouble_cutspacing = #{coldoubleCutspacing},</if>
            <if test="rowdoubleCutspacing != null">rowdouble_cutspacing = #{rowdoubleCutspacing},</if>
            <if test="sendworkMultiple != null">sendwork_multiple = #{sendworkMultiple},</if>
            <if test="printingPaperlenth != null">printing_paperlenth = #{printingPaperlenth},</if>
            <if test="printPaperwidth != null">print_paperwidth = #{printPaperwidth},</if>
            <if test="frontColorId != null">front_color_id = #{frontColorId},</if>
            <if test="oppositeColorId != null">opposite_color_id = #{oppositeColorId},</if>
            <if test="ngReason != null">ng_reason = #{ngReason},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="prototypeMakeStatus != null">prototype_make_status = #{prototypeMakeStatus},</if>
            <if test="length != null">length = #{length},</if>
            <if test="width != null">width = #{width},</if>
            <if test="height != null">height = #{height},</if>
            <if test="thick != null">thick = #{thick},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="angleType != null">angle_type = #{angleType},</if>
            <if test="isAllotype != null">is_allotype = #{isAllotype},</if>
            <if test="isRightAngle != null">is_right_angle = #{isRightAngle},</if>
            <if test="fillet != null">fillet = #{fillet},</if>
            <if test="angle != null">angle = #{angle},</if>
            <if test="aperture != null">aperture = #{aperture},</if>
            <if test="singleLayerThick != null">single_layer_thick = #{singleLayerThick},</if>
            <if test="singleWeight != null">single_weight = #{singleWeight},</if>
            <if test="layerNum != null">layer_num = #{layerNum},</if>
            <if test="isMould != null">is_mould = #{isMould},</if>
            <if test="isCoding != null">is_coding = #{isCoding},</if>
            <if test="certification != null">certification = #{certification},</if>
            <if test="shape != null">shape = #{shape},</if>
            <if test="shapeSize != null">shape_size = #{shapeSize},</if>
            <if test="frontImg != null">front_img = #{frontImg},</if>
            <if test="backImg != null">back_img = #{backImg},</if>
        </trim>
        where prototype_make_id = #{prototypeMakeId}
    </update>

    <delete id="deleteProPrototypeMakeByPrototypeMakeId" parameterType="Long">
        delete
        from pro_prototype_make
        where prototype_make_id = #{prototypeMakeId}
    </delete>

    <delete id="deleteProPrototypeMakeByPrototypeMakeIds" parameterType="String">
        delete from pro_prototype_make where prototype_make_id in
        <foreach item="prototypeMakeId" collection="array" open="(" separator="," close=")">
            #{prototypeMakeId}
        </foreach>
    </delete>
    <update id="updateProPrototypeMakeStatus">
        update pro_prototype_make
        set prototype_make_status = #{prototypeMakeStatus}
        where prototype_make_id = #{prototypeMakeId}
    </update>
</mapper>
