Commit 74f2c8a879f67785d649b5204b0ac4f2fc618709

Authored by YunaiV
1 parent 5fc03bd8

1. 同步最新的表结构

2. 记录执行日志
sql/ruoyi-vue-pro.sql
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 Target Server Version : 50718 11 Target Server Version : 50718
12 File Encoding : 65001 12 File Encoding : 65001
13 13
14 - Date: 14/02/2021 22:48:01 14 + Date: 17/02/2021 20:59:32
15 */ 15 */
16 16
17 SET NAMES utf8mb4; 17 SET NAMES utf8mb4;
@@ -81,6 +81,79 @@ INSERT INTO `inf_job` VALUES (3, '用户 Session 超时 Job', 1, 'sysUserSession @@ -81,6 +81,79 @@ INSERT INTO `inf_job` VALUES (3, '用户 Session 超时 Job', 1, 'sysUserSession
81 COMMIT; 81 COMMIT;
82 82
83 -- ---------------------------- 83 -- ----------------------------
  84 +-- Table structure for inf_job_log
  85 +-- ----------------------------
  86 +DROP TABLE IF EXISTS `inf_job_log`;
  87 +CREATE TABLE `inf_job_log` (
  88 + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '日志编号',
  89 + `job_id` bigint(20) NOT NULL COMMENT '任务编号',
  90 + `handler_name` varchar(64) NOT NULL COMMENT '处理器的名字',
  91 + `handler_param` varchar(255) DEFAULT NULL COMMENT '处理器的参数',
  92 + `begin_time` datetime NOT NULL COMMENT '开始执行时间',
  93 + `end_time` datetime DEFAULT NULL COMMENT '结束执行时间',
  94 + `duration` int(11) DEFAULT NULL COMMENT '执行时长',
  95 + `status` tinyint(4) NOT NULL COMMENT '任务状态',
  96 + `result` varchar(4000) DEFAULT '' COMMENT '结果数据',
  97 + `create_by` varchar(64) DEFAULT '' COMMENT '创建者',
  98 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  99 + `update_by` varchar(64) DEFAULT '' COMMENT '更新者',
  100 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  101 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  102 + PRIMARY KEY (`id`) USING BTREE
  103 +) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COMMENT='定时任务表';
  104 +
  105 +-- ----------------------------
  106 +-- Records of inf_job_log
  107 +-- ----------------------------
  108 +BEGIN;
  109 +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');
  110 +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');
  111 +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');
  112 +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');
  113 +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');
  114 +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');
  115 +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');
  116 +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');
  117 +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');
  118 +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');
  119 +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');
  120 +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');
  121 +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');
  122 +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');
  123 +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');
  124 +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');
  125 +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');
  126 +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');
  127 +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');
  128 +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');
  129 +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');
  130 +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');
  131 +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');
  132 +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');
  133 +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');
  134 +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');
  135 +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');
  136 +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');
  137 +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');
  138 +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');
  139 +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');
  140 +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');
  141 +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');
  142 +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');
  143 +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');
  144 +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');
  145 +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');
  146 +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');
  147 +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');
  148 +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');
  149 +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');
  150 +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');
  151 +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');
  152 +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');
  153 +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');
  154 +COMMIT;
  155 +
  156 +-- ----------------------------
84 -- Table structure for sys_dept 157 -- Table structure for sys_dept
85 -- ---------------------------- 158 -- ----------------------------
86 DROP TABLE IF EXISTS `sys_dept`; 159 DROP TABLE IF EXISTS `sys_dept`;
@@ -586,7 +659,7 @@ CREATE TABLE `sys_operate_log` ( @@ -586,7 +659,7 @@ CREATE TABLE `sys_operate_log` (
586 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 659 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
587 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 660 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
588 PRIMARY KEY (`id`) USING BTREE 661 PRIMARY KEY (`id`) USING BTREE
589 -) ENGINE=InnoDB AUTO_INCREMENT=261 DEFAULT CHARSET=utf8mb4 COMMENT='操作日志记录'; 662 +) ENGINE=InnoDB AUTO_INCREMENT=262 DEFAULT CHARSET=utf8mb4 COMMENT='操作日志记录';
590 663
591 -- ---------------------------- 664 -- ----------------------------
592 -- Records of sys_operate_log 665 -- Records of sys_operate_log
@@ -687,6 +760,7 @@ INSERT INTO `sys_operate_log` VALUES (257, 'a3b43efc-c3a3-4228-8f48-f978c2c7ff6c @@ -687,6 +760,7 @@ INSERT INTO `sys_operate_log` VALUES (257, 'a3b43efc-c3a3-4228-8f48-f978c2c7ff6c
687 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'); 760 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');
688 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'); 761 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');
689 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'); 762 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');
  763 +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');
