<?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.foreverwin.mesnac.production.mapper.SfcDataAssembleMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.production.model.SfcDataAssemble">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="SFC_DISPATCH_BO" property="sfcDispatchBo" />
        <result column="STATUS" property="status" />
        <result column="INVENTORY_BO" property="inventoryBo" />
        <result column="ASSEMBLE_QTY" property="assembleQty" />
        <result column="ITEM_BO" property="itemBo" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="CREATED_USER" property="createdUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="MODIFY_USER" property="modifyUser" />
        <result column="SEQ" property="seq" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, SFC_DISPATCH_BO, STATUS, INVENTORY_BO, ASSEMBLE_QTY, ITEM_BO, CREATED_DATE_TIME, CREATED_USER, MODIFIED_DATE_TIME, MODIFY_USER, SEQ
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="selectById" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE=#{handle}
    </select>

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_SFC_DATA_ASSEMBLE
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </select>

    <select id="selectBatchIds" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </select>

    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
            <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
            <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
            <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
            <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
            <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
            <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                <if test="ew.entity.handle!=null">
                    HANDLE=#{ew.entity.handle}
                </if>
                <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMaps" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectObjs" resultType="Object">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <insert id="insert" parameterType="com.foreverwin.mesnac.production.model.SfcDataAssemble">
        INSERT INTO Z_SFC_DATA_ASSEMBLE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="sfcDispatchBo!=null">SFC_DISPATCH_BO,</if>
            <if test="status!=null">STATUS,</if>
            <if test="inventoryBo!=null">INVENTORY_BO,</if>
            <if test="assembleQty!=null">ASSEMBLE_QTY,</if>
            <if test="itemBo!=null">ITEM_BO,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="createdUser!=null">CREATED_USER,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="modifyUser!=null">MODIFY_USER,</if>
            <if test="seq!=null">SEQ,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="sfcDispatchBo!=null">#{sfcDispatchBo},</if>
            <if test="status!=null">#{status},</if>
            <if test="inventoryBo!=null">#{inventoryBo},</if>
            <if test="assembleQty!=null">#{assembleQty},</if>
            <if test="itemBo!=null">#{itemBo},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="createdUser!=null">#{createdUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="modifyUser!=null">#{modifyUser},</if>
            <if test="seq!=null">#{seq},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.production.model.SfcDataAssemble">
        INSERT INTO Z_SFC_DATA_ASSEMBLE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{sfcDispatchBo},
            #{status},
            #{inventoryBo},
            #{assembleQty},
            #{itemBo},
            #{createdDateTime},
            #{createdUser},
            #{modifiedDateTime},
            #{modifyUser},
            #{seq},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.inventoryBo!=null">INVENTORY_BO=#{et.inventoryBo},</if>
        <if test="et.assembleQty!=null">ASSEMBLE_QTY=#{et.assembleQty},</if>
        <if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.seq!=null">SEQ=#{et.seq},</if>
        </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="updateAllColumnById">
        UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        SFC_DISPATCH_BO=#{et.sfcDispatchBo},
        STATUS=#{et.status},
        INVENTORY_BO=#{et.inventoryBo},
        ASSEMBLE_QTY=#{et.assembleQty},
        ITEM_BO=#{et.itemBo},
        CREATED_DATE_TIME=#{et.createdDateTime},
        CREATED_USER=#{et.createdUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
        MODIFY_USER=#{et.modifyUser},
        SEQ=#{et.seq},
     </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="update">
        UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.inventoryBo!=null">INVENTORY_BO=#{et.inventoryBo},</if>
        <if test="et.assembleQty!=null">ASSEMBLE_QTY=#{et.assembleQty},</if>
        <if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.seq!=null">SEQ=#{et.seq},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </update>

    <delete id="deleteById">
        DELETE FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_SFC_DATA_ASSEMBLE
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </delete>

    <delete id="delete">
        DELETE FROM Z_SFC_DATA_ASSEMBLE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
                    <if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </delete>

    <delete id="deleteBatchIds">
        DELETE FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="querySfcAssemble" resultType="map">
        WITH SFC_DATA AS(
            SELECT DA.ITEM_BO,DA.SEQ, SUM(DA.ASSEMBLE_QTY) ASSEMBLE_QTY FROM Z_SFC_DATA_ASSEMBLE DA
            WHERE DA.SFC_DISPATCH_BO = #{sfcDispatchBo}
            GROUP BY DA.ITEM_BO, DA.SEQ
        )
        SELECT '物料：'||I.ITEM||'/'||I.REVISION||N'      数量：'|| S.QTY * BC.QTY  ITEM_REVISION,
            S.QTY * BC.QTY QTY,NVL(SD.ASSEMBLE_QTY,0) ASSEMBLE_QTY,I.HANDLE ITEM_BO,I.ITEM,IT.DESCRIPTION ITEM_DESC,
            CASE WHEN NVL(SD.ASSEMBLE_QTY,0) = 0 THEN 'WHITE'
                WHEN NVL(SD.ASSEMBLE_QTY,0) = S.QTY * BC.QTY THEN 'GREEN'
            ELSE 'YELLOW' END IS_ASSEMBLE,BC.HANDLE BOM_COMPONENT_BO, BC."SEQUENCE"  SEQ
        FROM Z_SFC_DISPATCH DM
        INNER JOIN SFC S ON S.SITE = DM.SITE AND S.SFC = DM.SFC
        INNER JOIN SFC_BOM SB ON SB.SFC_BO = S.HANDLE
        INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SB.BOM_BO
        INNER JOIN ITEM I ON I.HANDLE = BC.COMPONENT_GBO
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE ='zh'
        INNER JOIN CUSTOM_FIELDS I_CF ON I_CF.HANDLE = I.HANDLE AND I_CF."ATTRIBUTE" = 'ACCESSORY_TYPE' AND I_CF.VALUE ='9'
        INNER JOIN CUSTOM_FIELDS CF ON CF.HANDLE = BC.HANDLE AND CF."ATTRIBUTE" = 'STEP_ID' AND CF.VALUE = DM.STEP_ID
        LEFT JOIN SFC_DATA SD ON SD.ITEM_BO = I.HANDLE AND BC."SEQUENCE" = SD.SEQ
        WHERE DM.HANDLE = #{sfcDispatchBo}
    </select>
</mapper>
