<?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.anomaly.mapper.AbnormalBillDisposeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.anomaly.model.AbnormalBillDispose">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="ABNORMAL_BILL_BO" property="abnormalBillBo" />
        <result column="DUTY_USER" property="dutyUser" />
        <result column="DUTY_DATE_TIME" property="dutyDateTime" />
        <result column="DUTY_DEPART" property="dutyDepart" />
        <result column="DUTY_TYPE" property="dutyType" />
        <result column="PRINCIPAL_USER" property="principalUser" />
        <result column="DUTY_CAUSE_DESCRIPTION" property="dutyCauseDescription" />
        <result column="DUTY_CAUSE_TYPE" property="dutyCauseType" />
        <result column="DUTY_SEND_USER_GROUP" property="dutySendUserGroup" />
        <result column="RESOLVE_USER" property="resolveUser" />
        <result column="RESOLVE_DATE_TIME" property="resolveDateTime" />
        <result column="ABNORMAL_METHOD" property="abnormalMethod" />
        <result column="ROUTER_BO" property="routerBo" />
        <result column="RESOLVE_SHOP_ORDER" property="resolveShopOrder" />
        <result column="RESOLVE_REMARK" property="resolveRemark" />
        <result column="RESOLVE_SEND_USER_GROUP" property="resolveSendUserGroup" />
        <result column="CLOSED_USER" property="closedUser" />
        <result column="CLOSED_DATE_TIME" property="closedDateTime" />
        <result column="ABNORMAL_REASON" property="abnormalReason" />
        <result column="BEFORE_MEASURE" property="beforeMeasure" />
        <result column="CREATED_USER" property="createdUser" />
        <result column="CREATED_DATA_TIME" property="createdDataTime" />
        <result column="MODIFIED_USER" property="modifiedUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
    </resultMap>



    <!--质量异常响应界面检索用-->
    <resultMap id="AbnormalBillDisposeDto" type="com.foreverwin.mesnac.anomaly.dto.AbnormalBillDisposeDto" extends="BaseResultMap">
        <result column="ABNORMAL_NO" property="abnormalNo"/>
        <result column="STATUS" property="status"/>
        <result column="ITEM" property="item"/>
        <result column="ITEM_BO" property="itemBo"/>
        <result column="ITEM_DESCRIPTION" property="itemDescription"/>
        <result column="TYPE" property="type"/>
        <result column="SFC" property="sfc"/>
        <result column="MESSAGE_TYPE" property="messageType"/>
        <result column="SHOP_ORDER" property="shopOrder"/>
        <result column="WORK_CENTER" property="workCenter"/>
        <result column="RESRCE" property="resrce"/>
        <result column="WORK_ORDER" property="workOrder"/>
        <result column="ITEM_NUMBER" property="itemNumber"/>
        <result column="NC_CODE" property="ncCode"/>
        <result column="NC_CODE_DESCRIPTION" property="ncCodeDescription"/>
        <result column="PRODUCT_CATEGORY" property="productCategory"/>
        <result column="MAP" property="map"/>
        <result column="PB_DESCRIPTION" property="pbDescription"/>
        <result column="NC_QTY" property="ncQty"/>
        <result column="PB_GRADE" property="pbGrade"/>
        <result column="PB_USER" property="pbUser"/>
        <result column="PB_QTY" property="pbQty"/>
        <result column="DISCOVER" property="discover"/>
        <result column="INSPECTOR" property="inspector"/>
        <result column="ENTITY_LOCATION" property="entityLocation"/>
        <result column="REPORT_FROM" property="reportFrom"/>
        <result column="OBJECT_BO" property="objectBo"/>
        <result column="PB_PHOTOSHOP" property="pbPhotoShop"/>
        <result column="ROUTER" property="router"/>
        <result column="RESRCE_DESCRIPTION" property="resrceDescription"/>
        <result column="FULL_NAME" property="fullName"/>
        <result column="OPERATION" property="operation"/>
        <result column="OPERATION_DESCRIPTION" property="operationDescription"/>
        <result column="REPORT_SEND_USER_GROUP" property="reportSendUserGroup"/>
        <result column="CORRECTION" property="correction"/>
        <result column="PROGRAM" property="program"/>
        <result column="WORK_CENTER_DESCRIPTION" property="workCenterDescription"/>
        <result column="SHUT_DOWN" property="shutDown" />
        <result column="DUTY_DEPART" property="dutyDepart"/>
        <result column="DUTY_TYPE" property="dutyType"/>
        <result column="DUTY_CAUSE_TYPE" property="dutyCauseType"/>
        <result column="ROUTER_DESCRIPTION" property="routerDescription"/>
    </resultMap>



    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, ABNORMAL_BILL_BO, DUTY_USER, DUTY_DATE_TIME, DUTY_DEPART, DUTY_TYPE, PRINCIPAL_USER, DUTY_CAUSE_DESCRIPTION, DUTY_CAUSE_TYPE, DUTY_SEND_USER_GROUP, RESOLVE_USER, RESOLVE_DATE_TIME, ABNORMAL_METHOD, ROUTER_BO, RESOLVE_SHOP_ORDER, RESOLVE_REMARK, RESOLVE_SEND_USER_GROUP, CLOSED_USER, CLOSED_DATE_TIME, ABNORMAL_REASON, BEFORE_MEASURE, CREATED_USER, CREATED_DATA_TIME, MODIFIED_USER, MODIFIED_DATE_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_ABNORMAL_BILL_DISPOSE
        <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_ABNORMAL_BILL_DISPOSE 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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
            <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
            <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
            <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
            <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
            <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
            <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
            <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
            <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
            <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
            <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
            <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
            <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
            <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
            <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
            <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
            <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
            <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
            <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
            <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
            <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
            <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
            <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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="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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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="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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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.anomaly.model.AbnormalBillDispose">
        INSERT INTO Z_ABNORMAL_BILL_DISPOSE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="abnormalBillBo!=null">ABNORMAL_BILL_BO,</if>
            <if test="dutyUser!=null">DUTY_USER,</if>
            <if test="dutyDateTime!=null">DUTY_DATE_TIME,</if>
            <if test="dutyDepart!=null">DUTY_DEPART,</if>
            <if test="dutyType!=null">DUTY_TYPE,</if>
            <if test="principalUser!=null">PRINCIPAL_USER,</if>
            <if test="dutyCauseDescription!=null">DUTY_CAUSE_DESCRIPTION,</if>
            <if test="dutyCauseType!=null">DUTY_CAUSE_TYPE,</if>
            <if test="dutySendUserGroup!=null">DUTY_SEND_USER_GROUP,</if>
            <if test="resolveUser!=null">RESOLVE_USER,</if>
            <if test="resolveDateTime!=null">RESOLVE_DATE_TIME,</if>
            <if test="abnormalMethod!=null">ABNORMAL_METHOD,</if>
            <if test="routerBo!=null">ROUTER_BO,</if>
            <if test="resolveShopOrder!=null">RESOLVE_SHOP_ORDER,</if>
            <if test="resolveRemark!=null">RESOLVE_REMARK,</if>
            <if test="resolveSendUserGroup!=null">RESOLVE_SEND_USER_GROUP,</if>
            <if test="closedUser!=null">CLOSED_USER,</if>
            <if test="closedDateTime!=null">CLOSED_DATE_TIME,</if>
            <if test="abnormalReason!=null">ABNORMAL_REASON,</if>
            <if test="beforeMeasure!=null">BEFORE_MEASURE,</if>
            <if test="createdUser!=null">CREATED_USER,</if>
            <if test="createdDataTime!=null">CREATED_DATA_TIME,</if>
            <if test="modifiedUser!=null">MODIFIED_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="abnormalBillBo!=null">#{abnormalBillBo},</if>
            <if test="dutyUser!=null">#{dutyUser},</if>
            <if test="dutyDateTime!=null">#{dutyDateTime},</if>
            <if test="dutyDepart!=null">#{dutyDepart},</if>
            <if test="dutyType!=null">#{dutyType},</if>
            <if test="principalUser!=null">#{principalUser},</if>
            <if test="dutyCauseDescription!=null">#{dutyCauseDescription},</if>
            <if test="dutyCauseType!=null">#{dutyCauseType},</if>
            <if test="dutySendUserGroup!=null">#{dutySendUserGroup},</if>
            <if test="resolveUser!=null">#{resolveUser},</if>
            <if test="resolveDateTime!=null">#{resolveDateTime},</if>
            <if test="abnormalMethod!=null">#{abnormalMethod},</if>
            <if test="routerBo!=null">#{routerBo},</if>
            <if test="resolveShopOrder!=null">#{resolveShopOrder},</if>
            <if test="resolveRemark!=null">#{resolveRemark},</if>
            <if test="resolveSendUserGroup!=null">#{resolveSendUserGroup},</if>
            <if test="closedUser!=null">#{closedUser},</if>
            <if test="closedDateTime!=null">#{closedDateTime},</if>
            <if test="abnormalReason!=null">#{abnormalReason},</if>
            <if test="beforeMeasure!=null">#{beforeMeasure},</if>
            <if test="createdUser!=null">#{createdUser},</if>
            <if test="createdDataTime!=null">#{createdDataTime},</if>
            <if test="modifiedUser!=null">#{modifiedUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.anomaly.model.AbnormalBillDispose">
        INSERT INTO Z_ABNORMAL_BILL_DISPOSE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{abnormalBillBo},
            #{dutyUser},
            #{dutyDateTime},
            #{dutyDepart},
            #{dutyType},
            #{principalUser},
            #{dutyCauseDescription},
            #{dutyCauseType},
            #{dutySendUserGroup},
            #{resolveUser},
            #{resolveDateTime},
            #{abnormalMethod},
            #{routerBo},
            #{resolveShopOrder},
            #{resolveRemark},
            #{resolveSendUserGroup},
            #{closedUser},
            #{closedDateTime},
            #{abnormalReason},
            #{beforeMeasure},
            #{createdUser},
            #{createdDataTime},
            #{modifiedUser},
            #{modifiedDateTime},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_ABNORMAL_BILL_DISPOSE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.abnormalBillBo!=null">ABNORMAL_BILL_BO=#{et.abnormalBillBo},</if>
        <if test="et.dutyUser!=null">DUTY_USER=#{et.dutyUser},</if>
        <if test="et.dutyDateTime!=null">DUTY_DATE_TIME=#{et.dutyDateTime},</if>
        <if test="et.dutyDepart!=null">DUTY_DEPART=#{et.dutyDepart},</if>
        <if test="et.dutyType!=null">DUTY_TYPE=#{et.dutyType},</if>
        <if test="et.principalUser!=null">PRINCIPAL_USER=#{et.principalUser},</if>
        <if test="et.dutyCauseDescription!=null">DUTY_CAUSE_DESCRIPTION=#{et.dutyCauseDescription},</if>
        <if test="et.dutyCauseType!=null">DUTY_CAUSE_TYPE=#{et.dutyCauseType},</if>
        <if test="et.dutySendUserGroup!=null">DUTY_SEND_USER_GROUP=#{et.dutySendUserGroup},</if>
        <if test="et.resolveUser!=null">RESOLVE_USER=#{et.resolveUser},</if>
        <if test="et.resolveDateTime!=null">RESOLVE_DATE_TIME=#{et.resolveDateTime},</if>
        <if test="et.abnormalMethod!=null">ABNORMAL_METHOD=#{et.abnormalMethod},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.resolveShopOrder!=null">RESOLVE_SHOP_ORDER=#{et.resolveShopOrder},</if>
        <if test="et.resolveRemark!=null">RESOLVE_REMARK=#{et.resolveRemark},</if>
        <if test="et.resolveSendUserGroup!=null">RESOLVE_SEND_USER_GROUP=#{et.resolveSendUserGroup},</if>
        <if test="et.closedUser!=null">CLOSED_USER=#{et.closedUser},</if>
        <if test="et.closedDateTime!=null">CLOSED_DATE_TIME=#{et.closedDateTime},</if>
        <if test="et.abnormalReason!=null">ABNORMAL_REASON=#{et.abnormalReason},</if>
        <if test="et.beforeMeasure!=null">BEFORE_MEASURE=#{et.beforeMeasure},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.createdDataTime!=null">CREATED_DATA_TIME=#{et.createdDataTime},</if>
        <if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</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_ABNORMAL_BILL_DISPOSE <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        ABNORMAL_BILL_BO=#{et.abnormalBillBo},
        DUTY_USER=#{et.dutyUser},
        DUTY_DATE_TIME=#{et.dutyDateTime},
        DUTY_DEPART=#{et.dutyDepart},
        DUTY_TYPE=#{et.dutyType},
        PRINCIPAL_USER=#{et.principalUser},
        DUTY_CAUSE_DESCRIPTION=#{et.dutyCauseDescription},
        DUTY_CAUSE_TYPE=#{et.dutyCauseType},
        DUTY_SEND_USER_GROUP=#{et.dutySendUserGroup},
        RESOLVE_USER=#{et.resolveUser},
        RESOLVE_DATE_TIME=#{et.resolveDateTime},
        ABNORMAL_METHOD=#{et.abnormalMethod},
        ROUTER_BO=#{et.routerBo},
        RESOLVE_SHOP_ORDER=#{et.resolveShopOrder},
        RESOLVE_REMARK=#{et.resolveRemark},
        RESOLVE_SEND_USER_GROUP=#{et.resolveSendUserGroup},
        CLOSED_USER=#{et.closedUser},
        CLOSED_DATE_TIME=#{et.closedDateTime},
        ABNORMAL_REASON=#{et.abnormalReason},
        BEFORE_MEASURE=#{et.beforeMeasure},
        CREATED_USER=#{et.createdUser},
        CREATED_DATA_TIME=#{et.createdDataTime},
        MODIFIED_USER=#{et.modifiedUser},
        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_ABNORMAL_BILL_DISPOSE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.abnormalBillBo!=null">ABNORMAL_BILL_BO=#{et.abnormalBillBo},</if>
        <if test="et.dutyUser!=null">DUTY_USER=#{et.dutyUser},</if>
        <if test="et.dutyDateTime!=null">DUTY_DATE_TIME=#{et.dutyDateTime},</if>
        <if test="et.dutyDepart!=null">DUTY_DEPART=#{et.dutyDepart},</if>
        <if test="et.dutyType!=null">DUTY_TYPE=#{et.dutyType},</if>
        <if test="et.principalUser!=null">PRINCIPAL_USER=#{et.principalUser},</if>
        <if test="et.dutyCauseDescription!=null">DUTY_CAUSE_DESCRIPTION=#{et.dutyCauseDescription},</if>
        <if test="et.dutyCauseType!=null">DUTY_CAUSE_TYPE=#{et.dutyCauseType},</if>
        <if test="et.dutySendUserGroup!=null">DUTY_SEND_USER_GROUP=#{et.dutySendUserGroup},</if>
        <if test="et.resolveUser!=null">RESOLVE_USER=#{et.resolveUser},</if>
        <if test="et.resolveDateTime!=null">RESOLVE_DATE_TIME=#{et.resolveDateTime},</if>
        <if test="et.abnormalMethod!=null">ABNORMAL_METHOD=#{et.abnormalMethod},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.resolveShopOrder!=null">RESOLVE_SHOP_ORDER=#{et.resolveShopOrder},</if>
        <if test="et.resolveRemark!=null">RESOLVE_REMARK=#{et.resolveRemark},</if>
        <if test="et.resolveSendUserGroup!=null">RESOLVE_SEND_USER_GROUP=#{et.resolveSendUserGroup},</if>
        <if test="et.closedUser!=null">CLOSED_USER=#{et.closedUser},</if>
        <if test="et.closedDateTime!=null">CLOSED_DATE_TIME=#{et.closedDateTime},</if>
        <if test="et.abnormalReason!=null">ABNORMAL_REASON=#{et.abnormalReason},</if>
        <if test="et.beforeMeasure!=null">BEFORE_MEASURE=#{et.beforeMeasure},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.createdDataTime!=null">CREATED_DATA_TIME=#{et.createdDataTime},</if>
        <if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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_ABNORMAL_BILL_DISPOSE WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_ABNORMAL_BILL_DISPOSE
        <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_ABNORMAL_BILL_DISPOSE
        <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.abnormalBillBo!=null"> AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo}</if>
                    <if test="ew.entity.dutyUser!=null"> AND DUTY_USER=#{ew.entity.dutyUser}</if>
                    <if test="ew.entity.dutyDateTime!=null"> AND DUTY_DATE_TIME=#{ew.entity.dutyDateTime}</if>
                    <if test="ew.entity.dutyDepart!=null"> AND DUTY_DEPART=#{ew.entity.dutyDepart}</if>
                    <if test="ew.entity.dutyType!=null"> AND DUTY_TYPE=#{ew.entity.dutyType}</if>
                    <if test="ew.entity.principalUser!=null"> AND PRINCIPAL_USER=#{ew.entity.principalUser}</if>
                    <if test="ew.entity.dutyCauseDescription!=null"> AND DUTY_CAUSE_DESCRIPTION=#{ew.entity.dutyCauseDescription}</if>
                    <if test="ew.entity.dutyCauseType!=null"> AND DUTY_CAUSE_TYPE=#{ew.entity.dutyCauseType}</if>
                    <if test="ew.entity.dutySendUserGroup!=null"> AND DUTY_SEND_USER_GROUP=#{ew.entity.dutySendUserGroup}</if>
                    <if test="ew.entity.resolveUser!=null"> AND RESOLVE_USER=#{ew.entity.resolveUser}</if>
                    <if test="ew.entity.resolveDateTime!=null"> AND RESOLVE_DATE_TIME=#{ew.entity.resolveDateTime}</if>
                    <if test="ew.entity.abnormalMethod!=null"> AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.resolveShopOrder!=null"> AND RESOLVE_SHOP_ORDER=#{ew.entity.resolveShopOrder}</if>
                    <if test="ew.entity.resolveRemark!=null"> AND RESOLVE_REMARK=#{ew.entity.resolveRemark}</if>
                    <if test="ew.entity.resolveSendUserGroup!=null"> AND RESOLVE_SEND_USER_GROUP=#{ew.entity.resolveSendUserGroup}</if>
                    <if test="ew.entity.closedUser!=null"> AND CLOSED_USER=#{ew.entity.closedUser}</if>
                    <if test="ew.entity.closedDateTime!=null"> AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime}</if>
                    <if test="ew.entity.abnormalReason!=null"> AND ABNORMAL_REASON=#{ew.entity.abnormalReason}</if>
                    <if test="ew.entity.beforeMeasure!=null"> AND BEFORE_MEASURE=#{ew.entity.beforeMeasure}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDataTime!=null"> AND CREATED_DATA_TIME=#{ew.entity.createdDataTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</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_ABNORMAL_BILL_DISPOSE WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->


    <select id="findAllByAbnormalNo" resultMap="AbnormalBillDisposeDto">
        SELECT ZAB.ABNORMAL_NO ABNORMAL_NO ,ZAB.STATUS STATUS,I.ITEM ITEM,IT.DESCRIPTION ITEM_DESCRIPTION,
        ZAB."TYPE" "TYPE" ,ZAB.SFC SFC,ZAB.MESSAGE_TYPE MESSAGE_TYPE,ZAB.SHOP_ORDER SHOP_ORDER,
        ZAB.WORK_CENTER WORK_CENTER,ZAB.RESRCE RESRCE, WORKORDER.VALUE WORK_ORDER,ITEMNUMBER.VALUE ITEM_NUMBER,
        PRODUCTCATEGORY.VALUE PRODUCT_CATEGORY,
        listagg(NG.DESCRIPTION || '/'||NCT.DESCRIPTION || ',') within GROUP(ORDER BY zab.ABNORMAL_NO) NC_CODE_DESCRIPTION,
        ZAB.PB_DESCRIPTION PB_DESCRIPTION ,ZAB.NC_QTY NC_QTY,
        ZAB.PB_GRADE PB_GRADE ,NWA.FULL_NAME PB_USER ,ZAB.PB_QTY PB_QTY ,ZAB.DISCOVER DISCOVER ,
        NWA2.FULL_NAME INSPECTOR ,ZAB.ENTITY_LOCATION ENTITY_LOCATION ,ZAB.REPORT_FROM REPORT_FROM ,SUBSTR(ZAB.OBJECT_BO,INSTR(ZAB.OBJECT_BO,',')+1) OBJECT_BO,
        ZAB.PB_PHOTOSHOP PB_PHOTOSHOP,ZABD.DUTY_CAUSE_DESCRIPTION DUTY_CAUSE_DESCRIPTION,ZABD.DUTY_CAUSE_TYPE DUTY_CAUSE_TYPE,ZABD.DUTY_DEPART DUTY_DEPART,
        ZABD.DUTY_SEND_USER_GROUP DUTY_SEND_USER_GROUP,ZABD.DUTY_TYPE DUTY_TYPE,ZABD.PRINCIPAL_USER PRINCIPAL_USER,ZABD.ABNORMAL_METHOD ABNORMAL_METHOD,
        R.ROUTER ROUTER,ZABD.RESOLVE_SHOP_ORDER RESOLVE_SHOP_ORDER,ZABD.RESOLVE_REMARK RESOLVE_REMARK,ZABD.RESOLVE_SEND_USER_GROUP RESOLVE_SEND_USER_GROUP,
        ZABD.ABNORMAL_REASON ABNORMAL_REASON,ZABD.BEFORE_MEASURE BEFORE_MEASURE,"MAP".VALUE "MAP",
        listagg(ZANC.NC_CODE_GROUP || '/'||ZANC.NC_CODE || ',') within GROUP(ORDER BY zab.ABNORMAL_NO) NC_CODE,
        ZABD.ROUTER_BO ROUTER_BO,ZAB.OPERATION OPERATION,I.HANDLE ITEM_BO,ZAB.REPORT_SEND_USER_GROUP REPORT_SEND_USER_GROUP,
        ZAB.CORRECTION CORRECTION,ZAB.PROGRAM PROGRAM,WCT.DESCRIPTION WORK_CENTER_DESCRIPTION,ZAB.SHUT_DOWN SHUT_DOWN,
        RS.DESCRIPTION RESRCE_DESCRIPTION,OT.DESCRIPTION OPERATION_DESCRIPTION,R.DESCRIPTION ROUTER_DESCRIPTION
        FROM Z_ABNORMAL_BILL ZAB
        LEFT JOIN Z_ABNORMAL_BILL_DISPOSE ZABD ON ZAB.HANDLE = ZABD.ABNORMAL_BILL_BO
        LEFT JOIN ITEM I ON I.HANDLE = ZAB.ITEM_BO
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE = #{locale}
        LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZAB.SHOP_ORDER AND SO.SITE = ZAB.SITE
        LEFT JOIN RESRCE RS ON RS.RESRCE = ZAB.RESRCE AND RS.SITE = ZAB.SITE
        LEFT JOIN OPERATION O ON O.OPERATION = ZAB.OPERATION AND O.SITE = ZAB.SITE  AND  O.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T OT ON O.HANDLE = OT.OPERATION_BO AND OT.LOCALE = #{locale}
        LEFT JOIN CUSTOM_FIELDS WORKORDER ON WORKORDER.HANDLE = SO.HANDLE AND WORKORDER."ATTRIBUTE" = 'WORK_ORDER'
        LEFT JOIN CUSTOM_FIELDS ITEMNUMBER ON ITEMNUMBER.HANDLE = SO.HANDLE AND ITEMNUMBER."ATTRIBUTE" = 'ITEM_NUMBER'
        LEFT JOIN CUSTOM_FIELDS PRODUCTCATEGORY ON PRODUCTCATEGORY.HANDLE = SO.HANDLE AND PRODUCTCATEGORY."ATTRIBUTE" = 'PRODUCT_CATEGORY'
        LEFT JOIN CUSTOM_FIELDS "MAP" ON "MAP".HANDLE = SO.HANDLE AND "MAP"."ATTRIBUTE" = 'MAP'
        LEFT JOIN Z_ABNORMAL_NC_CODE ZANC ON ZAB.HANDLE = ZANC.ABNORMAL_BILL_BO
        LEFT JOIN NC_CODE_T NCT ON ('NCCodeBO:' || ZAB.SITE || ',' || ZANC.NC_CODE) = NCT.NC_CODE_BO AND NCT.LOCALE = #{locale}
        LEFT JOIN WORK_CENTER_T WCT ON ('WorkCenterBO:' || ZAB.SITE || ',' || ZAB.WORK_CENTER) = WCT.WORK_CENTER_BO AND WCT.LOCALE = #{locale}
        LEFT JOIN Z_NWA_USER NWA ON NWA.USER_NAME = ZAB.PB_USER AND NWA.SITE = ZAB.SITE
        LEFT JOIN Z_NWA_USER NWA2 ON NWA2.USER_NAME = ZAB.INSPECTOR AND NWA2.SITE = ZAB.SITE
        LEFT  JOIN NC_GROUP NG ON NG.NC_GROUP = ZANC.NC_CODE_GROUP AND NG.SITE = ZAB.SITE
        LEFT JOIN ROUTER R ON SUBSTR(R.HANDLE,1,INSTR(R.HANDLE,',',-1)-1) = SUBSTR(ZABD.ROUTER_BO,1,INSTR(ZABD.ROUTER_BO,',',-1)-1) AND R.CURRENT_REVISION = 'true'
        <where>
            <if test="abnormalBill != null">
                <if test="abnormalBill.site != null and abnormalBill.site != ''">
                    ZAB.SITE = #{abnormalBill.site}
                </if>
                <if test="abnormalBill.abnormalNo != null and abnormalBill.abnormalNo != ''">
                    AND ZAB.ABNORMAL_NO = #{abnormalBill.abnormalNo}
                </if>
            </if>
        </where>
        GROUP BY
        ZAB.ABNORMAL_NO  ,ZAB.STATUS ,I.ITEM ,IT.DESCRIPTION ,
        ZAB."TYPE"  ,ZAB.SFC ,ZAB.MESSAGE_TYPE ,ZAB.SHOP_ORDER ,
        ZAB.WORK_CENTER ,ZAB.RESRCE , WORKORDER.VALUE ,ITEMNUMBER.VALUE ,
        PRODUCTCATEGORY.VALUE, ZAB.PB_DESCRIPTION  ,ZAB.NC_QTY ,
        ZAB.PB_GRADE  ,NWA.FULL_NAME  ,ZAB.PB_QTY  ,ZAB.DISCOVER  ,
        NWA2.FULL_NAME  ,ZAB.ENTITY_LOCATION  ,ZAB.REPORT_FROM  ,SUBSTR(ZAB.OBJECT_BO,INSTR(ZAB.OBJECT_BO,',')+1),
        ZAB.PB_PHOTOSHOP ,ZABD.DUTY_CAUSE_DESCRIPTION ,ZABD.DUTY_CAUSE_TYPE ,ZABD.DUTY_DEPART ,
        ZABD.DUTY_SEND_USER_GROUP ,ZABD.DUTY_TYPE ,ZABD.PRINCIPAL_USER ,ZABD.ABNORMAL_METHOD ,
        R.ROUTER ,ZABD.RESOLVE_SHOP_ORDER ,ZABD.RESOLVE_REMARK ,ZABD.RESOLVE_SEND_USER_GROUP ,
        ZABD.ABNORMAL_REASON ,ZABD.BEFORE_MEASURE ,"MAP".VALUE,ZABD.ROUTER_BO,ZAB.OPERATION,I.HANDLE,
        ZAB.REPORT_SEND_USER_GROUP,ZAB.CORRECTION,ZAB.PROGRAM,WCT.DESCRIPTION,ZAB.SHUT_DOWN,RS.DESCRIPTION,
        OT.DESCRIPTION,R.DESCRIPTION
    </select>


</mapper>