690 COMMIT; 764 COMMIT;
691 765
692 -- ---------------------------- 766 -- ----------------------------
@@ -1016,7 +1090,7 @@ CREATE TABLE `sys_user_session` ( @@ -1016,7 +1090,7 @@ CREATE TABLE `sys_user_session` (
1016 BEGIN; 1090 BEGIN;
1017 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'); 1091 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');
1018 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'); 1092 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');
1019 -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'); 1093 +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');
1020 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'); 1094 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');
1021 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'); 1095 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');
1022 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'); 1096 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');
src/main/java/cn/iocoder/dashboard/framework/quartz/core/handler/JobHandler.java
1 package cn.iocoder.dashboard.framework.quartz.core.handler; 1 package cn.iocoder.dashboard.framework.quartz.core.handler;
2 2
3 -import cn.iocoder.dashboard.common.pojo.CommonResult;  
4 -  
5 /** 3 /**
6 * 任务处理器 4 * 任务处理器
7 * 5 *
@@ -16,6 +14,6 @@ public interface JobHandler { @@ -16,6 +14,6 @@ public interface JobHandler {
16 * @return 结果 14 * @return 结果
17 * @throws Exception 异常 15 * @throws Exception 异常
18 */ 16 */
19 - CommonResult<String> execute(String param) throws Exception; 17 + String execute(String param) throws Exception;
20 18
21 } 19 }
src/main/java/cn/iocoder/dashboard/framework/quartz/core/handler/JobHandlerInvoker.java
1 package cn.iocoder.dashboard.framework.quartz.core.handler; 1 package cn.iocoder.dashboard.framework.quartz.core.handler;
2 2
3 -import cn.hutool.core.exceptions.ExceptionUtil;  
4 import cn.hutool.core.lang.Assert; 3 import cn.hutool.core.lang.Assert;
5 -import cn.hutool.core.util.NumberUtil;  
6 import cn.hutool.core.util.StrUtil; 4 import cn.hutool.core.util.StrUtil;
7 -import cn.iocoder.dashboard.common.exception.ServiceException;  
8 -import cn.iocoder.dashboard.common.pojo.CommonResult;  
9 import cn.iocoder.dashboard.framework.quartz.core.enums.JobDataKeyEnum; 5 import cn.iocoder.dashboard.framework.quartz.core.enums.JobDataKeyEnum;
10 import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService; 6 import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService;
11 import lombok.extern.slf4j.Slf4j; 7 import lombok.extern.slf4j.Slf4j;
@@ -19,8 +15,8 @@ import org.springframework.scheduling.quartz.QuartzJobBean; @@ -19,8 +15,8 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
19 import javax.annotation.Resource; 15 import javax.annotation.Resource;
20 import java.util.Date; 16 import java.util.Date;
21 17
22 -import static cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;  
23 import static cn.iocoder.dashboard.util.date.DateUtils.diff; 18 import static cn.iocoder.dashboard.util.date.DateUtils.diff;
  19 +import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage;
