diff --git a/doc/sql/easy_retry_postgre.sql b/doc/sql/easy_retry_postgre.sql
index 6dc92c20..921bc7d1 100644
--- a/doc/sql/easy_retry_postgre.sql
+++ b/doc/sql/easy_retry_postgre.sql
@@ -11,7 +11,7 @@ CREATE TABLE namespace
deleted SMALLINT NOT NULL DEFAULT 0
);
-CREATE UNIQUE INDEX uk_namespace_unique_id ON namespace (unique_id);
+CREATE UNIQUE INDEX uk_namespace_unique_id ON "namespace" (unique_id);
COMMENT ON COLUMN namespace.id IS '主键';
COMMENT ON COLUMN namespace.name IS '名称';
@@ -22,6 +22,9 @@ COMMENT ON COLUMN namespace.update_dt IS '修改时间';
COMMENT ON COLUMN namespace.deleted IS '逻辑删除 1、删除';
COMMENT ON TABLE namespace IS '命名空间';
+INSERT INTO namespace (name, unique_id, create_dt, update_dt, deleted)
+VALUES ('Default', '764d604ec6fc45f68cd92514c40e9e1a', now(), now(), 0);
+
CREATE TABLE group_config
(
id BIGSERIAL PRIMARY KEY,
@@ -555,6 +558,7 @@ COMMENT ON TABLE "job_task" IS '任务批次';
CREATE TABLE job_notify_config
(
id BIGSERIAL PRIMARY KEY,
+ namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
group_name VARCHAR(64) NOT NULL,
job_id BIGINT NOT NULL,
notify_status SMALLINT NOT NULL DEFAULT 0,
@@ -569,9 +573,10 @@ CREATE TABLE job_notify_config
update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-CREATE INDEX idx_group_name ON job_notify_config (group_name);
+CREATE INDEX idx_namespace_id_group_name_job_id_job_notify_config ON job_notify_config (namespace_id, group_name, job_id);
COMMENT ON COLUMN "job_notify_config"."id" IS '主键';
+COMMENT ON COLUMN "job_task"."namespace_id" IS '命名空间id';
COMMENT ON COLUMN "job_notify_config"."group_name" IS '组名称';
COMMENT ON COLUMN "job_notify_config"."job_id" IS '任务信息id';
COMMENT ON COLUMN "job_notify_config"."notify_status" IS '通知状态 0、未启用 1、启用';
diff --git a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/Namespace.java b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/Namespace.java
index 470751a6..60b31ee4 100644
--- a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/Namespace.java
+++ b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/Namespace.java
@@ -52,5 +52,5 @@ public class Namespace implements Serializable {
/**
* 逻辑删除 1、删除
*/
- private Byte deleted;
+ private Integer deleted;
}
diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml
index 4e5f4c38..3cd0a1f4 100644
--- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml
+++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml
@@ -32,4 +32,18 @@
#{item.taskType}, #{item.createDt}, #{item.namespaceId})
+
+
diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/ServerNodeMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/ServerNodeMapper.xml
index 9eaa533a..efe654dc 100644
--- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/ServerNodeMapper.xml
+++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/ServerNodeMapper.xml
@@ -18,13 +18,13 @@
id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
- insert into server_node (id, group_name, host_id, host_ip, host_port,
+ 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
-
- #{id,jdbcType=BIGINT}, #{groupName,jdbcType=VARCHAR}, #{hostId,jdbcType=VARCHAR}, #{hostIp,jdbcType=VARCHAR},
- #{hostPort,jdbcType=INTEGER},
- #{expireAt,jdbcType=TIMESTAMP}, #{nodeType,jdbcType=TINYINT}, #{extAttrs,jdbcType=VARCHAR}, #{contextPath,jdbcType=VARCHAR}, #{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})
ON DUPLICATE KEY UPDATE
expire_at = values(`expire_at`)
diff --git a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/JobSummaryMapper.xml
index 8f76ea97..f5bcba14 100644
--- a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/JobSummaryMapper.xml
+++ b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/JobSummaryMapper.xml
@@ -53,28 +53,28 @@
SELECT
- DATE_FORMAT(create_dt,'%H')
+ to_char(create_dt,'%H')
- DATE_FORMAT(create_dt,'%Y-%m-%d')
+ to_char(create_dt,'%Y-%m-%d')
- DATE_FORMAT(create_dt,'%Y-%m-%d')
+ to_char(create_dt,'%Y-%m-%d')
- DATE_FORMAT(create_dt,'%Y-%m')
+ to_char(create_dt,'%Y-%m')
- DATE_FORMAT(create_dt,'%Y-%m-%d')
+ to_char(create_dt,'%Y-%m-%d')
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
+ COALESCE(SUM(success_num), 0) AS success,
+ COALESCE(SUM(fail_num), 0) AS failNum,
+ COALESCE(SUM(stop_num), 0) AS stop,
+ COALESCE(SUM(cancel_num), 0) AS cancel,
+ COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
+ COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
FROM job_summary
@@ -87,11 +87,11 @@
@@ -99,7 +99,7 @@
diff --git a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/RetrySummaryMapper.xml b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/RetrySummaryMapper.xml
index 303f1d04..8a6680bd 100644
--- a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/RetrySummaryMapper.xml
+++ b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/RetrySummaryMapper.xml
@@ -41,31 +41,31 @@
+
+
+
+ SELECT namespace_id AS namespaceId,
+ group_name AS groupName,
+ scene_name AS sceneName,
+ SUM(CASE WHEN (retry_status = 0) THEN 1 ELSE 0 END) AS runningNum,
+ SUM(CASE WHEN (retry_status = 1) THEN 1 ELSE 0 END) AS finishNum,
+ SUM(CASE WHEN (retry_status = 2) THEN 1 ELSE 0 END) AS maxCountNum,
+ SUM(CASE WHEN (retry_status = 3) THEN 1 ELSE 0 END) AS suspendNum
+ FROM retry_task_log
+ WHERE create_dt between #{from} and #{to}
+ GROUP BY namespace_id, group_name, scene_name
+
diff --git a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/ServerNodeMapper.xml b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/ServerNodeMapper.xml
index 052d3631..72ec5d32 100644
--- a/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/ServerNodeMapper.xml
+++ b/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/ServerNodeMapper.xml
@@ -19,7 +19,7 @@
- INSERT INTO server_node (group_name, host_id, host_ip, host_port,
+ 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
diff --git a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/controller/GroupConfigController.java b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/controller/GroupConfigController.java
index 2ead7ffe..8250faaf 100644
--- a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/controller/GroupConfigController.java
+++ b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/controller/GroupConfigController.java
@@ -11,6 +11,7 @@ import com.aizuda.easy.retry.server.web.model.response.GroupConfigResponseVO;
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
import com.aizuda.easy.retry.server.web.service.GroupConfigService;
+import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.validation.annotation.Validated;
@@ -91,7 +92,16 @@ public class GroupConfigController {
@GetMapping("/partition-table/list")
public List getTablePartitionList() {
// https://gitee.com/aizuda/easy-retry/issues/I8DAMH
- List tableList = jdbcTemplate.queryForList("SHOW TABLES LIKE 'retry_task_%'", String.class);
+ String sql;
+ if (systemProperties.getDbType().getDb().equals(DbTypeEnum.POSTGRES.getDb())) {
+ sql = "SELECT table_name\n"
+ + "FROM information_schema.tables\n"
+ + "WHERE table_name LIKE 'retry_task_%' AND table_schema = 'public'";
+ } else {
+ sql = "SHOW TABLES LIKE 'retry_task_%'";
+ }
+
+ List tableList = jdbcTemplate.queryForList(sql, String.class);
return tableList.stream().map(ReUtil::getFirstNumber).filter(i ->
!Objects.isNull(i) && i <= systemProperties.getTotalPartition()).distinct().collect(Collectors.toList());
}
diff --git a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/GroupConfigServiceImpl.java b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/GroupConfigServiceImpl.java
index 32e0a954..ac94c120 100644
--- a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/GroupConfigServiceImpl.java
+++ b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/GroupConfigServiceImpl.java
@@ -248,7 +248,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
try {
TaskAccess retryTaskAccess = accessTemplate.getRetryDeadLetterAccess();
- retryTaskAccess.one(groupConfig.getGroupName(), groupConfig.getNamespaceId(),
+ retryTaskAccess.one(groupConfig.getGroupName(), namespaceId,
new LambdaQueryWrapper().eq(RetryDeadLetter::getId, 1));
} catch (BadSqlGrammarException e) {
Optional.ofNullable(e.getMessage()).ifPresent(s -> {
diff --git a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/JobServiceImpl.java b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/JobServiceImpl.java
index 632ac807..e50c37a3 100644
--- a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/JobServiceImpl.java
+++ b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/JobServiceImpl.java
@@ -26,13 +26,13 @@ import com.aizuda.easy.retry.server.web.service.convert.JobConverter;
import com.aizuda.easy.retry.server.web.service.convert.JobResponseVOConverter;
import com.aizuda.easy.retry.server.web.util.UserSessionUtils;
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobMapper;
-import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.Job;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -54,6 +54,7 @@ public class JobServiceImpl implements JobService {
private JobMapper jobMapper;
@Autowired
@Qualifier("terminalJobPrepareHandler")
+ @Lazy
private JobPrePareHandler jobPrePareHandler;
@Override
diff --git a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/NamespaceServiceImpl.java b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/NamespaceServiceImpl.java
index 76d04cae..4aafdb0a 100644
--- a/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/NamespaceServiceImpl.java
+++ b/easy-retry-server/easy-retry-server-web/src/main/java/com/aizuda/easy/retry/server/web/service/impl/NamespaceServiceImpl.java
@@ -73,7 +73,7 @@ public class NamespaceServiceImpl implements NamespaceService {
;
}
- queryWrapper.eq(Namespace::getDeleted, StatusEnum.NO);
+ queryWrapper.eq(Namespace::getDeleted, StatusEnum.NO.getStatus());
queryWrapper.orderByDesc(Namespace::getId);
PageDTO selectPage = namespaceMapper.selectPage(pageDTO, queryWrapper);
return new PageResult<>(pageDTO,