From cd5f8564e84694d098a4eeddecc36aa8ce7cfdf3 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 26 八月 2024 09:57:44 +0800 Subject: [PATCH] job --- /dev/null | 532 -------------------------------------------- iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java | 8 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/vo/ScheduleJobReqVO.java | 23 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java | 17 - iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java | 15 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java | 41 +- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java | 59 ++-- 10 files changed, 104 insertions(+), 599 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/db/mysql/mysql.sql b/iailab-module-data/iailab-module-data-biz/db/mysql/mysql.sql deleted file mode 100644 index 35a252c..0000000 --- a/iailab-module-data/iailab-module-data-biz/db/mysql/mysql.sql +++ /dev/null @@ -1,532 +0,0 @@ -CREATE database if NOT EXISTS `iailab_test_data` default character set utf8mb4 collate utf8mb4_general_ci; -USE `iailab_test_data`; - - --- 定时任务 -CREATE TABLE schedule_job -( - id bigint NOT NULL COMMENT 'id', - bean_name varchar(200) DEFAULT NULL COMMENT 'spring bean名称', - params varchar(2000) DEFAULT NULL COMMENT '参数', - cron_expression varchar(100) DEFAULT NULL COMMENT 'cron表达式', - status tinyint unsigned COMMENT '任务状态 0:暂停 1:正常', - remark varchar(255) DEFAULT NULL COMMENT '备注', - creator bigint COMMENT '创建者', - create_date datetime COMMENT '创建时间', - updater bigint COMMENT '更新者', - update_date datetime COMMENT '更新时间', - PRIMARY KEY (id), - key idx_create_date (create_date) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='定时任务'; - --- 定时任务日志 -CREATE TABLE schedule_job_log -( - id bigint NOT NULL COMMENT 'id', - job_id bigint NOT NULL COMMENT '任务id', - bean_name varchar(200) DEFAULT NULL COMMENT 'spring bean名称', - params varchar(2000) DEFAULT NULL COMMENT '参数', - status tinyint unsigned NOT NULL COMMENT '任务状态 0:失败 1:成功', - error varchar(2000) DEFAULT NULL COMMENT '失败信息', - times int NOT NULL COMMENT '耗时(单位:毫秒)', - create_date datetime COMMENT '创建时间', - PRIMARY KEY (id), - key idx_job_id (job_id), - key idx_create_date (create_date) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='定时任务日志'; - --- quartz自带表结构 -CREATE TABLE QRTZ_JOB_DETAILS -( - SCHED_NAME VARCHAR(120) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - JOB_CLASS_NAME VARCHAR(250) NOT NULL, - IS_DURABLE VARCHAR(1) NOT NULL, - IS_NONCONCURRENT VARCHAR(1) NOT NULL, - IS_UPDATE_DATA VARCHAR(1) NOT NULL, - REQUESTS_RECOVERY VARCHAR(1) NOT NULL, - JOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - NEXT_FIRE_TIME BIGINT(13) NULL, - PREV_FIRE_TIME BIGINT(13) NULL, - PRIORITY INTEGER NULL, - TRIGGER_STATE VARCHAR(16) NOT NULL, - TRIGGER_TYPE VARCHAR(8) NOT NULL, - START_TIME BIGINT(13) NOT NULL, - END_TIME BIGINT(13) NULL, - CALENDAR_NAME VARCHAR(200) NULL, - MISFIRE_INSTR SMALLINT(2) NULL, - JOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) - REFERENCES QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_SIMPLE_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - REPEAT_COUNT BIGINT(7) NOT NULL, - REPEAT_INTERVAL BIGINT(12) NOT NULL, - TIMES_TRIGGERED BIGINT(10) NOT NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_CRON_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - CRON_EXPRESSION VARCHAR(120) NOT NULL, - TIME_ZONE_ID VARCHAR(80), - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_SIMPROP_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - STR_PROP_1 VARCHAR(512) NULL, - STR_PROP_2 VARCHAR(512) NULL, - STR_PROP_3 VARCHAR(512) NULL, - INT_PROP_1 INT NULL, - INT_PROP_2 INT NULL, - LONG_PROP_1 BIGINT NULL, - LONG_PROP_2 BIGINT NULL, - DEC_PROP_1 NUMERIC(13, 4) NULL, - DEC_PROP_2 NUMERIC(13, 4) NULL, - BOOL_PROP_1 VARCHAR(1) NULL, - BOOL_PROP_2 VARCHAR(1) NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_BLOB_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - BLOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - INDEX (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_CALENDARS -( - SCHED_NAME VARCHAR(120) NOT NULL, - CALENDAR_NAME VARCHAR(200) NOT NULL, - CALENDAR BLOB NOT NULL, - PRIMARY KEY (SCHED_NAME, CALENDAR_NAME) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_GROUP) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_FIRED_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - ENTRY_ID VARCHAR(95) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - FIRED_TIME BIGINT(13) NOT NULL, - SCHED_TIME BIGINT(13) NOT NULL, - PRIORITY INTEGER NOT NULL, - STATE VARCHAR(16) NOT NULL, - JOB_NAME VARCHAR(200) NULL, - JOB_GROUP VARCHAR(200) NULL, - IS_NONCONCURRENT VARCHAR(1) NULL, - REQUESTS_RECOVERY VARCHAR(1) NULL, - PRIMARY KEY (SCHED_NAME, ENTRY_ID) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_SCHEDULER_STATE -( - SCHED_NAME VARCHAR(120) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - LAST_CHECKIN_TIME BIGINT(13) NOT NULL, - CHECKIN_INTERVAL BIGINT(13) NOT NULL, - PRIMARY KEY (SCHED_NAME, INSTANCE_NAME) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE TABLE QRTZ_LOCKS -( - SCHED_NAME VARCHAR(120) NOT NULL, - LOCK_NAME VARCHAR(40) NOT NULL, - PRIMARY KEY (SCHED_NAME, LOCK_NAME) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - -CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS (SCHED_NAME, REQUESTS_RECOVERY); -CREATE INDEX IDX_QRTZ_J_GRP ON QRTZ_JOB_DETAILS (SCHED_NAME, JOB_GROUP); - -CREATE INDEX IDX_QRTZ_T_J ON QRTZ_TRIGGERS (SCHED_NAME, JOB_NAME, JOB_GROUP); -CREATE INDEX IDX_QRTZ_T_JG ON QRTZ_TRIGGERS (SCHED_NAME, JOB_GROUP); -CREATE INDEX IDX_QRTZ_T_C ON QRTZ_TRIGGERS (SCHED_NAME, CALENDAR_NAME); -CREATE INDEX IDX_QRTZ_T_G ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_GROUP); -CREATE INDEX IDX_QRTZ_T_STATE ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_STATE); -CREATE INDEX IDX_QRTZ_T_N_STATE ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP, TRIGGER_STATE); -CREATE INDEX IDX_QRTZ_T_N_G_STATE ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_GROUP, TRIGGER_STATE); -CREATE INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON QRTZ_TRIGGERS (SCHED_NAME, NEXT_FIRE_TIME); -CREATE INDEX IDX_QRTZ_T_NFT_ST ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_STATE, NEXT_FIRE_TIME); -CREATE INDEX IDX_QRTZ_T_NFT_MISFIRE ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME); -CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_STATE); -CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_GROUP, - TRIGGER_STATE); - -CREATE INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, INSTANCE_NAME); -CREATE INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, INSTANCE_NAME, REQUESTS_RECOVERY); -CREATE INDEX IDX_QRTZ_FT_J_G ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, JOB_NAME, JOB_GROUP); -CREATE INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, JOB_GROUP); -CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP); -CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, TRIGGER_GROUP); - --- data -CREATE TABLE `t_channel_opcda_device` ( - `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', - `server_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '服务名', - `host` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'ip', - `user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户名', - `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '密码', - `prog_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备名', - `cls_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备注册表ID', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_server_name` (`server_name`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='OPCDA表'; - -CREATE TABLE `t_channel_opcda_tag` ( - `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', - `server_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '服务id', - `tag_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '测点名称', - `data_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '数据类型', - `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', - `item_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'itemId', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='opcda测点表'; - -CREATE TABLE `t_channel_opcua_device` ( - `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `server_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `endpoint_url` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `security_policy` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `security_mode` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `connection_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `user_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `password` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `certificate_path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `connect_inactivity_timeout` int DEFAULT NULL, - `reconnect_interval` int DEFAULT NULL, - `creator` bigint DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `updater` bigint DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_server_name` (`server_name`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='OPCUA表'; - -CREATE TABLE `t_channel_opcua_tag` ( - `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', - `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型', - `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', - `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备', - `address` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'opcda地址', - `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_device` (`device`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='opcda测点表'; - -CREATE TABLE `t_channel_modbus_device` ( - `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备名称', - `address` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'IP地址', - `port` smallint unsigned NOT NULL COMMENT '端口', - `connect_inactivity_timeout` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '不活动超时(ms)', - `reconnect_interval` smallint unsigned DEFAULT NULL COMMENT '重连超时(ms)', - `attempts_before_timeout` smallint unsigned DEFAULT NULL COMMENT '重试次数', - `wait_to_retry_milliseconds` smallint unsigned DEFAULT NULL COMMENT '重试间隔(ms)', - `read_timeout` smallint unsigned DEFAULT NULL COMMENT '读超时(ms)', - `write_timeout` smallint unsigned DEFAULT NULL COMMENT '写超时(ms)', - `use_optimized_block_read` tinyint(1) DEFAULT NULL COMMENT '是否使用优化', - `project_reference` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '系统内部用,默认空字符串', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_name` (`name`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='ModBus表'; - -CREATE TABLE `t_channel_modbus_tag` ( - `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', - `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型', - `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', - `format` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '大小端', - `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备', - `address` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'Modbus地址', - `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `tag_desc` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '描述', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_device` (`device`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='ModBus测点表'; - - -CREATE TABLE `t_channel_kio_device` ( - `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `instance_name` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '实例名称', - `address` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'IP地址', - `port` smallint unsigned NOT NULL COMMENT '端口', - `username` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', - `password` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_instance_name` (`instance_name`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='KIO实例表'; - - -CREATE TABLE `t_channel_kio_tag` ( - `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `tag_name` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', - `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型', - `tag_id` int NOT NULL COMMENT '顺序号', - `tag_desc` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci default NULL COMMENT '测点描述', - `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', - `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备', - `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_device` (`device`) USING BTREE, - KEY `idx_tag_name` (`tag_name`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='KIO测点表'; - -CREATE TABLE t_da_point( - `id` VARCHAR(255) NOT NULL COMMENT 'ID' , - `point_no` VARCHAR(36) COMMENT '测点编码' , - `point_name` VARCHAR(36) COMMENT '测点名称' , - `point_type` VARCHAR(10) COMMENT '测点类型' , - `data_type` VARCHAR(10) COMMENT '数据类型' , - `value_type` VARCHAR(10) COMMENT '值类型' , - `store_type` VARCHAR(10) COMMENT '存储类型' , - `unit` VARCHAR(36) COMMENT '测量单位' , - `unittransfactor` DECIMAL(24,6) COMMENT '单位转换' , - `default_value` DECIMAL(24,6) COMMENT '默认值' , - `max_value` DECIMAL(24,6) COMMENT '最大值' , - `min_value` DECIMAL(24,6) COMMENT '最小值' , - `offset_value` DECIMAL(24,6) COMMENT '偏移量' , - `minfreqid` VARCHAR(10) COMMENT '采集频率' , - `remark` VARCHAR(255) COMMENT '备注' , - `is_enable` tinyint(1) COMMENT '是否启用' , - `creator` VARCHAR(255) COMMENT '创建人' , - `create_time` DATETIME COMMENT '创建时间' , - `updater` VARCHAR(255) COMMENT '修改人' , - `update_time` DATETIME COMMENT '修改时间' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_no` (`point_no`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '测点表;'; - -CREATE TABLE t_da_measure_point( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `point_id` VARCHAR(36) COMMENT '测点ID' , - `source_type` VARCHAR(10) COMMENT '数据源类型', - `source_id` VARCHAR(36) COMMENT '数据源ID', - `tag_no` VARCHAR(64) COMMENT '测点Tag', - `dimension` INT COMMENT '尺度' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE, - KEY `uk_tag_no` (`tag_no`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '测量点表'; - -CREATE TABLE t_da_math_point( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `point_id` VARCHAR(36) COMMENT '测点ID' , - `expression` VARCHAR(500) COMMENT '计算公式' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计算点表'; - -CREATE TABLE `t_da_point_value` ( - `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', - `point_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '测点编码', - `data_time` datetime DEFAULT NULL COMMENT '数据时间', - `data_value` decimal(24,6) DEFAULT NULL COMMENT '数据值', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_point_no` (`point_no`) USING BTREE, - KEY `idx_data_time` (`data_time`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='点值表'; - -CREATE TABLE t_da_sequence_num( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `code` VARCHAR(36) COMMENT '编号', - `name` VARCHAR(36) COMMENT '名称', - `sequence_num` int COMMENT '序号' , - `prefix` VARCHAR(10) COMMENT '前缀' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_code` (`code`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '序号表'; -INSERT INTO `t_da_sequence_num` (`id`, `code`, `name`, `sequence_num`, `prefix`) VALUES ('1', 'POINT_M', '测量点编码', 100000, 'M'); -INSERT INTO `t_da_sequence_num` (`id`, `code`, `name`, `sequence_num`, `prefix`) VALUES ('2', 'POINT_C', '计算点编码', 100000, 'C'); - -CREATE TABLE `t_http_api` ( - `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID', - `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编码', - `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称', - `url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'URL', - `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '方法', - `param` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数', - `descp` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述', - `status` int NULL DEFAULT NULL COMMENT '状态', - `creator` VARCHAR(255) COMMENT '创建人' , - `create_time` DATETIME COMMENT '创建时间' , - `updater` VARCHAR(255) COMMENT '修改人' , - `update_time` DATETIME COMMENT '修改时间' , - PRIMARY KEY (`ID`) USING BTREE, - UNIQUE KEY `uk_code` (`code`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'Api接口' ROW_FORMAT = DYNAMIC; - - -CREATE TABLE `t_http_token` ( - `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `api_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `login_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `client_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `client_secret` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `token` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'token', - `expire_time` datetime DEFAULT NULL COMMENT '过期时间', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_api_id` (`api_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='接口Token'; - -CREATE TABLE `t_http_tag` ( - `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '查询号', - `http_api_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'HTTP 接口代码', - `tag_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点编码', - `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='接口Tag表'; - -CREATE TABLE t_ind_item_atom( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `data_source` VARCHAR(20) COMMENT '数据源', - `query_sql` VARCHAR(500) COMMENT '查询语句', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标'; - -CREATE TABLE t_ind_item( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_no` VARCHAR(36) COMMENT '指标编码' , - `item_name` VARCHAR(36) COMMENT '指标名称' , - `item_type` VARCHAR(10) COMMENT '指标类型' , - `coefficient` decimal(10, 4) COMMENT '系数', - `precision` int COMMENT '指标精度', - `business_type` VARCHAR(10) COMMENT '业务类型', - `time_range` VARCHAR(20) COMMENT '时间范围' , - `time_granularity` VARCHAR(10) COMMENT '时间粒度' , - `remark` VARCHAR(255) COMMENT '备注' , - `is_enable` tinyint(1) COMMENT '是否启用' , - `creator` VARCHAR(36) COMMENT '创建人' , - `create_time` DATETIME COMMENT '创建时间' , - `updater` VARCHAR(36) COMMENT '修改人' , - `update_time` DATETIME COMMENT '修改时间' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_item_no` (`item_no`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标项表'; - -CREATE TABLE t_ind_item_atom( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `data_source` VARCHAR(20) COMMENT '数据源', - `query_sql` VARCHAR(500) COMMENT '查询语句', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标'; - -CREATE TABLE t_ind_item_cal( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `expression` varchar(100) DEFAULT NULL COMMENT '计算表达式', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计算指标'; - -CREATE TABLE t_ind_item_derive( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `limit_time` varchar(100) DEFAULT NULL COMMENT '时间限定', - `limit_business` varchar(100) DEFAULT NULL COMMENT '业务限定', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '派生指标'; - -CREATE TABLE `t_ind_item_value` ( - `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', - `item_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '指标编码', - `data_time` varchar(36) DEFAULT NULL COMMENT '数据时间', - `data_value` decimal(24,6) DEFAULT NULL COMMENT '数据值', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_item_no` (`item_no`) USING BTREE, - KEY `idx_data_time` (`data_time`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='指标值表'; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java index a59347e..bfc5fce 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java @@ -8,9 +8,9 @@ import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; import javax.annotation.Resource; -import javax.validation.Valid; import com.iailab.module.data.channel.modbus.vo.ModBusDeviceRespVO; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.UUID; @@ -35,7 +35,7 @@ * @param reqVO */ @GetMapping("/page") - public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Valid ModBusDevicePageReqVO reqVO) { + public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Validated ModBusDevicePageReqVO reqVO) { PageResult<ChannelModBusDeviceEntity> page = channelModbusDeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, ModBusDeviceRespVO.class)); diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java index cb124e6..7883fec 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java @@ -1,6 +1,8 @@ package com.iailab.module.data.job.controller.admin; -import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.common.utils.Constant; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.util.validation.ValidationUtils; @@ -8,16 +10,21 @@ import com.iailab.framework.common.validation.group.DefaultGroup; import com.iailab.framework.common.validation.group.UpdateGroup; import com.iailab.module.data.job.dto.ScheduleJobDTO; +import com.iailab.module.data.job.entity.ScheduleJobEntity; import com.iailab.module.data.job.service.ScheduleJobService; +import com.iailab.module.data.job.vo.ScheduleJobReqVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import javax.annotation.Resource; + import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.Map; + +import static com.iailab.framework.common.pojo.CommonResult.success; /** * 定时任务 @@ -25,7 +32,7 @@ * @author Mark sunlightcs@gmail.com */ @RestController -@RequestMapping("/sys/schedule") +@RequestMapping("/data/job/schedule") @Tag(name = "定时任务") public class ScheduleJobController { @Resource @@ -40,25 +47,26 @@ @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , @Parameter(name = "beanName", description = "beanName") }) - @PreAuthorize("@ss.hasPermission('sys:schedule:page')") - public CommonResult<PageData<ScheduleJobDTO>> page(@RequestParam Map<String, Object> params){ - PageData<ScheduleJobDTO> page = scheduleJobService.page(params); + @PreAuthorize("@ss.hasPermission('data:schedule:query')") + public CommonResult<PageResult<ScheduleJobDTO>> page(@Validated ScheduleJobReqVO reqVO){ + reqVO.setTenantId(TenantContextHolder.getTenantId()); + PageResult<ScheduleJobEntity> page = scheduleJobService.page(reqVO); - return new CommonResult<PageData<ScheduleJobDTO>>().setData(page); + return success(BeanUtils.toBean(page, ScheduleJobDTO.class)); } - @GetMapping("{id}") + @GetMapping("info") @Operation(summary = "信息") - @PreAuthorize("@ss.hasPermission('sys:schedule:info')") - public CommonResult<ScheduleJobDTO> info(@PathVariable("id") Long id){ + @PreAuthorize("@ss.hasPermission('data:schedule:query')") + public CommonResult<ScheduleJobDTO> info(@RequestParam("id") Long id){ ScheduleJobDTO schedule = scheduleJobService.get(id); return new CommonResult<ScheduleJobDTO>().setData(schedule); } - @PostMapping + @PostMapping("/create") @Operation(summary = "保存") - @PreAuthorize("@ss.hasPermission('sys:schedule:save')") + @PreAuthorize("@ss.hasPermission('data:schedule:create')") public CommonResult save(@RequestBody ScheduleJobDTO dto){ ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); @@ -67,9 +75,9 @@ return new CommonResult(); } - @PutMapping + @PutMapping("/update") @Operation(summary = "修改") - @PreAuthorize("@ss.hasPermission('sys:schedule:update')") + @PreAuthorize("@ss.hasPermission('data:schedule:update')") public CommonResult update(@RequestBody ScheduleJobDTO dto){ ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); @@ -78,19 +86,20 @@ return new CommonResult(); } - @DeleteMapping + @DeleteMapping("/delete") @Operation(summary = "删除") - @PreAuthorize("@ss.hasPermission('sys:schedule:delete')") - public CommonResult delete(@RequestBody Long[] ids){ - scheduleJobService.deleteBatch(ids); + @PreAuthorize("@ss.hasPermission('data:schedule:delete')") + public CommonResult delete(@RequestParam("id") Long id){ + scheduleJobService.deleteBatch(id); return new CommonResult(); } @PutMapping("/run") @Operation(summary = "立即执行") - @PreAuthorize("@ss.hasPermission('sys:schedule:run')") - public CommonResult run(@RequestBody Long[] ids){ + public CommonResult run(@RequestParam("id") Long id){ + Long[] ids = new Long[1]; + ids[0] = id; scheduleJobService.run(ids); return new CommonResult(); @@ -98,8 +107,9 @@ @PutMapping("/pause") @Operation(summary = "暂停") - @PreAuthorize("@ss.hasPermission('sys:schedule:pause')") - public CommonResult pause(@RequestBody Long[] ids){ + public CommonResult pause(@RequestParam("id") Long id){ + Long[] ids = new Long[1]; + ids[0] = id; scheduleJobService.pause(ids); return new CommonResult(); @@ -107,8 +117,9 @@ @PutMapping("/resume") @Operation(summary = "恢复") - @PreAuthorize("@ss.hasPermission('sys:schedule:resume')") - public CommonResult resume(@RequestBody Long[] ids){ + public CommonResult resume(@RequestParam("id") Long id){ + Long[] ids = new Long[1]; + ids[0] = id; scheduleJobService.resume(ids); return new CommonResult(); diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java index fd4d2ca..90209d7 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java @@ -1,8 +1,11 @@ package com.iailab.module.data.job.dao; import com.baomidou.dynamic.datasource.annotation.Master; -import com.iailab.framework.common.dao.BaseDao; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.vo.ScheduleJobReqVO; import org.apache.ibatis.annotations.Mapper; import java.util.Map; @@ -14,7 +17,15 @@ */ @Master @Mapper -public interface ScheduleJobDao extends BaseDao<ScheduleJobEntity> { +public interface ScheduleJobDao extends BaseMapperX<ScheduleJobEntity> { + + default PageResult<ScheduleJobEntity> selectPage(ScheduleJobReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<ScheduleJobEntity>() + .likeIfPresent(ScheduleJobEntity::getBeanName, reqVO.getBeanName()) + .eqIfPresent(ScheduleJobEntity::getTenantId, reqVO.getTenantId()) + .orderByDesc(ScheduleJobEntity::getCreateDate)); + + } /** * 批量更新状态 diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java index 99f5369..bc6d09e 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java @@ -1,20 +1,11 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - package com.iailab.module.data.job.service; -import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.BaseService; import com.iailab.module.data.job.entity.ScheduleJobEntity; -import com.iailab.module.data.job.entity.ScheduleJobEntity; import com.iailab.module.data.job.dto.ScheduleJobDTO; +import com.iailab.module.data.job.vo.ScheduleJobReqVO; -import java.util.Map; /** * 定时任务 @@ -23,7 +14,7 @@ */ public interface ScheduleJobService extends BaseService<ScheduleJobEntity> { - PageData<ScheduleJobDTO> page(Map<String, Object> params); + PageResult<ScheduleJobEntity> page(ScheduleJobReqVO reqVO); ScheduleJobDTO get(Long id); @@ -40,7 +31,7 @@ /** * 批量删除定时任务 */ - void deleteBatch(Long[] ids); + void deleteBatch(Long id); /** * 批量更新定时任务状态 diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java index 917cdf2..677e041 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java @@ -1,25 +1,20 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - package com.iailab.module.data.job.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.framework.security.core.util.SecurityFrameworkUtils; +import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.job.entity.ScheduleJobEntity; import com.iailab.module.data.job.dao.ScheduleJobDao; import com.iailab.module.data.job.dto.ScheduleJobDTO; import com.iailab.module.data.job.service.ScheduleJobService; import com.iailab.module.data.job.utils.ScheduleUtils; +import com.iailab.module.data.job.vo.ScheduleJobReqVO; import org.apache.commons.lang3.StringUtils; import org.quartz.Scheduler; import javax.annotation.Resource; @@ -37,12 +32,8 @@ private Scheduler scheduler; @Override - public PageData<ScheduleJobDTO> page(Map<String, Object> params) { - IPage<ScheduleJobEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), - getWrapper(params) - ); - return getPageData(page, ScheduleJobDTO.class); + public PageResult<ScheduleJobEntity> page(ScheduleJobReqVO reqVO) { + return baseDao.selectPage(reqVO); } @Override @@ -64,9 +55,13 @@ @Override @Transactional(rollbackFor = Exception.class) public void save(ScheduleJobDTO dto) { + Long tenantId = TenantContextHolder.getRequiredTenantId(); ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); - entity.setCreateDate(new Date()); + entity.setId(System.currentTimeMillis()); entity.setStatus(Constant.ScheduleStatus.NORMAL.getValue()); + entity.setTenantId(tenantId); + entity.setCreator(SecurityFrameworkUtils.getLoginUser().getId()); + entity.setCreateDate(new Date()); this.insert(entity); ScheduleUtils.createScheduleJob(scheduler, entity); @@ -75,8 +70,11 @@ @Override @Transactional(rollbackFor = Exception.class) public void update(ScheduleJobDTO dto) { + Long tenantId = TenantContextHolder.getRequiredTenantId(); ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); entity.setUpdateDate(new Date()); + entity.setUpdater(SecurityFrameworkUtils.getLoginUser().getId()); + entity.setTenantId(tenantId); ScheduleUtils.updateScheduleJob(scheduler, entity); this.updateById(entity); @@ -84,13 +82,10 @@ @Override @Transactional(rollbackFor = Exception.class) - public void deleteBatch(Long[] ids) { - for(Long id : ids){ - ScheduleUtils.deleteScheduleJob(scheduler, id); - } - - //删除数据 - this.deleteBatchIds(Arrays.asList(ids)); + public void deleteBatch(Long id) { + ScheduleUtils.deleteScheduleJob(scheduler, id); + + baseDao.deleteById(id); } @Override diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java index acdbd82..b4bf553 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java @@ -6,6 +6,7 @@ import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.job.entity.ScheduleJobEntity; import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.service.ScheduleJobLogService; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.slf4j.Logger; @@ -32,13 +33,16 @@ //设置当前租户 TenantContextHolder.setTenantId(scheduleJob.getTenantId()); + Long tenantId = TenantContextHolder.getRequiredTenantId(); //数据库保存执行记录 ScheduleJobLogEntity log = new ScheduleJobLogEntity(); + log.setId(System.currentTimeMillis()); log.setJobId(scheduleJob.getId()); log.setBeanName(scheduleJob.getBeanName()); log.setParams(scheduleJob.getParams()); log.setCreateDate(new Date()); + log.setTenantId(tenantId); //任务开始时间 long startTime = System.currentTimeMillis(); @@ -69,8 +73,8 @@ log.setError(ExceptionUtils.getErrorStackTrace(e)); }finally { //获取spring bean - /*ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); - scheduleJobLogService.insert(log);*/ + ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); + scheduleJobLogService.insert(log); } } } \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/vo/ScheduleJobReqVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/vo/ScheduleJobReqVO.java new file mode 100644 index 0000000..9dd88e8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/vo/ScheduleJobReqVO.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.job.vo; + +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月23日 + */ +@Schema(description = "数据平台 - 定时任务分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ScheduleJobReqVO extends PageParam { + + private String beanName; + + private Long tenantId; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml index f2fa1c5..80f21a9 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml @@ -38,7 +38,7 @@ primary: master datasource: master: - url: jdbc:mysql://127.0.0.1:3306/iailab_data_master?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://127.0.0.1:3306/iailab_expert_master?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root password: 123456 diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml index 2e2cfb4..b0e8d5e 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml @@ -175,6 +175,8 @@ - qrtz_simple_triggers - qrtz_simprop_triggers - qrtz_triggers + - schedule_job + - schedule_job_log - t_channel_kio_device - t_channel_kio_tag - t_channel_modbus_device -- Gitblit v1.9.3