From e4829212d3a86bb237781302804a302c830d7a13 Mon Sep 17 00:00:00 2001 From: KAI <1373639299@qq.com> Date: Tue, 2 Jul 2024 18:58:22 +0800 Subject: [PATCH 01/21] =?UTF-8?q?feat:=20=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=A8=A1=E5=9D=97=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../continew-admin-job-server/pom.xml | 78 + .../job/ContinewAdminJobApplication.java | 30 + .../main/resources/config/application-dev.yml | 59 + .../resources/config/application-prod.yml | 80 + .../src/main/resources/config/application.yml | 16 + .../db/changelogs/db.changelog-master.yaml | 3 + .../db/changelogs/dm/snail_job_dm8.sql | 821 +++++ .../db/changelogs/mysql/snail_job_mysql.sql | 518 ++++ .../db/changelogs/oracle/snail_job_oracle.sql | 890 ++++++ .../changelogs/postgre/snail_job_postgre.sql | 821 +++++ .../sqlserver/snail_job_sqlserver.sql | 2690 +++++++++++++++++ .../job/ContinewAdminJobApplicationTests.java | 29 + continew-admin-extension/pom.xml | 18 + .../continew-admin-job/pom.xml | 46 + .../job/config/http/HttpInterfaceConfig.java | 85 + .../admin/job/config/http/JobApi.java | 65 + .../admin/job/config/http/JobBatchApi.java | 63 + .../admin/job/config/http/TokenHolder.java | 73 + .../admin/job/constant/JobConstants.java | 28 + .../continew/admin/job/model/JobResult.java | 37 + .../admin/job/model/query/JobLogQuery.java | 49 + .../admin/job/model/query/JobQuery.java | 37 + .../admin/job/model/query/JobTaskQuery.java | 37 + .../continew/admin/job/model/req/JobReq.java | 154 + .../admin/job/model/req/JobStatusReq.java | 39 + .../admin/job/model/req/JobUserReq.java | 42 + .../admin/job/model/resp/JobLogResp.java | 119 + .../admin/job/model/resp/JobResp.java | 174 ++ .../admin/job/model/resp/JobTaskResp.java | 116 + .../admin/job/model/resp/JobUserResp.java | 53 + .../admin/job/service/JobLogService.java | 43 + .../admin/job/service/JobService.java | 46 + .../job/service/impl/JobLogServiceImpl.java | 131 + .../job/service/impl/JobServiceImpl.java | 169 ++ .../src/test/java/top/continew/AppTest.java | 38 + continew-admin-plugins/pom.xml | 1 + continew-admin-webapi/pom.xml | 26 + .../admin/ContiNewAdminApplication.java | 2 + .../admin/controller/job/JobController.java | 117 + .../controller/job/JobLogController.java | 92 + .../main/resources/config/application-dev.yml | 41 + .../resources/config/application-prod.yml | 41 + pom.xml | 7 + 43 files changed, 8024 insertions(+) create mode 100644 continew-admin-extension/continew-admin-job-server/pom.xml create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql create mode 100644 continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java create mode 100644 continew-admin-extension/pom.xml create mode 100644 continew-admin-plugins/continew-admin-job/pom.xml create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java create mode 100644 continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java create mode 100644 continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java create mode 100644 continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java diff --git a/continew-admin-extension/continew-admin-job-server/pom.xml b/continew-admin-extension/continew-admin-job-server/pom.xml new file mode 100644 index 00000000..f5481ae0 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + top.continew + continew-admin-extension + ${revision} + + + continew-admin-job-server + 分布式 定时任务模块 + + + + 1.1.0-beta1 + + + + + + org.liquibase + liquibase-core + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.aizuda + snail-job-server-starter + ${snail-job-version} + + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + + com.baomidou + dynamic-datasource-spring-boot3-starter + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java b/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java new file mode 100644 index 00000000..7695411d --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.job; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ContinewAdminJobApplication { + + public static void main(String[] args) { + //需要使用snailJobServer启动 + SpringApplication.run(com.aizuda.snailjob.server.SnailJobServerApplication.class, args); + } + +} diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml new file mode 100644 index 00000000..b44364ea --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml @@ -0,0 +1,59 @@ +server: + port: 8001 +# 数据源配置 +spring.datasource: + type: com.zaxxer.hikari.HikariDataSource + ## 动态数据源配置(可配多主多从:m1、s1...;纯粹多库:mysql、oracle...;混合配置:m1、s1、oracle...) + dynamic: + # 设置默认的数据源或者数据源组(默认:master) + primary: master + # 严格匹配数据源(true:未匹配到指定数据源时抛异常;false:使用默认数据源;默认 false) + strict: false + datasource: + # 主库配置(可配多个,构成多主) + master: + url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:continew_admin_job}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false&allowPublicKeyRetrieval=true + username: ${DB_USER:root} + password: ${DB_PWD:123456} + driver-class-name: com.mysql.cj.jdbc.Driver + type: ${spring.datasource.type} + hikari: + # 最大连接数量(默认 10,根据实际环境调整) + # 注意:当连接达到上限,并且没有空闲连接可用时,获取连接将在超时前阻塞最多 connectionTimeout 毫秒 + max-pool-size: 20 + # 获取连接超时时间(默认 30000 毫秒,30 秒) + connection-timeout: 30000 + # 空闲连接最大存活时间(默认 600000 毫秒,10 分钟) + idle-timeout: 600000 + # 保持连接活动的频率,以防止它被数据库或网络基础设施超时。该值必须小于 maxLifetime(默认 0,禁用) + keepaliveTime: 30000 + # 连接最大生存时间(默认 1800000 毫秒,30 分钟) + max-lifetime: 1800000 +## Liquibase 配置 +spring.liquibase: + # 是否启用 + enabled: true + # 配置文件路径 + change-log: classpath:/db/changelogs/db.changelog-master.yaml + +--- # snail-job 服务端配置 +snail-job: + # 拉取重试数据的每批次的大小 + retry-pull-page-size: 1000 + # 拉取重试数据的每批次的大小 + job-pull-page-size: 1000 + # 服务端netty端口 + netty-port: 1788 + # 一个客户端每秒最多接收的重试数量指令 + limiter: 1000 + # 号段模式下步长配置 + step: 100 + # 日志保存时间(单位: day) + log-storage: 90 + # 回调配置 + callback: + #回调最大执行次数 + max-count: 288 + #间隔时间 + trigger-interval: 900 + retry-max-pull-count: 10 \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml new file mode 100644 index 00000000..37331f9e --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml @@ -0,0 +1,80 @@ +server: + port: 1788 +# 数据源配置 +spring.datasource: + type: com.zaxxer.hikari.HikariDataSource + ## 动态数据源配置(可配多主多从:m1、s1...;纯粹多库:mysql、oracle...;混合配置:m1、s1、oracle...) + dynamic: + # 设置默认的数据源或者数据源组(默认:master) + primary: master + # 严格匹配数据源(true:未匹配到指定数据源时抛异常;false:使用默认数据源;默认 false) + strict: false + datasource: + # 主库配置(可配多个,构成多主) + master: + url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:continew_admin_job}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false + username: ${DB_USER:root} + password: ${DB_PWD:123456} + driver-class-name: com.mysql.cj.jdbc.Driver + type: ${spring.datasource.type} + hikari: + # 最大连接数量(默认 10,根据实际环境调整) + # 注意:当连接达到上限,并且没有空闲连接可用时,获取连接将在超时前阻塞最多 connectionTimeout 毫秒 + max-pool-size: 20 + # 获取连接超时时间(默认 30000 毫秒,30 秒) + connection-timeout: 30000 + # 空闲连接最大存活时间(默认 600000 毫秒,10 分钟) + idle-timeout: 600000 + # 保持连接活动的频率,以防止它被数据库或网络基础设施超时。该值必须小于 maxLifetime(默认 0,禁用) + keepaliveTime: 30000 + # 连接最大生存时间(默认 1800000 毫秒,30 分钟) + max-lifetime: 1800000 +## Liquibase 配置 +spring.liquibase: + # 是否启用 + enabled: true + # 配置文件路径 + change-log: classpath:/db/changelogs/db.changelog-master.yaml + +--- # snail-job 服务端配置 +snail-job: + # bucket的总数量 + bucket-total: 128 + callback: + # 配置回调的最大执行次数 + max-count: 288 + # 回调uniqueId前缀 + prefix: CB + # 配置回调触发的间隔时间 + trigger-interval: 900 + # 配置一个客户端每秒最多接收的重试数量指令 + limiter: 10 + # 配置负载均衡周期时间 + load-balance-cycle-time: 10 + # 配置日志保存时间(单位:天) + log-storage: 90 + # 配置邮件通知配置 + mail: + auth: true + connectionTimeout: 0 + enabled: true + from: xxx.qq.com + host: xxx + pass: xxxx + port: 465 + sslEnable: false + starttlsEnable: false + timeout: 0 + user: demo + # 合并日志默认保存天数 + merge-Log-days: 1 + # 合并日志默认的条数 + merge-Log-num: 500 + # 服务端netty的端口号 + netty-port: 1788 + # 配置每批次拉取重试数据的大小 + retry-pull-page-size: 100 + # 配置号段模式下的步长 + step: 100 + # Dashboard 任务容错天数 + summary-day: 7 diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml new file mode 100644 index 00000000..0f29861c --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml @@ -0,0 +1,16 @@ +spring: + application: + name: continew-admin-job + main: + allow-bean-definition-overriding: true +mybatis-plus: + typeAliasesPackage: com.aizuda.snailjob.template.datasource.persistence.po + global-config: + db-config: + where-strategy: NOT_EMPTY + capital-mode: false + logic-delete-value: 1 + logic-not-delete-value: 0 + configuration: + map-underscore-to-camel-case: true + cache-enabled: true \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml new file mode 100644 index 00000000..8f656108 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml @@ -0,0 +1,3 @@ +databaseChangeLog: + - include: + file: db/changelogs/mysql/snail_job_mysql.sql diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql new file mode 100644 index 00000000..42498f78 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql @@ -0,0 +1,821 @@ +/* + SnailJob Database Transfer Tool + Source Server Type : MySQL + Target Server Type : DM8 + Date: 2024-06-01 00:26:12 +*/ + + +-- sj_namespace +CREATE TABLE sj_namespace +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + name varchar(64) NULL, + unique_id varchar(64) NULL, + description varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_namespace_01 ON sj_namespace (name); + +COMMENT ON COLUMN sj_namespace.id IS '主键'; +COMMENT ON COLUMN sj_namespace.name IS '名称'; +COMMENT ON COLUMN sj_namespace.unique_id IS '唯一id'; +COMMENT ON COLUMN sj_namespace.description IS '描述'; +COMMENT ON COLUMN sj_namespace.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_namespace.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_namespace.update_dt IS '修改时间'; +COMMENT ON TABLE sj_namespace IS '命名空间'; + +INSERT INTO sj_namespace (name, unique_id, create_dt, update_dt, deleted) +VALUES ('Default', '764d604ec6fc45f68cd92514c40e9e1a', sysdate, sysdate, 0); + +-- sj_group_config +CREATE TABLE sj_group_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) DEFAULT '' NULL, + description varchar(256) DEFAULT '' NULL, + token varchar(64) DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT' NULL, + group_status smallint DEFAULT 0 NOT NULL, + version int NOT NULL, + group_partition int NOT NULL, + id_generator_mode smallint DEFAULT 1 NOT NULL, + init_scene smallint DEFAULT 0 NOT NULL, + bucket_index int DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_group_config_01 ON sj_group_config (namespace_id, group_name); + +COMMENT ON COLUMN sj_group_config.id IS '主键'; +COMMENT ON COLUMN sj_group_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_group_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_group_config.description IS '组描述'; +COMMENT ON COLUMN sj_group_config.token IS 'token'; +COMMENT ON COLUMN sj_group_config.group_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_group_config.version IS '版本号'; +COMMENT ON COLUMN sj_group_config.group_partition IS '分区'; +COMMENT ON COLUMN sj_group_config.id_generator_mode IS '唯一id生成模式 默认号段模式'; +COMMENT ON COLUMN sj_group_config.init_scene IS '是否初始化场景 0:否 1:是'; +COMMENT ON COLUMN sj_group_config.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_group_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_group_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_group_config IS '组配置'; + +-- sj_notify_config +CREATE TABLE sj_notify_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + business_id varchar(64) NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + notify_status smallint DEFAULT 0 NOT NULL, + recipient_ids varchar(128) NULL, + notify_threshold int DEFAULT 0 NOT NULL, + notify_scene smallint DEFAULT 0 NOT NULL, + rate_limiter_status smallint DEFAULT 0 NOT NULL, + rate_limiter_threshold int DEFAULT 0 NOT NULL, + description varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_notify_config_01 ON sj_notify_config (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_notify_config.id IS '主键'; +COMMENT ON COLUMN sj_notify_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_notify_config.business_id IS '业务id ( job_id或workflow_id或scene_name ) '; +COMMENT ON COLUMN sj_notify_config.system_task_type IS '任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_notify_config.notify_status IS '通知状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.recipient_ids IS '接收人id列表'; +COMMENT ON COLUMN sj_notify_config.notify_threshold IS '通知阈值'; +COMMENT ON COLUMN sj_notify_config.notify_scene IS '通知场景'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_status IS '限流状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_threshold IS '每秒限流阈值'; +COMMENT ON COLUMN sj_notify_config.description IS '描述'; +COMMENT ON COLUMN sj_notify_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_config IS '通知配置'; + +-- sj_notify_recipient +CREATE TABLE sj_notify_recipient +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + recipient_name varchar(64) NULL, + notify_type smallint DEFAULT 0 NOT NULL, + notify_attribute varchar(512) NULL, + description varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id); + +COMMENT ON COLUMN sj_notify_recipient.id IS '主键'; +COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称'; +COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook'; +COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性'; +COMMENT ON COLUMN sj_notify_recipient.description IS '描述'; +COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_recipient.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_recipient IS '告警通知接收人'; + +-- sj_retry_dead_letter_0 +CREATE TABLE sj_retry_dead_letter_0 +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar(64) NULL, + group_name varchar(64) NULL, + scene_name varchar(64) NULL, + idempotent_id varchar(64) NULL, + biz_no varchar(64) DEFAULT '' NULL, + executor_name varchar(512) DEFAULT '' NULL, + args_str text NULL, + ext_attrs text NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_dead_letter_0_02 ON sj_retry_dead_letter_0 (idempotent_id); +CREATE INDEX idx_sj_retry_dead_letter_0_03 ON sj_retry_dead_letter_0 (biz_no); +CREATE INDEX idx_sj_retry_dead_letter_0_04 ON sj_retry_dead_letter_0 (create_dt); + +COMMENT ON COLUMN sj_retry_dead_letter_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_dead_letter_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_dead_letter_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_dead_letter_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_dead_letter_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_dead_letter_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_dead_letter_0.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_dead_letter_0 IS '死信队列表'; + +-- sj_retry_task_0 +CREATE TABLE sj_retry_task_0 +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar(64) NULL, + group_name varchar(64) NULL, + scene_name varchar(64) NULL, + idempotent_id varchar(64) NULL, + biz_no varchar(64) DEFAULT '' NULL, + executor_name varchar(512) DEFAULT '' NULL, + args_str text NULL, + ext_attrs text NULL, + next_trigger_at datetime NOT NULL, + retry_count int DEFAULT 0 NOT NULL, + retry_status smallint DEFAULT 0 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_0_02 ON sj_retry_task_0 (namespace_id, group_name, task_type); +CREATE INDEX idx_sj_retry_task_0_03 ON sj_retry_task_0 (namespace_id, group_name, retry_status); +CREATE INDEX idx_sj_retry_task_0_04 ON sj_retry_task_0 (idempotent_id); +CREATE INDEX idx_sj_retry_task_0_05 ON sj_retry_task_0 (biz_no); +CREATE INDEX idx_sj_retry_task_0_06 ON sj_retry_task_0 (create_dt); + +COMMENT ON COLUMN sj_retry_task_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_0.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_retry_task_0.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_retry_task_0.retry_status IS '重试状态 0、重试中 1、成功 2、最大重试次数'; +COMMENT ON COLUMN sj_retry_task_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_0.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_0.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_0 IS '任务表'; + +-- sj_retry_task_log +CREATE TABLE sj_retry_task_log +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar(64) NULL, + group_name varchar(64) NULL, + scene_name varchar(64) NULL, + idempotent_id varchar(64) NULL, + biz_no varchar(64) DEFAULT '' NULL, + executor_name varchar(512) DEFAULT '' NULL, + args_str text NULL, + ext_attrs text NULL, + retry_status smallint DEFAULT 0 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_retry_task_log_01 ON sj_retry_task_log (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_log_02 ON sj_retry_task_log (retry_status); +CREATE INDEX idx_sj_retry_task_log_03 ON sj_retry_task_log (idempotent_id); +CREATE INDEX idx_sj_retry_task_log_04 ON sj_retry_task_log (unique_id); +CREATE INDEX idx_sj_retry_task_log_05 ON sj_retry_task_log (biz_no); +CREATE INDEX idx_sj_retry_task_log_06 ON sj_retry_task_log (create_dt); + +COMMENT ON COLUMN sj_retry_task_log.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_log.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_log.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_log.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_log.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_log.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_log.retry_status IS '重试状态 0、重试中 1、成功 2、最大次数'; +COMMENT ON COLUMN sj_retry_task_log.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_log.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_log.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_log IS '任务日志基础信息表'; + +-- sj_retry_task_log_message +CREATE TABLE sj_retry_task_log_message +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + unique_id varchar(64) NULL, + message text NULL, + log_num int DEFAULT 1 NOT NULL, + real_time bigint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id); +CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt); + +COMMENT ON COLUMN sj_retry_task_log_message.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log_message.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log_message.message IS '异常信息'; +COMMENT ON COLUMN sj_retry_task_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_retry_task_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_retry_task_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_task_log_message IS '任务调度日志信息记录表'; + +-- sj_retry_scene_config +CREATE TABLE sj_retry_scene_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + scene_name varchar(64) NULL, + group_name varchar(64) NULL, + scene_status smallint DEFAULT 0 NOT NULL, + max_retry_count int DEFAULT 5 NOT NULL, + back_off smallint DEFAULT 1 NOT NULL, + trigger_interval varchar(16) DEFAULT '' NULL, + deadline_request bigint DEFAULT 60000 NOT NULL, + executor_timeout int DEFAULT 5 NOT NULL, + route_key smallint DEFAULT 4 NOT NULL, + description varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_retry_scene_config_01 ON sj_retry_scene_config (namespace_id, group_name, scene_name); + +COMMENT ON COLUMN sj_retry_scene_config.id IS '主键'; +COMMENT ON COLUMN sj_retry_scene_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_scene_config.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_scene_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_scene_config.scene_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_retry_scene_config.max_retry_count IS '最大重试次数'; +COMMENT ON COLUMN sj_retry_scene_config.back_off IS '1、默认等级 2、固定间隔时间 3、CRON 表达式'; +COMMENT ON COLUMN sj_retry_scene_config.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_retry_scene_config.deadline_request IS 'Deadline Request 调用链超时 单位毫秒'; +COMMENT ON COLUMN sj_retry_scene_config.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_retry_scene_config.route_key IS '路由策略'; +COMMENT ON COLUMN sj_retry_scene_config.description IS '描述'; +COMMENT ON COLUMN sj_retry_scene_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_scene_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_scene_config IS '场景配置'; + +-- sj_server_node +CREATE TABLE sj_server_node +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + host_id varchar(64) NULL, + host_ip varchar(64) NULL, + host_port int NOT NULL, + expire_at datetime NOT NULL, + node_type smallint NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_server_node_01 ON sj_server_node (host_id, host_ip); + +CREATE INDEX idx_sj_server_node_01 ON sj_server_node (namespace_id, group_name); +CREATE INDEX idx_sj_server_node_02 ON sj_server_node (expire_at, node_type); + +COMMENT ON COLUMN sj_server_node.id IS '主键'; +COMMENT ON COLUMN sj_server_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_server_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_server_node.host_id IS '主机id'; +COMMENT ON COLUMN sj_server_node.host_ip IS '机器ip'; +COMMENT ON COLUMN sj_server_node.host_port IS '机器端口'; +COMMENT ON COLUMN sj_server_node.expire_at IS '过期时间'; +COMMENT ON COLUMN sj_server_node.node_type IS '节点类型 1、客户端 2、是服务端'; +COMMENT ON COLUMN sj_server_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_server_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_server_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_server_node IS '服务器节点'; + +-- sj_distributed_lock +CREATE TABLE sj_distributed_lock +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + name varchar(64) NULL, + lock_until timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL, + locked_at timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL, + locked_by varchar(255) NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +COMMENT ON COLUMN sj_distributed_lock.id IS '主键'; +COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称'; +COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长'; +COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间'; +COMMENT ON COLUMN sj_distributed_lock.locked_by IS '锁定者'; +COMMENT ON COLUMN sj_distributed_lock.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_distributed_lock.update_dt IS '修改时间'; +COMMENT ON TABLE sj_distributed_lock IS '锁定表'; + +-- sj_system_user +CREATE TABLE sj_system_user +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + username varchar(64) NULL, + password varchar(128) NULL, + role smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +COMMENT ON COLUMN sj_system_user.id IS '主键'; +COMMENT ON COLUMN sj_system_user.username IS '账号'; +COMMENT ON COLUMN sj_system_user.password IS '密码'; +COMMENT ON COLUMN sj_system_user.role IS '角色:1-普通用户、2-管理员'; +COMMENT ON COLUMN sj_system_user.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user IS '系统用户表'; + +INSERT INTO sj_system_user (username, password, role) +VALUES ('admin', '465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2); + +-- sj_system_user_permission +CREATE TABLE sj_system_user_permission +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + group_name varchar(64) NULL, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + system_user_id bigint NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id); + +COMMENT ON COLUMN sj_system_user_permission.id IS '主键'; +COMMENT ON COLUMN sj_system_user_permission.group_name IS '组名称'; +COMMENT ON COLUMN sj_system_user_permission.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_system_user_permission.system_user_id IS '系统用户id'; +COMMENT ON COLUMN sj_system_user_permission.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user_permission.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user_permission IS '系统用户权限表'; + +-- sj_sequence_alloc +CREATE TABLE sj_sequence_alloc +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) DEFAULT '' NULL, + max_id bigint DEFAULT 1 NOT NULL, + step int DEFAULT 100 NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_sequence_alloc_01 ON sj_sequence_alloc (namespace_id, group_name); + +COMMENT ON COLUMN sj_sequence_alloc.id IS '主键'; +COMMENT ON COLUMN sj_sequence_alloc.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_sequence_alloc.group_name IS '组名称'; +COMMENT ON COLUMN sj_sequence_alloc.max_id IS '最大id'; +COMMENT ON COLUMN sj_sequence_alloc.step IS '步长'; +COMMENT ON COLUMN sj_sequence_alloc.update_dt IS '更新时间'; +COMMENT ON TABLE sj_sequence_alloc IS '号段模式序号ID分配表'; + +-- sj_job +CREATE TABLE sj_job +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + job_name varchar(64) NULL, + args_str text DEFAULT NULL NULL, + args_type smallint DEFAULT 1 NOT NULL, + next_trigger_at bigint NOT NULL, + job_status smallint DEFAULT 1 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + route_key smallint DEFAULT 4 NOT NULL, + executor_type smallint DEFAULT 1 NOT NULL, + executor_info varchar(255) DEFAULT NULL NULL, + trigger_type smallint NOT NULL, + trigger_interval varchar(255) NULL, + block_strategy smallint DEFAULT 1 NOT NULL, + executor_timeout int DEFAULT 0 NOT NULL, + max_retry_times int DEFAULT 0 NOT NULL, + parallel_num int DEFAULT 1 NOT NULL, + retry_interval int DEFAULT 0 NOT NULL, + bucket_index int DEFAULT 0 NOT NULL, + resident smallint DEFAULT 0 NOT NULL, + description varchar(256) DEFAULT '' NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_job_01 ON sj_job (namespace_id, group_name); +CREATE INDEX idx_sj_job_02 ON sj_job (job_status, bucket_index); +CREATE INDEX idx_sj_job_03 ON sj_job (create_dt); + +COMMENT ON COLUMN sj_job.id IS '主键'; +COMMENT ON COLUMN sj_job.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job.group_name IS '组名称'; +COMMENT ON COLUMN sj_job.job_name IS '名称'; +COMMENT ON COLUMN sj_job.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_job.job_status IS '任务状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_job.task_type IS '任务类型 1、集群 2、广播 3、切片'; +COMMENT ON COLUMN sj_job.route_key IS '路由策略'; +COMMENT ON COLUMN sj_job.executor_type IS '执行器类型'; +COMMENT ON COLUMN sj_job.executor_info IS '执行器名称'; +COMMENT ON COLUMN sj_job.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_job.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_job.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_job.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_job.max_retry_times IS '最大重试次数'; +COMMENT ON COLUMN sj_job.parallel_num IS '并行数'; +COMMENT ON COLUMN sj_job.retry_interval IS '重试间隔 ( s ) '; +COMMENT ON COLUMN sj_job.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_job.resident IS '是否是常驻任务'; +COMMENT ON COLUMN sj_job.description IS '描述'; +COMMENT ON COLUMN sj_job.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job IS '任务信息'; + +-- sj_job_log_message +CREATE TABLE sj_job_log_message +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + task_id bigint NOT NULL, + message text NULL, + log_num int DEFAULT 1 NOT NULL, + real_time bigint DEFAULT 0 NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_job_log_message_01 ON sj_job_log_message (task_batch_id, task_id); +CREATE INDEX idx_sj_job_log_message_02 ON sj_job_log_message (create_dt); +CREATE INDEX idx_sj_job_log_message_03 ON sj_job_log_message (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_log_message.id IS '主键'; +COMMENT ON COLUMN sj_job_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_log_message.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_log_message.task_batch_id IS '任务批次id'; +COMMENT ON COLUMN sj_job_log_message.task_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_log_message.message IS '调度信息'; +COMMENT ON COLUMN sj_job_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_job_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_job_log_message.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_job_log_message IS '调度日志'; + +-- sj_job_task +CREATE TABLE sj_job_task +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + parent_id bigint DEFAULT 0 NOT NULL, + task_status smallint DEFAULT 0 NOT NULL, + retry_count int DEFAULT 0 NOT NULL, + client_info varchar(128) DEFAULT NULL NULL, + result_message text NULL, + args_str text DEFAULT NULL NULL, + args_type smallint DEFAULT 1 NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_job_task_01 ON sj_job_task (task_batch_id, task_status); +CREATE INDEX idx_sj_job_task_02 ON sj_job_task (create_dt); +CREATE INDEX idx_sj_job_task_03 ON sj_job_task (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_task.id IS '主键'; +COMMENT ON COLUMN sj_job_task.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id'; +COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port'; +COMMENT ON COLUMN sj_job_task.result_message IS '执行结果'; +COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job_task.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task IS '任务实例'; + +-- sj_job_task_batch +CREATE TABLE sj_job_task_batch +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + job_id bigint NOT NULL, + workflow_node_id bigint DEFAULT 0 NOT NULL, + parent_workflow_node_id bigint DEFAULT 0 NOT NULL, + workflow_task_batch_id bigint DEFAULT 0 NOT NULL, + task_batch_status smallint DEFAULT 0 NOT NULL, + operation_reason smallint DEFAULT 0 NOT NULL, + execution_at bigint DEFAULT 0 NOT NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + parent_id varchar(64) DEFAULT '' NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_job_task_batch_01 ON sj_job_task_batch (job_id, task_batch_status); +CREATE INDEX idx_sj_job_task_batch_02 ON sj_job_task_batch (create_dt); +CREATE INDEX idx_sj_job_task_batch_03 ON sj_job_task_batch (namespace_id, group_name); +CREATE INDEX idx_sj_job_task_batch_04 ON sj_job_task_batch (workflow_task_batch_id, workflow_node_id); + +COMMENT ON COLUMN sj_job_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_job_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task_batch.job_id IS '任务id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_node_id IS '工作流节点id'; +COMMENT ON COLUMN sj_job_task_batch.parent_workflow_node_id IS '工作流任务父批次id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_task_batch_id IS '工作流任务批次id'; +COMMENT ON COLUMN sj_job_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_job_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_job_task_batch.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_task_batch.parent_id IS '父节点'; +COMMENT ON COLUMN sj_job_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task_batch IS '任务批次'; + +-- sj_job_summary +CREATE TABLE sj_job_summary +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) DEFAULT '' NULL, + business_id bigint NOT NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + trigger_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + success_num int DEFAULT 0 NOT NULL, + fail_num int DEFAULT 0 NOT NULL, + fail_reason varchar(512) DEFAULT '' NULL, + stop_num int DEFAULT 0 NOT NULL, + stop_reason varchar(512) DEFAULT '' NULL, + cancel_num int DEFAULT 0 NOT NULL, + cancel_reason varchar(512) DEFAULT '' NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_job_summary_01 ON sj_job_summary (trigger_at, system_task_type, business_id); + +CREATE INDEX idx_sj_job_summary_01 ON sj_job_summary (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_job_summary.id IS '主键'; +COMMENT ON COLUMN sj_job_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_summary.business_id IS '业务id ( job_id或workflow_id ) '; +COMMENT ON COLUMN sj_job_summary.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_job_summary.success_num IS '执行成功-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.stop_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.stop_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.cancel_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.cancel_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_summary IS 'DashBoard_Job'; + +-- sj_retry_summary +CREATE TABLE sj_retry_summary +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) DEFAULT '' NULL, + scene_name varchar(50) DEFAULT '' NULL, + trigger_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + running_num int DEFAULT 0 NOT NULL, + finish_num int DEFAULT 0 NOT NULL, + max_count_num int DEFAULT 0 NOT NULL, + suspend_num int DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE UNIQUE INDEX uk_sj_retry_summary_01 ON sj_retry_summary (namespace_id, group_name, scene_name, trigger_at); + +CREATE INDEX idx_sj_retry_summary_01 ON sj_retry_summary (trigger_at); + +COMMENT ON COLUMN sj_retry_summary.id IS '主键'; +COMMENT ON COLUMN sj_retry_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_summary.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_retry_summary.running_num IS '重试中-日志数量'; +COMMENT ON COLUMN sj_retry_summary.finish_num IS '重试完成-日志数量'; +COMMENT ON COLUMN sj_retry_summary.max_count_num IS '重试到达最大次数-日志数量'; +COMMENT ON COLUMN sj_retry_summary.suspend_num IS '暂停重试-日志数量'; +COMMENT ON COLUMN sj_retry_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_summary IS 'DashBoard_Retry'; + +-- sj_workflow +CREATE TABLE sj_workflow +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + workflow_name varchar(64) NULL, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + workflow_status smallint DEFAULT 1 NOT NULL, + trigger_type smallint NOT NULL, + trigger_interval varchar(255) NULL, + next_trigger_at bigint NOT NULL, + block_strategy smallint DEFAULT 1 NOT NULL, + executor_timeout int DEFAULT 0 NOT NULL, + description varchar(256) DEFAULT '' NULL, + flow_info text DEFAULT NULL NULL, + bucket_index int DEFAULT 0 NOT NULL, + version int NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_workflow_01 ON sj_workflow (create_dt); +CREATE INDEX idx_sj_workflow_02 ON sj_workflow (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow.id IS '主键'; +COMMENT ON COLUMN sj_workflow.workflow_name IS '工作流名称'; +COMMENT ON COLUMN sj_workflow.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow.workflow_status IS '工作流状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_workflow.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_workflow.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_workflow.description IS '描述'; +COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_workflow.version IS '版本号'; +COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow IS '工作流'; + +-- sj_workflow_node +CREATE TABLE sj_workflow_node +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + node_name varchar(64) NULL, + group_name varchar(64) NULL, + job_id bigint NOT NULL, + workflow_id bigint NOT NULL, + node_type smallint DEFAULT 1 NOT NULL, + expression_type smallint DEFAULT 0 NOT NULL, + fail_strategy smallint DEFAULT 1 NOT NULL, + workflow_node_status smallint DEFAULT 1 NOT NULL, + priority_level int DEFAULT 1 NOT NULL, + node_info text DEFAULT NULL NULL, + version int NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_workflow_node_01 ON sj_workflow_node (create_dt); +CREATE INDEX idx_sj_workflow_node_02 ON sj_workflow_node (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_node.id IS '主键'; +COMMENT ON COLUMN sj_workflow_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_node.node_name IS '节点名称'; +COMMENT ON COLUMN sj_workflow_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_node.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_workflow_node.workflow_id IS '工作流ID'; +COMMENT ON COLUMN sj_workflow_node.node_type IS '1、任务节点 2、条件节点'; +COMMENT ON COLUMN sj_workflow_node.expression_type IS '1、SpEl、2、Aviator 3、QL'; +COMMENT ON COLUMN sj_workflow_node.fail_strategy IS '失败策略 1、跳过 2、阻塞'; +COMMENT ON COLUMN sj_workflow_node.workflow_node_status IS '工作流节点状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow_node.priority_level IS '优先级'; +COMMENT ON COLUMN sj_workflow_node.node_info IS '节点信息 '; +COMMENT ON COLUMN sj_workflow_node.version IS '版本号'; +COMMENT ON COLUMN sj_workflow_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_node.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_node IS '工作流节点'; + +-- sj_workflow_task_batch +CREATE TABLE sj_workflow_task_batch +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id varchar(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar(64) NULL, + workflow_id bigint NOT NULL, + task_batch_status smallint DEFAULT 0 NOT NULL, + operation_reason smallint DEFAULT 0 NOT NULL, + flow_info text DEFAULT NULL NULL, + execution_at bigint DEFAULT 0 NOT NULL, + ext_attrs varchar(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt datetime DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +CREATE INDEX idx_sj_workflow_task_batch_01 ON sj_workflow_task_batch (workflow_id, task_batch_status); +CREATE INDEX idx_sj_workflow_task_batch_02 ON sj_workflow_task_batch (create_dt); +CREATE INDEX idx_sj_workflow_task_batch_03 ON sj_workflow_task_batch (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_workflow_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id'; +COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次'; + diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql new file mode 100644 index 00000000..1b11a298 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql @@ -0,0 +1,518 @@ +SET NAMES utf8mb4; + +CREATE TABLE `sj_namespace` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(64) NOT NULL COMMENT '名称', + `unique_id` varchar(64) NOT NULL COMMENT '唯一id', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + UNIQUE KEY `uk_unique_id` (`unique_id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='命名空间'; + +INSERT INTO `sj_namespace` (`id`, `name`, `unique_id`, `create_dt`, `update_dt`, `deleted`) +VALUES (1, 'Default', '764d604ec6fc45f68cd92514c40e9e1a', now(), now(), 0); + + +CREATE TABLE `sj_group_config` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL DEFAULT '' COMMENT '组名称', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '组描述', + `token` varchar(64) NOT NULL DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT' COMMENT 'token', + `group_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '组状态 0、未启用 1、启用', + `version` int(11) NOT NULL COMMENT '版本号', + `group_partition` int(11) NOT NULL COMMENT '分区', + `id_generator_mode` tinyint(4) NOT NULL DEFAULT 1 COMMENT '唯一id生成模式 默认号段模式', + `init_scene` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否初始化场景 0:否 1:是', + `bucket_index` int(11) NOT NULL DEFAULT 0 COMMENT 'bucket', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='组配置' +; + +CREATE TABLE `sj_notify_config` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `business_id` varchar(64) NOT NULL COMMENT '业务id (job_id或workflow_id或scene_name)', + `system_task_type` tinyint(4) NOT NULL DEFAULT 3 COMMENT '任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务', + `notify_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知状态 0、未启用 1、启用', + `recipient_ids` varchar(128) NOT NULL COMMENT '接收人id列表', + `notify_threshold` int(11) NOT NULL DEFAULT 0 COMMENT '通知阈值', + `notify_scene` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知场景', + `rate_limiter_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '限流状态 0、未启用 1、启用', + `rate_limiter_threshold` int(11) NOT NULL DEFAULT 0 COMMENT '每秒限流阈值', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `business_id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='通知配置' +; + +CREATE TABLE `sj_notify_recipient` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `recipient_name` varchar(64) NOT NULL COMMENT '接收人名称', + `notify_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook', + `notify_attribute` varchar(512) NOT NULL COMMENT '配置属性', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id` (`namespace_id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='告警通知接收人' +; + + +CREATE TABLE `sj_retry_dead_letter_0` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `scene_name` varchar(64) NOT NULL COMMENT '场景名称', + `idempotent_id` varchar(64) NOT NULL COMMENT '幂等id', + `biz_no` varchar(64) NOT NULL DEFAULT '' COMMENT '业务编号', + `executor_name` varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', + `args_str` text NOT NULL COMMENT '执行方法参数', + `ext_attrs` text NOT NULL COMMENT '扩展字段', + `task_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '任务类型 1、重试数据 2、回调数据', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `scene_name`), + KEY `idx_idempotent_id` (`idempotent_id`), + KEY `idx_biz_no` (`biz_no`), + KEY `idx_create_dt` (`create_dt`), + UNIQUE KEY `uk_namespace_id_group_name_unique_id` (`namespace_id`, `group_name`, `unique_id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='死信队列表' +; + +CREATE TABLE `sj_retry_task_0` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `scene_name` varchar(64) NOT NULL COMMENT '场景名称', + `idempotent_id` varchar(64) NOT NULL COMMENT '幂等id', + `biz_no` varchar(64) NOT NULL DEFAULT '' COMMENT '业务编号', + `executor_name` varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', + `args_str` text NOT NULL COMMENT '执行方法参数', + `ext_attrs` text NOT NULL COMMENT '扩展字段', + `next_trigger_at` datetime NOT NULL COMMENT '下次触发时间', + `retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '重试次数', + `retry_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '重试状态 0、重试中 1、成功 2、最大重试次数', + `task_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '任务类型 1、重试数据 2、回调数据', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `scene_name`), + KEY `idx_namespace_id_group_name_task_type` (`namespace_id`, `group_name`, `task_type`), + KEY `idx_namespace_id_group_name_retry_status` (`namespace_id`, `group_name`, `retry_status`), + KEY `idx_idempotent_id` (`idempotent_id`), + KEY `idx_biz_no` (`biz_no`), + KEY `idx_create_dt` (`create_dt`), + UNIQUE KEY `uk_name_unique_id` (`namespace_id`, `group_name`, `unique_id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务表' +; + +CREATE TABLE `sj_retry_task_log` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `scene_name` varchar(64) NOT NULL COMMENT '场景名称', + `idempotent_id` varchar(64) NOT NULL COMMENT '幂等id', + `biz_no` varchar(64) NOT NULL DEFAULT '' COMMENT '业务编号', + `executor_name` varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', + `args_str` text NOT NULL COMMENT '执行方法参数', + `ext_attrs` text NOT NULL COMMENT '扩展字段', + `retry_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '重试状态 0、重试中 1、成功 2、最大次数', + `task_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '任务类型 1、重试数据 2、回调数据', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_group_name_scene_name` (`namespace_id`, `group_name`, `scene_name`), + KEY `idx_retry_status` (`retry_status`), + KEY `idx_idempotent_id` (`idempotent_id`), + KEY `idx_unique_id` (`unique_id`), + KEY `idx_biz_no` (`biz_no`), + KEY `idx_create_dt` (`create_dt`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务日志基础信息表' +; + +CREATE TABLE `sj_retry_task_log_message` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一', + `message` longtext NOT NULL COMMENT '异常信息', + `log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量', + `real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `unique_id`), + KEY `idx_create_dt` (`create_dt`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务调度日志信息记录表' +; + +CREATE TABLE `sj_retry_scene_config` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `scene_name` varchar(64) NOT NULL COMMENT '场景名称', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `scene_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '组状态 0、未启用 1、启用', + `max_retry_count` int(11) NOT NULL DEFAULT 5 COMMENT '最大重试次数', + `back_off` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1、默认等级 2、固定间隔时间 3、CRON 表达式', + `trigger_interval` varchar(16) NOT NULL DEFAULT '' COMMENT '间隔时长', + `deadline_request` bigint(20) unsigned NOT NULL DEFAULT 60000 COMMENT 'Deadline Request 调用链超时 单位毫秒', + `executor_timeout` int(11) unsigned NOT NULL DEFAULT 5 COMMENT '任务执行超时时间,单位秒', + `route_key` tinyint(4) NOT NULL DEFAULT 4 COMMENT '路由策略', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `scene_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='场景配置' +; + +CREATE TABLE `sj_server_node` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `host_id` varchar(64) NOT NULL COMMENT '主机id', + `host_ip` varchar(64) NOT NULL COMMENT '机器ip', + `host_port` int(16) NOT NULL COMMENT '机器端口', + `expire_at` datetime NOT NULL COMMENT '过期时间', + `node_type` tinyint(4) NOT NULL COMMENT '节点类型 1、客户端 2、是服务端', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`), + KEY `idx_expire_at_node_type` (`expire_at`, `node_type`), + UNIQUE KEY `uk_host_id_host_ip` (`host_id`, `host_ip`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='服务器节点' +; + +CREATE TABLE `sj_distributed_lock` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(64) NOT NULL COMMENT '锁名称', + `lock_until` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '锁定时长', + `locked_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '锁定时间', + `locked_by` varchar(255) NOT NULL COMMENT '锁定者', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_name` (`name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='锁定表' +; + +CREATE TABLE `sj_system_user` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `username` varchar(64) NOT NULL COMMENT '账号', + `password` varchar(128) NOT NULL COMMENT '密码', + `role` tinyint(4) NOT NULL DEFAULT 0 COMMENT '角色:1-普通用户、2-管理员', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_username` (`username`) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='系统用户表'; + +-- pwd: admin +INSERT INTO `sj_system_user` (username, password, role) +VALUES ('admin', '465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2); + +CREATE TABLE `sj_system_user_permission` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `system_user_id` bigint(20) NOT NULL COMMENT '系统用户id', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_namespace_id_group_name_system_user_id` (`namespace_id`, `group_name`, `system_user_id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='系统用户权限表'; + +CREATE TABLE `sj_sequence_alloc` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL DEFAULT '' COMMENT '组名称', + `max_id` bigint(20) NOT NULL DEFAULT 1 COMMENT '最大id', + `step` int(11) NOT NULL DEFAULT 100 COMMENT '步长', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='号段模式序号ID分配表'; + +-- 分布式调度DDL +CREATE TABLE `sj_job` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `job_name` varchar(64) NOT NULL COMMENT '名称', + `args_str` text DEFAULT NULL COMMENT '执行方法参数', + `args_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '参数类型 ', + `next_trigger_at` bigint(13) NOT NULL COMMENT '下次触发时间', + `job_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '任务状态 0、关闭、1、开启', + `task_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '任务类型 1、集群 2、广播 3、切片', + `route_key` tinyint(4) NOT NULL DEFAULT 4 COMMENT '路由策略', + `executor_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '执行器类型', + `executor_info` varchar(255) DEFAULT NULL COMMENT '执行器名称', + `trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间', + `trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长', + `block_strategy` tinyint(4) NOT NULL DEFAULT 1 COMMENT '阻塞策略 1、丢弃 2、覆盖 3、并行', + `executor_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '任务执行超时时间,单位秒', + `max_retry_times` int(11) NOT NULL DEFAULT 0 COMMENT '最大重试次数', + `parallel_num` int(11) NOT NULL DEFAULT 1 COMMENT '并行数', + `retry_interval` int(11) NOT NULL DEFAULT 0 COMMENT '重试间隔(s)', + `bucket_index` int(11) NOT NULL DEFAULT 0 COMMENT 'bucket', + `resident` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否是常驻任务', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`), + KEY `idx_job_status_bucket_index` (`job_status`, `bucket_index`), + KEY `idx_create_dt` (`create_dt`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务信息'; + +CREATE TABLE `sj_job_log_message` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `job_id` bigint(20) NOT NULL COMMENT '任务信息id', + `task_batch_id` bigint(20) NOT NULL COMMENT '任务批次id', + `task_id` bigint(20) NOT NULL COMMENT '调度任务id', + `message` longtext NOT NULL COMMENT '调度信息', + `log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量', + `real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_task_batch_id_task_id` (`task_batch_id`, `task_id`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='调度日志'; + +CREATE TABLE `sj_job_task` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `job_id` bigint(20) NOT NULL COMMENT '任务信息id', + `task_batch_id` bigint(20) NOT NULL COMMENT '调度任务id', + `parent_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '父执行器id', + `task_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '执行的状态 0、失败 1、成功', + `retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '重试次数', + `client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port', + `result_message` text NOT NULL COMMENT '执行结果', + `args_str` text DEFAULT NULL COMMENT '执行方法参数', + `args_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '参数类型 ', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_task_batch_id_task_status` (`task_batch_id`, `task_status`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务实例'; + +CREATE TABLE `sj_job_task_batch` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `job_id` bigint(20) NOT NULL COMMENT '任务id', + `workflow_node_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '工作流节点id', + `parent_workflow_node_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '工作流任务父批次id', + `workflow_task_batch_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '工作流任务批次id', + `task_batch_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '任务批次状态 0、失败 1、成功', + `operation_reason` tinyint(4) NOT NULL DEFAULT 0 COMMENT '操作原因', + `execution_at` bigint(13) NOT NULL DEFAULT 0 COMMENT '任务执行时间', + `system_task_type` tinyint(4) NOT NULL DEFAULT 3 COMMENT '任务类型 3、JOB任务 4、WORKFLOW任务', + `parent_id` varchar(64) NOT NULL DEFAULT '' COMMENT '父节点', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_job_id_task_batch_status` (`job_id`, `task_batch_status`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`), + KEY `idx_workflow_task_batch_id_workflow_node_id` (`workflow_task_batch_id`, `workflow_node_id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='任务批次'; + +CREATE TABLE `sj_job_summary` +( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称', + `business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)', + `system_task_type` tinyint(4) NOT NULL DEFAULT 3 COMMENT '任务类型 3、JOB任务 4、WORKFLOW任务', + `trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间', + `success_num` int NOT NULL DEFAULT 0 COMMENT '执行成功-日志数量', + `fail_num` int NOT NULL DEFAULT 0 COMMENT '执行失败-日志数量', + `fail_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', + `stop_num` int NOT NULL DEFAULT 0 COMMENT '执行失败-日志数量', + `stop_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', + `cancel_num` int NOT NULL DEFAULT 0 COMMENT '执行失败-日志数量', + `cancel_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_namespace_id_group_name_business_id` (`namespace_id`, `group_name`, business_id), + UNIQUE KEY `uk_trigger_at_system_task_type_business_id` (`trigger_at`, `system_task_type`, `business_id`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 1 + DEFAULT CHARSET = utf8mb4 COMMENT ='DashBoard_Job'; + +CREATE TABLE `sj_retry_summary` +( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称', + `scene_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '场景名称', + `trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间', + `running_num` int NOT NULL DEFAULT 0 COMMENT '重试中-日志数量', + `finish_num` int NOT NULL DEFAULT 0 COMMENT '重试完成-日志数量', + `max_count_num` int NOT NULL DEFAULT 0 COMMENT '重试到达最大次数-日志数量', + `suspend_num` int NOT NULL DEFAULT 0 COMMENT '暂停重试-日志数量', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_trigger_at` (`trigger_at`), + UNIQUE KEY `uk_scene_name_trigger_at` (`namespace_id`, `group_name`, `scene_name`, `trigger_at`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 1 + DEFAULT CHARSET = utf8mb4 COMMENT ='DashBoard_Retry'; + +CREATE TABLE `sj_workflow` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `workflow_name` varchar(64) NOT NULL COMMENT '工作流名称', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `workflow_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '工作流状态 0、关闭、1、开启', + `trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间', + `trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长', + `next_trigger_at` bigint(13) NOT NULL COMMENT '下次触发时间', + `block_strategy` tinyint(4) NOT NULL DEFAULT 1 COMMENT '阻塞策略 1、丢弃 2、覆盖 3、并行', + `executor_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '任务执行超时时间,单位秒', + `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述', + `flow_info` text DEFAULT NULL COMMENT '流程信息', + `bucket_index` int(11) NOT NULL DEFAULT 0 COMMENT 'bucket', + `version` int(11) NOT NULL COMMENT '版本号', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='工作流'; + +CREATE TABLE `sj_workflow_node` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `node_name` varchar(64) NOT NULL COMMENT '节点名称', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `job_id` bigint(20) NOT NULL COMMENT '任务信息id', + `workflow_id` bigint(20) NOT NULL COMMENT '工作流ID', + `node_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1、任务节点 2、条件节点', + `expression_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1、SpEl、2、Aviator 3、QL', + `fail_strategy` tinyint(4) NOT NULL DEFAULT 1 COMMENT '失败策略 1、跳过 2、阻塞', + `workflow_node_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '工作流节点状态 0、关闭、1、开启', + `priority_level` int(11) NOT NULL DEFAULT 1 COMMENT '优先级', + `node_info` text DEFAULT NULL COMMENT '节点信息 ', + `version` int(11) NOT NULL COMMENT '版本号', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='工作流节点'; + +CREATE TABLE `sj_workflow_task_batch` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', + `group_name` varchar(64) NOT NULL COMMENT '组名称', + `workflow_id` bigint(20) NOT NULL COMMENT '工作流任务id', + `task_batch_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '任务批次状态 0、失败 1、成功', + `operation_reason` tinyint(4) NOT NULL DEFAULT 0 COMMENT '操作原因', + `flow_info` text DEFAULT NULL COMMENT '流程信息', + `execution_at` bigint(13) NOT NULL DEFAULT 0 COMMENT '任务执行时间', + `ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段', + `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除', + `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + KEY `idx_job_id_task_batch_status` (`workflow_id`, `task_batch_status`), + KEY `idx_create_dt` (`create_dt`), + KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 0 + DEFAULT CHARSET = utf8mb4 COMMENT ='工作流批次'; diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql new file mode 100644 index 00000000..1a89e65e --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql @@ -0,0 +1,890 @@ +/* + SnailJob Database Transfer Tool + Source Server Type : MySQL + Target Server Type : Oracle + Date: 2024-05-20 22:01:56 +*/ + + +-- sj_namespace +CREATE TABLE sj_namespace +( + id number GENERATED ALWAYS AS IDENTITY, + name varchar2(64) NULL, + unique_id varchar2(64) NULL, + description varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_namespace + ADD CONSTRAINT pk_sj_namespace PRIMARY KEY (id); + +CREATE INDEX idx_sj_namespace_01 ON sj_namespace (name); + +COMMENT ON COLUMN sj_namespace.id IS '主键'; +COMMENT ON COLUMN sj_namespace.name IS '名称'; +COMMENT ON COLUMN sj_namespace.unique_id IS '唯一id'; +COMMENT ON COLUMN sj_namespace.description IS '描述'; +COMMENT ON COLUMN sj_namespace.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_namespace.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_namespace.update_dt IS '修改时间'; +COMMENT ON TABLE sj_namespace IS '命名空间'; + +INSERT INTO sj_namespace (name, unique_id, create_dt, update_dt, deleted) +VALUES ('Default', '764d604ec6fc45f68cd92514c40e9e1a', sysdate, sysdate, 0); + +-- sj_group_config +CREATE TABLE sj_group_config +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) DEFAULT '' NULL, + description varchar2(256) DEFAULT '' NULL, + token varchar2(64) DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT' NULL, + group_status smallint DEFAULT 0 NOT NULL, + version number NOT NULL, + group_partition number NOT NULL, + id_generator_mode smallint DEFAULT 1 NOT NULL, + init_scene smallint DEFAULT 0 NOT NULL, + bucket_index number DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_group_config + ADD CONSTRAINT pk_sj_group_config PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_group_config_01 ON sj_group_config (namespace_id, group_name); + +COMMENT ON COLUMN sj_group_config.id IS '主键'; +COMMENT ON COLUMN sj_group_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_group_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_group_config.description IS '组描述'; +COMMENT ON COLUMN sj_group_config.token IS 'token'; +COMMENT ON COLUMN sj_group_config.group_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_group_config.version IS '版本号'; +COMMENT ON COLUMN sj_group_config.group_partition IS '分区'; +COMMENT ON COLUMN sj_group_config.id_generator_mode IS '唯一id生成模式 默认号段模式'; +COMMENT ON COLUMN sj_group_config.init_scene IS '是否初始化场景 0:否 1:是'; +COMMENT ON COLUMN sj_group_config.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_group_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_group_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_group_config IS '组配置'; + +-- sj_notify_config +CREATE TABLE sj_notify_config +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + business_id varchar2(64) NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + notify_status smallint DEFAULT 0 NOT NULL, + recipient_ids varchar2(128) NULL, + notify_threshold number DEFAULT 0 NOT NULL, + notify_scene smallint DEFAULT 0 NOT NULL, + rate_limiter_status smallint DEFAULT 0 NOT NULL, + rate_limiter_threshold number DEFAULT 0 NOT NULL, + description varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_notify_config + ADD CONSTRAINT pk_sj_notify_config PRIMARY KEY (id); + +CREATE INDEX idx_sj_notify_config_01 ON sj_notify_config (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_notify_config.id IS '主键'; +COMMENT ON COLUMN sj_notify_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_notify_config.business_id IS '业务id ( job_id或workflow_id或scene_name ) '; +COMMENT ON COLUMN sj_notify_config.system_task_type IS '任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_notify_config.notify_status IS '通知状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.recipient_ids IS '接收人id列表'; +COMMENT ON COLUMN sj_notify_config.notify_threshold IS '通知阈值'; +COMMENT ON COLUMN sj_notify_config.notify_scene IS '通知场景'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_status IS '限流状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_threshold IS '每秒限流阈值'; +COMMENT ON COLUMN sj_notify_config.description IS '描述'; +COMMENT ON COLUMN sj_notify_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_config IS '通知配置'; + +-- sj_notify_recipient +CREATE TABLE sj_notify_recipient +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + recipient_name varchar2(64) NULL, + notify_type smallint DEFAULT 0 NOT NULL, + notify_attribute varchar2(512) NULL, + description varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_notify_recipient + ADD CONSTRAINT pk_sj_notify_recipient PRIMARY KEY (id); + +CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id); + +COMMENT ON COLUMN sj_notify_recipient.id IS '主键'; +COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称'; +COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook'; +COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性'; +COMMENT ON COLUMN sj_notify_recipient.description IS '描述'; +COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_recipient.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_recipient IS '告警通知接收人'; + +-- sj_retry_dead_letter_0 +CREATE TABLE sj_retry_dead_letter_0 +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar2(64) NULL, + group_name varchar2(64) NULL, + scene_name varchar2(64) NULL, + idempotent_id varchar2(64) NULL, + biz_no varchar2(64) DEFAULT '' NULL, + executor_name varchar2(512) DEFAULT '' NULL, + args_str clob NULL, + ext_attrs clob NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_dead_letter_0 + ADD CONSTRAINT pk_sj_retry_dead_letter_0 PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_dead_letter_0_02 ON sj_retry_dead_letter_0 (idempotent_id); +CREATE INDEX idx_sj_retry_dead_letter_0_03 ON sj_retry_dead_letter_0 (biz_no); +CREATE INDEX idx_sj_retry_dead_letter_0_04 ON sj_retry_dead_letter_0 (create_dt); + +COMMENT ON COLUMN sj_retry_dead_letter_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_dead_letter_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_dead_letter_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_dead_letter_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_dead_letter_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_dead_letter_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_dead_letter_0.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_dead_letter_0 IS '死信队列表'; + +-- sj_retry_task_0 +CREATE TABLE sj_retry_task_0 +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar2(64) NULL, + group_name varchar2(64) NULL, + scene_name varchar2(64) NULL, + idempotent_id varchar2(64) NULL, + biz_no varchar2(64) DEFAULT '' NULL, + executor_name varchar2(512) DEFAULT '' NULL, + args_str clob NULL, + ext_attrs clob NULL, + next_trigger_at date NOT NULL, + retry_count number DEFAULT 0 NOT NULL, + retry_status smallint DEFAULT 0 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_task_0 + ADD CONSTRAINT pk_sj_retry_task_0 PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_0_02 ON sj_retry_task_0 (namespace_id, group_name, task_type); +CREATE INDEX idx_sj_retry_task_0_03 ON sj_retry_task_0 (namespace_id, group_name, retry_status); +CREATE INDEX idx_sj_retry_task_0_04 ON sj_retry_task_0 (idempotent_id); +CREATE INDEX idx_sj_retry_task_0_05 ON sj_retry_task_0 (biz_no); +CREATE INDEX idx_sj_retry_task_0_06 ON sj_retry_task_0 (create_dt); + +COMMENT ON COLUMN sj_retry_task_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_0.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_retry_task_0.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_retry_task_0.retry_status IS '重试状态 0、重试中 1、成功 2、最大重试次数'; +COMMENT ON COLUMN sj_retry_task_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_0.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_0.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_0 IS '任务表'; + +-- sj_retry_task_log +CREATE TABLE sj_retry_task_log +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + unique_id varchar2(64) NULL, + group_name varchar2(64) NULL, + scene_name varchar2(64) NULL, + idempotent_id varchar2(64) NULL, + biz_no varchar2(64) DEFAULT '' NULL, + executor_name varchar2(512) DEFAULT '' NULL, + args_str clob NULL, + ext_attrs clob NULL, + retry_status smallint DEFAULT 0 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_task_log + ADD CONSTRAINT pk_sj_retry_task_log PRIMARY KEY (id); + +CREATE INDEX idx_sj_retry_task_log_01 ON sj_retry_task_log (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_log_02 ON sj_retry_task_log (retry_status); +CREATE INDEX idx_sj_retry_task_log_03 ON sj_retry_task_log (idempotent_id); +CREATE INDEX idx_sj_retry_task_log_04 ON sj_retry_task_log (unique_id); +CREATE INDEX idx_sj_retry_task_log_05 ON sj_retry_task_log (biz_no); +CREATE INDEX idx_sj_retry_task_log_06 ON sj_retry_task_log (create_dt); + +COMMENT ON COLUMN sj_retry_task_log.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_log.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_log.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_log.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_log.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_log.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_log.retry_status IS '重试状态 0、重试中 1、成功 2、最大次数'; +COMMENT ON COLUMN sj_retry_task_log.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_log.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_log.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_log IS '任务日志基础信息表'; + +-- sj_retry_task_log_message +CREATE TABLE sj_retry_task_log_message +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + unique_id varchar2(64) NULL, + message clob NULL, + log_num number DEFAULT 1 NOT NULL, + real_time number DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_task_log_message + ADD CONSTRAINT pk_sj_retry_task_log_message PRIMARY KEY (id); + +CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id); +CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt); + +COMMENT ON COLUMN sj_retry_task_log_message.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log_message.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log_message.message IS '异常信息'; +COMMENT ON COLUMN sj_retry_task_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_retry_task_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_retry_task_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_task_log_message IS '任务调度日志信息记录表'; + +-- sj_retry_scene_config +CREATE TABLE sj_retry_scene_config +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + scene_name varchar2(64) NULL, + group_name varchar2(64) NULL, + scene_status smallint DEFAULT 0 NOT NULL, + max_retry_count number DEFAULT 5 NOT NULL, + back_off smallint DEFAULT 1 NOT NULL, + trigger_interval varchar2(16) DEFAULT '' NULL, + deadline_request number DEFAULT 60000 NOT NULL, + executor_timeout number DEFAULT 5 NOT NULL, + route_key smallint DEFAULT 4 NOT NULL, + description varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_scene_config + ADD CONSTRAINT pk_sj_retry_scene_config PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_retry_scene_config_01 ON sj_retry_scene_config (namespace_id, group_name, scene_name); + +COMMENT ON COLUMN sj_retry_scene_config.id IS '主键'; +COMMENT ON COLUMN sj_retry_scene_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_scene_config.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_scene_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_scene_config.scene_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_retry_scene_config.max_retry_count IS '最大重试次数'; +COMMENT ON COLUMN sj_retry_scene_config.back_off IS '1、默认等级 2、固定间隔时间 3、CRON 表达式'; +COMMENT ON COLUMN sj_retry_scene_config.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_retry_scene_config.deadline_request IS 'Deadline Request 调用链超时 单位毫秒'; +COMMENT ON COLUMN sj_retry_scene_config.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_retry_scene_config.route_key IS '路由策略'; +COMMENT ON COLUMN sj_retry_scene_config.description IS '描述'; +COMMENT ON COLUMN sj_retry_scene_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_scene_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_scene_config IS '场景配置'; + +-- sj_server_node +CREATE TABLE sj_server_node +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + host_id varchar2(64) NULL, + host_ip varchar2(64) NULL, + host_port number NOT NULL, + expire_at date NOT NULL, + node_type smallint NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_server_node + ADD CONSTRAINT pk_sj_server_node PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_server_node_01 ON sj_server_node (host_id, host_ip); + +CREATE INDEX idx_sj_server_node_01 ON sj_server_node (namespace_id, group_name); +CREATE INDEX idx_sj_server_node_02 ON sj_server_node (expire_at, node_type); + +COMMENT ON COLUMN sj_server_node.id IS '主键'; +COMMENT ON COLUMN sj_server_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_server_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_server_node.host_id IS '主机id'; +COMMENT ON COLUMN sj_server_node.host_ip IS '机器ip'; +COMMENT ON COLUMN sj_server_node.host_port IS '机器端口'; +COMMENT ON COLUMN sj_server_node.expire_at IS '过期时间'; +COMMENT ON COLUMN sj_server_node.node_type IS '节点类型 1、客户端 2、是服务端'; +COMMENT ON COLUMN sj_server_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_server_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_server_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_server_node IS '服务器节点'; + +-- sj_distributed_lock +CREATE TABLE sj_distributed_lock +( + id number GENERATED ALWAYS AS IDENTITY, + name varchar2(64) NULL, + lock_until timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL, + locked_at timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL, + locked_by varchar2(255) NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_distributed_lock + ADD CONSTRAINT pk_sj_distributed_lock PRIMARY KEY (id); + +COMMENT ON COLUMN sj_distributed_lock.id IS '主键'; +COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称'; +COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长'; +COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间'; +COMMENT ON COLUMN sj_distributed_lock.locked_by IS '锁定者'; +COMMENT ON COLUMN sj_distributed_lock.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_distributed_lock.update_dt IS '修改时间'; +COMMENT ON TABLE sj_distributed_lock IS '锁定表'; + +-- sj_system_user +CREATE TABLE sj_system_user +( + id number GENERATED ALWAYS AS IDENTITY, + username varchar2(64) NULL, + password varchar2(128) NULL, + role smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_system_user + ADD CONSTRAINT pk_sj_system_user PRIMARY KEY (id); + +COMMENT ON COLUMN sj_system_user.id IS '主键'; +COMMENT ON COLUMN sj_system_user.username IS '账号'; +COMMENT ON COLUMN sj_system_user.password IS '密码'; +COMMENT ON COLUMN sj_system_user.role IS '角色:1-普通用户、2-管理员'; +COMMENT ON COLUMN sj_system_user.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user IS '系统用户表'; + +INSERT INTO sj_system_user (username, password, role) +VALUES ('admin', '465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2); + +-- sj_system_user_permission +CREATE TABLE sj_system_user_permission +( + id number GENERATED ALWAYS AS IDENTITY, + group_name varchar2(64) NULL, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + system_user_id number NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_system_user_permission + ADD CONSTRAINT pk_sj_system_user_permission PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id); + +COMMENT ON COLUMN sj_system_user_permission.id IS '主键'; +COMMENT ON COLUMN sj_system_user_permission.group_name IS '组名称'; +COMMENT ON COLUMN sj_system_user_permission.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_system_user_permission.system_user_id IS '系统用户id'; +COMMENT ON COLUMN sj_system_user_permission.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user_permission.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user_permission IS '系统用户权限表'; + +-- sj_sequence_alloc +CREATE TABLE sj_sequence_alloc +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) DEFAULT '' NULL, + max_id number DEFAULT 1 NOT NULL, + step number DEFAULT 100 NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_sequence_alloc + ADD CONSTRAINT pk_sj_sequence_alloc PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_sequence_alloc_01 ON sj_sequence_alloc (namespace_id, group_name); + +COMMENT ON COLUMN sj_sequence_alloc.id IS '主键'; +COMMENT ON COLUMN sj_sequence_alloc.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_sequence_alloc.group_name IS '组名称'; +COMMENT ON COLUMN sj_sequence_alloc.max_id IS '最大id'; +COMMENT ON COLUMN sj_sequence_alloc.step IS '步长'; +COMMENT ON COLUMN sj_sequence_alloc.update_dt IS '更新时间'; +COMMENT ON TABLE sj_sequence_alloc IS '号段模式序号ID分配表'; + +-- sj_job +CREATE TABLE sj_job +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + job_name varchar2(64) NULL, + args_str clob DEFAULT NULL NULL, + args_type smallint DEFAULT 1 NOT NULL, + next_trigger_at number NOT NULL, + job_status smallint DEFAULT 1 NOT NULL, + task_type smallint DEFAULT 1 NOT NULL, + route_key smallint DEFAULT 4 NOT NULL, + executor_type smallint DEFAULT 1 NOT NULL, + executor_info varchar2(255) DEFAULT NULL NULL, + trigger_type smallint NOT NULL, + trigger_interval varchar2(255) NULL, + block_strategy smallint DEFAULT 1 NOT NULL, + executor_timeout number DEFAULT 0 NOT NULL, + max_retry_times number DEFAULT 0 NOT NULL, + parallel_num number DEFAULT 1 NOT NULL, + retry_interval number DEFAULT 0 NOT NULL, + bucket_index number DEFAULT 0 NOT NULL, + resident smallint DEFAULT 0 NOT NULL, + description varchar2(256) DEFAULT '' NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_job + ADD CONSTRAINT pk_sj_job PRIMARY KEY (id); + +CREATE INDEX idx_sj_job_01 ON sj_job (namespace_id, group_name); +CREATE INDEX idx_sj_job_02 ON sj_job (job_status, bucket_index); +CREATE INDEX idx_sj_job_03 ON sj_job (create_dt); + +COMMENT ON COLUMN sj_job.id IS '主键'; +COMMENT ON COLUMN sj_job.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job.group_name IS '组名称'; +COMMENT ON COLUMN sj_job.job_name IS '名称'; +COMMENT ON COLUMN sj_job.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_job.job_status IS '任务状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_job.task_type IS '任务类型 1、集群 2、广播 3、切片'; +COMMENT ON COLUMN sj_job.route_key IS '路由策略'; +COMMENT ON COLUMN sj_job.executor_type IS '执行器类型'; +COMMENT ON COLUMN sj_job.executor_info IS '执行器名称'; +COMMENT ON COLUMN sj_job.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_job.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_job.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_job.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_job.max_retry_times IS '最大重试次数'; +COMMENT ON COLUMN sj_job.parallel_num IS '并行数'; +COMMENT ON COLUMN sj_job.retry_interval IS '重试间隔 ( s ) '; +COMMENT ON COLUMN sj_job.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_job.resident IS '是否是常驻任务'; +COMMENT ON COLUMN sj_job.description IS '描述'; +COMMENT ON COLUMN sj_job.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job IS '任务信息'; + +-- sj_job_log_message +CREATE TABLE sj_job_log_message +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + job_id number NOT NULL, + task_batch_id number NOT NULL, + task_id number NOT NULL, + message clob NULL, + log_num number DEFAULT 1 NOT NULL, + real_time number DEFAULT 0 NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_job_log_message + ADD CONSTRAINT pk_sj_job_log_message PRIMARY KEY (id); + +CREATE INDEX idx_sj_job_log_message_01 ON sj_job_log_message (task_batch_id, task_id); +CREATE INDEX idx_sj_job_log_message_02 ON sj_job_log_message (create_dt); +CREATE INDEX idx_sj_job_log_message_03 ON sj_job_log_message (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_log_message.id IS '主键'; +COMMENT ON COLUMN sj_job_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_log_message.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_log_message.task_batch_id IS '任务批次id'; +COMMENT ON COLUMN sj_job_log_message.task_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_log_message.message IS '调度信息'; +COMMENT ON COLUMN sj_job_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_job_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_job_log_message.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_job_log_message IS '调度日志'; + +-- sj_job_task +CREATE TABLE sj_job_task +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + job_id number NOT NULL, + task_batch_id number NOT NULL, + parent_id number DEFAULT 0 NOT NULL, + task_status smallint DEFAULT 0 NOT NULL, + retry_count number DEFAULT 0 NOT NULL, + client_info varchar2(128) DEFAULT NULL NULL, + result_message clob NULL, + args_str clob DEFAULT NULL NULL, + args_type smallint DEFAULT 1 NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_job_task + ADD CONSTRAINT pk_sj_job_task PRIMARY KEY (id); + +CREATE INDEX idx_sj_job_task_01 ON sj_job_task (task_batch_id, task_status); +CREATE INDEX idx_sj_job_task_02 ON sj_job_task (create_dt); +CREATE INDEX idx_sj_job_task_03 ON sj_job_task (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_task.id IS '主键'; +COMMENT ON COLUMN sj_job_task.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id'; +COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port'; +COMMENT ON COLUMN sj_job_task.result_message IS '执行结果'; +COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job_task.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task IS '任务实例'; + +-- sj_job_task_batch +CREATE TABLE sj_job_task_batch +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + job_id number NOT NULL, + workflow_node_id number DEFAULT 0 NOT NULL, + parent_workflow_node_id number DEFAULT 0 NOT NULL, + workflow_task_batch_id number DEFAULT 0 NOT NULL, + task_batch_status smallint DEFAULT 0 NOT NULL, + operation_reason smallint DEFAULT 0 NOT NULL, + execution_at number DEFAULT 0 NOT NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + parent_id varchar2(64) DEFAULT '' NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_job_task_batch + ADD CONSTRAINT pk_sj_job_task_batch PRIMARY KEY (id); + +CREATE INDEX idx_sj_job_task_batch_01 ON sj_job_task_batch (job_id, task_batch_status); +CREATE INDEX idx_sj_job_task_batch_02 ON sj_job_task_batch (create_dt); +CREATE INDEX idx_sj_job_task_batch_03 ON sj_job_task_batch (namespace_id, group_name); +CREATE INDEX idx_sj_job_task_batch_04 ON sj_job_task_batch (workflow_task_batch_id, workflow_node_id); + +COMMENT ON COLUMN sj_job_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_job_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task_batch.job_id IS '任务id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_node_id IS '工作流节点id'; +COMMENT ON COLUMN sj_job_task_batch.parent_workflow_node_id IS '工作流任务父批次id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_task_batch_id IS '工作流任务批次id'; +COMMENT ON COLUMN sj_job_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_job_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_job_task_batch.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_task_batch.parent_id IS '父节点'; +COMMENT ON COLUMN sj_job_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task_batch IS '任务批次'; + +-- sj_job_summary +CREATE TABLE sj_job_summary +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) DEFAULT '' NULL, + business_id number NOT NULL, + system_task_type smallint DEFAULT 3 NOT NULL, + trigger_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, + success_num number DEFAULT 0 NOT NULL, + fail_num number DEFAULT 0 NOT NULL, + fail_reason varchar2(512) DEFAULT '' NULL, + stop_num number DEFAULT 0 NOT NULL, + stop_reason varchar2(512) DEFAULT '' NULL, + cancel_num number DEFAULT 0 NOT NULL, + cancel_reason varchar2(512) DEFAULT '' NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_job_summary + ADD CONSTRAINT pk_sj_job_summary PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_job_summary_01 ON sj_job_summary (trigger_at, system_task_type, business_id); + +CREATE INDEX idx_sj_job_summary_01 ON sj_job_summary (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_job_summary.id IS '主键'; +COMMENT ON COLUMN sj_job_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_summary.business_id IS '业务id ( job_id或workflow_id ) '; +COMMENT ON COLUMN sj_job_summary.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_job_summary.success_num IS '执行成功-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.stop_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.stop_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.cancel_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.cancel_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_summary IS 'DashBoard_Job'; + +-- sj_retry_summary +CREATE TABLE sj_retry_summary +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) DEFAULT '' NULL, + scene_name varchar2(50) DEFAULT '' NULL, + trigger_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, + running_num number DEFAULT 0 NOT NULL, + finish_num number DEFAULT 0 NOT NULL, + max_count_num number DEFAULT 0 NOT NULL, + suspend_num number DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_retry_summary + ADD CONSTRAINT pk_sj_retry_summary PRIMARY KEY (id); + +CREATE UNIQUE INDEX uk_sj_retry_summary_01 ON sj_retry_summary (namespace_id, group_name, scene_name, trigger_at); + +CREATE INDEX idx_sj_retry_summary_01 ON sj_retry_summary (trigger_at); + +COMMENT ON COLUMN sj_retry_summary.id IS '主键'; +COMMENT ON COLUMN sj_retry_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_summary.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_retry_summary.running_num IS '重试中-日志数量'; +COMMENT ON COLUMN sj_retry_summary.finish_num IS '重试完成-日志数量'; +COMMENT ON COLUMN sj_retry_summary.max_count_num IS '重试到达最大次数-日志数量'; +COMMENT ON COLUMN sj_retry_summary.suspend_num IS '暂停重试-日志数量'; +COMMENT ON COLUMN sj_retry_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_summary IS 'DashBoard_Retry'; + +-- sj_workflow +CREATE TABLE sj_workflow +( + id number GENERATED ALWAYS AS IDENTITY, + workflow_name varchar2(64) NULL, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + workflow_status smallint DEFAULT 1 NOT NULL, + trigger_type smallint NOT NULL, + trigger_interval varchar2(255) NULL, + next_trigger_at number NOT NULL, + block_strategy smallint DEFAULT 1 NOT NULL, + executor_timeout number DEFAULT 0 NOT NULL, + description varchar2(256) DEFAULT '' NULL, + flow_info clob DEFAULT NULL NULL, + bucket_index number DEFAULT 0 NOT NULL, + version number NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_workflow + ADD CONSTRAINT pk_sj_workflow PRIMARY KEY (id); + +CREATE INDEX idx_sj_workflow_01 ON sj_workflow (create_dt); +CREATE INDEX idx_sj_workflow_02 ON sj_workflow (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow.id IS '主键'; +COMMENT ON COLUMN sj_workflow.workflow_name IS '工作流名称'; +COMMENT ON COLUMN sj_workflow.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow.workflow_status IS '工作流状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_workflow.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_workflow.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_workflow.description IS '描述'; +COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_workflow.version IS '版本号'; +COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow IS '工作流'; + +-- sj_workflow_node +CREATE TABLE sj_workflow_node +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + node_name varchar2(64) NULL, + group_name varchar2(64) NULL, + job_id number NOT NULL, + workflow_id number NOT NULL, + node_type smallint DEFAULT 1 NOT NULL, + expression_type smallint DEFAULT 0 NOT NULL, + fail_strategy smallint DEFAULT 1 NOT NULL, + workflow_node_status smallint DEFAULT 1 NOT NULL, + priority_level number DEFAULT 1 NOT NULL, + node_info clob DEFAULT NULL NULL, + version number NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_workflow_node + ADD CONSTRAINT pk_sj_workflow_node PRIMARY KEY (id); + +CREATE INDEX idx_sj_workflow_node_01 ON sj_workflow_node (create_dt); +CREATE INDEX idx_sj_workflow_node_02 ON sj_workflow_node (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_node.id IS '主键'; +COMMENT ON COLUMN sj_workflow_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_node.node_name IS '节点名称'; +COMMENT ON COLUMN sj_workflow_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_node.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_workflow_node.workflow_id IS '工作流ID'; +COMMENT ON COLUMN sj_workflow_node.node_type IS '1、任务节点 2、条件节点'; +COMMENT ON COLUMN sj_workflow_node.expression_type IS '1、SpEl、2、Aviator 3、QL'; +COMMENT ON COLUMN sj_workflow_node.fail_strategy IS '失败策略 1、跳过 2、阻塞'; +COMMENT ON COLUMN sj_workflow_node.workflow_node_status IS '工作流节点状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow_node.priority_level IS '优先级'; +COMMENT ON COLUMN sj_workflow_node.node_info IS '节点信息 '; +COMMENT ON COLUMN sj_workflow_node.version IS '版本号'; +COMMENT ON COLUMN sj_workflow_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_node.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_node IS '工作流节点'; + +-- sj_workflow_task_batch +CREATE TABLE sj_workflow_task_batch +( + id number GENERATED ALWAYS AS IDENTITY, + namespace_id varchar2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NULL, + group_name varchar2(64) NULL, + workflow_id number NOT NULL, + task_batch_status smallint DEFAULT 0 NOT NULL, + operation_reason smallint DEFAULT 0 NOT NULL, + flow_info clob DEFAULT NULL NULL, + execution_at number DEFAULT 0 NOT NULL, + ext_attrs varchar2(256) DEFAULT '' NULL, + deleted smallint DEFAULT 0 NOT NULL, + create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL, + update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE sj_workflow_task_batch + ADD CONSTRAINT pk_sj_workflow_task_batch PRIMARY KEY (id); + +CREATE INDEX idx_sj_workflow_task_batch_01 ON sj_workflow_task_batch (workflow_id, task_batch_status); +CREATE INDEX idx_sj_workflow_task_batch_02 ON sj_workflow_task_batch (create_dt); +CREATE INDEX idx_sj_workflow_task_batch_03 ON sj_workflow_task_batch (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_workflow_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id'; +COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次'; + diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql new file mode 100644 index 00000000..35cbbba3 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql @@ -0,0 +1,821 @@ +/* + SnailJob Database Transfer Tool + Source Server Type : MySQL + Target Server Type : PostgreSQL + Date: 2024-05-20 22:02:23 +*/ + + +-- sj_namespace +CREATE TABLE sj_namespace +( + id bigserial PRIMARY KEY, + name varchar(64) NOT NULL, + unique_id varchar(64) NOT NULL, + description varchar(256) NOT NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_namespace_01 ON sj_namespace (name); + +COMMENT ON COLUMN sj_namespace.id IS '主键'; +COMMENT ON COLUMN sj_namespace.name IS '名称'; +COMMENT ON COLUMN sj_namespace.unique_id IS '唯一id'; +COMMENT ON COLUMN sj_namespace.description IS '描述'; +COMMENT ON COLUMN sj_namespace.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_namespace.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_namespace.update_dt IS '修改时间'; +COMMENT ON TABLE sj_namespace IS '命名空间'; + +INSERT INTO sj_namespace (id, name, unique_id, create_dt, update_dt, deleted) +VALUES (1, 'Default', '764d604ec6fc45f68cd92514c40e9e1a', now(), now(), 0); + +-- sj_group_config +CREATE TABLE sj_group_config +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL DEFAULT '', + description varchar(256) NOT NULL DEFAULT '', + token varchar(64) NOT NULL DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT', + group_status smallint NOT NULL DEFAULT 0, + version int NOT NULL, + group_partition int NOT NULL, + id_generator_mode smallint NOT NULL DEFAULT 1, + init_scene smallint NOT NULL DEFAULT 0, + bucket_index int NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_group_config_01 ON sj_group_config (namespace_id, group_name); + +COMMENT ON COLUMN sj_group_config.id IS '主键'; +COMMENT ON COLUMN sj_group_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_group_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_group_config.description IS '组描述'; +COMMENT ON COLUMN sj_group_config.token IS 'token'; +COMMENT ON COLUMN sj_group_config.group_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_group_config.version IS '版本号'; +COMMENT ON COLUMN sj_group_config.group_partition IS '分区'; +COMMENT ON COLUMN sj_group_config.id_generator_mode IS '唯一id生成模式 默认号段模式'; +COMMENT ON COLUMN sj_group_config.init_scene IS '是否初始化场景 0:否 1:是'; +COMMENT ON COLUMN sj_group_config.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_group_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_group_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_group_config IS '组配置'; + +-- sj_notify_config +CREATE TABLE sj_notify_config +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + business_id varchar(64) NOT NULL, + system_task_type smallint NOT NULL DEFAULT 3, + notify_status smallint NOT NULL DEFAULT 0, + recipient_ids varchar(128) NOT NULL, + notify_threshold int NOT NULL DEFAULT 0, + notify_scene smallint NOT NULL DEFAULT 0, + rate_limiter_status smallint NOT NULL DEFAULT 0, + rate_limiter_threshold int NOT NULL DEFAULT 0, + description varchar(256) NOT NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_notify_config_01 ON sj_notify_config (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_notify_config.id IS '主键'; +COMMENT ON COLUMN sj_notify_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_notify_config.business_id IS '业务id ( job_id或workflow_id或scene_name ) '; +COMMENT ON COLUMN sj_notify_config.system_task_type IS '任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_notify_config.notify_status IS '通知状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.recipient_ids IS '接收人id列表'; +COMMENT ON COLUMN sj_notify_config.notify_threshold IS '通知阈值'; +COMMENT ON COLUMN sj_notify_config.notify_scene IS '通知场景'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_status IS '限流状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_notify_config.rate_limiter_threshold IS '每秒限流阈值'; +COMMENT ON COLUMN sj_notify_config.description IS '描述'; +COMMENT ON COLUMN sj_notify_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_config IS '通知配置'; + +-- sj_notify_recipient +CREATE TABLE sj_notify_recipient +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + recipient_name varchar(64) NOT NULL, + notify_type smallint NOT NULL DEFAULT 0, + notify_attribute varchar(512) NOT NULL, + description varchar(256) NOT NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id); + +COMMENT ON COLUMN sj_notify_recipient.id IS '主键'; +COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称'; +COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook'; +COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性'; +COMMENT ON COLUMN sj_notify_recipient.description IS '描述'; +COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_notify_recipient.update_dt IS '修改时间'; +COMMENT ON TABLE sj_notify_recipient IS '告警通知接收人'; + +-- sj_retry_dead_letter_0 +CREATE TABLE sj_retry_dead_letter_0 +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id varchar(64) NOT NULL, + group_name varchar(64) NOT NULL, + scene_name varchar(64) NOT NULL, + idempotent_id varchar(64) NOT NULL, + biz_no varchar(64) NOT NULL DEFAULT '', + executor_name varchar(512) NOT NULL DEFAULT '', + args_str text NOT NULL, + ext_attrs text NOT NULL, + task_type smallint NOT NULL DEFAULT 1, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_dead_letter_0_02 ON sj_retry_dead_letter_0 (idempotent_id); +CREATE INDEX idx_sj_retry_dead_letter_0_03 ON sj_retry_dead_letter_0 (biz_no); +CREATE INDEX idx_sj_retry_dead_letter_0_04 ON sj_retry_dead_letter_0 (create_dt); + +COMMENT ON COLUMN sj_retry_dead_letter_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_dead_letter_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_dead_letter_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_dead_letter_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_dead_letter_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_dead_letter_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_dead_letter_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_dead_letter_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_dead_letter_0.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_dead_letter_0 IS '死信队列表'; + +-- sj_retry_task_0 +CREATE TABLE sj_retry_task_0 +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id varchar(64) NOT NULL, + group_name varchar(64) NOT NULL, + scene_name varchar(64) NOT NULL, + idempotent_id varchar(64) NOT NULL, + biz_no varchar(64) NOT NULL DEFAULT '', + executor_name varchar(512) NOT NULL DEFAULT '', + args_str text NOT NULL, + ext_attrs text NOT NULL, + next_trigger_at timestamp NOT NULL, + retry_count int NOT NULL DEFAULT 0, + retry_status smallint NOT NULL DEFAULT 0, + task_type smallint NOT NULL DEFAULT 1, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, unique_id); + +CREATE INDEX idx_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_0_02 ON sj_retry_task_0 (namespace_id, group_name, task_type); +CREATE INDEX idx_sj_retry_task_0_03 ON sj_retry_task_0 (namespace_id, group_name, retry_status); +CREATE INDEX idx_sj_retry_task_0_04 ON sj_retry_task_0 (idempotent_id); +CREATE INDEX idx_sj_retry_task_0_05 ON sj_retry_task_0 (biz_no); +CREATE INDEX idx_sj_retry_task_0_06 ON sj_retry_task_0 (create_dt); + +COMMENT ON COLUMN sj_retry_task_0.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_0.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_0.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_0.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_0.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_0.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_0.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_0.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_0.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_0.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_0.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_retry_task_0.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_retry_task_0.retry_status IS '重试状态 0、重试中 1、成功 2、最大重试次数'; +COMMENT ON COLUMN sj_retry_task_0.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_0.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_0.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_0 IS '任务表'; + +-- sj_retry_task_log +CREATE TABLE sj_retry_task_log +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id varchar(64) NOT NULL, + group_name varchar(64) NOT NULL, + scene_name varchar(64) NOT NULL, + idempotent_id varchar(64) NOT NULL, + biz_no varchar(64) NOT NULL DEFAULT '', + executor_name varchar(512) NOT NULL DEFAULT '', + args_str text NOT NULL, + ext_attrs text NOT NULL, + retry_status smallint NOT NULL DEFAULT 0, + task_type smallint NOT NULL DEFAULT 1, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_retry_task_log_01 ON sj_retry_task_log (namespace_id, group_name, scene_name); +CREATE INDEX idx_sj_retry_task_log_02 ON sj_retry_task_log (retry_status); +CREATE INDEX idx_sj_retry_task_log_03 ON sj_retry_task_log (idempotent_id); +CREATE INDEX idx_sj_retry_task_log_04 ON sj_retry_task_log (unique_id); +CREATE INDEX idx_sj_retry_task_log_05 ON sj_retry_task_log (biz_no); +CREATE INDEX idx_sj_retry_task_log_06 ON sj_retry_task_log (create_dt); + +COMMENT ON COLUMN sj_retry_task_log.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_task_log.idempotent_id IS '幂等id'; +COMMENT ON COLUMN sj_retry_task_log.biz_no IS '业务编号'; +COMMENT ON COLUMN sj_retry_task_log.executor_name IS '执行器名称'; +COMMENT ON COLUMN sj_retry_task_log.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_retry_task_log.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_retry_task_log.retry_status IS '重试状态 0、重试中 1、成功 2、最大次数'; +COMMENT ON COLUMN sj_retry_task_log.task_type IS '任务类型 1、重试数据 2、回调数据'; +COMMENT ON COLUMN sj_retry_task_log.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_task_log.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_task_log IS '任务日志基础信息表'; + +-- sj_retry_task_log_message +CREATE TABLE sj_retry_task_log_message +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + unique_id varchar(64) NOT NULL, + message text NOT NULL, + log_num int NOT NULL DEFAULT 1, + real_time bigint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id); +CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt); + +COMMENT ON COLUMN sj_retry_task_log_message.id IS '主键'; +COMMENT ON COLUMN sj_retry_task_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_task_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_task_log_message.unique_id IS '同组下id唯一'; +COMMENT ON COLUMN sj_retry_task_log_message.message IS '异常信息'; +COMMENT ON COLUMN sj_retry_task_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_retry_task_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_retry_task_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_retry_task_log_message IS '任务调度日志信息记录表'; + +-- sj_retry_scene_config +CREATE TABLE sj_retry_scene_config +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + scene_name varchar(64) NOT NULL, + group_name varchar(64) NOT NULL, + scene_status smallint NOT NULL DEFAULT 0, + max_retry_count int NOT NULL DEFAULT 5, + back_off smallint NOT NULL DEFAULT 1, + trigger_interval varchar(16) NOT NULL DEFAULT '', + deadline_request bigint NOT NULL DEFAULT 60000, + executor_timeout int NOT NULL DEFAULT 5, + route_key smallint NOT NULL DEFAULT 4, + description varchar(256) NOT NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_retry_scene_config_01 ON sj_retry_scene_config (namespace_id, group_name, scene_name); + +COMMENT ON COLUMN sj_retry_scene_config.id IS '主键'; +COMMENT ON COLUMN sj_retry_scene_config.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_scene_config.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_scene_config.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_scene_config.scene_status IS '组状态 0、未启用 1、启用'; +COMMENT ON COLUMN sj_retry_scene_config.max_retry_count IS '最大重试次数'; +COMMENT ON COLUMN sj_retry_scene_config.back_off IS '1、默认等级 2、固定间隔时间 3、CRON 表达式'; +COMMENT ON COLUMN sj_retry_scene_config.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_retry_scene_config.deadline_request IS 'Deadline Request 调用链超时 单位毫秒'; +COMMENT ON COLUMN sj_retry_scene_config.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_retry_scene_config.route_key IS '路由策略'; +COMMENT ON COLUMN sj_retry_scene_config.description IS '描述'; +COMMENT ON COLUMN sj_retry_scene_config.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_scene_config.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_scene_config IS '场景配置'; + +-- sj_server_node +CREATE TABLE sj_server_node +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + host_id varchar(64) NOT NULL, + host_ip varchar(64) NOT NULL, + host_port int NOT NULL, + expire_at timestamp NOT NULL, + node_type smallint NOT NULL, + ext_attrs varchar(256) NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_server_node_01 ON sj_server_node (host_id, host_ip); + +CREATE INDEX idx_sj_server_node_01 ON sj_server_node (namespace_id, group_name); +CREATE INDEX idx_sj_server_node_02 ON sj_server_node (expire_at, node_type); + +COMMENT ON COLUMN sj_server_node.id IS '主键'; +COMMENT ON COLUMN sj_server_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_server_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_server_node.host_id IS '主机id'; +COMMENT ON COLUMN sj_server_node.host_ip IS '机器ip'; +COMMENT ON COLUMN sj_server_node.host_port IS '机器端口'; +COMMENT ON COLUMN sj_server_node.expire_at IS '过期时间'; +COMMENT ON COLUMN sj_server_node.node_type IS '节点类型 1、客户端 2、是服务端'; +COMMENT ON COLUMN sj_server_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_server_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_server_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_server_node IS '服务器节点'; + +-- sj_distributed_lock +CREATE TABLE sj_distributed_lock +( + id bigserial PRIMARY KEY, + name varchar(64) NOT NULL, + lock_until timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + locked_at timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + locked_by varchar(255) NOT NULL, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +COMMENT ON COLUMN sj_distributed_lock.id IS '主键'; +COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称'; +COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长'; +COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间'; +COMMENT ON COLUMN sj_distributed_lock.locked_by IS '锁定者'; +COMMENT ON COLUMN sj_distributed_lock.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_distributed_lock.update_dt IS '修改时间'; +COMMENT ON TABLE sj_distributed_lock IS '锁定表'; + +-- sj_system_user +CREATE TABLE sj_system_user +( + id bigserial PRIMARY KEY, + username varchar(64) NOT NULL, + password varchar(128) NOT NULL, + role smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +COMMENT ON COLUMN sj_system_user.id IS '主键'; +COMMENT ON COLUMN sj_system_user.username IS '账号'; +COMMENT ON COLUMN sj_system_user.password IS '密码'; +COMMENT ON COLUMN sj_system_user.role IS '角色:1-普通用户、2-管理员'; +COMMENT ON COLUMN sj_system_user.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user IS '系统用户表'; + +INSERT INTO sj_system_user (username, password, role) +VALUES ('admin', '465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2); + +-- sj_system_user_permission +CREATE TABLE sj_system_user_permission +( + id bigserial PRIMARY KEY, + group_name varchar(64) NOT NULL, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + system_user_id bigint NOT NULL, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id); + +COMMENT ON COLUMN sj_system_user_permission.id IS '主键'; +COMMENT ON COLUMN sj_system_user_permission.group_name IS '组名称'; +COMMENT ON COLUMN sj_system_user_permission.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_system_user_permission.system_user_id IS '系统用户id'; +COMMENT ON COLUMN sj_system_user_permission.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_system_user_permission.update_dt IS '修改时间'; +COMMENT ON TABLE sj_system_user_permission IS '系统用户权限表'; + +-- sj_sequence_alloc +CREATE TABLE sj_sequence_alloc +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL DEFAULT '', + max_id bigint NOT NULL DEFAULT 1, + step int NOT NULL DEFAULT 100, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_sequence_alloc_01 ON sj_sequence_alloc (namespace_id, group_name); + +COMMENT ON COLUMN sj_sequence_alloc.id IS '主键'; +COMMENT ON COLUMN sj_sequence_alloc.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_sequence_alloc.group_name IS '组名称'; +COMMENT ON COLUMN sj_sequence_alloc.max_id IS '最大id'; +COMMENT ON COLUMN sj_sequence_alloc.step IS '步长'; +COMMENT ON COLUMN sj_sequence_alloc.update_dt IS '更新时间'; +COMMENT ON TABLE sj_sequence_alloc IS '号段模式序号ID分配表'; + +-- sj_job +CREATE TABLE sj_job +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + job_name varchar(64) NOT NULL, + args_str text NULL DEFAULT NULL, + args_type smallint NOT NULL DEFAULT 1, + next_trigger_at bigint NOT NULL, + job_status smallint NOT NULL DEFAULT 1, + task_type smallint NOT NULL DEFAULT 1, + route_key smallint NOT NULL DEFAULT 4, + executor_type smallint NOT NULL DEFAULT 1, + executor_info varchar(255) NULL DEFAULT NULL, + trigger_type smallint NOT NULL, + trigger_interval varchar(255) NOT NULL, + block_strategy smallint NOT NULL DEFAULT 1, + executor_timeout int NOT NULL DEFAULT 0, + max_retry_times int NOT NULL DEFAULT 0, + parallel_num int NOT NULL DEFAULT 1, + retry_interval int NOT NULL DEFAULT 0, + bucket_index int NOT NULL DEFAULT 0, + resident smallint NOT NULL DEFAULT 0, + description varchar(256) NOT NULL DEFAULT '', + ext_attrs varchar(256) NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_job_01 ON sj_job (namespace_id, group_name); +CREATE INDEX idx_sj_job_02 ON sj_job (job_status, bucket_index); +CREATE INDEX idx_sj_job_03 ON sj_job (create_dt); + +COMMENT ON COLUMN sj_job.id IS '主键'; +COMMENT ON COLUMN sj_job.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job.group_name IS '组名称'; +COMMENT ON COLUMN sj_job.job_name IS '名称'; +COMMENT ON COLUMN sj_job.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_job.job_status IS '任务状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_job.task_type IS '任务类型 1、集群 2、广播 3、切片'; +COMMENT ON COLUMN sj_job.route_key IS '路由策略'; +COMMENT ON COLUMN sj_job.executor_type IS '执行器类型'; +COMMENT ON COLUMN sj_job.executor_info IS '执行器名称'; +COMMENT ON COLUMN sj_job.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_job.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_job.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_job.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_job.max_retry_times IS '最大重试次数'; +COMMENT ON COLUMN sj_job.parallel_num IS '并行数'; +COMMENT ON COLUMN sj_job.retry_interval IS '重试间隔 ( s ) '; +COMMENT ON COLUMN sj_job.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_job.resident IS '是否是常驻任务'; +COMMENT ON COLUMN sj_job.description IS '描述'; +COMMENT ON COLUMN sj_job.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job IS '任务信息'; + +-- sj_job_log_message +CREATE TABLE sj_job_log_message +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + task_id bigint NOT NULL, + message text NOT NULL, + log_num int NOT NULL DEFAULT 1, + real_time bigint NOT NULL DEFAULT 0, + ext_attrs varchar(256) NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_job_log_message_01 ON sj_job_log_message (task_batch_id, task_id); +CREATE INDEX idx_sj_job_log_message_02 ON sj_job_log_message (create_dt); +CREATE INDEX idx_sj_job_log_message_03 ON sj_job_log_message (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_log_message.id IS '主键'; +COMMENT ON COLUMN sj_job_log_message.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_log_message.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_log_message.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_log_message.task_batch_id IS '任务批次id'; +COMMENT ON COLUMN sj_job_log_message.task_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_log_message.message IS '调度信息'; +COMMENT ON COLUMN sj_job_log_message.log_num IS '日志数量'; +COMMENT ON COLUMN sj_job_log_message.real_time IS '上报时间'; +COMMENT ON COLUMN sj_job_log_message.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_log_message.create_dt IS '创建时间'; +COMMENT ON TABLE sj_job_log_message IS '调度日志'; + +-- sj_job_task +CREATE TABLE sj_job_task +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + parent_id bigint NOT NULL DEFAULT 0, + task_status smallint NOT NULL DEFAULT 0, + retry_count int NOT NULL DEFAULT 0, + client_info varchar(128) NULL DEFAULT NULL, + result_message text NOT NULL, + args_str text NULL DEFAULT NULL, + args_type smallint NOT NULL DEFAULT 1, + ext_attrs varchar(256) NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_job_task_01 ON sj_job_task (task_batch_id, task_status); +CREATE INDEX idx_sj_job_task_02 ON sj_job_task (create_dt); +CREATE INDEX idx_sj_job_task_03 ON sj_job_task (namespace_id, group_name); + +COMMENT ON COLUMN sj_job_task.id IS '主键'; +COMMENT ON COLUMN sj_job_task.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id'; +COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id'; +COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数'; +COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port'; +COMMENT ON COLUMN sj_job_task.result_message IS '执行结果'; +COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数'; +COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 '; +COMMENT ON COLUMN sj_job_task.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task IS '任务实例'; + +-- sj_job_task_batch +CREATE TABLE sj_job_task_batch +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + job_id bigint NOT NULL, + workflow_node_id bigint NOT NULL DEFAULT 0, + parent_workflow_node_id bigint NOT NULL DEFAULT 0, + workflow_task_batch_id bigint NOT NULL DEFAULT 0, + task_batch_status smallint NOT NULL DEFAULT 0, + operation_reason smallint NOT NULL DEFAULT 0, + execution_at bigint NOT NULL DEFAULT 0, + system_task_type smallint NOT NULL DEFAULT 3, + parent_id varchar(64) NOT NULL DEFAULT '', + ext_attrs varchar(256) NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_job_task_batch_01 ON sj_job_task_batch (job_id, task_batch_status); +CREATE INDEX idx_sj_job_task_batch_02 ON sj_job_task_batch (create_dt); +CREATE INDEX idx_sj_job_task_batch_03 ON sj_job_task_batch (namespace_id, group_name); +CREATE INDEX idx_sj_job_task_batch_04 ON sj_job_task_batch (workflow_task_batch_id, workflow_node_id); + +COMMENT ON COLUMN sj_job_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_job_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_task_batch.job_id IS '任务id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_node_id IS '工作流节点id'; +COMMENT ON COLUMN sj_job_task_batch.parent_workflow_node_id IS '工作流任务父批次id'; +COMMENT ON COLUMN sj_job_task_batch.workflow_task_batch_id IS '工作流任务批次id'; +COMMENT ON COLUMN sj_job_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_job_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_job_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_job_task_batch.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_task_batch.parent_id IS '父节点'; +COMMENT ON COLUMN sj_job_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_job_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_job_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_task_batch IS '任务批次'; + +-- sj_job_summary +CREATE TABLE sj_job_summary +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL DEFAULT '', + business_id bigint NOT NULL, + system_task_type smallint NOT NULL DEFAULT 3, + trigger_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + success_num int NOT NULL DEFAULT 0, + fail_num int NOT NULL DEFAULT 0, + fail_reason varchar(512) NOT NULL DEFAULT '', + stop_num int NOT NULL DEFAULT 0, + stop_reason varchar(512) NOT NULL DEFAULT '', + cancel_num int NOT NULL DEFAULT 0, + cancel_reason varchar(512) NOT NULL DEFAULT '', + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_job_summary_01 ON sj_job_summary (trigger_at, system_task_type, business_id); + +CREATE INDEX idx_sj_job_summary_01 ON sj_job_summary (namespace_id, group_name, business_id); + +COMMENT ON COLUMN sj_job_summary.id IS '主键'; +COMMENT ON COLUMN sj_job_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_job_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_job_summary.business_id IS '业务id ( job_id或workflow_id ) '; +COMMENT ON COLUMN sj_job_summary.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; +COMMENT ON COLUMN sj_job_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_job_summary.success_num IS '执行成功-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.fail_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.stop_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.stop_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.cancel_num IS '执行失败-日志数量'; +COMMENT ON COLUMN sj_job_summary.cancel_reason IS '失败原因'; +COMMENT ON COLUMN sj_job_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_job_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_job_summary IS 'DashBoard_Job'; + +-- sj_retry_summary +CREATE TABLE sj_retry_summary +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL DEFAULT '', + scene_name varchar(50) NOT NULL DEFAULT '', + trigger_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + running_num int NOT NULL DEFAULT 0, + finish_num int NOT NULL DEFAULT 0, + max_count_num int NOT NULL DEFAULT 0, + suspend_num int NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX uk_sj_retry_summary_01 ON sj_retry_summary (namespace_id, group_name, scene_name, trigger_at); + +CREATE INDEX idx_sj_retry_summary_01 ON sj_retry_summary (trigger_at); + +COMMENT ON COLUMN sj_retry_summary.id IS '主键'; +COMMENT ON COLUMN sj_retry_summary.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_retry_summary.group_name IS '组名称'; +COMMENT ON COLUMN sj_retry_summary.scene_name IS '场景名称'; +COMMENT ON COLUMN sj_retry_summary.trigger_at IS '统计时间'; +COMMENT ON COLUMN sj_retry_summary.running_num IS '重试中-日志数量'; +COMMENT ON COLUMN sj_retry_summary.finish_num IS '重试完成-日志数量'; +COMMENT ON COLUMN sj_retry_summary.max_count_num IS '重试到达最大次数-日志数量'; +COMMENT ON COLUMN sj_retry_summary.suspend_num IS '暂停重试-日志数量'; +COMMENT ON COLUMN sj_retry_summary.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_retry_summary.update_dt IS '修改时间'; +COMMENT ON TABLE sj_retry_summary IS 'DashBoard_Retry'; + +-- sj_workflow +CREATE TABLE sj_workflow +( + id bigserial PRIMARY KEY, + workflow_name varchar(64) NOT NULL, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + workflow_status smallint NOT NULL DEFAULT 1, + trigger_type smallint NOT NULL, + trigger_interval varchar(255) NOT NULL, + next_trigger_at bigint NOT NULL, + block_strategy smallint NOT NULL DEFAULT 1, + executor_timeout int NOT NULL DEFAULT 0, + description varchar(256) NOT NULL DEFAULT '', + flow_info text NULL DEFAULT NULL, + bucket_index int NOT NULL DEFAULT 0, + version int NOT NULL, + ext_attrs varchar(256) NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_workflow_01 ON sj_workflow (create_dt); +CREATE INDEX idx_sj_workflow_02 ON sj_workflow (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow.id IS '主键'; +COMMENT ON COLUMN sj_workflow.workflow_name IS '工作流名称'; +COMMENT ON COLUMN sj_workflow.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow.workflow_status IS '工作流状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间'; +COMMENT ON COLUMN sj_workflow.trigger_interval IS '间隔时长'; +COMMENT ON COLUMN sj_workflow.next_trigger_at IS '下次触发时间'; +COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行'; +COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒'; +COMMENT ON COLUMN sj_workflow.description IS '描述'; +COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket'; +COMMENT ON COLUMN sj_workflow.version IS '版本号'; +COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow IS '工作流'; + +-- sj_workflow_node +CREATE TABLE sj_workflow_node +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + node_name varchar(64) NOT NULL, + group_name varchar(64) NOT NULL, + job_id bigint NOT NULL, + workflow_id bigint NOT NULL, + node_type smallint NOT NULL DEFAULT 1, + expression_type smallint NOT NULL DEFAULT 0, + fail_strategy smallint NOT NULL DEFAULT 1, + workflow_node_status smallint NOT NULL DEFAULT 1, + priority_level int NOT NULL DEFAULT 1, + node_info text NULL DEFAULT NULL, + version int NOT NULL, + ext_attrs varchar(256) NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_workflow_node_01 ON sj_workflow_node (create_dt); +CREATE INDEX idx_sj_workflow_node_02 ON sj_workflow_node (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_node.id IS '主键'; +COMMENT ON COLUMN sj_workflow_node.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_node.node_name IS '节点名称'; +COMMENT ON COLUMN sj_workflow_node.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_node.job_id IS '任务信息id'; +COMMENT ON COLUMN sj_workflow_node.workflow_id IS '工作流ID'; +COMMENT ON COLUMN sj_workflow_node.node_type IS '1、任务节点 2、条件节点'; +COMMENT ON COLUMN sj_workflow_node.expression_type IS '1、SpEl、2、Aviator 3、QL'; +COMMENT ON COLUMN sj_workflow_node.fail_strategy IS '失败策略 1、跳过 2、阻塞'; +COMMENT ON COLUMN sj_workflow_node.workflow_node_status IS '工作流节点状态 0、关闭、1、开启'; +COMMENT ON COLUMN sj_workflow_node.priority_level IS '优先级'; +COMMENT ON COLUMN sj_workflow_node.node_info IS '节点信息 '; +COMMENT ON COLUMN sj_workflow_node.version IS '版本号'; +COMMENT ON COLUMN sj_workflow_node.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_node.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_node.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_node.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_node IS '工作流节点'; + +-- sj_workflow_task_batch +CREATE TABLE sj_workflow_task_batch +( + id bigserial PRIMARY KEY, + namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name varchar(64) NOT NULL, + workflow_id bigint NOT NULL, + task_batch_status smallint NOT NULL DEFAULT 0, + operation_reason smallint NOT NULL DEFAULT 0, + flow_info text NULL DEFAULT NULL, + execution_at bigint NOT NULL DEFAULT 0, + ext_attrs varchar(256) NULL DEFAULT '', + deleted smallint NOT NULL DEFAULT 0, + create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_sj_workflow_task_batch_01 ON sj_workflow_task_batch (workflow_id, task_batch_status); +CREATE INDEX idx_sj_workflow_task_batch_02 ON sj_workflow_task_batch (create_dt); +CREATE INDEX idx_sj_workflow_task_batch_03 ON sj_workflow_task_batch (namespace_id, group_name); + +COMMENT ON COLUMN sj_workflow_task_batch.id IS '主键'; +COMMENT ON COLUMN sj_workflow_task_batch.namespace_id IS '命名空间id'; +COMMENT ON COLUMN sj_workflow_task_batch.group_name IS '组名称'; +COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id'; +COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功'; +COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因'; +COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息'; +COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间'; +COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段'; +COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除'; +COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间'; +COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间'; +COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次'; + diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql new file mode 100644 index 00000000..b2c1b7aa --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql @@ -0,0 +1,2690 @@ +/* + SnailJob Database Transfer Tool + Source Server Type : MySQL + Target Server Type : Microsoft SQL Server + Date: 2024-05-20 22:03:46 +*/ + + +-- sj_namespace +CREATE TABLE sj_namespace +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + name nvarchar(64) NOT NULL, + unique_id nvarchar(64) NOT NULL, + description nvarchar(256) NOT NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_namespace_01 ON sj_namespace (name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'唯一id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'unique_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_namespace' +GO + +INSERT INTO sj_namespace (name, unique_id, create_dt, update_dt, deleted) +VALUES (N'Default', N'764d604ec6fc45f68cd92514c40e9e1a', getdate(), getdate(), 0) +GO + +-- sj_group_config +CREATE TABLE sj_group_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL DEFAULT '', + description nvarchar(256) NOT NULL DEFAULT '', + token nvarchar(64) NOT NULL DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT', + group_status tinyint NOT NULL DEFAULT 0, + version int NOT NULL, + group_partition int NOT NULL, + id_generator_mode tinyint NOT NULL DEFAULT 1, + init_scene tinyint NOT NULL DEFAULT 0, + bucket_index int NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_group_config_01 ON sj_group_config (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'token', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'token' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组状态 0、未启用 1、启用', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'group_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'版本号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'version' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'分区', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'group_partition' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'唯一id生成模式 默认号段模式', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'id_generator_mode' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'是否初始化场景 0:否 1:是', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'init_scene' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'bucket', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'bucket_index' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组配置', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_group_config' +GO + +-- sj_notify_config +CREATE TABLE sj_notify_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + business_id nvarchar(64) NOT NULL, + system_task_type tinyint NOT NULL DEFAULT 3, + notify_status tinyint NOT NULL DEFAULT 0, + recipient_ids nvarchar(128) NOT NULL, + notify_threshold int NOT NULL DEFAULT 0, + notify_scene tinyint NOT NULL DEFAULT 0, + rate_limiter_status tinyint NOT NULL DEFAULT 0, + rate_limiter_threshold int NOT NULL DEFAULT 0, + description nvarchar(256) NOT NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_notify_config_01 ON sj_notify_config (namespace_id, group_name, business_id) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'业务id ( job_id或workflow_id或scene_name ) ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'business_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'system_task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'通知状态 0、未启用 1、启用', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'notify_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'接收人id列表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'recipient_ids' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'通知阈值', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'notify_threshold' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'通知场景', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'notify_scene' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'限流状态 0、未启用 1、启用', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'rate_limiter_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'每秒限流阈值', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'rate_limiter_threshold' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'通知配置', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_config' +GO + +-- sj_notify_recipient +CREATE TABLE sj_notify_recipient +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + recipient_name nvarchar(64) NOT NULL, + notify_type tinyint NOT NULL DEFAULT 0, + notify_attribute nvarchar(512) NOT NULL, + description nvarchar(256) NOT NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'接收人名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'recipient_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'notify_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'配置属性', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'notify_attribute' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'告警通知接收人', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_notify_recipient' +GO + +-- sj_retry_dead_letter_0 +CREATE TABLE sj_retry_dead_letter_0 +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id nvarchar(64) NOT NULL, + group_name nvarchar(64) NOT NULL, + scene_name nvarchar(64) NOT NULL, + idempotent_id nvarchar(64) NOT NULL, + biz_no nvarchar(64) NOT NULL DEFAULT '', + executor_name nvarchar(512) NOT NULL DEFAULT '', + args_str nvarchar(max) NOT NULL, + ext_attrs nvarchar(max) NOT NULL, + task_type tinyint NOT NULL DEFAULT 1, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, unique_id) +GO + +CREATE INDEX idx_sj_retry_dead_letter_0_01 ON sj_retry_dead_letter_0 (namespace_id, group_name, scene_name) +GO +CREATE INDEX idx_sj_retry_dead_letter_0_02 ON sj_retry_dead_letter_0 (idempotent_id) +GO +CREATE INDEX idx_sj_retry_dead_letter_0_03 ON sj_retry_dead_letter_0 (biz_no) +GO +CREATE INDEX idx_sj_retry_dead_letter_0_04 ON sj_retry_dead_letter_0 (create_dt) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'同组下id唯一', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'unique_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'scene_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'幂等id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'idempotent_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'业务编号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'biz_no' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行器名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'executor_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行方法参数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'args_str' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 1、重试数据 2、回调数据', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'死信队列表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_dead_letter_0' +GO + +-- sj_retry_task_0 +CREATE TABLE sj_retry_task_0 +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id nvarchar(64) NOT NULL, + group_name nvarchar(64) NOT NULL, + scene_name nvarchar(64) NOT NULL, + idempotent_id nvarchar(64) NOT NULL, + biz_no nvarchar(64) NOT NULL DEFAULT '', + executor_name nvarchar(512) NOT NULL DEFAULT '', + args_str nvarchar(max) NOT NULL, + ext_attrs nvarchar(max) NOT NULL, + next_trigger_at datetime2 NOT NULL, + retry_count int NOT NULL DEFAULT 0, + retry_status tinyint NOT NULL DEFAULT 0, + task_type tinyint NOT NULL DEFAULT 1, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, unique_id) +GO + +CREATE INDEX idx_sj_retry_task_0_01 ON sj_retry_task_0 (namespace_id, group_name, scene_name) +GO +CREATE INDEX idx_sj_retry_task_0_02 ON sj_retry_task_0 (namespace_id, group_name, task_type) +GO +CREATE INDEX idx_sj_retry_task_0_03 ON sj_retry_task_0 (namespace_id, group_name, retry_status) +GO +CREATE INDEX idx_sj_retry_task_0_04 ON sj_retry_task_0 (idempotent_id) +GO +CREATE INDEX idx_sj_retry_task_0_05 ON sj_retry_task_0 (biz_no) +GO +CREATE INDEX idx_sj_retry_task_0_06 ON sj_retry_task_0 (create_dt) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'同组下id唯一', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'unique_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'scene_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'幂等id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'idempotent_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'业务编号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'biz_no' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行器名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'executor_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行方法参数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'args_str' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'下次触发时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'next_trigger_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'retry_count' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试状态 0、重试中 1、成功 2、最大重试次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'retry_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 1、重试数据 2、回调数据', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_0' +GO + +-- sj_retry_task_log +CREATE TABLE sj_retry_task_log +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + unique_id nvarchar(64) NOT NULL, + group_name nvarchar(64) NOT NULL, + scene_name nvarchar(64) NOT NULL, + idempotent_id nvarchar(64) NOT NULL, + biz_no nvarchar(64) NOT NULL DEFAULT '', + executor_name nvarchar(512) NOT NULL DEFAULT '', + args_str nvarchar(max) NOT NULL, + ext_attrs nvarchar(max) NOT NULL, + retry_status tinyint NOT NULL DEFAULT 0, + task_type tinyint NOT NULL DEFAULT 1, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_retry_task_log_01 ON sj_retry_task_log (namespace_id, group_name, scene_name) +GO +CREATE INDEX idx_sj_retry_task_log_02 ON sj_retry_task_log (retry_status) +GO +CREATE INDEX idx_sj_retry_task_log_03 ON sj_retry_task_log (idempotent_id) +GO +CREATE INDEX idx_sj_retry_task_log_04 ON sj_retry_task_log (unique_id) +GO +CREATE INDEX idx_sj_retry_task_log_05 ON sj_retry_task_log (biz_no) +GO +CREATE INDEX idx_sj_retry_task_log_06 ON sj_retry_task_log (create_dt) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'同组下id唯一', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'unique_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'scene_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'幂等id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'idempotent_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'业务编号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'biz_no' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行器名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'executor_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行方法参数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'args_str' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试状态 0、重试中 1、成功 2、最大次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'retry_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 1、重试数据 2、回调数据', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务日志基础信息表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log' +GO + +-- sj_retry_task_log_message +CREATE TABLE sj_retry_task_log_message +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + unique_id nvarchar(64) NOT NULL, + message nvarchar(max) NOT NULL, + log_num int NOT NULL DEFAULT 1, + real_time bigint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id) +GO +CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'同组下id唯一', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'unique_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'异常信息', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'message' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'log_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'上报时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'real_time' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务调度日志信息记录表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_task_log_message' +GO + +-- sj_retry_scene_config +CREATE TABLE sj_retry_scene_config +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + scene_name nvarchar(64) NOT NULL, + group_name nvarchar(64) NOT NULL, + scene_status tinyint NOT NULL DEFAULT 0, + max_retry_count int NOT NULL DEFAULT 5, + back_off tinyint NOT NULL DEFAULT 1, + trigger_interval nvarchar(16) NOT NULL DEFAULT '', + deadline_request bigint NOT NULL DEFAULT 60000, + executor_timeout int NOT NULL DEFAULT 5, + route_key tinyint NOT NULL DEFAULT 4, + description nvarchar(256) NOT NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_retry_scene_config_01 ON sj_retry_scene_config (namespace_id, group_name, scene_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'scene_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组状态 0、未启用 1、启用', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'scene_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'最大重试次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'max_retry_count' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'1、默认等级 2、固定间隔时间 3、CRON 表达式', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'back_off' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'间隔时长', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'trigger_interval' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'Deadline Request 调用链超时 单位毫秒', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'deadline_request' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务执行超时时间,单位秒', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'executor_timeout' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'路由策略', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'route_key' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景配置', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_scene_config' +GO + +-- sj_server_node +CREATE TABLE sj_server_node +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + host_id nvarchar(64) NOT NULL, + host_ip nvarchar(64) NOT NULL, + host_port int NOT NULL, + expire_at datetime2 NOT NULL, + node_type tinyint NOT NULL, + ext_attrs nvarchar(256) NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_server_node_01 ON sj_server_node (host_id, host_ip) +GO + +CREATE INDEX idx_sj_server_node_01 ON sj_server_node (namespace_id, group_name) +GO +CREATE INDEX idx_sj_server_node_02 ON sj_server_node (expire_at, node_type) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主机id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'host_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'机器ip', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'host_ip' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'机器端口', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'host_port' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'过期时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'expire_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'节点类型 1、客户端 2、是服务端', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'node_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'服务器节点', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_server_node' +GO + +-- sj_distributed_lock +CREATE TABLE sj_distributed_lock +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + name nvarchar(64) NOT NULL, + lock_until datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + locked_at datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + locked_by nvarchar(255) NOT NULL, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'锁名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'锁定时长', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'lock_until' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'锁定时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'locked_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'锁定者', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'locked_by' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'锁定表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_distributed_lock' +GO + +-- sj_system_user +CREATE TABLE sj_system_user +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + username nvarchar(64) NOT NULL, + password nvarchar(128) NOT NULL, + role tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'账号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'username' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'密码', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'password' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'角色:1-普通用户、2-管理员', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'role' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'系统用户表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user' +GO + +INSERT INTO sj_system_user (username, password, role) +VALUES (N'admin', N'465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2) +GO + +-- sj_system_user_permission +CREATE TABLE sj_system_user_permission +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + group_name nvarchar(64) NOT NULL, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + system_user_id bigint NOT NULL, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'系统用户id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'system_user_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'系统用户权限表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_system_user_permission' +GO + +-- sj_sequence_alloc +CREATE TABLE sj_sequence_alloc +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL DEFAULT '', + max_id bigint NOT NULL DEFAULT 1, + step int NOT NULL DEFAULT 100, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_sequence_alloc_01 ON sj_sequence_alloc (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'最大id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'max_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'步长', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'step' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'更新时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'号段模式序号ID分配表', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_sequence_alloc' +GO + +-- sj_job +CREATE TABLE sj_job +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + job_name nvarchar(64) NOT NULL, + args_str nvarchar(max) NULL DEFAULT NULL, + args_type tinyint NOT NULL DEFAULT 1, + next_trigger_at bigint NOT NULL, + job_status tinyint NOT NULL DEFAULT 1, + task_type tinyint NOT NULL DEFAULT 1, + route_key tinyint NOT NULL DEFAULT 4, + executor_type tinyint NOT NULL DEFAULT 1, + executor_info nvarchar(255) NULL DEFAULT NULL, + trigger_type tinyint NOT NULL, + trigger_interval nvarchar(255) NOT NULL, + block_strategy tinyint NOT NULL DEFAULT 1, + executor_timeout int NOT NULL DEFAULT 0, + max_retry_times int NOT NULL DEFAULT 0, + parallel_num int NOT NULL DEFAULT 1, + retry_interval int NOT NULL DEFAULT 0, + bucket_index int NOT NULL DEFAULT 0, + resident tinyint NOT NULL DEFAULT 0, + description nvarchar(256) NOT NULL DEFAULT '', + ext_attrs nvarchar(256) NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_job_01 ON sj_job (namespace_id, group_name) +GO +CREATE INDEX idx_sj_job_02 ON sj_job (job_status, bucket_index) +GO +CREATE INDEX idx_sj_job_03 ON sj_job (create_dt) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'job_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行方法参数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'args_str' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'参数类型 ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'args_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'下次触发时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'next_trigger_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务状态 0、关闭、1、开启', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'job_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 1、集群 2、广播 3、切片', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'路由策略', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'route_key' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行器类型', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'executor_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行器名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'executor_info' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'触发类型 1.CRON 表达式 2. 固定时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'trigger_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'间隔时长', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'trigger_interval' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'阻塞策略 1、丢弃 2、覆盖 3、并行', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'block_strategy' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务执行超时时间,单位秒', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'executor_timeout' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'最大重试次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'max_retry_times' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'并行数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'parallel_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试间隔 ( s ) ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'retry_interval' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'bucket', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'bucket_index' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'是否是常驻任务', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'resident' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务信息', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job' +GO + +-- sj_job_log_message +CREATE TABLE sj_job_log_message +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + task_id bigint NOT NULL, + message nvarchar(max) NOT NULL, + log_num int NOT NULL DEFAULT 1, + real_time bigint NOT NULL DEFAULT 0, + ext_attrs nvarchar(256) NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_job_log_message_01 ON sj_job_log_message (task_batch_id, task_id) +GO +CREATE INDEX idx_sj_job_log_message_02 ON sj_job_log_message (create_dt) +GO +CREATE INDEX idx_sj_job_log_message_03 ON sj_job_log_message (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务信息id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'job_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务批次id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'task_batch_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'调度任务id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'task_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'调度信息', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'message' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'log_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'上报时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'real_time' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'调度日志', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_log_message' +GO + +-- sj_job_task +CREATE TABLE sj_job_task +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + job_id bigint NOT NULL, + task_batch_id bigint NOT NULL, + parent_id bigint NOT NULL DEFAULT 0, + task_status tinyint NOT NULL DEFAULT 0, + retry_count int NOT NULL DEFAULT 0, + client_info nvarchar(128) NULL DEFAULT NULL, + result_message nvarchar(max) NOT NULL, + args_str nvarchar(max) NULL DEFAULT NULL, + args_type tinyint NOT NULL DEFAULT 1, + ext_attrs nvarchar(256) NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_job_task_01 ON sj_job_task (task_batch_id, task_status) +GO +CREATE INDEX idx_sj_job_task_02 ON sj_job_task (create_dt) +GO +CREATE INDEX idx_sj_job_task_03 ON sj_job_task (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务信息id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'job_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'调度任务id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'task_batch_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'父执行器id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'parent_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行的状态 0、失败 1、成功', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'task_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试次数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'retry_count' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'客户端地址 clientId#ip:port', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'client_info' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行结果', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'result_message' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行方法参数', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'args_str' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'参数类型 ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'args_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务实例', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task' +GO + +-- sj_job_task_batch +CREATE TABLE sj_job_task_batch +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + job_id bigint NOT NULL, + workflow_node_id bigint NOT NULL DEFAULT 0, + parent_workflow_node_id bigint NOT NULL DEFAULT 0, + workflow_task_batch_id bigint NOT NULL DEFAULT 0, + task_batch_status tinyint NOT NULL DEFAULT 0, + operation_reason tinyint NOT NULL DEFAULT 0, + execution_at bigint NOT NULL DEFAULT 0, + system_task_type tinyint NOT NULL DEFAULT 3, + parent_id nvarchar(64) NOT NULL DEFAULT '', + ext_attrs nvarchar(256) NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_job_task_batch_01 ON sj_job_task_batch (job_id, task_batch_status) +GO +CREATE INDEX idx_sj_job_task_batch_02 ON sj_job_task_batch (create_dt) +GO +CREATE INDEX idx_sj_job_task_batch_03 ON sj_job_task_batch (namespace_id, group_name) +GO +CREATE INDEX idx_sj_job_task_batch_04 ON sj_job_task_batch (workflow_task_batch_id, workflow_node_id) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'job_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流节点id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'workflow_node_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流任务父批次id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'parent_workflow_node_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流任务批次id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'workflow_task_batch_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务批次状态 0、失败 1、成功', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'task_batch_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'操作原因', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'operation_reason' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务执行时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'execution_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 3、JOB任务 4、WORKFLOW任务', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'system_task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'父节点', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'parent_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务批次', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_task_batch' +GO + +-- sj_job_summary +CREATE TABLE sj_job_summary +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL DEFAULT '', + business_id bigint NOT NULL, + system_task_type tinyint NOT NULL DEFAULT 3, + trigger_at datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + success_num int NOT NULL DEFAULT 0, + fail_num int NOT NULL DEFAULT 0, + fail_reason nvarchar(512) NOT NULL DEFAULT '', + stop_num int NOT NULL DEFAULT 0, + stop_reason nvarchar(512) NOT NULL DEFAULT '', + cancel_num int NOT NULL DEFAULT 0, + cancel_reason nvarchar(512) NOT NULL DEFAULT '', + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_job_summary_01 ON sj_job_summary (trigger_at, system_task_type, business_id) +GO + +CREATE INDEX idx_sj_job_summary_01 ON sj_job_summary (namespace_id, group_name, business_id) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'业务id ( job_id或workflow_id ) ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'business_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 3、JOB任务 4、WORKFLOW任务', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'system_task_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'统计时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'trigger_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行成功-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'success_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行失败-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'fail_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'失败原因', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'fail_reason' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行失败-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'stop_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'失败原因', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'stop_reason' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'执行失败-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'cancel_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'失败原因', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'cancel_reason' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'DashBoard_Job', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_job_summary' +GO + +-- sj_retry_summary +CREATE TABLE sj_retry_summary +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL DEFAULT '', + scene_name nvarchar(50) NOT NULL DEFAULT '', + trigger_at datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + running_num int NOT NULL DEFAULT 0, + finish_num int NOT NULL DEFAULT 0, + max_count_num int NOT NULL DEFAULT 0, + suspend_num int NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE UNIQUE INDEX uk_sj_retry_summary_01 ON sj_retry_summary (namespace_id, group_name, scene_name, trigger_at) +GO + +CREATE INDEX idx_sj_retry_summary_01 ON sj_retry_summary (trigger_at) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'场景名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'scene_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'统计时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'trigger_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试中-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'running_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试完成-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'finish_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'重试到达最大次数-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'max_count_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'暂停重试-日志数量', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'suspend_num' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'DashBoard_Retry', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_retry_summary' +GO + +-- sj_workflow +CREATE TABLE sj_workflow +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + workflow_name nvarchar(64) NOT NULL, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + workflow_status tinyint NOT NULL DEFAULT 1, + trigger_type tinyint NOT NULL, + trigger_interval nvarchar(255) NOT NULL, + next_trigger_at bigint NOT NULL, + block_strategy tinyint NOT NULL DEFAULT 1, + executor_timeout int NOT NULL DEFAULT 0, + description nvarchar(256) NOT NULL DEFAULT '', + flow_info nvarchar(max) NULL DEFAULT NULL, + bucket_index int NOT NULL DEFAULT 0, + version int NOT NULL, + ext_attrs nvarchar(256) NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_workflow_01 ON sj_workflow (create_dt) +GO +CREATE INDEX idx_sj_workflow_02 ON sj_workflow (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'workflow_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流状态 0、关闭、1、开启', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'workflow_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'触发类型 1.CRON 表达式 2. 固定时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'trigger_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'间隔时长', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'trigger_interval' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'下次触发时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'next_trigger_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'阻塞策略 1、丢弃 2、覆盖 3、并行', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'block_strategy' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务执行超时时间,单位秒', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'executor_timeout' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'描述', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'description' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'流程信息', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'flow_info' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'bucket', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'bucket_index' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'版本号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'version' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow' +GO + +-- sj_workflow_node +CREATE TABLE sj_workflow_node +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + node_name nvarchar(64) NOT NULL, + group_name nvarchar(64) NOT NULL, + job_id bigint NOT NULL, + workflow_id bigint NOT NULL, + node_type tinyint NOT NULL DEFAULT 1, + expression_type tinyint NOT NULL DEFAULT 0, + fail_strategy tinyint NOT NULL DEFAULT 1, + workflow_node_status tinyint NOT NULL DEFAULT 1, + priority_level int NOT NULL DEFAULT 1, + node_info nvarchar(max) NULL DEFAULT NULL, + version int NOT NULL, + ext_attrs nvarchar(256) NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_workflow_node_01 ON sj_workflow_node (create_dt) +GO +CREATE INDEX idx_sj_workflow_node_02 ON sj_workflow_node (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'节点名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'node_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务信息id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'job_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流ID', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'workflow_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'1、任务节点 2、条件节点', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'node_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'1、SpEl、2、Aviator 3、QL', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'expression_type' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'失败策略 1、跳过 2、阻塞', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'fail_strategy' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流节点状态 0、关闭、1、开启', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'workflow_node_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'优先级', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'priority_level' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'节点信息 ', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'node_info' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'版本号', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'version' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流节点', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_node' +GO + +-- sj_workflow_task_batch +CREATE TABLE sj_workflow_task_batch +( + id bigint NOT NULL PRIMARY KEY IDENTITY, + namespace_id nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name nvarchar(64) NOT NULL, + workflow_id bigint NOT NULL, + task_batch_status tinyint NOT NULL DEFAULT 0, + operation_reason tinyint NOT NULL DEFAULT 0, + flow_info nvarchar(max) NULL DEFAULT NULL, + execution_at bigint NOT NULL DEFAULT 0, + ext_attrs nvarchar(256) NULL DEFAULT '', + deleted tinyint NOT NULL DEFAULT 0, + create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP +) +GO + +CREATE INDEX idx_sj_workflow_task_batch_01 ON sj_workflow_task_batch (workflow_id, task_batch_status) +GO +CREATE INDEX idx_sj_workflow_task_batch_02 ON sj_workflow_task_batch (create_dt) +GO +CREATE INDEX idx_sj_workflow_task_batch_03 ON sj_workflow_task_batch (namespace_id, group_name) +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'主键', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'命名空间id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'namespace_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'组名称', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'group_name' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流任务id', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'workflow_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务批次状态 0、失败 1、成功', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'task_batch_status' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'操作原因', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'operation_reason' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'流程信息', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'flow_info' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务执行时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'execution_at' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'扩展字段', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'ext_attrs' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'逻辑删除 1、删除', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'deleted' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'创建时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'create_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch', + 'COLUMN', N'update_dt' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'工作流批次', + 'SCHEMA', N'dbo', + 'TABLE', N'sj_workflow_task_batch' +GO + diff --git a/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java b/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java new file mode 100644 index 00000000..bb07fa25 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.job; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ContinewAdminJobApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/continew-admin-extension/pom.xml b/continew-admin-extension/pom.xml new file mode 100644 index 00000000..486ac555 --- /dev/null +++ b/continew-admin-extension/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + top.continew + continew-admin + ${revision} + + + continew-admin-extension + pom + 扩展模块(存放其他扩展模块) + + + + continew-admin-job-server + + diff --git a/continew-admin-plugins/continew-admin-job/pom.xml b/continew-admin-plugins/continew-admin-job/pom.xml new file mode 100644 index 00000000..a0080350 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + top.continew + continew-admin-plugins + ${revision} + + + continew-admin-job + jar + + continew-admin-job + http://maven.apache.org + + + UTF-8 + + + + + + top.continew + continew-starter-log-httptrace-pro + + + + + top.continew + continew-admin-common + + + + + org.springframework + spring-webflux + + + + io.projectreactor.netty + reactor-netty-http + 1.1.18 + + + + diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java new file mode 100644 index 00000000..59a9252b --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.config.http; + +import io.netty.channel.ChannelOption; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.handler.timeout.WriteTimeoutHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.web.reactive.function.client.ClientRequest; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.support.WebClientAdapter; +import org.springframework.web.service.invoker.HttpServiceProxyFactory; +import reactor.netty.http.client.HttpClient; +import top.continew.admin.job.constant.JobConstants; + +/** + * HTTPClint配置器 + * + * @author KAI + * @since 2024/6/25 18:03:18 + */ +@Configuration(proxyBeanMethods = false) +@RequiredArgsConstructor +public class HttpInterfaceConfig { + //snail-job服务端地址 + @Value("${snail-job.server.url}") + private String jobServerUrl; + + //snail-job 命名空间 + @Value("${snail-job.namespace}") + private String namespace; + + private final TokenHolder tokenHolder; + + @Bean + JobApi jobApi() { + return createApi(JobApi.class); + } + + @Bean + JobBatchApi jobBatchApi() { + return createApi(JobBatchApi.class); + } + + private T createApi(Class apiClass) { + HttpClient httpClient = HttpClient.create() + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)//连接时间 + .doOnConnected(conn -> { + conn.addHandlerLast(new ReadTimeoutHandler(10));//读超时 + conn.addHandlerLast(new WriteTimeoutHandler(10));//写超时 + }); + WebClient webClient = WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .filter((request, next) -> { + ClientRequest filtered = ClientRequest.from(request) + .header(JobConstants.SNAIL_JOB_NAMESPACE_ID_HEADER, namespace) + .header(JobConstants.SNAIL_JOB_AUTH_HEADER, tokenHolder.getToken()) + .build(); + return next.exchange(filtered); + }) + .baseUrl(jobServerUrl) + .build(); + + return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build().createClient(apiClass); + } + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java new file mode 100644 index 00000000..1e3d1de3 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.config.http; + +import com.alibaba.fastjson.JSONObject; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.service.annotation.*; +import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.req.JobReq; +import top.continew.admin.job.model.req.JobStatusReq; + +import java.util.List; + +/** + * 任务调度远程调用API + * + * @author KAI + * @since 2024/6/25 18:20:18 + */ +@HttpExchange +public interface JobApi { + + @GetExchange("/group/all/group-name/list") + ResponseEntity>> getAllGroupNameList(); + + @GetExchange("/job/page/list") + ResponseEntity getJobPage(@RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "jobStatus", required = false) Integer jobStatus, + @RequestParam("page") int page, + @RequestParam("size") int size); + + @PostExchange(value = "/job", accept = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity> saveJob(@RequestBody @Validated JobReq jobRequestVO); + + @PutExchange(value = "/job", accept = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity> updateJob(@RequestBody @Validated JobReq jobRequestVO); + + @DeleteExchange("/job/{id}") + ResponseEntity> deleteJobById(@PathVariable("id") Long id); + + @PostExchange("/job/trigger/{jobId}") + ResponseEntity> trigger(@PathVariable("jobId") Long jobId); + + @PutExchange("/job/status") + ResponseEntity> updateJobStatus(@RequestBody @Validated JobStatusReq jobStatusReq); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java new file mode 100644 index 00000000..5e78ca9c --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.config.http; + +import com.alibaba.fastjson.JSONObject; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.HttpExchange; +import org.springframework.web.service.annotation.PostExchange; +import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.resp.JobLogResp; + +import java.time.LocalDateTime; + +/** + * 任务批次远程调用API + * + * @author KAI + * @since 2024/6/27 23:03:23 + */ +@HttpExchange(url = "/job") +public interface JobBatchApi { + @GetExchange("/batch/list") + ResponseEntity getJobBatchPage(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "groupName", required = false) String groupName, + @RequestParam(value = "taskBatchStatus", required = false) Integer taskBatchStatus, + @RequestParam(value = "datetimeRange", required = false) LocalDateTime[] datetimeRange, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); + + @GetExchange("/batch/{id}") + ResponseEntity> getJobBatchDetail(@PathVariable("id") Long id); + + @PostExchange("/batch/stop/{taskBatchId}") + ResponseEntity> stop(@PathVariable("taskBatchId") Long taskBatchId); + + @PostExchange("/batch/retry/{taskBatchId}") + ResponseEntity> retry(@PathVariable("taskBatchId") Long taskBatchId); + + @GetExchange("/task/list") + ResponseEntity getJobTaskPage(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java new file mode 100644 index 00000000..7edcf409 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.config.http; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import top.continew.admin.job.constant.JobConstants; +import top.continew.admin.job.model.resp.JobUserResp; +import top.continew.starter.cache.redisson.util.RedisUtils; + +import java.time.Duration; +import java.util.HashMap; + +/** + * TokenHolder + * + * @author KAI + * @since 2024/6/25 18:18:59 + */ +@Component +public class TokenHolder { + //snail-job服务端地址 + @Value("${snail-job.server.url}") + private String jobServerUrl; + //snail-job服务端用户名 + @Value("${snail-job.server.username}") + private String username; + //snail-job服务端密码 + @Value("${snail-job.server.password}") + private String password; + + /** + * 获取token + */ + public String getToken() { + String token = RedisUtils.get(JobConstants.SNAIL_JOB_AUTH_HEADER); + if (StrUtil.isBlank(token)) { + HashMap paramMap = new HashMap<>(); + paramMap.put("username", username); + paramMap.put("password", SecureUtil.md5(password)); + String post = HttpUtil.post(jobServerUrl + "/auth/login", JSONObject.toJSONString(paramMap)); + JSONObject jsonObject = JSONObject.parseObject(post); + if (jsonObject.getIntValue("status") != 1) { + throw new SecurityException(jsonObject.getString("message")); + } + + JSONObject data = jsonObject.getJSONObject("data"); + JobUserResp userResp = JSONObject.parseObject(data.toJSONString(), JobUserResp.class); + token = userResp.getToken(); + RedisUtils.set(JobConstants.SNAIL_JOB_AUTH_HEADER, token, Duration.ofHours(1)); + } + return token; + } + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java new file mode 100644 index 00000000..5c68c028 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.constant; + +/** + * Job常量 + * + * @author KAI + * @since 2024/6/26 9:19:09 + */ +public class JobConstants { + public static final String SNAIL_JOB_NAMESPACE_ID_HEADER = "SNAIL-JOB-NAMESPACE-ID"; + public static final String SNAIL_JOB_AUTH_HEADER = "Snail-Job-Auth"; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java new file mode 100644 index 00000000..8726fc35 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * Job服务端返回对象 + * + * @author KAI + * @since 2024/6/26 22:27:2 + */ +@Data +public class JobResult { + @JsonProperty("data") + private T data; + private boolean success; + private String message; + private int code; + private int status; + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java new file mode 100644 index 00000000..1de4283b --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.query; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 任务日志查询条件 + * + * @author KAI + * @since 2024/6/27 23:58:12 + */ +@Data +@Schema(description = "任务日志查询条件") +public class JobLogQuery { + + @Schema(description = "任务ID") + private Long jobId; + + @Schema(description = "任务名称") + private String jobName; + + @Schema(description = "任务批次状态") + private Integer taskBatchStatus; + + @Schema(description = "任务组名称") + private String groupName; + + @Schema(description = "开始时间") + private String startTime; + + @Schema(description = "结束时间时间") + private String endTime; +} \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java new file mode 100644 index 00000000..043b66b2 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.query; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 定时任务查询条件 + * + * @author KAI + * @since 2024/6/25 16:43:15 + */ +@Data +@Schema(description = "定时任务查询条件") +public class JobQuery { + + @Schema(description = "任务名称") + private String jobName; + + @Schema(description = "任务状态") + private Integer jobStatus; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java new file mode 100644 index 00000000..eba6716f --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.query; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 任务实例查询条件 + * + * @author KAI + * @since 2024/6/28 16:58:21 + */ +@Data +@Schema(description = "任务实例查询条件") +public class JobTaskQuery { + + @Schema(description = "任务ID") + private Long jobId; + + @Schema(description = "任务批次ID") + private Long taskBatchId; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java new file mode 100644 index 00000000..ba4dfc2f --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import lombok.Data; + +/** + * 定时任务信息 + * + * @author KAI + * @since 2024/6/25 16:40:11 + */ +@Data +@Schema(description = "定时任务信息") +public class JobReq { + + @Schema(description = "任务ID") + private Long id; + + /** + * 组名称 + */ + @NotBlank(message = "groupName 不能为空") + @Pattern(regexp = "^[A-Za-z0-9_-]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母、下划线和短横线") + @Schema(description = "组名称") + private String groupName; + + /** + * 名称 + */ + @NotBlank(message = "jobName 不能为空") + @Schema(description = "任务名称") + private String jobName; + + /** + * 任务状态 0、关闭、1、开启 + */ + @NotNull(message = "jobStatus 不能为空") + @Schema(description = "任务状态") + private Integer jobStatus; + + /** + * 执行方法参数 + */ + @Schema(description = "执行方法参数") + private String argsStr; + + /** + * 参数类型 text/json + */ + @Schema(description = "参数类型", example = "text/json") + private Integer argsType; + + /** + * 执行器路由策略 + */ + @NotNull(message = "routeKey 不能为空") + @Schema(description = "执行器路由策略") + private Integer routeKey; + + /** + * 执行器类型 1、Java + */ + @NotNull(message = "executorType 不能为空") + @Schema(description = "执行器类型 1、Java") + private Integer executorType; + + /** + * 执行器名称 + */ + @NotBlank(message = "executorInfo 不能为空") + @Schema(description = "执行器名称") + private String executorInfo; + + /** + * 触发类型 2. 固定时间 3.CRON 表达式 99.工作流 + */ + @NotNull(message = "triggerType 不能为空") + private Integer triggerType; + + /** + * 间隔时长 + */ + @NotNull(message = "triggerInterval 不能为空") + @Schema(description = "触发类型 2. 固定时间 3.CRON 表达式 99.工作流") + private String triggerInterval; + + /** + * 阻塞策略 1、丢弃 2、覆盖 3、并行 + */ + @NotNull(message = "blockStrategy 不能为空") + @Schema(description = "阻塞策略 1、丢弃 2、覆盖 3、并行") + private Integer blockStrategy; + + /** + * 任务执行超时时间,单位秒 + */ + @NotNull(message = "executorTimeout 不能为空") + @Schema(description = "任务执行超时时间") + private Integer executorTimeout; + + /** + * 最大重试次数 + */ + @NotNull(message = "maxRetryTimes 不能为空") + @Schema(description = "最大重试次数") + private Integer maxRetryTimes; + + /** + * 重试间隔(s) + */ + @NotNull(message = "retryInterval 不能为空") + @Schema(description = "重试间隔") + private Integer retryInterval; + + /** + * 任务类型 + */ + @NotNull(message = "taskType 不能为空") + @Schema(description = "任务类型") + private Integer taskType; + + /** + * 并行数 + */ + @NotNull(message = "parallelNum 不能为空") + @Schema(description = "并行书") + private Integer parallelNum; + + /** + * 描述 + */ + @Schema(description = "描述") + private String description; + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java new file mode 100644 index 00000000..89b87041 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * 修改定时任务信息 + * + * @author KAI + * @since 2024/6/27 9:24:09 + */ +@Data +@Schema(description = "修改定时任务信息") +public class JobStatusReq { + @Schema(description = "任务ID") + @NotNull(message = "id不能为空") + private Long id; + + @Schema(description = "任务状态 1.开启 0.关闭") + @NotNull(message = "任务状态不能为空") + private Integer jobStatus; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java new file mode 100644 index 00000000..1322a9c1 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * 定时任务登录用户信息 + * + * @author KAI + * @since 2024/6/26 9:15:09 + */ +@Data +@Schema(description = "定时任务登录用户信息") +public class JobUserReq { + + @NotBlank(message = "用户名不能为空", groups = PostMapping.class) + @Schema(description = "用户名") + private String username; + + @NotBlank(message = "密码不能为空", groups = PostMapping.class) + @Schema(description = "密码") + private String password; + +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java new file mode 100644 index 00000000..0f9cc7ea --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 任务批次信息 + * + * @author KAI + * @since 2024/6/27 22:50:12 + */ +@Data +@Schema(description = "任务日志信息") +public class JobLogResp { + + @Schema(description = "主键id") + private Long id; + + /** + * 组名称 + */ + @Schema(description = "组名称") + private String groupName; + + /** + * 名称 + */ + @Schema(description = "名称") + private String jobName; + + /** + * 工作流节点名称 + */ + @Schema(description = "工作流节点名称") + private String nodeName; + + /** + * 任务信息id + */ + @Schema(description = "任务信息id") + private Long jobId; + + /** + * 任务状态 + */ + @Schema(description = "任务状态") + private Integer taskBatchStatus; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + private Date createDt; + + /** + * 任务执行时间 + */ + @Schema(description = "任务执行时间") + private Date executionAt; + /** + * 操作原因 + */ + @Schema(description = "操作原因") + private Integer operationReason; + + /** + * 执行器类型 1、Java + */ + @Schema(description = "执行器类型 1、Java") + private Integer executorType; + + /** + * 执行器名称 + */ + @Schema(description = "执行器名称") + private String executorInfo; + + // /** + // * 工作流的回调节点信息 + // */ + // @Schema(description = "工作流的回调节点信息") + // private CallbackConfig callback; + + // /** + // * 工作流的决策节点信息 + // */ + // @Schema(description = "工作流的决策节点信息") + // private DecisionConfig decision; + + /** + * 工作流批次id + */ + @Schema(description = "工作流批次id") + private Long workflowTaskBatchId; + + /** + * 工作流节点id + */ + @Schema(description = "工作流节点id") + private Long workflowNodeId; +} \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java new file mode 100644 index 00000000..a6610ef5 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 任务信息 + * + * @author KAI + * @since 2024/6/25 17:15:23 + */ +@Data +@Schema(description = "任务信息") +public class JobResp { + @Schema(description = "组名称") + private Long id; + + /** + * 组名称 + */ + @Schema(description = "组名称") + private String groupName; + + /** + * 名称 + */ + @Schema(description = "任务名称") + private String jobName; + + /** + * 执行方法参数 + */ + @Schema(description = "执行方法参数") + private String argsStr; + + /** + * 参数类型 text/json + */ + @Schema(description = "参数类型", example = "text/json") + private String argsType; + + /** + * 扩展字段 + */ + @Schema(description = "扩展字段") + private String extAttrs; + + /** + * 下次触发时间 + */ + @Schema(description = "下次触发时间") + private Date nextTriggerAt; + + /** + * 重试状态 0、关闭、1、开启 + */ + @Schema(description = "任务状态") + private Integer jobStatus; + + /** + * 执行器路由策略 + */ + @Schema(description = "执行器路由策略") + private Integer routeKey; + + /** + * 执行器类型 1、Java + */ + @Schema(description = " 执行器类型 1、Java") + private Integer executorType; + + /** + * 执行器名称 + */ + @Schema(description = "执行器名称") + private String executorInfo; + + /** + * 触发类型 1.CRON 表达式 2. 固定时间 + */ + @Schema(description = "触发类型 1.CRON 表达式 2. 固定时间") + private Integer triggerType; + + /** + * 间隔时长 + */ + @Schema(description = "间隔时长") + private String triggerInterval; + + /** + * 阻塞策略 1、丢弃 2、覆盖 3、并行 + */ + @Schema(description = "阻塞策略 1、丢弃 2、覆盖 3、并行") + private Integer blockStrategy; + + /** + * 任务执行超时时间,单位秒 + */ + @Schema(description = "任务执行超时时间") + private Integer executorTimeout; + + /** + * 最大重试次数 + */ + @Schema(description = "最大重试次数") + private Integer maxRetryTimes; + + /** + * 重试间隔(s) + */ + @Schema(description = "重试间隔") + private Integer retryInterval; + + /** + * 任务类型 + */ + @Schema(description = "任务类型") + private Integer taskType; + + /** + * 并行数 + */ + @Schema(description = "并行数") + private Integer parallelNum; + + /** + * bucket + */ + @Schema(description = "bucket") + private Integer bucketIndex; + + /** + * 描述 + */ + @Schema(description = "描述") + private String description; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + private Date createDt; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + private Date updateDt; + + /** + * 逻辑删除 1、删除 + */ + @Schema(description = "逻辑删除") + private Integer deleted; + +} \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java new file mode 100644 index 00000000..63784b3a --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 任务实例返回对象 + * + * @author KAI + * @since 2024/6/28 下午16:58:33 + */ +@Schema(description = "任务实例返回") +@Data +public class JobTaskResp { + @Schema(description = "ID") + private Long id; + + @Schema(description = "Key") + private Long key; + + /** + * 组名称 + */ + @Schema(description = "组名称") + private String groupName; + + /** + * 任务信息id + */ + @Schema(description = "任务信息 ID") + private Long jobId; + + /** + * 调度任务id + */ + @Schema(description = "调度任务 ID") + private Long taskBatchId; + + /** + * 父执行器id + */ + @Schema(description = "父执行器 ID") + private Long parentId; + + /** + * 执行的状态 0、失败 1、成功 + */ + @Schema(description = "执行状态 (0: 失败, 1: 成功)") + private Integer taskStatus; + + /** + * 重试次数 + */ + @Schema(description = "重试次数") + private Integer retryCount; + + /** + * 执行结果 + */ + @Schema(description = "执行结果") + private String resultMessage; + + /** + * 客户端ID + */ + @Schema(description = "客户端 ID") + private String clientInfo; + + /** + * 执行方法参数 + */ + @Schema(description = "执行方法参数") + private String argsStr; + + /** + * 参数类型 text/json + */ + @Schema(description = "参数类型 (text/json)") + private String argsType; + + /** + * 扩展字段 + */ + @Schema(description = "扩展字段") + private String extAttrs; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + private LocalDateTime createDt; + + /** + * 修改时间 + */ + @Schema(description = "修改时间") + private LocalDateTime updateDt; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java new file mode 100644 index 00000000..3c45e196 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 任务用户登录返回信息 + * + * @author KAI + * @since 2024/6/26 9:13:12 + */ +@Data +@Schema(description = "任务用户登录返回信息") +public class JobUserResp { + @Schema(description = "用户ID") + private Long id; + + @Schema(description = "用户名") + private String username; + + @Schema(description = "角色") + private Integer role; + + @Schema(description = "认证凭证") + private String token; + + @Schema(description = "创建时间") + private LocalDateTime createDt; + + @Schema(description = "修改时间") + private LocalDateTime updateDt; + + @Schema(description = "模式") + private String mode; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java new file mode 100644 index 00000000..943ba7eb --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.starter.extension.crud.model.query.PageQuery; + +/** + * 任务日志API接口类 + * + * @author KAI + * @since 2024/6/27 22:52:22 + */ +public interface JobLogService { + + Page getJobLogPage(JobLogQuery jobQuery, PageQuery pageQuery); + + JobLogResp getJobLogDetail(Long id); + + boolean stop(Long taskBatchId); + + Boolean retry(Long taskBatchId); + + Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java new file mode 100644 index 00000000..43cccba3 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import top.continew.admin.job.model.query.JobQuery; +import top.continew.admin.job.model.req.JobReq; +import top.continew.admin.job.model.req.JobStatusReq; +import top.continew.admin.job.model.resp.JobResp; +import top.continew.starter.extension.crud.model.query.PageQuery; + +import java.util.List; + +/** + * @author KAI + * @since 2024/6/25 17:20:17 + */ +public interface JobService { + Page page(JobQuery jobQuery, PageQuery pageQuery); + + boolean addJob(JobReq jobReq); + + boolean updateJob(JobReq jobReq); + + boolean deleteJob(Long id); + + List getGroupList(); + + boolean triggerJob(Long id); + + boolean updateJobStatus(JobStatusReq req); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java new file mode 100644 index 00000000..7c71615b --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import top.continew.admin.job.config.http.JobBatchApi; +import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.service.JobLogService; +import top.continew.starter.core.exception.BaseException; +import top.continew.starter.extension.crud.model.query.PageQuery; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * 任务日志服务实现 + * + * @author KAI + * @since 2024/6/27 22:54:10 + */ +@Service +@RequiredArgsConstructor +public class JobLogServiceImpl implements JobLogService { + + private final JobBatchApi jobBatchApi; + private final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + @Override + public Page getJobLogPage(JobLogQuery jobQuery, PageQuery pageQuery) { + LocalDateTime[] localDateTimes = new LocalDateTime[2]; + if (jobQuery != null && jobQuery.getStartTime() != null && jobQuery.getEndTime() != null) { + localDateTimes[0] = LocalDateTime.parse(jobQuery.getStartTime(), FORMATTER); + localDateTimes[1] = LocalDateTime.parse(jobQuery.getEndTime(), FORMATTER); + } + ResponseEntity entity = jobBatchApi.getJobBatchPage(jobQuery.getJobId(), jobQuery + .getJobName(), jobQuery.getGroupName(), jobQuery.getTaskBatchStatus(), localDateTimes, pageQuery + .getPage(), pageQuery.getSize()); + // 校验请求返回的数据 + JSONObject body = checkResponseEntity(entity); + if (body == null) { + return new Page<>(); + } + // 获取返回的数据 + JSONArray data = body.getJSONArray("data"); + if (data == null) { + return new Page<>(); + } + // 数据转化 + List jobRespList = JSONObject.parseArray(data.toJSONString(), JobLogResp.class); + // 构建分页对象 + Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body + .getIntValue("total")); + page.setRecords(jobRespList); + return page; + } + + @Override + public JobLogResp getJobLogDetail(Long id) { + ResponseEntity> entity = jobBatchApi.getJobBatchDetail(id); + JobResult result = checkResponseEntity(entity); + return result.getData(); + } + + @Override + public boolean stop(Long taskBatchId) { + ResponseEntity> entity = jobBatchApi.stop(taskBatchId); + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + @Override + public Boolean retry(Long taskBatchId) { + ResponseEntity> entity = jobBatchApi.retry(taskBatchId); + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + @Override + public Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { + ResponseEntity entity = jobBatchApi.getJobTaskPage(jobTaskQuery.getJobId(), jobTaskQuery + .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); + // 校验请求返回的数据 + JSONObject body = checkResponseEntity(entity); + if (body == null) { + return new Page<>(); + } + // 获取返回的数据 + JSONArray data = body.getJSONArray("data"); + if (data == null) { + return new Page<>(); + } + // 数据转化 + List jobTaskRespList = JSONObject.parseArray(data.toJSONString(), JobTaskResp.class); + // 构建分页对象 + Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body + .getIntValue("total")); + page.setRecords(jobTaskRespList); + return page; + } + + private T checkResponseEntity(ResponseEntity entity) { + if (!entity.getStatusCode().is2xxSuccessful()) { + throw new BaseException("连接定时任务服务器异常"); + } + return entity.getBody(); + } +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java new file mode 100644 index 00000000..e422d0f6 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import top.continew.admin.job.config.http.JobApi; +import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.query.JobQuery; +import top.continew.admin.job.model.req.JobReq; +import top.continew.admin.job.model.req.JobStatusReq; +import top.continew.admin.job.model.resp.JobResp; +import top.continew.admin.job.service.JobService; +import top.continew.starter.core.exception.BaseException; +import top.continew.starter.extension.crud.model.query.PageQuery; + +import java.util.List; +import java.util.Objects; + +/** + * 任务调度服务实现 + * + * @author KAI + * @since 2024/6/25 17:25:30 + */ + +@Service +@RequiredArgsConstructor +public class JobServiceImpl implements JobService { + + private final JobApi jobApi; + + /** + * 任务分页查询 + * + * @param jobQuery 查询参数 + * @param pageQuery 分页参数 + * @return 分页信息 + */ + @Override + public Page page(JobQuery jobQuery, PageQuery pageQuery) { + ResponseEntity entity = jobApi.getJobPage(jobQuery.getJobName(), jobQuery.getJobStatus(), pageQuery + .getPage(), pageQuery.getSize()); + // 校验请求返回的数据 + JSONObject body = checkResponseEntity(entity); + if (body == null) { + return new Page<>(); + } + // 获取返回的数据 + JSONArray data = body.getJSONArray("data"); + if (data == null) { + return new Page<>(); + } + // 数据转化 + List jobRespList = JSONObject.parseArray(data.toJSONString(), JobResp.class); + // 构建分页对象 + Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body.getIntValue("total")); + page.setRecords(jobRespList); + return page; + } + + /** + * 新增任务 + * + * @param jobReq 任务信息 + * @return 结果 true or false + */ + @Override + public boolean addJob(JobReq jobReq) { + ResponseEntity> entity = jobApi.saveJob(jobReq); + // 校验请求返回的数据 + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + /** + * 修改任务 + * + * @param jobReq 任务信息 + * @return 结果 true or false + */ + @Override + public boolean updateJob(JobReq jobReq) { + ResponseEntity> entity = jobApi.updateJob(jobReq); + // 校验请求返回的数据 + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + /** + * 删除任务 + * + * @param id 任务ID + * @return 结果 true or false + */ + @Override + public boolean deleteJob(Long id) { + ResponseEntity> entity = jobApi.deleteJobById(id); + // 校验请求返回的数据 + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + /** + * 查询任务列表 + * + * @return 组名称数组 ["continew_admin"] + */ + @Override + public List getGroupList() { + ResponseEntity>> entity = jobApi.getAllGroupNameList(); + // 校验请求返回的数据 + JobResult> result = checkResponseEntity(entity); + return Objects.requireNonNull(result.getData()); + } + + /** + * 执行任务 + * + * @param id 任务ID + * @return 结果 true or false + */ + @Override + public boolean triggerJob(Long id) { + ResponseEntity> entity = jobApi.trigger(id); + // 校验请求返回的数据 + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + /** + * 修改任务状态 + * + * @param req 修改任务状态参数 + * @return 结果 true or false + */ + @Override + public boolean updateJobStatus(JobStatusReq req) { + ResponseEntity> entity = jobApi.updateJobStatus(req); + // 校验请求返回的数据 + JobResult result = checkResponseEntity(entity); + return Boolean.TRUE.equals(result.getData()); + } + + private T checkResponseEntity(ResponseEntity entity) { + if (!entity.getStatusCode().is2xxSuccessful()) { + throw new BaseException("连接定时任务服务器异常"); + } + return entity.getBody(); + } +} \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java b/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java new file mode 100644 index 00000000..feee09e6 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java @@ -0,0 +1,38 @@ +package top.continew; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/continew-admin-plugins/pom.xml b/continew-admin-plugins/pom.xml index fcdb848f..db22cca0 100644 --- a/continew-admin-plugins/pom.xml +++ b/continew-admin-plugins/pom.xml @@ -15,6 +15,7 @@ continew-admin-generator + continew-admin-job diff --git a/continew-admin-webapi/pom.xml b/continew-admin-webapi/pom.xml index 31a77954..982a224d 100644 --- a/continew-admin-webapi/pom.xml +++ b/continew-admin-webapi/pom.xml @@ -13,6 +13,8 @@ API 及打包部署模块 + + 1.1.0-beta1 top.continew.admin.ContiNewAdminApplication @@ -43,11 +45,35 @@ continew-admin-generator + + + top.continew + continew-admin-job + + top.continew continew-admin-system + + + com.aizuda + snail-job-client-starter + ${snail-job-version} + + + + com.aizuda + snail-job-client-retry-core + ${snail-job-version} + + + + com.aizuda + snail-job-client-job-core + ${snail-job-version} + diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java index 79764610..e957acba 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java @@ -20,6 +20,7 @@ import cn.dev33.satoken.annotation.SaIgnore; import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.extra.spring.SpringUtil; +import com.aizuda.snailjob.client.starter.EnableSnailJob; import com.alicp.jetcache.anno.config.EnableMethodCache; import com.github.xiaoymin.knife4j.spring.configuration.Knife4jProperties; import io.swagger.v3.oas.annotations.Hidden; @@ -45,6 +46,7 @@ import top.continew.starter.web.annotation.EnableGlobalExceptionHandler; */ @Slf4j @RestController +@EnableSnailJob @EnableFileStorage @SpringBootApplication @RequiredArgsConstructor diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java new file mode 100644 index 00000000..5dce29ec --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.controller.job; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import top.continew.admin.job.model.query.JobQuery; +import top.continew.admin.job.model.req.JobReq; +import top.continew.admin.job.model.req.JobStatusReq; +import top.continew.admin.job.model.resp.JobResp; +import top.continew.admin.job.service.JobService; +import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; +import top.continew.starter.log.core.annotation.Log; +import top.continew.starter.web.model.R; + +import java.util.List; + +/** + * 任务调度管理 + * + * @author KAI + * @since 2024/6/25 下午22:24 + */ +@Log(module = "任务调度管理") +@Tag(name = " 任务调度管理 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/system/job") +public class JobController { + + private final JobService jobService; + + @GetMapping("/page") + @Operation(summary = "分页查询任务列表", description = "分页查询任务列表") + public R> getJobPage(JobQuery jobQuery, PageQuery pageQuery) { + Page jobRespPage = jobService.page(jobQuery, pageQuery); + //构建返回对象 + PageResp pageResp = PageResp.build(jobRespPage); + return R.ok(pageResp); + } + + @GetMapping("/groupList") + @Operation(summary = "获取任务分组列表", description = "获取任务分组列表") + public R> getGroupList() { + List groupList = jobService.getGroupList(); + return R.ok(groupList); + } + + @PostMapping + @Operation(summary = "新增任务", description = "新增任务") + public R addJob(@Validated @RequestBody JobReq jobReq) { + boolean flag = jobService.addJob(jobReq); + if (flag) { + return R.ok(); + } + return R.fail("新增任务失败"); + } + + @PutMapping + @Operation(summary = "修改任务", description = "修改任务") + public R updateJob(@Validated @RequestBody JobReq jobReq) { + boolean flag = jobService.updateJob(jobReq); + if (flag) { + return R.ok(); + } + return R.fail("修改任务失败"); + } + + @DeleteMapping("/{id}") + @Operation(summary = "删除任务", description = "删除任务") + public R deleteJob(@PathVariable Long id) { + boolean flag = jobService.deleteJob(id); + if (flag) { + return R.ok(); + } + return R.fail("删除任务失败"); + } + + @GetMapping("/trigger/{id}") + @Operation(summary = "执行任务", description = "执行任务") + public R triggerJob(@PathVariable Long id) { + boolean flag = jobService.triggerJob(id); + if (flag) { + return R.ok(); + } + return R.fail("执行任务失败"); + } + + @PutMapping("/status") + @Operation(summary = "修改任务状态", description = "修改任务状态") + public R updateJobStatus(@RequestBody JobStatusReq req) { + boolean flag = jobService.updateJobStatus(req); + if (flag) { + return R.ok(); + } + return R.fail("修改任务失败"); + } +} diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java new file mode 100644 index 00000000..efa70d37 --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.controller.job; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; +import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.service.JobLogService; +import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; +import top.continew.starter.log.core.annotation.Log; +import top.continew.starter.web.model.R; + +/** + * 任务日志管理 + * + * @author KAI + * @since 2024/6/27 22:24:11 + */ +@RestController +@RequestMapping("/system/job/log") +@RequiredArgsConstructor +@Log(module = "任务日志管理") +@Tag(description = "任务日志管理", name = "任务日志管理") +public class JobLogController { + private final JobLogService jobLogService; + + @GetMapping("/list") + @Operation(summary = "分页查询任务日志列表", description = "分页查询任务日志列表") + public R> getJobLogPage(JobLogQuery jobLogQuery, PageQuery pageQuery) { + Page jobBatchPage = jobLogService.getJobLogPage(jobLogQuery, pageQuery); + //构建返回对象 + PageResp pageResp = PageResp.build(jobBatchPage); + return R.ok(pageResp); + } + + @GetMapping("{id}") + @Operation(summary = "查询任务日志详情", description = "查询任务日志详情") + public R getJobLogDetail(@PathVariable("id") Long id) { + JobLogResp jobLogResp = jobLogService.getJobLogDetail(id); + return R.ok(jobLogResp); + } + + @PostMapping("/stop/{taskBatchId}") + @Operation(summary = "停止任务", description = "停止任务") + public R stop(@PathVariable("taskBatchId") Long taskBatchId) { + boolean flag = jobLogService.stop(taskBatchId); + if (flag) { + return R.ok(); + } + return R.fail("任务停止调用失败"); + } + + @PostMapping("/retry/{taskBatchId}") + @Operation(summary = "重试任务", description = "重试任务") + public R retry(@PathVariable("taskBatchId") Long taskBatchId) { + boolean flag = jobLogService.retry(taskBatchId); + if (flag) { + return R.ok(); + } + return R.fail("任务重试调用失败"); + } + + @GetMapping("/task/list") + @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") + public R> getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { + Page jobBatchPage = jobLogService.getTaskPage(jobTaskQuery, pageQuery); + //构建返回对象 + PageResp pageResp = PageResp.build(jobBatchPage); + return R.ok(pageResp); + } +} diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index 02da2755..b0d35a7a 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -286,3 +286,44 @@ spring.servlet: ## 头像支持格式配置 avatar: support-suffix: jpg,jpeg,png,gif +# 定时任务 +snail-job: + # 基础配置 + group: continew_admin + server: + username: admin + password: admin + url: http://127.0.0.1:8001/snail-job + host: 127.0.0.1 # 服务端的地址 + port: 1788 # 服务端netty的端口号 + host: 127.0.0.1 # 指定客户端IP + port: 1789 # 指定客户端端口 + namespace: kcRdQthJrBdiI3fsD4OqF2hJX1s24tlG # 名称空间ID + token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj # 令牌 + # 邮箱配置 + mail: + enabled: true # 开关 + host: xxx # SMTP服务器域名 + port: 465 # SMTP服务端口 + auth: true # 是否需要用户名密码验证 + user: demo # 用户名 + pass: xxxx # 密码 + from: xxx.qq.com # 发送方 + starttlsEnable: false # 使用 STARTTLS安全连接 + sslEnable: false # 使用 SSL安全连接 + timeout: 0 # SMTP超时时长 + connectionTimeout: 0 # Socket连接超时值 + # 重试数据批量上报滑动窗口配置 + retry: + reportSlidingWindow: + chrono-unit: seconds # 窗口期单位 + duration: 10 # 窗口期时间长度 + total-threshold: 50 # 总量窗口期阈值 + window-total-threshold: 150 # 窗口数量预警 + # 调度线程池配置 + dispatcherThreadPool: + corePoolSize: 16 # 核心线程数 + maximumPoolSize: 16 # 最大线程数 + keepAliveTime: 1 # 线程存活时间 + timeUnit: SECONDS # 时间单位 + queueCapacity: 10000 # 队列容量 \ No newline at end of file diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml index 50b1d9fc..1cf7c293 100644 --- a/continew-admin-webapi/src/main/resources/config/application-prod.yml +++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml @@ -283,3 +283,44 @@ spring.servlet: ## 头像支持格式配置 avatar: support-suffix: jpg,jpeg,png,gif +# 定时任务 +snail-job: + # 基础配置 + group: continew_admin + server: + username: admin + password: admin + url: http://127.0.0.1:8001/snail-job + host: 127.0.0.1 # 服务端的地址 + port: 1788 # 服务端netty的端口号 + host: 127.0.0.1 # 指定客户端IP + port: 1789 # 指定客户端端口 + namespace: kcRdQthJrBdiI3fsD4OqF2hJX1s24tlG # 名称空间ID + token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj # 令牌 + # 邮箱配置 + mail: + enabled: true # 开关 + host: xxx # SMTP服务器域名 + port: 465 # SMTP服务端口 + auth: true # 是否需要用户名密码验证 + user: demo # 用户名 + pass: xxxx # 密码 + from: xxx.qq.com # 发送方 + starttlsEnable: false # 使用 STARTTLS安全连接 + sslEnable: false # 使用 SSL安全连接 + timeout: 0 # SMTP超时时长 + connectionTimeout: 0 # Socket连接超时值 + # 重试数据批量上报滑动窗口配置 + retry: + reportSlidingWindow: + chrono-unit: seconds # 窗口期单位 + duration: 10 # 窗口期时间长度 + total-threshold: 50 # 总量窗口期阈值 + window-total-threshold: 150 # 窗口数量预警 + # 调度线程池配置 + dispatcherThreadPool: + corePoolSize: 16 # 核心线程数 + maximumPoolSize: 16 # 最大线程数 + keepAliveTime: 1 # 线程存活时间 + timeUnit: SECONDS # 时间单位 + queueCapacity: 10000 # 队列容量 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5714951b..57bb696d 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ continew-admin-plugins continew-admin-system continew-admin-common + continew-admin-extension @@ -65,6 +66,12 @@ continew-admin-common ${revision} + + + top.continew + continew-admin-job + ${revision} + -- Gitee From 035f8c8fb81f95656bcee9e68da87f6504e38538 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 2 Jul 2024 21:38:23 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E4=BC=98=E5=8C=96=20Jo?= =?UTF-8?q?b=20=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{job => tool}/JobController.java | 91 +++++++++++-------- .../{job => tool}/JobLogController.java | 68 +++++++------- 2 files changed, 86 insertions(+), 73 deletions(-) rename continew-admin-webapi/src/main/java/top/continew/admin/controller/{job => tool}/JobController.java (52%) rename continew-admin-webapi/src/main/java/top/continew/admin/controller/{job => tool}/JobLogController.java (52%) diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java similarity index 52% rename from continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java rename to continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java index 5dce29ec..921a85e3 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java @@ -14,10 +14,13 @@ * limitations under the License. */ -package top.continew.admin.controller.job; +package top.continew.admin.controller.tool; +import cn.dev33.satoken.annotation.SaCheckPermission; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; @@ -29,89 +32,99 @@ import top.continew.admin.job.model.resp.JobResp; import top.continew.admin.job.service.JobService; import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; -import top.continew.starter.log.core.annotation.Log; +import top.continew.starter.extension.crud.util.ValidateGroup; import top.continew.starter.web.model.R; import java.util.List; /** - * 任务调度管理 + * 任务调度 API * * @author KAI - * @since 2024/6/25 下午22:24 + * @author Charles7c + * @since 2024/6/25 22:24 */ -@Log(module = "任务调度管理") -@Tag(name = " 任务调度管理 API") +@Tag(name = " 任务调度 API") +@Validated @RestController @RequiredArgsConstructor -@RequestMapping("/system/job") +@RequestMapping("/job") public class JobController { - private final JobService jobService; + private final JobService baseService; - @GetMapping("/page") @Operation(summary = "分页查询任务列表", description = "分页查询任务列表") - public R> getJobPage(JobQuery jobQuery, PageQuery pageQuery) { - Page jobRespPage = jobService.page(jobQuery, pageQuery); - //构建返回对象 + @SaCheckPermission("tool:job:list") + @GetMapping + public R> page(JobQuery query, @Validated PageQuery pageQuery) { + Page jobRespPage = baseService.page(query, pageQuery); PageResp pageResp = PageResp.build(jobRespPage); return R.ok(pageResp); } - @GetMapping("/groupList") - @Operation(summary = "获取任务分组列表", description = "获取任务分组列表") - public R> getGroupList() { - List groupList = jobService.getGroupList(); - return R.ok(groupList); - } - - @PostMapping @Operation(summary = "新增任务", description = "新增任务") - public R addJob(@Validated @RequestBody JobReq jobReq) { - boolean flag = jobService.addJob(jobReq); + @SaCheckPermission("tool:job:add") + @PostMapping + public R add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody JobReq req) { + boolean flag = baseService.addJob(req); if (flag) { return R.ok(); } - return R.fail("新增任务失败"); + return R.fail(); } - @PutMapping @Operation(summary = "修改任务", description = "修改任务") - public R updateJob(@Validated @RequestBody JobReq jobReq) { - boolean flag = jobService.updateJob(jobReq); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:update") + @PutMapping("/{id}") + public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody JobReq req, @PathVariable Long id) { + boolean flag = baseService.updateJob(req); if (flag) { return R.ok(); } - return R.fail("修改任务失败"); + return R.fail(); } - @DeleteMapping("/{id}") @Operation(summary = "删除任务", description = "删除任务") - public R deleteJob(@PathVariable Long id) { - boolean flag = jobService.deleteJob(id); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:delete") + @DeleteMapping("/{id}") + public R delete(@PathVariable Long id) { + boolean flag = baseService.deleteJob(id); if (flag) { return R.ok(); } - return R.fail("删除任务失败"); + return R.fail(); } - @GetMapping("/trigger/{id}") @Operation(summary = "执行任务", description = "执行任务") - public R triggerJob(@PathVariable Long id) { - boolean flag = jobService.triggerJob(id); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:trigger") + @PostMapping("/trigger/{id}") + public R trigger(@PathVariable Long id) { + boolean flag = baseService.triggerJob(id); if (flag) { return R.ok(); } - return R.fail("执行任务失败"); + return R.fail(); } - @PutMapping("/status") @Operation(summary = "修改任务状态", description = "修改任务状态") - public R updateJobStatus(@RequestBody JobStatusReq req) { - boolean flag = jobService.updateJobStatus(req); + @SaCheckPermission("tool:job:update") + @PatchMapping("/{id}/status") + public R updateStatus(@Validated @RequestBody JobStatusReq req, @PathVariable Long id) { + boolean flag = baseService.updateJobStatus(req); if (flag) { return R.ok(); } - return R.fail("修改任务失败"); + return R.fail(); + } + + @Operation(summary = "查询任务分组列表", description = "查询任务分组列表") + @SaCheckPermission("tool:job:list") + @GetMapping("/group") + public R> listGroup() { + List groupList = baseService.getGroupList(); + return R.ok(groupList); } } diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java similarity index 52% rename from continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java rename to continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index efa70d37..d589fd02 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/job/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -14,79 +14,79 @@ * limitations under the License. */ -package top.continew.admin.controller.job; +package top.continew.admin.controller.tool; +import cn.dev33.satoken.annotation.SaCheckPermission; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.admin.job.service.JobLogService; import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; -import top.continew.starter.log.core.annotation.Log; import top.continew.starter.web.model.R; /** - * 任务日志管理 + * 任务调度日志 API * * @author KAI - * @since 2024/6/27 22:24:11 + * @author Charles7c + * @since 2024/6/27 22:24 */ +@Tag(name = " 任务调度日志 API") +@Validated @RestController -@RequestMapping("/system/job/log") @RequiredArgsConstructor -@Log(module = "任务日志管理") -@Tag(description = "任务日志管理", name = "任务日志管理") +@RequestMapping("/job/log") public class JobLogController { - private final JobLogService jobLogService; - @GetMapping("/list") + private final JobLogService baseService; + @Operation(summary = "分页查询任务日志列表", description = "分页查询任务日志列表") - public R> getJobLogPage(JobLogQuery jobLogQuery, PageQuery pageQuery) { - Page jobBatchPage = jobLogService.getJobLogPage(jobLogQuery, pageQuery); - //构建返回对象 + @SaCheckPermission("tool:job:log:list") + @GetMapping + public R> page(JobLogQuery query, @Validated PageQuery pageQuery) { + Page jobBatchPage = baseService.getJobLogPage(query, pageQuery); PageResp pageResp = PageResp.build(jobBatchPage); return R.ok(pageResp); } - @GetMapping("{id}") @Operation(summary = "查询任务日志详情", description = "查询任务日志详情") - public R getJobLogDetail(@PathVariable("id") Long id) { - JobLogResp jobLogResp = jobLogService.getJobLogDetail(id); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:log:detail") + @GetMapping("/{id}") + public R get(@PathVariable Long id) { + JobLogResp jobLogResp = baseService.getJobLogDetail(id); return R.ok(jobLogResp); } - @PostMapping("/stop/{taskBatchId}") @Operation(summary = "停止任务", description = "停止任务") - public R stop(@PathVariable("taskBatchId") Long taskBatchId) { - boolean flag = jobLogService.stop(taskBatchId); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:log:stop") + @PostMapping("/stop/{id}") + public R stop(@PathVariable Long id) { + boolean flag = baseService.stop(id); if (flag) { return R.ok(); } - return R.fail("任务停止调用失败"); + return R.fail(); } - @PostMapping("/retry/{taskBatchId}") @Operation(summary = "重试任务", description = "重试任务") - public R retry(@PathVariable("taskBatchId") Long taskBatchId) { - boolean flag = jobLogService.retry(taskBatchId); + @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) + @SaCheckPermission("tool:job:log:retry") + @PostMapping("/retry/{id}") + public R retry(@PathVariable Long id) { + boolean flag = baseService.retry(id); if (flag) { return R.ok(); } - return R.fail("任务重试调用失败"); - } - - @GetMapping("/task/list") - @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") - public R> getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { - Page jobBatchPage = jobLogService.getTaskPage(jobTaskQuery, pageQuery); - //构建返回对象 - PageResp pageResp = PageResp.build(jobBatchPage); - return R.ok(pageResp); + return R.fail(); } } -- Gitee From 8764e01dcc7df3964b6df43dc6972a2ab16da723 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 2 Jul 2024 21:39:17 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/config/application-dev.yml | 71 ++++++++++--------- .../resources/config/application-prod.yml | 71 ++++++++++--------- 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index b0d35a7a..aa3f975d 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -286,44 +286,45 @@ spring.servlet: ## 头像支持格式配置 avatar: support-suffix: jpg,jpeg,png,gif -# 定时任务 + +--- ### 任务调度配置 snail-job: - # 基础配置 + # 分组名 group: continew_admin + # 客户端地址(默认自动获取本机 IP) + #host: 127.0.0.1 + # 客户端端口(默认:1789) + port: 1789 + # 名称空间 ID + namespace: 764d604ec6fc45f68cd92514c40e9e1a + # 令牌 + token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj + ## 服务端配置 server: - username: admin - password: admin - url: http://127.0.0.1:8001/snail-job - host: 127.0.0.1 # 服务端的地址 - port: 1788 # 服务端netty的端口号 - host: 127.0.0.1 # 指定客户端IP - port: 1789 # 指定客户端端口 - namespace: kcRdQthJrBdiI3fsD4OqF2hJX1s24tlG # 名称空间ID - token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj # 令牌 - # 邮箱配置 - mail: - enabled: true # 开关 - host: xxx # SMTP服务器域名 - port: 465 # SMTP服务端口 - auth: true # 是否需要用户名密码验证 - user: demo # 用户名 - pass: xxxx # 密码 - from: xxx.qq.com # 发送方 - starttlsEnable: false # 使用 STARTTLS安全连接 - sslEnable: false # 使用 SSL安全连接 - timeout: 0 # SMTP超时时长 - connectionTimeout: 0 # Socket连接超时值 - # 重试数据批量上报滑动窗口配置 + # 服务端地址,若服务端集群部署则此处配置域名 + host: 127.0.0.1 + # 服务端端口号 + port: 1788 + ## 重试数据批量上报滑动窗口配置 retry: reportSlidingWindow: - chrono-unit: seconds # 窗口期单位 - duration: 10 # 窗口期时间长度 - total-threshold: 50 # 总量窗口期阈值 - window-total-threshold: 150 # 窗口数量预警 - # 调度线程池配置 + # 窗口期单位 + chrono-unit: SECONDS + # 窗口期时间长度 + duration: 10 + # 总量窗口期阈值 + total-threshold: 50 + # 窗口数量预警 + window-total-threshold: 150 + ## 调度线程池配置 dispatcherThreadPool: - corePoolSize: 16 # 核心线程数 - maximumPoolSize: 16 # 最大线程数 - keepAliveTime: 1 # 线程存活时间 - timeUnit: SECONDS # 时间单位 - queueCapacity: 10000 # 队列容量 \ No newline at end of file + # 核心线程数 + corePoolSize: 16 + # 最大线程数 + maximumPoolSize: 16 + # 线程存活时间 + keepAliveTime: 1 + # 时间单位 + timeUnit: SECONDS + # 队列容量 + queueCapacity: 10000 \ No newline at end of file diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml index 1cf7c293..9e815180 100644 --- a/continew-admin-webapi/src/main/resources/config/application-prod.yml +++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml @@ -283,44 +283,45 @@ spring.servlet: ## 头像支持格式配置 avatar: support-suffix: jpg,jpeg,png,gif -# 定时任务 + +--- ### 任务调度配置 snail-job: - # 基础配置 + # 分组名 group: continew_admin + # 客户端地址(默认自动获取本机 IP) + #host: 127.0.0.1 + # 客户端端口(默认:1789) + port: 1789 + # 名称空间 ID + namespace: 764d604ec6fc45f68cd92514c40e9e1a + # 令牌 + token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj + ## 服务端配置 server: - username: admin - password: admin - url: http://127.0.0.1:8001/snail-job - host: 127.0.0.1 # 服务端的地址 - port: 1788 # 服务端netty的端口号 - host: 127.0.0.1 # 指定客户端IP - port: 1789 # 指定客户端端口 - namespace: kcRdQthJrBdiI3fsD4OqF2hJX1s24tlG # 名称空间ID - token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj # 令牌 - # 邮箱配置 - mail: - enabled: true # 开关 - host: xxx # SMTP服务器域名 - port: 465 # SMTP服务端口 - auth: true # 是否需要用户名密码验证 - user: demo # 用户名 - pass: xxxx # 密码 - from: xxx.qq.com # 发送方 - starttlsEnable: false # 使用 STARTTLS安全连接 - sslEnable: false # 使用 SSL安全连接 - timeout: 0 # SMTP超时时长 - connectionTimeout: 0 # Socket连接超时值 - # 重试数据批量上报滑动窗口配置 + # 服务端地址,若服务端集群部署则此处配置域名 + host: 127.0.0.1 + # 服务端端口号 + port: 1788 + ## 重试数据批量上报滑动窗口配置 retry: reportSlidingWindow: - chrono-unit: seconds # 窗口期单位 - duration: 10 # 窗口期时间长度 - total-threshold: 50 # 总量窗口期阈值 - window-total-threshold: 150 # 窗口数量预警 - # 调度线程池配置 + # 窗口期单位 + chrono-unit: SECONDS + # 窗口期时间长度 + duration: 10 + # 总量窗口期阈值 + total-threshold: 50 + # 窗口数量预警 + window-total-threshold: 150 + ## 调度线程池配置 dispatcherThreadPool: - corePoolSize: 16 # 核心线程数 - maximumPoolSize: 16 # 最大线程数 - keepAliveTime: 1 # 线程存活时间 - timeUnit: SECONDS # 时间单位 - queueCapacity: 10000 # 队列容量 \ No newline at end of file + # 核心线程数 + corePoolSize: 16 + # 最大线程数 + maximumPoolSize: 16 + # 线程存活时间 + keepAliveTime: 1 + # 时间单位 + timeUnit: SECONDS + # 队列容量 + queueCapacity: 10000 \ No newline at end of file -- Gitee From c5d06576c5bd41d40d6267e5456644e30af890c1 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 2 Jul 2024 21:39:39 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../continew-admin-job/pom.xml | 29 ++++++-------- .../src/test/java/top/continew/AppTest.java | 38 ------------------- continew-admin-webapi/pom.xml | 35 ++++------------- pom.xml | 34 +++++++++++++---- 4 files changed, 46 insertions(+), 90 deletions(-) delete mode 100644 continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java diff --git a/continew-admin-plugins/continew-admin-job/pom.xml b/continew-admin-plugins/continew-admin-job/pom.xml index a0080350..cc5f8923 100644 --- a/continew-admin-plugins/continew-admin-job/pom.xml +++ b/continew-admin-plugins/continew-admin-job/pom.xml @@ -8,29 +8,24 @@ continew-admin-job - jar - - continew-admin-job - http://maven.apache.org - - - UTF-8 - + 任务调度插件 - + - top.continew - continew-starter-log-httptrace-pro + com.aizuda + snail-job-client-starter - - - top.continew - continew-admin-common + com.aizuda + snail-job-client-retry-core + + + com.aizuda + snail-job-client-job-core - + org.springframework spring-webflux @@ -39,8 +34,6 @@ io.projectreactor.netty reactor-netty-http - 1.1.18 - diff --git a/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java b/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java deleted file mode 100644 index feee09e6..00000000 --- a/continew-admin-plugins/continew-admin-job/src/test/java/top/continew/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package top.continew; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/continew-admin-webapi/pom.xml b/continew-admin-webapi/pom.xml index 982a224d..2e86f0f0 100644 --- a/continew-admin-webapi/pom.xml +++ b/continew-admin-webapi/pom.xml @@ -13,8 +13,6 @@ API 及打包部署模块 - - 1.1.0-beta1 top.continew.admin.ContiNewAdminApplication @@ -33,10 +31,10 @@ liquibase-core + - org.springframework.boot - spring-boot-starter-test - test + top.continew + continew-admin-system @@ -45,34 +43,17 @@ continew-admin-generator - + top.continew continew-admin-job + ${revision} - - - top.continew - continew-admin-system - - - com.aizuda - snail-job-client-starter - ${snail-job-version} - - - - com.aizuda - snail-job-client-retry-core - ${snail-job-version} - - - - com.aizuda - snail-job-client-job-core - ${snail-job-version} + org.springframework.boot + spring-boot-starter-test + test diff --git a/pom.xml b/pom.xml index 57bb696d..7cda4473 100644 --- a/pom.xml +++ b/pom.xml @@ -34,22 +34,34 @@ 3.1.0 + + 1.1.0-beta1 - + - top.continew - continew-admin-webapi - ${revision} + com.aizuda + snail-job-client-starter + ${snail-job.version} + + + com.aizuda + snail-job-client-retry-core + ${snail-job.version} + + + com.aizuda + snail-job-client-job-core + ${snail-job.version} - + top.continew - continew-admin-generator + continew-admin-webapi ${revision} @@ -66,7 +78,15 @@ continew-admin-common ${revision} - + + + + top.continew + continew-admin-generator + ${revision} + + + top.continew continew-admin-job -- Gitee From 6016bf52fd2f4dd557173e1b2ea40d06ef56383b Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 2 Jul 2024 22:12:02 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../continew-admin-job-server/pom.xml | 49 ++++++++--------- .../job/ContinewAdminJobApplication.java | 10 +++- .../main/resources/config/application-dev.yml | 42 ++++++++------ .../resources/config/application-prod.yml | 55 ++++++++----------- .../src/main/resources/config/application.yml | 18 ++++-- .../db/changelogs/db.changelog-master.yaml | 2 +- .../dm/{snail_job_dm8.sql => snail_job.sql} | 9 +-- .../{snail_job_mysql.sql => snail_job.sql} | 3 + .../{snail_job_oracle.sql => snail_job.sql} | 9 +-- .../snail_job.sql} | 9 +-- ...{snail_job_sqlserver.sql => snail_job.sql} | 9 +-- .../job/ContinewAdminJobApplicationTests.java | 29 ---------- continew-admin-webapi/pom.xml | 12 ++-- .../main/resources/config/application-dev.yml | 2 +- .../resources/config/application-prod.yml | 2 +- .../src/main/resources/config/application.yml | 2 + 16 files changed, 112 insertions(+), 150 deletions(-) rename continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/{ => admin/extension}/job/ContinewAdminJobApplication.java (88%) rename continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/{snail_job_dm8.sql => snail_job.sql} (99%) rename continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/{snail_job_mysql.sql => snail_job.sql} (99%) rename continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/{snail_job_oracle.sql => snail_job.sql} (99%) rename continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/{postgre/snail_job_postgre.sql => postgresql/snail_job.sql} (99%) rename continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/{snail_job_sqlserver.sql => snail_job.sql} (99%) delete mode 100644 continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java diff --git a/continew-admin-extension/continew-admin-job-server/pom.xml b/continew-admin-extension/continew-admin-job-server/pom.xml index f5481ae0..1ebbaa9c 100644 --- a/continew-admin-extension/continew-admin-job-server/pom.xml +++ b/continew-admin-extension/continew-admin-job-server/pom.xml @@ -10,52 +10,49 @@ continew-admin-job-server - 分布式 定时任务模块 + 任务调度服务模块 - - 1.1.0-beta1 + + 1.1.0-beta1 + + + com.aizuda + snail-job-server-starter + ${snail-job.version} + + + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + + + com.baomidou + dynamic-datasource-spring-boot3-starter + + org.liquibase liquibase-core + org.springframework.boot spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter - - org.springframework.boot spring-boot-starter-test test - - - com.aizuda - snail-job-server-starter - ${snail-job-version} - - - - com.baomidou - mybatis-plus-spring-boot3-starter - - - - com.baomidou - dynamic-datasource-spring-boot3-starter - - diff --git a/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java b/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/admin/extension/job/ContinewAdminJobApplication.java similarity index 88% rename from continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java rename to continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/admin/extension/job/ContinewAdminJobApplication.java index 7695411d..99d9ff8a 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/job/ContinewAdminJobApplication.java +++ b/continew-admin-extension/continew-admin-job-server/src/main/java/top/continew/admin/extension/job/ContinewAdminJobApplication.java @@ -14,17 +14,21 @@ * limitations under the License. */ -package top.continew.job; +package top.continew.admin.extension.job; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * 任务调度服务启动程序 + * + * @author KAI + * @since 2024/6/25 22:24 + */ @SpringBootApplication public class ContinewAdminJobApplication { public static void main(String[] args) { - //需要使用snailJobServer启动 SpringApplication.run(com.aizuda.snailjob.server.SnailJobServerApplication.class, args); } - } diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml index b44364ea..9565200f 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-dev.yml @@ -1,6 +1,7 @@ server: port: 8001 -# 数据源配置 + +--- ### 数据源配置 spring.datasource: type: com.zaxxer.hikari.HikariDataSource ## 动态数据源配置(可配多主多从:m1、s1...;纯粹多库:mysql、oracle...;混合配置:m1、s1、oracle...) @@ -36,24 +37,33 @@ spring.liquibase: # 配置文件路径 change-log: classpath:/db/changelogs/db.changelog-master.yaml ---- # snail-job 服务端配置 +--- ### Snail Job 服务端配置 snail-job: - # 拉取重试数据的每批次的大小 - retry-pull-page-size: 1000 - # 拉取重试数据的每批次的大小 - job-pull-page-size: 1000 - # 服务端netty端口 + # Netty 端口 netty-port: 1788 - # 一个客户端每秒最多接收的重试数量指令 - limiter: 1000 - # 号段模式下步长配置 - step: 100 - # 日志保存时间(单位: day) + # 合并日志默认保存天数 + merge-Log-days: 1 + # 合并日志默认的条数 + merge-Log-num: 500 + # 配置日志保存时间(单位:天) log-storage: 90 - # 回调配置 + # 配置每批次拉取重试数据的大小 + retry-pull-page-size: 100 + # 配置一个客户端每秒最多接收的重试数量指令 + limiter: 10 + # 配置号段模式下的步长 + step: 100 + # bucket 的总数量 + bucket-total: 128 + # Dashboard 任务容错天数 + summary-day: 7 + # 配置负载均衡周期时间 + load-balance-cycle-time: 10 + ## 回调配置 callback: - #回调最大执行次数 + # 回调 uniqueId 前缀 + prefix: CB + # 配置回调的最大执行次数 max-count: 288 - #间隔时间 + # 配置回调触发的间隔时间 trigger-interval: 900 - retry-max-pull-count: 10 \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml index 37331f9e..6bbc85b9 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application-prod.yml @@ -1,6 +1,7 @@ server: - port: 1788 -# 数据源配置 + port: 18001 + +--- ### 数据源配置 spring.datasource: type: com.zaxxer.hikari.HikariDataSource ## 动态数据源配置(可配多主多从:m1、s1...;纯粹多库:mysql、oracle...;混合配置:m1、s1、oracle...) @@ -36,45 +37,33 @@ spring.liquibase: # 配置文件路径 change-log: classpath:/db/changelogs/db.changelog-master.yaml ---- # snail-job 服务端配置 +--- ### Snail Job 服务端配置 snail-job: - # bucket的总数量 - bucket-total: 128 - callback: - # 配置回调的最大执行次数 - max-count: 288 - # 回调uniqueId前缀 - prefix: CB - # 配置回调触发的间隔时间 - trigger-interval: 900 - # 配置一个客户端每秒最多接收的重试数量指令 - limiter: 10 - # 配置负载均衡周期时间 - load-balance-cycle-time: 10 - # 配置日志保存时间(单位:天) - log-storage: 90 - # 配置邮件通知配置 - mail: - auth: true - connectionTimeout: 0 - enabled: true - from: xxx.qq.com - host: xxx - pass: xxxx - port: 465 - sslEnable: false - starttlsEnable: false - timeout: 0 - user: demo + # Netty 端口 + netty-port: 1788 # 合并日志默认保存天数 merge-Log-days: 1 # 合并日志默认的条数 merge-Log-num: 500 - # 服务端netty的端口号 - netty-port: 1788 + # 配置日志保存时间(单位:天) + log-storage: 90 # 配置每批次拉取重试数据的大小 retry-pull-page-size: 100 + # 配置一个客户端每秒最多接收的重试数量指令 + limiter: 10 # 配置号段模式下的步长 step: 100 + # bucket 的总数量 + bucket-total: 128 # Dashboard 任务容错天数 summary-day: 7 + # 配置负载均衡周期时间 + load-balance-cycle-time: 10 + ## 回调配置 + callback: + # 回调 uniqueId 前缀 + prefix: CB + # 配置回调的最大执行次数 + max-count: 288 + # 配置回调触发的间隔时间 + trigger-interval: 900 diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml index 0f29861c..a9613450 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml @@ -1,16 +1,22 @@ +--- ### Spring 配置 spring: application: - name: continew-admin-job - main: - allow-bean-definition-overriding: true + name: continew-admin-job-server + +--- ### MyBatis Plus 配置 mybatis-plus: + # 类型别名扫描包配置 typeAliasesPackage: com.aizuda.snailjob.template.datasource.persistence.po + ## MyBatis 配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: true + ## 全局配置 global-config: db-config: where-strategy: NOT_EMPTY capital-mode: false + # 逻辑删除全局值(默认 1,表示已删除) logic-delete-value: 1 + # 逻辑未删除全局值(默认 0,表示未删除) logic-not-delete-value: 0 - configuration: - map-underscore-to-camel-case: true - cache-enabled: true \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml index 8f656108..02f23397 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/db.changelog-master.yaml @@ -1,3 +1,3 @@ databaseChangeLog: - include: - file: db/changelogs/mysql/snail_job_mysql.sql + file: db/changelogs/mysql/snail_job.sql diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job.sql similarity index 99% rename from continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql rename to continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job.sql index 42498f78..5f0d4e40 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job_dm8.sql +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/dm/snail_job.sql @@ -1,11 +1,6 @@ -/* - SnailJob Database Transfer Tool - Source Server Type : MySQL - Target Server Type : DM8 - Date: 2024-06-01 00:26:12 -*/ - +-- liquibase formatted sql +-- changeset snail-job-server:1 -- sj_namespace CREATE TABLE sj_namespace ( diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job.sql similarity index 99% rename from continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql rename to continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job.sql index 1b11a298..8bff12f6 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job_mysql.sql +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/mysql/snail_job.sql @@ -1,3 +1,6 @@ +-- liquibase formatted sql + +-- changeset snail-job-server:1 SET NAMES utf8mb4; CREATE TABLE `sj_namespace` diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job.sql similarity index 99% rename from continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql rename to continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job.sql index 1a89e65e..76204ef7 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job_oracle.sql +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/oracle/snail_job.sql @@ -1,11 +1,6 @@ -/* - SnailJob Database Transfer Tool - Source Server Type : MySQL - Target Server Type : Oracle - Date: 2024-05-20 22:01:56 -*/ - +-- liquibase formatted sql +-- changeset snail-job-server:1 -- sj_namespace CREATE TABLE sj_namespace ( diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgresql/snail_job.sql similarity index 99% rename from continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql rename to continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgresql/snail_job.sql index 35cbbba3..45250036 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgre/snail_job_postgre.sql +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/postgresql/snail_job.sql @@ -1,11 +1,6 @@ -/* - SnailJob Database Transfer Tool - Source Server Type : MySQL - Target Server Type : PostgreSQL - Date: 2024-05-20 22:02:23 -*/ - +-- liquibase formatted sql +-- changeset snail-job-server:1 -- sj_namespace CREATE TABLE sj_namespace ( diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job.sql similarity index 99% rename from continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql rename to continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job.sql index b2c1b7aa..93efaa63 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job_sqlserver.sql +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/db/changelogs/sqlserver/snail_job.sql @@ -1,11 +1,6 @@ -/* - SnailJob Database Transfer Tool - Source Server Type : MySQL - Target Server Type : Microsoft SQL Server - Date: 2024-05-20 22:03:46 -*/ - +-- liquibase formatted sql +-- changeset snail-job-server:1 -- sj_namespace CREATE TABLE sj_namespace ( diff --git a/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java b/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java deleted file mode 100644 index bb07fa25..00000000 --- a/continew-admin-extension/continew-admin-job-server/src/test/java/top/continew/job/ContinewAdminJobApplicationTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.job; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ContinewAdminJobApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/continew-admin-webapi/pom.xml b/continew-admin-webapi/pom.xml index 2e86f0f0..afdbe8a1 100644 --- a/continew-admin-webapi/pom.xml +++ b/continew-admin-webapi/pom.xml @@ -25,12 +25,6 @@ - - - org.liquibase - liquibase-core - - top.continew @@ -50,6 +44,12 @@ ${revision} + + + org.liquibase + liquibase-core + + org.springframework.boot spring-boot-starter-test diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index aa3f975d..5208a7b8 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -287,7 +287,7 @@ spring.servlet: avatar: support-suffix: jpg,jpeg,png,gif ---- ### 任务调度配置 +--- ### Snail Job 配置 snail-job: # 分组名 group: continew_admin diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml index 9e815180..ca5e5c84 100644 --- a/continew-admin-webapi/src/main/resources/config/application-prod.yml +++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml @@ -284,7 +284,7 @@ spring.servlet: avatar: support-suffix: jpg,jpeg,png,gif ---- ### 任务调度配置 +--- ### Snail Job 配置 snail-job: # 分组名 group: continew_admin diff --git a/continew-admin-webapi/src/main/resources/config/application.yml b/continew-admin-webapi/src/main/resources/config/application.yml index ef4ac2ca..7e38f18e 100644 --- a/continew-admin-webapi/src/main/resources/config/application.yml +++ b/continew-admin-webapi/src/main/resources/config/application.yml @@ -122,10 +122,12 @@ mybatis-plus: mapper-locations: classpath*:/mapper/**/*Mapper.xml # 类型别名扫描包配置 type-aliases-package: ${project.base-package}.**.model + ## MyBatis 配置 configuration: # MyBatis 自动映射策略 # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 auto-mapping-behavior: PARTIAL + ## 全局配置 global-config: banner: true db-config: -- Gitee From 92cf993b781fd3d3ef2ba6b50fe4cf68d8cfa2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E5=87=AF?= <1373639299@qq.com> Date: Thu, 4 Jul 2024 00:29:54 +0800 Subject: [PATCH 06/21] =?UTF-8?q?feat:=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/config/http/HttpInterfaceConfig.java | 35 ++++++------ .../admin/job/config/http/JobBatchApi.java | 5 -- .../admin/job/config/http/JobTaskApi.java | 23 ++++++++ .../admin/job/config/http/TokenHolder.java | 8 +++ .../admin/job/service/JobLogService.java | 6 +-- .../admin/job/service/JobService.java | 2 + .../admin/job/service/JobTaskService.java | 17 ++++++ .../job/service/impl/JobLogServiceImpl.java | 33 +----------- .../job/service/impl/JobServiceImpl.java | 11 ++-- .../job/service/impl/JobTaskServiceImpl.java | 53 +++++++++++++++++++ .../controller/tool/JobLogController.java | 3 +- .../controller/tool/JobTaskController.java | 41 ++++++++++++++ .../main/resources/config/application-dev.yml | 6 +++ .../resources/config/application-prod.yml | 6 +++ .../db/changelog/mysql/conrinew-admin_job.sql | 11 ++++ 15 files changed, 195 insertions(+), 65 deletions(-) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java create mode 100644 continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java create mode 100644 continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java index 59a9252b..216eeb4d 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java @@ -60,24 +60,29 @@ public class HttpInterfaceConfig { return createApi(JobBatchApi.class); } + @Bean + JobTaskApi jobTaskApi() { + return createApi(JobTaskApi.class); + } + private T createApi(Class apiClass) { HttpClient httpClient = HttpClient.create() - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)//连接时间 - .doOnConnected(conn -> { - conn.addHandlerLast(new ReadTimeoutHandler(10));//读超时 - conn.addHandlerLast(new WriteTimeoutHandler(10));//写超时 - }); + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)//连接时间 + .doOnConnected(conn -> { + conn.addHandlerLast(new ReadTimeoutHandler(10));//读超时 + conn.addHandlerLast(new WriteTimeoutHandler(10));//写超时 + }); WebClient webClient = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(httpClient)) - .filter((request, next) -> { - ClientRequest filtered = ClientRequest.from(request) - .header(JobConstants.SNAIL_JOB_NAMESPACE_ID_HEADER, namespace) - .header(JobConstants.SNAIL_JOB_AUTH_HEADER, tokenHolder.getToken()) - .build(); - return next.exchange(filtered); - }) - .baseUrl(jobServerUrl) - .build(); + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .filter((request, next) -> { + ClientRequest filtered = ClientRequest.from(request) + .header(JobConstants.SNAIL_JOB_NAMESPACE_ID_HEADER, namespace) + .header(JobConstants.SNAIL_JOB_AUTH_HEADER, tokenHolder.getToken()) + .build(); + return next.exchange(filtered); + }) + .baseUrl(jobServerUrl) + .build(); return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build().createClient(apiClass); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java index 5e78ca9c..80e13d71 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java @@ -54,10 +54,5 @@ public interface JobBatchApi { @PostExchange("/batch/retry/{taskBatchId}") ResponseEntity> retry(@PathVariable("taskBatchId") Long taskBatchId); - @GetExchange("/task/list") - ResponseEntity getJobTaskPage(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "size") Integer size); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java new file mode 100644 index 00000000..7249ee86 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java @@ -0,0 +1,23 @@ +package top.continew.admin.job.config.http; + +import com.alibaba.fastjson.JSONObject; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.HttpExchange; + +/** + * 任务实例API远程调用 + * + * @author KAI + * @since 2024/7/4 上午00:07:31 + */ +@HttpExchange(url = "/job") +public interface JobTaskApi { + + @GetExchange("/task/list") + ResponseEntity getJobTaskPage(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java index 7edcf409..a51ab1c7 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java @@ -21,10 +21,12 @@ import cn.hutool.crypto.SecureUtil; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSONObject; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import top.continew.admin.job.constant.JobConstants; import top.continew.admin.job.model.resp.JobUserResp; import top.continew.starter.cache.redisson.util.RedisUtils; +import top.continew.starter.core.exception.BaseException; import java.time.Duration; import java.util.HashMap; @@ -70,4 +72,10 @@ public class TokenHolder { return token; } + public static T checkResponseEntity(ResponseEntity entity) { + if (!entity.getStatusCode().is2xxSuccessful()) { + throw new BaseException("连接定时任务服务器异常"); + } + return entity.getBody(); + } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java index 943ba7eb..87d984c9 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java @@ -18,13 +18,11 @@ package top.continew.admin.job.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.starter.extension.crud.model.query.PageQuery; /** - * 任务日志API接口类 + * 任务日志API接口 * * @author KAI * @since 2024/6/27 22:52:22 @@ -38,6 +36,4 @@ public interface JobLogService { boolean stop(Long taskBatchId); Boolean retry(Long taskBatchId); - - Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java index 43cccba3..0d997c5a 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java @@ -26,6 +26,8 @@ import top.continew.starter.extension.crud.model.query.PageQuery; import java.util.List; /** + * 任务服务API接口 + * * @author KAI * @since 2024/6/25 17:20:17 */ diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java new file mode 100644 index 00000000..26428bc6 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java @@ -0,0 +1,17 @@ +package top.continew.admin.job.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.starter.extension.crud.model.query.PageQuery; + +/** + * 任务实例API接口 + * + * @author KAI + * @since 2024/7/4 00:03:10 + */ +public interface JobTaskService { + + Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index 7c71615b..cb945db3 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -25,9 +25,7 @@ import org.springframework.stereotype.Service; import top.continew.admin.job.config.http.JobBatchApi; import top.continew.admin.job.model.JobResult; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.admin.job.service.JobLogService; import top.continew.starter.core.exception.BaseException; import top.continew.starter.extension.crud.model.query.PageQuery; @@ -36,6 +34,8 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; + /** * 任务日志服务实现 * @@ -99,33 +99,4 @@ public class JobLogServiceImpl implements JobLogService { return Boolean.TRUE.equals(result.getData()); } - @Override - public Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { - ResponseEntity entity = jobBatchApi.getJobTaskPage(jobTaskQuery.getJobId(), jobTaskQuery - .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); - // 校验请求返回的数据 - JSONObject body = checkResponseEntity(entity); - if (body == null) { - return new Page<>(); - } - // 获取返回的数据 - JSONArray data = body.getJSONArray("data"); - if (data == null) { - return new Page<>(); - } - // 数据转化 - List jobTaskRespList = JSONObject.parseArray(data.toJSONString(), JobTaskResp.class); - // 构建分页对象 - Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body - .getIntValue("total")); - page.setRecords(jobTaskRespList); - return page; - } - - private T checkResponseEntity(ResponseEntity entity) { - if (!entity.getStatusCode().is2xxSuccessful()) { - throw new BaseException("连接定时任务服务器异常"); - } - return entity.getBody(); - } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index e422d0f6..00d251b8 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -29,12 +29,13 @@ import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; import top.continew.admin.job.service.JobService; -import top.continew.starter.core.exception.BaseException; import top.continew.starter.extension.crud.model.query.PageQuery; import java.util.List; import java.util.Objects; +import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; + /** * 任务调度服务实现 * @@ -58,7 +59,7 @@ public class JobServiceImpl implements JobService { @Override public Page page(JobQuery jobQuery, PageQuery pageQuery) { ResponseEntity entity = jobApi.getJobPage(jobQuery.getJobName(), jobQuery.getJobStatus(), pageQuery - .getPage(), pageQuery.getSize()); + .getPage(), pageQuery.getSize()); // 校验请求返回的数据 JSONObject body = checkResponseEntity(entity); if (body == null) { @@ -160,10 +161,4 @@ public class JobServiceImpl implements JobService { return Boolean.TRUE.equals(result.getData()); } - private T checkResponseEntity(ResponseEntity entity) { - if (!entity.getStatusCode().is2xxSuccessful()) { - throw new BaseException("连接定时任务服务器异常"); - } - return entity.getBody(); - } } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java new file mode 100644 index 00000000..573dbcc1 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java @@ -0,0 +1,53 @@ +package top.continew.admin.job.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import top.continew.admin.job.config.http.JobTaskApi; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.service.JobTaskService; +import top.continew.starter.extension.crud.model.query.PageQuery; + +import java.util.List; + +import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; + +/** + * 任务实例实现 + * + * @author KAI + * @since 2024/7/4 00:04:12 + */ +@Service +@RequiredArgsConstructor +public class JobTaskServiceImpl implements JobTaskService { + + private final JobTaskApi jobTaskApi; + + @Override + public Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { + ResponseEntity entity = jobTaskApi.getJobTaskPage(jobTaskQuery.getJobId(), jobTaskQuery + .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); + // 校验请求返回的数据 + JSONObject body = checkResponseEntity(entity); + if (body == null) { + return new Page<>(); + } + // 获取返回的数据 + JSONArray data = body.getJSONArray("data"); + if (data == null) { + return new Page<>(); + } + // 数据转化 + List jobTaskRespList = JSONObject.parseArray(data.toJSONString(), JobTaskResp.class); + // 构建分页对象 + Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body + .getIntValue("total")); + page.setRecords(jobTaskRespList); + return page; + } +} diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index d589fd02..d8a205e2 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -80,7 +80,7 @@ public class JobLogController { @Operation(summary = "重试任务", description = "重试任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:log:retry") + @SaCheckPermission("tool:job:log:retry") @PostMapping("/retry/{id}") public R retry(@PathVariable Long id) { boolean flag = baseService.retry(id); @@ -89,4 +89,5 @@ public class JobLogController { } return R.fail(); } + } diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java new file mode 100644 index 00000000..c574086c --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java @@ -0,0 +1,41 @@ +package top.continew.admin.controller.tool; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.service.JobTaskService; +import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; +import top.continew.starter.web.model.R; + +/** + * 任务实例控制层 + * + * @author KAI + * @since 2024/7/4 00:02:21 + */ +@Tag(name = "任务实例 API") +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping("/job/task") +public class JobTaskController { + + private final JobTaskService baseService; + + @GetMapping + @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") + public R> page(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { + Page jobBatchPage = baseService.getTaskPage(jobTaskQuery, pageQuery); + //构建返回对象 + PageResp pageResp = PageResp.build(jobBatchPage); + return R.ok(pageResp); + } +} diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index 5208a7b8..387257dc 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -301,6 +301,12 @@ snail-job: token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj ## 服务端配置 server: + #服务端地址 + url: http://127.0.0.1:8001/snail-job + #服务端用户名 + username: admin + #服务端密码 + password: admin # 服务端地址,若服务端集群部署则此处配置域名 host: 127.0.0.1 # 服务端端口号 diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml index ca5e5c84..2fa73c82 100644 --- a/continew-admin-webapi/src/main/resources/config/application-prod.yml +++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml @@ -298,6 +298,12 @@ snail-job: token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj ## 服务端配置 server: + #服务端地址 + url: http://127.0.0.1:8001/snail-job + #服务端用户名 + username: admin + #服务端密码 + password: admin # 服务端地址,若服务端集群部署则此处配置域名 host: 127.0.0.1 # 服务端端口号 diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql new file mode 100644 index 00000000..1797e243 --- /dev/null +++ b/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql @@ -0,0 +1,11 @@ +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599024956302442500, '任务调度', 3000, 2, '/tool/jobCenter', 'ToolJobCenter', 'tool/job/index', NULL, 'clock-circle', b'0', b'1', b'0', NULL, 1, 1, 1, '2024-07-03 23:51:19', 1, '2024-07-03 23:53:56'); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599025355029757959, '任务日志', 599024956302442500, 2, '/tool/job/log', 'ToolJobLog', 'tool/job/log/index', NULL, 'unfold', b'0', b'0', b'1', NULL, 999, 1, 1, '2024-07-03 23:52:54', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033131265179666, '查看', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:list', 999, 1, 1, '2024-07-04 00:23:48', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033201607852053, '新增', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:add', 999, 1, 1, '2024-07-04 00:24:05', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033265134780440, '修改', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:update', 999, 1, 1, '2024-07-04 00:24:20', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033360517447707, '删除', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:delete', 999, 1, 1, '2024-07-04 00:24:43', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033414682689566, '执行', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:trigger', 999, 1, 1, '2024-07-04 00:24:56', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033600721043489, '查看', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:list', 999, 1, 1, '2024-07-04 00:25:40', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033667355951140, '详情', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:detail', 999, 1, 1, '2024-07-04 00:25:56', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033762495348775, '停止', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:stop', 999, 1, 1, '2024-07-04 00:26:18', NULL, NULL); +INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033840782032938, '重试', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:retry', 999, 1, 1, '2024-07-04 00:26:37', NULL, NULL); -- Gitee From 0b7287a3a5fd7127a7c711a1578dc5c600d6a9e3 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 9 Jul 2024 22:49:10 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/{config/http => api}/JobApi.java | 56 ++++--- .../top/continew/admin/job/api/JobClient.java | 151 ++++++++++++++++++ ...ig.java => HttpExchangeConfiguration.java} | 77 +++++---- .../job/config/{http => }/JobBatchApi.java | 11 +- .../job/config/{http => }/JobTaskApi.java | 18 ++- .../admin/job/config/http/TokenHolder.java | 45 +----- .../admin/job/constant/JobConstants.java | 19 ++- .../{JobResult.java => JobPageResult.java} | 28 ++-- .../admin/job/model/query/JobQuery.java | 21 ++- .../admin/job/service/JobService.java | 17 +- .../admin/job/service/JobTaskService.java | 16 ++ .../job/service/impl/JobLogServiceImpl.java | 17 +- .../job/service/impl/JobServiceImpl.java | 78 ++------- .../job/service/impl/JobTaskServiceImpl.java | 22 ++- .../admin/controller/tool/JobController.java | 9 +- .../controller/tool/JobLogController.java | 2 +- .../controller/tool/JobTaskController.java | 16 ++ .../main/resources/config/application-dev.yml | 6 +- .../resources/config/application-prod.yml | 6 +- .../db/changelog/mysql/conrinew-admin_job.sql | 11 -- .../changelog/mysql/continew-admin_data.sql | 17 +- 21 files changed, 412 insertions(+), 231 deletions(-) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/{config/http => api}/JobApi.java (42%) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/{http/HttpInterfaceConfig.java => HttpExchangeConfiguration.java} (51%) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/{http => }/JobBatchApi.java (85%) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/{http => }/JobTaskApi.java (55%) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/{JobResult.java => JobPageResult.java} (68%) delete mode 100644 continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java similarity index 42% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java index 1e3d1de3..20b30ee8 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package top.continew.admin.job.config.http; +package top.continew.admin.job.api; -import com.alibaba.fastjson.JSONObject; +import com.aizuda.snailjob.common.core.model.Result; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; @@ -24,42 +24,52 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.service.annotation.*; -import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.JobPageResult; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; +import top.continew.admin.job.model.resp.JobResp; import java.util.List; /** - * 任务调度远程调用API + * 任务 REST API * * @author KAI - * @since 2024/6/25 18:20:18 + * @since 2024/6/25 18:20 */ -@HttpExchange +@HttpExchange("/job") public interface JobApi { - @GetExchange("/group/all/group-name/list") - ResponseEntity>> getAllGroupNameList(); + /** + * 分页查询任务列表 + * + * @param jobName 任务名称 + * @param jobStatus 任务状态 + * @param page 页码 + * @param size 每页条数 + * @return 响应信息 + */ + @GetExchange("/page/list") + ResponseEntity>> getJobPage(@RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "jobStatus", required = false) Integer jobStatus, + @RequestParam("page") int page, + @RequestParam("size") int size); - @GetExchange("/job/page/list") - ResponseEntity getJobPage(@RequestParam(value = "jobName", required = false) String jobName, - @RequestParam(value = "jobStatus", required = false) Integer jobStatus, - @RequestParam("page") int page, - @RequestParam("size") int size); + @GetExchange("/group/all/group-name/list") + ResponseEntity>> getAllGroupNameList(); - @PostExchange(value = "/job", accept = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> saveJob(@RequestBody @Validated JobReq jobRequestVO); + @PostExchange(accept = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity> saveJob(@RequestBody @Validated JobReq jobRequestVO); - @PutExchange(value = "/job", accept = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> updateJob(@RequestBody @Validated JobReq jobRequestVO); + @PutExchange(accept = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity> updateJob(@RequestBody @Validated JobReq jobRequestVO); - @DeleteExchange("/job/{id}") - ResponseEntity> deleteJobById(@PathVariable("id") Long id); + @DeleteExchange("/{id}") + ResponseEntity> deleteJobById(@PathVariable("id") Long id); - @PostExchange("/job/trigger/{jobId}") - ResponseEntity> trigger(@PathVariable("jobId") Long jobId); + @PostExchange("/trigger/{jobId}") + ResponseEntity> trigger(@PathVariable("jobId") Long jobId); - @PutExchange("/job/status") - ResponseEntity> updateJobStatus(@RequestBody @Validated JobStatusReq jobStatusReq); + @PutExchange("/status") + ResponseEntity> updateJobStatus(@RequestBody @Validated JobStatusReq jobStatusReq); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java new file mode 100644 index 00000000..3d167709 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.api; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import cn.hutool.jwt.JWTUtil; +import cn.hutool.jwt.RegisteredPayload; +import com.aizuda.snailjob.common.core.model.Result; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import top.continew.admin.job.constant.JobConstants; +import top.continew.admin.job.model.JobPageResult; +import top.continew.starter.cache.redisson.util.RedisUtils; +import top.continew.starter.extension.crud.model.resp.PageResp; + +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + +/** + * 任务调度客户端 + * + * @author Charles7c + * @since 2024/7/4 23:07 + */ +@Data +@Slf4j +public class JobClient { + + private final String url; + + private final String username; + + private final String password; + + public JobClient(String url, String username, String password) { + Assert.notBlank(url, "任务调度服务 URL 不能为空"); + Assert.notBlank(username, "任务调度服务用户名不能为空"); + Assert.notBlank(password, "任务调度服务密码不能为空"); + this.url = url; + this.username = username; + this.password = password; + } + + /** + * 请求 + * + * @param apiSupplier API 请求 + * @param 响应类型 + * @return 响应信息 + */ + public T request(Supplier>> apiSupplier) { + try { + ResponseEntity> responseEntity = apiSupplier.get(); + if (!responseEntity.getStatusCode().is2xxSuccessful()) { + throw new IllegalStateException("连接任务调度服务器错误"); + } + Result result = responseEntity.getBody(); + if (result.getStatus() != 1) { + throw new IllegalStateException(result.getMessage()); + } + return result.getData(); + } catch (Exception e) { + log.error("Request job server failed, error msg: {}", e.getMessage(), e); + throw new IllegalStateException(e); + } + } + + /** + * 分页请求 + * + * @param apiSupplier API 请求 + * @param 响应类型 + * @return 分页信息 + */ + public PageResp requestPage(Supplier>>> apiSupplier) { + try { + ResponseEntity>> responseEntity = apiSupplier.get(); + if (!responseEntity.getStatusCode().is2xxSuccessful()) { + throw new IllegalStateException("连接任务调度服务器错误"); + } + JobPageResult> result = responseEntity.getBody(); + PageResp page = new PageResp<>(); + page.setList(result.getData()); + page.setTotal(result.getTotal()); + return page; + } catch (Exception e) { + log.error("Request job server failed, error msg: {}", e.getMessage(), e); + throw new IllegalStateException(e); + } + } + + /** + * 获取 Token + * + * @return Token + */ + public String getToken() { + // 登录 + String token = RedisUtils.get(JobConstants.AUTH_TOKEN_HEADER); + if (StrUtil.isBlank(token)) { + token = this.authenticate(); + Object expiresAtSeconds = JWTUtil.parseToken(token).getPayload(RegisteredPayload.EXPIRES_AT); + RedisUtils.set(JobConstants.AUTH_TOKEN_HEADER, token, Duration.ofSeconds(Convert + .toLong(expiresAtSeconds) - DateUtil.currentSeconds() - 60)); + } + return token; + } + + /** + * 密码认证 + * + * @return Token + */ + private String authenticate() { + Map paramMap = MapUtil.newHashMap(2); + paramMap.put("username", username); + paramMap.put("password", SecureUtil.md5(password)); + String responseStr = HttpUtil.post("%s/auth/login".formatted(url), JSONUtil.toJsonStr(paramMap)); + JSONObject response = JSONUtil.parseObj(responseStr); + if (response.getInt("status") != 1) { + throw new IllegalStateException("Password Authentication failed, expected a successful response. error msg: %s" + .formatted(response.getStr("message"))); + } + return Convert.toStr(response.getByPath("data.token")); + } +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java similarity index 51% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java index 216eeb4d..7568bfeb 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/HttpInterfaceConfig.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.job.config.http; +package top.continew.admin.job.config; import io.netty.channel.ChannelOption; import io.netty.handler.timeout.ReadTimeoutHandler; @@ -29,62 +29,73 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.support.WebClientAdapter; import org.springframework.web.service.invoker.HttpServiceProxyFactory; import reactor.netty.http.client.HttpClient; +import top.continew.admin.job.api.JobApi; +import top.continew.admin.job.api.JobClient; import top.continew.admin.job.constant.JobConstants; /** - * HTTPClint配置器 + * HTTP Exchange 配置 * * @author KAI - * @since 2024/6/25 18:03:18 + * @author Charles7c + * @since 2024/6/25 18:03 */ -@Configuration(proxyBeanMethods = false) +@Configuration @RequiredArgsConstructor -public class HttpInterfaceConfig { - //snail-job服务端地址 +public class HttpExchangeConfiguration { + @Value("${snail-job.server.url}") - private String jobServerUrl; + private String baseUrl; - //snail-job 命名空间 @Value("${snail-job.namespace}") private String namespace; - private final TokenHolder tokenHolder; + @Value("${snail-job.server.username}") + private String username; + + @Value("${snail-job.server.password}") + private String password; @Bean - JobApi jobApi() { - return createApi(JobApi.class); + public JobApi jobApi() { + return httpServiceProxyFactory().createClient(JobApi.class); } @Bean - JobBatchApi jobBatchApi() { - return createApi(JobBatchApi.class); + public JobBatchApi jobBatchApi() { + return httpServiceProxyFactory().createClient(JobBatchApi.class); } @Bean - JobTaskApi jobTaskApi() { - return createApi(JobTaskApi.class); + public JobTaskApi jobTaskApi() { + return httpServiceProxyFactory().createClient(JobTaskApi.class); } - private T createApi(Class apiClass) { + @Bean + public HttpServiceProxyFactory httpServiceProxyFactory() { HttpClient httpClient = HttpClient.create() - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)//连接时间 - .doOnConnected(conn -> { - conn.addHandlerLast(new ReadTimeoutHandler(10));//读超时 - conn.addHandlerLast(new WriteTimeoutHandler(10));//写超时 - }); + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000) + .doOnConnected(conn -> { + conn.addHandlerLast(new ReadTimeoutHandler(10)); + conn.addHandlerLast(new WriteTimeoutHandler(10)); + }); WebClient webClient = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(httpClient)) - .filter((request, next) -> { - ClientRequest filtered = ClientRequest.from(request) - .header(JobConstants.SNAIL_JOB_NAMESPACE_ID_HEADER, namespace) - .header(JobConstants.SNAIL_JOB_AUTH_HEADER, tokenHolder.getToken()) - .build(); - return next.exchange(filtered); - }) - .baseUrl(jobServerUrl) - .build(); - - return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build().createClient(apiClass); + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .filter((request, next) -> { + // 设置请求头 + ClientRequest filtered = ClientRequest.from(request) + .header(JobConstants.NAMESPACE_ID_HEADER, namespace) + .header(JobConstants.AUTH_TOKEN_HEADER, jobClient().getToken()) + .build(); + return next.exchange(filtered); + }) + .baseUrl(baseUrl) + .build(); + return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build(); } + @Bean + public JobClient jobClient() { + return new JobClient(baseUrl, username, password); + } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java similarity index 85% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java index 80e13d71..3d0499ce 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobBatchApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.job.config.http; +package top.continew.admin.job.config; import com.alibaba.fastjson.JSONObject; import org.springframework.http.ResponseEntity; @@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.service.annotation.GetExchange; import org.springframework.web.service.annotation.HttpExchange; import org.springframework.web.service.annotation.PostExchange; -import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.model.JobPageResult; import top.continew.admin.job.model.resp.JobLogResp; import java.time.LocalDateTime; @@ -46,13 +46,12 @@ public interface JobBatchApi { @RequestParam(value = "size") Integer size); @GetExchange("/batch/{id}") - ResponseEntity> getJobBatchDetail(@PathVariable("id") Long id); + ResponseEntity> getJobBatchDetail(@PathVariable("id") Long id); @PostExchange("/batch/stop/{taskBatchId}") - ResponseEntity> stop(@PathVariable("taskBatchId") Long taskBatchId); + ResponseEntity> stop(@PathVariable("taskBatchId") Long taskBatchId); @PostExchange("/batch/retry/{taskBatchId}") - ResponseEntity> retry(@PathVariable("taskBatchId") Long taskBatchId); - + ResponseEntity> retry(@PathVariable("taskBatchId") Long taskBatchId); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java similarity index 55% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java index 7249ee86..63b38749 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/JobTaskApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java @@ -1,4 +1,20 @@ -package top.continew.admin.job.config.http; +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.config; import com.alibaba.fastjson.JSONObject; import org.springframework.http.ResponseEntity; diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java index a51ab1c7..b83abd74 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java @@ -16,21 +16,10 @@ package top.continew.admin.job.config.http; -import cn.hutool.core.util.StrUtil; -import cn.hutool.crypto.SecureUtil; -import cn.hutool.http.HttpUtil; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import top.continew.admin.job.constant.JobConstants; -import top.continew.admin.job.model.resp.JobUserResp; -import top.continew.starter.cache.redisson.util.RedisUtils; import top.continew.starter.core.exception.BaseException; -import java.time.Duration; -import java.util.HashMap; - /** * TokenHolder * @@ -39,40 +28,8 @@ import java.util.HashMap; */ @Component public class TokenHolder { - //snail-job服务端地址 - @Value("${snail-job.server.url}") - private String jobServerUrl; - //snail-job服务端用户名 - @Value("${snail-job.server.username}") - private String username; - //snail-job服务端密码 - @Value("${snail-job.server.password}") - private String password; - - /** - * 获取token - */ - public String getToken() { - String token = RedisUtils.get(JobConstants.SNAIL_JOB_AUTH_HEADER); - if (StrUtil.isBlank(token)) { - HashMap paramMap = new HashMap<>(); - paramMap.put("username", username); - paramMap.put("password", SecureUtil.md5(password)); - String post = HttpUtil.post(jobServerUrl + "/auth/login", JSONObject.toJSONString(paramMap)); - JSONObject jsonObject = JSONObject.parseObject(post); - if (jsonObject.getIntValue("status") != 1) { - throw new SecurityException(jsonObject.getString("message")); - } - - JSONObject data = jsonObject.getJSONObject("data"); - JobUserResp userResp = JSONObject.parseObject(data.toJSONString(), JobUserResp.class); - token = userResp.getToken(); - RedisUtils.set(JobConstants.SNAIL_JOB_AUTH_HEADER, token, Duration.ofHours(1)); - } - return token; - } - public static T checkResponseEntity(ResponseEntity entity) { + public static T checkResponseEntity(ResponseEntity entity) { if (!entity.getStatusCode().is2xxSuccessful()) { throw new BaseException("连接定时任务服务器异常"); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java index 5c68c028..ec644334 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/constant/JobConstants.java @@ -17,12 +17,23 @@ package top.continew.admin.job.constant; /** - * Job常量 + * 任务调度常量 * * @author KAI - * @since 2024/6/26 9:19:09 + * @since 2024/6/26 9:19 */ public class JobConstants { - public static final String SNAIL_JOB_NAMESPACE_ID_HEADER = "SNAIL-JOB-NAMESPACE-ID"; - public static final String SNAIL_JOB_AUTH_HEADER = "Snail-Job-Auth"; + + /** + * 请求头:命名空间 ID + */ + public static final String NAMESPACE_ID_HEADER = "SNAIL-JOB-NAMESPACE-ID"; + + /** + * 请求头:认证令牌 + */ + public static final String AUTH_TOKEN_HEADER = "Snail-Job-Auth"; + + private JobConstants() { + } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java similarity index 68% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java index 8726fc35..4e78feba 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobResult.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java @@ -16,22 +16,30 @@ package top.continew.admin.job.model; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.aizuda.snailjob.common.core.model.Result; import lombok.Data; /** - * Job服务端返回对象 + * 任务调度服务端分页返回对象 * * @author KAI - * @since 2024/6/26 22:27:2 + * @since 2024/6/26 22:27 */ @Data -public class JobResult { - @JsonProperty("data") - private T data; - private boolean success; - private String message; - private int code; - private int status; +public class JobPageResult extends Result { + /** + * 页码 + */ + private long page; + + /** + * 每页条数 + */ + private long size; + + /** + * 总条数 + */ + private long total; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java index 043b66b2..b9b8bd26 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java @@ -20,18 +20,25 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** - * 定时任务查询条件 + * 任务查询条件 * * @author KAI - * @since 2024/6/25 16:43:15 + * @author Charles7c + * @since 2024/6/25 16:43 */ @Data -@Schema(description = "定时任务查询条件") +@Schema(description = "任务查询条件") public class JobQuery { - @Schema(description = "任务名称") - private String jobName; + /** + * 名称 + */ + @Schema(description = "名称") + private String name; - @Schema(description = "任务状态") - private Integer jobStatus; + /** + * 状态 + */ + @Schema(description = "状态") + private Integer status; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java index 0d997c5a..2ec6b70e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java @@ -16,23 +16,32 @@ package top.continew.admin.job.service; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import top.continew.admin.job.model.query.JobQuery; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; /** - * 任务服务API接口 + * 任务业务接口 * * @author KAI - * @since 2024/6/25 17:20:17 + * @author Charles7c + * @since 2024/6/25 17:20 */ public interface JobService { - Page page(JobQuery jobQuery, PageQuery pageQuery); + + /** + * 分页查询列表 + * + * @param query 查询条件 + * @param pageQuery 分页查询条件 + * @return 分页列表信息 + */ + PageResp page(JobQuery query, PageQuery pageQuery); boolean addJob(JobReq jobReq); diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java index 26428bc6..9d8d8eac 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package top.continew.admin.job.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index cb945db3..ca9eb25d 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -22,12 +22,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import top.continew.admin.job.config.http.JobBatchApi; -import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.config.JobBatchApi; +import top.continew.admin.job.model.JobPageResult; import top.continew.admin.job.model.query.JobLogQuery; import top.continew.admin.job.model.resp.JobLogResp; import top.continew.admin.job.service.JobLogService; -import top.continew.starter.core.exception.BaseException; import top.continew.starter.extension.crud.model.query.PageQuery; import java.time.LocalDateTime; @@ -80,22 +79,22 @@ public class JobLogServiceImpl implements JobLogService { @Override public JobLogResp getJobLogDetail(Long id) { - ResponseEntity> entity = jobBatchApi.getJobBatchDetail(id); - JobResult result = checkResponseEntity(entity); + ResponseEntity> entity = jobBatchApi.getJobBatchDetail(id); + JobPageResult result = checkResponseEntity(entity); return result.getData(); } @Override public boolean stop(Long taskBatchId) { - ResponseEntity> entity = jobBatchApi.stop(taskBatchId); - JobResult result = checkResponseEntity(entity); + ResponseEntity> entity = jobBatchApi.stop(taskBatchId); + JobPageResult result = checkResponseEntity(entity); return Boolean.TRUE.equals(result.getData()); } @Override public Boolean retry(Long taskBatchId) { - ResponseEntity> entity = jobBatchApi.retry(taskBatchId); - JobResult result = checkResponseEntity(entity); + ResponseEntity> entity = jobBatchApi.retry(taskBatchId); + JobPageResult result = checkResponseEntity(entity); return Boolean.TRUE.equals(result.getData()); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index 00d251b8..4ccf2e14 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -16,66 +16,38 @@ package top.continew.admin.job.service.impl; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import top.continew.admin.job.config.http.JobApi; -import top.continew.admin.job.model.JobResult; +import top.continew.admin.job.api.JobApi; +import top.continew.admin.job.api.JobClient; import top.continew.admin.job.model.query.JobQuery; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; import top.continew.admin.job.service.JobService; import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; -import java.util.Objects; - -import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; /** - * 任务调度服务实现 + * 任务业务实现 * * @author KAI - * @since 2024/6/25 17:25:30 + * @author Charles7c + * @since 2024/6/25 17:25 */ - @Service @RequiredArgsConstructor public class JobServiceImpl implements JobService { private final JobApi jobApi; + private final JobClient jobClient; - /** - * 任务分页查询 - * - * @param jobQuery 查询参数 - * @param pageQuery 分页参数 - * @return 分页信息 - */ @Override - public Page page(JobQuery jobQuery, PageQuery pageQuery) { - ResponseEntity entity = jobApi.getJobPage(jobQuery.getJobName(), jobQuery.getJobStatus(), pageQuery - .getPage(), pageQuery.getSize()); - // 校验请求返回的数据 - JSONObject body = checkResponseEntity(entity); - if (body == null) { - return new Page<>(); - } - // 获取返回的数据 - JSONArray data = body.getJSONArray("data"); - if (data == null) { - return new Page<>(); - } - // 数据转化 - List jobRespList = JSONObject.parseArray(data.toJSONString(), JobResp.class); - // 构建分页对象 - Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body.getIntValue("total")); - page.setRecords(jobRespList); - return page; + public PageResp page(JobQuery query, PageQuery pageQuery) { + return jobClient.requestPage(() -> jobApi.getJobPage(query.getName(), query.getStatus(), pageQuery + .getPage(), pageQuery.getSize())); } /** @@ -86,10 +58,7 @@ public class JobServiceImpl implements JobService { */ @Override public boolean addJob(JobReq jobReq) { - ResponseEntity> entity = jobApi.saveJob(jobReq); - // 校验请求返回的数据 - JobResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.saveJob(jobReq))); } /** @@ -100,10 +69,7 @@ public class JobServiceImpl implements JobService { */ @Override public boolean updateJob(JobReq jobReq) { - ResponseEntity> entity = jobApi.updateJob(jobReq); - // 校验请求返回的数据 - JobResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateJob(jobReq))); } /** @@ -114,10 +80,7 @@ public class JobServiceImpl implements JobService { */ @Override public boolean deleteJob(Long id) { - ResponseEntity> entity = jobApi.deleteJobById(id); - // 校验请求返回的数据 - JobResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.deleteJobById(id))); } /** @@ -127,10 +90,7 @@ public class JobServiceImpl implements JobService { */ @Override public List getGroupList() { - ResponseEntity>> entity = jobApi.getAllGroupNameList(); - // 校验请求返回的数据 - JobResult> result = checkResponseEntity(entity); - return Objects.requireNonNull(result.getData()); + return jobClient.request(jobApi::getAllGroupNameList); } /** @@ -141,10 +101,7 @@ public class JobServiceImpl implements JobService { */ @Override public boolean triggerJob(Long id) { - ResponseEntity> entity = jobApi.trigger(id); - // 校验请求返回的数据 - JobResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.trigger(id))); } /** @@ -155,10 +112,7 @@ public class JobServiceImpl implements JobService { */ @Override public boolean updateJobStatus(JobStatusReq req) { - ResponseEntity> entity = jobApi.updateJobStatus(req); - // 校验请求返回的数据 - JobResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateJobStatus(req))); } } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java index 573dbcc1..721c1aa8 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package top.continew.admin.job.service.impl; import com.alibaba.fastjson.JSONArray; @@ -6,7 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import top.continew.admin.job.config.http.JobTaskApi; +import top.continew.admin.job.config.JobTaskApi; import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.admin.job.service.JobTaskService; @@ -31,7 +47,7 @@ public class JobTaskServiceImpl implements JobTaskService { @Override public Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { ResponseEntity entity = jobTaskApi.getJobTaskPage(jobTaskQuery.getJobId(), jobTaskQuery - .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); + .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); // 校验请求返回的数据 JSONObject body = checkResponseEntity(entity); if (body == null) { @@ -46,7 +62,7 @@ public class JobTaskServiceImpl implements JobTaskService { List jobTaskRespList = JSONObject.parseArray(data.toJSONString(), JobTaskResp.class); // 构建分页对象 Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body - .getIntValue("total")); + .getIntValue("total")); page.setRecords(jobTaskRespList); return page; } diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java index 921a85e3..7b407c12 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java @@ -17,7 +17,6 @@ package top.continew.admin.controller.tool; import cn.dev33.satoken.annotation.SaCheckPermission; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -38,13 +37,13 @@ import top.continew.starter.web.model.R; import java.util.List; /** - * 任务调度 API + * 任务 API * * @author KAI * @author Charles7c * @since 2024/6/25 22:24 */ -@Tag(name = " 任务调度 API") +@Tag(name = " 任务 API") @Validated @RestController @RequiredArgsConstructor @@ -57,9 +56,7 @@ public class JobController { @SaCheckPermission("tool:job:list") @GetMapping public R> page(JobQuery query, @Validated PageQuery pageQuery) { - Page jobRespPage = baseService.page(query, pageQuery); - PageResp pageResp = PageResp.build(jobRespPage); - return R.ok(pageResp); + return R.ok(baseService.page(query, pageQuery)); } @Operation(summary = "新增任务", description = "新增任务") diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index d8a205e2..50210eed 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -80,7 +80,7 @@ public class JobLogController { @Operation(summary = "重试任务", description = "重试任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:log:retry") + @SaCheckPermission("tool:job:log:retry") @PostMapping("/retry/{id}") public R retry(@PathVariable Long id) { boolean flag = baseService.retry(id); diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java index c574086c..00eb2ef8 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package top.continew.admin.controller.tool; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index 387257dc..05047543 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -301,11 +301,11 @@ snail-job: token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj ## 服务端配置 server: - #服务端地址 + # 服务端地址 url: http://127.0.0.1:8001/snail-job - #服务端用户名 + # 服务端用户名 username: admin - #服务端密码 + # 服务端密码 password: admin # 服务端地址,若服务端集群部署则此处配置域名 host: 127.0.0.1 diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml index 2fa73c82..d1b80bd7 100644 --- a/continew-admin-webapi/src/main/resources/config/application-prod.yml +++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml @@ -298,11 +298,11 @@ snail-job: token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj ## 服务端配置 server: - #服务端地址 + # 服务端地址 url: http://127.0.0.1:8001/snail-job - #服务端用户名 + # 服务端用户名 username: admin - #服务端密码 + # 服务端密码 password: admin # 服务端地址,若服务端集群部署则此处配置域名 host: 127.0.0.1 diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql deleted file mode 100644 index 1797e243..00000000 --- a/continew-admin-webapi/src/main/resources/db/changelog/mysql/conrinew-admin_job.sql +++ /dev/null @@ -1,11 +0,0 @@ -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599024956302442500, '任务调度', 3000, 2, '/tool/jobCenter', 'ToolJobCenter', 'tool/job/index', NULL, 'clock-circle', b'0', b'1', b'0', NULL, 1, 1, 1, '2024-07-03 23:51:19', 1, '2024-07-03 23:53:56'); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599025355029757959, '任务日志', 599024956302442500, 2, '/tool/job/log', 'ToolJobLog', 'tool/job/log/index', NULL, 'unfold', b'0', b'0', b'1', NULL, 999, 1, 1, '2024-07-03 23:52:54', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033131265179666, '查看', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:list', 999, 1, 1, '2024-07-04 00:23:48', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033201607852053, '新增', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:add', 999, 1, 1, '2024-07-04 00:24:05', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033265134780440, '修改', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:update', 999, 1, 1, '2024-07-04 00:24:20', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033360517447707, '删除', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:delete', 999, 1, 1, '2024-07-04 00:24:43', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033414682689566, '执行', 599024956302442500, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:trigger', 999, 1, 1, '2024-07-04 00:24:56', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033600721043489, '查看', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:list', 999, 1, 1, '2024-07-04 00:25:40', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033667355951140, '详情', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:detail', 999, 1, 1, '2024-07-04 00:25:56', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033762495348775, '停止', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:stop', 999, 1, 1, '2024-07-04 00:26:18', NULL, NULL); -INSERT INTO `continew_admin`.`sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (599033840782032938, '重试', 599025355029757959, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'tool:job:log:retry', 999, 1, 1, '2024-07-04 00:26:37', NULL, NULL); diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql index b573fe7d..9c0c7e9a 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql @@ -172,4 +172,19 @@ INSERT INTO `sys_storage` (`id`, `name`, `code`, `type`, `access_key`, `secret_key`, `endpoint`, `bucket_name`, `domain`, `description`, `is_default`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', b'1', 1, 1, 1, NOW(), NULL, NULL), -(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL); \ No newline at end of file +(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL); + +-- changeset Kai:3.2-1 +INSERT INTO `sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) +VALUES +(3020, '任务调度', 3000, 2, '/tool/job', 'ToolJob', 'tool/job/index', NULL, 'clock-circle', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), +(3021, '查看', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:list', 1, 1, 1, NOW(), NULL, NULL), +(3022, '新增', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:add', 2, 1, 1, NOW(), NULL, NULL), +(3023, '修改', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:update', 3, 1, 1, NOW(), NULL, NULL), +(3024, '删除', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:delete', 4, 1, 1, NOW(), NULL, NULL), +(3025, '执行', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:trigger', 5, 1, 1, NOW(), NULL, NULL), +(3026, '任务日志', 3020, 2, '/tool/job/log', 'ToolJobLog', 'tool/job/log/index', NULL, 'unfold', b'0', b'0', b'1', NULL, 999, 1, 1, NOW(), NULL, NULL), +(3027, '查看日志', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:list', 1, 1, 1, NOW(), NULL, NULL), +(3028, '日志详情', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:detail', 2, 1, 1, NOW(), NULL, NULL), +(3029, '停止任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:stop', 3, 1, 1, NOW(), NULL, NULL), +(3030, '重试任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:retry', 4, 1, 1, NOW(), NULL, NULL); -- Gitee From 4d9e83e9083d25d7cefdb739daaafe3294b12667 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 10 Jul 2024 13:51:28 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=20AP?= =?UTF-8?q?I?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/continew/admin/job/api/JobApi.java | 74 ++++++++++++++----- .../top/continew/admin/job/api/JobClient.java | 19 ++--- .../admin/job/service/JobService.java | 49 ++++++++++-- .../job/service/impl/JobServiceImpl.java | 64 ++++------------ .../admin/controller/tool/JobController.java | 44 +++-------- 5 files changed, 134 insertions(+), 116 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java index 20b30ee8..681b9ed4 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java @@ -19,7 +19,6 @@ package top.continew.admin.job.api; import com.aizuda.snailjob.common.core.model.Result; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -37,11 +36,11 @@ import java.util.List; * @author KAI * @since 2024/6/25 18:20 */ -@HttpExchange("/job") +@HttpExchange(accept = MediaType.APPLICATION_JSON_VALUE) public interface JobApi { /** - * 分页查询任务列表 + * 分页查询列表 * * @param jobName 任务名称 * @param jobStatus 任务状态 @@ -49,27 +48,62 @@ public interface JobApi { * @param size 每页条数 * @return 响应信息 */ - @GetExchange("/page/list") - ResponseEntity>> getJobPage(@RequestParam(value = "jobName", required = false) String jobName, - @RequestParam(value = "jobStatus", required = false) Integer jobStatus, - @RequestParam("page") int page, - @RequestParam("size") int size); + @GetExchange("/job/page/list") + ResponseEntity>> page(@RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "jobStatus", required = false) Integer jobStatus, + @RequestParam("page") int page, + @RequestParam("size") int size); - @GetExchange("/group/all/group-name/list") - ResponseEntity>> getAllGroupNameList(); + /** + * 新增 + * + * @param req 新增信息 + * @return 响应信息 + */ + @PostExchange("/job") + ResponseEntity> add(@RequestBody JobReq req); - @PostExchange(accept = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> saveJob(@RequestBody @Validated JobReq jobRequestVO); + /** + * 修改 + * + * @param req 修改信息 + * @return 响应信息 + */ + @PutExchange("/job") + ResponseEntity> update(@RequestBody JobReq req); - @PutExchange(accept = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> updateJob(@RequestBody @Validated JobReq jobRequestVO); + /** + * 修改状态 + * + * @param req 修改信息 + * @return 响应信息 + */ + @PutExchange("/job/status") + ResponseEntity> updateStatus(@RequestBody JobStatusReq req); - @DeleteExchange("/{id}") - ResponseEntity> deleteJobById(@PathVariable("id") Long id); + /** + * 删除 + * + * @param id ID + * @return 响应信息 + */ + @DeleteExchange("/job/{id}") + ResponseEntity> delete(@PathVariable("id") Long id); - @PostExchange("/trigger/{jobId}") - ResponseEntity> trigger(@PathVariable("jobId") Long jobId); + /** + * 执行 + * + * @param id ID + * @return 响应信息 + */ + @PostExchange("/job/trigger/{id}") + ResponseEntity> trigger(@PathVariable("id") Long id); - @PutExchange("/status") - ResponseEntity> updateJobStatus(@RequestBody @Validated JobStatusReq jobStatusReq); + /** + * 查询分组列表 + * + * @return 响应信息 + */ + @GetExchange("/group/all/group-name/list") + ResponseEntity>> listGroup(); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java index 3d167709..ac813627 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java @@ -47,14 +47,13 @@ import java.util.function.Supplier; * @author Charles7c * @since 2024/7/4 23:07 */ -@Data @Slf4j +@Data public class JobClient { + public static final Integer STATUS_SUCCESS = 1; private final String url; - private final String username; - private final String password; public JobClient(String url, String username, String password) { @@ -76,11 +75,11 @@ public class JobClient { public T request(Supplier>> apiSupplier) { try { ResponseEntity> responseEntity = apiSupplier.get(); - if (!responseEntity.getStatusCode().is2xxSuccessful()) { + if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { throw new IllegalStateException("连接任务调度服务器错误"); } Result result = responseEntity.getBody(); - if (result.getStatus() != 1) { + if (!STATUS_SUCCESS.equals(result.getStatus())) { throw new IllegalStateException(result.getMessage()); } return result.getData(); @@ -95,15 +94,18 @@ public class JobClient { * * @param apiSupplier API 请求 * @param 响应类型 - * @return 分页信息 + * @return 分页列表信息 */ public PageResp requestPage(Supplier>>> apiSupplier) { try { ResponseEntity>> responseEntity = apiSupplier.get(); - if (!responseEntity.getStatusCode().is2xxSuccessful()) { + if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { throw new IllegalStateException("连接任务调度服务器错误"); } JobPageResult> result = responseEntity.getBody(); + if (!STATUS_SUCCESS.equals(result.getStatus())) { + throw new IllegalStateException(result.getMessage()); + } PageResp page = new PageResp<>(); page.setList(result.getData()); page.setTotal(result.getTotal()); @@ -120,7 +122,6 @@ public class JobClient { * @return Token */ public String getToken() { - // 登录 String token = RedisUtils.get(JobConstants.AUTH_TOKEN_HEADER); if (StrUtil.isBlank(token)) { token = this.authenticate(); @@ -142,7 +143,7 @@ public class JobClient { paramMap.put("password", SecureUtil.md5(password)); String responseStr = HttpUtil.post("%s/auth/login".formatted(url), JSONUtil.toJsonStr(paramMap)); JSONObject response = JSONUtil.parseObj(responseStr); - if (response.getInt("status") != 1) { + if (STATUS_SUCCESS.equals(response.getInt("status"))) { throw new IllegalStateException("Password Authentication failed, expected a successful response. error msg: %s" .formatted(response.getStr("message"))); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java index 2ec6b70e..22a4c2a9 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java @@ -43,15 +43,52 @@ public interface JobService { */ PageResp page(JobQuery query, PageQuery pageQuery); - boolean addJob(JobReq jobReq); + /** + * 新增 + * + * @param req 创建信息 + * @return 新增结果 + */ + boolean add(JobReq req); - boolean updateJob(JobReq jobReq); + /** + * 修改 + * + * @param req 修改信息 + * @param id ID + * @return 修改结果 + */ + boolean update(JobReq req, Long id); - boolean deleteJob(Long id); + /** + * 修改状态 + * + * @param req 修改状态信息 + * @param id ID + * @return 修改状态结果 + */ + boolean updateStatus(JobStatusReq req, Long id); - List getGroupList(); + /** + * 删除 + * + * @param id ID + * @return 删除结果 + */ + boolean delete(Long id); - boolean triggerJob(Long id); + /** + * 执行 + * + * @param id ID + * @return 执行结果 + */ + boolean trigger(Long id); - boolean updateJobStatus(JobStatusReq req); + /** + * 查询分组列表 + * + * @return 分组列表 + */ + List listGroup(); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index 4ccf2e14..8d57f23b 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -41,78 +41,44 @@ import java.util.List; @RequiredArgsConstructor public class JobServiceImpl implements JobService { - private final JobApi jobApi; private final JobClient jobClient; + private final JobApi jobApi; @Override public PageResp page(JobQuery query, PageQuery pageQuery) { - return jobClient.requestPage(() -> jobApi.getJobPage(query.getName(), query.getStatus(), pageQuery + return jobClient.requestPage(() -> jobApi.page(query.getName(), query.getStatus(), pageQuery .getPage(), pageQuery.getSize())); } - /** - * 新增任务 - * - * @param jobReq 任务信息 - * @return 结果 true or false - */ @Override - public boolean addJob(JobReq jobReq) { - return Boolean.TRUE.equals(jobClient.request(() -> jobApi.saveJob(jobReq))); + public boolean add(JobReq req) { + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.add(req))); } - /** - * 修改任务 - * - * @param jobReq 任务信息 - * @return 结果 true or false - */ @Override - public boolean updateJob(JobReq jobReq) { - return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateJob(jobReq))); + public boolean update(JobReq req, Long id) { + req.setId(id); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.update(req))); } - /** - * 删除任务 - * - * @param id 任务ID - * @return 结果 true or false - */ @Override - public boolean deleteJob(Long id) { - return Boolean.TRUE.equals(jobClient.request(() -> jobApi.deleteJobById(id))); + public boolean updateStatus(JobStatusReq req, Long id) { + req.setId(id); + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateStatus(req))); } - /** - * 查询任务列表 - * - * @return 组名称数组 ["continew_admin"] - */ @Override - public List getGroupList() { - return jobClient.request(jobApi::getAllGroupNameList); + public boolean delete(Long id) { + return Boolean.TRUE.equals(jobClient.request(() -> jobApi.delete(id))); } - /** - * 执行任务 - * - * @param id 任务ID - * @return 结果 true or false - */ @Override - public boolean triggerJob(Long id) { + public boolean trigger(Long id) { return Boolean.TRUE.equals(jobClient.request(() -> jobApi.trigger(id))); } - /** - * 修改任务状态 - * - * @param req 修改任务状态参数 - * @return 结果 true or false - */ @Override - public boolean updateJobStatus(JobStatusReq req) { - return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateJobStatus(req))); + public List listGroup() { + return jobClient.request(jobApi::listGroup); } - } \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java index 7b407c12..a0db951a 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java @@ -63,11 +63,7 @@ public class JobController { @SaCheckPermission("tool:job:add") @PostMapping public R add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody JobReq req) { - boolean flag = baseService.addJob(req); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.add(req) ? R.ok() : R.fail(); } @Operation(summary = "修改任务", description = "修改任务") @@ -75,11 +71,14 @@ public class JobController { @SaCheckPermission("tool:job:update") @PutMapping("/{id}") public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody JobReq req, @PathVariable Long id) { - boolean flag = baseService.updateJob(req); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.update(req, id) ? R.ok() : R.fail(); + } + + @Operation(summary = "修改任务状态", description = "修改任务状态") + @SaCheckPermission("tool:job:update") + @PatchMapping("/{id}/status") + public R updateStatus(@Validated @RequestBody JobStatusReq req, @PathVariable Long id) { + return baseService.updateStatus(req, id) ? R.ok() : R.fail(); } @Operation(summary = "删除任务", description = "删除任务") @@ -87,11 +86,7 @@ public class JobController { @SaCheckPermission("tool:job:delete") @DeleteMapping("/{id}") public R delete(@PathVariable Long id) { - boolean flag = baseService.deleteJob(id); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.delete(id) ? R.ok() : R.fail(); } @Operation(summary = "执行任务", description = "执行任务") @@ -99,29 +94,14 @@ public class JobController { @SaCheckPermission("tool:job:trigger") @PostMapping("/trigger/{id}") public R trigger(@PathVariable Long id) { - boolean flag = baseService.triggerJob(id); - if (flag) { - return R.ok(); - } - return R.fail(); - } - - @Operation(summary = "修改任务状态", description = "修改任务状态") - @SaCheckPermission("tool:job:update") - @PatchMapping("/{id}/status") - public R updateStatus(@Validated @RequestBody JobStatusReq req, @PathVariable Long id) { - boolean flag = baseService.updateJobStatus(req); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.trigger(id) ? R.ok() : R.fail(); } @Operation(summary = "查询任务分组列表", description = "查询任务分组列表") @SaCheckPermission("tool:job:list") @GetMapping("/group") public R> listGroup() { - List groupList = baseService.getGroupList(); + List groupList = baseService.listGroup(); return R.ok(groupList); } } -- Gitee From c699e30b432f75e3a4667e177077edb3bd1ef530 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 10 Jul 2024 15:40:06 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/continew/admin/job/api/JobApi.java | 1 + .../continew/admin/job/api/JobBatchApi.java | 113 ++++++++++++++++++ .../job/config/HttpExchangeConfiguration.java | 6 +- .../admin/job/config/JobBatchApi.java | 57 --------- .../continew/admin/job/config/JobTaskApi.java | 39 ------ .../admin/job/config/http/TokenHolder.java | 38 ------ .../admin/job/model/JobPageResult.java | 1 + .../admin/job/service/JobLogService.java | 52 ++++++-- .../admin/job/service/JobTaskService.java | 33 ----- .../job/service/impl/JobLogServiceImpl.java | 76 +++++------- .../job/service/impl/JobTaskServiceImpl.java | 69 ----------- .../admin/controller/tool/JobController.java | 2 + .../controller/tool/JobLogController.java | 41 +++---- .../controller/tool/JobTaskController.java | 57 --------- 14 files changed, 208 insertions(+), 377 deletions(-) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java delete mode 100644 continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java index 681b9ed4..06729eb2 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java @@ -34,6 +34,7 @@ import java.util.List; * 任务 REST API * * @author KAI + * @author Charles7c * @since 2024/6/25 18:20 */ @HttpExchange(accept = MediaType.APPLICATION_JSON_VALUE) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java new file mode 100644 index 00000000..bc4d9208 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.api; + +import com.aizuda.snailjob.common.core.model.Result; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.HttpExchange; +import org.springframework.web.service.annotation.PostExchange; +import top.continew.admin.job.model.JobPageResult; +import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 任务批次 REST API + * + * @author KAI + * @author Charles7c + * @since 2024/6/27 23:03 + */ +@HttpExchange(value = "/job", accept = MediaType.APPLICATION_JSON_VALUE) +public interface JobBatchApi { + + /** + * 分页查询列表 + * + * @param jobId 任务ID + * @param jobName 任务名称 + * @param groupName 组名称 + * @param taskBatchStatus 任务批次状态 + * @param datetimeRange 时间范围 + * @param page 页码 + * @param size 每页显示条数 + * @return 响应信息 + */ + @GetExchange("/batch/list") + ResponseEntity>> page(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "groupName", required = false) String groupName, + @RequestParam(value = "taskBatchStatus", required = false) Integer taskBatchStatus, + @RequestParam(value = "datetimeRange", required = false) LocalDateTime[] datetimeRange, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); + + /** + * 停止 + * + * @param id ID + * @return 响应信息 + */ + @PostExchange("/batch/stop/{id}") + ResponseEntity> stop(@PathVariable("id") Long id); + + /** + * 重试 + * + * @param id ID + * @return 响应信息 + */ + @PostExchange("/batch/retry/{id}") + ResponseEntity> retry(@PathVariable("id") Long id); + + /** + * 分页查询任务列表 + * + * @param jobId 任务 ID + * @param taskBatchId 任务批次 ID + * @param page 页码 + * @param size 每页显示条数 + * @return 响应信息 + */ + @GetExchange("/task/list") + ResponseEntity>> pageTask(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); + + /** + * 分页查询日志列表 + * + * @param jobId 任务 ID + * @param taskBatchId 任务批次 ID + * @param fromIndex 起始索引 + * @param size 每页显示条数 + * @return 响应信息 + */ + @GetExchange("/log/list") + ResponseEntity>> pageLog(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "taskId") Long taskId, + @RequestParam(value = "fromIndex") Integer fromIndex, + @RequestParam(value = "size") Integer size); +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java index 7568bfeb..e873a1d8 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java @@ -30,6 +30,7 @@ import org.springframework.web.reactive.function.client.support.WebClientAdapter import org.springframework.web.service.invoker.HttpServiceProxyFactory; import reactor.netty.http.client.HttpClient; import top.continew.admin.job.api.JobApi; +import top.continew.admin.job.api.JobBatchApi; import top.continew.admin.job.api.JobClient; import top.continew.admin.job.constant.JobConstants; @@ -66,11 +67,6 @@ public class HttpExchangeConfiguration { return httpServiceProxyFactory().createClient(JobBatchApi.class); } - @Bean - public JobTaskApi jobTaskApi() { - return httpServiceProxyFactory().createClient(JobTaskApi.class); - } - @Bean public HttpServiceProxyFactory httpServiceProxyFactory() { HttpClient httpClient = HttpClient.create() diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java deleted file mode 100644 index 3d0499ce..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobBatchApi.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.job.config; - -import com.alibaba.fastjson.JSONObject; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.service.annotation.GetExchange; -import org.springframework.web.service.annotation.HttpExchange; -import org.springframework.web.service.annotation.PostExchange; -import top.continew.admin.job.model.JobPageResult; -import top.continew.admin.job.model.resp.JobLogResp; - -import java.time.LocalDateTime; - -/** - * 任务批次远程调用API - * - * @author KAI - * @since 2024/6/27 23:03:23 - */ -@HttpExchange(url = "/job") -public interface JobBatchApi { - @GetExchange("/batch/list") - ResponseEntity getJobBatchPage(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "jobName", required = false) String jobName, - @RequestParam(value = "groupName", required = false) String groupName, - @RequestParam(value = "taskBatchStatus", required = false) Integer taskBatchStatus, - @RequestParam(value = "datetimeRange", required = false) LocalDateTime[] datetimeRange, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "size") Integer size); - - @GetExchange("/batch/{id}") - ResponseEntity> getJobBatchDetail(@PathVariable("id") Long id); - - @PostExchange("/batch/stop/{taskBatchId}") - ResponseEntity> stop(@PathVariable("taskBatchId") Long taskBatchId); - - @PostExchange("/batch/retry/{taskBatchId}") - ResponseEntity> retry(@PathVariable("taskBatchId") Long taskBatchId); - -} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java deleted file mode 100644 index 63b38749..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/JobTaskApi.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.job.config; - -import com.alibaba.fastjson.JSONObject; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.service.annotation.GetExchange; -import org.springframework.web.service.annotation.HttpExchange; - -/** - * 任务实例API远程调用 - * - * @author KAI - * @since 2024/7/4 上午00:07:31 - */ -@HttpExchange(url = "/job") -public interface JobTaskApi { - - @GetExchange("/task/list") - ResponseEntity getJobTaskPage(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "size") Integer size); -} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java deleted file mode 100644 index b83abd74..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/http/TokenHolder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.job.config.http; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import top.continew.starter.core.exception.BaseException; - -/** - * TokenHolder - * - * @author KAI - * @since 2024/6/25 18:18:59 - */ -@Component -public class TokenHolder { - - public static T checkResponseEntity(ResponseEntity entity) { - if (!entity.getStatusCode().is2xxSuccessful()) { - throw new BaseException("连接定时任务服务器异常"); - } - return entity.getBody(); - } -} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java index 4e78feba..4cd3b2ff 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobPageResult.java @@ -23,6 +23,7 @@ import lombok.Data; * 任务调度服务端分页返回对象 * * @author KAI + * @author Charles7c * @since 2024/6/26 22:27 */ @Data diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java index 87d984c9..5ba020cb 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java @@ -16,24 +16,62 @@ package top.continew.admin.job.service; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; /** - * 任务日志API接口 + * 任务日志业务接口 * * @author KAI - * @since 2024/6/27 22:52:22 + * @author Charles7c + * @since 2024/6/27 22:52 */ public interface JobLogService { - Page getJobLogPage(JobLogQuery jobQuery, PageQuery pageQuery); + /** + * 分页查询列表 + * + * @param query 查询条件 + * @param pageQuery 分页查询条件 + * @return 分页列表信息 + */ + PageResp page(JobLogQuery query, PageQuery pageQuery); - JobLogResp getJobLogDetail(Long id); + /** + * 查看详情 + * + * @param query 查询条件 + * @param pageQuery 分页查询条件 + * @return 分页列表信息 + */ + PageResp detail(JobLogQuery query, PageQuery pageQuery); - boolean stop(Long taskBatchId); + /** + * 停止 + * + * @param id ID + * @return 停止结果 + */ + boolean stop(Long id); - Boolean retry(Long taskBatchId); + /** + * 重试 + * + * @param id ID + * @return 重试结果 + */ + boolean retry(Long id); + + /** + * 分页查询任务实例列表 + * + * @param query 查询条件 + * @param pageQuery 分页查询条件 + * @return 分页列表信息 + */ + PageResp pageTask(JobTaskQuery query, PageQuery pageQuery); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java deleted file mode 100644 index 9d8d8eac..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobTaskService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.job.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import top.continew.admin.job.model.query.JobTaskQuery; -import top.continew.admin.job.model.resp.JobTaskResp; -import top.continew.starter.extension.crud.model.query.PageQuery; - -/** - * 任务实例API接口 - * - * @author KAI - * @since 2024/7/4 00:03:10 - */ -public interface JobTaskService { - - Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery); -} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index ca9eb25d..20631d9b 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -16,86 +16,64 @@ package top.continew.admin.job.service.impl; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import cn.hutool.core.date.DatePattern; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import top.continew.admin.job.config.JobBatchApi; -import top.continew.admin.job.model.JobPageResult; +import top.continew.admin.job.api.JobBatchApi; +import top.continew.admin.job.api.JobClient; import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.admin.job.service.JobLogService; import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.resp.PageResp; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; /** - * 任务日志服务实现 + * 任务日志业务实现 * * @author KAI - * @since 2024/6/27 22:54:10 + * @author Charles7c + * @since 2024/6/27 22:54 */ @Service @RequiredArgsConstructor public class JobLogServiceImpl implements JobLogService { + private final JobClient jobClient; private final JobBatchApi jobBatchApi; - private final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Override - public Page getJobLogPage(JobLogQuery jobQuery, PageQuery pageQuery) { + public PageResp page(JobLogQuery query, PageQuery pageQuery) { LocalDateTime[] localDateTimes = new LocalDateTime[2]; - if (jobQuery != null && jobQuery.getStartTime() != null && jobQuery.getEndTime() != null) { - localDateTimes[0] = LocalDateTime.parse(jobQuery.getStartTime(), FORMATTER); - localDateTimes[1] = LocalDateTime.parse(jobQuery.getEndTime(), FORMATTER); - } - ResponseEntity entity = jobBatchApi.getJobBatchPage(jobQuery.getJobId(), jobQuery - .getJobName(), jobQuery.getGroupName(), jobQuery.getTaskBatchStatus(), localDateTimes, pageQuery - .getPage(), pageQuery.getSize()); - // 校验请求返回的数据 - JSONObject body = checkResponseEntity(entity); - if (body == null) { - return new Page<>(); - } - // 获取返回的数据 - JSONArray data = body.getJSONArray("data"); - if (data == null) { - return new Page<>(); + if (query != null && query.getStartTime() != null && query.getEndTime() != null) { + localDateTimes[0] = LocalDateTime.parse(query.getStartTime(), DatePattern.NORM_DATETIME_FORMATTER); + localDateTimes[1] = LocalDateTime.parse(query.getEndTime(), DatePattern.NORM_DATETIME_FORMATTER); } - // 数据转化 - List jobRespList = JSONObject.parseArray(data.toJSONString(), JobLogResp.class); - // 构建分页对象 - Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body - .getIntValue("total")); - page.setRecords(jobRespList); - return page; + return jobClient.requestPage(() -> jobBatchApi.page(query.getJobId(), query.getJobName(), query + .getGroupName(), query.getTaskBatchStatus(), localDateTimes, pageQuery.getPage(), pageQuery.getSize())); } @Override - public JobLogResp getJobLogDetail(Long id) { - ResponseEntity> entity = jobBatchApi.getJobBatchDetail(id); - JobPageResult result = checkResponseEntity(entity); - return result.getData(); + public PageResp detail(JobLogQuery query, PageQuery pageQuery) { + return jobClient.requestPage(() -> jobBatchApi.pageLog(query.getJobId(), 1L, 1L, 0, pageQuery.getSize())); } @Override - public boolean stop(Long taskBatchId) { - ResponseEntity> entity = jobBatchApi.stop(taskBatchId); - JobPageResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + public boolean stop(Long id) { + return Boolean.TRUE.equals(jobClient.request(() -> jobBatchApi.stop(id))); } @Override - public Boolean retry(Long taskBatchId) { - ResponseEntity> entity = jobBatchApi.retry(taskBatchId); - JobPageResult result = checkResponseEntity(entity); - return Boolean.TRUE.equals(result.getData()); + public boolean retry(Long id) { + return Boolean.TRUE.equals(jobClient.request(() -> jobBatchApi.retry(id))); } + @Override + public PageResp pageTask(JobTaskQuery query, PageQuery pageQuery) { + return jobClient.requestPage(() -> jobBatchApi.pageTask(query.getJobId(), query.getTaskBatchId(), pageQuery + .getPage(), pageQuery.getSize())); + } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java deleted file mode 100644 index 721c1aa8..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobTaskServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.job.service.impl; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import top.continew.admin.job.config.JobTaskApi; -import top.continew.admin.job.model.query.JobTaskQuery; -import top.continew.admin.job.model.resp.JobTaskResp; -import top.continew.admin.job.service.JobTaskService; -import top.continew.starter.extension.crud.model.query.PageQuery; - -import java.util.List; - -import static top.continew.admin.job.config.http.TokenHolder.checkResponseEntity; - -/** - * 任务实例实现 - * - * @author KAI - * @since 2024/7/4 00:04:12 - */ -@Service -@RequiredArgsConstructor -public class JobTaskServiceImpl implements JobTaskService { - - private final JobTaskApi jobTaskApi; - - @Override - public Page getTaskPage(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { - ResponseEntity entity = jobTaskApi.getJobTaskPage(jobTaskQuery.getJobId(), jobTaskQuery - .getTaskBatchId(), pageQuery.getPage(), pageQuery.getSize()); - // 校验请求返回的数据 - JSONObject body = checkResponseEntity(entity); - if (body == null) { - return new Page<>(); - } - // 获取返回的数据 - JSONArray data = body.getJSONArray("data"); - if (data == null) { - return new Page<>(); - } - // 数据转化 - List jobTaskRespList = JSONObject.parseArray(data.toJSONString(), JobTaskResp.class); - // 构建分页对象 - Page page = new Page<>(body.getIntValue("page"), body.getIntValue("size"), body - .getIntValue("total")); - page.setRecords(jobTaskRespList); - return page; - } -} diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java index a0db951a..82d1e809 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java @@ -32,6 +32,7 @@ import top.continew.admin.job.service.JobService; import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.extension.crud.util.ValidateGroup; +import top.continew.starter.log.core.annotation.Log; import top.continew.starter.web.model.R; import java.util.List; @@ -97,6 +98,7 @@ public class JobController { return baseService.trigger(id) ? R.ok() : R.fail(); } + @Log(ignore = true) @Operation(summary = "查询任务分组列表", description = "查询任务分组列表") @SaCheckPermission("tool:job:list") @GetMapping("/group") diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index 50210eed..088f7d2f 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -17,7 +17,6 @@ package top.continew.admin.controller.tool; import cn.dev33.satoken.annotation.SaCheckPermission; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -26,20 +25,22 @@ import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import top.continew.admin.job.model.query.JobLogQuery; +import top.continew.admin.job.model.query.JobTaskQuery; import top.continew.admin.job.model.resp.JobLogResp; +import top.continew.admin.job.model.resp.JobTaskResp; import top.continew.admin.job.service.JobLogService; import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.web.model.R; /** - * 任务调度日志 API + * 任务日志 API * * @author KAI * @author Charles7c * @since 2024/6/27 22:24 */ -@Tag(name = " 任务调度日志 API") +@Tag(name = " 任务日志 API") @Validated @RestController @RequiredArgsConstructor @@ -52,18 +53,14 @@ public class JobLogController { @SaCheckPermission("tool:job:log:list") @GetMapping public R> page(JobLogQuery query, @Validated PageQuery pageQuery) { - Page jobBatchPage = baseService.getJobLogPage(query, pageQuery); - PageResp pageResp = PageResp.build(jobBatchPage); - return R.ok(pageResp); + return R.ok(baseService.page(query, pageQuery)); } - @Operation(summary = "查询任务日志详情", description = "查询任务日志详情") - @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:log:detail") - @GetMapping("/{id}") - public R get(@PathVariable Long id) { - JobLogResp jobLogResp = baseService.getJobLogDetail(id); - return R.ok(jobLogResp); + @Operation(summary = "查看任务日志详情", description = "查看任务日志详情") + @SaCheckPermission("tool:job:log:list") + @GetMapping + public R> detail(JobLogQuery query, @Validated PageQuery pageQuery) { + return R.ok(baseService.detail(query, pageQuery)); } @Operation(summary = "停止任务", description = "停止任务") @@ -71,11 +68,7 @@ public class JobLogController { @SaCheckPermission("tool:job:log:stop") @PostMapping("/stop/{id}") public R stop(@PathVariable Long id) { - boolean flag = baseService.stop(id); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.stop(id) ? R.ok() : R.fail(); } @Operation(summary = "重试任务", description = "重试任务") @@ -83,11 +76,13 @@ public class JobLogController { @SaCheckPermission("tool:job:log:retry") @PostMapping("/retry/{id}") public R retry(@PathVariable Long id) { - boolean flag = baseService.retry(id); - if (flag) { - return R.ok(); - } - return R.fail(); + return baseService.retry(id) ? R.ok() : R.fail(); } + @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") + @SaCheckPermission("tool:job:log:list") + @GetMapping("/task") + public R> page(JobTaskQuery query, PageQuery pageQuery) { + return R.ok(baseService.pageTask(query, pageQuery)); + } } diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java deleted file mode 100644 index 00eb2ef8..00000000 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobTaskController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.controller.tool; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.continew.admin.job.model.query.JobTaskQuery; -import top.continew.admin.job.model.resp.JobTaskResp; -import top.continew.admin.job.service.JobTaskService; -import top.continew.starter.extension.crud.model.query.PageQuery; -import top.continew.starter.extension.crud.model.resp.PageResp; -import top.continew.starter.web.model.R; - -/** - * 任务实例控制层 - * - * @author KAI - * @since 2024/7/4 00:02:21 - */ -@Tag(name = "任务实例 API") -@Validated -@RestController -@RequiredArgsConstructor -@RequestMapping("/job/task") -public class JobTaskController { - - private final JobTaskService baseService; - - @GetMapping - @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") - public R> page(JobTaskQuery jobTaskQuery, PageQuery pageQuery) { - Page jobBatchPage = baseService.getTaskPage(jobTaskQuery, pageQuery); - //构建返回对象 - PageResp pageResp = PageResp.build(jobBatchPage); - return R.ok(pageResp); - } -} -- Gitee From c6b9b5af1e7b673cf378813ec3a68fe4e501817e Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 10 Jul 2024 23:42:21 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E9=83=A8=E5=88=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/top/continew/admin/job/api/JobClient.java | 6 +++--- .../continew/admin/controller/tool/JobLogController.java | 2 +- .../src/main/resources/config/application-dev.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java index ac813627..1780cd3e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java @@ -76,7 +76,7 @@ public class JobClient { try { ResponseEntity> responseEntity = apiSupplier.get(); if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { - throw new IllegalStateException("连接任务调度服务器错误"); + throw new IllegalStateException("连接任务调度中心错误"); } Result result = responseEntity.getBody(); if (!STATUS_SUCCESS.equals(result.getStatus())) { @@ -100,7 +100,7 @@ public class JobClient { try { ResponseEntity>> responseEntity = apiSupplier.get(); if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { - throw new IllegalStateException("连接任务调度服务器错误"); + throw new IllegalStateException("连接任务调度中心错误"); } JobPageResult> result = responseEntity.getBody(); if (!STATUS_SUCCESS.equals(result.getStatus())) { @@ -143,7 +143,7 @@ public class JobClient { paramMap.put("password", SecureUtil.md5(password)); String responseStr = HttpUtil.post("%s/auth/login".formatted(url), JSONUtil.toJsonStr(paramMap)); JSONObject response = JSONUtil.parseObj(responseStr); - if (STATUS_SUCCESS.equals(response.getInt("status"))) { + if (!STATUS_SUCCESS.equals(response.getInt("status"))) { throw new IllegalStateException("Password Authentication failed, expected a successful response. error msg: %s" .formatted(response.getStr("message"))); } diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index 088f7d2f..cf82478b 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -58,7 +58,7 @@ public class JobLogController { @Operation(summary = "查看任务日志详情", description = "查看任务日志详情") @SaCheckPermission("tool:job:log:list") - @GetMapping + @GetMapping("/detail") public R> detail(JobLogQuery query, @Validated PageQuery pageQuery) { return R.ok(baseService.detail(query, pageQuery)); } diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml index 05047543..8d5c0433 100644 --- a/continew-admin-webapi/src/main/resources/config/application-dev.yml +++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml @@ -290,7 +290,7 @@ avatar: --- ### Snail Job 配置 snail-job: # 分组名 - group: continew_admin + group: continew-admin # 客户端地址(默认自动获取本机 IP) #host: 127.0.0.1 # 客户端端口(默认:1789) -- Gitee From 3e51671a9f0c3aec99ad4df74870bd6e144c91ba Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 11 Jul 2024 14:15:04 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/job/model/query/JobQuery.java | 13 +- .../continew/admin/job/model/req/JobReq.java | 136 +++++++++--------- .../admin/job/model/resp/JobResp.java | 132 ++++++++--------- .../job/service/impl/JobServiceImpl.java | 2 +- 4 files changed, 140 insertions(+), 143 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java index b9b8bd26..35e22fae 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java @@ -23,7 +23,6 @@ import lombok.Data; * 任务查询条件 * * @author KAI - * @author Charles7c * @since 2024/6/25 16:43 */ @Data @@ -31,14 +30,14 @@ import lombok.Data; public class JobQuery { /** - * 名称 + * 任务名称 */ - @Schema(description = "名称") - private String name; + @Schema(description = "任务名称", example = "") + private String jobName; /** - * 状态 + * 任务状态 */ - @Schema(description = "状态") - private Integer status; + @Schema(description = "任务状态", example = "") + private Integer jobStatus; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java index ba4dfc2f..bbfbadb6 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -19,136 +19,144 @@ package top.continew.admin.job.model.req; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import java.io.Serial; +import java.io.Serializable; /** - * 定时任务信息 + * 创建或修改任务信息 * * @author KAI - * @since 2024/6/25 16:40:11 + * @author Charles7c + * @since 2024/6/25 16:40 */ @Data -@Schema(description = "定时任务信息") -public class JobReq { +@Schema(description = "创建或修改任务信息") +public class JobReq implements Serializable { - @Schema(description = "任务ID") - private Long id; + @Serial + private static final long serialVersionUID = 1L; /** - * 组名称 + * 任务组 */ - @NotBlank(message = "groupName 不能为空") - @Pattern(regexp = "^[A-Za-z0-9_-]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母、下划线和短横线") - @Schema(description = "组名称") + @Schema(description = "任务组", example = "continew-admin") + @NotBlank(message = "任务组不能为空") private String groupName; /** - * 名称 + * 任务名称 */ - @NotBlank(message = "jobName 不能为空") - @Schema(description = "任务名称") + @Schema(description = "任务名称", example = "密码到期提醒") + @NotBlank(message = "任务名称不能为空") + @Length(max = 64, message = "任务名称不能超过 {max} 个字符") private String jobName; /** - * 任务状态 0、关闭、1、开启 + * 描述 */ - @NotNull(message = "jobStatus 不能为空") - @Schema(description = "任务状态") - private Integer jobStatus; + @Schema(description = "描述", example = "每天凌晨1点检查密码是否已到期") + private String description; /** - * 执行方法参数 + * 触发类型 */ - @Schema(description = "执行方法参数") - private String argsStr; + @Schema(description = "触发类型", allowableValues = {"2", "3"}, example = "2") + @NotNull(message = "触发类型不能为空") + private Integer triggerType; /** - * 参数类型 text/json + * 间隔时长 */ - @Schema(description = "参数类型", example = "text/json") - private Integer argsType; + @Schema(description = "间隔时长", example = "60") + @NotBlank(message = "间隔时长不能为空") + private String triggerInterval; /** - * 执行器路由策略 + * 执行器类型 */ - @NotNull(message = "routeKey 不能为空") - @Schema(description = "执行器路由策略") - private Integer routeKey; + @Schema(description = "执行器类型", allowableValues = {"1"}, example = "1", defaultValue = "1") + private Integer executorType = 1; /** - * 执行器类型 1、Java + * 任务类型 */ - @NotNull(message = "executorType 不能为空") - @Schema(description = "执行器类型 1、Java") - private Integer executorType; + @Schema(description = "任务类型", allowableValues = {"1"}, example = "1") + @NotNull(message = "任务类型不能为空") + private Integer taskType; /** * 执行器名称 */ - @NotBlank(message = "executorInfo 不能为空") - @Schema(description = "执行器名称") + @Schema(description = "执行器名称", example = "1") + @NotBlank(message = "执行器名称不能为空") private String executorInfo; /** - * 触发类型 2. 固定时间 3.CRON 表达式 99.工作流 + * 方法参数 */ - @NotNull(message = "triggerType 不能为空") - private Integer triggerType; + @Schema(description = "方法参数", example = "") + private String argsStr; /** - * 间隔时长 + * 参数类型 */ - @NotNull(message = "triggerInterval 不能为空") - @Schema(description = "触发类型 2. 固定时间 3.CRON 表达式 99.工作流") - private String triggerInterval; + @Schema(description = "参数类型", example = "1") + private Integer argsType; + + /** + * 路由策略 + */ + @Schema(description = "路由策略", example = "") + @NotNull(message = "路由策略不能为空") + private Integer routeKey; /** - * 阻塞策略 1、丢弃 2、覆盖 3、并行 + * 阻塞策略 */ - @NotNull(message = "blockStrategy 不能为空") - @Schema(description = "阻塞策略 1、丢弃 2、覆盖 3、并行") + @Schema(description = "阻塞策略", example = "") + @NotNull(message = "阻塞策略不能为空") private Integer blockStrategy; /** - * 任务执行超时时间,单位秒 + * 超时时间(单位:秒) */ - @NotNull(message = "executorTimeout 不能为空") - @Schema(description = "任务执行超时时间") + @Schema(description = "超时时间(单位:秒)", example = "60") + @NotNull(message = "超时时间不能为空") private Integer executorTimeout; /** * 最大重试次数 */ - @NotNull(message = "maxRetryTimes 不能为空") - @Schema(description = "最大重试次数") + @Schema(description = "最大重试次数", example = "3") + @NotNull(message = "最大重试次数不能为空") private Integer maxRetryTimes; /** - * 重试间隔(s) + * 重试间隔(单位:秒) */ - @NotNull(message = "retryInterval 不能为空") - @Schema(description = "重试间隔") + @Schema(description = "重试间隔(单位:秒)", example = "1") + @NotNull(message = "重试间隔不能为空") private Integer retryInterval; - /** - * 任务类型 - */ - @NotNull(message = "taskType 不能为空") - @Schema(description = "任务类型") - private Integer taskType; - /** * 并行数 */ - @NotNull(message = "parallelNum 不能为空") - @Schema(description = "并行书") + @Schema(description = "并行数", example = "1") + @NotNull(message = "并行数不能为空") private Integer parallelNum; /** - * 描述 + * 任务状态 */ - @Schema(description = "描述") - private String description; + @Schema(description = "任务状态", example = "0") + private Integer jobStatus = 0; + /** + * ID + */ + @Schema(hidden = true) + private Long id; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index a6610ef5..ae892f8e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -16,159 +16,149 @@ package top.continew.admin.job.model.resp; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.util.Date; +import java.time.LocalDateTime; /** * 任务信息 * * @author KAI - * @since 2024/6/25 17:15:23 + * @author Charles7c + * @since 2024/6/25 17:15 */ @Data @Schema(description = "任务信息") public class JobResp { - @Schema(description = "组名称") + + /** + * ID + */ + @Schema(description = "ID", example = "1") private Long id; /** - * 组名称 + * 任务组 */ - @Schema(description = "组名称") + @Schema(description = "任务组", example = "continew-admin") private String groupName; /** - * 名称 + * 任务名称 */ - @Schema(description = "任务名称") + @Schema(description = "任务名称", example = "") private String jobName; /** - * 执行方法参数 + * 描述 */ - @Schema(description = "执行方法参数") - private String argsStr; + @Schema(description = "描述", example = "") + private String description; /** - * 参数类型 text/json + * 触发类型 */ - @Schema(description = "参数类型", example = "text/json") - private String argsType; + @Schema(description = "触发类型", example = "") + private Integer triggerType; /** - * 扩展字段 + * 间隔时长 */ - @Schema(description = "扩展字段") - private String extAttrs; + @Schema(description = "间隔时长", example = "") + private String triggerInterval; /** - * 下次触发时间 + * 执行器类型 */ - @Schema(description = "下次触发时间") - private Date nextTriggerAt; + @Schema(description = " 执行器类型", example = "") + private Integer executorType; /** - * 重试状态 0、关闭、1、开启 + * 任务类型 */ - @Schema(description = "任务状态") - private Integer jobStatus; + @Schema(description = "任务类型", example = "") + private Integer taskType; /** - * 执行器路由策略 + * 执行器名称 */ - @Schema(description = "执行器路由策略") - private Integer routeKey; + @Schema(description = "执行器名称", example = "") + private String executorInfo; /** - * 执行器类型 1、Java + * 方法参数 */ - @Schema(description = " 执行器类型 1、Java") - private Integer executorType; - - /** - * 执行器名称 - */ - @Schema(description = "执行器名称") - private String executorInfo; + @Schema(description = "方法参数", example = "") + private String argsStr; /** - * 触发类型 1.CRON 表达式 2. 固定时间 + * 参数类型 */ - @Schema(description = "触发类型 1.CRON 表达式 2. 固定时间") - private Integer triggerType; + @Schema(description = "参数类型", example = "1") + private String argsType; /** - * 间隔时长 + * 路由策略 */ - @Schema(description = "间隔时长") - private String triggerInterval; + @Schema(description = "路由策略", example = "") + private Integer routeKey; /** - * 阻塞策略 1、丢弃 2、覆盖 3、并行 + * 阻塞策略 */ - @Schema(description = "阻塞策略 1、丢弃 2、覆盖 3、并行") + @Schema(description = "阻塞策略", example = "") private Integer blockStrategy; /** - * 任务执行超时时间,单位秒 + * 超时时间(单位:秒) */ - @Schema(description = "任务执行超时时间") + @Schema(description = "超时时间(单位:秒)", example = "60") private Integer executorTimeout; /** * 最大重试次数 */ - @Schema(description = "最大重试次数") + @Schema(description = "最大重试次数", example = "3") private Integer maxRetryTimes; /** - * 重试间隔(s) + * 重试间隔(单位:秒) */ - @Schema(description = "重试间隔") + @Schema(description = "重试间隔", example = "1") private Integer retryInterval; - /** - * 任务类型 - */ - @Schema(description = "任务类型") - private Integer taskType; - /** * 并行数 */ - @Schema(description = "并行数") + @Schema(description = "并行数", example = "1") private Integer parallelNum; /** - * bucket + * 任务状态 */ - @Schema(description = "bucket") - private Integer bucketIndex; + @Schema(description = "任务状态", example = "1") + private Integer jobStatus; /** - * 描述 + * 下次触发时间 */ - @Schema(description = "描述") - private String description; + @Schema(description = "下次触发时间", example = "") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime nextTriggerAt; /** * 创建时间 */ - @Schema(description = "创建时间") - private Date createDt; + @Schema(description = "创建时间", example = "") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createDt; /** * 修改时间 */ - @Schema(description = "修改时间") - private Date updateDt; - - /** - * 逻辑删除 1、删除 - */ - @Schema(description = "逻辑删除") - private Integer deleted; - + @Schema(description = "修改时间", example = "") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateDt; } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index 8d57f23b..219d9613 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -46,7 +46,7 @@ public class JobServiceImpl implements JobService { @Override public PageResp page(JobQuery query, PageQuery pageQuery) { - return jobClient.requestPage(() -> jobApi.page(query.getName(), query.getStatus(), pageQuery + return jobClient.requestPage(() -> jobApi.page(query.getJobName(), query.getJobStatus(), pageQuery .getPage(), pageQuery.getSize())); } -- Gitee From a8bda816451b29913e894bec3ff3bc2bc92c0ed0 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 11 Jul 2024 23:34:59 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/continew/admin/job/api/JobApi.java | 13 ++--- .../admin/job/enums/JobBlockStrategyEnum.java | 50 +++++++++++++++++ .../admin/job/enums/JobRouteStrategyEnum.java | 55 +++++++++++++++++++ .../admin/job/enums/JobStatusEnum.java | 47 ++++++++++++++++ .../admin/job/enums/JobTaskTypeEnum.java | 52 ++++++++++++++++++ .../admin/job/enums/JobTriggerTypeEnum.java | 47 ++++++++++++++++ .../admin/job/model/query/JobQuery.java | 26 ++++++++- .../continew/admin/job/model/req/JobReq.java | 22 +++++--- .../admin/job/model/resp/JobResp.java | 17 +++--- .../admin/job/service/JobService.java | 6 +- .../job/service/impl/JobServiceImpl.java | 6 +- .../admin/controller/tool/JobController.java | 5 +- 12 files changed, 307 insertions(+), 39 deletions(-) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobBlockStrategyEnum.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobRouteStrategyEnum.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobStatusEnum.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTaskTypeEnum.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java index 06729eb2..703944a0 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java @@ -21,9 +21,10 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.service.annotation.*; import top.continew.admin.job.model.JobPageResult; +import top.continew.admin.job.model.query.JobQuery; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; @@ -43,17 +44,11 @@ public interface JobApi { /** * 分页查询列表 * - * @param jobName 任务名称 - * @param jobStatus 任务状态 - * @param page 页码 - * @param size 每页条数 + * @param query 查询条件 * @return 响应信息 */ @GetExchange("/job/page/list") - ResponseEntity>> page(@RequestParam(value = "jobName", required = false) String jobName, - @RequestParam(value = "jobStatus", required = false) Integer jobStatus, - @RequestParam("page") int page, - @RequestParam("size") int size); + ResponseEntity>> page(@RequestPart JobQuery query); /** * 新增 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobBlockStrategyEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobBlockStrategyEnum.java new file mode 100644 index 00000000..fe5a6d25 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobBlockStrategyEnum.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务阻塞策略枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobBlockStrategyEnum implements IBaseEnum { + + /** + * 丢弃 + */ + DISCARD(1, "丢弃"), + + /** + * 覆盖 + */ + COVER(2, "覆盖"), + + /** + * 并行 + */ + PARALLEL(3, "并行"),; + + private final Integer value; + private final String description; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobRouteStrategyEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobRouteStrategyEnum.java new file mode 100644 index 00000000..8049eafd --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobRouteStrategyEnum.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务路由策略枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobRouteStrategyEnum implements IBaseEnum { + + /** + * 轮询 + */ + POLLING(4, "轮询"), + + /** + * 随机 + */ + RANDOM(2, "随机"), + + /** + * 一致性哈希 + */ + HASH(1, "一致性哈希"), + + /** + * LRU + */ + LRU(3, "LRU"),; + + private final Integer value; + private final String description; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobStatusEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobStatusEnum.java new file mode 100644 index 00000000..d902e4ea --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobStatusEnum.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.admin.common.constant.UiConstants; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务状态枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobStatusEnum implements IBaseEnum { + + /** + * 禁用 + */ + DISABLED(0, "禁用", UiConstants.COLOR_ERROR), + + /** + * 启用 + */ + ENABLED(1, "启用", UiConstants.COLOR_SUCCESS),; + + private final Integer value; + private final String description; + private final String color; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTaskTypeEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTaskTypeEnum.java new file mode 100644 index 00000000..e6a2b737 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTaskTypeEnum.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.admin.common.constant.UiConstants; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务类型枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobTaskTypeEnum implements IBaseEnum { + + /** + * 集群 + */ + CLUSTER(1, "集群", UiConstants.COLOR_PRIMARY), + + /** + * 广播 + */ + BROADCAST(2, "广播", UiConstants.COLOR_PRIMARY), + + /** + * 静态切片 + */ + SLICE(3, "静态切片", UiConstants.COLOR_PRIMARY),; + + private final Integer value; + private final String description; + private final String color; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java new file mode 100644 index 00000000..6978fabf --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.admin.common.constant.UiConstants; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务触发类型枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobTriggerTypeEnum implements IBaseEnum { + + /** + * CRON + */ + CRON(1, "CRON"), + + /** + * 固定时间 + */ + FIXED_TIME(2, "固定时间"), + ; + + private final Integer value; + private final String description; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java index 35e22fae..62e477d2 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java @@ -17,7 +17,9 @@ package top.continew.admin.job.model.query; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Min; import lombok.Data; +import org.hibernate.validator.constraints.Range; /** * 任务查询条件 @@ -29,15 +31,35 @@ import lombok.Data; @Schema(description = "任务查询条件") public class JobQuery { + /** + * 任务组 + */ + @Schema(description = "任务组", example = "continew-admin") + private String groupName; + /** * 任务名称 */ - @Schema(description = "任务名称", example = "") + @Schema(description = "任务名称", example = "定时任务1") private String jobName; /** * 任务状态 */ - @Schema(description = "任务状态", example = "") + @Schema(description = "任务状态", example = "1") private Integer jobStatus; + + /** + * 页码 + */ + @Schema(description = "页码", example = "1") + @Min(value = 1, message = "页码最小值为 {value}") + private Integer page = 1; + + /** + * 每页条数 + */ + @Schema(description = "每页条数", example = "10") + @Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})") + private Integer size = 10; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java index bbfbadb6..3d122641 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -21,6 +21,10 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; import org.hibernate.validator.constraints.Length; +import top.continew.admin.job.enums.JobRouteStrategyEnum; +import top.continew.admin.job.enums.JobStatusEnum; +import top.continew.admin.job.enums.JobTaskTypeEnum; +import top.continew.admin.job.enums.JobTriggerTypeEnum; import java.io.Serial; import java.io.Serializable; @@ -64,8 +68,8 @@ public class JobReq implements Serializable { * 触发类型 */ @Schema(description = "触发类型", allowableValues = {"2", "3"}, example = "2") - @NotNull(message = "触发类型不能为空") - private Integer triggerType; + @NotNull(message = "触发类型非法") + private JobTriggerTypeEnum triggerType; /** * 间隔时长 @@ -84,8 +88,8 @@ public class JobReq implements Serializable { * 任务类型 */ @Schema(description = "任务类型", allowableValues = {"1"}, example = "1") - @NotNull(message = "任务类型不能为空") - private Integer taskType; + @NotNull(message = "任务类型非法") + private JobTaskTypeEnum taskType; /** * 执行器名称 @@ -95,9 +99,9 @@ public class JobReq implements Serializable { private String executorInfo; /** - * 方法参数 + * 任务参数 */ - @Schema(description = "方法参数", example = "") + @Schema(description = "任务参数", example = "") private String argsStr; /** @@ -117,8 +121,8 @@ public class JobReq implements Serializable { * 阻塞策略 */ @Schema(description = "阻塞策略", example = "") - @NotNull(message = "阻塞策略不能为空") - private Integer blockStrategy; + @NotNull(message = "阻塞策略非法") + private JobRouteStrategyEnum blockStrategy; /** * 超时时间(单位:秒) @@ -152,7 +156,7 @@ public class JobReq implements Serializable { * 任务状态 */ @Schema(description = "任务状态", example = "0") - private Integer jobStatus = 0; + private JobStatusEnum jobStatus = JobStatusEnum.DISABLED; /** * ID diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index ae892f8e..cf49b7b3 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -19,6 +19,7 @@ package top.continew.admin.job.model.resp; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import top.continew.admin.job.enums.*; import java.time.LocalDateTime; @@ -48,19 +49,19 @@ public class JobResp { /** * 任务名称 */ - @Schema(description = "任务名称", example = "") + @Schema(description = "任务名称", example = "定时任务1") private String jobName; /** * 描述 */ - @Schema(description = "描述", example = "") + @Schema(description = "描述", example = "定时任务1的描述") private String description; /** * 触发类型 */ - @Schema(description = "触发类型", example = "") + @Schema(description = "触发类型", example = "1") private Integer triggerType; /** @@ -78,7 +79,7 @@ public class JobResp { /** * 任务类型 */ - @Schema(description = "任务类型", example = "") + @Schema(description = "任务类型", example = "1") private Integer taskType; /** @@ -88,9 +89,9 @@ public class JobResp { private String executorInfo; /** - * 方法参数 + * 任务参数 */ - @Schema(description = "方法参数", example = "") + @Schema(description = "任务参数", example = "") private String argsStr; /** @@ -102,13 +103,13 @@ public class JobResp { /** * 路由策略 */ - @Schema(description = "路由策略", example = "") + @Schema(description = "路由策略", example = "1") private Integer routeKey; /** * 阻塞策略 */ - @Schema(description = "阻塞策略", example = "") + @Schema(description = "阻塞策略", example = "1") private Integer blockStrategy; /** diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java index 22a4c2a9..af3e989e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobService.java @@ -20,7 +20,6 @@ import top.continew.admin.job.model.query.JobQuery; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; -import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; @@ -37,11 +36,10 @@ public interface JobService { /** * 分页查询列表 * - * @param query 查询条件 - * @param pageQuery 分页查询条件 + * @param query 查询条件 * @return 分页列表信息 */ - PageResp page(JobQuery query, PageQuery pageQuery); + PageResp page(JobQuery query); /** * 新增 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index 219d9613..3dc71e33 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -25,7 +25,6 @@ import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; import top.continew.admin.job.service.JobService; -import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; @@ -45,9 +44,8 @@ public class JobServiceImpl implements JobService { private final JobApi jobApi; @Override - public PageResp page(JobQuery query, PageQuery pageQuery) { - return jobClient.requestPage(() -> jobApi.page(query.getJobName(), query.getJobStatus(), pageQuery - .getPage(), pageQuery.getSize())); + public PageResp page(JobQuery query) { + return jobClient.requestPage(() -> jobApi.page(query)); } @Override diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java index 82d1e809..f8d9dd99 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java @@ -29,7 +29,6 @@ import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; import top.continew.admin.job.service.JobService; -import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.extension.crud.util.ValidateGroup; import top.continew.starter.log.core.annotation.Log; @@ -56,8 +55,8 @@ public class JobController { @Operation(summary = "分页查询任务列表", description = "分页查询任务列表") @SaCheckPermission("tool:job:list") @GetMapping - public R> page(JobQuery query, @Validated PageQuery pageQuery) { - return R.ok(baseService.page(query, pageQuery)); + public R> page(JobQuery query) { + return R.ok(baseService.page(query)); } @Operation(summary = "新增任务", description = "新增任务") -- Gitee From 1b93ccb000e2e9e43fe85ddfc357c0f2acaaaa21 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sat, 13 Jul 2024 21:57:05 +0800 Subject: [PATCH 13/21] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/job/enums/JobTriggerTypeEnum.java | 4 +-- .../continew/admin/job/model/req/JobReq.java | 12 +++---- .../admin/job/model/req/JobStatusReq.java | 31 +++++++++++++------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java index 6978fabf..55ea9101 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobTriggerTypeEnum.java @@ -18,7 +18,6 @@ package top.continew.admin.job.enums; import lombok.Getter; import lombok.RequiredArgsConstructor; -import top.continew.admin.common.constant.UiConstants; import top.continew.starter.data.mybatis.plus.base.IBaseEnum; /** @@ -39,8 +38,7 @@ public enum JobTriggerTypeEnum implements IBaseEnum { /** * 固定时间 */ - FIXED_TIME(2, "固定时间"), - ; + FIXED_TIME(2, "固定时间"),; private final Integer value; private final String description; diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java index 3d122641..3d8ecd92 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -21,10 +21,6 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; import org.hibernate.validator.constraints.Length; -import top.continew.admin.job.enums.JobRouteStrategyEnum; -import top.continew.admin.job.enums.JobStatusEnum; -import top.continew.admin.job.enums.JobTaskTypeEnum; -import top.continew.admin.job.enums.JobTriggerTypeEnum; import java.io.Serial; import java.io.Serializable; @@ -69,7 +65,7 @@ public class JobReq implements Serializable { */ @Schema(description = "触发类型", allowableValues = {"2", "3"}, example = "2") @NotNull(message = "触发类型非法") - private JobTriggerTypeEnum triggerType; + private Integer triggerType; /** * 间隔时长 @@ -89,7 +85,7 @@ public class JobReq implements Serializable { */ @Schema(description = "任务类型", allowableValues = {"1"}, example = "1") @NotNull(message = "任务类型非法") - private JobTaskTypeEnum taskType; + private Integer taskType; /** * 执行器名称 @@ -122,7 +118,7 @@ public class JobReq implements Serializable { */ @Schema(description = "阻塞策略", example = "") @NotNull(message = "阻塞策略非法") - private JobRouteStrategyEnum blockStrategy; + private Integer blockStrategy; /** * 超时时间(单位:秒) @@ -156,7 +152,7 @@ public class JobReq implements Serializable { * 任务状态 */ @Schema(description = "任务状态", example = "0") - private JobStatusEnum jobStatus = JobStatusEnum.DISABLED; + private Integer jobStatus = 0; /** * ID diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java index 89b87041..be8a3f5a 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java @@ -20,20 +20,33 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Data; +import java.io.Serial; +import java.io.Serializable; + /** - * 修改定时任务信息 + * 修改任务状态信息 * * @author KAI - * @since 2024/6/27 9:24:09 + * @author Charles7c + * @since 2024/6/27 9:24 */ @Data -@Schema(description = "修改定时任务信息") -public class JobStatusReq { - @Schema(description = "任务ID") - @NotNull(message = "id不能为空") - private Long id; +@Schema(description = "修改任务状态信息") +public class JobStatusReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; - @Schema(description = "任务状态 1.开启 0.关闭") - @NotNull(message = "任务状态不能为空") + /** + * 任务状态 + */ + @Schema(description = "任务状态", example = "1") + @NotNull(message = "任务状态非法") private Integer jobStatus; + + /** + * ID + */ + @Schema(hidden = true) + private Long id; } -- Gitee From eb4353370af4cddd657e89dd62c3ff040dc4e72d Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 14 Jul 2024 21:58:53 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/continew/admin/job/api/JobApi.java | 15 +- .../continew/admin/job/api/JobBatchApi.java | 32 +++-- .../top/continew/admin/job/api/JobClient.java | 38 +++-- .../admin/job/enums/JobExecuteReasonEnum.java | 135 ++++++++++++++++++ .../JobExecuteStatusEnum.java} | 59 +++++--- ...esp.java => JobInstanceLogPageResult.java} | 57 +++++--- .../job/model/query/JobInstanceLogQuery.java | 77 ++++++++++ ...obTaskQuery.java => JobInstanceQuery.java} | 20 ++- .../admin/job/model/query/JobLogQuery.java | 62 ++++++-- .../admin/job/model/query/JobQuery.java | 8 +- ...{JobTaskResp.java => JobInstanceResp.java} | 83 ++++------- .../admin/job/model/resp/JobLogResp.java | 87 +++++------ .../admin/job/model/resp/JobResp.java | 19 ++- .../admin/job/service/JobLogService.java | 38 ++--- .../job/service/impl/JobLogServiceImpl.java | 36 +++-- .../job/service/impl/JobServiceImpl.java | 3 +- .../controller/tool/JobLogController.java | 37 ++--- .../changelog/mysql/continew-admin_data.sql | 5 +- 18 files changed, 552 insertions(+), 259 deletions(-) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteReasonEnum.java rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/{model/req/JobUserReq.java => enums/JobExecuteStatusEnum.java} (38%) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/{resp/JobUserResp.java => JobInstanceLogPageResult.java} (44%) create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceLogQuery.java rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/{JobTaskQuery.java => JobInstanceQuery.java} (70%) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/{JobTaskResp.java => JobInstanceResp.java} (46%) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java index 703944a0..b7d9e427 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobApi.java @@ -21,10 +21,9 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.service.annotation.*; import top.continew.admin.job.model.JobPageResult; -import top.continew.admin.job.model.query.JobQuery; import top.continew.admin.job.model.req.JobReq; import top.continew.admin.job.model.req.JobStatusReq; import top.continew.admin.job.model.resp.JobResp; @@ -44,11 +43,19 @@ public interface JobApi { /** * 分页查询列表 * - * @param query 查询条件 + * @param groupName 任务组 + * @param jobName 任务名称 + * @param jobStatus 任务状态 + * @param page 页码 + * @param size 每页条数 * @return 响应信息 */ @GetExchange("/job/page/list") - ResponseEntity>> page(@RequestPart JobQuery query); + ResponseEntity>> page(@RequestParam(value = "groupName", required = false) String groupName, + @RequestParam(value = "jobName", required = false) String jobName, + @RequestParam(value = "jobStatus", required = false) Integer jobStatus, + @RequestParam("page") int page, + @RequestParam("size") int size); /** * 新增 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java index bc4d9208..56213143 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java @@ -24,9 +24,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.service.annotation.GetExchange; import org.springframework.web.service.annotation.HttpExchange; import org.springframework.web.service.annotation.PostExchange; +import top.continew.admin.job.model.JobInstanceLogPageResult; import top.continew.admin.job.model.JobPageResult; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.model.resp.JobInstanceResp; import java.time.LocalDateTime; import java.util.List; @@ -44,13 +45,13 @@ public interface JobBatchApi { /** * 分页查询列表 * - * @param jobId 任务ID + * @param jobId 任务 ID * @param jobName 任务名称 * @param groupName 组名称 * @param taskBatchStatus 任务批次状态 * @param datetimeRange 时间范围 * @param page 页码 - * @param size 每页显示条数 + * @param size 每页条数 * @return 响应信息 */ @GetExchange("/batch/list") @@ -86,28 +87,29 @@ public interface JobBatchApi { * @param jobId 任务 ID * @param taskBatchId 任务批次 ID * @param page 页码 - * @param size 每页显示条数 + * @param size 每页条数 * @return 响应信息 */ @GetExchange("/task/list") - ResponseEntity>> pageTask(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "size") Integer size); + ResponseEntity>> pageTask(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "size") Integer size); /** - * 分页查询日志列表 + * 分页查询实例日志列表 * * @param jobId 任务 ID * @param taskBatchId 任务批次 ID * @param fromIndex 起始索引 - * @param size 每页显示条数 + * @param size 每页条数 * @return 响应信息 */ @GetExchange("/log/list") - ResponseEntity>> pageLog(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "taskId") Long taskId, - @RequestParam(value = "fromIndex") Integer fromIndex, - @RequestParam(value = "size") Integer size); + ResponseEntity pageLog(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "taskId") Long taskId, + @RequestParam(value = "startId") Integer startId, + @RequestParam(value = "fromIndex") Integer fromIndex, + @RequestParam(value = "size") Integer size); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java index 1780cd3e..f0443984 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobClient.java @@ -22,8 +22,9 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.hutool.jwt.JWTUtil; import cn.hutool.jwt.RegisteredPayload; @@ -52,6 +53,7 @@ import java.util.function.Supplier; public class JobClient { public static final Integer STATUS_SUCCESS = 1; + private static final String AUTH_URL = "/auth/login"; private final String url; private final String username; private final String password; @@ -75,9 +77,7 @@ public class JobClient { public T request(Supplier>> apiSupplier) { try { ResponseEntity> responseEntity = apiSupplier.get(); - if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { - throw new IllegalStateException("连接任务调度中心错误"); - } + this.checkResponse(responseEntity); Result result = responseEntity.getBody(); if (!STATUS_SUCCESS.equals(result.getStatus())) { throw new IllegalStateException(result.getMessage()); @@ -99,9 +99,7 @@ public class JobClient { public PageResp requestPage(Supplier>>> apiSupplier) { try { ResponseEntity>> responseEntity = apiSupplier.get(); - if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { - throw new IllegalStateException("连接任务调度中心错误"); - } + this.checkResponse(responseEntity); JobPageResult> result = responseEntity.getBody(); if (!STATUS_SUCCESS.equals(result.getStatus())) { throw new IllegalStateException(result.getMessage()); @@ -141,12 +139,28 @@ public class JobClient { Map paramMap = MapUtil.newHashMap(2); paramMap.put("username", username); paramMap.put("password", SecureUtil.md5(password)); - String responseStr = HttpUtil.post("%s/auth/login".formatted(url), JSONUtil.toJsonStr(paramMap)); - JSONObject response = JSONUtil.parseObj(responseStr); - if (!STATUS_SUCCESS.equals(response.getInt("status"))) { + HttpRequest httpRequest = HttpUtil.createPost("%s%s".formatted(url, AUTH_URL)); + httpRequest.body(JSONUtil.toJsonStr(paramMap)); + HttpResponse response = httpRequest.execute(); + if (!response.isOk() || response.body() == null) { + throw new IllegalStateException("连接任务调度中心错误"); + } + Result result = JSONUtil.toBean(response.body(), Result.class); + if (!STATUS_SUCCESS.equals(result.getStatus())) { throw new IllegalStateException("Password Authentication failed, expected a successful response. error msg: %s" - .formatted(response.getStr("message"))); + .formatted(result.getMessage())); + } + return JSONUtil.parseObj(result.getData()).getStr("token"); + } + + /** + * 检查响应 + * + * @param responseEntity 响应信息 + */ + private void checkResponse(ResponseEntity responseEntity) { + if (!responseEntity.getStatusCode().is2xxSuccessful() || responseEntity.getBody() == null) { + throw new IllegalStateException("连接任务调度中心错误"); } - return Convert.toStr(response.getByPath("data.token")); } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteReasonEnum.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteReasonEnum.java new file mode 100644 index 00000000..42c18c55 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteReasonEnum.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; + +/** + * 任务执行原因枚举 + * + * @author Charles7c + * @since 2024/7/11 22:28 + */ +@Getter +@RequiredArgsConstructor +public enum JobExecuteReasonEnum implements IBaseEnum { + + /** + * 无 + */ + NONE(0, "无"), + + /** + * 任务执行超时 + */ + TIME_OUT(1, "任务执行超时"), + + /** + * 无客户端节点 + */ + CLIENT_NOT_FOUND(2, "无客户端节点"), + + /** + * 任务已关闭 + */ + TASK_CLOSED(3, "任务已关闭"), + + /** + * 任务丢弃 + */ + TASK_DROPPED(4, "任务丢弃"), + + /** + * 任务被覆盖 + */ + TASK_COVERED(5, "任务被覆盖"), + + /** + * 无可执行任务项 + */ + TASK_NONE(6, "无可执行任务项"), + + /** + * 任务执行期间发生非预期异常 + */ + TASK_EXCEPTION(7, "任务执行期间发生非预期异常"), + + /** + * 手动停止 + */ + MANUAL_STOP(8, "手动停止"), + + /** + * 条件节点执行异常 + */ + NODE_EXCEPTION(9, "条件节点执行异常"), + + /** + * 任务中断 + */ + TASK_INTERRUPT(10, "任务中断"), + + /** + * 回调节点执行异常 + */ + CALLBACK_EXCEPTION(11, "回调节点执行异常"), + + /** + * 无需处理 + */ + NO_NEED_PROCESS(12, "无需处理"), + + /** + * 节点关闭跳过执行 + */ + NODE_SKIP(13, "节点关闭跳过执行"), + + /** + * 判定未通过 + */ + NOT_PASS(14, "判定未通过"), + + /** + * 任务已完成 + */ + TASK_FINISHED(15, "任务已完成"), + + /** + * 任务状态 + */ + TASK_RUNNING(16, "任务正在执行"), + + /** + * 任务等待执行 + */ + TASK_WAITING(17, "任务等待执行"), + + /** + * 任务执行失败 + */ + TASK_FAILED(18, "任务执行失败"), + + /** + * 任务执行成功 + */ + TASK_SUCCESS(19, "任务执行成功"),; + + private final Integer value; + private final String description; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteStatusEnum.java similarity index 38% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteStatusEnum.java index 1322a9c1..7fbf109c 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobUserReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/enums/JobExecuteStatusEnum.java @@ -14,29 +14,54 @@ * limitations under the License. */ -package top.continew.admin.job.model.req; +package top.continew.admin.job.enums; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; -import org.springframework.web.bind.annotation.PostMapping; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import top.continew.admin.common.constant.UiConstants; +import top.continew.starter.data.mybatis.plus.base.IBaseEnum; /** - * 定时任务登录用户信息 + * 任务执行状态枚举 * - * @author KAI - * @since 2024/6/26 9:15:09 + * @author Charles7c + * @since 2024/7/11 22:28 */ -@Data -@Schema(description = "定时任务登录用户信息") -public class JobUserReq { +@Getter +@RequiredArgsConstructor +public enum JobExecuteStatusEnum implements IBaseEnum { - @NotBlank(message = "用户名不能为空", groups = PostMapping.class) - @Schema(description = "用户名") - private String username; + /** + * 待处理 + */ + WAITING(1, "待处理", UiConstants.COLOR_PRIMARY), - @NotBlank(message = "密码不能为空", groups = PostMapping.class) - @Schema(description = "密码") - private String password; + /** + * 运行中 + */ + RUNNING(2, "运行中", UiConstants.COLOR_WARNING), + /** + * 成功 + */ + SUCCEEDED(3, "成功", UiConstants.COLOR_SUCCESS), + + /** + * 已失败 + */ + FAILED(4, "已失败", UiConstants.COLOR_ERROR), + + /** + * 已停止 + */ + STOPPED(5, "已停止", UiConstants.COLOR_ERROR), + + /** + * 已取消 + */ + CANCELED(6, "已取消", UiConstants.COLOR_DEFAULT),; + + private final Integer value; + private final String description; + private final String color; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java similarity index 44% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java index 3c45e196..e60f946f 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobUserResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java @@ -14,40 +14,55 @@ * limitations under the License. */ -package top.continew.admin.job.model.resp; +package top.continew.admin.job.model; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.time.LocalDateTime; +import java.io.Serial; +import java.io.Serializable; +import java.util.List; /** - * 任务用户登录返回信息 + * 任务实例日志分页信息 * - * @author KAI - * @since 2024/6/26 9:13:12 + * @author Charles7c + * @since 2024/7/14 21:51 */ @Data -@Schema(description = "任务用户登录返回信息") -public class JobUserResp { - @Schema(description = "用户ID") - private Long id; +@Schema(description = "任务实例日志分页信息") +public class JobInstanceLogPageResult implements Serializable { - @Schema(description = "用户名") - private String username; + @Serial + private static final long serialVersionUID = 1L; - @Schema(description = "角色") - private Integer role; + /** + * ID + */ + @Schema(description = "ID", example = "1") + private Long id; - @Schema(description = "认证凭证") - private String token; + /** + * 日志详情 + */ + @Schema(description = "日志详情") + private List message; - @Schema(description = "创建时间") - private LocalDateTime createDt; + /** + * 是否结束 + */ + @Schema(description = "是否结束", example = "true") + private boolean isFinished; - @Schema(description = "修改时间") - private LocalDateTime updateDt; + /** + * 起始索引 + */ + @Schema(description = "起始索引", example = "") + private Integer fromIndex; - @Schema(description = "模式") - private String mode; + /** + * 下一个开始 ID + */ + @Schema(description = "下一个开始ID", example = "") + private Long nextStartId; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceLogQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceLogQuery.java new file mode 100644 index 00000000..eb4e4d6f --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceLogQuery.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.job.model.query; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Min; +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 任务实例日志查询条件 + * + * @author KAI + * @since 2024/6/28 16:58 + */ +@Data +@Schema(description = "任务实例日志查询条件") +public class JobInstanceLogQuery implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 任务 ID + */ + @Schema(description = "任务ID", example = "1") + private Long jobId; + + /** + * 任务批次 ID + */ + @Schema(description = "任务批次ID", example = "1") + private Long taskBatchId; + + /** + * 任务实例 ID + */ + @Schema(description = "任务实例ID", example = "1") + private Long taskId; + + /** + * 开始 ID + */ + @Schema(description = "开始ID", example = "2850") + private Integer startId; + + /** + * 起始索引 + */ + @Schema(description = "起始索引", example = "0") + @Min(value = 0, message = "起始索引最小值为 {value}") + private Integer fromIndex = 0; + + /** + * 每页条数 + */ + @Schema(description = "每页条数", example = "50") + @Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})") + private Integer size = 50; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceQuery.java similarity index 70% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceQuery.java index eba6716f..4529e110 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobTaskQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobInstanceQuery.java @@ -19,19 +19,31 @@ package top.continew.admin.job.model.query; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serial; +import java.io.Serializable; + /** * 任务实例查询条件 * * @author KAI - * @since 2024/6/28 16:58:21 + * @since 2024/6/28 16:58 */ @Data @Schema(description = "任务实例查询条件") -public class JobTaskQuery { +public class JobInstanceQuery implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; - @Schema(description = "任务ID") + /** + * 任务 ID + */ + @Schema(description = "任务ID", example = "1") private Long jobId; - @Schema(description = "任务批次ID") + /** + * 任务批次 ID + */ + @Schema(description = "任务批次ID", example = "1") private Long taskBatchId; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java index 1de4283b..4790da47 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java @@ -16,34 +16,74 @@ package top.continew.admin.job.model.query; +import cn.hutool.core.date.DatePattern; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Size; import lombok.Data; +import org.hibernate.validator.constraints.Range; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDateTime; /** * 任务日志查询条件 * * @author KAI - * @since 2024/6/27 23:58:12 + * @since 2024/6/27 23:58 */ @Data @Schema(description = "任务日志查询条件") -public class JobLogQuery { +public class JobLogQuery implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; - @Schema(description = "任务ID") + /** + * 任务 ID + */ + @Schema(description = "任务ID", example = "1") private Long jobId; - @Schema(description = "任务名称") + /** + * 任务组 + */ + @Schema(description = "任务组", example = "continew-admin") + private String groupName; + + /** + * 任务名称 + */ + @Schema(description = "任务名称", example = "") private String jobName; - @Schema(description = "任务批次状态") + /** + * 任务批次状态 + */ + @Schema(description = "任务批次状态", example = "") private Integer taskBatchStatus; - @Schema(description = "任务组名称") - private String groupName; + /** + * 创建时间 + */ + @Schema(description = "创建时间", example = "2023-08-08 00:00:00,2023-08-08 23:59:59") + @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) + @Size(max = 2, message = "创建时间必须是一个范围") + private LocalDateTime[] datetimeRange; - @Schema(description = "开始时间") - private String startTime; + /** + * 页码 + */ + @Schema(description = "页码", example = "1") + @Min(value = 1, message = "页码最小值为 {value}") + private Integer page = 1; - @Schema(description = "结束时间时间") - private String endTime; + /** + * 每页条数 + */ + @Schema(description = "每页条数", example = "10") + @Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})") + private Integer size = 10; } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java index 62e477d2..da53bf2b 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobQuery.java @@ -21,6 +21,9 @@ import jakarta.validation.constraints.Min; import lombok.Data; import org.hibernate.validator.constraints.Range; +import java.io.Serial; +import java.io.Serializable; + /** * 任务查询条件 * @@ -29,7 +32,10 @@ import org.hibernate.validator.constraints.Range; */ @Data @Schema(description = "任务查询条件") -public class JobQuery { +public class JobQuery implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; /** * 任务组 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java similarity index 46% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java index 63784b3a..08d7513f 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobTaskResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java @@ -19,98 +19,69 @@ package top.continew.admin.job.model.resp; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.time.LocalDateTime; +import java.io.Serial; +import java.io.Serializable; /** - * 任务实例返回对象 + * 任务实例信息 * * @author KAI - * @since 2024/6/28 下午16:58:33 + * @author Charles7c + * @since 2024/6/28 16:58 */ -@Schema(description = "任务实例返回") @Data -public class JobTaskResp { - @Schema(description = "ID") - private Long id; +@Schema(description = "任务实例信息") +public class JobInstanceResp implements Serializable { - @Schema(description = "Key") - private Long key; + @Serial + private static final long serialVersionUID = 1L; /** - * 组名称 + * ID */ - @Schema(description = "组名称") - private String groupName; + @Schema(description = "ID", example = "1") + private Long id; /** - * 任务信息id + * 任务组 */ - @Schema(description = "任务信息 ID") - private Long jobId; + @Schema(description = "任务组", example = "continew-admin") + private String groupName; /** - * 调度任务id + * 任务 ID */ - @Schema(description = "调度任务 ID") - private Long taskBatchId; + @Schema(description = "任务ID", example = "1") + private Long jobId; /** - * 父执行器id + * 任务批次 ID */ - @Schema(description = "父执行器 ID") - private Long parentId; + @Schema(description = "任务批次ID", example = "1") + private Long taskBatchId; /** - * 执行的状态 0、失败 1、成功 + * 执行状态 */ - @Schema(description = "执行状态 (0: 失败, 1: 成功)") + @Schema(description = "执行状态", example = "1") private Integer taskStatus; /** * 重试次数 */ - @Schema(description = "重试次数") + @Schema(description = "重试次数", example = "1") private Integer retryCount; /** * 执行结果 */ - @Schema(description = "执行结果") + @Schema(description = "执行结果", example = "") private String resultMessage; /** - * 客户端ID + * 客户端信息 */ - @Schema(description = "客户端 ID") + @Schema(description = "客户端信息", example = "1812406095098114048@192.168.138.48:1789") private String clientInfo; - /** - * 执行方法参数 - */ - @Schema(description = "执行方法参数") - private String argsStr; - - /** - * 参数类型 text/json - */ - @Schema(description = "参数类型 (text/json)") - private String argsType; - - /** - * 扩展字段 - */ - @Schema(description = "扩展字段") - private String extAttrs; - - /** - * 创建时间 - */ - @Schema(description = "创建时间") - private LocalDateTime createDt; - - /** - * 修改时间 - */ - @Schema(description = "修改时间") - private LocalDateTime updateDt; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java index 0f9cc7ea..59038747 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java @@ -16,104 +16,87 @@ package top.continew.admin.job.model.resp; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.util.Date; +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDateTime; /** - * 任务批次信息 + * 任务日志信息 * * @author KAI - * @since 2024/6/27 22:50:12 + * @author Charles7c + * @since 2024/6/27 22:50 */ @Data @Schema(description = "任务日志信息") -public class JobLogResp { +public class JobLogResp implements Serializable { - @Schema(description = "主键id") - private Long id; + @Serial + private static final long serialVersionUID = 1L; /** - * 组名称 + * ID */ - @Schema(description = "组名称") - private String groupName; + @Schema(description = "ID", example = "1") + private Long id; /** - * 名称 + * 任务组 */ - @Schema(description = "名称") - private String jobName; + @Schema(description = "任务组", example = "continew-admin") + private String groupName; /** - * 工作流节点名称 + * 任务名称 */ - @Schema(description = "工作流节点名称") - private String nodeName; + @Schema(description = "任务名称", example = "定时任务1") + private String jobName; /** - * 任务信息id + * 任务 ID */ - @Schema(description = "任务信息id") + @Schema(description = "任务ID", example = "1") private Long jobId; /** * 任务状态 */ - @Schema(description = "任务状态") + @Schema(description = "任务状态", example = "") private Integer taskBatchStatus; - /** - * 创建时间 - */ - @Schema(description = "创建时间") - private Date createDt; - - /** - * 任务执行时间 - */ - @Schema(description = "任务执行时间") - private Date executionAt; /** * 操作原因 */ - @Schema(description = "操作原因") + @Schema(description = "操作原因", example = "") private Integer operationReason; /** - * 执行器类型 1、Java + * 执行器类型 */ - @Schema(description = "执行器类型 1、Java") + @Schema(description = "执行器类型", example = "1") private Integer executorType; /** * 执行器名称 */ - @Schema(description = "执行器名称") + @Schema(description = "执行器名称", example = "") private String executorInfo; - // /** - // * 工作流的回调节点信息 - // */ - // @Schema(description = "工作流的回调节点信息") - // private CallbackConfig callback; - - // /** - // * 工作流的决策节点信息 - // */ - // @Schema(description = "工作流的决策节点信息") - // private DecisionConfig decision; - /** - * 工作流批次id + * 执行时间 */ - @Schema(description = "工作流批次id") - private Long workflowTaskBatchId; + @Schema(description = "执行时间", example = "2023-08-08 08:08:08", type = "string") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime executionAt; /** - * 工作流节点id + * 创建时间 */ - @Schema(description = "工作流节点id") - private Long workflowNodeId; -} \ No newline at end of file + @Schema(description = "创建时间", example = "2023-08-08 08:08:08", type = "string") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createDt; +} diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index cf49b7b3..3c613330 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -21,6 +21,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import top.continew.admin.job.enums.*; +import java.io.Serial; +import java.io.Serializable; import java.time.LocalDateTime; /** @@ -32,7 +34,10 @@ import java.time.LocalDateTime; */ @Data @Schema(description = "任务信息") -public class JobResp { +public class JobResp implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; /** * ID @@ -61,19 +66,19 @@ public class JobResp { /** * 触发类型 */ - @Schema(description = "触发类型", example = "1") + @Schema(description = "触发类型", example = "2") private Integer triggerType; /** * 间隔时长 */ - @Schema(description = "间隔时长", example = "") + @Schema(description = "间隔时长", example = "60") private String triggerInterval; /** * 执行器类型 */ - @Schema(description = " 执行器类型", example = "") + @Schema(description = " 执行器类型", example = "1") private Integer executorType; /** @@ -145,21 +150,21 @@ public class JobResp { /** * 下次触发时间 */ - @Schema(description = "下次触发时间", example = "") + @Schema(description = "下次触发时间", example = "2023-08-08 08:09:00", type = "string") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime nextTriggerAt; /** * 创建时间 */ - @Schema(description = "创建时间", example = "") + @Schema(description = "创建时间", example = "2023-08-08 08:08:00", type = "string") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createDt; /** * 修改时间 */ - @Schema(description = "修改时间", example = "") + @Schema(description = "修改时间", example = "2023-08-08 08:08:00", type = "string") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateDt; } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java index 5ba020cb..67a0b86c 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/JobLogService.java @@ -16,13 +16,16 @@ package top.continew.admin.job.service; +import top.continew.admin.job.model.JobInstanceLogPageResult; +import top.continew.admin.job.model.query.JobInstanceLogQuery; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.query.JobInstanceQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; -import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.admin.job.model.resp.JobInstanceResp; import top.continew.starter.extension.crud.model.resp.PageResp; +import java.util.List; + /** * 任务日志业务接口 * @@ -35,20 +38,10 @@ public interface JobLogService { /** * 分页查询列表 * - * @param query 查询条件 - * @param pageQuery 分页查询条件 - * @return 分页列表信息 - */ - PageResp page(JobLogQuery query, PageQuery pageQuery); - - /** - * 查看详情 - * - * @param query 查询条件 - * @param pageQuery 分页查询条件 + * @param query 查询条件 * @return 分页列表信息 */ - PageResp detail(JobLogQuery query, PageQuery pageQuery); + PageResp page(JobLogQuery query); /** * 停止 @@ -67,11 +60,18 @@ public interface JobLogService { boolean retry(Long id); /** - * 分页查询任务实例列表 + * 查询任务实例列表 + * + * @param query 查询条件 + * @return 列表信息 + */ + List listInstance(JobInstanceQuery query); + + /** + * 分页查询任务实例日志列表 * - * @param query 查询条件 - * @param pageQuery 分页查询条件 + * @param query 查询条件 * @return 分页列表信息 */ - PageResp pageTask(JobTaskQuery query, PageQuery pageQuery); + JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index 20631d9b..e4f53b13 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -16,20 +16,20 @@ package top.continew.admin.job.service.impl; -import cn.hutool.core.date.DatePattern; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.continew.admin.job.api.JobBatchApi; import top.continew.admin.job.api.JobClient; +import top.continew.admin.job.model.JobInstanceLogPageResult; +import top.continew.admin.job.model.query.JobInstanceLogQuery; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.query.JobInstanceQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.model.resp.JobInstanceResp; import top.continew.admin.job.service.JobLogService; -import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; -import java.time.LocalDateTime; +import java.util.List; /** * 任务日志业务实现 @@ -46,19 +46,9 @@ public class JobLogServiceImpl implements JobLogService { private final JobBatchApi jobBatchApi; @Override - public PageResp page(JobLogQuery query, PageQuery pageQuery) { - LocalDateTime[] localDateTimes = new LocalDateTime[2]; - if (query != null && query.getStartTime() != null && query.getEndTime() != null) { - localDateTimes[0] = LocalDateTime.parse(query.getStartTime(), DatePattern.NORM_DATETIME_FORMATTER); - localDateTimes[1] = LocalDateTime.parse(query.getEndTime(), DatePattern.NORM_DATETIME_FORMATTER); - } + public PageResp page(JobLogQuery query) { return jobClient.requestPage(() -> jobBatchApi.page(query.getJobId(), query.getJobName(), query - .getGroupName(), query.getTaskBatchStatus(), localDateTimes, pageQuery.getPage(), pageQuery.getSize())); - } - - @Override - public PageResp detail(JobLogQuery query, PageQuery pageQuery) { - return jobClient.requestPage(() -> jobBatchApi.pageLog(query.getJobId(), 1L, 1L, 0, pageQuery.getSize())); + .getGroupName(), query.getTaskBatchStatus(), query.getDatetimeRange(), query.getPage(), query.getSize())); } @Override @@ -72,8 +62,14 @@ public class JobLogServiceImpl implements JobLogService { } @Override - public PageResp pageTask(JobTaskQuery query, PageQuery pageQuery) { - return jobClient.requestPage(() -> jobBatchApi.pageTask(query.getJobId(), query.getTaskBatchId(), pageQuery - .getPage(), pageQuery.getSize())); + public List listInstance(JobInstanceQuery query) { + return jobClient.requestPage(() -> jobBatchApi.pageTask(query.getJobId(), query.getTaskBatchId(), 1, 100)) + .getList(); + } + + @Override + public JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query) { + return jobBatchApi.pageLog(query.getJobId(), query.getTaskBatchId(), query.getTaskId(), query + .getStartId(), query.getFromIndex(), query.getSize()).getBody(); } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java index 3dc71e33..2b9c85ae 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobServiceImpl.java @@ -45,7 +45,8 @@ public class JobServiceImpl implements JobService { @Override public PageResp page(JobQuery query) { - return jobClient.requestPage(() -> jobApi.page(query)); + return jobClient.requestPage(() -> jobApi.page(query.getGroupName(), query.getJobName(), query + .getJobStatus(), query.getPage(), query.getSize())); } @Override diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java index cf82478b..f5b343bf 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java @@ -24,15 +24,19 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import top.continew.admin.job.model.JobInstanceLogPageResult; +import top.continew.admin.job.model.query.JobInstanceLogQuery; import top.continew.admin.job.model.query.JobLogQuery; -import top.continew.admin.job.model.query.JobTaskQuery; +import top.continew.admin.job.model.query.JobInstanceQuery; import top.continew.admin.job.model.resp.JobLogResp; -import top.continew.admin.job.model.resp.JobTaskResp; +import top.continew.admin.job.model.resp.JobInstanceResp; import top.continew.admin.job.service.JobLogService; -import top.continew.starter.extension.crud.model.query.PageQuery; import top.continew.starter.extension.crud.model.resp.PageResp; +import top.continew.starter.log.core.annotation.Log; import top.continew.starter.web.model.R; +import java.util.List; + /** * 任务日志 API * @@ -52,15 +56,8 @@ public class JobLogController { @Operation(summary = "分页查询任务日志列表", description = "分页查询任务日志列表") @SaCheckPermission("tool:job:log:list") @GetMapping - public R> page(JobLogQuery query, @Validated PageQuery pageQuery) { - return R.ok(baseService.page(query, pageQuery)); - } - - @Operation(summary = "查看任务日志详情", description = "查看任务日志详情") - @SaCheckPermission("tool:job:log:list") - @GetMapping("/detail") - public R> detail(JobLogQuery query, @Validated PageQuery pageQuery) { - return R.ok(baseService.detail(query, pageQuery)); + public R> page(JobLogQuery query) { + return R.ok(baseService.page(query)); } @Operation(summary = "停止任务", description = "停止任务") @@ -79,10 +76,18 @@ public class JobLogController { return baseService.retry(id) ? R.ok() : R.fail(); } - @Operation(summary = "分页查询任务实例列表", description = "分页查询任务实例列表") + @Log(ignore = true) + @Operation(summary = "查询任务实例列表", description = "查询任务实例列表") + @SaCheckPermission("tool:job:log:list") + @GetMapping("/instance") + public R> listInstance(JobInstanceQuery query) { + return R.ok(baseService.listInstance(query)); + } + + @Operation(summary = "分页查询任务实例日志列表", description = "分页查询任务实例日志列表") @SaCheckPermission("tool:job:log:list") - @GetMapping("/task") - public R> page(JobTaskQuery query, PageQuery pageQuery) { - return R.ok(baseService.pageTask(query, pageQuery)); + @GetMapping("/instance/log") + public R pageInstanceLog(JobInstanceLogQuery query) { + return R.ok(baseService.pageInstanceLog(query)); } } diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql index 9c0c7e9a..4deae945 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql @@ -185,6 +185,5 @@ VALUES (3025, '执行', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:trigger', 5, 1, 1, NOW(), NULL, NULL), (3026, '任务日志', 3020, 2, '/tool/job/log', 'ToolJobLog', 'tool/job/log/index', NULL, 'unfold', b'0', b'0', b'1', NULL, 999, 1, 1, NOW(), NULL, NULL), (3027, '查看日志', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:list', 1, 1, 1, NOW(), NULL, NULL), -(3028, '日志详情', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:detail', 2, 1, 1, NOW(), NULL, NULL), -(3029, '停止任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:stop', 3, 1, 1, NOW(), NULL, NULL), -(3030, '重试任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:retry', 4, 1, 1, NOW(), NULL, NULL); +(3028, '停止任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:stop', 2, 1, 1, NOW(), NULL, NULL), +(3029, '重试任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:retry', 3, 1, 1, NOW(), NULL, NULL); -- Gitee From 68aeab2dc0cfc0b5245910354fb71c29a88fbbe4 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 16 Jul 2024 15:10:40 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/config/HttpExchangeConfiguration.java | 6 ++++++ .../continew/admin/job/model/req/JobReq.java | 13 ++++++------ .../admin/job/model/req/JobStatusReq.java | 3 ++- .../admin/job/model/resp/JobInstanceResp.java | 1 - .../admin/job/model/resp/JobLogResp.java | 8 +++---- .../admin/job/model/resp/JobResp.java | 13 +++++------- .../{tool => schedule}/JobController.java | 18 ++++++++-------- .../{tool => schedule}/JobLogController.java | 14 ++++++------- .../changelog/mysql/continew-admin_data.sql | 21 ++++++++++--------- 9 files changed, 51 insertions(+), 46 deletions(-) rename continew-admin-webapi/src/main/java/top/continew/admin/controller/{tool => schedule}/JobController.java (90%) rename continew-admin-webapi/src/main/java/top/continew/admin/controller/{tool => schedule}/JobLogController.java (91%) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java index e873a1d8..f2af548a 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java @@ -16,6 +16,7 @@ package top.continew.admin.job.config; +import com.fasterxml.jackson.databind.ObjectMapper; import io.netty.channel.ChannelOption; import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.WriteTimeoutHandler; @@ -24,6 +25,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.http.codec.json.Jackson2JsonDecoder; +import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.web.reactive.function.client.ClientRequest; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.support.WebClientAdapter; @@ -45,6 +48,7 @@ import top.continew.admin.job.constant.JobConstants; @RequiredArgsConstructor public class HttpExchangeConfiguration { + private final ObjectMapper objectMapper; @Value("${snail-job.server.url}") private String baseUrl; @@ -76,6 +80,8 @@ public class HttpExchangeConfiguration { conn.addHandlerLast(new WriteTimeoutHandler(10)); }); WebClient webClient = WebClient.builder() + .codecs(config -> config.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper))) + .codecs(config -> config.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper))) .clientConnector(new ReactorClientHttpConnector(httpClient)) .filter((request, next) -> { // 设置请求头 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java index 3d8ecd92..c3efd08e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -21,6 +21,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; import org.hibernate.validator.constraints.Length; +import top.continew.admin.job.enums.*; import java.io.Serial; import java.io.Serializable; @@ -65,7 +66,7 @@ public class JobReq implements Serializable { */ @Schema(description = "触发类型", allowableValues = {"2", "3"}, example = "2") @NotNull(message = "触发类型非法") - private Integer triggerType; + private JobTriggerTypeEnum triggerType; /** * 间隔时长 @@ -85,7 +86,7 @@ public class JobReq implements Serializable { */ @Schema(description = "任务类型", allowableValues = {"1"}, example = "1") @NotNull(message = "任务类型非法") - private Integer taskType; + private JobTaskTypeEnum taskType; /** * 执行器名称 @@ -110,15 +111,15 @@ public class JobReq implements Serializable { * 路由策略 */ @Schema(description = "路由策略", example = "") - @NotNull(message = "路由策略不能为空") - private Integer routeKey; + @NotNull(message = "路由策略非法") + private JobRouteStrategyEnum routeKey; /** * 阻塞策略 */ @Schema(description = "阻塞策略", example = "") @NotNull(message = "阻塞策略非法") - private Integer blockStrategy; + private JobBlockStrategyEnum blockStrategy; /** * 超时时间(单位:秒) @@ -152,7 +153,7 @@ public class JobReq implements Serializable { * 任务状态 */ @Schema(description = "任务状态", example = "0") - private Integer jobStatus = 0; + private JobStatusEnum jobStatus = JobStatusEnum.DISABLED; /** * ID diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java index be8a3f5a..b55491bf 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobStatusReq.java @@ -19,6 +19,7 @@ package top.continew.admin.job.model.req; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Data; +import top.continew.admin.job.enums.JobStatusEnum; import java.io.Serial; import java.io.Serializable; @@ -42,7 +43,7 @@ public class JobStatusReq implements Serializable { */ @Schema(description = "任务状态", example = "1") @NotNull(message = "任务状态非法") - private Integer jobStatus; + private JobStatusEnum jobStatus; /** * ID diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java index 08d7513f..07a606bd 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobInstanceResp.java @@ -83,5 +83,4 @@ public class JobInstanceResp implements Serializable { */ @Schema(description = "客户端信息", example = "1812406095098114048@192.168.138.48:1789") private String clientInfo; - } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java index 59038747..4b54255c 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java @@ -19,6 +19,8 @@ package top.continew.admin.job.model.resp; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import top.continew.admin.job.enums.JobExecuteReasonEnum; +import top.continew.admin.job.enums.JobExecuteStatusEnum; import java.io.Serial; import java.io.Serializable; @@ -66,13 +68,13 @@ public class JobLogResp implements Serializable { * 任务状态 */ @Schema(description = "任务状态", example = "") - private Integer taskBatchStatus; + private JobExecuteStatusEnum taskBatchStatus; /** * 操作原因 */ @Schema(description = "操作原因", example = "") - private Integer operationReason; + private JobExecuteReasonEnum operationReason; /** * 执行器类型 @@ -90,13 +92,11 @@ public class JobLogResp implements Serializable { * 执行时间 */ @Schema(description = "执行时间", example = "2023-08-08 08:08:08", type = "string") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime executionAt; /** * 创建时间 */ @Schema(description = "创建时间", example = "2023-08-08 08:08:08", type = "string") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createDt; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index 3c613330..a8c16b90 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -67,7 +67,7 @@ public class JobResp implements Serializable { * 触发类型 */ @Schema(description = "触发类型", example = "2") - private Integer triggerType; + private JobTriggerTypeEnum triggerType; /** * 间隔时长 @@ -85,7 +85,7 @@ public class JobResp implements Serializable { * 任务类型 */ @Schema(description = "任务类型", example = "1") - private Integer taskType; + private JobTaskTypeEnum taskType; /** * 执行器名称 @@ -109,13 +109,13 @@ public class JobResp implements Serializable { * 路由策略 */ @Schema(description = "路由策略", example = "1") - private Integer routeKey; + private JobRouteStrategyEnum routeKey; /** * 阻塞策略 */ @Schema(description = "阻塞策略", example = "1") - private Integer blockStrategy; + private JobBlockStrategyEnum blockStrategy; /** * 超时时间(单位:秒) @@ -145,26 +145,23 @@ public class JobResp implements Serializable { * 任务状态 */ @Schema(description = "任务状态", example = "1") - private Integer jobStatus; + private JobStatusEnum jobStatus; /** * 下次触发时间 */ @Schema(description = "下次触发时间", example = "2023-08-08 08:09:00", type = "string") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime nextTriggerAt; /** * 创建时间 */ @Schema(description = "创建时间", example = "2023-08-08 08:08:00", type = "string") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createDt; /** * 修改时间 */ @Schema(description = "修改时间", example = "2023-08-08 08:08:00", type = "string") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateDt; } \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobController.java similarity index 90% rename from continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java rename to continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobController.java index f8d9dd99..6d52f061 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.controller.tool; +package top.continew.admin.controller.schedule; import cn.dev33.satoken.annotation.SaCheckPermission; import io.swagger.v3.oas.annotations.Operation; @@ -47,20 +47,20 @@ import java.util.List; @Validated @RestController @RequiredArgsConstructor -@RequestMapping("/job") +@RequestMapping("/schedule/job") public class JobController { private final JobService baseService; @Operation(summary = "分页查询任务列表", description = "分页查询任务列表") - @SaCheckPermission("tool:job:list") + @SaCheckPermission("schedule:job:list") @GetMapping public R> page(JobQuery query) { return R.ok(baseService.page(query)); } @Operation(summary = "新增任务", description = "新增任务") - @SaCheckPermission("tool:job:add") + @SaCheckPermission("schedule:job:add") @PostMapping public R add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody JobReq req) { return baseService.add(req) ? R.ok() : R.fail(); @@ -68,14 +68,14 @@ public class JobController { @Operation(summary = "修改任务", description = "修改任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:update") + @SaCheckPermission("schedule:job:update") @PutMapping("/{id}") public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody JobReq req, @PathVariable Long id) { return baseService.update(req, id) ? R.ok() : R.fail(); } @Operation(summary = "修改任务状态", description = "修改任务状态") - @SaCheckPermission("tool:job:update") + @SaCheckPermission("schedule:job:update") @PatchMapping("/{id}/status") public R updateStatus(@Validated @RequestBody JobStatusReq req, @PathVariable Long id) { return baseService.updateStatus(req, id) ? R.ok() : R.fail(); @@ -83,7 +83,7 @@ public class JobController { @Operation(summary = "删除任务", description = "删除任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:delete") + @SaCheckPermission("schedule:job:delete") @DeleteMapping("/{id}") public R delete(@PathVariable Long id) { return baseService.delete(id) ? R.ok() : R.fail(); @@ -91,7 +91,7 @@ public class JobController { @Operation(summary = "执行任务", description = "执行任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:trigger") + @SaCheckPermission("schedule:job:trigger") @PostMapping("/trigger/{id}") public R trigger(@PathVariable Long id) { return baseService.trigger(id) ? R.ok() : R.fail(); @@ -99,7 +99,7 @@ public class JobController { @Log(ignore = true) @Operation(summary = "查询任务分组列表", description = "查询任务分组列表") - @SaCheckPermission("tool:job:list") + @SaCheckPermission("schedule:job:list") @GetMapping("/group") public R> listGroup() { List groupList = baseService.listGroup(); diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java similarity index 91% rename from continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java rename to continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java index f5b343bf..c56649f9 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/tool/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.controller.tool; +package top.continew.admin.controller.schedule; import cn.dev33.satoken.annotation.SaCheckPermission; import io.swagger.v3.oas.annotations.Operation; @@ -48,13 +48,13 @@ import java.util.List; @Validated @RestController @RequiredArgsConstructor -@RequestMapping("/job/log") +@RequestMapping("/schedule/log") public class JobLogController { private final JobLogService baseService; @Operation(summary = "分页查询任务日志列表", description = "分页查询任务日志列表") - @SaCheckPermission("tool:job:log:list") + @SaCheckPermission("schedule:log:list") @GetMapping public R> page(JobLogQuery query) { return R.ok(baseService.page(query)); @@ -62,7 +62,7 @@ public class JobLogController { @Operation(summary = "停止任务", description = "停止任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:log:stop") + @SaCheckPermission("schedule:log:stop") @PostMapping("/stop/{id}") public R stop(@PathVariable Long id) { return baseService.stop(id) ? R.ok() : R.fail(); @@ -70,7 +70,7 @@ public class JobLogController { @Operation(summary = "重试任务", description = "重试任务") @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) - @SaCheckPermission("tool:job:log:retry") + @SaCheckPermission("schedule:log:retry") @PostMapping("/retry/{id}") public R retry(@PathVariable Long id) { return baseService.retry(id) ? R.ok() : R.fail(); @@ -78,14 +78,14 @@ public class JobLogController { @Log(ignore = true) @Operation(summary = "查询任务实例列表", description = "查询任务实例列表") - @SaCheckPermission("tool:job:log:list") + @SaCheckPermission("schedule:log:list") @GetMapping("/instance") public R> listInstance(JobInstanceQuery query) { return R.ok(baseService.listInstance(query)); } @Operation(summary = "分页查询任务实例日志列表", description = "分页查询任务实例日志列表") - @SaCheckPermission("tool:job:log:list") + @SaCheckPermission("schedule:log:list") @GetMapping("/instance/log") public R pageInstanceLog(JobInstanceLogQuery query) { return R.ok(baseService.pageInstanceLog(query)); diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql index 4deae945..221004b4 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql @@ -177,13 +177,14 @@ VALUES -- changeset Kai:3.2-1 INSERT INTO `sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES -(3020, '任务调度', 3000, 2, '/tool/job', 'ToolJob', 'tool/job/index', NULL, 'clock-circle', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), -(3021, '查看', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:list', 1, 1, 1, NOW(), NULL, NULL), -(3022, '新增', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:add', 2, 1, 1, NOW(), NULL, NULL), -(3023, '修改', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:update', 3, 1, 1, NOW(), NULL, NULL), -(3024, '删除', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:delete', 4, 1, 1, NOW(), NULL, NULL), -(3025, '执行', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:trigger', 5, 1, 1, NOW(), NULL, NULL), -(3026, '任务日志', 3020, 2, '/tool/job/log', 'ToolJobLog', 'tool/job/log/index', NULL, 'unfold', b'0', b'0', b'1', NULL, 999, 1, 1, NOW(), NULL, NULL), -(3027, '查看日志', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:list', 1, 1, 1, NOW(), NULL, NULL), -(3028, '停止任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:stop', 2, 1, 1, NOW(), NULL, NULL), -(3029, '重试任务', 3020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:job:log:retry', 3, 1, 1, NOW(), NULL, NULL); +(4000, '任务调度', 0, 1, '/schedule', 'Schedule', 'Layout', '/schedule/job', 'schedule', b'0', b'0', b'0', NULL, 997, 1, 1, NOW(), NULL, NULL), +(4010, '任务管理', 4000, 2, '/schedule/job', 'ScheduleJob', 'schedule/job/index', NULL, '', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL), +(4011, '查看', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:list', 1, 1, 1, NOW(), NULL, NULL), +(4012, '新增', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:add', 2, 1, 1, NOW(), NULL, NULL), +(4013, '修改', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:update', 3, 1, 1, NOW(), NULL, NULL), +(4014, '删除', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:delete', 4, 1, 1, NOW(), NULL, NULL), +(4015, '执行', 1010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:trigger', 5, 1, 1, NOW(), NULL, NULL), +(4020, '任务日志', 4000, 2, '/schedule/log', 'ScheduleLog', 'schedule/log/index', NULL, '', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), +(4021, '查看', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:list', 1, 1, 1, NOW(), NULL, NULL), +(4022, '停止', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 2, 1, 1, NOW(), NULL, NULL), +(4023, '重试', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 3, 1, 1, NOW(), NULL, NULL); \ No newline at end of file -- Gitee From 14b62d7728e59ac9350a1d56bca37da31d9d880f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E5=87=AF?= <1373639299@qq.com> Date: Wed, 17 Jul 2024 00:17:45 +0800 Subject: [PATCH 16/21] =?UTF-8?q?feat:=20=E6=97=A5=E5=BF=97=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20=EF=BC=88=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/logback-spring.xml | 92 +++++++++++++++++++ .../admin/job/config/SnailJobConfig.java | 29 ++++++ .../job/model/JobInstanceLogPageResult.java | 3 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../admin/ContiNewAdminApplication.java | 5 +- 5 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml create mode 100644 continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java create mode 100644 continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml b/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..ba7c7449 --- /dev/null +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + ${console.log.pattern} + utf-8 + + + + + + ${log.path}/console.log + + + ${log.path}/console.%d{yyyy-MM-dd}.log + + 1 + + + ${log.pattern} + utf-8 + + + + INFO + + + + + ${log.path}/info.log + + ${log.path}/info.%d{yyyy-MM-dd}.log + 60 + + + ${log.pattern} + + + INFO + ACCEPT + DENY + + + + + ${log.path}/error.log + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + ERROR + ACCEPT + DENY + + + + + 100 + 1024 + + + + + 100 + 1024 + + + + + + + + + + + + + + + diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java new file mode 100644 index 00000000..0bf2a090 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java @@ -0,0 +1,29 @@ +package top.continew.admin.job.config; + +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; +import com.aizuda.snailjob.client.common.appender.SnailLogbackAppender; +import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent; +import com.aizuda.snailjob.client.starter.EnableSnailJob; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.EnableScheduling; + +@AutoConfiguration +@EnableScheduling +@EnableSnailJob +public class SnailJobConfig { + + @EventListener(SnailClientStartingEvent.class) + public void onStarting(SnailClientStartingEvent event) { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + SnailLogbackAppender ca = new SnailLogbackAppender<>(); + ca.setName("snail_log_appender"); + ca.start(); + Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.addAppender(ca); + } + +} \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java index e60f946f..d1f0f3bc 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java @@ -21,7 +21,6 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; -import java.util.List; /** * 任务实例日志分页信息 @@ -46,7 +45,7 @@ public class JobInstanceLogPageResult implements Serializable { * 日志详情 */ @Schema(description = "日志详情") - private List message; + private Object message; /** * 是否结束 diff --git a/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..f48587e5 --- /dev/null +++ b/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +top.continew.admin.job.config.SnailJobConfig \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java index e957acba..431327f8 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java @@ -20,7 +20,6 @@ import cn.dev33.satoken.annotation.SaIgnore; import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.extra.spring.SpringUtil; -import com.aizuda.snailjob.client.starter.EnableSnailJob; import com.alicp.jetcache.anno.config.EnableMethodCache; import com.github.xiaoymin.knife4j.spring.configuration.Knife4jProperties; import io.swagger.v3.oas.annotations.Hidden; @@ -32,6 +31,7 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.context.annotation.ComponentScan; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import top.continew.starter.core.autoconfigure.project.ProjectProperties; @@ -46,13 +46,14 @@ import top.continew.starter.web.annotation.EnableGlobalExceptionHandler; */ @Slf4j @RestController -@EnableSnailJob +//@EnableSnailJob @EnableFileStorage @SpringBootApplication @RequiredArgsConstructor @EnableCrudRestController @EnableGlobalExceptionHandler @EnableMethodCache(basePackages = "top.continew.admin") +@ComponentScan(basePackages = {"top.continew.admin","top.continew.admin.job.config"}) public class ContiNewAdminApplication implements ApplicationRunner { private final ProjectProperties projectProperties; -- Gitee From 64fde8d843d0ea69a499583973a268e5878fe134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E5=87=AF?= <1373639299@qq.com> Date: Wed, 17 Jul 2024 00:18:04 +0800 Subject: [PATCH 17/21] =?UTF-8?q?feat:=20=E6=97=A5=E5=BF=97=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20=EF=BC=88=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yml | 2 ++ .../main/java/top/continew/admin/ContiNewAdminApplication.java | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml index a9613450..986c2245 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml @@ -20,3 +20,5 @@ mybatis-plus: logic-delete-value: 1 # 逻辑未删除全局值(默认 0,表示未删除) logic-not-delete-value: 0 +logging: + config: classpath:logback-spring.xml \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java index 431327f8..fdf6db95 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java @@ -46,7 +46,6 @@ import top.continew.starter.web.annotation.EnableGlobalExceptionHandler; */ @Slf4j @RestController -//@EnableSnailJob @EnableFileStorage @SpringBootApplication @RequiredArgsConstructor -- Gitee From 51065483a71250ed1ae7f27b2497e4ff1879c4e4 Mon Sep 17 00:00:00 2001 From: KAI <1373639299@qq.com> Date: Wed, 17 Jul 2024 21:30:30 +0800 Subject: [PATCH 18/21] =?UTF-8?q?feat:=20=E6=97=A5=E5=BF=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/continew/admin/job/api/JobBatchApi.java | 16 ++++++++++------ .../job/model/JobInstanceLogPageResult.java | 3 ++- .../job/service/impl/JobLogServiceImpl.java | 6 ++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java index 56213143..d2c5c1fa 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java @@ -16,6 +16,9 @@ package top.continew.admin.job.api; + +import com.aizuda.snailjob.common.core.model.Result; +import com.alibaba.fastjson.JSONObject; import com.aizuda.snailjob.common.core.model.Result; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -105,11 +108,12 @@ public interface JobBatchApi { * @param size 每页条数 * @return 响应信息 */ +// JobInstanceLogPageResult @GetExchange("/log/list") - ResponseEntity pageLog(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "taskId") Long taskId, - @RequestParam(value = "startId") Integer startId, - @RequestParam(value = "fromIndex") Integer fromIndex, - @RequestParam(value = "size") Integer size); + ResponseEntity> pageLog(@RequestParam(value = "jobId", required = false) Long jobId, + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "taskId") Long taskId, + @RequestParam(value = "startId") Integer startId, + @RequestParam(value = "fromIndex") Integer fromIndex, + @RequestParam(value = "size") Integer size); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java index d1f0f3bc..ea005f31 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java @@ -18,6 +18,7 @@ package top.continew.admin.job.model; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; import java.io.Serial; import java.io.Serializable; @@ -45,7 +46,7 @@ public class JobInstanceLogPageResult implements Serializable { * 日志详情 */ @Schema(description = "日志详情") - private Object message; + private List message; /** * 是否结束 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index e4f53b13..0125dcea 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -16,6 +16,7 @@ package top.continew.admin.job.service.impl; +import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.continew.admin.job.api.JobBatchApi; @@ -30,6 +31,7 @@ import top.continew.admin.job.service.JobLogService; import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; +import java.util.Objects; /** * 任务日志业务实现 @@ -69,7 +71,7 @@ public class JobLogServiceImpl implements JobLogService { @Override public JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query) { - return jobBatchApi.pageLog(query.getJobId(), query.getTaskBatchId(), query.getTaskId(), query - .getStartId(), query.getFromIndex(), query.getSize()).getBody(); + return Objects.requireNonNull(jobBatchApi.pageLog(query.getJobId(), query.getTaskBatchId(), query.getTaskId(), query + .getStartId(), query.getFromIndex(), query.getSize()).getBody()).getData(); } } -- Gitee From cad4ea4f549b258761543ecd9c0cb320a0dbfd81 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 18 Jul 2024 13:41:00 +0800 Subject: [PATCH 19/21] =?UTF-8?q?=E6=9C=80=E5=90=8E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yml | 2 + .../src/main/resources/logback-spring.xml | 136 +++++++++--------- .../continew/admin/job/api/JobBatchApi.java | 17 +-- .../job/config/HttpExchangeConfiguration.java | 4 +- ...Config.java => SnailJobConfiguration.java} | 47 ++++-- .../job/model/JobInstanceLogPageResult.java | 4 +- .../admin/job/model/resp/JobLogResp.java | 1 - .../admin/job/model/resp/JobResp.java | 1 - .../job/service/impl/JobLogServiceImpl.java | 5 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../admin/ContiNewAdminApplication.java | 2 - .../controller/schedule/JobLogController.java | 2 - 12 files changed, 115 insertions(+), 107 deletions(-) rename continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/{SnailJobConfig.java => SnailJobConfiguration.java} (31%) delete mode 100644 continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml index 986c2245..70d8cbed 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/config/application.yml @@ -20,5 +20,7 @@ mybatis-plus: logic-delete-value: 1 # 逻辑未删除全局值(默认 0,表示未删除) logic-not-delete-value: 0 + +--- ### 日志配置 logging: config: classpath:logback-spring.xml \ No newline at end of file diff --git a/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml b/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml index ba7c7449..8a911d22 100644 --- a/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml +++ b/continew-admin-extension/continew-admin-job-server/src/main/resources/logback-spring.xml @@ -1,92 +1,88 @@ - - - - + + + - - - - ${console.log.pattern} - utf-8 - - + + + + + + + + + + + + + - - - ${log.path}/console.log - - - ${log.path}/console.%d{yyyy-MM-dd}.log - - 1 - + + - ${log.pattern} - utf-8 + ${CONSOLE_LOG_PATTERN} + ${LOG_CHARSET} - - - INFO - - - ${log.path}/info.log - - ${log.path}/info.%d{yyyy-MM-dd}.log - 60 - + + - ${log.pattern} + ${FILE_LOG_PATTERN} + ${LOG_CHARSET} - - INFO - ACCEPT - DENY - - - ${log.path}/error.log - - ${log.path}/error.%d{yyyy-MM-dd}.log - - 60 + + + + ${LOG_PATH}/${APP_NAME}.log + + + + ${LOG_PATH}/%d{yyyy-MM-dd}/${APP_NAME}.%d{yyyy-MM-dd}.%i.log.gz + + ${FILE_MAX_SIZE} + + ${FILE_MAX_HISTORY} - ${log.pattern} + ${FILE_LOG_PATTERN} + ${LOG_CHARSET} - - ERROR - ACCEPT - DENY - - - 100 - 1024 - + + + + 0 + + 512 + + - - 100 - 1024 - - + + - - - + + + + + + + + - - - - - - - + + + + + + + + + + diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java index d2c5c1fa..98457fd3 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/api/JobBatchApi.java @@ -16,9 +16,7 @@ package top.continew.admin.job.api; - import com.aizuda.snailjob.common.core.model.Result; -import com.alibaba.fastjson.JSONObject; import com.aizuda.snailjob.common.core.model.Result; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -85,7 +83,7 @@ public interface JobBatchApi { ResponseEntity> retry(@PathVariable("id") Long id); /** - * 分页查询任务列表 + * 分页查询任务实例列表 * * @param jobId 任务 ID * @param taskBatchId 任务批次 ID @@ -100,7 +98,7 @@ public interface JobBatchApi { @RequestParam(value = "size") Integer size); /** - * 分页查询实例日志列表 + * 分页查询任务实例日志列表 * * @param jobId 任务 ID * @param taskBatchId 任务批次 ID @@ -108,12 +106,11 @@ public interface JobBatchApi { * @param size 每页条数 * @return 响应信息 */ -// JobInstanceLogPageResult @GetExchange("/log/list") ResponseEntity> pageLog(@RequestParam(value = "jobId", required = false) Long jobId, - @RequestParam(value = "taskBatchId") Long taskBatchId, - @RequestParam(value = "taskId") Long taskId, - @RequestParam(value = "startId") Integer startId, - @RequestParam(value = "fromIndex") Integer fromIndex, - @RequestParam(value = "size") Integer size); + @RequestParam(value = "taskBatchId") Long taskBatchId, + @RequestParam(value = "taskId") Long taskId, + @RequestParam(value = "startId") Integer startId, + @RequestParam(value = "fromIndex") Integer fromIndex, + @RequestParam(value = "size") Integer size); } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java index f2af548a..1c7f16a1 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/HttpExchangeConfiguration.java @@ -80,8 +80,8 @@ public class HttpExchangeConfiguration { conn.addHandlerLast(new WriteTimeoutHandler(10)); }); WebClient webClient = WebClient.builder() - .codecs(config -> config.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper))) - .codecs(config -> config.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper))) + .codecs(config -> config.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper))) + .codecs(config -> config.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper))) .clientConnector(new ReactorClientHttpConnector(httpClient)) .filter((request, next) -> { // 设置请求头 diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfiguration.java similarity index 31% rename from continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java rename to continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfiguration.java index 0bf2a090..04cb721e 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfig.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/config/SnailJobConfiguration.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package top.continew.admin.job.config; import ch.qos.logback.classic.Logger; @@ -7,23 +23,28 @@ import com.aizuda.snailjob.client.common.appender.SnailLogbackAppender; import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent; import com.aizuda.snailjob.client.starter.EnableSnailJob; import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Configuration; import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.EnableScheduling; -@AutoConfiguration -@EnableScheduling +/** + * Snail Job 配置 + * + * @author KAI + * @since 2024/6/26 9:19 + */ +@Configuration @EnableSnailJob -public class SnailJobConfig { +public class SnailJobConfiguration { + /** + * 日志上报 + */ @EventListener(SnailClientStartingEvent.class) - public void onStarting(SnailClientStartingEvent event) { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - SnailLogbackAppender ca = new SnailLogbackAppender<>(); - ca.setName("snail_log_appender"); - ca.start(); - Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME); - rootLogger.addAppender(ca); + public void onStarting() { + SnailLogbackAppender appender = new SnailLogbackAppender<>(); + appender.start(); + LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory(); + Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.addAppender(appender); } - } \ No newline at end of file diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java index ea005f31..754004af 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/JobInstanceLogPageResult.java @@ -57,12 +57,12 @@ public class JobInstanceLogPageResult implements Serializable { /** * 起始索引 */ - @Schema(description = "起始索引", example = "") + @Schema(description = "起始索引", example = "0") private Integer fromIndex; /** * 下一个开始 ID */ - @Schema(description = "下一个开始ID", example = "") + @Schema(description = "下一个开始ID", example = "9") private Long nextStartId; } diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java index 4b54255c..91033e74 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java @@ -16,7 +16,6 @@ package top.continew.admin.job.model.resp; -import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import top.continew.admin.job.enums.JobExecuteReasonEnum; diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index a8c16b90..218e5aff 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -16,7 +16,6 @@ package top.continew.admin.job.model.resp; -import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import top.continew.admin.job.enums.*; diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java index 0125dcea..f881f616 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/service/impl/JobLogServiceImpl.java @@ -16,7 +16,6 @@ package top.continew.admin.job.service.impl; -import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.continew.admin.job.api.JobBatchApi; @@ -71,7 +70,7 @@ public class JobLogServiceImpl implements JobLogService { @Override public JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query) { - return Objects.requireNonNull(jobBatchApi.pageLog(query.getJobId(), query.getTaskBatchId(), query.getTaskId(), query - .getStartId(), query.getFromIndex(), query.getSize()).getBody()).getData(); + return Objects.requireNonNull(jobBatchApi.pageLog(query.getJobId(), query.getTaskBatchId(), query + .getTaskId(), query.getStartId(), query.getFromIndex(), query.getSize()).getBody()).getData(); } } diff --git a/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index f48587e5..00000000 --- a/continew-admin-plugins/continew-admin-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -top.continew.admin.job.config.SnailJobConfig \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java index fdf6db95..79764610 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/ContiNewAdminApplication.java @@ -31,7 +31,6 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.context.annotation.ComponentScan; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import top.continew.starter.core.autoconfigure.project.ProjectProperties; @@ -52,7 +51,6 @@ import top.continew.starter.web.annotation.EnableGlobalExceptionHandler; @EnableCrudRestController @EnableGlobalExceptionHandler @EnableMethodCache(basePackages = "top.continew.admin") -@ComponentScan(basePackages = {"top.continew.admin","top.continew.admin.job.config"}) public class ContiNewAdminApplication implements ApplicationRunner { private final ProjectProperties projectProperties; diff --git a/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java index c56649f9..e924e2dc 100644 --- a/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java +++ b/continew-admin-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java @@ -32,7 +32,6 @@ import top.continew.admin.job.model.resp.JobLogResp; import top.continew.admin.job.model.resp.JobInstanceResp; import top.continew.admin.job.service.JobLogService; import top.continew.starter.extension.crud.model.resp.PageResp; -import top.continew.starter.log.core.annotation.Log; import top.continew.starter.web.model.R; import java.util.List; @@ -76,7 +75,6 @@ public class JobLogController { return baseService.retry(id) ? R.ok() : R.fail(); } - @Log(ignore = true) @Operation(summary = "查询任务实例列表", description = "查询任务实例列表") @SaCheckPermission("schedule:log:list") @GetMapping("/instance") -- Gitee From 87063690c748ba8301ee934b08f1dd03839fefbe Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 18 Jul 2024 13:48:53 +0800 Subject: [PATCH 20/21] =?UTF-8?q?=E6=9C=80=E5=90=8E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/job/model/query/JobLogQuery.java | 4 ++-- .../continew/admin/job/model/req/JobReq.java | 18 +++++++++--------- .../admin/job/model/resp/JobLogResp.java | 6 +++--- .../continew/admin/job/model/resp/JobResp.java | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java index 4790da47..b1fc4e43 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/query/JobLogQuery.java @@ -56,13 +56,13 @@ public class JobLogQuery implements Serializable { /** * 任务名称 */ - @Schema(description = "任务名称", example = "") + @Schema(description = "任务名称", example = "定时任务1") private String jobName; /** * 任务批次状态 */ - @Schema(description = "任务批次状态", example = "") + @Schema(description = "任务批次状态", example = "1") private Integer taskBatchStatus; /** diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java index c3efd08e..88f099cc 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/req/JobReq.java @@ -50,7 +50,7 @@ public class JobReq implements Serializable { /** * 任务名称 */ - @Schema(description = "任务名称", example = "密码到期提醒") + @Schema(description = "任务名称", example = "定时任务1") @NotBlank(message = "任务名称不能为空") @Length(max = 64, message = "任务名称不能超过 {max} 个字符") private String jobName; @@ -58,13 +58,13 @@ public class JobReq implements Serializable { /** * 描述 */ - @Schema(description = "描述", example = "每天凌晨1点检查密码是否已到期") + @Schema(description = "描述", example = "定时任务1的描述") private String description; /** * 触发类型 */ - @Schema(description = "触发类型", allowableValues = {"2", "3"}, example = "2") + @Schema(description = "触发类型", example = "2") @NotNull(message = "触发类型非法") private JobTriggerTypeEnum triggerType; @@ -78,20 +78,20 @@ public class JobReq implements Serializable { /** * 执行器类型 */ - @Schema(description = "执行器类型", allowableValues = {"1"}, example = "1", defaultValue = "1") + @Schema(description = "执行器类型", example = "1", defaultValue = "1") private Integer executorType = 1; /** * 任务类型 */ - @Schema(description = "任务类型", allowableValues = {"1"}, example = "1") + @Schema(description = "任务类型", example = "1") @NotNull(message = "任务类型非法") private JobTaskTypeEnum taskType; /** * 执行器名称 */ - @Schema(description = "执行器名称", example = "1") + @Schema(description = "执行器名称", example = "test") @NotBlank(message = "执行器名称不能为空") private String executorInfo; @@ -110,14 +110,14 @@ public class JobReq implements Serializable { /** * 路由策略 */ - @Schema(description = "路由策略", example = "") + @Schema(description = "路由策略", example = "4") @NotNull(message = "路由策略非法") private JobRouteStrategyEnum routeKey; /** * 阻塞策略 */ - @Schema(description = "阻塞策略", example = "") + @Schema(description = "阻塞策略", example = "1") @NotNull(message = "阻塞策略非法") private JobBlockStrategyEnum blockStrategy; @@ -152,7 +152,7 @@ public class JobReq implements Serializable { /** * 任务状态 */ - @Schema(description = "任务状态", example = "0") + @Schema(description = "任务状态", example = "0", defaultValue = "0") private JobStatusEnum jobStatus = JobStatusEnum.DISABLED; /** diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java index 91033e74..3a578ad5 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobLogResp.java @@ -66,13 +66,13 @@ public class JobLogResp implements Serializable { /** * 任务状态 */ - @Schema(description = "任务状态", example = "") + @Schema(description = "任务状态", example = "3") private JobExecuteStatusEnum taskBatchStatus; /** * 操作原因 */ - @Schema(description = "操作原因", example = "") + @Schema(description = "操作原因", example = "0") private JobExecuteReasonEnum operationReason; /** @@ -84,7 +84,7 @@ public class JobLogResp implements Serializable { /** * 执行器名称 */ - @Schema(description = "执行器名称", example = "") + @Schema(description = "执行器名称", example = "test") private String executorInfo; /** diff --git a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java index 218e5aff..0d96f0f5 100644 --- a/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java +++ b/continew-admin-plugins/continew-admin-job/src/main/java/top/continew/admin/job/model/resp/JobResp.java @@ -89,7 +89,7 @@ public class JobResp implements Serializable { /** * 执行器名称 */ - @Schema(description = "执行器名称", example = "") + @Schema(description = "执行器名称", example = "test") private String executorInfo; /** -- Gitee From af5b385357465cf24922f0abbf2efc901b4e0e8d Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 18 Jul 2024 13:59:24 +0800 Subject: [PATCH 21/21] =?UTF-8?q?=E6=9C=80=E5=90=8E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/db/changelog/mysql/continew-admin_data.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql index 221004b4..68b78a06 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/mysql/continew-admin_data.sql @@ -178,13 +178,13 @@ VALUES INSERT INTO `sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES (4000, '任务调度', 0, 1, '/schedule', 'Schedule', 'Layout', '/schedule/job', 'schedule', b'0', b'0', b'0', NULL, 997, 1, 1, NOW(), NULL, NULL), -(4010, '任务管理', 4000, 2, '/schedule/job', 'ScheduleJob', 'schedule/job/index', NULL, '', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL), +(4010, '任务管理', 4000, 2, '/schedule/job', 'ScheduleJob', 'schedule/job/index', NULL, 'select-all', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL), (4011, '查看', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:list', 1, 1, 1, NOW(), NULL, NULL), (4012, '新增', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:add', 2, 1, 1, NOW(), NULL, NULL), (4013, '修改', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:update', 3, 1, 1, NOW(), NULL, NULL), (4014, '删除', 4010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:delete', 4, 1, 1, NOW(), NULL, NULL), (4015, '执行', 1010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:job:trigger', 5, 1, 1, NOW(), NULL, NULL), -(4020, '任务日志', 4000, 2, '/schedule/log', 'ScheduleLog', 'schedule/log/index', NULL, '', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), +(4020, '任务日志', 4000, 2, '/schedule/log', 'ScheduleLog', 'schedule/log/index', NULL, 'find-replace', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), (4021, '查看', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:list', 1, 1, 1, NOW(), NULL, NULL), (4022, '停止', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 2, 1, 1, NOW(), NULL, NULL), (4023, '重试', 4020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 3, 1, 1, NOW(), NULL, NULL); \ No newline at end of file -- Gitee