24 20
25 /** 21 /**
26 * 基础 Job 调用者,负责调用 {@link JobHandler#execute(String)} 执行任务 22 * 基础 Job 调用者,负责调用 {@link JobHandler#execute(String)} 执行任务
@@ -40,68 +36,68 @@ public class JobHandlerInvoker extends QuartzJobBean { @@ -40,68 +36,68 @@ public class JobHandlerInvoker extends QuartzJobBean {
40 36
41 @Override 37 @Override
42 protected void executeInternal(JobExecutionContext executionContext) throws JobExecutionException { 38 protected void executeInternal(JobExecutionContext executionContext) throws JobExecutionException {
43 - // 获得 Job 数据  
44 - // 1. 获得 jobId 参数  
45 - String jobIdStr = getJobData(executionContext, JobDataKeyEnum.JOB_ID);  
46 - if (NumberUtil.isNumber(jobIdStr)) {  
47 - log.error("[executeInternal][Job({}) 获取不到正确的 jobId({})]", executionContext.getJobDetail().getKey(), jobIdStr);  
48 - throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobId({})",  
49 - executionContext.getJobDetail().getKey(), jobIdStr));  
50 - }  
51 - Long jobId = Long.valueOf(jobIdStr);  
52 - // 2. 获得 jobHandlerName 参数  
53 - String jobHandlerName = getJobData(executionContext, JobDataKeyEnum.JOB_HANDLER_NAME);  
54 - if (StrUtil.isEmpty(jobHandlerName)) {  
55 - log.error("[executeInternal][Job({}) 获取不到正确的 jobHandlerName({})]", executionContext.getJobDetail().getKey(), jobHandlerName);  
56 - throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobHandlerName({})",  
57 - executionContext.getJobDetail().getKey(), jobHandlerName));  
58 - }  
59 - // 3. 获得 jobHandlerParam 参数  
60 - String jobHandlerParam = getJobData(executionContext, JobDataKeyEnum.JOB_HANDLER_PARAM); 39 + // 第一步,获得 Job 数据
  40 + Long jobId = executionContext.getMergedJobDataMap().getLong(JobDataKeyEnum.JOB_ID.name());
  41 + String jobHandlerName = getJobHandlerName(executionContext);
  42 + String jobHandlerParam = executionContext.getMergedJobDataMap().getString(JobDataKeyEnum.JOB_HANDLER_PARAM.name());
61 43
  44 + // 第二步,执行任务
62 Long jobLogId = null; 45 Long jobLogId = null;
63 Date startTime = new Date(); 46 Date startTime = new Date();
  47 + String data = null;
  48 + Throwable exception = null;
64 try { 49 try {
65 // 记录 Job 日志(初始) 50 // 记录 Job 日志(初始)
66 - jobLogId = jobLogFrameworkService.createJobLog(jobId, jobHandlerName, jobHandlerParam); 51 + jobLogId = jobLogFrameworkService.createJobLog(jobId, startTime, jobHandlerName, jobHandlerParam);
67 // 执行任务 52 // 执行任务
68 - String data = this.executeInternal(jobId, jobHandlerName, jobHandlerParam);  
69 - // 标记 Job 日志(成功)  
70 - Date endTime = new Date();  
71 - jobLogFrameworkService.updateJobLogSuccessAsync(jobLogId, endTime, diff(endTime, startTime), data);  
72 - } catch (ServiceException serviceException) {  
73 - // 标记 Job 日志(异常)  
74 - Date endTime = new Date();  
75 - jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, diff(endTime, startTime),  
76 - serviceException.getCode(), serviceException.getMessage());  
77 - // 最终还是抛出异常,用于停止任务  
78 - throw serviceException;  
79 - } catch (Throwable e) {  
80 - // 标记 Job 日志(异常)  
81 - Date endTime = new Date();  
82 - jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, diff(endTime, startTime),  
83 - INTERNAL_SERVER_ERROR.getCode(), ExceptionUtil.getRootCauseMessage(e));  
84 - // 最终还是抛出异常,用于停止任务  
85 - throw new JobExecutionException(e); 53 + data = this.executeInternal(jobHandlerName, jobHandlerParam);
  54 + } catch (Throwable ex) {
  55 + exception = ex;
  56 + }
  57 +
  58 + // 第三步,记录执行日志
  59 + this.updateJobLogResultAsync(jobLogId, startTime, data, exception, executionContext);
  60 +
  61 + // 最终还是抛出异常,用于停止任务
  62 + if (exception != null) {
  63 + throw new JobExecutionException(exception);
  64 + }
  65 + }
  66 +
  67 + private static String getJobHandlerName(JobExecutionContext executionContext) {
  68 + String jobHandlerName = executionContext.getMergedJobDataMap().getString(JobDataKeyEnum.JOB_HANDLER_NAME.name());
  69 + if (StrUtil.isEmpty(jobHandlerName)) {
  70 + log.error("[executeInternal][Job({}) 获取不到正确的 jobHandlerName({})]",
  71 + executionContext.getJobDetail().getKey(), jobHandlerName);
  72 + throw new IllegalStateException(StrUtil.format("Job({}) 获取不到正确的 jobHandlerName({})",
  73 + executionContext.getJobDetail().getKey(), jobHandlerName));
86 } 74 }
  75 + return jobHandlerName;
87 } 76 }
88 77
89 - private String executeInternal(Long jobId, String jobHandlerName, String jobHandlerParam) throws Exception { 78 + private String executeInternal(String jobHandlerName, String jobHandlerParam) throws Exception {
90 // 获得 JobHandler 对象 79 // 获得 JobHandler 对象
91 JobHandler jobHandler = applicationContext.getBean(jobHandlerName, JobHandler.class); 80 JobHandler jobHandler = applicationContext.getBean(jobHandlerName, JobHandler.class);
92 - Assert.isNull(jobHandler, "JobHandler 不会为空");  
93 - 81 + Assert.notNull(jobHandler, "JobHandler 不会为空");
94 // 执行任务 82 // 执行任务
95 - CommonResult<String> result = jobHandler.execute(jobHandlerParam);  
96 - // 如果执行失败,则抛出 ServiceException 异常,方便统一记录  
97 - if (result.isError()) {  
98 - throw new ServiceException(result.getCode(), result.getMsg());  
99 - }  
100 - return result.getData(); 83 + return jobHandler.execute(jobHandlerParam);
101 } 84 }
102 85
103 - private static String getJobData(JobExecutionContext executionContext, JobDataKeyEnum key) {  
104 - return executionContext.getMergedJobDataMap().getString(key.name()); 86 + private void updateJobLogResultAsync(Long jobLogId, Date startTime, String data, Throwable exception,
  87 + JobExecutionContext executionContext) {
  88 + Date endTime = new Date();
  89 + try {
  90 + if (data != null) { // 成功
  91 + jobLogFrameworkService.updateJobLogSuccessAsync(jobLogId, endTime, (int) diff(endTime, startTime), data);
  92 + } else { // 失败
  93 + jobLogFrameworkService.updateJobLogErrorAsync(jobLogId, endTime, (int) diff(endTime, startTime),
  94 + getRootCauseMessage(exception));
  95 + }
  96 + } catch (Exception ex) {
  97 + log.error("[executeInternal][Job({}) logId({}) 记录执行日志失败({})]",
  98 + executionContext.getJobDetail().getKey(), jobLogId,
  99 + data != null ? data : getRootCauseMessage(exception));
  100 + }
105 } 101 }
106 102
107 } 103 }
src/main/java/cn/iocoder/dashboard/framework/quartz/core/service/JobLogFrameworkService.java
1 package cn.iocoder.dashboard.framework.quartz.core.service; 1 package cn.iocoder.dashboard.framework.quartz.core.service;
2 2
  3 +import javax.validation.constraints.NotEmpty;
  4 +import javax.validation.constraints.NotNull;
3 import java.util.Date; 5 import java.util.Date;
4 6
5 /** 7 /**
@@ -13,31 +15,40 @@ public interface JobLogFrameworkService { @@ -13,31 +15,40 @@ public interface JobLogFrameworkService {
13 * 创建 Job 日志 15 * 创建 Job 日志
14 * 16 *
15 * @param jobId 任务编号 17 * @param jobId 任务编号
  18 + * @param beginTime 开始时间
16 * @param jobHandlerName Job 处理器的名字 19 * @param jobHandlerName Job 处理器的名字
17 * @param jobHandlerParam Job 处理器的参数 20 * @param jobHandlerParam Job 处理器的参数
18 * @return Job 日志的编号 21 * @return Job 日志的编号
19 */ 22 */
20 - Long createJobLog(Long jobId, String jobHandlerName, String jobHandlerParam); 23 + Long createJobLog(@NotNull(message = "任务编号不能为空") Long jobId,
  24 + @NotNull(message = "开始时间") Date beginTime,
  25 + @NotEmpty(message = "Job 处理器的名字不能为空") String jobHandlerName,
  26 + String jobHandlerParam);
