cn.ponfee.disjob.supervisor.dao.xml.SchedJobMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of disjob-supervisor Show documentation
Show all versions of disjob-supervisor Show documentation
Distributed job supervisor module
The newest version!
<?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="cn.ponfee.disjob.supervisor.dao.mapper.SchedJobMapper"> <sql id="Table_Name">sched_job</sql> <sql id="Base_Column_List"> job_id, `group`, job_name, job_type, job_state, job_executor, job_param, retry_type, retry_count, retry_interval, trigger_type, trigger_value, start_time, end_time, execute_timeout, collided_strategy, misfire_strategy, route_strategy, shutdown_strategy, remark, last_trigger_time, next_trigger_time, next_scan_time, scan_failed_count, version, updated_by, created_by, updated_at, created_at </sql> <select id="findByJobIds" parameterType="collection" resultType="cn.ponfee.disjob.supervisor.model.SchedJob"> SELECT <include refid="Base_Column_List"/> FROM <include refid="Table_Name" /> WHERE job_id IN (<foreach collection="collection" separator="," item="jobId">#{jobId,jdbcType=BIGINT}</foreach>) AND is_deleted = 0 </select> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="cn.ponfee.disjob.supervisor.model.SchedJob" useGeneratedKeys="true"> INSERT INTO <include refid="Table_Name" /> ( job_id, `group`, job_name, job_type, job_state, job_executor, job_param, retry_type, retry_count, retry_interval, trigger_type, trigger_value, start_time, end_time, execute_timeout, collided_strategy, misfire_strategy, route_strategy, shutdown_strategy, remark, next_trigger_time, updated_by, created_by ) VALUES ( #{jobId,jdbcType=BIGINT}, #{group,jdbcType=VARCHAR}, #{jobName,jdbcType=VARCHAR}, #{jobType,jdbcType=TINYINT}, #{jobState,jdbcType=TINYINT}, #{jobExecutor,jdbcType=LONGVARCHAR}, #{jobParam,jdbcType=LONGVARCHAR}, #{retryType,jdbcType=TINYINT}, #{retryCount,jdbcType=TINYINT}, #{retryInterval,jdbcType=INTEGER}, #{triggerType,jdbcType=TINYINT}, #{triggerValue,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{executeTimeout,jdbcType=INTEGER}, #{collidedStrategy,jdbcType=TINYINT}, #{misfireStrategy,jdbcType=TINYINT}, #{routeStrategy,jdbcType=TINYINT}, #{shutdownStrategy,jdbcType=TINYINT}, #{remark,jdbcType=VARCHAR}, #{nextTriggerTime,jdbcType=BIGINT}, #{updatedBy,jdbcType=VARCHAR}, #{createdBy,jdbcType=VARCHAR} ) </insert> <update id="update" parameterType="cn.ponfee.disjob.supervisor.model.SchedJob"> UPDATE <include refid="Table_Name" /> SET job_name = #{jobName,jdbcType=VARCHAR}, <if test="jobExecutor != null and jobExecutor != ''"> job_executor = #{jobExecutor,jdbcType=LONGVARCHAR}, job_param = #{jobParam,jdbcType=LONGVARCHAR}, job_type = #{jobType,jdbcType=TINYINT}, route_strategy = #{routeStrategy,jdbcType=TINYINT}, </if> job_state = #{jobState,jdbcType=TINYINT}, retry_type = #{retryType,jdbcType=TINYINT}, retry_count = #{retryCount,jdbcType=TINYINT}, retry_interval = #{retryInterval,jdbcType=INTEGER}, start_time = #{startTime,jdbcType=TIMESTAMP}, end_time = #{endTime,jdbcType=TIMESTAMP}, <if test="triggerType != null"> trigger_type = #{triggerType,jdbcType=TINYINT}, trigger_value = #{triggerValue,jdbcType=VARCHAR}, next_trigger_time = #{nextTriggerTime,jdbcType=BIGINT}, </if> execute_timeout = #{executeTimeout,jdbcType=INTEGER}, collided_strategy = #{collidedStrategy,jdbcType=TINYINT}, misfire_strategy = #{misfireStrategy,jdbcType=TINYINT}, shutdown_strategy = #{shutdownStrategy,jdbcType=TINYINT}, <if test="remark != null and remark != ''"> remark = #{remark,jdbcType=VARCHAR}, </if> version = version+1, updated_by = #{updatedBy,jdbcType=VARCHAR} WHERE job_id = #{jobId,jdbcType=BIGINT} AND version = #{version,jdbcType=INTEGER} AND is_deleted = 0 </update> <select id="get" parameterType="_long" resultType="cn.ponfee.disjob.supervisor.model.SchedJob"> SELECT <include refid="Base_Column_List" /> FROM <include refid="Table_Name" /> WHERE job_id = #{jobId,jdbcType=BIGINT} AND is_deleted = 0 </select> <select id="getJobId" resultType="long"> SELECT job_id FROM <include refid="Table_Name" /> WHERE `group` = #{group,jdbcType=VARCHAR} AND job_name = #{jobName,jdbcType=VARCHAR} AND is_deleted = 0 </select> <select id="getGroup" parameterType="_long" resultType="string"> SELECT `group` FROM <include refid="Table_Name" /> WHERE job_id = #{jobId,jdbcType=BIGINT} AND is_deleted = 0 </select> <select id="findBeTriggering" resultType="cn.ponfee.disjob.supervisor.model.SchedJob"> SELECT <include refid="Base_Column_List"/> FROM <include refid="Table_Name" /> WHERE job_state = 1 AND next_trigger_time < #{maxNextTriggerTime} AND next_scan_time < CURRENT_TIMESTAMP(3) AND is_deleted = 0 ORDER BY next_trigger_time LIMIT #{size} </select> <update id="updateNextScanTime" parameterType="cn.ponfee.disjob.supervisor.model.SchedJob"> UPDATE <include refid="Table_Name" /> SET next_scan_time = #{nextScanTime,jdbcType=TIMESTAMP}, scan_failed_count = #{scanFailedCount,jdbcType=INTEGER}, version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND version = #{version,jdbcType=INTEGER} AND is_deleted = 0 </update> <update id="disable" parameterType="cn.ponfee.disjob.supervisor.model.SchedJob"> UPDATE <include refid="Table_Name" /> SET job_state = 0, next_trigger_time = null, remark = #{remark,jdbcType=VARCHAR}, version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND job_state = 1 AND version = #{version,jdbcType=INTEGER} AND is_deleted = 0 </update> <update id="updateNextTriggerTime" parameterType="cn.ponfee.disjob.supervisor.model.SchedJob"> UPDATE <include refid="Table_Name" /> SET job_state = #{jobState,jdbcType=TINYINT}, last_trigger_time = #{lastTriggerTime,jdbcType=BIGINT}, next_trigger_time = #{nextTriggerTime,jdbcType=BIGINT}, scan_failed_count = 0, <if test="jobState == 0"> remark = #{remark,jdbcType=VARCHAR}, </if> version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND job_state = 1 AND version = #{version,jdbcType=INTEGER} AND is_deleted = 0 </update> <update id="updateState"> UPDATE <include refid="Table_Name" /> SET job_state = #{toState,jdbcType=TINYINT}, version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND job_state = #{fromState,jdbcType=TINYINT} AND is_deleted = 0 </update> <update id="updateFixedNextTriggerTime"> UPDATE <include refid="Table_Name" /> SET next_trigger_time = #{nextTriggerTime,jdbcType=BIGINT}, version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND is_deleted = 0 AND job_state = 1 AND trigger_type IN (5, 6) AND last_trigger_time = #{lastTriggerTime,jdbcType=BIGINT} AND next_trigger_time = 9223372036854775807 </update> <update id="softDelete" parameterType="_long"> UPDATE <include refid="Table_Name" /> SET is_deleted = id, version = version+1 WHERE job_id = #{jobId,jdbcType=BIGINT} AND job_state = 0 AND is_deleted = 0 </update> <select id="searchJob" resultType="map"> SELECT CAST(job_id AS CHAR) id, CONCAT(`group`, ' | ', job_name) text FROM <include refid="Table_Name" /> WHERE `group` IN (<foreach collection="groups" separator="," item="g">#{g,jdbcType=VARCHAR}</foreach>) AND is_deleted = 0 <choose> <when test="jobName != null and jobName != '' and jobId != null"> AND ( job_name LIKE #{jobName} OR job_id = #{jobId} ) </when> <when test="jobName != null and jobName != ''"> AND job_name LIKE #{jobName} </when> <when test="jobId != null"> AND job_id = #{jobId} </when> <otherwise> </otherwise> </choose> LIMIT 20 </select> <!-- ********************page query******************** --> <!-- COUNT(*)是SQL 92定义的标准统计行数的语法,优先走普通索引进行统计 --> <select id="queryPageCount" resultType="_long"> SELECT COUNT(*) cnt FROM <include refid="Table_Name" /> <include refid="Query_Page_Condition" /> </select> <!-- 文件导出功能时:paged=false --> <select id="queryPageRecords" resultType="cn.ponfee.disjob.supervisor.model.SchedJob"> SELECT <include refid="Base_Column_List" /> FROM <include refid="Table_Name" /> <include refid="Query_Page_Condition" /> ORDER BY created_at DESC <if test="paged">LIMIT #{offset}, #{pageSize}</if> </select> <sql id="Query_Page_Condition"> WHERE is_deleted = 0 <if test="groups != null and groups.size() != 0"> AND `group` IN (<foreach collection="groups" separator="," item="g">#{g,jdbcType=VARCHAR}</foreach>) </if> <if test="jobName != null and jobName != ''"> AND job_name LIKE CONCAT('%', #{jobName}, '%') </if> <if test="jobType != null"> AND job_type = #{jobType} </if> <if test="jobState != null"> AND job_state = #{jobState} </if> </sql> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy