<?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.quartz.mapper.SystemJobMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.quartz.model.SystemJob">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="NAME" property="name" />
        <result column="DESCRIPTION" property="description" />
        <result column="JOB_CLASS" property="jobClass" />
        <result column="JOB_GROUP" property="jobGroup" />
        <result column="JOB_PARAM" property="jobParam" />
        <result column="REMARK" property="remark" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="UPDATED_DATE_TIME" property="updatedDateTime" />
        <result column="CREATE_USER_BO" property="createUserBo" />
        <result column="UPDATE_USER_BO" property="updateUserBo" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, NAME, DESCRIPTION, JOB_CLASS, JOB_GROUP, JOB_PARAM, REMARK, CREATED_DATE_TIME, UPDATED_DATE_TIME, CREATE_USER_BO, UPDATE_USER_BO
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_SYSTEM_JOB
        <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_SYSTEM_JOB 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_SYSTEM_JOB
        <where>
            <if test="ew.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.site!=null"> AND SITE=#{ew.site}</if>
            <if test="ew.name!=null"> AND NAME=#{ew.name}</if>
            <if test="ew.description!=null"> AND DESCRIPTION=#{ew.description}</if>
            <if test="ew.jobClass!=null"> AND JOB_CLASS=#{ew.jobClass}</if>
            <if test="ew.jobGroup!=null"> AND JOB_GROUP=#{ew.jobGroup}</if>
            <if test="ew.jobParam!=null"> AND JOB_PARAM=#{ew.jobParam}</if>
            <if test="ew.remark!=null"> AND REMARK=#{ew.remark}</if>
            <if test="ew.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.createdDateTime}</if>
            <if test="ew.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.updatedDateTime}</if>
            <if test="ew.createUserBo!=null"> AND CREATE_USER_BO=#{ew.createUserBo}</if>
            <if test="ew.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.updateUserBo}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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.quartz.model.SystemJob">
        INSERT INTO Z_SYSTEM_JOB
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="name!=null">NAME,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="jobClass!=null">JOB_CLASS,</if>
            <if test="jobGroup!=null">JOB_GROUP,</if>
            <if test="jobParam!=null">JOB_PARAM,</if>
            <if test="remark!=null">REMARK,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="updatedDateTime!=null">UPDATED_DATE_TIME,</if>
            <if test="createUserBo!=null">CREATE_USER_BO,</if>
            <if test="updateUserBo!=null">UPDATE_USER_BO,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="name!=null">#{name},</if>
            <if test="description!=null">#{description},</if>
            <if test="jobClass!=null">#{jobClass},</if>
            <if test="jobGroup!=null">#{jobGroup},</if>
            <if test="jobParam!=null">#{jobParam},</if>
            <if test="remark!=null">#{remark},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="updatedDateTime!=null">#{updatedDateTime},</if>
            <if test="createUserBo!=null">#{createUserBo},</if>
            <if test="updateUserBo!=null">#{updateUserBo},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.quartz.model.SystemJob">
        INSERT INTO Z_SYSTEM_JOB
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{name},
            #{description},
            #{jobClass},
            #{jobGroup},
            #{jobParam},
            #{remark},
            #{createdDateTime},
            #{updatedDateTime},
            #{createUserBo},
            #{updateUserBo},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_SYSTEM_JOB <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.name!=null">NAME=#{et.name},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.jobClass!=null">JOB_CLASS=#{et.jobClass},</if>
        <if test="et.jobGroup!=null">JOB_GROUP=#{et.jobGroup},</if>
        <if test="et.jobParam!=null">JOB_PARAM=#{et.jobParam},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.updatedDateTime!=null">UPDATED_DATE_TIME=#{et.updatedDateTime},</if>
        <if test="et.createUserBo!=null">CREATE_USER_BO=#{et.createUserBo},</if>
        <if test="et.updateUserBo!=null">UPDATE_USER_BO=#{et.updateUserBo},</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_SYSTEM_JOB <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        NAME=#{et.name},
        DESCRIPTION=#{et.description},
        JOB_CLASS=#{et.jobClass},
        JOB_GROUP=#{et.jobGroup},
        JOB_PARAM=#{et.jobParam},
        REMARK=#{et.remark},
        CREATED_DATE_TIME=#{et.createdDateTime},
        UPDATED_DATE_TIME=#{et.updatedDateTime},
        CREATE_USER_BO=#{et.createUserBo},
        UPDATE_USER_BO=#{et.updateUserBo},
     </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_SYSTEM_JOB <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.name!=null">NAME=#{et.name},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.jobClass!=null">JOB_CLASS=#{et.jobClass},</if>
        <if test="et.jobGroup!=null">JOB_GROUP=#{et.jobGroup},</if>
        <if test="et.jobParam!=null">JOB_PARAM=#{et.jobParam},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.updatedDateTime!=null">UPDATED_DATE_TIME=#{et.updatedDateTime},</if>
        <if test="et.createUserBo!=null">CREATE_USER_BO=#{et.createUserBo},</if>
        <if test="et.updateUserBo!=null">UPDATE_USER_BO=#{et.updateUserBo},</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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_SYSTEM_JOB
        <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_SYSTEM_JOB
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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_SYSTEM_JOB WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->

    <resultMap id="SystemJobDTO" type="com.foreverwin.mesnac.quartz.dto.SystemJobDTO" extends="BaseResultMap">
        <result column="CRON_EXPRESSION" property="cronExpression" />
        <result column="PREV_FIRE_TIME" property="prevFireTime" />
        <result column="NEXT_FIRE_TIME" property="nextFireTime" />
        <result column="START_TIME" property="startTime" />
        <result column="TRIGGER_STATE" property="triggerState" />
    </resultMap>

    <!-- 自定义查询/修改/删除 -->
    <select id="selectPageSystemJob" resultMap="SystemJobDTO">
        SELECT * FROM (
        SELECT qct.CRON_EXPRESSION, qt.PREV_FIRE_TIME, qt.NEXT_FIRE_TIME, qt.START_TIME, qt.TRIGGER_STATE,
            mt.*
        FROM Z_SYSTEM_JOB mt
        LEFT JOIN QRTZ_TRIGGERS qt ON qt.JOB_NAME = mt.NAME AND qt.JOB_GROUP = mt.JOB_GROUP
        LEFT JOIN QRTZ_CRON_TRIGGERS qct ON qt.TRIGGER_NAME = qct.TRIGGER_NAME AND qt.TRIGGER_GROUP = qct.TRIGGER_GROUP
        )T
        <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.name!=null"> AND NAME=#{ew.entity.name}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.jobClass!=null"> AND JOB_CLASS=#{ew.entity.jobClass}</if>
                    <if test="ew.entity.jobGroup!=null"> AND JOB_GROUP=#{ew.entity.jobGroup}</if>
                    <if test="ew.entity.jobParam!=null"> AND JOB_PARAM=#{ew.entity.jobParam}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
                    <if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
                    <if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</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="selectSystemJobList" resultMap="SystemJobDTO">
        SELECT qct.CRON_EXPRESSION, qt.PREV_FIRE_TIME, qt.NEXT_FIRE_TIME, qt.START_TIME, qt.TRIGGER_STATE,
            mt.*
        FROM Z_SYSTEM_JOB mt
        LEFT JOIN QRTZ_TRIGGERS qt ON qt.JOB_NAME = mt.NAME AND qt.JOB_GROUP = mt.JOB_GROUP
        LEFT JOIN QRTZ_CRON_TRIGGERS qct ON qt.TRIGGER_NAME = qct.TRIGGER_NAME AND qt.TRIGGER_GROUP = qct.TRIGGER_GROUP
    </select>
</mapper>