21 27
22 /** 28 /**
23 * 更新 Job 日志成功 29 * 更新 Job 日志成功
24 * 30 *
25 - * @param id 日志编号 31 + * @param logId 日志编号
26 * @param endTime 结束时间。因为是异步,避免记录时间不准去 32 * @param endTime 结束时间。因为是异步,避免记录时间不准去
27 * @param duration 运行时长,单位:毫秒 33 * @param duration 运行时长,单位:毫秒
28 - * @param data 成功数据 34 + * @param result 成功数据
29 */ 35 */
30 - void updateJobLogSuccessAsync(Long id, Date endTime, Long duration, String data); 36 + void updateJobLogSuccessAsync(@NotNull(message = "日志编号不能为空") Long logId,
  37 + @NotNull(message = "结束时间不能为空") Date endTime,
  38 + @NotNull(message = "运行时长不能为空") Integer duration,
  39 + String result);
31 40
32 /** 41 /**
33 * 更新 Job 日志失败 42 * 更新 Job 日志失败
34 * 43 *
35 - * @param id 日志编号 44 + * @param logId 日志编号
36 * @param endTime 结束时间。因为是异步,避免记录时间不准去 45 * @param endTime 结束时间。因为是异步,避免记录时间不准去
37 * @param duration 运行时长,单位:毫秒 46 * @param duration 运行时长,单位:毫秒
38 - * @param code 错误码  
39 - * @param msg 异常提示 47 + * @param result 异常提示
40 */ 48 */
41 - void updateJobLogErrorAsync(Long id, Date endTime, Long duration, Integer code, String msg); 49 + void updateJobLogErrorAsync(@NotNull(message = "日志编号不能为空") Long logId,
  50 + @NotNull(message = "结束时间不能为空") Date endTime,
  51 + @NotNull(message = "运行时长不能为空") Integer duration,
  52 + String result);
