parent
5fc03bd8aa
commit
74f2c8a879
|
@ -11,7 +11,7 @@
|
||||||
Target Server Version : 50718
|
Target Server Version : 50718
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 14/02/2021 22:48:01
|
Date: 17/02/2021 20:59:32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
|
@ -80,6 +80,79 @@ INSERT INTO `inf_job` VALUES (2, '用户 Session 超时 Job', 3, 'sysUserSession
|
||||||
INSERT INTO `inf_job` VALUES (3, '用户 Session 超时 Job', 1, 'sysUserSessionTimeoutJob', NULL, '0/5 * * * * ? *', NULL, NULL, NULL, NULL, 0, '', '2021-02-07 13:07:32', '', '2021-02-07 13:07:32', b'0');
|
INSERT INTO `inf_job` VALUES (3, '用户 Session 超时 Job', 1, 'sysUserSessionTimeoutJob', NULL, '0/5 * * * * ? *', NULL, NULL, NULL, NULL, 0, '', '2021-02-07 13:07:32', '', '2021-02-07 13:07:32', b'0');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for inf_job_log
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `inf_job_log`;
|
||||||
|
CREATE TABLE `inf_job_log` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '日志编号',
|
||||||
|
`job_id` bigint(20) NOT NULL COMMENT '任务编号',
|
||||||
|
`handler_name` varchar(64) NOT NULL COMMENT '处理器的名字',
|
||||||
|
`handler_param` varchar(255) DEFAULT NULL COMMENT '处理器的参数',
|
||||||
|
`begin_time` datetime NOT NULL COMMENT '开始执行时间',
|
||||||
|
`end_time` datetime DEFAULT NULL COMMENT '结束执行时间',
|
||||||
|
`duration` int(11) DEFAULT NULL COMMENT '执行时长',
|
||||||
|
`status` tinyint(4) NOT NULL COMMENT '任务状态',
|
||||||
|
`result` varchar(4000) DEFAULT '' COMMENT '结果数据',
|
||||||
|
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COMMENT='定时任务表';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of inf_job_log
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `inf_job_log` VALUES (4, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:08', '2021-02-17 20:55:10', 1758, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:00', '', '2021-02-08 00:38:02', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (5, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:10', '2021-02-17 20:55:11', 556, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:02', '', '2021-02-08 00:38:03', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (6, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:11', '2021-02-17 20:55:11', 554, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:03', '', '2021-02-08 00:38:03', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (7, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:11', '2021-02-17 20:55:12', 179, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:03', '', '2021-02-08 00:38:04', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (8, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:12', '2021-02-17 20:55:12', 185, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:04', '', '2021-02-08 00:38:04', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (9, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:12', '2021-02-17 20:55:12', 279, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:04', '', '2021-02-08 00:38:04', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (10, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:15', '2021-02-17 20:55:37', 21590, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:07', '', '2021-02-08 00:38:40', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (11, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:47', '2021-02-17 20:55:52', 4053, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:40', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (12, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 10, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (13, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (14, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (15, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (16, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (17, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:52', '2021-02-17 20:55:52', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:44', '', '2021-02-08 00:38:44', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (18, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:55:55', '2021-02-17 20:55:55', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:47', '', '2021-02-08 00:38:47', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (19, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:00', '2021-02-17 20:56:00', 4, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:52', '', '2021-02-08 00:38:52', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (20, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:05', '2021-02-17 20:56:05', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:38:57', '', '2021-02-08 00:38:57', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (21, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:27', '2021-02-17 20:56:42', 14963, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:19', '', '2021-02-08 00:39:34', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (22, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:42', '2021-02-17 20:56:42', 7, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:34', '', '2021-02-08 00:39:34', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (23, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:42', '2021-02-17 20:56:42', 3, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:34', '', '2021-02-08 00:39:34', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (24, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:42', '2021-02-17 20:56:42', 2, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:34', '', '2021-02-08 00:39:34', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (25, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:42', '2021-02-17 20:56:42', 4, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:34', '', '2021-02-08 00:39:34', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (26, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:56:42', '2021-02-17 20:56:42', 4, 2, 'IllegalArgumentException: JobHandler 不会为空', '', '2021-02-08 00:39:35', '', '2021-02-08 00:39:35', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (27, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 28, 2, '', '', '2021-02-08 00:40:04', '', '2021-02-08 00:40:04', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (28, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 6, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (29, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 4, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (30, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 5, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (31, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 3, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (32, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:12', '2021-02-17 20:57:12', 6, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (33, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:13', '2021-02-17 20:57:13', 4, 2, '', '', '2021-02-08 00:40:05', '', '2021-02-08 00:40:05', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (34, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:15', '2021-02-17 20:57:15', 4, 2, '', '', '2021-02-08 00:40:07', '', '2021-02-08 00:40:07', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (35, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:20', '2021-02-17 20:57:20', 4, 2, '', '', '2021-02-08 00:40:12', '', '2021-02-08 00:40:12', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (36, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:25', '2021-02-17 20:57:25', 4, 2, '', '', '2021-02-08 00:40:17', '', '2021-02-08 00:40:17', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (37, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:30', '2021-02-17 20:57:30', 5, 2, '', '', '2021-02-08 00:40:22', '', '2021-02-08 00:40:22', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (38, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:35', '2021-02-17 20:57:35', 4, 2, '', '', '2021-02-08 00:40:27', '', '2021-02-08 00:40:27', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (39, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:40', '2021-02-17 20:57:40', 4, 2, '', '', '2021-02-08 00:40:32', '', '2021-02-08 00:40:32', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (40, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:45', '2021-02-17 20:57:45', 3, 2, '', '', '2021-02-08 00:40:37', '', '2021-02-08 00:40:37', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (41, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:50', '2021-02-17 20:57:50', 3, 2, '', '', '2021-02-08 00:40:42', '', '2021-02-08 00:40:42', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (42, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:57:55', '2021-02-17 20:57:55', 4, 2, '', '', '2021-02-08 00:40:47', '', '2021-02-08 00:40:47', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (43, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:00', '2021-02-17 20:58:00', 4, 2, '', '', '2021-02-08 00:40:52', '', '2021-02-08 00:40:52', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (44, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:05', '2021-02-17 20:58:05', 3, 2, '', '', '2021-02-08 00:40:57', '', '2021-02-08 00:40:57', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (45, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:10', '2021-02-17 20:58:10', 4, 2, '', '', '2021-02-08 00:41:02', '', '2021-02-08 00:41:02', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (46, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:15', '2021-02-17 20:58:15', 6, 2, '', '', '2021-02-08 00:41:07', '', '2021-02-08 00:41:13', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (47, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:21', '2021-02-17 20:58:21', 3, 2, '', '', '2021-02-08 00:41:13', '', '2021-02-08 00:41:17', b'0');
|
||||||
|
INSERT INTO `inf_job_log` VALUES (48, 3, 'sysUserSessionTimeoutJob', NULL, '2021-02-17 20:58:25', '2021-02-17 20:58:25', 6, 2, '', '', '2021-02-08 00:41:17', '', '2021-02-08 00:41:17', b'0');
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_dept
|
-- Table structure for sys_dept
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -586,7 +659,7 @@ CREATE TABLE `sys_operate_log` (
|
||||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=261 DEFAULT CHARSET=utf8mb4 COMMENT='操作日志记录';
|
) ENGINE=InnoDB AUTO_INCREMENT=262 DEFAULT CHARSET=utf8mb4 COMMENT='操作日志记录';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_operate_log
|
-- Records of sys_operate_log
|
||||||
|
@ -687,6 +760,7 @@ INSERT INTO `sys_operate_log` VALUES (257, 'a3b43efc-c3a3-4228-8f48-f978c2c7ff6c
|
||||||
INSERT INTO `sys_operate_log` VALUES (258, '2be3590d-9ab4-4cc1-a8af-4b2a7c557958', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:46:07', 1008, 0, '', 'null', '', '2021-02-07 13:10:00', '', '2021-02-07 13:10:00', b'0');
|
INSERT INTO `sys_operate_log` VALUES (258, '2be3590d-9ab4-4cc1-a8af-4b2a7c557958', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:46:07', 1008, 0, '', 'null', '', '2021-02-07 13:10:00', '', '2021-02-07 13:10:00', b'0');
|
||||||
INSERT INTO `sys_operate_log` VALUES (259, '5dc1134b-41e0-4080-9e4e-9d955674d8d5', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:46:13', 37, 0, '', 'null', '', '2021-02-07 13:10:06', '', '2021-02-07 13:10:06', b'0');
|
INSERT INTO `sys_operate_log` VALUES (259, '5dc1134b-41e0-4080-9e4e-9d955674d8d5', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:46:13', 37, 0, '', 'null', '', '2021-02-07 13:10:06', '', '2021-02-07 13:10:06', b'0');
|
||||||
INSERT INTO `sys_operate_log` VALUES (260, '2df8e5e2-613e-4aab-b95f-ffd692c2e563', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:47:28', 27, 0, '', 'null', '', '2021-02-07 13:11:20', '', '2021-02-07 13:11:20', b'0');
|
INSERT INTO `sys_operate_log` VALUES (260, '2df8e5e2-613e-4aab-b95f-ffd692c2e563', 1, '定时任务', '导出定时任务 Excel', 5, '', '', 'GET', '/api/infra/job/export-excel', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'void cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.exportJobExcel(InfJobExportReqVO,HttpServletResponse)', '{\"exportReqVO\":{\"name\":null,\"status\":null,\"handlerName\":null},\"response\":\"[ignore]\"}', '2021-02-14 22:47:28', 27, 0, '', 'null', '', '2021-02-07 13:11:20', '', '2021-02-07 13:11:20', b'0');
|
||||||
|
INSERT INTO `sys_operate_log` VALUES (261, 'b8d90eff-b3ba-473f-ad88-d42c64a7a3d8', 1, '定时任务', '更新定时任务', 3, '', '', 'PUT', '/api/infra/job/update', '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', 'CommonResult cn.iocoder.dashboard.modules.infra.controller.job.InfJobController.updateJob(InfJobUpdateReqVO)', '{\"updateReqVO\":{\"name\":\"用户 Session 超时 Job\",\"handlerParam\":null,\"cronExpression\":\"0/5 * * * * ? * 11111\",\"monitorTimeout\":0,\"id\":3}}', '2021-02-14 22:57:48', 15, 500, 'ServiceException: CRON 表达式不正确', 'null', '', '2021-02-07 13:21:41', '', '2021-02-07 13:21:41', b'0');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -1016,7 +1090,7 @@ CREATE TABLE `sys_user_session` (
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO `sys_user_session` VALUES ('019f009268e24cc1957c46763eef1fd4', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-07 08:36:48', '', '2021-02-14 20:04:33', b'0');
|
INSERT INTO `sys_user_session` VALUES ('019f009268e24cc1957c46763eef1fd4', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-07 08:36:48', '', '2021-02-14 20:04:33', b'0');
|
||||||
INSERT INTO `sys_user_session` VALUES ('04d51ff81ad54d05ab2f29e66b2a02f2', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 17:46:10', '', '2021-02-11 00:58:19', b'0');
|
INSERT INTO `sys_user_session` VALUES ('04d51ff81ad54d05ab2f29e66b2a02f2', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 17:46:10', '', '2021-02-11 00:58:19', b'0');
|
||||||
INSERT INTO `sys_user_session` VALUES ('0df60899301d4080bd4164f24bccf18b', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-07 13:05:42', '', '2021-02-07 13:05:42', b'0');
|
INSERT INTO `sys_user_session` VALUES ('0df60899301d4080bd4164f24bccf18b', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-07 13:05:42', '', '2021-02-14 22:57:44', b'0');
|
||||||
INSERT INTO `sys_user_session` VALUES ('1127b5eb9b0c4f9fa382d4d98a8a4a38', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 06:49:00', '', '2021-02-10 11:10:31', b'0');
|
INSERT INTO `sys_user_session` VALUES ('1127b5eb9b0c4f9fa382d4d98a8a4a38', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 06:49:00', '', '2021-02-10 11:10:31', b'0');
|
||||||
INSERT INTO `sys_user_session` VALUES ('20109910c52e4b02bbc0531212bff8cb', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-06 02:39:48', '', '2021-02-06 02:39:48', b'0');
|
INSERT INTO `sys_user_session` VALUES ('20109910c52e4b02bbc0531212bff8cb', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-06 02:39:48', '', '2021-02-06 02:39:48', b'0');
|
||||||
INSERT INTO `sys_user_session` VALUES ('2024509755b3444690c2a1dddaebd812', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 06:22:30', '', '2021-02-05 06:22:30', b'0');
|
INSERT INTO `sys_user_session` VALUES ('2024509755b3444690c2a1dddaebd812', 1, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36', '', '2021-02-05 06:22:30', '', '2021-02-05 06:22:30', b'0');
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package cn.iocoder.dashboard.framework.quartz.core.handler;
|
package cn.iocoder.dashboard.framework.quartz.core.handler;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务处理器
|
* 任务处理器
|
||||||
*
|
*
|
||||||
|
@ -16,6 +14,6 @@ public interface JobHandler {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
CommonResult<String> execute(String param) throws Exception;
|
String execute(String param) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package cn.iocoder.dashboard.framework.quartz.core.handler;
|
package cn.iocoder.dashboard.framework.quartz.core.handler;
|
||||||
|
|
||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.dashboard.common.exception.ServiceException;
|
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.dashboard.framework.quartz.core.enums.JobDataKeyEnum;
|
import cn.iocoder.dashboard.framework.quartz.core.enums.JobDataKeyEnum;
|
||||||
import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService;
|
import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -19,8 +15,8 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
|
||||||
import static cn.iocoder.dashboard.util.date.DateUtils.diff;
|
import static cn.iocoder.dashboard.util.date.DateUtils.diff;
|
||||||
|
import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础 Job 调用者,负责调用 {@link JobHandler#execute(String)} 执行任务
|
* 基础 Job 调用者,负责调用 {@link JobHandler#execute(String)} 执行任务
|
||||||
|
@ -40,68 +36,68 @@ public class JobHandlerInvoker extends QuartzJobBean {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void executeInternal(JobExecutionContext executionContext) throws JobExecutionException {
|
protected void executeInternal(JobExecutionContext executionContext) throws JobExecutionException {
|
||||||
// 获得 Job 数据
|
// 第一步,获得 Job 数据
|
||||||
// 1. 获得 jobId 参数
|
Long jobId = executionContext.getMergedJobDataMap().getLong(JobDataKeyEnum.JOB_ID.name());
|
||||||
String jobIdStr = getJobData(executionContext, JobDataKeyEnum.JOB_ID);
|
String jobHandlerName = getJobHandlerName(executionContext);
|
||||||
if (NumberUtil.isNumber(jobIdStr)) {
|
String jobHandlerParam = executionContext.getMergedJobDataMap().getString(JobDataKeyEnum.JOB_HANDLER_PARAM.name());
|
||||||
log.error("[executeInternal][Job({}) 获取不到正确的 jobId({})]", executionContext.getJobDetail().getKey(), jobIdStr);
|
|
||||||
throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobId({})",
|
// 第二步,执行任务
|
||||||
executionContext.getJobDetail().getKey(), jobIdStr));
|
Long jobLogId = null;
|
||||||
|
Date startTime = new Date();
|
||||||
|
String data = null;
|
||||||
|
Throwable exception = null;
|
||||||
|
try {
|
||||||
|
// 记录 Job 日志(初始)
|
||||||
|
jobLogId = jobLogFrameworkService.createJobLog(jobId, startTime, jobHandlerName, jobHandlerParam);
|
||||||
|
// 执行任务
|
||||||
|
data = this.executeInternal(jobHandlerName, jobHandlerParam);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
exception = ex;
|
||||||
}
|
}
|
||||||
Long jobId = Long.valueOf(jobIdStr);
|
|
||||||
// 2. 获得 jobHandlerName 参数
|
// 第三步,记录执行日志
|
||||||
String jobHandlerName = getJobData(executionContext, JobDataKeyEnum.JOB_HANDLER_NAME);
|
this.updateJobLogResultAsync(jobLogId, startTime, data, exception, executionContext);
|
||||||
|
|
||||||
|
// 最终还是抛出异常,用于停止任务
|
||||||
|
if (exception != null) {
|
||||||
|
throw new JobExecutionException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getJobHandlerName(JobExecutionContext executionContext) {
|
||||||
|
String jobHandlerName = executionContext.getMergedJobDataMap().getString(JobDataKeyEnum.JOB_HANDLER_NAME.name());
|
||||||
if (StrUtil.isEmpty(jobHandlerName)) {
|
if (StrUtil.isEmpty(jobHandlerName)) {
|
||||||
log.error("[executeInternal][Job({}) 获取不到正确的 jobHandlerName({})]", executionContext.getJobDetail().getKey(), jobHandlerName);
|
log.error("[executeInternal][Job({}) 获取不到正确的 jobHandlerName({})]",
|
||||||
|
executionContext.getJobDetail().getKey(), jobHandlerName);
|
||||||
throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobHandlerName({})",
|
throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobHandlerName({})",
|
||||||
executionContext.getJobDetail().getKey(), jobHandlerName));
|
executionContext.getJobDetail().getKey(), jobHandlerName));
|
||||||
}
|
}
|
||||||
// 3. 获得 jobHandlerParam 参数
|
return jobHandlerName;
|
||||||
String jobHandlerParam = getJobData(executionContext, JobDataKeyEnum.JOB_HANDLER_PARAM);
|
|
||||||
|
|
||||||
Long jobLogId = null;
|
|
||||||
Date startTime = new Date();
|
|
||||||
try {
|
|
||||||
// 记录 Job 日志(初始)
|
|
||||||
jobLogId = jobLogFrameworkService.createJobLog(jobId, jobHandlerName, jobHandlerParam);
|
|
||||||
// 执行任务
|
|
||||||
String data = this.executeInternal(jobId, jobHandlerName, jobHandlerParam);
|
|
||||||
// 标记 Job 日志(成功)
|
|
||||||
Date endTime = new Date();
|
|
||||||
jobLogFrameworkService.updateJobLogSuccessAsync(jobLogId, endTime, diff(endTime, startTime), data);
|
|
||||||
} catch (ServiceException serviceException) {
|
|
||||||
// 标记 Job 日志(异常)
|
|
||||||
Date endTime = new Date();
|
|
||||||
jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, diff(endTime, startTime),
|
|
||||||
serviceException.getCode(), serviceException.getMessage());
|
|
||||||
// 最终还是抛出异常,用于停止任务
|
|
||||||
throw serviceException;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// 标记 Job 日志(异常)
|
|
||||||
Date endTime = new Date();
|
|
||||||
jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, diff(endTime, startTime),
|
|
||||||
INTERNAL_SERVER_ERROR.getCode(), ExceptionUtil.getRootCauseMessage(e));
|
|
||||||
// 最终还是抛出异常,用于停止任务
|
|
||||||
throw new JobExecutionException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String executeInternal(Long jobId, String jobHandlerName, String jobHandlerParam) throws Exception {
|
private String executeInternal(String jobHandlerName, String jobHandlerParam) throws Exception {
|
||||||
// 获得 JobHandler 对象
|
// 获得 JobHandler 对象
|
||||||
JobHandler jobHandler = applicationContext.getBean(jobHandlerName, JobHandler.class);
|
JobHandler jobHandler = applicationContext.getBean(jobHandlerName, JobHandler.class);
|
||||||
Assert.isNull(jobHandler, "JobHandler 不会为空");
|
Assert.notNull(jobHandler, "JobHandler 不会为空");
|
||||||
|
|
||||||
// 执行任务
|
// 执行任务
|
||||||
CommonResult<String> result = jobHandler.execute(jobHandlerParam);
|
return jobHandler.execute(jobHandlerParam);
|
||||||
// 如果执行失败,则抛出 ServiceException 异常,方便统一记录
|
|
||||||
if (result.isError()) {
|
|
||||||
throw new ServiceException(result.getCode(), result.getMsg());
|
|
||||||
}
|
|
||||||
return result.getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getJobData(JobExecutionContext executionContext, JobDataKeyEnum key) {
|
private void updateJobLogResultAsync(Long jobLogId, Date startTime, String data, Throwable exception,
|
||||||
return executionContext.getMergedJobDataMap().getString(key.name());
|
JobExecutionContext executionContext) {
|
||||||
|
Date endTime = new Date();
|
||||||
|
try {
|
||||||
|
if (data != null) { // 成功
|
||||||
|
jobLogFrameworkService.updateJobLogSuccessAsync(jobLogId, endTime, (int) diff(endTime, startTime), data);
|
||||||
|
} else { // 失败
|
||||||
|
jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, (int) diff(endTime, startTime),
|
||||||
|
getRootCauseMessage(exception));
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("[executeInternal][Job({}) logId({}) 记录执行日志失败({})]",
|
||||||
|
executionContext.getJobDetail().getKey(), jobLogId,
|
||||||
|
data != null ? data : getRootCauseMessage(exception));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package cn.iocoder.dashboard.framework.quartz.core.service;
|
package cn.iocoder.dashboard.framework.quartz.core.service;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,31 +15,40 @@ public interface JobLogFrameworkService {
|
||||||
* 创建 Job 日志
|
* 创建 Job 日志
|
||||||
*
|
*
|
||||||
* @param jobId 任务编号
|
* @param jobId 任务编号
|
||||||
|
* @param beginTime 开始时间
|
||||||
* @param jobHandlerName Job 处理器的名字
|
* @param jobHandlerName Job 处理器的名字
|
||||||
* @param jobHandlerParam Job 处理器的参数
|
* @param jobHandlerParam Job 处理器的参数
|
||||||
* @return Job 日志的编号
|
* @return Job 日志的编号
|
||||||
*/
|
*/
|
||||||
Long createJobLog(Long jobId, String jobHandlerName, String jobHandlerParam);
|
Long createJobLog(@NotNull(message = "任务编号不能为空") Long jobId,
|
||||||
|
@NotNull(message = "开始时间") Date beginTime,
|
||||||
|
@NotEmpty(message = "Job 处理器的名字不能为空") String jobHandlerName,
|
||||||
|
String jobHandlerParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新 Job 日志成功
|
* 更新 Job 日志成功
|
||||||
*
|
*
|
||||||
* @param id 日志编号
|
* @param logId 日志编号
|
||||||
* @param endTime 结束时间。因为是异步,避免记录时间不准去
|
* @param endTime 结束时间。因为是异步,避免记录时间不准去
|
||||||
* @param duration 运行时长,单位:毫秒
|
* @param duration 运行时长,单位:毫秒
|
||||||
* @param data 成功数据
|
* @param result 成功数据
|
||||||
*/
|
*/
|
||||||
void updateJobLogSuccessAsync(Long id, Date endTime, Long duration, String data);
|
void updateJobLogSuccessAsync(@NotNull(message = "日志编号不能为空") Long logId,
|
||||||
|
@NotNull(message = "结束时间不能为空") Date endTime,
|
||||||
|
@NotNull(message = "运行时长不能为空") Integer duration,
|
||||||
|
String result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新 Job 日志失败
|
* 更新 Job 日志失败
|
||||||
*
|
*
|
||||||
* @param id 日志编号
|
* @param logId 日志编号
|
||||||
* @param endTime 结束时间。因为是异步,避免记录时间不准去
|
* @param endTime 结束时间。因为是异步,避免记录时间不准去
|
||||||
* @param duration 运行时长,单位:毫秒
|
* @param duration 运行时长,单位:毫秒
|
||||||
* @param code 错误码
|
* @param result 异常提示
|
||||||
* @param msg 异常提示
|
|
||||||
*/
|
*/
|
||||||
void updateJobLogErrorAsync(Long id, Date endTime, Long duration, Integer code, String msg);
|
void updateJobLogErrorAsync(@NotNull(message = "日志编号不能为空") Long logId,
|
||||||
|
@NotNull(message = "结束时间不能为空") Date endTime,
|
||||||
|
@NotNull(message = "运行时长不能为空") Integer duration,
|
||||||
|
String result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package cn.iocoder.dashboard.modules.infra.dal.dataobject.job;
|
package cn.iocoder.dashboard.modules.infra.dal.dataobject.job;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.enums.job.InfJobLogStatusEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -18,6 +17,9 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class InfJobLogDO extends BaseDO {
|
public class InfJobLogDO extends BaseDO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +48,7 @@ public class InfJobLogDO extends BaseDO {
|
||||||
/**
|
/**
|
||||||
* 开始执行时间
|
* 开始执行时间
|
||||||
*/
|
*/
|
||||||
private Date startTime;
|
private Date beginTime;
|
||||||
/**
|
/**
|
||||||
* 结束执行时间
|
* 结束执行时间
|
||||||
*/
|
*/
|
||||||
|
@ -56,16 +58,16 @@ public class InfJobLogDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Integer duration;
|
private Integer duration;
|
||||||
/**
|
/**
|
||||||
* 结果码
|
* 状态
|
||||||
*
|
*
|
||||||
* 目前使用的 {@link CommonResult#getCode()} 属性
|
* 枚举 {@link InfJobLogStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer resultCode;
|
private Integer status;
|
||||||
/**
|
/**
|
||||||
* 结果
|
* 结果数据
|
||||||
*
|
*
|
||||||
* 成功时,使用 {@link CommonResult#getData()} 数据
|
* 成功时,使用 {@link JobHandler#execute(String)} 的结果
|
||||||
* 失败时,使用 {@link CommonResult#getMsg()} 属性
|
* 失败时,使用 {@link JobHandler#execute(String)} 的异常堆栈
|
||||||
*/
|
*/
|
||||||
private String result;
|
private String result;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package cn.iocoder.dashboard.modules.infra.dal.mysql.job;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.dal.dataobject.job.InfJobLogDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务日志 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface InfJobLogMapper extends BaseMapperX<InfJobLogDO> {
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package cn.iocoder.dashboard.modules.infra.enums.job;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务日志的状态枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum InfJobLogStatusEnum {
|
||||||
|
|
||||||
|
RUNNING(0), // 运行中
|
||||||
|
SUCCESS(1), // 成功
|
||||||
|
FAILURE(2); // 失败
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private final Integer status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package cn.iocoder.dashboard.modules.infra.service.job;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job 日志 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface InfJobLogService extends JobLogFrameworkService {
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package cn.iocoder.dashboard.modules.infra.service.job.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.infra.dal.dataobject.job.InfJobLogDO;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.job.InfJobLogMapper;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.enums.job.InfJobLogStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.service.job.InfJobLogService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job 日志 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class InfJobLogServiceImpl implements InfJobLogService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private InfJobLogMapper jobLogMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createJobLog(Long jobId, Date beginTime, String jobHandlerName, String jobHandlerParam) {
|
||||||
|
InfJobLogDO log = InfJobLogDO.builder().jobId(jobId).handlerName(jobHandlerName).handlerParam(jobHandlerParam)
|
||||||
|
.beginTime(beginTime).status(InfJobLogStatusEnum.RUNNING.getStatus()).build();
|
||||||
|
jobLogMapper.insert(log);
|
||||||
|
return log.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Async
|
||||||
|
public void updateJobLogSuccessAsync(Long logId, Date endTime, Integer duration, String result) {
|
||||||
|
updateJobLogResult(logId, endTime, duration, result, InfJobLogStatusEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Async
|
||||||
|
public void updateJobLogErrorAsync(Long logId, Date endTime, Integer duration, String result) {
|
||||||
|
updateJobLogResult(logId, endTime, duration, result, InfJobLogStatusEnum.FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateJobLogResult(Long logId, Date endTime, Integer duration, String result, InfJobLogStatusEnum status) {
|
||||||
|
try {
|
||||||
|
InfJobLogDO updateObj = InfJobLogDO.builder().id(logId).endTime(endTime).duration(duration)
|
||||||
|
.status(status.getStatus()).result(result).build();
|
||||||
|
jobLogMapper.updateById(updateObj);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("[updateJobLogResult][logId({}) endTime({}) duration({}) result({}) status({})]",
|
||||||
|
logId, endTime, duration, result, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package cn.iocoder.dashboard.modules.system.job.auth;
|
package cn.iocoder.dashboard.modules.system.job.auth;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -15,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||||
public class SysUserSessionTimeoutJob implements JobHandler {
|
public class SysUserSessionTimeoutJob implements JobHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<String> execute(String param) throws Exception {
|
public String execute(String param) throws Exception {
|
||||||
// System.out.println("执行了一次任务");
|
// System.out.println("执行了一次任务");
|
||||||
log.info("[execute][执行任务:{}]", param);
|
log.info("[execute][执行任务:{}]", param);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class DateUtils {
|
||||||
return System.currentTimeMillis() > time.getTime();
|
return System.currentTimeMillis() > time.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Long diff(Date endTime, Date startTime) {
|
public static long diff(Date endTime, Date startTime) {
|
||||||
return endTime.getTime() - startTime.getTime();
|
return endTime.getTime() - startTime.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue