feat:2.5.0

1、https://gitee.com/aizuda/easy-retry/issues/I8CKC8
2、通知列表选条件改为下拉联动
3、通知新增修改页面修改
  .通知场景新增任务重试数量超过阈值、任务失败进入死信队列
  .新增限制流状态、每秒限流阈值字段
  .钉钉和飞书配置属性新增被@联系人
4、mysql、postgre库的 notify_config表 新增场景名称、限流状态、每秒限流阈值字段
This commit is contained in:
zuojunlin 2023-11-20 11:36:51 +08:00 committed by byteblogs168
parent 150097764e
commit 598d6e2481
20 changed files with 393 additions and 172 deletions

View File

@ -26,11 +26,14 @@ CREATE TABLE `notify_config`
( (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`group_name` varchar(64) NOT NULL COMMENT '组名称', `group_name` varchar(64) NOT NULL COMMENT '组名称',
`notify_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '组状态 0、未启用 1、启用', `scene_name` varchar(64) NOT NULL COMMENT '场景名称',
`notify_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知状态 0、未启用 1、启用',
`notify_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信', `notify_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信',
`notify_attribute` varchar(512) NOT NULL COMMENT '配置属性', `notify_attribute` varchar(512) NOT NULL COMMENT '配置属性',
`notify_threshold` int(11) NOT NULL DEFAULT '0' COMMENT '通知阈值', `notify_threshold` int(11) NOT NULL DEFAULT '0' COMMENT '通知阈值',
`notify_scene` tinyint(4) 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 '描述', `description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',

View File

@ -34,11 +34,14 @@ CREATE TABLE notify_config
( (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
group_name VARCHAR(64) NOT NULL, group_name VARCHAR(64) NOT NULL,
scene_name VARCHAR(64) NOT NULL,
notify_status SMALLINT NOT NULL DEFAULT 0, notify_status SMALLINT NOT NULL DEFAULT 0,
notify_type SMALLINT NOT NULL DEFAULT 0, notify_type SMALLINT NOT NULL DEFAULT 0,
notify_attribute VARCHAR(512) NOT NULL, notify_attribute VARCHAR(512) NOT NULL,
notify_threshold INT NOT NULL DEFAULT 0, notify_threshold INT NOT NULL DEFAULT 0,
notify_scene SMALLINT 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 '', description VARCHAR(256) NOT NULL DEFAULT '',
create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
@ -48,11 +51,14 @@ CREATE INDEX idx_group_name ON notify_config (group_name);
COMMENT ON COLUMN "notify_config"."id" IS '主键'; COMMENT ON COLUMN "notify_config"."id" IS '主键';
COMMENT ON COLUMN "notify_config"."group_name" IS '组名称'; COMMENT ON COLUMN "notify_config"."group_name" IS '组名称';
COMMENT ON COLUMN "notify_config"."scene_name" IS '场景名称';
COMMENT ON COLUMN "notify_config"."notify_status" IS '通知状态 0、未启用 1、启用'; COMMENT ON COLUMN "notify_config"."notify_status" IS '通知状态 0、未启用 1、启用';
COMMENT ON COLUMN "notify_config"."notify_type" IS '通知类型 1、钉钉 2、邮件 3、企业微信'; COMMENT ON COLUMN "notify_config"."notify_type" IS '通知类型 1、钉钉 2、邮件 3、企业微信';
COMMENT ON COLUMN "notify_config"."notify_attribute" IS '配置属性'; COMMENT ON COLUMN "notify_config"."notify_attribute" IS '配置属性';
COMMENT ON COLUMN "notify_config"."notify_threshold" IS '通知阈值'; COMMENT ON COLUMN "notify_config"."notify_threshold" IS '通知阈值';
COMMENT ON COLUMN "notify_config"."notify_scene" IS '通知场景'; COMMENT ON COLUMN "notify_config"."notify_scene" IS '通知场景';
COMMENT ON COLUMN "notify_config"."rate_limiter_status" IS '限流状态 0、未启用 1、启用';
COMMENT ON COLUMN "notify_config"."rate_limiter_threshold" IS '每秒限流阈值';
COMMENT ON COLUMN "notify_config"."description" IS '描述'; COMMENT ON COLUMN "notify_config"."description" IS '描述';
COMMENT ON COLUMN "notify_config"."create_dt" IS '创建时间'; COMMENT ON COLUMN "notify_config"."create_dt" IS '创建时间';
COMMENT ON COLUMN "notify_config"."update_dt" IS '修改时间'; COMMENT ON COLUMN "notify_config"."update_dt" IS '修改时间';

View File

@ -52,6 +52,17 @@ public interface ConfigAccess<T> extends Access<T> {
*/ */
List<NotifyConfig> getNotifyConfigByGroupName(String groupName, Integer notifyScene); List<NotifyConfig> getNotifyConfigByGroupName(String groupName, Integer notifyScene);
/**
* 获取通知配置
*
* @param groupName 组名称
* @param groupName 场景名称
* @param notifyScene {@link NotifySceneEnum} 场景类型
* @return {@link NotifyConfig} 场景配置
*/
List<NotifyConfig> getNotifyConfigByGroupNameAndSceneName(String groupName,String sceneName, Integer notifyScene);
/** /**
* 获取通知配置 * 获取通知配置
* *
@ -88,6 +99,14 @@ public interface ConfigAccess<T> extends Access<T> {
*/ */
List<GroupConfig> getAllConfigGroupList(); List<GroupConfig> getAllConfigGroupList();
/**
* 获取所有场景配置信息
*
* @return 场景配置列表
*/
List<SceneConfig> getAllConfigSceneList();
/** /**
* 获取配置版本号 * 获取配置版本号
* *

View File

@ -50,6 +50,12 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
.eq(NotifyConfig::getNotifyScene, notifyScene)); .eq(NotifyConfig::getNotifyScene, notifyScene));
} }
private List<NotifyConfig> getByGroupIdAndSceneIdAndNotifyScene(String groupName, String sceneName, Integer notifyScene) {
return notifyConfigMapper.selectList(new LambdaQueryWrapper<NotifyConfig>().eq(NotifyConfig::getGroupName, groupName)
.eq(NotifyConfig::getSceneName, sceneName)
.eq(NotifyConfig::getNotifyScene, notifyScene));
}
protected SceneConfig getByGroupNameAndSceneName(String groupName, String sceneName) { protected SceneConfig getByGroupNameAndSceneName(String groupName, String sceneName) {
return sceneConfigMapper.selectOne(new LambdaQueryWrapper<SceneConfig>() return sceneConfigMapper.selectOne(new LambdaQueryWrapper<SceneConfig>()
.eq(SceneConfig::getGroupName, groupName).eq(SceneConfig::getSceneName, sceneName)); .eq(SceneConfig::getGroupName, groupName).eq(SceneConfig::getSceneName, sceneName));
@ -89,6 +95,11 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
return getByGroupIdAndNotifyScene(shardingGroupId, notifyScene); return getByGroupIdAndNotifyScene(shardingGroupId, notifyScene);
} }
@Override
public List<NotifyConfig> getNotifyConfigByGroupNameAndSceneName(String shardingGroupId,String shardingSceneId, Integer notifyScene) {
return getByGroupIdAndSceneIdAndNotifyScene(shardingGroupId,shardingSceneId, notifyScene);
}
@Override @Override
public List<NotifyConfig> getNotifyListConfigByGroupName(String shardingGroupId) { public List<NotifyConfig> getNotifyListConfigByGroupName(String shardingGroupId) {
return getNotifyConfigs(shardingGroupId); return getNotifyConfigs(shardingGroupId);
@ -138,6 +149,15 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
return allSystemConfigGroupList; return allSystemConfigGroupList;
} }
@Override
public List<SceneConfig> getAllConfigSceneList() {
List<SceneConfig> allSystemConfigSceneList = sceneConfigMapper.selectList(new LambdaQueryWrapper<SceneConfig>().orderByAsc(SceneConfig::getId));
if (CollectionUtils.isEmpty(allSystemConfigSceneList)) {
return Collections.EMPTY_LIST;
}
return allSystemConfigSceneList;
}
@Override @Override
public Integer getConfigVersion(String groupName) { public Integer getConfigVersion(String groupName) {
GroupConfig groupConfig = getGroupConfigByGroupName(groupName); GroupConfig groupConfig = getGroupConfigByGroupName(groupName);

View File

@ -3,7 +3,6 @@ package com.aizuda.easy.retry.template.datasource.persistence.po;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -15,6 +14,8 @@ public class NotifyConfig implements Serializable {
private String groupName; private String groupName;
private String sceneName;
private Integer notifyStatus; private Integer notifyStatus;
private Integer notifyType; private Integer notifyType;
@ -25,6 +26,10 @@ public class NotifyConfig implements Serializable {
private Integer notifyScene; private Integer notifyScene;
private Integer rateLimiterStatus;
private Integer rateLimiterThreshold;
private String description; private String description;
private LocalDateTime createDt; private LocalDateTime createDt;

View File

@ -7,6 +7,11 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/**
* @author zuojunlin
* @date 2023-11-19 22:05:25
* @since 2.5.0
*/
@Data @Data
public class SceneConfig implements Serializable { public class SceneConfig implements Serializable {

View File

@ -12,15 +12,14 @@ import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
import com.aizuda.easy.retry.server.common.util.DateUtils; import com.aizuda.easy.retry.server.common.util.DateUtils;
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate; import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
import com.aizuda.easy.retry.template.datasource.access.TaskAccess; import com.aizuda.easy.retry.template.datasource.access.TaskAccess;
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig; import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryDeadLetter; import com.aizuda.easy.retry.template.datasource.persistence.po.RetryDeadLetter;
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -38,7 +37,8 @@ import java.util.List;
public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule implements Lifecycle { public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule implements Lifecycle {
private static String retryErrorMoreThresholdTextMessageFormatter = private static String retryErrorMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试失败数据监控</font> \n" + "<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试失败数据监控</font> \n" +
"> 名称:{} \n" + "> 组名称:{} \n" +
"> 场景名称:{} \n" +
"> 时间窗口:{} ~ {} \n" + "> 时间窗口:{} ~ {} \n" +
"> **共计:{}** \n"; "> **共计:{}** \n";
@ -60,37 +60,35 @@ public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule imple
@Override @Override
protected void doExecute() { protected void doExecute() {
LogUtils.info(log, "retryErrorMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp()); LogUtils.info(log, "retryErrorMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp());
for (SceneConfig sceneConfig : accessTemplate.getSceneConfigAccess().getAllConfigSceneList()) {
for (GroupConfig groupConfig : accessTemplate.getGroupConfigAccess().getAllConfigGroupList()) { List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupNameAndSceneName(sceneConfig.getGroupName(),sceneConfig.getSceneName(), NotifySceneEnum.MAX_RETRY_ERROR.getNotifyScene());
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupName(groupConfig.getGroupName(), NotifySceneEnum.MAX_RETRY_ERROR.getNotifyScene()); if (CollectionUtils.isEmpty(notifyConfigs)) {
if (CollectionUtils.isEmpty(notifyConfigs)) { continue;
continue; }
} // x分钟内x组x场景进入死信队列的数据量
LocalDateTime now = LocalDateTime.now();
// x分钟内进入死信队列的数据量 TaskAccess<RetryDeadLetter> retryDeadLetterAccess = accessTemplate.getRetryDeadLetterAccess();
LocalDateTime now = LocalDateTime.now(); long count = retryDeadLetterAccess.count(sceneConfig.getGroupName(), new LambdaQueryWrapper<RetryDeadLetter>().
TaskAccess<RetryDeadLetter> retryDeadLetterAccess = accessTemplate.getRetryDeadLetterAccess(); between(RetryDeadLetter::getCreateDt, now.minusMinutes(30), now)
.eq(RetryDeadLetter::getGroupName,sceneConfig.getGroupName())
long count = retryDeadLetterAccess.count(groupConfig.getGroupName(), new LambdaQueryWrapper<RetryDeadLetter>() .eq(RetryDeadLetter::getSceneName,sceneConfig.getSceneName()));
.between(RetryDeadLetter::getCreateDt, now.minusMinutes(30), now)); for (NotifyConfig notifyConfig : notifyConfigs) {
for (NotifyConfig notifyConfig : notifyConfigs) { if (count > notifyConfig.getNotifyThreshold()) {
if (count > notifyConfig.getNotifyThreshold()) { // 预警
// 预警 AlarmContext context = AlarmContext.build().text(retryErrorMoreThresholdTextMessageFormatter,
AlarmContext context = AlarmContext.build() EnvironmentUtils.getActiveProfile(),
.text(retryErrorMoreThresholdTextMessageFormatter, sceneConfig.getGroupName(),
EnvironmentUtils.getActiveProfile(), sceneConfig.getSceneName(),
groupConfig.getGroupName(), DateUtils.format(now.minusMinutes(30),
DateUtils.format(now.minusMinutes(30), DateUtils.NORM_DATETIME_PATTERN), DateUtils.NORM_DATETIME_PATTERN),
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN), DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN), count)
count) .title("组:[{}] 场景:[{}] 环境重试失败数据监控", sceneConfig.getGroupName(),sceneConfig.getSceneName())
.title("组:[{}] 环境重试失败数据监控", groupConfig.getGroupName()) .notifyAttribute(notifyConfig.getNotifyAttribute());
.notifyAttribute(notifyConfig.getNotifyAttribute()); Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType());
alarmType.asyncSendMessage(context);
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType()); }
alarmType.asyncSendMessage(context);
} }
} }
}
} }
@Override @Override

View File

@ -12,9 +12,9 @@ import com.aizuda.easy.retry.server.common.Lifecycle;
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule; import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
import com.aizuda.easy.retry.server.common.util.DateUtils; import com.aizuda.easy.retry.server.common.util.DateUtils;
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate; import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig; import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask; import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask;
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -40,6 +40,7 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
private static String retryTaskMoreThresholdTextMessageFormatter = private static String retryTaskMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试数据监控</font> \n" + "<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试数据监控</font> \n" +
"> 组名称:{} \n" + "> 组名称:{} \n" +
"> 场景名称:{} \n" +
"> 告警时间:{} \n" + "> 告警时间:{} \n" +
"> **共计:{}** \n"; "> **共计:{}** \n";
@ -59,34 +60,33 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
@Override @Override
protected void doExecute() { protected void doExecute() {
LogUtils.info(log, "retryTaskMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp()); LogUtils.info(log, "retryTaskMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp());
for (SceneConfig sceneConfig : accessTemplate.getSceneConfigAccess().getAllConfigSceneList()) {
for (GroupConfig groupConfig : accessTemplate.getGroupConfigAccess().getAllConfigGroupList()) { List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupNameAndSceneName(sceneConfig.getGroupName(),sceneConfig.getSceneName(), NotifySceneEnum.MAX_RETRY.getNotifyScene());
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupName(groupConfig.getGroupName(), NotifySceneEnum.MAX_RETRY.getNotifyScene()); if (CollectionUtils.isEmpty(notifyConfigs)) {
if (CollectionUtils.isEmpty(notifyConfigs)) { continue;
continue; }
} long count = accessTemplate.getRetryTaskAccess().count(sceneConfig.getGroupName(), new LambdaQueryWrapper<RetryTask>()
.eq(RetryTask::getGroupName, sceneConfig.getGroupName())
long count = accessTemplate.getRetryTaskAccess().count(groupConfig.getGroupName(), new LambdaQueryWrapper<RetryTask>() .eq(RetryTask::getSceneName,sceneConfig.getSceneName())
.eq(RetryTask::getGroupName, groupConfig.getGroupName()) .eq(RetryTask::getRetryStatus, RetryStatusEnum.RUNNING.getStatus()));
.eq(RetryTask::getRetryStatus, RetryStatusEnum.RUNNING.getStatus())); for (NotifyConfig notifyConfig : notifyConfigs) {
for (NotifyConfig notifyConfig : notifyConfigs) { if (count > notifyConfig.getNotifyThreshold()) {
if (count > notifyConfig.getNotifyThreshold()) { // 预警
// 预警 AlarmContext context = AlarmContext.build()
AlarmContext context = AlarmContext.build() .text(retryTaskMoreThresholdTextMessageFormatter,
.text(retryTaskMoreThresholdTextMessageFormatter, EnvironmentUtils.getActiveProfile(),
EnvironmentUtils.getActiveProfile(), sceneConfig.getGroupName(),
groupConfig.getGroupName(), sceneConfig.getSceneName(),
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN), DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN),
count) count)
.title("组:[{}])重试数据过多", groupConfig.getGroupName()) .title("组:[{}] 场景:[{}] 重试数据过多", sceneConfig.getGroupName(),sceneConfig.getSceneName())
.notifyAttribute(notifyConfig.getNotifyAttribute()); .notifyAttribute(notifyConfig.getNotifyAttribute());
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType());
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType()); alarmType.asyncSendMessage(context);
alarmType.asyncSendMessage(context); }
} }
} }
} }
}
@Override @Override
public String lockName() { public String lockName() {

View File

@ -20,6 +20,8 @@ public class NotifyConfigRequestVO {
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线") @Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String groupName; private String groupName;
private String sceneName;
@NotNull(message = "通知状态不能为空") @NotNull(message = "通知状态不能为空")
private Integer notifyStatus; private Integer notifyStatus;
@ -34,6 +36,10 @@ public class NotifyConfigRequestVO {
@NotNull(message = "通知场景不能为空") @NotNull(message = "通知场景不能为空")
private Integer notifyScene; private Integer notifyScene;
@NotNull(message = "限流状态不能为空")
private Integer rateLimiterStatus;
private Integer rateLimiterThreshold;
/** /**
* 描述 * 描述
*/ */

View File

@ -12,6 +12,8 @@ public class NotifyConfigResponseVO implements Serializable {
private String groupName; private String groupName;
private String sceneName;
private Integer notifyStatus; private Integer notifyStatus;
private String notifyName; private String notifyName;
@ -24,6 +26,10 @@ public class NotifyConfigResponseVO implements Serializable {
private Integer notifyScene; private Integer notifyScene;
private Integer rateLimiterStatus;
private Integer rateLimiterThreshold;
private String description; private String description;
private LocalDateTime createDt; private LocalDateTime createDt;

View File

@ -40,7 +40,9 @@ public class NotifyConfigServiceImpl implements NotifyConfigService {
if (StrUtil.isNotBlank(queryVO.getGroupName())) { if (StrUtil.isNotBlank(queryVO.getGroupName())) {
queryWrapper.eq(NotifyConfig::getGroupName, queryVO.getGroupName()); queryWrapper.eq(NotifyConfig::getGroupName, queryVO.getGroupName());
} }
if (StrUtil.isNotBlank(queryVO.getSceneName())) {
queryWrapper.eq(NotifyConfig::getSceneName, queryVO.getSceneName());
}
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().listPage(pageDTO, queryWrapper).getRecords(); List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().listPage(pageDTO, queryWrapper).getRecords();
return new PageResult<>(pageDTO, NotifyConfigResponseVOConverter.INSTANCE.batchConvert(notifyConfigs)); return new PageResult<>(pageDTO, NotifyConfigResponseVOConverter.INSTANCE.batchConvert(notifyConfigs));
} }

View File

@ -114,7 +114,7 @@ export const asyncRouterMap = [
path: '/retry/notify/list', path: '/retry/notify/list',
name: 'NotifyList', name: 'NotifyList',
component: () => import('@/views/task/NotifyList'), component: () => import('@/views/task/NotifyList'),
meta: { title: '通知配置', icon: 'profile', keepAlive: true, permission: ['retryTask'] } meta: { title: '通知列表', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
}, },
{ {
path: '/retry/notify/config', path: '/retry/notify/config',

View File

@ -39,11 +39,11 @@ const enums = {
}, },
notifyScene: { notifyScene: {
'1': { '1': {
'name': '重试数量超过阈值', 'name': '场景重试数量超过阈值',
'color': '#d06892' 'color': '#d06892'
}, },
'2': { '2': {
'name': '重试失败数量超过阈值', 'name': '场景重试失败数量超过阈值',
'color': '#f5a22d' 'color': '#f5a22d'
}, },
'3': { '3': {
@ -53,6 +53,14 @@ const enums = {
'4': { '4': {
'name': '客户端组件异常', 'name': '客户端组件异常',
'color': '#a127f3' 'color': '#a127f3'
},
'5': {
'name': '任务重试数量超过阈值',
'color': '#f5a22d'
},
'6': {
'name': '任务失败进入死信队列',
'color': '#f5a22d'
} }
}, },
routeKey: { routeKey: {
@ -87,6 +95,16 @@ const enums = {
'color': '#087da1' 'color': '#087da1'
} }
}, },
rateLimiterStatus: {
'0': {
'name': '未启用',
'color': '#9c1f1f'
},
'1': {
'name': '启用',
'color': '#f5a22d'
}
},
notifyStatus: { notifyStatus: {
'0': { '0': {
'name': '停用', 'name': '停用',

View File

@ -7,19 +7,23 @@
<template> <template>
<a-col :md="8" :sm="24"> <a-col :md="8" :sm="24">
<a-form-item label="组名称"> <a-form-item label="组名称">
<a-select <a-select v-model="queryParam.groupName" placeholder="请输入组名称" @change="value => handleChange(value)" allowClear>
v-model="queryParam.groupName"
placeholder="请输入组名称"
>
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option> <a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :md="8" :sm="24">
<a-form-item label="场景名称">
<a-select v-model="queryParam.sceneName" placeholder="请选择场景名称" allowClear>
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName"> {{ item.sceneName }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
</template> </template>
<a-col :md="!advanced && 8 || 24" :sm="24"> <a-col :md="!advanced && 8 || 24" :sm="24">
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} "> <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
<a-button type="primary" @click="queryChange()">查询</a-button> <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
</span> </span>
</a-col> </a-col>
</a-row> </a-row>
@ -45,13 +49,18 @@
:rowSelection="options.rowSelection" :rowSelection="options.rowSelection"
> >
<span slot="notifyType" slot-scope="text"> <span slot="notifyType" slot-scope="text">
<a-tag :color="notifyType[text].color"> <a-tag :color="notifyTypeList[text].color">
{{ notifyType[text].name }} {{ notifyTypeList[text].name }}
</a-tag>
</span>
<span slot="notifyStatus" slot-scope="text">
<a-tag :color="notifyStatusList[text].color">
{{ notifyStatusList[text].name }}
</a-tag> </a-tag>
</span> </span>
<span slot="notifyScene" slot-scope="text"> <span slot="notifyScene" slot-scope="text">
<a-tag :color="notifyScene[text].color"> <a-tag :color="notifySceneList[text].color">
{{ notifyScene[text].name }} {{ notifySceneList[text].name }}
</a-tag> </a-tag>
</span> </span>
<span slot="notifyAttribute" slot-scope="text, record"> <span slot="notifyAttribute" slot-scope="text, record">
@ -72,7 +81,7 @@
</template> </template>
<script> <script>
import { getAllGroupNameList, getNotifyConfigList } from '@/api/manage' import { getAllGroupNameList, getNotifyConfigList, getSceneList } from '@/api/manage'
import { STable } from '@/components' import { STable } from '@/components'
const enums = require('@/utils/retryEnum') const enums = require('@/utils/retryEnum')
@ -82,6 +91,26 @@ export default {
data () { data () {
return { return {
notifyColumns: [ notifyColumns: [
{
title: '组名',
dataIndex: 'groupName',
key: 'groupName',
width: '10%',
scopedSlots: { customRender: 'groupName' }
},
{
title: '场景名称',
dataIndex: 'sceneName',
key: 'sceneName',
width: '10%',
scopedSlots: { customRender: 'sceneName' }
},
{
title: '通知状态',
dataIndex: 'notifyStatus',
width: '10%',
scopedSlots: { customRender: 'notifyStatus' }
},
{ {
title: '通知类型', title: '通知类型',
dataIndex: 'notifyType', dataIndex: 'notifyType',
@ -103,13 +132,6 @@ export default {
width: '10%', width: '10%',
scopedSlots: { customRender: 'notifyThreshold' } scopedSlots: { customRender: 'notifyThreshold' }
}, },
{
title: '配置属性',
dataIndex: 'notifyAttribute',
key: 'notifyAttribute',
width: '30%',
scopedSlots: { customRender: 'notifyAttribute' }
},
{ {
title: '描述', title: '描述',
dataIndex: 'description', dataIndex: 'description',
@ -154,18 +176,24 @@ export default {
}, },
optionAlertShow: false, optionAlertShow: false,
memberLoading: false, memberLoading: false,
notifyScene: enums.notifyScene, notifySceneList: enums.notifyScene,
notifyType: enums.notifyType, notifyTypeList: enums.notifyType,
notifyStatus: enums.notifyStatus, notifyStatusList: enums.notifyStatus,
visible: false, visible: false,
key: '', key: '',
notifyTypeValue: '1', notifyTypeValue: '1',
groupNameList: [] groupNameList: [],
sceneList: []
} }
}, },
created () { created () {
getAllGroupNameList().then((res) => { getAllGroupNameList().then((res) => {
this.groupNameList = res.data this.groupNameList = res.data
if (this.groupNameList !== null && this.groupNameList.length > 0) {
this.queryParam['groupName'] = this.groupNameList[0]
this.$refs.table.refresh(true)
this.handleChange(this.groupNameList[0])
}
}) })
const groupName = this.$route.query.groupName const groupName = this.$route.query.groupName
@ -174,32 +202,20 @@ export default {
} }
}, },
methods: { methods: {
resetFiled () {
this.queryParam = {}
this.sceneList = []
},
handleNew () { handleNew () {
this.$router.push({ path: '/retry/notify/config' }) this.$router.push({ path: '/retry/notify/config' })
}, },
handleEdit (record) { handleEdit (record) {
this.$router.push({ path: '/retry/notify/config', query: { id: record.id } }) this.$router.push({ path: '/retry/notify/config', query: { id: record.id } })
}, },
parseJson (text, record) { handleChange (value) {
if (!text) { getSceneList({ groupName: value }).then((res) => {
return null this.sceneList = res.data
} })
let s =
'用户名:' + text['user'] + ';\r\n' +
'密码:' + text['pass'] + ';\r\n' +
'SMTP地址:' + text['host'] + ';\r\n' +
'SMTP端口:' + text['port'] + ';\r\n' +
'发件人:' + text['from'] + ';\r\n' +
'收件人:' + text['tos'] + ';'
if (record.notifyType === 1) {
s = text['dingDingUrl']
} else if (record.notifyType === 4) {
s = text['larkUrl']
}
return s
} }
} }
} }

View File

@ -37,7 +37,7 @@
<a-col :md="!advanced && 8 || 24" :sm="24"> <a-col :md="!advanced && 8 || 24" :sm="24">
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} "> <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button> <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
<a @click="toggleAdvanced" style="margin-left: 8px"> <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'"/> <a-icon :type="advanced ? 'up' : 'down'"/>
@ -167,7 +167,7 @@ export default {
ellipsis: true ellipsis: true
}, },
{ {
title: '场景id', title: '场景名称',
dataIndex: 'sceneName', dataIndex: 'sceneName',
ellipsis: true ellipsis: true
}, },
@ -241,6 +241,10 @@ export default {
}) })
}, },
methods: { methods: {
resetFiled () {
this.queryParam = {}
this.sceneList = []
},
handleNew () { handleNew () {
this.$router.push('/form/basic-config') this.$router.push('/form/basic-config')
}, },

View File

@ -37,7 +37,7 @@
<a-col :md="!advanced && 8 || 24" :sm="24"> <a-col :md="!advanced && 8 || 24" :sm="24">
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} "> <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button> <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
<a @click="toggleAdvanced" style="margin-left: 8px"> <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'"/> <a-icon :type="advanced ? 'up' : 'down'"/>
@ -157,7 +157,7 @@ export default {
width: '10%' width: '10%'
}, },
{ {
title: '场景id', title: '场景名称',
dataIndex: 'sceneName', dataIndex: 'sceneName',
ellipsis: true, ellipsis: true,
width: '10%' width: '10%'
@ -236,6 +236,10 @@ export default {
}) })
}, },
methods: { methods: {
resetFiled () {
this.queryParam = {}
this.sceneList = []
},
handleNew () { handleNew () {
this.$router.push('/form/basic-config') this.$router.push('/form/basic-config')
}, },

View File

@ -55,7 +55,7 @@
:style="(advanced && { float: 'right', overflow: 'hidden' }) || {}" :style="(advanced && { float: 'right', overflow: 'hidden' }) || {}"
> >
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button> <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
<a @click="toggleAdvanced" style="margin-left: 8px"> <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'" /> <a-icon :type="advanced ? 'up' : 'down'" />
@ -324,6 +324,10 @@ export default {
}) })
}, },
methods: { methods: {
resetFiled () {
this.queryParam = {}
this.sceneList = []
},
handleNew () { handleNew () {
this.$refs.saveRetryTask.isShow(true, null) this.$refs.saveRetryTask.isShow(true, null)
}, },

View File

@ -7,24 +7,23 @@
<template> <template>
<a-col :md="8" :sm="24"> <a-col :md="8" :sm="24">
<a-form-item label="组名称"> <a-form-item label="组名称">
<a-select <a-select v-model="queryParam.groupName" placeholder="请输入组名称" @change="value => handleChange(value)" allowClear>
v-model="queryParam.groupName"
placeholder="请输入组名称"
>
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option> <a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :md="8" :sm="24"> <a-col :md="8" :sm="24">
<a-form-item label="场景名称"> <a-form-item label="场景名称">
<a-input v-model="queryParam.sceneName" placeholder="请输入场景名称" allowClear/> <a-select v-model="queryParam.sceneName" placeholder="请选择场景名称" allowClear>
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName"> {{ item.sceneName }}</a-select-option>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
</template> </template>
<a-col :md="!advanced && 8 || 24" :sm="24"> <a-col :md="!advanced && 8 || 24" :sm="24">
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} "> <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button> <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
</span> </span>
</a-col> </a-col>
</a-row> </a-row>
@ -89,7 +88,7 @@
</template> </template>
<script> <script>
import { getAllGroupNameList, getScenePage } from '@/api/manage' import { getAllGroupNameList, getSceneList, getScenePage } from '@/api/manage'
import { STable } from '@/components' import { STable } from '@/components'
const enums = require('@/utils/retryEnum') const enums = require('@/utils/retryEnum')
export default { export default {
@ -100,6 +99,13 @@ export default {
data () { data () {
return { return {
sceneColumns: [ sceneColumns: [
{
title: '组名',
dataIndex: 'groupName',
key: 'groupName',
width: '10%',
scopedSlots: { customRender: 'groupName' }
},
{ {
title: '场景名称', title: '场景名称',
dataIndex: 'sceneName', dataIndex: 'sceneName',
@ -203,20 +209,35 @@ export default {
} }
}, },
optionAlertShow: false, optionAlertShow: false,
groupNameList: [] groupNameList: [],
sceneList: []
} }
}, },
created () { created () {
getAllGroupNameList().then((res) => { getAllGroupNameList().then((res) => {
this.groupNameList = res.data this.groupNameList = res.data
if (this.groupNameList !== null && this.groupNameList.length > 0) {
this.queryParam['groupName'] = this.groupNameList[0]
this.$refs.table.refresh(true)
this.handleChange(this.groupNameList[0])
}
}) })
}, },
methods: { methods: {
resetFiled () {
this.queryParam = {}
this.sceneList = []
},
handleNew () { handleNew () {
this.$router.push({ path: '/retry/scene/config' }) this.$router.push({ path: '/retry/scene/config' })
}, },
handleEdit (record) { handleEdit (record) {
this.$router.push({ path: '/retry/scene/config', query: { id: record.id } }) this.$router.push({ path: '/retry/scene/config', query: { id: record.id } })
},
handleChange (value) {
getSceneList({ groupName: value }).then((res) => {
this.sceneList = res.data
})
} }
} }
} }

View File

@ -21,11 +21,11 @@
'notifyScene', 'notifyScene',
{ {
initialValue: '1', initialValue: '1',
rules: [{ required: true, message: '请选择状态'}] rules: [{ required: true, message: '请选通知场景'}]
} }
]" ]"
> >
<a-select-option :value="index" v-for="(item, index) in notifyScene" :key="index">{{ item.name }}</a-select-option> <a-select-option :value="index" v-for="(item, index) in notifySceneList" :key="index">{{ item.name }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -50,33 +50,21 @@
rules: [{ required: !notifyThresholdDisabled.includes(this.notifySceneValue), message: '请输入通知阈值'}] rules: [{ required: !notifyThresholdDisabled.includes(this.notifySceneValue), message: '请输入通知阈值'}]
} }
]" /> ]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row class="form-row" :gutter="16"> <a-row class="form-row" :gutter="16">
<a-col :lg="18" :md="18" :sm="24"> <a-col :lg="18" :md="12" :sm="24">
<a-form-item label="组"> <a-form-item label="组">
<a-select <a-select placeholder="请选择组" v-decorator="['groupName', { rules: [{ required: true, message: '请选择组' }] }]" @change="value => changeGroup(value)">
placeholder="请选择组"
v-decorator="['groupName', { rules: [{ required: true, message: '请选择组' }] }]"
>
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option> <a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="6" :md="12" :sm="24"> <a-col :lg="6" :md="12" :sm="24">
<a-form-item label="状态"> <a-form-item label="场景">
<a-select <a-select :disabled="sceneNameDisabled.includes(this.notifySceneValue)" placeholder="请选择场景" v-decorator="['sceneName', { rules: [{ required: !sceneNameDisabled.includes(this.notifySceneValue), message: '请选择场景' }] }]" >
placeholder="请选择状态" <a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName">{{ item.sceneName }}</a-select-option>
v-decorator="[
'notifyStatus',
{
initialValue: '1',
rules: [{ required: true, message: '请选择状态'}]
}
]" >
<a-select-option :value="index" v-for="(item, index) in notifyStatus" :key="index">{{ item.name }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -92,11 +80,11 @@
'notifyType', 'notifyType',
{ {
initialValue: '1', initialValue: '1',
rules: [{ required: true, message: '请选择状态'}] rules: [{ required: true, message: '请选择通知类型'}]
} }
]" ]"
> >
<a-select-option :value="index" v-for="(item, index) in notifyType" :key="index">{{ item.name }}</a-select-option> <a-select-option :value="index" v-for="(item, index) in notifyTypeList" :key="index">{{ item.name }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -109,7 +97,35 @@
'notifyAttribute', 'notifyAttribute',
{rules: [{ required: true, message: '请输入配置属性', whitespace: true}]} {rules: [{ required: true, message: '请输入配置属性', whitespace: true}]}
]" /> ]" />
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="8" :md="12" :sm="24">
<a-form-item label="限流状态">
<a-select :disabled="rateLimiterStatusDisabled.includes(this.notifySceneValue)" placeholder="请选择限流状态" @change="changeRateLimiterStatus" v-decorator="['rateLimiterStatus',{initialValue: '0', rules: [{ required: true, message: '请选择限流状态'}]}]" >
<a-select-option :value="index" v-for="(item, index) in rateLimiterStatusList" :key="index">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :sm="24">
<a-form-item label="每秒限流阈值">
<a-input-number :disabled="rateLimiterThresholdDisabled.includes(this.rateLimiterStatusValue)" id="inputNumber" :min="1" style="width: -webkit-fill-available" v-decorator= "['rateLimiterThreshold',{initialValue: '100',rules: [{ required: !rateLimiterThresholdDisabled.includes(this.rateLimiterStatusValue), message: '请输入通知阈值' }]}]" />
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :sm="24">
<a-form-item label="状态">
<a-select
placeholder="请选择状态"
v-decorator="[
'notifyStatus',
{
initialValue: '1',
rules: [{ required: true, message: '请选择状态'}]
}
]" >
<a-select-option :value="index" v-for="(item, index) in notifyStatusList" :key="index">{{ item.name }}</a-select-option>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -131,11 +147,9 @@
style="text-align: center" style="text-align: center"
> >
<a-button htmlType="submit" type="primary">提交</a-button> <a-button htmlType="submit" type="primary">提交</a-button>
<a-button style="margin-left: 8px">重置</a-button>
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-card> </a-card>
<a-modal :visible="visible" title="添加配置" @ok="handleOk" @cancel="handlerCancel" width="1000px"> <a-modal :visible="visible" title="添加配置" @ok="handleOk" @cancel="handlerCancel" width="1000px">
<a-form :form="notifyAttributeForm" @submit="handleSubmit" :body-style="{padding: '0px 0px'}" v-bind="formItemLayout" > <a-form :form="notifyAttributeForm" @submit="handleSubmit" :body-style="{padding: '0px 0px'}" v-bind="formItemLayout" >
<a-form-item <a-form-item
@ -144,20 +158,43 @@
<a-input <a-input
placeholder="请输入钉钉URL" placeholder="请输入钉钉URL"
v-decorator="[ v-decorator="[
'dingDingUrl', 'webhookUrl',
{rules: [{ required: true, message: '请输入钉钉URL', whitespace: true}]} {rules: [{ required: true, message: '请输入钉钉URL', whitespace: true}]}
]" /> ]" />
</a-form-item> </a-form-item>
<a-form-item v-if="this.notifyTypeValue === '1'">
<span slot="label">@负责人手机号&nbsp;<a :href="officialWebsite + '/pages/32e4a0/#被@负责人手机号是何物' +''" target="_blank"> <a-icon type="question-circle-o" /></a></span>
<a-input
placeholder="请输入被@负责人手机号"
type="textarea"
v-if="this.notifyTypeValue === '1'"
v-decorator="[
'ats',
{rules: [{ required: true, message: '请输入被@负责人手机号', whitespace: true}]}
]" />
</a-form-item>
<a-form-item <a-form-item
v-if="this.notifyTypeValue === '4'" v-if="this.notifyTypeValue === '4'"
label="飞书URL"> label="飞书URL">
<a-input <a-input
placeholder="请输入飞书URL" placeholder="请输入飞书URL"
v-decorator="[ v-decorator="[
'larkUrl', 'webhookUrl',
{rules: [{ required: true, message: '请输入飞书URL', whitespace: true}]} {rules: [{ required: true, message: '请输入飞书URL', whitespace: true}]}
]" /> ]" />
</a-form-item> </a-form-item>
<a-form-item
v-if="this.notifyTypeValue === '4'">
<span slot="label">@负责人用户id&nbsp;<a :href="officialWebsite + '/pages/32e4a0/#被@负责人用户id是何物' +''" target="_blank"> <a-icon type="question-circle-o" /></a></span>
<a-input
placeholder="请输入被@负责人用户id"
type="textarea"
v-if="this.notifyTypeValue === '4'"
v-decorator="[
'ats',
{rules: [{ required: true, message: '请输入被@负责人用户id', whitespace: true}]}
]" />
</a-form-item>
<a-form-item <a-form-item
v-if="this.notifyTypeValue === '2'" v-if="this.notifyTypeValue === '2'"
label="用户名"> label="用户名">
@ -237,15 +274,14 @@
</template> </template>
<script> <script>
import { getAllGroupNameList } from '@/api/manage' import { getAllGroupNameList, getSceneList } from '@/api/manage'
import { getNotifyConfigDetail, saveNotify, updateNotify } from '@/api/retryApi' import { getNotifyConfigDetail, saveNotify, updateNotify } from '@/api/retryApi'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import CronModal from '@/views/job/from/CronModal' import CronModal from '@/views/job/from/CronModal'
import { officialWebsite } from '@/utils/util'
const enums = require('@/utils/retryEnum') const enums = require('@/utils/retryEnum')
export default { export default {
name: 'NotifyFrom', name: 'NotifyFrom',
components: { CronModal },
props: {}, props: {},
comments: { comments: {
CronModal CronModal
@ -257,6 +293,7 @@ export default {
labelCol: { lg: { span: 7 }, sm: { span: 7 } }, labelCol: { lg: { span: 7 }, sm: { span: 7 } },
wrapperCol: { lg: { span: 10 }, sm: { span: 17 } } wrapperCol: { lg: { span: 10 }, sm: { span: 17 } }
}, },
officialWebsite: officialWebsite(),
formItemLayoutWithOutLabel: { formItemLayoutWithOutLabel: {
wrapperCol: { wrapperCol: {
xs: { span: 24, offset: 0 }, xs: { span: 24, offset: 0 },
@ -265,17 +302,24 @@ export default {
}, },
formType: 'create', formType: 'create',
groupNameList: [], groupNameList: [],
notifyScene: enums.notifyScene, sceneList: [],
notifyType: enums.notifyType, notifySceneList: enums.notifyScene,
notifyStatus: enums.notifyStatus, notifyTypeList: enums.notifyType,
notifyStatusList: enums.notifyStatus,
rateLimiterStatusList: enums.rateLimiterStatus,
loading: false, loading: false,
visible: false, visible: false,
count: 0, count: 0,
notifyTypeValue: '1', notifyTypeValue: '1',
notifyAttribute: '', notifyAttribute: '',
notifyThresholdDisabled: ['3', '4'], notifyThresholdDisabled: ['3', '4', '6'],
notifySceneValue: '1' sceneNameDisabled: ['3', '4'],
rateLimiterStatusDisabled: ['1', '2', '3', '4'],
rateLimiterThresholdDisabled: ['0'],
notifySceneValue: '1',
rateLimiterStatusValue: '0',
defaultRateLimiterStatusValue: '0',
defaultRateLimiterThreshold: '100'
} }
}, },
beforeCreate () { beforeCreate () {
@ -299,24 +343,55 @@ export default {
}) })
}, },
methods: { methods: {
resetFiled () {
this.form.resetFields()
},
buildNotifyAttribute (formData) {
formData.ats = formData.ats && formData.ats.replace(/\s+/g, '').split(',')
return JSON.stringify(formData)
},
handleChange (notifyType) { handleChange (notifyType) {
this.notifyTypeValue = notifyType this.notifyTypeValue = notifyType
}, },
changeGroup (value) {
getSceneList({ groupName: value }).then((res) => {
this.sceneList = res.data
})
},
changeRateLimiterStatus (rateLimiterStatus) {
this.rateLimiterStatusValue = rateLimiterStatus
},
changeNotifyScene (notifyScene) { changeNotifyScene (notifyScene) {
console.log(notifyScene)
this.notifySceneValue = notifyScene this.notifySceneValue = notifyScene
const { form } = this
if (this.sceneNameDisabled.includes(notifyScene)) {
form.setFieldsValue({
sceneName: ''
})
}
if (this.rateLimiterStatusDisabled.includes(notifyScene)) {
form.setFieldsValue({
rateLimiterStatus: this.defaultRateLimiterStatusValue,
rateLimiterThreshold: this.defaultRateLimiterThreshold
})
this.changeRateLimiterStatus(this.defaultRateLimiterStatusValue)
}
}, },
handleBlur () { handleBlur () {
new Promise((resolve) => { new Promise((resolve) => {
setTimeout(resolve, 100) setTimeout(resolve, 100)
}).then(() => { }).then(() => {
if (this.formType === 'edit') { if (this.formType === 'edit') {
const formData = pick(JSON.parse(this.notifyAttribute), ['dingDingUrl', 'larkUrl', 'user', 'pass', 'host', 'port', 'from', 'tos']) const formData = pick(JSON.parse(this.notifyAttribute), ['webhookUrl', 'ats', 'user', 'pass', 'host', 'port', 'from', 'tos'])
console.log(formData) this.notifyAttributeForm.getFieldDecorator(`webhookUrl`, { initialValue: formData.webhookUrl, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`ats`, { initialValue: formData.ats.join(','), preserve: true })
this.notifyAttributeForm.getFieldDecorator(`dingDingUrl`, { initialValue: formData.dingDingUrl, preserve: true }) this.notifyAttributeForm.getFieldDecorator(`user`, { initialValue: formData.user, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`pass`, { initialValue: formData.pass, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`host`, { initialValue: formData.host, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`port`, { initialValue: formData.port, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`from`, { initialValue: formData.from, preserve: true })
this.notifyAttributeForm.getFieldDecorator(`tos`, { initialValue: formData.tos, preserve: true })
} }
this.visible = !this.visible this.visible = !this.visible
}) })
}, },
@ -326,11 +401,9 @@ export default {
handleOk () { handleOk () {
this.notifyAttributeForm.validateFields((err, values) => { this.notifyAttributeForm.validateFields((err, values) => {
if (!err) { if (!err) {
console.log(values)
const { form } = this const { form } = this
const formData = pick(values, ['dingDingUrl', 'larkUrl', 'user', 'pass', 'host', 'port', 'from', 'tos']) const formData = pick(values, ['webhookUrl', 'ats', 'user', 'pass', 'host', 'port', 'from', 'tos'])
console.log(this.parseJson(formData)) this.notifyAttribute = this.buildNotifyAttribute(formData)
this.notifyAttribute = JSON.stringify(formData)
form.setFieldsValue({ form.setFieldsValue({
notifyAttribute: this.parseJson(formData) notifyAttribute: this.parseJson(formData)
}) })
@ -359,24 +432,29 @@ export default {
} }
}) })
}, },
loadEditInfo (data) { loadEditInfo (data) {
this.formType = 'edit' this.formType = 'edit'
const { form } = this const { form } = this
// ajax // ajax
new Promise((resolve) => { new Promise((resolve) => {
setTimeout(resolve, 100) setTimeout(async () => {
await this.changeGroup(data.groupName)
resolve()
}, 100)
}).then(() => { }).then(() => {
const formData = pick(data, [ const formData = pick(data, [
'id', 'notifyAttribute', 'groupName', 'notifyStatus', 'notifyScene', 'notifyThreshold', 'notifyType', 'notifyThreshold', 'description']) 'id', 'notifyAttribute', 'groupName', 'sceneName', 'notifyStatus', 'notifyScene', 'notifyThreshold', 'notifyType', 'description', 'rateLimiterStatus', 'rateLimiterThreshold'])
formData.notifyStatus = formData.notifyStatus.toString() formData.notifyStatus = formData.notifyStatus.toString()
formData.notifyScene = formData.notifyScene.toString() formData.notifyScene = formData.notifyScene.toString()
formData.notifyType = formData.notifyType.toString() formData.notifyType = formData.notifyType.toString()
formData.notifyThreshold = formData.notifyThreshold.toString() formData.notifyThreshold = formData.notifyThreshold.toString()
formData.rateLimiterStatus = formData.rateLimiterStatus.toString()
formData.rateLimiterThreshold = formData.rateLimiterThreshold.toString()
this.notifyTypeValue = formData.notifyType this.notifyTypeValue = formData.notifyType
this.notifyAttribute = formData.notifyAttribute this.notifyAttribute = formData.notifyAttribute
this.notifySceneValue = formData.notifyScene this.notifySceneValue = formData.notifyScene
this.rateLimiterStatusValue = formData.rateLimiterStatus
formData.notifyAttribute = this.parseJson(JSON.parse(formData.notifyAttribute)) formData.notifyAttribute = this.parseJson(JSON.parse(formData.notifyAttribute))
console.log(formData)
form.setFieldsValue(formData) form.setFieldsValue(formData)
}) })
}, },
@ -394,11 +472,14 @@ export default {
'收件人:' + json['tos'] + ';' '收件人:' + json['tos'] + ';'
if (this.notifyTypeValue === '1') { if (this.notifyTypeValue === '1') {
s = json['dingDingUrl'] s =
'钉钉Url:' + json['webhookUrl'] + ';' +
'被@负责人手机号:' + json['ats'] + ';'
} else if (this.notifyTypeValue === '4') { } else if (this.notifyTypeValue === '4') {
s = json['larkUrl'] s =
'飞书Url:' + json['webhookUrl'] + ';' +
'被@负责人用户id:' + json['ats'] + ';'
} }
return s return s
} }
} }

View File

@ -187,7 +187,7 @@
style="text-align: center" style="text-align: center"
> >
<a-button htmlType="submit" type="primary">提交</a-button> <a-button htmlType="submit" type="primary">提交</a-button>
<a-button style="margin-left: 8px">重置</a-button> <a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-card> </a-card>
@ -245,6 +245,9 @@ export default {
}) })
}, },
methods: { methods: {
resetFiled () {
this.form.resetFields()
},
handleChange (value) { handleChange (value) {
console.log(value) console.log(value)
this.backOff = value this.backOff = value