42 53
43 } 54 }
src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/job/InfJobLogDO.java
1 package cn.iocoder.dashboard.modules.infra.dal.dataobject.job; 1 package cn.iocoder.dashboard.modules.infra.dal.dataobject.job;
2 2
3 -import cn.iocoder.dashboard.common.pojo.CommonResult;  
4 import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
  5 +import cn.iocoder.dashboard.modules.infra.enums.job.InfJobLogStatusEnum;
5 import com.baomidou.mybatisplus.annotation.TableName; 6 import com.baomidou.mybatisplus.annotation.TableName;
6 -import lombok.Data;  
7 -import lombok.EqualsAndHashCode;  
8 -import lombok.ToString; 7 +import lombok.*;
9 8
10 import java.util.Date; 9 import java.util.Date;
11 10
@@ -18,6 +17,9 @@ import java.util.Date; @@ -18,6 +17,9 @@ import java.util.Date;
18 @Data 17 @Data
19 @EqualsAndHashCode(callSuper = true) 18 @EqualsAndHashCode(callSuper = true)
20 @ToString(callSuper = true) 19 @ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
21 public class InfJobLogDO extends BaseDO { 23 public class InfJobLogDO extends BaseDO {
22 24
23 /** 25 /**
@@ -46,7 +48,7 @@ public class InfJobLogDO extends BaseDO { @@ -46,7 +48,7 @@ public class InfJobLogDO extends BaseDO {
46 /** 48 /**
47 * 开始执行时间 49 * 开始执行时间
48 */ 50 */
49 - private Date startTime; 51 + private Date beginTime;
50 /** 52 /**
51 * 结束执行时间 53 * 结束执行时间
52 */ 54 */
@@ -56,16 +58,16 @@ public class InfJobLogDO extends BaseDO { @@ -56,16 +58,16 @@ public class InfJobLogDO extends BaseDO {
56 */ 58 */
57 private Integer duration; 59 private Integer duration;
58 /** 60 /**
59 - * 结果码 61 + * 状态
60 * 62 *
61 - * 目前使用的 {@link CommonResult#getCode()} 属性 63 + * 枚举 {@link InfJobLogStatusEnum}
62 */ 64 */
63 - private Integer resultCode; 65 + private Integer status;
64 /** 66 /**
65 - * 结果 67 + * 结果数据
66 * 68 *
67 - * 成功时,使用 {@link CommonResult#getData()} 数据  
68 - * 失败时,使用 {@link CommonResult#getMsg()} 属性 69 + * 成功时,使用 {@link JobHandler#execute(String)} 的结果
  70 + * 失败时,使用 {@link JobHandler#execute(String)} 的异常堆栈
69 */ 71 */
70 private String result; 72 private String result;
71 73
src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/job/InfJobLogMapper.java 0 → 100644
  1 +package cn.iocoder.dashboard.modules.infra.dal.mysql.job;
  2 +
  3 +import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
  4 +import cn.iocoder.dashboard.modules.infra.dal.dataobject.job.InfJobLogDO;
  5 +import org.apache.ibatis.annotations.Mapper;
  6 +
  7 +/**
  8 + * 任务日志 Mapper
  9 + *
  10 + * @author 芋道源码
  11 + */
  12 +@Mapper
  13 +public interface InfJobLogMapper extends BaseMapperX<InfJobLogDO> {
  14 +}
src/main/java/cn/iocoder/dashboard/modules/infra/enums/job/InfJobLogStatusEnum.java 0 → 100644
  1 +package cn.iocoder.dashboard.modules.infra.enums.job;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Getter;
  5 +
  6 +/**
  7 + * 任务日志的状态枚举
  8 + *
  9 + * @author 芋道源码
  10 + */
  11 +@Getter
  12 +@AllArgsConstructor
  13 +public enum InfJobLogStatusEnum {
  14 +
  15 + RUNNING(0), // 运行中
  16 + SUCCESS(1), // 成功
  17 + FAILURE(2); // 失败
  18 +
  19 + /**
  20 + * 状态
  21 + */
  22 + private final Integer status;
  23 +
  24 +}
src/main/java/cn/iocoder/dashboard/modules/infra/service/job/InfJobLogService.java 0 → 100644
  1 +package cn.iocoder.dashboard.modules.infra.service.job;
  2 +
  3 +import cn.iocoder.dashboard.framework.quartz.core.service.JobLogFrameworkService;
  4 +
  5 +/**
  6 + * Job 日志 Service 接口
  7 + *
  8 + * @author 芋道源码
  9 + */
  10 +public interface InfJobLogService extends JobLogFrameworkService {
  11 +}
src/main/java/cn/iocoder/dashboard/modules/infra/service/job/impl/InfJobLogServiceImpl.java 0 → 100644
  1 +package cn.iocoder.dashboard.modules.infra.service.job.impl;
  2 +
  3 +import cn.iocoder.dashboard.modules.infra.dal.dataobject.job.InfJobLogDO;
  4 +import cn.iocoder.dashboard.modules.infra.dal.mysql.job.InfJobLogMapper;
  5 +import cn.iocoder.dashboard.modules.infra.enums.job.InfJobLogStatusEnum;
  6 +import cn.iocoder.dashboard.modules.infra.service.job.InfJobLogService;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.springframework.scheduling.annotation.Async;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.validation.annotation.Validated;
  11 +
  12 +import javax.annotation.Resource;
  13 +import java.util.Date;
  14 +
  15 +/**
  16 + * Job 日志 Service 实现类
  17 + *
  18 + * @author 芋道源码
  19 + */
  20 +@Service
  21 +@Validated
  22 +@Slf4j
  23 +public class InfJobLogServiceImpl implements InfJobLogService {
  24 +
  25 + @Resource
  26 + private InfJobLogMapper jobLogMapper;
  27 +
  28 + @Override
  29 + public Long createJobLog(Long jobId, Date beginTime, String jobHandlerName, String jobHandlerParam) {
  30 + InfJobLogDO log = InfJobLogDO.builder().jobId(jobId).handlerName(jobHandlerName).handlerParam(jobHandlerParam)
  31 + .beginTime(beginTime).status(InfJobLogStatusEnum.RUNNING.getStatus()).build();
  32 + jobLogMapper.insert(log);
  33 + return log.getId();
  34 + }
  35 +
  36 + @Override
  37 + @Async
  38 + public void updateJobLogSuccessAsync(Long logId, Date endTime, Integer duration, String result) {
  39 + updateJobLogResult(logId, endTime, duration, result, InfJobLogStatusEnum.SUCCESS);
  40 + }
  41 +
  42 + @Override
  43 + @Async
  44 + public void updateJobLogErrorAsync(Long logId, Date endTime, Integer duration, String result) {
  45 + updateJobLogResult(logId, endTime, duration, result, InfJobLogStatusEnum.FAILURE);
  46 + }
  47 +
  48 + private void updateJobLogResult(Long logId, Date endTime, Integer duration, String result, InfJobLogStatusEnum status) {
  49 + try {
  50 + InfJobLogDO updateObj = InfJobLogDO.builder().id(logId).endTime(endTime).duration(duration)
  51 + .status(status.getStatus()).result(result).build();
  52 + jobLogMapper.updateById(updateObj);
  53 + } catch (Exception ex) {
  54 + log.error("[updateJobLogResult][logId({}) endTime({}) duration({}) result({}) status({})]",
  55 + logId, endTime, duration, result, status);
  56 + }
  57 + }
  58 +
  59 +}
src/main/java/cn/iocoder/dashboard/modules/system/job/auth/SysUserSessionTimeoutJob.java
1 package cn.iocoder.dashboard.modules.system.job.auth; 1 package cn.iocoder.dashboard.modules.system.job.auth;
2 2
3 -import cn.iocoder.dashboard.common.pojo.CommonResult;  
4 import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler; 3 import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
5 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
6 import org.springframework.stereotype.Component; 5 import org.springframework.stereotype.Component;
@@ -15,7 +14,7 @@ import org.springframework.stereotype.Component; @@ -15,7 +14,7 @@ import org.springframework.stereotype.Component;
15 public class SysUserSessionTimeoutJob implements JobHandler { 14 public class SysUserSessionTimeoutJob implements JobHandler {
16 15
17 @Override 16 @Override
18 - public CommonResult<String> execute(String param) throws Exception { 17 + public String execute(String param) throws Exception {
19 // System.out.println("执行了一次任务"); 18 // System.out.println("执行了一次任务");
20 log.info("[execute][执行任务:{}]", param); 19 log.info("[execute][执行任务:{}]", param);
21 return null; 20 return null;
src/main/java/cn/iocoder/dashboard/util/date/DateUtils.java
@@ -18,7 +18,7 @@ public class DateUtils { @@ -18,7 +18,7 @@ public class DateUtils {
18 return System.currentTimeMillis() > time.getTime(); 18 return System.currentTimeMillis() > time.getTime();
19 } 19 }
20 20
21 - public static Long diff(Date endTime, Date startTime) { 21 + public static long diff(Date endTime, Date startTime) {
22 return endTime.getTime() - startTime.getTime(); 22 return endTime.getTime() - startTime.getTime();
23 } 23 }
24 24