From 674e7520cc7a004cf28c8ffcefdc68db7fc3ff0a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Sep 2024 20:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E4=BF=A1=E5=88=9B=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=9A?= =?UTF-8?q?=E5=A4=A7=E9=87=91=E6=95=B0=E6=8D=AE=E5=BA=93=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20Quartz=20=E7=9A=84=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/kingbase/quartz.sql | 170 ++++++++++++++++++ sql/tools/README.md | 7 +- sql/tools/docker-compose.yaml | 6 +- .../IdTypeEnvironmentPostProcessor.java | 1 + .../mybatis/core/query/QueryWrapperX.java | 2 +- 5 files changed, 176 insertions(+), 10 deletions(-) create mode 100644 sql/kingbase/quartz.sql diff --git a/sql/kingbase/quartz.sql b/sql/kingbase/quartz.sql new file mode 100644 index 000000000..ff1e215d1 --- /dev/null +++ b/sql/kingbase/quartz.sql @@ -0,0 +1,170 @@ +set client_min_messages = WARNING; +DROP TABLE IF EXISTS qrtz_fired_triggers; +DROP TABLE IF EXISTS qrtz_paused_trigger_grps; +DROP TABLE IF EXISTS qrtz_scheduler_state; +DROP TABLE IF EXISTS qrtz_locks; +DROP TABLE IF EXISTS qrtz_simprop_triggers; +DROP TABLE IF EXISTS qrtz_simple_triggers; +DROP TABLE IF EXISTS qrtz_cron_triggers; +DROP TABLE IF EXISTS qrtz_blob_triggers; +DROP TABLE IF EXISTS qrtz_triggers; +DROP TABLE IF EXISTS qrtz_job_details; +DROP TABLE IF EXISTS qrtz_calendars; +set client_min_messages = NOTICE; + +CREATE TABLE qrtz_job_details + ( + sched_name TEXT NOT NULL, + job_name TEXT NOT NULL, + job_group TEXT NOT NULL, + description TEXT NULL, + job_class_name TEXT NOT NULL, + is_durable BOOL NOT NULL, + is_nonconcurrent BOOL NOT NULL, + is_update_data BOOL NOT NULL, + requests_recovery BOOL NOT NULL, + job_data BYTEA NULL, + PRIMARY KEY (sched_name,job_name,job_group) +); + +CREATE TABLE qrtz_triggers + ( + sched_name TEXT NOT NULL, + trigger_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + job_name TEXT NOT NULL, + job_group TEXT NOT NULL, + description TEXT NULL, + next_fire_time BIGINT NULL, + prev_fire_time BIGINT NULL, + priority INTEGER NULL, + trigger_state TEXT NOT NULL, + trigger_type TEXT NOT NULL, + start_time BIGINT NOT NULL, + end_time BIGINT NULL, + calendar_name TEXT NULL, + misfire_instr SMALLINT NULL, + job_data BYTEA NULL, + PRIMARY KEY (sched_name,trigger_name,trigger_group), + FOREIGN KEY (sched_name,job_name,job_group) + REFERENCES qrtz_job_details(sched_name,job_name,job_group) +); + +CREATE TABLE qrtz_simple_triggers + ( + sched_name TEXT NOT NULL, + trigger_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + repeat_count BIGINT NOT NULL, + repeat_interval BIGINT NOT NULL, + times_triggered BIGINT NOT NULL, + PRIMARY KEY (sched_name,trigger_name,trigger_group), + FOREIGN KEY (sched_name,trigger_name,trigger_group) + REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE +); + +CREATE TABLE QRTZ_SIMPROP_TRIGGERS + ( + sched_name TEXT NOT NULL, + trigger_name TEXT NOT NULL , + trigger_group TEXT NOT NULL , + str_prop_1 TEXT NULL, + str_prop_2 TEXT NULL, + str_prop_3 TEXT NULL, + int_prop_1 INTEGER NULL, + int_prop_2 INTEGER NULL, + long_prop_1 BIGINT NULL, + long_prop_2 BIGINT NULL, + dec_prop_1 NUMERIC NULL, + dec_prop_2 NUMERIC NULL, + bool_prop_1 BOOL NULL, + bool_prop_2 BOOL NULL, + time_zone_id TEXT NULL, + PRIMARY KEY (sched_name,trigger_name,trigger_group), + FOREIGN KEY (sched_name,trigger_name,trigger_group) + REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE +); + +CREATE TABLE qrtz_cron_triggers + ( + sched_name TEXT NOT NULL, + trigger_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + cron_expression TEXT NOT NULL, + time_zone_id TEXT, + PRIMARY KEY (sched_name,trigger_name,trigger_group), + FOREIGN KEY (sched_name,trigger_name,trigger_group) + REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE +); + +CREATE TABLE qrtz_blob_triggers + ( + sched_name TEXT NOT NULL, + trigger_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + blob_data BYTEA NULL, + PRIMARY KEY (sched_name,trigger_name,trigger_group), + FOREIGN KEY (sched_name,trigger_name,trigger_group) + REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE +); + +CREATE TABLE qrtz_calendars + ( + sched_name TEXT NOT NULL, + calendar_name TEXT NOT NULL, + calendar BYTEA NOT NULL, + PRIMARY KEY (sched_name,calendar_name) +); + +CREATE TABLE qrtz_paused_trigger_grps + ( + sched_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + PRIMARY KEY (sched_name,trigger_group) +); + +CREATE TABLE qrtz_fired_triggers + ( + sched_name TEXT NOT NULL, + entry_id TEXT NOT NULL, + trigger_name TEXT NOT NULL, + trigger_group TEXT NOT NULL, + instance_name TEXT NOT NULL, + fired_time BIGINT NOT NULL, + sched_time BIGINT NOT NULL, + priority INTEGER NOT NULL, + state TEXT NOT NULL, + job_name TEXT NULL, + job_group TEXT NULL, + is_nonconcurrent BOOL NOT NULL, + requests_recovery BOOL NULL, + PRIMARY KEY (sched_name,entry_id) +); + +CREATE TABLE qrtz_scheduler_state + ( + sched_name TEXT NOT NULL, + instance_name TEXT NOT NULL, + last_checkin_time BIGINT NOT NULL, + checkin_interval BIGINT NOT NULL, + PRIMARY KEY (sched_name,instance_name) +); + +CREATE TABLE qrtz_locks + ( + sched_name TEXT NOT NULL, + lock_name TEXT NOT NULL, + PRIMARY KEY (sched_name,lock_name) +); + +create index idx_qrtz_j_req_recovery on qrtz_job_details(requests_recovery); +create index idx_qrtz_t_next_fire_time on qrtz_triggers(next_fire_time); +create index idx_qrtz_t_state on qrtz_triggers(trigger_state); +create index idx_qrtz_t_nft_st on qrtz_triggers(next_fire_time,trigger_state); +create index idx_qrtz_ft_trig_name on qrtz_fired_triggers(trigger_name); +create index idx_qrtz_ft_trig_group on qrtz_fired_triggers(trigger_group); +create index idx_qrtz_ft_trig_nm_gp on qrtz_fired_triggers(sched_name,trigger_name,trigger_group); +create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(instance_name); +create index idx_qrtz_ft_job_name on qrtz_fired_triggers(job_name); +create index idx_qrtz_ft_job_group on qrtz_fired_triggers(job_group); +create index idx_qrtz_ft_job_req_recovery on qrtz_fired_triggers(requests_recovery); diff --git a/sql/tools/README.md b/sql/tools/README.md index 589fb8a98..4c2221325 100644 --- a/sql/tools/README.md +++ b/sql/tools/README.md @@ -61,14 +61,13 @@ exit ① 下载人大金仓 Docker 镜像: -> x86_64 版本: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar - -> aarch64 版本:https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar +* [x86_64 版本](https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar) 【Windows 选择这个】 +* [aarch64 版本](https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar) 【MacBook Apple Silicon 选择这个】 ② 加载镜像文件,在镜像 tar 文件所在目录运行: ```Bash -docker load -i x86_64/kdb_x86_64_V009R001C001B0025.tar +docker load -i kdb_x86_64_V009R001C001B0025.tar ``` ③ 在项目 `sql/tools` 目录下运行: diff --git a/sql/tools/docker-compose.yaml b/sql/tools/docker-compose.yaml index 80b8ab74b..85623c1d9 100644 --- a/sql/tools/docker-compose.yaml +++ b/sql/tools/docker-compose.yaml @@ -73,7 +73,6 @@ services: # docker compose exec sqlserver bash /tmp/create_schema.sh - ./sqlserver/create_schema.sh:/tmp/create_schema.sh:ro - dm8: # docker load -i dm8_20240715_x86_rh6_rq_single.tar image: dm8_single:dm8_20240715_rev232765_x86_rh6_64 @@ -94,10 +93,8 @@ services: - ../dm/ruoyi-vue-pro-dm8.sql:/tmp/schema.sql:ro kingbase: - # x86_64: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar - # aarch64: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar - # docker load -i kdb_x86_64_V009R001C001B0025.tar image: kingbase_v009r001c001b0025_single_x86:v1 +# image: kingbase_v009r001c001b0025_single_arm:v1 restart: unless-stopped environment: DB_USER: root @@ -107,7 +104,6 @@ services: volumes: - kingbase:/home/kingbase/userdata - ../kingbase/ruoyi-vue-pro.sql:/tmp/schema.sql:ro - # docker compose exec kingbase bash -c 'ksql -U $DB_USER -d test -f /tmp/schema.sql' opengauss: image: opengauss/opengauss:5.0.0 diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/IdTypeEnvironmentPostProcessor.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/IdTypeEnvironmentPostProcessor.java index 53f0d4089..3a67b905f 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/IdTypeEnvironmentPostProcessor.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/IdTypeEnvironmentPostProcessor.java @@ -83,6 +83,7 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor driverClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate"; break; case DM: + case KINGBASE_ES: driverClass = "org.quartz.impl.jdbcjobstore.StdJDBCDelegate"; break; } diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java index 57862ebb0..087b1b846 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java @@ -157,7 +157,7 @@ public class QueryWrapperX extends QueryWrapper { case SQL_SERVER2005: super.select("TOP " + n + " *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段 break; - default: // MySQL、PostgreSQL、DM 达梦都是采用 LIMIT 实现 + default: // MySQL、PostgreSQL、DM 达梦、KingbaseES 大金都是采用 LIMIT 实现 super.last("LIMIT " + n); } return this;