<?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.meapi.mapper.WorkCenterMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.WorkCenter">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="WORK_CENTER" property="workCenter" />
        <result column="ROUTER_BO" property="routerBo" />
        <result column="CAN_BE_RELEASED_TO" property="canBeReleasedTo" />
        <result column="WC_CATEGORY" property="wcCategory" />
        <result column="STATUS_BO" property="statusBo" />
        <result column="WC_TYPE" property="wcType" />
        <result column="ASSIGNMENT_ENFORCEMENT" property="assignmentEnforcement" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="ERP_INTERNAL_ID" property="erpInternalId" />
        <result column="IS_ERP_WORK_CENTER" property="isErpWorkCenter" />
        <result column="ERP_WORK_CENTER" property="erpWorkCenter" />
        <result column="ERP_CAPACITY_CATEGORY" property="erpCapacityCategory" />
        <result column="PRODUCTION_SUPPLY_AREA" property="productionSupplyArea" />
        <result column="STANDARD_VALUE_KEY_BO" property="standardValueKeyBo" />
        <result column="DESCRIPTION" property="description" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, WORK_CENTER, ROUTER_BO, CAN_BE_RELEASED_TO, WC_CATEGORY, STATUS_BO, WC_TYPE, ASSIGNMENT_ENFORCEMENT, CREATED_DATE_TIME, MODIFIED_DATE_TIME, ERP_INTERNAL_ID, IS_ERP_WORK_CENTER, ERP_WORK_CENTER, ERP_CAPACITY_CATEGORY, PRODUCTION_SUPPLY_AREA, STANDARD_VALUE_KEY_BO
    </sql>

    <sql id="Full_Column_List">
        W.HANDLE, W.CHANGE_STAMP, W.SITE, W.WORK_CENTER, WT.DESCRIPTION, W.ROUTER_BO, W.CAN_BE_RELEASED_TO, W.WC_CATEGORY, W.STATUS_BO, W.WC_TYPE, W.ASSIGNMENT_ENFORCEMENT, W.CREATED_DATE_TIME, W.MODIFIED_DATE_TIME, W.ERP_INTERNAL_ID, W.IS_ERP_WORK_CENTER, ERP_WORK_CENTER, ERP_CAPACITY_CATEGORY, W.PRODUCTION_SUPPLY_AREA, W.STANDARD_VALUE_KEY_BO
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM WORK_CENTER
        <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="workCenterList" resultMap="BaseResultMap">
        SELECT A.WORK_CENTER,B.DESCRIPTION
        FROM WORK_CENTER A
        LEFT JOIN WORK_CENTER_T B ON A.HANDLE = B.WORK_CENTER_BO
        WHERE
          <if test="workCenter != null and workCenter != ''">
              (A.WORK_CENTER like '%${workCenter}%' OR
              B.DESCRIPTION like '%${workCenter}%') AND
          </if>
           A.SITE = #{site}
    </select>

    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM WORK_CENTER
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
            <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
            <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
            <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
            <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
            <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
            <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
            <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
            <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
            <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
            <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
            <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
            <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM WORK_CENTER
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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="Full_Column_List"></include></otherwise></choose>
        FROM WORK_CENTER W
        LEFT JOIN WORK_CENTER_T WT ON W.HANDLE = WT.WORK_CENTER_BO AND WT.LOCALE = 'zh'
        <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 W.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND W.WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND W.ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND W.CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND W.WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND W.STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND W.WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND W.ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND W.CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND W.MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND W.ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND W.IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND W.ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND W.ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND W.PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND W.STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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 WORK_CENTER
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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 WORK_CENTER
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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="Full_Column_List"></include></otherwise></choose>
        FROM WORK_CENTER W
        LEFT JOIN WORK_CENTER_T WT ON W.HANDLE = WT.WORK_CENTER_BO AND WT.LOCALE = 'zh'
        <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.changeStamp!=null"> AND W.CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND W.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND W.WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND W.ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND W.CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND W.WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND W.STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND W.WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND W.ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND W.CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND W.MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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="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 WORK_CENTER
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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.meapi.model.WorkCenter">
        INSERT INTO WORK_CENTER
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="workCenter!=null">WORK_CENTER,</if>
            <if test="routerBo!=null">ROUTER_BO,</if>
            <if test="canBeReleasedTo!=null">CAN_BE_RELEASED_TO,</if>
            <if test="wcCategory!=null">WC_CATEGORY,</if>
            <if test="statusBo!=null">STATUS_BO,</if>
            <if test="wcType!=null">WC_TYPE,</if>
            <if test="assignmentEnforcement!=null">ASSIGNMENT_ENFORCEMENT,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="erpInternalId!=null">ERP_INTERNAL_ID,</if>
            <if test="isErpWorkCenter!=null">IS_ERP_WORK_CENTER,</if>
            <if test="erpWorkCenter!=null">ERP_WORK_CENTER,</if>
            <if test="erpCapacityCategory!=null">ERP_CAPACITY_CATEGORY,</if>
            <if test="productionSupplyArea!=null">PRODUCTION_SUPPLY_AREA,</if>
            <if test="standardValueKeyBo!=null">STANDARD_VALUE_KEY_BO,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="workCenter!=null">#{workCenter},</if>
            <if test="routerBo!=null">#{routerBo},</if>
            <if test="canBeReleasedTo!=null">#{canBeReleasedTo},</if>
            <if test="wcCategory!=null">#{wcCategory},</if>
            <if test="statusBo!=null">#{statusBo},</if>
            <if test="wcType!=null">#{wcType},</if>
            <if test="assignmentEnforcement!=null">#{assignmentEnforcement},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="erpInternalId!=null">#{erpInternalId},</if>
            <if test="isErpWorkCenter!=null">#{isErpWorkCenter},</if>
            <if test="erpWorkCenter!=null">#{erpWorkCenter},</if>
            <if test="erpCapacityCategory!=null">#{erpCapacityCategory},</if>
            <if test="productionSupplyArea!=null">#{productionSupplyArea},</if>
            <if test="standardValueKeyBo!=null">#{standardValueKeyBo},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.WorkCenter">
        INSERT INTO WORK_CENTER
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{workCenter},
            #{routerBo},
            #{canBeReleasedTo},
            #{wcCategory},
            #{statusBo},
            #{wcType},
            #{assignmentEnforcement},
            #{createdDateTime},
            #{modifiedDateTime},
            #{erpInternalId},
            #{isErpWorkCenter},
            #{erpWorkCenter},
            #{erpCapacityCategory},
            #{productionSupplyArea},
            #{standardValueKeyBo},
        </trim>
    </insert>






    <update id="update">
        UPDATE WORK_CENTER <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.changeStamp!=null">CHANGE_STAMP=#{et.changeStamp},</if>
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.canBeReleasedTo!=null">CAN_BE_RELEASED_TO=#{et.canBeReleasedTo},</if>
        <if test="et.wcCategory!=null">WC_CATEGORY=#{et.wcCategory},</if>
        <if test="et.statusBo!=null">STATUS_BO=#{et.statusBo},</if>
        <if test="et.wcType!=null">WC_TYPE=#{et.wcType},</if>
        <if test="et.assignmentEnforcement!=null">ASSIGNMENT_ENFORCEMENT=#{et.assignmentEnforcement},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.erpInternalId!=null">ERP_INTERNAL_ID=#{et.erpInternalId},</if>
        <if test="et.isErpWorkCenter!=null">IS_ERP_WORK_CENTER=#{et.isErpWorkCenter},</if>
        <if test="et.erpWorkCenter!=null">ERP_WORK_CENTER=#{et.erpWorkCenter},</if>
        <if test="et.erpCapacityCategory!=null">ERP_CAPACITY_CATEGORY=#{et.erpCapacityCategory},</if>
        <if test="et.productionSupplyArea!=null">PRODUCTION_SUPPLY_AREA=#{et.productionSupplyArea},</if>
        <if test="et.standardValueKeyBo!=null">STANDARD_VALUE_KEY_BO=#{et.standardValueKeyBo},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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="deleteByMap">
        DELETE FROM WORK_CENTER
        <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 WORK_CENTER
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.canBeReleasedTo!=null"> AND CAN_BE_RELEASED_TO=#{ew.entity.canBeReleasedTo}</if>
                    <if test="ew.entity.wcCategory!=null"> AND WC_CATEGORY=#{ew.entity.wcCategory}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.wcType!=null"> AND WC_TYPE=#{ew.entity.wcType}</if>
                    <if test="ew.entity.assignmentEnforcement!=null"> AND ASSIGNMENT_ENFORCEMENT=#{ew.entity.assignmentEnforcement}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.isErpWorkCenter!=null"> AND IS_ERP_WORK_CENTER=#{ew.entity.isErpWorkCenter}</if>
                    <if test="ew.entity.erpWorkCenter!=null"> AND ERP_WORK_CENTER=#{ew.entity.erpWorkCenter}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.standardValueKeyBo!=null"> AND STANDARD_VALUE_KEY_BO=#{ew.entity.standardValueKeyBo}</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>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="getWorkShopList" resultMap="BaseResultMap" >
        SELECT WC.WORK_CENTER, CT.DESCRIPTION
        FROM WORK_CENTER WC
        INNER JOIN WORK_CENTER_T CT ON CT.WORK_CENTER_BO = WC.HANDLE AND CT.LOCALE = #{locale}
        WHERE WC.WC_CATEGORY = 'LEVEL4' AND WC.SITE = #{site}
    </select>

    <select id="findWorkCenterDescriptionByResrce" resultMap="BaseResultMap">
        SELECT WCT.DESCRIPTION DESCRIPTION,SUBSTR(WCM.WORK_CENTER_BO,INSTR(WCM.WORK_CENTER_BO,',',-1)+1) WORK_CENTER
        FROM WORK_CENTER_MEMBER WCM
        INNER JOIN WORK_CENTER_T WCT ON WCM.WORK_CENTER_BO = WCT.WORK_CENTER_BO AND WCT.LOCALE  = #{locale}
        WHERE WCM.WORK_CENTER_OR_RESOURCE_GBO = #{resrceBo}
    </select>

    <select id="findWorkCenterDescriptionByWorkCenter" resultMap="BaseResultMap">
        SELECT WC.WORK_CENTER WORK_CENTER,WCT.DESCRIPTION DESCRIPTION
        FROM WORK_CENTER WC
        LEFT JOIN WORK_CENTER_T WCT ON WC.HANDLE = WCT.WORK_CENTER_BO AND WCT.LOCALE = #{locale}
        WHERE WC.WORK_CENTER = #{workCenter} AND WC.SITE = #{site}
    </select>
</mapper>
