<?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.equip.mapper.ResourceInspectTaskMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.equip.model.ResourceInspectTask">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="TASK_NO" property="taskNo" />
        <result column="DESCRIPTION" property="description" />
        <result column="STATUS" property="status" />
        <result column="RESOURCE_INSPECT_PLAN_BO" property="resourceInspectPlanBo" />
        <result column="INSPECTION_ITEM_BO" property="inspectionItemBo" />
        <result column="RESRCE" property="resrce" />
        <result column="CATEGORY" property="category" />
        <result column="TASK_CREATE_DATE" property="taskCreateDate" />
        <result column="PLAN_START_DATE" property="planStartDate" />
        <result column="PLAN_COMPLETE_DATE" property="planCompleteDate" />
        <result column="ACTUAL_START_DATE" property="actualStartDate" />
        <result column="ACTUAL_COMPLETE_DATE" property="actualCompleteDate" />
        <result column="RESULT" property="result" />
        <result column="REASON" property="reason" />
        <result column="EXECUTOR" property="executor" />
        <result column="REMARK" property="remark" />
        <result column="SCHEDULE_TYPE" property="scheduleType" />
        <result column="FREQUENCY" property="frequency" />
        <result column="FREQUENCY_UNIT" property="frequencyUnit" />
        <result column="CREATE_USER" property="createUser" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFY_USER" property="modifyUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, TASK_NO, DESCRIPTION, STATUS, RESOURCE_INSPECT_PLAN_BO, INSPECTION_ITEM_BO, RESRCE, CATEGORY, TASK_CREATE_DATE, PLAN_START_DATE, PLAN_COMPLETE_DATE, ACTUAL_START_DATE, ACTUAL_COMPLETE_DATE, RESULT, REASON, EXECUTOR, REMARK, SCHEDULE_TYPE, FREQUENCY, FREQUENCY_UNIT, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_RESOURCE_INSPECT_TASK
        <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_RESOURCE_INSPECT_TASK 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_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
            <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
            <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
            <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
            <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
            <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
            <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
            <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
            <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
            <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
            <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
            <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
            <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
            <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
            <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
            <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
            <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
            <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
            <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
            <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="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_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="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_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectObjs" resultType="Object">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <insert id="insert" parameterType="com.foreverwin.mesnac.equip.model.ResourceInspectTask">
        INSERT INTO Z_RESOURCE_INSPECT_TASK
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="taskNo!=null">TASK_NO,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="status!=null">STATUS,</if>
            <if test="resourceInspectPlanBo!=null">RESOURCE_INSPECT_PLAN_BO,</if>
            <if test="inspectionItemBo!=null">INSPECTION_ITEM_BO,</if>
            <if test="resrce!=null">RESRCE,</if>
            <if test="category!=null">CATEGORY,</if>
            <if test="taskCreateDate!=null">TASK_CREATE_DATE,</if>
            <if test="planStartDate!=null">PLAN_START_DATE,</if>
            <if test="planCompleteDate!=null">PLAN_COMPLETE_DATE,</if>
            <if test="actualStartDate!=null">ACTUAL_START_DATE,</if>
            <if test="actualCompleteDate!=null">ACTUAL_COMPLETE_DATE,</if>
            <if test="result!=null">RESULT,</if>
            <if test="reason!=null">REASON,</if>
            <if test="executor!=null">EXECUTOR,</if>
            <if test="remark!=null">REMARK,</if>
            <if test="scheduleType!=null">SCHEDULE_TYPE,</if>
            <if test="frequency!=null">FREQUENCY,</if>
            <if test="frequencyUnit!=null">FREQUENCY_UNIT,</if>
            <if test="createUser!=null">CREATE_USER,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifyUser!=null">MODIFY_USER,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="taskNo!=null">#{taskNo},</if>
            <if test="description!=null">#{description},</if>
            <if test="status!=null">#{status},</if>
            <if test="resourceInspectPlanBo!=null">#{resourceInspectPlanBo},</if>
            <if test="inspectionItemBo!=null">#{inspectionItemBo},</if>
            <if test="resrce!=null">#{resrce},</if>
            <if test="category!=null">#{category},</if>
            <if test="taskCreateDate!=null">#{taskCreateDate},</if>
            <if test="planStartDate!=null">#{planStartDate},</if>
            <if test="planCompleteDate!=null">#{planCompleteDate},</if>
            <if test="actualStartDate!=null">#{actualStartDate},</if>
            <if test="actualCompleteDate!=null">#{actualCompleteDate},</if>
            <if test="result!=null">#{result},</if>
            <if test="reason!=null">#{reason},</if>
            <if test="executor!=null">#{executor},</if>
            <if test="remark!=null">#{remark},</if>
            <if test="scheduleType!=null">#{scheduleType},</if>
            <if test="frequency!=null">#{frequency},</if>
            <if test="frequencyUnit!=null">#{frequencyUnit},</if>
            <if test="createUser!=null">#{createUser},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifyUser!=null">#{modifyUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.equip.model.ResourceInspectTask">
        INSERT INTO Z_RESOURCE_INSPECT_TASK
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{taskNo},
            #{description},
            #{status},
            #{resourceInspectPlanBo},
            #{inspectionItemBo},
            #{resrce},
            #{category},
            #{taskCreateDate},
            #{planStartDate},
            #{planCompleteDate},
            #{actualStartDate},
            #{actualCompleteDate},
            #{result},
            #{reason},
            #{executor},
            #{remark},
            #{scheduleType},
            #{frequency},
            #{frequencyUnit},
            #{createUser},
            #{createdDateTime},
            #{modifyUser},
            #{modifiedDateTime},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_RESOURCE_INSPECT_TASK <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.taskNo!=null">TASK_NO=#{et.taskNo},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.resourceInspectPlanBo!=null">RESOURCE_INSPECT_PLAN_BO=#{et.resourceInspectPlanBo},</if>
        <if test="et.inspectionItemBo!=null">INSPECTION_ITEM_BO=#{et.inspectionItemBo},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.category!=null">CATEGORY=#{et.category},</if>
        <if test="et.taskCreateDate!=null">TASK_CREATE_DATE=#{et.taskCreateDate},</if>
        <if test="et.planStartDate!=null">PLAN_START_DATE=#{et.planStartDate},</if>
        <if test="et.planCompleteDate!=null">PLAN_COMPLETE_DATE=#{et.planCompleteDate},</if>
        <if test="et.actualStartDate!=null">ACTUAL_START_DATE=#{et.actualStartDate},</if>
        <if test="et.actualCompleteDate!=null">ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},</if>
        <if test="et.result!=null">RESULT=#{et.result},</if>
        <if test="et.reason!=null">REASON=#{et.reason},</if>
        <if test="et.executor!=null">EXECUTOR=#{et.executor},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.scheduleType!=null">SCHEDULE_TYPE=#{et.scheduleType},</if>
        <if test="et.frequency!=null">FREQUENCY=#{et.frequency},</if>
        <if test="et.frequencyUnit!=null">FREQUENCY_UNIT=#{et.frequencyUnit},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="updateAllColumnById">
        UPDATE Z_RESOURCE_INSPECT_TASK <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        TASK_NO=#{et.taskNo},
        DESCRIPTION=#{et.description},
        STATUS=#{et.status},
        RESOURCE_INSPECT_PLAN_BO=#{et.resourceInspectPlanBo},
        INSPECTION_ITEM_BO=#{et.inspectionItemBo},
        RESRCE=#{et.resrce},
        CATEGORY=#{et.category},
        TASK_CREATE_DATE=#{et.taskCreateDate},
        PLAN_START_DATE=#{et.planStartDate},
        PLAN_COMPLETE_DATE=#{et.planCompleteDate},
        ACTUAL_START_DATE=#{et.actualStartDate},
        ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},
        RESULT=#{et.result},
        REASON=#{et.reason},
        EXECUTOR=#{et.executor},
        REMARK=#{et.remark},
        SCHEDULE_TYPE=#{et.scheduleType},
        FREQUENCY=#{et.frequency},
        FREQUENCY_UNIT=#{et.frequencyUnit},
        CREATE_USER=#{et.createUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFY_USER=#{et.modifyUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
     </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="update">
        UPDATE Z_RESOURCE_INSPECT_TASK <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.taskNo!=null">TASK_NO=#{et.taskNo},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.resourceInspectPlanBo!=null">RESOURCE_INSPECT_PLAN_BO=#{et.resourceInspectPlanBo},</if>
        <if test="et.inspectionItemBo!=null">INSPECTION_ITEM_BO=#{et.inspectionItemBo},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.category!=null">CATEGORY=#{et.category},</if>
        <if test="et.taskCreateDate!=null">TASK_CREATE_DATE=#{et.taskCreateDate},</if>
        <if test="et.planStartDate!=null">PLAN_START_DATE=#{et.planStartDate},</if>
        <if test="et.planCompleteDate!=null">PLAN_COMPLETE_DATE=#{et.planCompleteDate},</if>
        <if test="et.actualStartDate!=null">ACTUAL_START_DATE=#{et.actualStartDate},</if>
        <if test="et.actualCompleteDate!=null">ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},</if>
        <if test="et.result!=null">RESULT=#{et.result},</if>
        <if test="et.reason!=null">REASON=#{et.reason},</if>
        <if test="et.executor!=null">EXECUTOR=#{et.executor},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.scheduleType!=null">SCHEDULE_TYPE=#{et.scheduleType},</if>
        <if test="et.frequency!=null">FREQUENCY=#{et.frequency},</if>
        <if test="et.frequencyUnit!=null">FREQUENCY_UNIT=#{et.frequencyUnit},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </update>

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

    <delete id="deleteByMap">
        DELETE FROM Z_RESOURCE_INSPECT_TASK
        <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_RESOURCE_INSPECT_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.resourceInspectPlanBo!=null"> AND RESOURCE_INSPECT_PLAN_BO=#{ew.entity.resourceInspectPlanBo}</if>
                    <if test="ew.entity.inspectionItemBo!=null"> AND INSPECTION_ITEM_BO=#{ew.entity.inspectionItemBo}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.category!=null"> AND CATEGORY=#{ew.entity.category}</if>
                    <if test="ew.entity.taskCreateDate!=null"> AND TASK_CREATE_DATE=#{ew.entity.taskCreateDate}</if>
                    <if test="ew.entity.planStartDate!=null"> AND PLAN_START_DATE=#{ew.entity.planStartDate}</if>
                    <if test="ew.entity.planCompleteDate!=null"> AND PLAN_COMPLETE_DATE=#{ew.entity.planCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.reason!=null"> AND REASON=#{ew.entity.reason}</if>
                    <if test="ew.entity.executor!=null"> AND EXECUTOR=#{ew.entity.executor}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.scheduleType!=null"> AND SCHEDULE_TYPE=#{ew.entity.scheduleType}</if>
                    <if test="ew.entity.frequency!=null"> AND FREQUENCY=#{ew.entity.frequency}</if>
                    <if test="ew.entity.frequencyUnit!=null"> AND FREQUENCY_UNIT=#{ew.entity.frequencyUnit}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </delete>

    <delete id="deleteBatchIds">
        DELETE FROM Z_RESOURCE_INSPECT_TASK WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->

    <!--自定义sql-->

    <!--自定义sql：模糊查询检验任务所有字段、车间、设备名称等字段-->
    <select id="findResourceInspectTaskList" resultType="com.foreverwin.mesnac.equip.dto.ResourceInspectTaskDto">
        SELECT DISTINCT RIK.* , ZNU.FULL_NAME, RIP.PLAN_NO AS PLAN_NO ,
        R.RESRCE AS RESOURCE_NO ,R.DESCRIPTION AS RESOURCE_DESCRIPTION ,
        RTR.RESOURCE_TYPE_BO ,RT.RESOURCE_TYPE AS RESOURCE_TYPE_NO ,RT.DESCRIPTION AS RESOURCE_TYPE_DESCRIPTION ,
        WCT.DESCRIPTION AS WORK_CENTER
        FROM Z_RESOURCE_INSPECT_TASK RIK
        LEFT JOIN Z_NWA_USER ZNU ON ZNU.USER_NAME = RIK.EXECUTOR
        LEFT JOIN Z_INSPECT_PLAN_USER_GROUP ZG ON ZG.RESOURCE_INSPECT_PLAN_BO = RIK.RESOURCE_INSPECT_PLAN_BO
        LEFT JOIN USER_GROUP_MEMBER UGM ON UGM.USER_GROUP_BO = ZG.USER_GROUP_BO
        LEFT JOIN Z_RESOURCE_INSPECT_PLAN RIP ON RIK.RESOURCE_INSPECT_PLAN_BO = RIP.HANDLE
        LEFT JOIN RESRCE R ON R.RESRCE = RIK.RESRCE
        LEFT JOIN WORK_CENTER_MEMBER WCM ON WCM.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
        LEFT JOIN WORK_CENTER_T WCT ON WCT.WORK_CENTER_BO = WCM.WORK_CENTER_BO
        LEFT JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = R.HANDLE
        LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
        WHERE
        (ZG.USER_GROUP_BO IS NULL OR (ZG.USER_GROUP_BO IS NOT NULL AND UGM.USER_OR_GROUP_GBO = #{currentUser}))
        AND RIK.SITE = #{site}
        AND TASK_CREATE_DATE &lt;= (SELECT TO_DATE(TO_CHAR(SYSDATE+1,'yyyy-mm-dd') || ' 00:00:00','yyyy-MM-dd hh24:mi-ss') -4/24 FROM DUAL)
        <if test="taskNo != null and taskNo != ''">
            AND RIK.TASK_NO = #{taskNo}
        </if>
        <if test="category != null and category != ''">
            AND RIK.CATEGORY = #{category}
        </if>
        <if test="status != null and status != ''">
            AND RIK.STATUS = #{status}
        </if>
        <if test="resourceInspectPlanBo != null and resourceInspectPlanBo != ''">
            AND RIK.RESOURCE_INSPECT_PLAN_BO LIKE #{resourceInspectPlanBo}
        </if>
        <if test="resrce != null and resrce != ''">
            AND RIK.RESRCE = #{resrce}
        </if>
        <if test="compareStartDate != null and compareStartDate != ''">
            AND RIK.TASK_CREATE_DATE &gt;= (TO_DATE( #{compareStartDate},'yyyy-MM-dd hh24:mi-ss' ) - 8/24 )
        </if>
        <if test="compareEndDate != null and compareEndDate != ''">
            AND RIK.TASK_CREATE_DATE &lt;= (TO_DATE( #{compareEndDate},'yyyy-MM-dd hh24:mi-ss' ) - 8/24)
        </if>
        <if test="resourceTypeBo != null and resourceTypeBo != ''">
            AND RTR.RESOURCE_TYPE_BO = #{resourceTypeBo}
        </if>
        <if test="workCenter != null and workCenter != ''">
            AND WCM.WORK_CENTER_BO = #{workCenter}
        </if>
        ORDER BY RIK.TASK_CREATE_DATE DESC
    </select>

    <!--自定义sql：条件查询，根据检验计划handle及设备handle，获取最新的创建任务时间-->
    <select id="selectMaxCreateTimeByPlanBoAnd" resultType="java.time.LocalDateTime">
        SELECT MAX(ZRIT.TASK_CREATE_DATE) as maxCreateDate
        FROM WIP.Z_RESOURCE_INSPECT_TASK ZRIT
        WHERE ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo}
          AND ZRIT.RESRCE = #{resrce}
    </select>

    <!--自定义sql：条件查询，根据检验计划handle及设备handle，获取最新的创建任务时间-->
    <select id="getMaxCreateTimeByStatus" resultType="java.time.LocalDateTime">
        SELECT MAX(ZRIT.TASK_CREATE_DATE) as maxCreateDate
        FROM WIP.Z_RESOURCE_INSPECT_TASK ZRIT
        WHERE ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo}
              AND ZRIT.RESRCE = #{resrce}
              AND ZRIT.STATUS = #{status}
    </select>

    <!--条件查询，根据点检计划、设备查询处理中、新建的点检任务-->
    <select id="getInspectTaskList" resultType="com.foreverwin.mesnac.equip.model.ResourceInspectTask">
        SELECT * FROM WIP.Z_RESOURCE_INSPECT_TASK ZRIT
        WHERE ZRIT.SITE = #{site}
        AND ZRIT.STATUS IN ('DOING','NEW')
        <if test="resourceInspectPlanBo != null and resourceInspectPlanBo != ''">
            AND ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo}
        </if>
        <if test="resrce != null and resrce != ''">
            AND ZRIT.RESRCE = #{resrce}
        </if>
        <if test="category != null and category != ''">
            AND ZRIT.CATEGORY = #{category}
        </if>
        <if test="planCompleteDate != null">
            AND ZRIT.TASK_CREATE_DATE &lt;= #{planCompleteDate}
        </if>
        <if test="planStartDate != null">
            AND ZRIT.TASK_CREATE_DATE &gt;= #{planStartDate}
        </if>
    </select>
    <!--条件查询，查询点检任务-->
    <select id="getInspectTaskListByCondition" resultType="com.foreverwin.mesnac.equip.model.ResourceInspectTask">
        SELECT * FROM WIP.Z_RESOURCE_INSPECT_TASK ZRIT
        WHERE ZRIT.SITE = #{site}
        <if test="resrce != null and resrce != ''">
            AND ZRIT.RESRCE = #{resrce}
        </if>
        <if test="category != null and category != ''">
            AND ZRIT.CATEGORY = #{category}
        </if>
        <if test="planCompleteDate != null">
            AND ZRIT.TASK_CREATE_DATE &lt;= #{planCompleteDate}
        </if>
        <if test="planStartDate != null">
            AND ZRIT.TASK_CREATE_DATE &gt;= #{planStartDate}
        </if>
        ORDER BY ZRIT.TASK_CREATE_DATE DESC
    </select>

    <select id="findResourceTaskByResrceAndCategory" resultType="Integer">
        SELECT  COUNT(*)  FROM Z_RESOURCE_INSPECT_TASK ZRIT
        INNER JOIN Z_RESOURCE_INSPECT_RESOURCE zrir ON ZRIR.RESOURCE_INSPECT_PLAN_BO = ZRIT.RESOURCE_INSPECT_PLAN_BO AND ZRIR.STATUS = '301'
        WHERE ZRIT.SITE = #{site} AND ZRIT.RESRCE = #{resrce} AND ZRIT.CATEGORY = #{category} AND ZRIT.RESOURCE_INSPECT_PLAN_BO != #{planHandle}
    </select>

    <!--自定义sql-->





</mapper>
