czsj/czsj-system/src/main/resources/mapper/bigdata/JobInfoMapper.xml

343 lines
10 KiB
XML

<?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.czsj.bigdata.mapper.JobInfoMapper">
<resultMap id="JobProject" type="com.czsj.bigdata.entity.JobInfo">
<result column="project_id" property="projectId"/>
</resultMap>
<resultMap id="JobInfo" type="com.czsj.bigdata.entity.JobInfo" >
<result column="id" property="id" />
<result column="job_group" property="jobGroup" />
<result column="job_cron" property="jobCron" />
<result column="job_desc" property="jobDesc" />
<result column="add_time" property="addTime" />
<result column="update_time" property="updateTime" />
<result column="user_id" property="userId" />
<result column="alarm_email" property="alarmEmail" />
<result column="executor_route_strategy" property="executorRouteStrategy" />
<result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" />
<result column="executor_block_strategy" property="executorBlockStrategy" />
<result column="executor_timeout" property="executorTimeout" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
<result column="glue_type" property="glueType" />
<result column="glue_source" property="glueSource" />
<result column="glue_remark" property="glueRemark" />
<result column="glue_updatetime" property="glueUpdatetime" />
<result column="child_jobid" property="childJobId" />
<result column="trigger_status" property="triggerStatus" />
<result column="trigger_last_time" property="triggerLastTime" />
<result column="trigger_next_time" property="triggerNextTime" />
<result column="job_json" property="jobJson" />
<result column="replace_param" property="replaceParam" />
<result column="jvm_param" property="jvmParam" />
<result column="inc_start_time" property="incStartTime" />
<result column="partition_info" property="partitionInfo" />
<result column="last_handle_code" property="lastHandleCode" />
<result column="replace_param_type" property="replaceParamType" />
<result column="project_id" property="projectId"/>
<result column="reader_table" property="readerTable" />
<result column="primary_key" property="primaryKey" />
<result column="inc_start_id" property="incStartId" />
<result column="increment_type" property="incrementType" />
<result column="datasource_id" property="datasourceId" />
</resultMap>
<sql id="Base_Column_List">
t.id,
t.job_group,
t.job_cron,
t.job_desc,
t.add_time,
t.update_time,
t.user_id,
t.alarm_email,
t.executor_route_strategy,
t.executor_handler,
t.executor_param,
t.executor_block_strategy,
t.executor_timeout,
t.executor_fail_retry_count,
t.glue_type,
t.glue_source,
t.glue_remark,
t.glue_updatetime,
t.child_jobid,
t.trigger_status,
t.trigger_last_time,
t.trigger_next_time,
t.job_json,
t.replace_param,
t.jvm_param,
t.inc_start_time,
t.partition_info,
t.last_handle_code,
t.replace_param_type,
t.project_id,
t.reader_table,
t.primary_key,
t.inc_start_id,
t.increment_type,
t.datasource_id
</sql>
<sql id="Project_Column_List">
p.name as project_name
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />,<include refid="Project_Column_List" />
FROM job_info AS t
INNER JOIN job_project p on t.project_id=p.id
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
<if test="triggerStatus gte 0">
AND t.trigger_status = #{triggerStatus}
</if>
<if test="jobDesc != null and jobDesc != ''">
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
</if>
<if test="glueType != null and glueType != ''">
AND t.glue_type like CONCAT(CONCAT('%', #{glueType}), '%')
</if>
<if test="userId gt 0">
AND t.user_id = #{userId}
</if>
<if test="projectIds != null and projectIds.length != 0">
AND t.project_id IN
<foreach collection="projectIds" item="projectId" index="index" open="(" close=")" separator=",">
#{projectId}
</foreach>
</if>
</trim>
ORDER BY id DESC
LIMIT #{offset}, #{pagesize}
</select>
<select id="findAll" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />
FROM job_info AS t
ORDER BY job_desc ASC
</select>
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
SELECT count(1)
FROM job_info AS t
INNER JOIN job_project p on t.project_id=p.id
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
<if test="triggerStatus gte 0">
AND t.trigger_status = #{triggerStatus}
</if>
<if test="jobDesc != null and jobDesc != ''">
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
</if>
<if test="glueType != null and glueType != ''">
AND t.glue_type like CONCAT(CONCAT('%', #{glueType}), '%')
</if>
<if test="userId gt 0">
AND t.user_id =#{userId}
</if>
<if test="projectIds != null and projectIds.length != 0">
AND t.project_id IN
<foreach collection="projectIds" item="projectId" index="index" open="(" close=")" separator=",">
#{projectId}
</foreach>
</if>
</trim>
</select>
<insert id="save" parameterType="com.czsj.bigdata.entity.JobInfo" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO job_info (
job_group,
job_cron,
job_desc,
add_time,
update_time,
user_id,
alarm_email,
executor_route_strategy,
executor_handler,
executor_param,
executor_block_strategy,
executor_timeout,
executor_fail_retry_count,
glue_type,
glue_source,
glue_remark,
glue_updatetime,
child_jobid,
trigger_status,
trigger_last_time,
trigger_next_time,
job_json,
replace_param,
jvm_param,
inc_start_time,
partition_info,
last_handle_code,
replace_param_type,
project_id,
reader_table,
primary_key,
inc_start_id,
increment_type,
datasource_id
) VALUES (
#{jobGroup},
#{jobCron},
#{jobDesc},
#{addTime},
#{updateTime},
#{userId},
#{alarmEmail},
#{executorRouteStrategy},
#{executorHandler},
#{executorParam},
#{executorBlockStrategy},
#{executorTimeout},
#{executorFailRetryCount},
#{glueType},
#{glueSource},
#{glueRemark},
#{glueUpdatetime},
#{childJobId},
#{triggerStatus},
#{triggerLastTime},
#{triggerNextTime},
#{jobJson},
#{replaceParam},
#{jvmParam},
#{incStartTime},
#{partitionInfo},
#{lastHandleCode},
#{replaceParamType},
#{projectId},
#{readerTable},
#{primaryKey},
#{incStartId},
#{incrementType},
#{datasourceId}
);
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
/*SELECT @@IDENTITY AS id*/
</selectKey>-->
</insert>
<select id="loadById" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />
FROM job_info AS t
WHERE t.id = #{id}
</select>
<update id="update" parameterType="com.czsj.bigdata.entity.JobInfo" >
UPDATE job_info
SET
job_group = #{jobGroup},
job_cron = #{jobCron},
job_desc = #{jobDesc},
update_time = #{updateTime},
user_id = #{userId},
alarm_email = #{alarmEmail},
executor_route_strategy = #{executorRouteStrategy},
executor_handler = #{executorHandler},
executor_param = #{executorParam},
executor_block_strategy = #{executorBlockStrategy},
executor_timeout = ${executorTimeout},
executor_fail_retry_count = ${executorFailRetryCount},
glue_type = #{glueType},
glue_source = #{glueSource},
glue_remark = #{glueRemark},
glue_updatetime = #{glueUpdatetime},
child_jobid = #{childJobId},
trigger_status = #{triggerStatus},
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime},
job_json=#{jobJson},
replace_param=#{replaceParam},
jvm_param=#{jvmParam},
inc_start_time=#{incStartTime},
partition_info=#{partitionInfo},
last_handle_code=#{lastHandleCode},
replace_param_type=#{replaceParamType},
project_id=#{projectId},
reader_table = #{readerTable},
primary_key = #{primaryKey},
inc_start_id = #{incStartId},
increment_type = #{incrementType},
datasource_id= #{datasourceId}
WHERE id = #{id}
</update>
<delete id="delete" parameterType="java.util.HashMap">
DELETE
FROM job_info
WHERE id = #{id}
</delete>
<select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />
FROM job_info AS t
WHERE t.job_group = #{jobGroup}
</select>
<select id="findAllCount" resultType="int">
SELECT count(1)
FROM job_info
</select>
<select id="scheduleJobQuery" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />
FROM job_info AS t
WHERE t.trigger_status = 1
and t.trigger_next_time <![CDATA[ <= ]]> #{maxNextTime}
ORDER BY id ASC
LIMIT #{pagesize}
</select>
<update id="scheduleUpdate" parameterType="com.czsj.bigdata.entity.JobInfo" >
UPDATE job_info
SET
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime},
trigger_status = #{triggerStatus}
WHERE id = #{id}
</update>
<update id="incrementTimeUpdate" parameterType="java.util.HashMap">
UPDATE job_info
SET
inc_start_time = #{incStartTime}
WHERE id = #{id}
</update>
<update id="updateLastHandleCode" parameterType="java.util.HashMap">
UPDATE job_info
SET
last_handle_code = #{lastHandleCode}
WHERE id = #{id}
</update>
<update id="incrementIdUpdate" parameterType="java.util.HashMap">
UPDATE job_info
SET
inc_start_id = #{incStartId}
WHERE id = #{id}
</update>
</mapper>