<?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.common.mapper.PrintLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.common.model.PrintLog">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="CATEGORY" property="category" />
        <result column="PRINT_NAME" property="printName" />
        <result column="PRINT_TEMPLATE" property="printTemplate" />
        <result column="PRINT_PARAM" property="printParam" />
        <result column="SFC" property="sfc" />
        <result column="RESRCE" property="resrce" />
        <result column="STEP_ID" property="stepId" />
        <result column="OPERATION" property="operation" />
        <result column="INVENTORY" property="inventory" />
        <result column="ITEM_BO" property="itemBo" />
        <result column="ITEM" property="item" />
        <result column="ITEM_DESCRIPTION" property="itemDescription" />
        <result column="COMMENTS" property="comments" />
        <result column="IS_PRINT" property="isPrint" />
        <result column="PRINT_NUM" property="printNum" />
        <result column="OTHER_1" property="other1" />
        <result column="OTHER_2" property="other2" />
        <result column="OTHER_3" property="other3" />
        <result column="OTHER_4" property="other4" />
        <result column="OTHER_5" property="other5" />
        <result column="CREATE_USER" property="createUser" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFY_USER" property="modifyUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, CATEGORY, PRINT_NAME, PRINT_TEMPLATE, PRINT_PARAM, SFC, RESRCE, STEP_ID, OPERATION, INVENTORY, ITEM_BO, COMMENTS, IS_PRINT, PRINT_NUM, OTHER_1, OTHER_2, OTHER_3, OTHER_4, OTHER_5, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_PRINT_LOG
        <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="selectList" resultMap="BaseResultMap">
        SELECT  ZL.HANDLE, ZL.SITE, ZL.CATEGORY, ZL.PRINT_NAME, ZL.PRINT_TEMPLATE, ZL.PRINT_PARAM, ZL.SFC, ZL.RESRCE, ZL.STEP_ID, ZL.OPERATION, ZL.INVENTORY, ZL.ITEM_BO, IM.ITEM, IT.DESCRIPTION ITEM_DESCRIPTION, ZL.COMMENTS, ZL.IS_PRINT, ZL.PRINT_NUM, ZL.CREATE_USER, ZL.CREATED_DATE_TIME, ZL.MODIFY_USER, ZL.MODIFIED_DATE_TIME
        FROM Z_PRINT_LOG ZL
        LEFT JOIN ITEM IM ON ZL.ITEM_BO = IM.HANDLE
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        ZL.HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND ZL.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.category!=null"> AND ZL.CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND ZL.PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND ZL.PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.sfc!=null"> AND ZL.SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND ZL.RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND ZL.STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND ZL.OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND ZL.INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ZL.ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND ZL.COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND ZL.IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND ZL.PRINT_NUM=#{ew.entity.printNum}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    AND ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            AND ${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_PRINT_LOG
        <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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_PRINT_LOG
        <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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_PRINT_LOG
        <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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_PRINT_LOG
        <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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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.common.model.PrintLog">
        INSERT INTO Z_PRINT_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="category!=null">CATEGORY,</if>
            <if test="printName!=null">PRINT_NAME,</if>
            <if test="printTemplate!=null">PRINT_TEMPLATE,</if>
            <if test="printParam!=null">PRINT_PARAM,</if>
            <if test="sfc!=null">SFC,</if>
            <if test="resrce!=null">RESRCE,</if>
            <if test="stepId!=null">STEP_ID,</if>
            <if test="operation!=null">OPERATION,</if>
            <if test="inventory!=null">INVENTORY,</if>
            <if test="itemBo!=null">ITEM_BO,</if>
            <if test="comments!=null">COMMENTS,</if>
            <if test="isPrint!=null">IS_PRINT,</if>
            <if test="printNum!=null">PRINT_NUM,</if>
            <if test="other1!=null">OTHER_1,</if>
            <if test="other2!=null">OTHER_2,</if>
            <if test="other3!=null">OTHER_3,</if>
            <if test="other4!=null">OTHER_4,</if>
            <if test="other5!=null">OTHER_5,</if>
            <if test="createUser!=null">CREATE_USER,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifyUser!=null">MODIFY_USER,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="category!=null">#{category},</if>
            <if test="printName!=null">#{printName},</if>
            <if test="printTemplate!=null">#{printTemplate},</if>
            <if test="printParam!=null">#{printParam},</if>
            <if test="sfc!=null">#{sfc},</if>
            <if test="resrce!=null">#{resrce},</if>
            <if test="stepId!=null">#{stepId},</if>
            <if test="operation!=null">#{operation},</if>
            <if test="inventory!=null">#{inventory},</if>
            <if test="itemBo!=null">#{itemBo},</if>
            <if test="comments!=null">#{comments},</if>
            <if test="isPrint!=null">#{isPrint},</if>
            <if test="printNum!=null">#{printNum},</if>
            <if test="other1!=null">#{other1},</if>
            <if test="other2!=null">#{other2},</if>
            <if test="other3!=null">#{other3},</if>
            <if test="other4!=null">#{other4},</if>
            <if test="other5!=null">#{other5},</if>
            <if test="createUser!=null">#{createUser},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifyUser!=null">#{modifyUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.common.model.PrintLog">
        INSERT INTO Z_PRINT_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{category},
            #{printName},
            #{printTemplate},
            #{printParam},
            #{sfc},
            #{resrce},
            #{stepId},
            #{operation},
            #{inventory},
            #{itemBo},
            #{comments},
            #{isPrint},
            #{printNum},
            #{other1},
            #{other2},
            #{other3},
            #{other4},
            #{other5},
            #{createUser},
            #{createdDateTime},
            #{modifyUser},
            #{modifiedDateTime},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_PRINT_LOG <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.category!=null">CATEGORY=#{et.category},</if>
        <if test="et.printName!=null">PRINT_NAME=#{et.printName},</if>
        <if test="et.printTemplate!=null">PRINT_TEMPLATE=#{et.printTemplate},</if>
        <if test="et.printParam!=null">PRINT_PARAM=#{et.printParam},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.inventory!=null">INVENTORY=#{et.inventory},</if>
        <if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
        <if test="et.comments!=null">COMMENTS=#{et.comments},</if>
        <if test="et.isPrint!=null">IS_PRINT=#{et.isPrint},</if>
        <if test="et.printNum!=null">PRINT_NUM=#{et.printNum},</if>
        <if test="et.other1!=null">OTHER_1=#{et.other1},</if>
        <if test="et.other2!=null">OTHER_2=#{et.other2},</if>
        <if test="et.other3!=null">OTHER_3=#{et.other3},</if>
        <if test="et.other4!=null">OTHER_4=#{et.other4},</if>
        <if test="et.other5!=null">OTHER_5=#{et.other5},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</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_PRINT_LOG <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        CATEGORY=#{et.category},
        PRINT_NAME=#{et.printName},
        PRINT_TEMPLATE=#{et.printTemplate},
        PRINT_PARAM=#{et.printParam},
        SFC=#{et.sfc},
        RESRCE=#{et.resrce},
        STEP_ID=#{et.stepId},
        OPERATION=#{et.operation},
        INVENTORY=#{et.inventory},
        ITEM_BO=#{et.itemBo},
        COMMENTS=#{et.comments},
        IS_PRINT=#{et.isPrint},
        PRINT_NUM=#{et.printNum},
        OTHER_1=#{et.other1},
        OTHER_2=#{et.other2},
        OTHER_3=#{et.other3},
        OTHER_4=#{et.other4},
        OTHER_5=#{et.other5},
        CREATE_USER=#{et.createUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFY_USER=#{et.modifyUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
     </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_PRINT_LOG <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.category!=null">CATEGORY=#{et.category},</if>
        <if test="et.printName!=null">PRINT_NAME=#{et.printName},</if>
        <if test="et.printTemplate!=null">PRINT_TEMPLATE=#{et.printTemplate},</if>
        <if test="et.printParam!=null">PRINT_PARAM=#{et.printParam},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.inventory!=null">INVENTORY=#{et.inventory},</if>
        <if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
        <if test="et.comments!=null">COMMENTS=#{et.comments},</if>
        <if test="et.isPrint!=null">IS_PRINT=#{et.isPrint},</if>
        <if test="et.printNum!=null">PRINT_NUM=#{et.printNum},</if>
        <if test="et.other1!=null">OTHER_1=#{et.other1},</if>
        <if test="et.other2!=null">OTHER_2=#{et.other2},</if>
        <if test="et.other3!=null">OTHER_3=#{et.other3},</if>
        <if test="et.other4!=null">OTHER_4=#{et.other4},</if>
        <if test="et.other5!=null">OTHER_5=#{et.other5},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_PRINT_LOG WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_PRINT_LOG
        <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_PRINT_LOG
        <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.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.printName!=null"> AND PRINT_NAME=#{ew.entity.printName}</if>
                    <if test="ew.entity.printTemplate!=null"> AND PRINT_TEMPLATE=#{ew.entity.printTemplate}</if>
                    <if test="ew.entity.printParam!=null"> AND PRINT_PARAM=#{ew.entity.printParam}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
                    <if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
                    <if test="ew.entity.comments!=null"> AND COMMENTS=#{ew.entity.comments}</if>
                    <if test="ew.entity.isPrint!=null"> AND IS_PRINT=#{ew.entity.isPrint}</if>
                    <if test="ew.entity.printNum!=null"> AND PRINT_NUM=#{ew.entity.printNum}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_PRINT_LOG WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->

    <!--自定义sql-->
    <select id="getPrintLogListByCondition" resultMap="BaseResultMap">
        SELECT PL.*, I.ITEM ,IT.DESCRIPTION ITEM_DESCRIPTION FROM Z_PRINT_LOG PL
        LEFT JOIN ITEM I ON I.HANDLE = PL.ITEM_BO
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE
        WHERE PL.SITE = #{site}
        <if test="startFromDate != null">
            AND PL.CREATED_DATE_TIME >= #{startFromDate}
        </if>
        <if test="startToDate != null">
            AND PL.CREATED_DATE_TIME &lt;= #{startToDate}
        </if>
        <if test="isPrint != null and isPrint != ''">
            AND PL.IS_PRINT = #{isPrint}
        </if>
        <if test="category != null and category != ''">
            AND PL.CATEGORY = #{category}
        </if>
        <if test="inventory != null and inventory != ''">
            AND PL.INVENTORY = #{inventory}
        </if>
        <if test="sfc != null and sfc != ''">
            AND PL.SFC = #{sfc}
        </if>
        <if test="item != null and item != ''">
            AND I.ITEM = #{item}
        </if>
        ORDER BY PL.CREATED_DATE_TIME DESC
    </select>

    <!--根据sfcBo，查询当前条码的打印信息-->
    <select id="findSfcPrintInfoBySfc" resultType="com.foreverwin.mesnac.common.dto.LabelPrintDto">
        SELECT  IM.ITEM ,S.SFC, IT.DESCRIPTION ITEM_DESCRIPTION, ZSD.SHOP_ORDER,
               I.QTY_ON_HAND QTY ,ZSD.BLANKING_SIZE , CF.VALUE DRAWING_REVISION
        FROM INVENTORY I
            LEFT JOIN SFC S ON I.INVENTORY_CONTEXT_GBO = S.HANDLE
            LEFT JOIN
                (SELECT MAX(STEP_ID),BLANKING_SIZE,SFC,SHOP_ORDER FROM Z_SFC_DISPATCH
                WHERE SFC = #{sfc} AND SITE = #{site} GROUP BY BLANKING_SIZE ,SFC,SHOP_ORDER) ZSD ON ZSD.SFC = S.SFC
            LEFT JOIN ITEM IM ON IM.HANDLE = I.ITEM_BO
            LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
            LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = I.ITEM_BO AND CF."ATTRIBUTE" = 'DRAWING_REVISION'
        WHERE S.SFC = #{sfc} AND I.SITE = #{site}
    </select>
    <!--自定义sql-->


</mapper>
