Xxl-job-admin 数据库使用DM8/达梦改造

Xxl-job 简介

XXL-JOB是一个分布式任务调度平台,其核心设计目标是开发迅速、学习简单、轻量级、易扩展。

XXL-JOB-ADMIN 是针对分布式定时任务管理的Web管理平台,默认使用的数据库是MySQL 8版本。

业务背景 

        在项目中使用分布式定时任务调度框架:xxl-job, 并通过xxl-job-admin 管理平台控制定时任务的开启、执行周期设置等等相关操作。由于现场客户的数据库为国产化数据库:DM8/达梦,要求我们必须把xxl-job-admin 管理平台必须有MySQL 8 切换为DM 8/达梦 数据库,本文是针对我在数据库替换中的重点记录。

数据库替换

1、Windows 安装DM 8/ 达梦数据库 

请参考文章:达梦数据库DM8-windows环境安装(图文详情)

2、 MySQL 8 导入xxl-job-admin 依赖的数据库xxl-job

tables-xxl-job.sql 数据库初始化文件存放目录地址:xxl-job-admin/doc/db/tables-xxl-job.sql 

#
# XXL-JOB v2.3.0-SNAPSHOT
# Copyright (c) 2015-present, xuxueli.CREATE database if NOT EXISTS `xxl_job` default character set utf8mb4 collate utf8mb4_unicode_ci;
use `xxl_job`;SET NAMES utf8mb4;CREATE TABLE `xxl_job_info` (`id` int(11) NOT NULL AUTO_INCREMENT,`job_group` int(11) NOT NULL COMMENT '执行器主键ID',`job_desc` varchar(255) NOT NULL,`add_time` datetime DEFAULT NULL,`update_time` datetime DEFAULT NULL,`author` varchar(64) DEFAULT NULL COMMENT '作者',`alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件',`schedule_type` varchar(50) NOT NULL DEFAULT 'NONE' COMMENT '调度类型',`schedule_conf` varchar(128) DEFAULT NULL COMMENT '调度配置,值含义取决于调度类型',`misfire_strategy` varchar(50) NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略',`executor_route_strategy` varchar(50) DEFAULT NULL COMMENT '执行器路由策略',`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',`executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略',`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',`glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',`glue_source` mediumtext COMMENT 'GLUE源代码',`glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',`glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间',`child_jobid` varchar(255) DEFAULT NULL COMMENT '子任务ID,多个逗号分隔',`trigger_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '调度状态:0-停止,1-运行',`trigger_last_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '上次调度时间',`trigger_next_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '下次调度时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_log` (`id` bigint(20) NOT NULL AUTO_INCREMENT,`job_group` int(11) NOT NULL COMMENT '执行器主键ID',`job_id` int(11) NOT NULL COMMENT '任务,主键ID',`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',`executor_sharding_param` varchar(20) DEFAULT NULL COMMENT '执行器任务分片参数,格式如 1/2',`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',`trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',`trigger_code` int(11) NOT NULL COMMENT '调度-结果',`trigger_msg` text COMMENT '调度-日志',`handle_time` datetime DEFAULT NULL COMMENT '执行-时间',`handle_code` int(11) NOT NULL COMMENT '执行-状态',`handle_msg` text COMMENT '执行-日志',`alarm_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败',PRIMARY KEY (`id`),KEY `I_trigger_time` (`trigger_time`),KEY `I_handle_code` (`handle_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_log_report` (`id` int(11) NOT NULL AUTO_INCREMENT,`trigger_day` datetime DEFAULT NULL COMMENT '调度-时间',`running_count` int(11) NOT NULL DEFAULT '0' COMMENT '运行中-日志数量',`suc_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',`fail_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',`update_time` datetime DEFAULT NULL,PRIMARY KEY (`id`),UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_logglue` (`id` int(11) NOT NULL AUTO_INCREMENT,`job_id` int(11) NOT NULL COMMENT '任务,主键ID',`glue_type` varchar(50) DEFAULT NULL COMMENT 'GLUE类型',`glue_source` mediumtext COMMENT 'GLUE源代码',`glue_remark` varchar(128) NOT NULL COMMENT 'GLUE备注',`add_time` datetime DEFAULT NULL,`update_time` datetime DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_registry` (`id` int(11) NOT NULL AUTO_INCREMENT,`registry_group` varchar(50) NOT NULL,`registry_key` varchar(255) NOT NULL,`registry_value` varchar(255) NOT NULL,`update_time` datetime DEFAULT NULL,PRIMARY KEY (`id`),KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_group` (`id` int(11) NOT NULL AUTO_INCREMENT,`app_name` varchar(64) NOT NULL COMMENT '执行器AppName',`title` varchar(12) NOT NULL COMMENT '执行器名称',`address_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '执行器地址类型:0=自动注册、1=手动录入',`address_list` text COMMENT '执行器地址列表,多地址逗号分隔',`update_time` datetime DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(50) NOT NULL COMMENT '账号',`password` varchar(50) NOT NULL COMMENT '密码',`role` tinyint(4) NOT NULL COMMENT '角色:0-普通用户、1-管理员',`permission` varchar(255) DEFAULT NULL COMMENT '权限:执行器ID列表,多个逗号分割',PRIMARY KEY (`id`),UNIQUE KEY `i_username` (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;CREATE TABLE `xxl_job_lock` (`lock_name` varchar(50) NOT NULL COMMENT '锁名称',PRIMARY KEY (`lock_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;INSERT INTO `xxl_job_group`(`id`, `app_name`, `title`, `address_type`, `address_list`, `update_time`) VALUES (1, 'xxl-job-executor-sample', '示例执行器', 0, NULL, '2018-11-03 22:21:31' );
INSERT INTO `xxl_job_info`(`id`, `job_group`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`, `schedule_type`, `schedule_conf`, `misfire_strategy`, `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`) VALUES (1, 1, '测试任务1', '2018-11-03 22:21:31', '2018-11-03 22:21:31', 'XXL', '', 'CRON', '0 0 0 * * ? *', 'DO_NOTHING', 'FIRST', 'demoJobHandler', '', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'GLUE代码初始化', '2018-11-03 22:21:31', '');
INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL);
INSERT INTO `xxl_job_lock` ( `lock_name`) VALUES ( 'schedule_lock');commit;

3、使用DM 8 数据迁移工具,实现MySQL 8  迁移至 DM 8

1、第一步:新建迁移,填写迁移名称为:xxl-job 数据库迁移

2、第二步:指定MySQL 8 数据库IP、端口、用户名和密码

 温馨提示:DM 8 默认提供MySQL 5.1 驱动版本,如果是MySQL 其他版本需要指定MySQL 驱动版本。

3、第三步:指定DM 8 数据库IP、端口、用户名和密码

温馨提示:这里使用DM 8 自带驱动版本。

4、配置迁移选项,默认即可。

 5、选择MySQL 8 迁移库和DM 8 接收库

6、选择MySQL 8 同步的库表

 7、查看需要同步的库表,点击完成‘按钮’,开始数据库同步操作。

 xxl-job-admin 源码变更

xxl-job-admin GitHub 下载地址:https://github.com/xxl-job/xxl-job-admin/

pom.xml 和application.properties 配置文件修改 

xxl-job-admin 的pom.xml 文件添加DM 8 数据库驱动:

请参考:IDEA中Maven项目快速导入本地jar包 

效果截图:

application.properties 配置文件:移除MySQL 8 添加DM 8 配置

### xxl-job, datasource
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=root_pwd
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# DM8 datasource 
spring.datasource.url=jdbc:dm://localhost:5236/xxl_job
spring.datasource.username=SYSDBA
spring.datasource.password=Qwe123456
spring.datasource.driver-class-name=dm.jdbc.driver.DmDriver

修改mybatis-mapper 目录下自定义SQL文件

XxlJobGroupMapper.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.xxl.job.admin.dao.XxlJobGroupDao"><resultMap id="XxlJobGroup" type="com.xxl.job.admin.core.model.XxlJobGroup" ><result column="id" property="id" /><result column="app_name" property="appname" /><result column="title" property="title" /><result column="address_type" property="addressType" /><result column="address_list" property="addressList" /><result column="update_time" property="updateTime" /></resultMap><sql id="Base_Column_List">t.id,t.app_name,t.title,t.address_type,t.address_list,t.update_time</sql><select id="findAll" resultMap="XxlJobGroup">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_GROUP" AS tORDER BY t.app_name, t.title, t.id ASC</select><select id="findByAddressType" parameterType="java.lang.Integer" resultMap="XxlJobGroup">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_GROUP" AS tWHERE t.address_type = #{addressType}ORDER BY t.app_name, t.title, t.id ASC</select><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_GROUP" ( app_name, title, address_type, address_list, update_time)values ( #{appname}, #{title}, #{addressType}, #{addressList}, #{updateTime} );</insert><update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" >UPDATE "xxl_job"."XXL_JOB_GROUP"SET app_name = #{appname},title = #{title},address_type = #{addressType},address_list = #{addressList},update_time = #{updateTime}WHERE id = #{id}</update><delete id="remove" parameterType="java.lang.Integer" >DELETE FROM "xxl_job"."XXL_JOB_GROUP"WHERE id = #{id}</delete><select id="load" parameterType="java.lang.Integer" resultMap="XxlJobGroup">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_GROUP" AS tWHERE t.id = #{id}</select><select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobGroup">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_GROUP" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="appname != null and appname != ''">AND t.app_name like CONCAT(CONCAT('%', #{appname}), '%')</if><if test="title != null and title != ''">AND t.title like CONCAT(CONCAT('%', #{title}), '%')</if></trim>ORDER BY t.app_name, t.title, t.id ASCLIMIT #{offset}, #{pagesize}</select><select id="pageListCount" parameterType="java.util.HashMap" resultType="int">SELECT count(1)FROM "xxl_job"."XXL_JOB_GROUP" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="appname != null and appname != ''">AND t.app_name like CONCAT(CONCAT('%', #{appname}), '%')</if><if test="title != null and title != ''">AND t.title like CONCAT(CONCAT('%', #{title}), '%')</if></trim></select></mapper>

XxlJobInfoMapper.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.xxl.job.admin.dao.XxlJobInfoDao"><resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" ><result column="id" property="id" /><result column="job_group" property="jobGroup" /><result column="job_desc" property="jobDesc" /><result column="add_time" property="addTime" /><result column="update_time" property="updateTime" /><result column="author" property="author" /><result column="alarm_email" property="alarmEmail" /><result column="schedule_type" property="scheduleType" /><result column="schedule_conf" property="scheduleConf" /><result column="misfire_strategy" property="misfireStrategy" /><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" /></resultMap><sql id="Base_Column_List">t.id,t.job_group,t.job_desc,t.add_time,t.update_time,t.author,t.alarm_email,t.schedule_type,t.schedule_conf,t.misfire_strategy,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</sql><select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_INFO" AS t<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="executorHandler != null and executorHandler != ''">AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')</if><if test="author != null and author != ''">AND t.author like CONCAT(CONCAT('%', #{author}), '%')</if></trim>ORDER BY id DESCLIMIT #{offset}, #{pagesize}</select><select id="pageListCount" parameterType="java.util.HashMap" resultType="int">SELECT count(1)FROM "xxl_job"."XXL_JOB_INFO" AS t<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="executorHandler != null and executorHandler != ''">AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')</if><if test="author != null and author != ''">AND t.author like CONCAT(CONCAT('%', #{author}), '%')</if></trim></select><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_INFO" (job_group,job_desc,add_time,update_time,author,alarm_email,schedule_type,schedule_conf,misfire_strategy,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) VALUES (#{jobGroup},#{jobDesc},#{addTime},#{updateTime},#{author},#{alarmEmail},#{scheduleType},#{scheduleConf},#{misfireStrategy},#{executorRouteStrategy},#{executorHandler},#{executorParam},#{executorBlockStrategy},#{executorTimeout},#{executorFailRetryCount},#{glueType},#{glueSource},#{glueRemark},#{glueUpdatetime},#{childJobId},#{triggerStatus},#{triggerLastTime},#{triggerNextTime});<!--<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="XxlJobInfo">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_INFO" AS tWHERE t.id = #{id}</select><update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >UPDATE "xxl_job"."XXL_JOB_INFO"SETjob_group = #{jobGroup},job_desc = #{jobDesc},update_time = #{updateTime},author = #{author},alarm_email = #{alarmEmail},schedule_type = #{scheduleType},schedule_conf = #{scheduleConf},misfire_strategy = #{misfireStrategy},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}WHERE id = #{id}</update><delete id="delete" parameterType="java.util.HashMap">DELETEFROM "xxl_job"."XXL_JOB_INFO"WHERE id = #{id}</delete><select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="XxlJobInfo">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_INFO" AS tWHERE t.job_group = #{jobGroup}</select><select id="findAllCount" resultType="int">SELECT count(1)FROM "xxl_job"."XXL_JOB_INFO"</select><select id="scheduleJobQuery" parameterType="java.util.HashMap" resultMap="XxlJobInfo">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_INFO" AS tWHERE t.trigger_status = 1and t.trigger_next_time <![CDATA[ <= ]]> #{maxNextTime}ORDER BY id ASCLIMIT #{pagesize}</select><update id="scheduleUpdate" parameterType="com.xxl.job.admin.core.model.XxlJobInfo"  >UPDATE "xxl_job"."XXL_JOB_INFO"SETtrigger_last_time = #{triggerLastTime},trigger_next_time = #{triggerNextTime},trigger_status = #{triggerStatus}WHERE id = #{id}</update></mapper>

XxlJobLogGlueMapper.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.xxl.job.admin.dao.XxlJobLogGlueDao"><resultMap id="XxlJobLogGlue" type="com.xxl.job.admin.core.model.XxlJobLogGlue" ><result column="id" property="id" /><result column="job_id" property="jobId" /><result column="glue_type" property="glueType" /><result column="glue_source" property="glueSource" /><result column="glue_remark" property="glueRemark" /><result column="add_time" property="addTime" /><result column="update_time" property="updateTime" /></resultMap><sql id="Base_Column_List">t.id,t.job_id,t.glue_type,t.glue_source,t.glue_remark,t.add_time,t.update_time</sql><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLogGlue" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_LOGGLUE" (job_id,glue_type,glue_source,glue_remark,add_time,update_time) VALUES (#{jobId},#{glueType},#{glueSource},#{glueRemark},#{addTime},#{updateTime});<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">SELECT LAST_INSERT_ID()</selectKey>--></insert><select id="findByJobId" parameterType="java.lang.Integer" resultMap="XxlJobLogGlue">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_LOGGLUE" AS tWHERE t.job_id = #{jobId}ORDER BY id DESC</select><delete id="removeOld" >DELETE FROM "xxl_job"."XXL_JOB_LOGGLUE"WHERE id NOT in(SELECT id FROM(SELECT id FROM "xxl_job"."XXL_JOB_LOGGLUE"WHERE job_id = #{jobId}ORDER BY update_time descLIMIT 0, #{limit}) t1) AND job_id = #{jobId}</delete><delete id="deleteByJobId" parameterType="java.lang.Integer" >DELETE FROM "xxl_job"."XXL_JOB_LOGGLUE"WHERE job_id = #{jobId}</delete></mapper>

XxlJobLogMapper.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.xxl.job.admin.dao.XxlJobLogDao"><resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" ><result column="id" property="id" /><result column="job_group" property="jobGroup" /><result column="job_id" property="jobId" /><result column="executor_address" property="executorAddress" /><result column="executor_handler" property="executorHandler" /><result column="executor_param" property="executorParam" /><result column="executor_sharding_param" property="executorShardingParam" /><result column="executor_fail_retry_count" property="executorFailRetryCount" /><result column="trigger_time" property="triggerTime" /><result column="trigger_code" property="triggerCode" /><result column="trigger_msg" property="triggerMsg" /><result column="handle_time" property="handleTime" /><result column="handle_code" property="handleCode" /><result column="handle_msg" property="handleMsg" /><result column="alarm_status" property="alarmStatus" /></resultMap><sql id="Base_Column_List">t.id,t.job_group,t.job_id,t.executor_address,t.executor_handler,t.executor_param,t.executor_sharding_param,t.executor_fail_retry_count,t.trigger_time,t.trigger_code,t.trigger_msg,t.handle_time,t.handle_code,t.handle_msg,t.alarm_status</sql><select id="pageList" resultMap="XxlJobLog">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_LOG" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="jobId==0 and jobGroup gt 0">AND t.job_group = #{jobGroup}</if><if test="jobId gt 0">AND t.job_id = #{jobId}</if><if test="triggerTimeStart != null">AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}</if><if test="triggerTimeEnd != null">AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}</if><if test="logStatus == 1" >AND t.handle_code = 200</if><if test="logStatus == 2" >AND (t.trigger_code NOT IN (0, 200) ORt.handle_code NOT IN (0, 200))</if><if test="logStatus == 3" >AND t.trigger_code = 200AND t.handle_code = 0</if></trim>ORDER BY t.trigger_time DESCLIMIT #{offset}, #{pagesize}</select><select id="pageListCount" resultType="int">SELECT count(1)FROM "xxl_job"."XXL_JOB_LOG" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="jobId==0 and jobGroup gt 0">AND t.job_group = #{jobGroup}</if><if test="jobId gt 0">AND t.job_id = #{jobId}</if><if test="triggerTimeStart != null">AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}</if><if test="triggerTimeEnd != null">AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}</if><if test="logStatus == 1" >AND t.handle_code = 200</if><if test="logStatus == 2" >AND (t.trigger_code NOT IN (0, 200) ORt.handle_code NOT IN (0, 200))</if><if test="logStatus == 3" >AND t.trigger_code = 200AND t.handle_code = 0</if></trim></select><select id="load" parameterType="java.lang.Long" resultMap="XxlJobLog">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_LOG" AS tWHERE t.id = #{id}</select><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_LOG" (job_group,job_id,trigger_time,trigger_code,handle_code) VALUES (#{jobGroup},#{jobId},#{triggerTime},#{triggerCode},#{handleCode});<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">SELECT LAST_INSERT_ID()</selectKey>--></insert><update id="updateTriggerInfo" >UPDATE "xxl_job"."XXL_JOB_LOG"SETtrigger_time= #{triggerTime},trigger_code= #{triggerCode},trigger_msg= #{triggerMsg},executor_address= #{executorAddress},executor_handler=#{executorHandler},executor_param= #{executorParam},executor_sharding_param= #{executorShardingParam},executor_fail_retry_count= #{executorFailRetryCount}WHERE `id`= #{id}</update><update id="updateHandleInfo">UPDATE "xxl_job"."XXL_JOB_LOG"SEThandle_time= #{handleTime},handle_code= #{handleCode},handle_msg= #{handleMsg}WHERE `id`= #{id}</update><delete id="delete" >delete from "xxl_job"."XXL_JOB_LOG"WHERE job_id = #{jobId}</delete><!--<select id="triggerCountByDay" resultType="java.util.Map" >SELECTDATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,COUNT(handle_code) triggerDayCount,SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSucFROM xxl_job_logWHERE trigger_time BETWEEN #{from} and #{to}GROUP BY triggerDayORDER BY triggerDay</select>--><select id="findLogReport" resultType="java.util.Map" >SELECTCOUNT(handle_code) triggerDayCount,SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSucFROM "xxl_job"."XXL_JOB_LOG"WHERE trigger_time BETWEEN #{from} and #{to}</select><select id="findClearLogIds" resultType="long" >SELECT id FROM "xxl_job"."XXL_JOB_LOG"<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="jobGroup gt 0">AND job_group = #{jobGroup}</if><if test="jobId gt 0">AND job_id = #{jobId}</if><if test="clearBeforeTime != null">AND trigger_time <![CDATA[ <= ]]> #{clearBeforeTime}</if><if test="clearBeforeNum gt 0">AND id NOT in(SELECT id FROM(SELECT id FROM "xxl_job"."XXL_JOB_LOG" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="jobGroup gt 0">AND t.job_group = #{jobGroup}</if><if test="jobId gt 0">AND t.job_id = #{jobId}</if></trim>ORDER BY t.trigger_time descLIMIT 0, #{clearBeforeNum}) t1)</if></trim>order by id ascLIMIT #{pagesize}</select><delete id="clearLog" >delete from "xxl_job"."XXL_JOB_LOG"WHERE id in<foreach collection="logIds" item="item" open="(" close=")" separator="," >#{item}</foreach></delete><select id="findFailJobLogIds" resultType="long" >SELECT id FROM "xxl_job"."XXL_JOB_LOG"WHERE !((trigger_code in (0, 200) and handle_code = 0)OR(handle_code = 200))AND alarm_status = 0ORDER BY id ASCLIMIT #{pagesize}</select><update id="updateAlarmStatus" >UPDATE "xxl_job"."XXL_JOB_LOG"SETalarm_status = #{newAlarmStatus}WHERE id= #{logId} AND alarm_status = #{oldAlarmStatus}</update><select id="findLostJobIds" resultType="long" >SELECT t.idFROM "xxl_job"."XXL_JOB_LOG" AS tWHERE t.trigger_code = 200and t.handle_code = 0and t.trigger_time <![CDATA[ <= ]]> #{losedTime}and t.executor_address not in (SELECT t2.registry_valueFROM "xxl_job"."XXL_JOB_REGISTRY" AS t2)</select></mapper>

XxlJobLogReportMapper.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.xxl.job.admin.dao.XxlJobLogReportDao"><resultMap id="XxlJobLogReport" type="com.xxl.job.admin.core.model.XxlJobLogReport" ><result column="id" property="id" /><result column="trigger_day" property="triggerDay" /><result column="running_count" property="runningCount" /><result column="suc_count" property="sucCount" /><result column="fail_count" property="failCount" /></resultMap><sql id="Base_Column_List">t.id,t.trigger_day,t.running_count,t.suc_count,t.fail_count</sql><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLogReport" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_LOG_REPORT" (trigger_day,running_count,suc_count,fail_count) VALUES (#{triggerDay},#{runningCount},#{sucCount},#{failCount});<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">SELECT LAST_INSERT_ID()</selectKey>--></insert><update id="update" >UPDATE "xxl_job"."XXL_JOB_LOG_REPORT"SET running_count = #{runningCount},suc_count = #{sucCount},fail_count = #{failCount}WHERE trigger_day = #{triggerDay}</update><select id="queryLogReport" resultMap="XxlJobLogReport">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_LOG_REPORT" AS tWHERE t.trigger_day between #{triggerDayFrom} and #{triggerDayTo}ORDER BY t.trigger_day ASC</select><select id="queryLogReportTotal" resultMap="XxlJobLogReport">SELECTSUM(running_count) running_count,SUM(suc_count) suc_count,SUM(fail_count) fail_countFROM "xxl_job"."XXL_JOB_LOG_REPORT" AS t</select></mapper>

XxlJobRegistryMapper.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.xxl.job.admin.dao.XxlJobRegistryDao"><resultMap id="XxlJobRegistry" type="com.xxl.job.admin.core.model.XxlJobRegistry" ><result column="id" property="id" /><result column="registry_group" property="registryGroup" /><result column="registry_key" property="registryKey" /><result column="registry_value" property="registryValue" /><result column="update_time" property="updateTime" /></resultMap><sql id="Base_Column_List">t.id,t.registry_group,t.registry_key,t.registry_value,t.update_time</sql><select id="findDead" parameterType="java.util.HashMap" resultType="java.lang.Integer" >SELECT t.idFROM "xxl_job"."XXL_JOB_REGISTRY" AS tWHERE t.update_time <![CDATA[ < ]]> DATEADD(SECOND, -#{timeout}, #{nowTime})</select><delete id="removeDead" parameterType="java.lang.Integer" >DELETE FROM "xxl_job"."XXL_JOB_REGISTRY"WHERE id in<foreach collection="ids" item="item" open="(" close=")" separator="," >#{item}</foreach></delete><select id="findAll" parameterType="java.util.HashMap" resultMap="XxlJobRegistry">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_REGISTRY" AS tWHERE t.update_time <![CDATA[ > ]]> DATEADD(SECOND,-#{timeout},#{nowTime})</select><update id="registryUpdate" >UPDATE "xxl_job"."XXL_JOB_REGISTRY"SET update_time = #{updateTime}WHERE registry_group = #{registryGroup}AND registry_key = #{registryKey}AND registry_value = #{registryValue}</update><insert id="registrySave" >INSERT INTO "xxl_job"."XXL_JOB_REGISTRY"( registry_group , registry_key , registry_value, update_time)VALUES( #{registryGroup}  , #{registryKey} , #{registryValue}, #{updateTime})</insert><delete id="registryDelete" >DELETE FROM "xxl_job"."XXL_JOB_REGISTRY"WHERE registry_group = #{registryGroup}AND registry_key = #{registryKey}AND registry_value = #{registryValue}</delete></mapper>

XxlJobUserMapper.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.xxl.job.admin.dao.XxlJobUserDao"><resultMap id="XxlJobUser" type="com.xxl.job.admin.core.model.XxlJobUser" ><result column="id" property="id" /><result column="username" property="username" /><result column="password" property="password" /><result column="role" property="role" /><result column="permission" property="permission" /></resultMap><sql id="Base_Column_List">t.id,t.username,t.password,t.role,t.permission</sql><select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobUser">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_USER" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="username != null and username != ''">AND t.username like CONCAT(CONCAT('%', #{username}), '%')</if><if test="role gt -1">AND t.role = #{role}</if></trim>ORDER BY username ASCLIMIT #{offset}, #{pagesize}</select><select id="pageListCount" parameterType="java.util.HashMap" resultType="int">SELECT count(1)FROM "xxl_job"."XXL_JOB_USER" AS t<trim prefix="WHERE" prefixOverrides="AND | OR" ><if test="username != null and username != ''">AND t.username like CONCAT(CONCAT('%', #{username}), '%')</if><if test="role gt -1">AND t.role = #{role}</if></trim></select><select id="loadByUserName" parameterType="java.util.HashMap" resultMap="XxlJobUser">SELECT <include refid="Base_Column_List" />FROM "xxl_job"."XXL_JOB_USER" AS tWHERE t.username = #{username}</select><insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobUser" useGeneratedKeys="true" keyProperty="id" >INSERT INTO "xxl_job"."XXL_JOB_USER" (username,password,role,permission) VALUES (#{username},#{password},#{role},#{permission});</insert><update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobUser" >UPDATE "xxl_job"."XXL_JOB_USER"SET<if test="password != null and password != ''">password = #{password},</if>role = #{role},permission = #{permission}WHERE id = #{id}</update><delete id="delete" parameterType="java.util.HashMap">DELETEFROM "xxl_job"."XXL_JOB_USER"WHERE id = #{id}</delete></mapper>

com.xxl.job.admin.core.thread.JobScheduleHelper.java 类文件修改

在第73 行代码修改如下:

                        preparedStatement = conn.prepareStatement(  "select * from \"xxl_job\".\"XXL_JOB_LOCK\" where lock_name = 'schedule_lock' for update" );

xxl-job-admin  启动及其简单验证

本地启动xxl-job-admin 项目:

打开浏览器,输入如下地址:http://localhost:8080/xxl-job-admin 

在执行器管理菜单栏中新增一个执行器,并在DM 8 数据库查看是否存在。

 

DM 8 中查看新增执行器数据是否插入成功:

至此xxl-job-admin 数据库替换至此结束。 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/285230.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux---Ubuntu软件卸载

1. 软件卸载的介绍 Ubuntu软件卸载有两种方式: 离线安装包的卸载(deb 文件格式卸载&#xff09;在线安装包的卸载(apt-get 方式卸载) 2. deb 文件格式卸载 命令格式: sudo dpkg –r 安装包名 -r 选项表示安装的卸载 dpkg 卸载效果图: 3. apt-get 方式卸载 命令格式: …

mybatis.interceptor.exception.SqLValidateException:Ilegal SQL::......

现象&#xff1a;⬇️ 描述&#xff1a;执行 SQL 没问题&#xff0c;应用代码报错 ⬇️ .mybatis.interceptor.exception.SqLValidateException&#xff1a;Ilegal SQL::SELECT voucherNo FROM voucher ORDER BY CAST(SUBSTRING(voucherNo FROM LOCATE(_, voucherNo) 1) AS U…

门控网络简介

门控网络是一种循环神经网络 (RNN)&#xff0c;它使用门来控制信息在时间步之间的流动。门是一种神经网络层&#xff0c;它可以选择性地允许或阻止信息通过。 门控网络的主要优点是它们可以解决传统 RNN 中存在的梯度消失问题。梯度消失是指随着时间步的增加&#xff0c;梯度会…

大模型(LLM)+词槽(slot)构建动态场景多轮对话系统

构建动态场景多轮对话系统 引言 在人工智能和自然语言处理领域&#xff0c;聊天机器人的开发一直是一个热点话题。近年来&#xff0c;随着大型语言模型&#xff08;LLM&#xff09;的进步&#xff0c;构建能够理解和响应各种用户需求的聊天机器人变得更加可行和强大。本文将介…

什么店生意好?C++采集美团商家信息做数据分析

最近遇到几个朋友&#xff0c;想要一起合伙投资一个实体店&#xff0c;不问类型&#xff0c;就看哪类产品相对比较受欢迎。抛除地址位置&#xff0c;租金的影响&#xff0c;我们之谈产品。因此&#xff0c;我熬了几个通宵&#xff0c;写了这么一段爬取美团商家商品信息的数据并…

Idea远程debugger调试

当我们服务部署在服务器上&#xff0c;我们想要像在本地一样debug,就可以使用idea自带的Remote JVM Debug 创建Remote JVM Debug服务器启动jar打断点进入断点 当我们服务部署在服务器上&#xff0c;我们想要像在本地一样debug,就可以使用idea自带的 Remote JVM Debug) 创建Rem…

AX7A200教程(9): ov5640摄像头输出显示720p视频

一&#xff0c;功能框图 ov5640摄像头视频通过ddr3缓存后&#xff0c;最后使用hdmi接口进行输出显示 二&#xff0c;摄像头硬件说明 2.1&#xff0c;像头硬件管脚 如下图所示&#xff0c;一共18个管脚 2.2&#xff0c;摄像头电源初始化时序 因这个ov5640摄像头是买的老摄像…

SQL语句整理二--Mysql

文章目录 知识点梳理&#xff1a;1. mysql 中 in 和 exists 区别2. varchar 与 char 的区别 查看表结构&#xff1a;获取当前时间&#xff1a;查看建表语句&#xff1a;修改用户密码&#xff1a;查看所有用户&#xff1a;grant命令&#xff1a;判断当前数据库有多少连接数&…

基于PaddleOCR一键搭建文字识别和身份证识别web api接口

前言 通过这篇文章【基于PaddleOCR的DBNet神经网络实现全网最快最准的身份证识别模型】开发的身份证识别模型&#xff0c;还无法进行部署应用&#xff0c;这篇文章就已经开发好的代码如何部署&#xff0c;并如何通过api的接口进行访问进行讲解。 项目部署 以windows系统为例&…

固件提取实战(附无损提取方案)

文章目录 1. 写在前面2. 设备介绍3. 固件提取4. 固件分析5. 固件提取改进6. 引脚接法 1. 写在前面 固件提取&#xff0c;对博主来讲一直带着一层神秘的面纱&#xff0c;归根结底还是因为博主之前对电路、硬件、嵌入式等等了解比较少&#xff08;说白了就是菜鸡&#xff09;。巧…

蓝桥杯嵌入式——KEY

CUBE里将这几个引脚配置成GPIO输入模式&#xff0c;再同时选中&#xff0c;配置成上拉&#xff0c;如下图&#xff1a; 同时配置定时器&#xff0c;定时10ms&#xff0c;每10ms扫描一次按键&#xff0c;计算公式&#xff1a;80 000 000 / 80 / 10000 100HZ 10ms&#xff0c;配…

【经典LeetCode算法题目专栏分类】【第6期】二分查找系列:x的平方根、有效完全平方数、搜索二位矩阵、寻找旋转排序数组最小值

《博主简介》 小伙伴们好&#xff0c;我是阿旭。专注于人工智能AI、python、计算机视觉相关分享研究。 ✌更多学习资源&#xff0c;可关注公-仲-hao:【阿旭算法与机器学习】&#xff0c;共同学习交流~ &#x1f44d;感谢小伙伴们点赞、关注&#xff01; X的平方根 class Soluti…