<?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.ResrceMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.Resrce">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="RESRCE" property="resrce" />
        <result column="DESCRIPTION" property="description" />
        <result column="STATUS_BO" property="statusBo" />
        <result column="PROCESS_RESOURCE" property="processResource" />
        <result column="OPERATION_BO" property="operationBo" />
        <result column="VALID_FROM" property="validFrom" />
        <result column="VALID_TO" property="validTo" />
        <result column="SETUP_STATE" property="setupState" />
        <result column="SETUP_DESCRIPTION" property="setupDescription" />
        <result column="CNC_MACHINE" property="cncMachine" />
        <result column="PENDING_STATUS_BO" property="pendingStatusBo" />
        <result column="PENDING_REASON_CODE_BO" property="pendingReasonCodeBo" />
        <result column="PENDING_RESOURCE_RC_BO" property="pendingResourceRcBo" />
        <result column="PENDING_COMMENTS" property="pendingComments" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="ERP_PLANT_MAINT_ORDER" property="erpPlantMaintOrder" />
        <result column="ERP_EQUIPMENT_NUMBER" property="erpEquipmentNumber" />
        <result column="ERP_INTERNAL_ID" property="erpInternalId" />
        <result column="ERP_CAPACITY_CATEGORY" property="erpCapacityCategory" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, RESRCE, DESCRIPTION, STATUS_BO, PROCESS_RESOURCE, OPERATION_BO, VALID_FROM, VALID_TO, SETUP_STATE, SETUP_DESCRIPTION, CNC_MACHINE, PENDING_STATUS_BO, PENDING_REASON_CODE_BO, PENDING_RESOURCE_RC_BO, PENDING_COMMENTS, CREATED_DATE_TIME, MODIFIED_DATE_TIME, ERP_PLANT_MAINT_ORDER, ERP_EQUIPMENT_NUMBER, ERP_INTERNAL_ID, ERP_CAPACITY_CATEGORY
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM RESRCE
        <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="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
            <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
            <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
            <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
            <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
            <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
            <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
            <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
            <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
            <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
            <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
            <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
            <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
            <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
            <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
            <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
            <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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">
              ${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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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.Resrce">
        INSERT INTO RESRCE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="resrce!=null">RESRCE,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="statusBo!=null">STATUS_BO,</if>
            <if test="processResource!=null">PROCESS_RESOURCE,</if>
            <if test="operationBo!=null">OPERATION_BO,</if>
            <if test="validFrom!=null">VALID_FROM,</if>
            <if test="validTo!=null">VALID_TO,</if>
            <if test="setupState!=null">SETUP_STATE,</if>
            <if test="setupDescription!=null">SETUP_DESCRIPTION,</if>
            <if test="cncMachine!=null">CNC_MACHINE,</if>
            <if test="pendingStatusBo!=null">PENDING_STATUS_BO,</if>
            <if test="pendingReasonCodeBo!=null">PENDING_REASON_CODE_BO,</if>
            <if test="pendingResourceRcBo!=null">PENDING_RESOURCE_RC_BO,</if>
            <if test="pendingComments!=null">PENDING_COMMENTS,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="erpPlantMaintOrder!=null">ERP_PLANT_MAINT_ORDER,</if>
            <if test="erpEquipmentNumber!=null">ERP_EQUIPMENT_NUMBER,</if>
            <if test="erpInternalId!=null">ERP_INTERNAL_ID,</if>
            <if test="erpCapacityCategory!=null">ERP_CAPACITY_CATEGORY,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="resrce!=null">#{resrce},</if>
            <if test="description!=null">#{description},</if>
            <if test="statusBo!=null">#{statusBo},</if>
            <if test="processResource!=null">#{processResource},</if>
            <if test="operationBo!=null">#{operationBo},</if>
            <if test="validFrom!=null">#{validFrom},</if>
            <if test="validTo!=null">#{validTo},</if>
            <if test="setupState!=null">#{setupState},</if>
            <if test="setupDescription!=null">#{setupDescription},</if>
            <if test="cncMachine!=null">#{cncMachine},</if>
            <if test="pendingStatusBo!=null">#{pendingStatusBo},</if>
            <if test="pendingReasonCodeBo!=null">#{pendingReasonCodeBo},</if>
            <if test="pendingResourceRcBo!=null">#{pendingResourceRcBo},</if>
            <if test="pendingComments!=null">#{pendingComments},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="erpPlantMaintOrder!=null">#{erpPlantMaintOrder},</if>
            <if test="erpEquipmentNumber!=null">#{erpEquipmentNumber},</if>
            <if test="erpInternalId!=null">#{erpInternalId},</if>
            <if test="erpCapacityCategory!=null">#{erpCapacityCategory},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.Resrce">
        INSERT INTO RESRCE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{resrce},
            #{description},
            #{statusBo},
            #{processResource},
            #{operationBo},
            #{validFrom},
            #{validTo},
            #{setupState},
            #{setupDescription},
            #{cncMachine},
            #{pendingStatusBo},
            #{pendingReasonCodeBo},
            #{pendingResourceRcBo},
            #{pendingComments},
            #{createdDateTime},
            #{modifiedDateTime},
            #{erpPlantMaintOrder},
            #{erpEquipmentNumber},
            #{erpInternalId},
            #{erpCapacityCategory},
        </trim>
    </insert>






    <update id="update">
        UPDATE RESRCE <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.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.statusBo!=null">STATUS_BO=#{et.statusBo},</if>
        <if test="et.processResource!=null">PROCESS_RESOURCE=#{et.processResource},</if>
        <if test="et.operationBo!=null">OPERATION_BO=#{et.operationBo},</if>
        <if test="et.validFrom!=null">VALID_FROM=#{et.validFrom},</if>
        <if test="et.validTo!=null">VALID_TO=#{et.validTo},</if>
        <if test="et.setupState!=null">SETUP_STATE=#{et.setupState},</if>
        <if test="et.setupDescription!=null">SETUP_DESCRIPTION=#{et.setupDescription},</if>
        <if test="et.cncMachine!=null">CNC_MACHINE=#{et.cncMachine},</if>
        <if test="et.pendingStatusBo!=null">PENDING_STATUS_BO=#{et.pendingStatusBo},</if>
        <if test="et.pendingReasonCodeBo!=null">PENDING_REASON_CODE_BO=#{et.pendingReasonCodeBo},</if>
        <if test="et.pendingResourceRcBo!=null">PENDING_RESOURCE_RC_BO=#{et.pendingResourceRcBo},</if>
        <if test="et.pendingComments!=null">PENDING_COMMENTS=#{et.pendingComments},</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.erpPlantMaintOrder!=null">ERP_PLANT_MAINT_ORDER=#{et.erpPlantMaintOrder},</if>
        <if test="et.erpEquipmentNumber!=null">ERP_EQUIPMENT_NUMBER=#{et.erpEquipmentNumber},</if>
        <if test="et.erpInternalId!=null">ERP_INTERNAL_ID=#{et.erpInternalId},</if>
        <if test="et.erpCapacityCategory!=null">ERP_CAPACITY_CATEGORY=#{et.erpCapacityCategory},</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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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 RESRCE
        <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 RESRCE
        <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.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.processResource!=null"> AND PROCESS_RESOURCE=#{ew.entity.processResource}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.validFrom!=null"> AND VALID_FROM=#{ew.entity.validFrom}</if>
                    <if test="ew.entity.validTo!=null"> AND VALID_TO=#{ew.entity.validTo}</if>
                    <if test="ew.entity.setupState!=null"> AND SETUP_STATE=#{ew.entity.setupState}</if>
                    <if test="ew.entity.setupDescription!=null"> AND SETUP_DESCRIPTION=#{ew.entity.setupDescription}</if>
                    <if test="ew.entity.cncMachine!=null"> AND CNC_MACHINE=#{ew.entity.cncMachine}</if>
                    <if test="ew.entity.pendingStatusBo!=null"> AND PENDING_STATUS_BO=#{ew.entity.pendingStatusBo}</if>
                    <if test="ew.entity.pendingReasonCodeBo!=null"> AND PENDING_REASON_CODE_BO=#{ew.entity.pendingReasonCodeBo}</if>
                    <if test="ew.entity.pendingResourceRcBo!=null"> AND PENDING_RESOURCE_RC_BO=#{ew.entity.pendingResourceRcBo}</if>
                    <if test="ew.entity.pendingComments!=null"> AND PENDING_COMMENTS=#{ew.entity.pendingComments}</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.erpPlantMaintOrder!=null"> AND ERP_PLANT_MAINT_ORDER=#{ew.entity.erpPlantMaintOrder}</if>
                    <if test="ew.entity.erpEquipmentNumber!=null"> AND ERP_EQUIPMENT_NUMBER=#{ew.entity.erpEquipmentNumber}</if>
                    <if test="ew.entity.erpInternalId!=null"> AND ERP_INTERNAL_ID=#{ew.entity.erpInternalId}</if>
                    <if test="ew.entity.erpCapacityCategory!=null"> AND ERP_CAPACITY_CATEGORY=#{ew.entity.erpCapacityCategory}</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="selectResourceListByType" resultMap="BaseResultMap">
        SELECT RS.HANDLE, RS.SITE, RS.RESRCE, RS.DESCRIPTION, RS.STATUS_BO, RS.PROCESS_RESOURCE, RS.OPERATION_BO, RS.VALID_FROM, RS.VALID_TO, RS.SETUP_STATE, RS.SETUP_DESCRIPTION, RS.CNC_MACHINE, RS.PENDING_STATUS_BO, RS.PENDING_REASON_CODE_BO, RS.PENDING_RESOURCE_RC_BO, RS.PENDING_COMMENTS, RS.CREATED_DATE_TIME, RS.MODIFIED_DATE_TIME, RS.ERP_PLANT_MAINT_ORDER, RS.ERP_EQUIPMENT_NUMBER, RS.ERP_INTERNAL_ID, RS.ERP_CAPACITY_CATEGORY
        FROM RESRCE RS
        INNER JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = RS.HANDLE
        INNER JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
        WHERE RT.SITE = #{site} AND RT.RESOURCE_TYPE = #{resourceType}
    </select>

    <select id="selectResourceTypeResourceList" resultType="java.util.HashMap">
        SELECT RS.SITE, RS.RESRCE, RT.RESOURCE_TYPE
        FROM RESRCE RS
        INNER JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = RS.HANDLE
        INNER JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
        WHERE RT.SITE = #{site}
    </select>
    <select id="findByResrce" resultType="com.foreverwin.mesnac.meapi.model.Resrce">
        SELECT RESRCE
        FROM RESRCE
        WHERE SITE = #{site}
        <if test="resrce != null and resrce != ''">
            AND RESRCE = #{resrce}
        </if>
    </select>
    <select id="findAllResrce" resultMap="BaseResultMap">
        SELECT  RESRCE,DESCRIPTION
        FROM RESRCE
        WHERE SITE = #{site}
    </select>
    <!--自定义sql，根据设备类型HANDLE，返回该类型所有设备-->
    <select id="findResourceListByResourceType" resultType="com.foreverwin.mesnac.meapi.model.Resrce">
        SELECT R.*
        FROM RESRCE R
        INNER JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = R.HANDLE
        WHERE R.SITE = #{site} AND RTR.RESOURCE_TYPE_BO = #{resourceTypeBo}
    </select>


    <select id="selectResourceOperation" resultType="java.util.HashMap">
        SELECT RS.SITE, RS.RESRCE, OP.HANDLE OPERATION_BO,OP.OPERATION, RT.RESOURCE_TYPE
        FROM RESRCE RS
        LEFT JOIN RESOURCE_TYPE_RESOURCE RR ON RS.HANDLE = RR.RESOURCE_BO
        LEFT JOIN OPERATION OP ON OP.RESOURCE_TYPE_BO = RR.RESOURCE_TYPE_BO
        LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RR.RESOURCE_TYPE_BO
        WHERE RS.HANDLE = #{resourceBo}
    </select>

    <select id="findResourceAndWorkCenterByResource" resultType="com.foreverwin.mesnac.meapi.dto.ResrceWorkCenter">
        SELECT R.RESRCE AS RESOURCE_NO ,R.DESCRIPTION AS RESOURCE_DESCRIPTION,
            WCM2.WORK_CENTER_BO , WCT.DESCRIPTION AS WORK_CENTER_DESCRIPTION ,WC.WORK_CENTER AS WORK_CENTER_NO
        FROM RESRCE r
        LEFT JOIN WORK_CENTER_MEMBER WCM ON WCM.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
        LEFT JOIN WORK_CENTER_MEMBER wcm2 ON WCM2.WORK_CENTER_OR_RESOURCE_GBO = WCM.WORK_CENTER_BO
        LEFT JOIN WORK_CENTER_T wct ON WCM2.WORK_CENTER_BO = WCT.WORK_CENTER_BO
        LEFT JOIN WORK_CENTER wc ON WC.HANDLE = WCM2.WORK_CENTER_BO
        WHERE R.RESRCE = #{resrce} AND R.SITE = #{site}
    </select>

    <select id="selectResourceListByUT" resultMap="BaseResultMap">
        SELECT RS.HANDLE, RS.SITE, RS.RESRCE, RS.DESCRIPTION, RS.STATUS_BO, RS.PROCESS_RESOURCE, RS.OPERATION_BO, RS.VALID_FROM, RS.VALID_TO, RS.SETUP_STATE, RS.CREATED_DATE_TIME, RS.MODIFIED_DATE_TIME
        FROM RESRCE RS
        INNER JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = RS.HANDLE
        INNER JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
        INNER JOIN Z_USER_RESOURCE ZR ON ZR.RESOURCE_BO = RS.HANDLE AND ZR.STATUS = 'true'
        WHERE RT.SITE = #{site} AND RT.RESOURCE_TYPE = #{resourceType}
        AND ZR.USER_ID IN
        <foreach collection="userList" item="item" open="(" close=")" separator="," >
            #{item}
        </foreach>
        GROUP BY RS.HANDLE, RS.SITE, RS.RESRCE, RS.DESCRIPTION, RS.STATUS_BO, RS.PROCESS_RESOURCE, RS.OPERATION_BO, RS.VALID_FROM, RS.VALID_TO, RS.SETUP_STATE, RS.CREATED_DATE_TIME, RS.MODIFIED_DATE_TIME
    </select>
</mapper>
