From fe61dcd0364456535f9adaec6a612da2f4d31af0 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Fri, 29 Mar 2024 20:04:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=AF=B9=E9=BD=903.2.0=20mysql?= =?UTF-8?q?=E7=89=88=E6=9C=ACDDL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/sql/easy_retry_oracle.sql | 40 ++++----- doc/sql/easy_retry_postgre.sql | 134 ++++++++++++++++--------------- doc/sql/easy_retry_sqlserver.sql | 57 +++++++++---- 3 files changed, 132 insertions(+), 99 deletions(-) diff --git a/doc/sql/easy_retry_oracle.sql b/doc/sql/easy_retry_oracle.sql index 0304c849..87eeb72c 100644 --- a/doc/sql/easy_retry_oracle.sql +++ b/doc/sql/easy_retry_oracle.sql @@ -194,7 +194,8 @@ CREATE TABLE retry_task_log ext_attrs CLOB DEFAULT '', retry_status SMALLINT DEFAULT 0, task_type SMALLINT DEFAULT 1, - create_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP + create_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX idx_retry_task_log_1 ON retry_task_log (namespace_id, group_name, scene_name); @@ -218,6 +219,7 @@ COMMENT ON COLUMN retry_task_log.ext_attrs IS '扩展字段'; COMMENT ON COLUMN retry_task_log.retry_status IS '重试状态 0、重试中 1、成功 2、最大次数'; COMMENT ON COLUMN retry_task_log.task_type IS '任务类型 1、重试数据 2、回调数据'; COMMENT ON COLUMN retry_task_log.create_dt IS '创建时间'; +COMMENT ON COLUMN retry_task_log.update_dt IS '修改时间'; -- retry_task_log_message CREATE TABLE retry_task_log_message @@ -657,30 +659,32 @@ COMMENT ON COLUMN retry_summary.update_dt IS '修改时间'; -- job_summary CREATE TABLE job_summary ( - id NUMBER GENERATED ALWAYS AS IDENTITY, - namespace_id VARCHAR2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', - group_name VARCHAR2(64) DEFAULT '', - job_id NUMBER(20) NOT NULL, - trigger_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - success_num INT DEFAULT 0, - fail_num INT DEFAULT 0, - fail_reason VARCHAR2(512) DEFAULT '', - stop_num INT DEFAULT 0, - stop_reason VARCHAR2(512) DEFAULT '', - cancel_num INT DEFAULT 0, - cancel_reason VARCHAR2(512) DEFAULT '', - create_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - update_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP + id NUMBER GENERATED ALWAYS AS IDENTITY, + namespace_id VARCHAR2(64) DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name VARCHAR2(64) DEFAULT '', + business_id NUMBER(20) NOT NULL, + system_task_type SMALLINT DEFAULT '3', + trigger_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + success_num INT DEFAULT 0, + fail_num INT DEFAULT 0, + fail_reason VARCHAR2(512) DEFAULT '', + stop_num INT DEFAULT 0, + stop_reason VARCHAR2(512) DEFAULT '', + cancel_num INT DEFAULT 0, + cancel_reason VARCHAR2(512) DEFAULT '', + create_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -CREATE UNIQUE INDEX uk_job_summary_1 ON job_summary (job_id, trigger_at); -CREATE INDEX idx_job_summary_1 ON job_summary (namespace_id, group_name, job_id); +CREATE UNIQUE INDEX uk_job_summary_1 ON job_summary (business_id, trigger_at); +CREATE INDEX idx_job_summary_1 ON job_summary (namespace_id, group_name, business_id); COMMENT ON TABLE job_summary IS 'DashBoard_Job'; COMMENT ON COLUMN job_summary.id IS '主键'; COMMENT ON COLUMN job_summary.namespace_id IS '命名空间id'; COMMENT ON COLUMN job_summary.group_name IS '组名称'; -COMMENT ON COLUMN job_summary.job_id IS '任务信息id'; +COMMENT ON COLUMN job_summary.business_id IS '业务id (job_id或workflow_id)'; +COMMENT ON COLUMN job_summary.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务'; COMMENT ON COLUMN job_summary.trigger_at IS '统计时间'; COMMENT ON COLUMN job_summary.success_num IS '执行成功-日志数量'; COMMENT ON COLUMN job_summary.fail_num IS '执行失败-日志数量'; diff --git a/doc/sql/easy_retry_postgre.sql b/doc/sql/easy_retry_postgre.sql index a8fa3f30..655eed87 100644 --- a/doc/sql/easy_retry_postgre.sql +++ b/doc/sql/easy_retry_postgre.sql @@ -28,17 +28,17 @@ VALUES ('Default', '764d604ec6fc45f68cd92514c40e9e1a', now(), now(), 0); CREATE TABLE group_config ( id BIGSERIAL PRIMARY KEY, - namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', - group_name VARCHAR(64) NOT NULL, - description VARCHAR(256) DEFAULT '', - 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 + namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + group_name VARCHAR(64) NOT NULL, + description VARCHAR(256) DEFAULT '', + 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_namespace_id_group_name_group_config" ON "group_config" ("namespace_id", "group_name"); @@ -189,7 +189,9 @@ CREATE TABLE retry_task_log 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 + create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); CREATE INDEX "idx_group_name_scene_name_retry_task_log" ON "retry_task_log" ("namespace_id", "group_name", "scene_name"); @@ -212,6 +214,7 @@ COMMENT ON COLUMN "retry_task_log"."ext_attrs" IS '扩展字段'; COMMENT ON COLUMN "retry_task_log"."retry_status" IS '重试状态 0、重试中 1、成功 2、最大次数'; COMMENT ON COLUMN "retry_task_log"."task_type" IS '任务类型 1、重试数据 2、回调数据'; COMMENT ON COLUMN "retry_task_log"."create_dt" IS '创建时间'; +COMMENT ON COLUMN "retry_task_log"."update_dt" IS '修改时间'; COMMENT ON TABLE "retry_task_log" IS '任务日志基础信息表'; CREATE TABLE retry_task_log_message @@ -254,7 +257,7 @@ CREATE TABLE scene_config update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); -CREATE UNIQUE INDEX "uk_namespace_id_group_name_scene_name" ON "scene_config" ("namespace_id", "group_name","scene_name"); +CREATE UNIQUE INDEX "uk_namespace_id_group_name_scene_name" ON "scene_config" ("namespace_id", "group_name", "scene_name"); COMMENT ON COLUMN "scene_config"."id" IS '主键'; COMMENT ON COLUMN "scene_config"."namespace_id" IS '命名空间id'; COMMENT ON COLUMN "scene_config"."scene_name" IS '场景名称'; @@ -287,8 +290,8 @@ CREATE TABLE server_node update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); -CREATE UNIQUE INDEX "uk_host_id_host_ip" ON "server_node" ("host_id","host_ip"); -CREATE INDEX "idx_expire_at_node_type" ON "server_node" ("expire_at","node_type"); +CREATE UNIQUE INDEX "uk_host_id_host_ip" ON "server_node" ("host_id", "host_ip"); +CREATE INDEX "idx_expire_at_node_type" ON "server_node" ("expire_at", "node_type"); CREATE INDEX "idx_namespace_id_group_name_server_node" ON "server_node" ("namespace_id", "group_name"); COMMENT ON COLUMN "server_node"."id" IS '主键'; @@ -316,7 +319,8 @@ CREATE TABLE distributed_lock update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); -ALTER TABLE distributed_lock ADD CONSTRAINT uk_name UNIQUE (name); +ALTER TABLE distributed_lock + ADD CONSTRAINT uk_name UNIQUE (name); COMMENT ON COLUMN "distributed_lock"."id" IS '主键'; COMMENT ON COLUMN "distributed_lock"."name" IS '锁名称'; @@ -361,7 +365,7 @@ CREATE TABLE system_user_permission update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); -CREATE UNIQUE INDEX "uk_namespace_id_group_name_system_user_id" ON "system_user_permission" ("namespace_id","group_name","system_user_id"); +CREATE UNIQUE INDEX "uk_namespace_id_group_name_system_user_id" ON "system_user_permission" ("namespace_id", "group_name", "system_user_id"); COMMENT ON COLUMN "system_user_permission"."id" IS '主键'; COMMENT ON COLUMN "system_user_permission"."namespace_id" IS '命名空间id'; COMMENT ON COLUMN "system_user_permission"."group_name" IS '组名称'; @@ -395,7 +399,7 @@ COMMENT ON TABLE "sequence_alloc" IS '号段模式序号ID分配表'; CREATE TABLE job ( id BIGSERIAL PRIMARY KEY, - namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', group_name VARCHAR(64) NOT NULL, job_name VARCHAR(64) NOT NULL, args_str TEXT NOT NULL DEFAULT '', @@ -462,7 +466,7 @@ CREATE TABLE job_log_message job_id BIGINT NOT NULL, task_batch_id BIGINT NOT NULL, task_id BIGINT NOT NULL, - message TEXT NOT NULL, + message TEXT NOT NULL, log_num INT NOT NULL DEFAULT 1, real_time BIGINT NOT NULL DEFAULT 0, ext_attrs VARCHAR(256) DEFAULT '', @@ -637,29 +641,31 @@ COMMENT ON TABLE "retry_summary" IS 'DashBoard_Retry'; CREATE TABLE job_summary ( - id BIGSERIAL PRIMARY KEY, - namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', - group_name VARCHAR(64) NOT NULL DEFAULT '', - job_id BIGINT NOT NULL, - 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 + 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_job_id_trigger_at ON job_summary ("job_id", "trigger_at"); -CREATE INDEX idx_namespace_id_group_name_job_id ON job_summary ("namespace_id", "group_name", "job_id"); +CREATE UNIQUE INDEX uk_job_id_trigger_at ON job_summary ("business_id", "trigger_at"); +CREATE INDEX idx_namespace_id_group_name_job_id ON job_summary ("namespace_id", "group_name", "business_id"); COMMENT ON COLUMN "job_summary"."id" IS '主键'; COMMENT ON COLUMN "job_summary"."namespace_id" IS '命名空间id'; COMMENT ON COLUMN "job_summary"."group_name" IS '组名称'; -COMMENT ON COLUMN "job_summary"."job_id" IS '任务信息id'; +COMMENT ON COLUMN "job_summary"."business_id" IS '业务id (job_id或workflow_id)'; +COMMENT ON COLUMN "job_summary"."system_task_type" IS '任务类型 3、JOB任务 4、WORKFLOW任务'; COMMENT ON COLUMN "job_summary"."trigger_at" IS '统计时间'; COMMENT ON COLUMN "job_summary"."success_num" IS '执行成功-日志数量'; COMMENT ON COLUMN "job_summary"."fail_num" IS '执行失败-日志数量'; @@ -689,7 +695,7 @@ CREATE TABLE workflow create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, deleted smallint NOT NULL DEFAULT 0, - ext_attrs varchar(256) NULL DEFAULT '' + ext_attrs varchar(256) NULL DEFAULT '' ); @@ -719,22 +725,22 @@ COMMENT ON COLUMN workflow.ext_attrs IS '扩展字段'; CREATE TABLE 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 DEFAULT NULL, - version INT NOT NULL, - create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - deleted SMALLINT NOT NULL DEFAULT 0, - ext_attrs VARCHAR(256) NULL DEFAULT '' + 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 DEFAULT NULL, + version INT NOT NULL, + create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted SMALLINT NOT NULL DEFAULT 0, + ext_attrs VARCHAR(256) NULL DEFAULT '' ); CREATE INDEX idx_create_dt_workflow_node ON workflow_node (create_dt); @@ -762,17 +768,17 @@ COMMENT ON COLUMN workflow_node.ext_attrs IS '扩展字段'; CREATE TABLE 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 DEFAULT NULL, - execution_at BIGINT NOT NULL DEFAULT 0, - create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - deleted SMALLINT NOT NULL DEFAULT 0, - ext_attrs VARCHAR(256) NULL DEFAULT '' + 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 DEFAULT NULL, + execution_at BIGINT NOT NULL DEFAULT 0, + create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted SMALLINT NOT NULL DEFAULT 0, + ext_attrs VARCHAR(256) NULL DEFAULT '' ); CREATE INDEX idx_job_id_task_batch_status_workflow_task_batch ON workflow_task_batch (workflow_id, task_batch_status); diff --git a/doc/sql/easy_retry_sqlserver.sql b/doc/sql/easy_retry_sqlserver.sql index 60fee158..882a7ff1 100644 --- a/doc/sql/easy_retry_sqlserver.sql +++ b/doc/sql/easy_retry_sqlserver.sql @@ -647,26 +647,27 @@ GO -- job_summary CREATE TABLE [job_summary] ( - [id] bigint PRIMARY KEY IDENTITY, - [namespace_id] nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', - [group_name] nvarchar(64) NOT NULL, - [job_id] bigint NOT NULL, - [trigger_at] datetime2 NOT NULL, - [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 GETDATE(), - [update_dt] datetime2 NOT NULL DEFAULT GETDATE() + [id] bigint PRIMARY KEY IDENTITY, + [namespace_id] nvarchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a', + [group_name] nvarchar(64) NOT NULL, + [business_id] bigint NOT NULL, + [system_task_type] tinyint NOT NULL DEFAULT '3', + [trigger_at] datetime2 NOT NULL, + [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 GETDATE(), + [update_dt] datetime2 NOT NULL DEFAULT GETDATE() ) GO -CREATE UNIQUE NONCLUSTERED INDEX [uk_job_id_trigger_at] ON [job_summary] ([job_id] ASC, [trigger_at] ASC) +CREATE UNIQUE NONCLUSTERED INDEX [uk_job_id_trigger_at] ON [job_summary] ([business_id] ASC, [trigger_at] ASC) GO -CREATE NONCLUSTERED INDEX [idx_namespace_id_group_name_job_id] ON [job_summary] ([namespace_id] ASC, [group_name] ASC, [job_id] ASC) +CREATE NONCLUSTERED INDEX [idx_namespace_id_group_name_job_id] ON [job_summary] ([namespace_id] ASC, [group_name] ASC, [business_id] ASC) GO EXEC sp_addextendedproperty @@ -690,6 +691,20 @@ EXEC sp_addextendedproperty 'COLUMN', N'group_name' GO +EXEC sp_addextendedproperty + 'MS_Description', N'业务id (job_id或workflow_id)', + 'SCHEMA', N'dbo', + 'TABLE', N'job_summary', + 'COLUMN', N'business_id' +GO + +EXEC sp_addextendedproperty + 'MS_Description', N'任务类型 3、JOB任务 4、WORKFLOW任务', + 'SCHEMA', N'dbo', + 'TABLE', N'job_summary', + 'COLUMN', N'system_task_type' +GO + EXEC sp_addextendedproperty 'MS_Description', N'任务信息id', 'SCHEMA', N'dbo', @@ -1661,7 +1676,8 @@ CREATE TABLE [retry_task_log] [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 GETDATE() + [create_dt] datetime2 NOT NULL DEFAULT GETDATE(), + [update_dt] datetime2 NOT NULL DEFAULT GETDATE() ) GO @@ -1769,6 +1785,13 @@ EXEC sp_addextendedproperty 'COLUMN', N'create_dt' GO +EXEC sp_addextendedproperty + 'MS_Description', N'修改时间', + 'SCHEMA', N'dbo', + 'TABLE', N'retry_task_log', + 'COLUMN', N'update_dt' +GO + EXEC sp_addextendedproperty 'MS_Description', N'任务日志基础信息表', 'SCHEMA', N'dbo', -- Gitee From 1288a85991c721b50c08ab38518df322c07a93a7 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Fri, 29 Mar 2024 23:39:06 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20JobSummaryMapper.jobLineList?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2,=E5=87=BD=E6=95=B0=E9=80=82=E9=85=8D=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oracle/mapper/JobSummaryMapper.xml | 4 +- .../postgresql/mapper/JobSummaryMapper.xml | 31 ++++++------- .../sqlserver/mapper/JobSummaryMapper.xml | 4 +- .../common/enums/DashboardLineEnum.java | 43 ++++++++++++++++--- .../service/impl/DashBoardServiceImpl.java | 3 +- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml index f8b169c7..c6a3c894 100644 --- a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml @@ -83,7 +83,7 @@ COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total FROM ( SELECT - DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt, + TO_CHAR(trigger_at, #{dateFormat}) AS createDt, success_num, fail_num, stop_num, @@ -91,7 +91,7 @@ FROM job_summary ${ew.customSqlSegment} ) - GROUP BY DATE_FORMAT(trigger_at, #{dateFormat}) + GROUP BY createDt SELECT - DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt, - ifnull(SUM(success_num), 0) AS success, - ifnull(SUM(fail_num), 0) AS failNum, - ifnull(SUM(stop_num), 0) AS stop, - ifnull(SUM(cancel_num), 0) AS cancel, - ifnull(SUM(fail_num + stop_num + cancel_num), 0) AS fail, - ifnull(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total + DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt, + IFNULL(SUM(success_num), 0) AS success, + IFNULL(SUM(fail_num), 0) AS failNum, + IFNULL(SUM(stop_num), 0) AS stop, + IFNULL(SUM(cancel_num), 0) AS cancel, + IFNULL(SUM(fail_num + stop_num + cancel_num), 0) AS fail, + IFNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total FROM job_summary ${ew.customSqlSegment} GROUP BY DATE_FORMAT(trigger_at, #{dateFormat}) @@ -67,11 +86,11 @@ diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetrySummaryMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetrySummaryMapper.xml index aab261f3..56e0895d 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetrySummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetrySummaryMapper.xml @@ -15,30 +15,49 @@ - - INSERT INTO - retry_summary (namespace_id, group_name, scene_name, trigger_at, running_num, finish_num, max_count_num, - suspend_num) + + INSERT INTO retry_summary (namespace_id, group_name, scene_name, trigger_at, + running_num, finish_num, max_count_num, suspend_num) VALUES - - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.sceneName}, - #{item.triggerAt}, - #{item.runningNum}, - #{item.finishNum}, - #{item.maxCountNum}, - #{item.suspendNum} - ) - - ON DUPLICATE KEY UPDATE - running_num = values(`running_num`), - finish_num = values(`finish_num`), - max_count_num = values(`max_count_num`), - suspend_num = values(`suspend_num`) + + ( + #{item.namespaceId}, + #{item.groupName}, + #{item.sceneName}, + #{item.triggerAt}, + #{item.runningNum}, + #{item.finishNum}, + #{item.maxCountNum}, + #{item.suspendNum} + ) + + + UPDATE retry_summary rt, + ( + + SELECT + #{item.runningNum} AS running_num, + #{item.finishNum} AS finish_num, + #{item.maxCountNum} AS max_count_num, + #{item.suspendNum} AS suspend_num, + #{item.triggerAt} AS trigger_at, + #{item.sceneName} AS scene_name, + #{item.namespaceId} AS namespace_id, + #{item.groupName} AS group_name + + ) tt + SET rt.running_num = tt.running_num, + rt.finish_num = tt.finish_num, + rt.max_count_num = tt.max_count_num, + rt.suspend_num = tt.suspend_num + WHERE rt.trigger_at = tt.trigger_at + AND rt.group_name = tt.group_name + AND rt.namespace_id = tt.namespace_id + AND rt.scene_name = tt.scene_name + + SELECT node_type as nodeType, count(*) as total from server_node diff --git a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml index d79a88d1..d0b4e728 100644 --- a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml @@ -40,31 +40,32 @@ ) + UPDATE job_summary rt, - ( - - SELECT - #{item.successNum} AS success_num, - #{item.failNum} AS fail_num, - #{item.failReason} AS fail_reason, - #{item.stopNum} AS stop_num, - #{item.stopReason} AS stop_reason, - #{item.cancelNum} AS cancel_num, - #{item.cancelReason} AS cancel_reason, - #{item.triggerAt} AS trigger_at, - #{item.businessId} AS business_id - - ) tt - SET - rt.success_num = tt.success_num, - rt.fail_num = tt.fail_num, - rt.fail_reason = tt.fail_reason, - rt.stop_num = tt.stop_num, - rt.stop_reason = tt.stop_reason, - rt.cancel_num = tt.cancel_num, - rt.cancel_reason = tt.cancel_reason - WHERE rt.trigger_at = tt.trigger_at and rt.business_id = tt.business_id + ( + + SELECT + #{item.successNum} AS success_num, + #{item.failNum} AS fail_num, + #{item.failReason} AS fail_reason, + #{item.stopNum} AS stop_num, + #{item.stopReason} AS stop_reason, + #{item.cancelNum} AS cancel_num, + #{item.cancelReason} AS cancel_reason, + #{item.triggerAt} AS trigger_at, + #{item.businessId} AS business_id + + ) tt + SET rt.success_num = tt.success_num, + rt.fail_num = tt.fail_num, + rt.fail_reason = tt.fail_reason, + rt.stop_num = tt.stop_num, + rt.stop_reason = tt.stop_reason, + rt.cancel_num = tt.cancel_num, + rt.cancel_reason = tt.cancel_reason + WHERE rt.trigger_at = tt.trigger_at + AND rt.business_id = tt.business_id - id - , namespace_id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt + id, namespace_id, group_name, context_path, host_id, host_ip, host_port, + expire_at, node_type,create_dt,update_dt INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port, - expire_at, node_type, ext_attrs, context_path, create_dt) + expire_at, node_type, ext_attrs, context_path, create_dt) VALUES - - ( - #{item.namespaceId,jdbcType=VARCHAR}, - #{item.groupName,jdbcType=VARCHAR}, - #{item.hostId,jdbcType=VARCHAR}, - #{item.hostIp,jdbcType=VARCHAR}, - #{item.hostPort,jdbcType=INTEGER}, - #{item.expireAt,jdbcType=TIMESTAMP}, - #{item.nodeType,jdbcType=TINYINT}, - #{item.extAttrs,jdbcType=VARCHAR}, - #{item.contextPath,jdbcType=VARCHAR}, - #{item.createDt,jdbcType=TIMESTAMP} - ) - + + ( + #{item.namespaceId,jdbcType=VARCHAR}, + #{item.groupName,jdbcType=VARCHAR}, + #{item.hostId,jdbcType=VARCHAR}, + #{item.hostIp,jdbcType=VARCHAR}, + #{item.hostPort,jdbcType=INTEGER}, + #{item.expireAt,jdbcType=TIMESTAMP}, + #{item.nodeType,jdbcType=TINYINT}, + #{item.extAttrs,jdbcType=VARCHAR}, + #{item.contextPath,jdbcType=VARCHAR}, + #{item.createDt,jdbcType=TIMESTAMP} + ) + + UPDATE server_node rt, - ( - - SELECT - #{item.expireAt} AS expire_at, - #{item.contextPath} AS context_path, - #{item.hostId} AS host_id, - #{item.hostIp} AS host_ip - - ) tt - SET rt.expire_at = tt.expire_at, rt.context_path = tt.context_path, - WHERE rt.host_id = tt.host_id and rt.host_ip = tt.host_ip + ( + + SELECT + #{item.expireAt} AS expire_at, + #{item.contextPath} AS context_path, + #{item.hostId} AS host_id, + #{item.hostIp} AS host_ip + + ) tt + SET rt.expire_at = tt.expire_at, + rt.context_path = tt.context_path + WHERE rt.host_id = tt.host_id + AND rt.host_ip = tt.host_ip + diff --git a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml index 47d3222c..d9118b7e 100644 --- a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml @@ -19,58 +19,42 @@ - - MERGE INTO job_summary dest - USING ( - - SELECT - #{item.namespaceId} AS namespace_id, - #{item.groupName} AS group_name, - #{item.businessId} AS business_id, - #{item.triggerAt} AS trigger_at, - #{item.systemTaskType} AS system_task_type, - #{item.successNum} AS success_num, - #{item.failNum} AS fail_num, - #{item.failReason} AS fail_reason, - #{item.stopNum} AS stop_num, - #{item.stopReason} AS stop_reason, - #{item.cancelNum} AS cancel_num, - #{item.cancelReason} AS cancel_reason - FROM DUAL - - ) src - ON (dest.business_id = src.business_id AND dest.trigger_at = src.trigger_at AND dest.system_task_type = src.system_task_type) - WHEN MATCHED THEN - UPDATE SET - dest.success_num = src.success_num, - dest.fail_num = src.fail_num, - dest.fail_reason = src.fail_reason, - dest.stop_num = src.stop_num, - dest.stop_reason = src.stop_reason, - dest.cancel_num = src.cancel_num, - dest.cancel_reason = src.cancel_reason - WHEN NOT MATCHED THEN - INSERT (namespace_id, group_name, business_id, trigger_at, system_task_type, - success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason) - VALUES - - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.businessId}, - #{item.triggerAt}, - #{item.systemTaskType}, - #{item.successNum}, - #{item.failNum}, - #{item.failReason}, - #{item.stopNum}, - #{item.stopReason}, - #{item.cancelNum}, - #{item.cancelReason} - ) - + + INSERT INTO job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type, + success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason) + + SELECT + #{item.namespaceId}, + #{item.groupName}, + #{item.businessId}, + #{item.triggerAt}, + #{item.systemTaskType}, + #{item.successNum}, + #{item.failNum}, + #{item.failReason}, + #{item.stopNum}, + #{item.stopReason}, + #{item.cancelNum}, + #{item.cancelReason} + FROM DUAL + + + + UPDATE job_summary + SET success_num = #{item.successNum}, + fail_num = #{item.failNum}, + fail_reason = #{item.failReason}, + stop_num = #{item.stopNum}, + stop_reason = #{item.stopReason}, + cancel_num = #{item.cancelNum}, + cancel_reason = #{item.cancelReason} + WHERE trigger_at = #{item.triggerAt} + AND business_id = #{item.businessId} + + + SELECT COALESCE(sum(running_num), 0) AS runningNum, @@ -75,8 +62,7 @@ SELECT * FROM ( - SELECT - trigger_at, running_num, finish_num, max_count_num, suspend_num + SELECT trigger_at, running_num, finish_num, max_count_num, suspend_num FROM retry_summary ${ew.customSqlSegment} ) diff --git a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/ServerNodeMapper.xml b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/ServerNodeMapper.xml index a1df2dfc..27f14909 100644 --- a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/ServerNodeMapper.xml +++ b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/ServerNodeMapper.xml @@ -19,40 +19,36 @@ id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt - - MERGE INTO server_node dest - USING( - - SELECT - #{item.namespaceId,jdbcType=VARCHAR} AS namespace_id, - #{item.groupName,jdbcType=VARCHAR} AS group_name, - #{item.hostId,jdbcType=VARCHAR} AS host_id, - #{item.hostIp,jdbcType=VARCHAR} AS host_ip, - #{item.hostPort,jdbcType=INTEGER} AS host_port, - #{item.expireAt,jdbcType=TIMESTAMP} AS expire_at, - #{item.nodeType,jdbcType=TINYINT} AS node_type, - #{item.extAttrs,jdbcType=VARCHAR} AS ext_attrs, - #{item.contextPath,jdbcType=VARCHAR} AS context_path, - #{item.createDt,jdbcType=TIMESTAMP} AS create_dt - FROM DUAL - - ) src - ON( dest.host_id = src.host_id AND dest.host_ip = src.host_ip) - WHEN MATCHED THEN - UPDATE SET expire_at = src.expire_at - WHEN NOT MATCHED THEN - INSERT (namespace_id, group_name, host_id, host_ip, host_port, - expire_at, node_type, ext_attrs, context_path, create_dt) - VALUES - - (#{item.namespaceId,jdbcType=VARCHAR}, #{item.groupName,jdbcType=VARCHAR}, #{item.hostId,jdbcType=VARCHAR}, #{item.hostIp,jdbcType=VARCHAR}, - #{item.hostPort,jdbcType=INTEGER}, #{item.expireAt,jdbcType=TIMESTAMP}, #{item.nodeType,jdbcType=TINYINT}, - #{item.extAttrs,jdbcType=VARCHAR}, #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP}) - - + + + INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port, + expire_at, node_type, ext_attrs, context_path, create_dt) + + SELECT + #{item.namespaceId,jdbcType=VARCHAR}, + #{item.groupName,jdbcType=VARCHAR}, + #{item.hostId,jdbcType=VARCHAR}, + #{item.hostIp,jdbcType=VARCHAR}, + #{item.hostPort,jdbcType=INTEGER}, + #{item.expireAt,jdbcType=TIMESTAMP}, + #{item.nodeType,jdbcType=TINYINT}, + #{item.extAttrs,jdbcType=VARCHAR}, + #{item.contextPath,jdbcType=VARCHAR}, + #{item.createDt,jdbcType=TIMESTAMP} + FROM DUAL + + + + UPDATE server_node + SET expire_at = #{item.expireAt}, + context_path = #{item.contextPath} + WHERE host_id = #{item.hostId} + AND host_ip = #{item.hostIp} + + + SELECT diff --git a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgresql/mapper/RetrySummaryMapper.xml b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgresql/mapper/RetrySummaryMapper.xml index 04f90469..3b6798f9 100644 --- a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgresql/mapper/RetrySummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgresql/mapper/RetrySummaryMapper.xml @@ -15,30 +15,49 @@ - - INSERT INTO - retry_summary (namespace_id, group_name, scene_name, trigger_at, running_num, finish_num, max_count_num, - suspend_num) + + INSERT INTO retry_summary (namespace_id, group_name, scene_name, trigger_at, + running_num, finish_num, max_count_num, suspend_num) VALUES - - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.sceneName}, - #{item.triggerAt}, - #{item.runningNum}, - #{item.finishNum}, - #{item.maxCountNum}, - #{item.suspendNum} - ) + + ( + #{item.namespaceId}, + #{item.groupName}, + #{item.sceneName}, + #{item.triggerAt}, + #{item.runningNum}, + #{item.finishNum}, + #{item.maxCountNum}, + #{item.suspendNum} + ) - ON CONFLICT (namespace_id, group_name, scene_name, trigger_at) DO UPDATE - SET running_num = EXCLUDED.running_num, - finish_num = EXCLUDED.finish_num, - max_count_num = EXCLUDED.max_count_num, - suspend_num = EXCLUDED.suspend_num + + UPDATE retry_summary AS rt + SET running_num = tt.running_num, + finish_num = tt.finish_num, + max_count_num = tt.max_count_num, + suspend_num = tt.suspend_num + FROM ( + + SELECT + #{item.runningNum} AS running_num, + #{item.finishNum} AS finish_num, + #{item.maxCountNum} AS max_count_num, + #{item.suspendNum} AS suspend_num, + #{item.triggerAt} AS trigger_at, + #{item.sceneName} AS scene_name, + #{item.namespaceId} AS namespace_id, + #{item.groupName} AS group_name + + ) AS tt + WHERE rt.trigger_at = tt.trigger_at + AND rt.group_name = tt.group_name + AND rt.namespace_id = tt.namespace_id + AND rt.scene_name = tt.scene_name + + SELECT node_type as nodeType, count(*) as total diff --git a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobMapper.xml b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobMapper.xml index 205020f0..d9d3a7a9 100644 --- a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobMapper.xml +++ b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobMapper.xml @@ -28,14 +28,15 @@ UPDATE job - SET job.next_trigger_at = src.next_trigger_at - FROM job - JOIN ( - - SELECT - #{item.nextTriggerAt} AS next_trigger_at, - #{item.id} AS id - - ) AS src ON job.id = src.id; + SET next_trigger_at = src.next_trigger_at + FROM job AS dest + JOIN ( + + SELECT + #{item.nextTriggerAt} AS next_trigger_at, + #{item.id} AS id + + ) AS src + ON (dest.id = src.id) diff --git a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml index 80f1db61..3e9d14ab 100644 --- a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml @@ -19,47 +19,55 @@ - - MERGE INTO job_summary AS target - USING ( - VALUES - - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.businessId}, - #{item.triggerAt}, - #{item.systemTaskType}, - #{item.successNum}, - #{item.failNum}, - #{item.failReason}, - #{item.stopNum}, - #{item.stopReason}, - #{item.cancelNum}, - #{item.cancelReason} - ) - - ) AS source (namespace_id, group_name, business_id, trigger_at, system_task_type, - success_num, fail_num, fail_reason, stop_num, stop_reason, cancel_num, cancel_reason) - ON target.namespace_id = source.namespace_id - AND target.business_id = source.business_id - WHEN MATCHED THEN - UPDATE SET - target.success_num = source.success_num, - target.fail_num = source.fail_num, - target.fail_reason = source.fail_reason, - target.stop_num = source.stop_num, - target.stop_reason = source.stop_reason, - target.cancel_num = source.cancel_num, - target.cancel_reason = source.cancel_reason - WHEN NOT MATCHED THEN - INSERT (namespace_id, group_name, business_id, trigger_at, system_task_type, - success_num, fail_num, fail_reason, stop_num, stop_reason, cancel_num, cancel_reason) - VALUES (source.namespace_id, source.group_name, source.business_id, source.trigger_at, source.system_task_type, - source.success_num, source.fail_num, source.fail_reason, source.stop_num, source.stop_reason, - source.cancel_num, source.cancel_reason); + + INSERT INTO job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type, + success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason) + VALUES + + ( + #{item.namespaceId}, + #{item.groupName}, + #{item.businessId}, + #{item.triggerAt}, + #{item.systemTaskType}, + #{item.successNum}, + #{item.failNum}, + #{item.failReason}, + #{item.stopNum}, + #{item.stopReason}, + #{item.cancelNum}, + #{item.cancelReason} + ) + + + UPDATE job_summary + SET success_num = src.success_num, + fail_num = src.fail_num, + fail_reason = src.fail_reason, + stop_num = src.stop_num, + stop_reason = src.stop_reason, + cancel_num = src.cancel_num, + cancel_reason = src.cancel_reason + FROM job_summary AS dest + JOIN ( + + SELECT + #{item.successNum} AS success_num, + #{item.failNum} AS fail_num, + #{item.failReason} AS fail_reason, + #{item.stopNum} AS stop_num, + #{item.stopReason} AS stop_reason, + #{item.cancelNum} AS cancel_num, + #{item.cancelReason} AS cancel_reason, + #{item.triggerAt} AS trigger_at, + #{item.businessId} AS business_id + + ) AS src + ON (dest.trigger_at = src.trigger_at AND dest.business_id = src.business_id) + + SELECT diff --git a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/ServerNodeMapper.xml b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/ServerNodeMapper.xml index a4b139db..4624032f 100644 --- a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/ServerNodeMapper.xml +++ b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/ServerNodeMapper.xml @@ -20,33 +20,43 @@ id, namespace_id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt - - MERGE INTO server_node AS target - USING ( - VALUES + + INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port, + expire_at, node_type, ext_attrs, context_path, create_dt) + VALUES ( - #{item.namespaceId,jdbcType=VARCHAR}, #{item.groupName,jdbcType=VARCHAR}, - #{item.hostId,jdbcType=VARCHAR}, #{item.hostIp,jdbcType=VARCHAR}, #{item.hostPort,jdbcType=INTEGER}, - #{item.expireAt,jdbcType=TIMESTAMP}, #{item.nodeType,jdbcType=TINYINT}, #{item.extAttrs,jdbcType=VARCHAR}, - #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP} + #{item.namespaceId,jdbcType=VARCHAR}, + #{item.groupName,jdbcType=VARCHAR}, + #{item.hostId,jdbcType=VARCHAR}, + #{item.hostIp,jdbcType=VARCHAR}, + #{item.hostPort,jdbcType=INTEGER}, + #{item.expireAt,jdbcType=TIMESTAMP}, + #{item.nodeType,jdbcType=TINYINT}, + #{item.extAttrs,jdbcType=VARCHAR}, + #{item.contextPath,jdbcType=VARCHAR}, + #{item.createDt,jdbcType=TIMESTAMP} ) - ) AS source (namespace_id, group_name, host_id, host_ip, host_port, - expire_at, node_type, ext_attrs, context_path, create_dt) - ON target.namespace_id = source.namespace_id - AND target.group_name = source.group_name - AND target.host_id = source.host_id - WHEN MATCHED THEN - UPDATE SET - target.expire_at = source.expire_at, target.update_dt = GETDATE() - WHEN NOT MATCHED THEN - INSERT (namespace_id, group_name, host_id, host_ip, host_port, - expire_at, node_type, ext_attrs, context_path, create_dt, update_dt) - VALUES (source.namespace_id, source.group_name, source.host_id, source.host_ip, source.host_port, - source.expire_at, source.node_type, source.ext_attrs, source.context_path, source.create_dt, GETDATE()); + + UPDATE server_node + SET expire_at = src.expire_at, + context_path = src.context_path + FROM server_node AS dest + JOIN ( + + SELECT + #{item.expireAt} AS expire_at, + #{item.contextPath} AS context_path, + #{item.hostId} AS host_id, + #{item.hostIp} AS host_ip + + ) AS src + ON (dest.host_id = src.host_id AND dest.host_ip = src.host_ip) + +