feat(project): 实现临期逾期告警功能

- 新增告警记录表 rdms_due_alert_record 用于去重控制
- 添加告警相关常量类 DueAlertConstants 和对象类型枚举
- 在各数据访问层增加告警候选查询方法
- 实现告警候选服务类和站内信等级功能
- 添加临期逾期告警模板常量定义
- 扩展站内信发送接口支持消息等级
- 新增未读消息批量查询功能用于重复发送判定
This commit is contained in:
2026-06-13 15:00:36 +08:00
parent 635c18767e
commit 896ef0f127
41 changed files with 1650 additions and 18 deletions

View File

@@ -2,6 +2,8 @@ package com.njcn.rdms.module.system.api.notify;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.notify.dto.NotifySingleSendReqDTO;
import com.njcn.rdms.module.system.api.notify.dto.NotifyUnreadMessageListReqDTO;
import com.njcn.rdms.module.system.api.notify.dto.NotifyUnreadMessageRespDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -10,6 +12,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
@@ -42,4 +45,26 @@ public interface NotifyMessageSendApi {
.setTemplateCode(templateCode).setTemplateParams(templateParams)).checkError();
}
/**
* 便捷方法:发送带等级的单条站内信给管理后台用户。
*
* @param level 消息等级,见 {@link com.njcn.rdms.module.system.enums.notify.NotifyMessageLevelConstants}
*/
default void sendSingleNotifyToAdmin(Long userId, String templateCode,
Map<String, Object> templateParams, Integer level) {
sendSingleNotify(new NotifySingleSendReqDTO().setUserId(userId)
.setTemplateCode(templateCode).setTemplateParams(templateParams).setLevel(level)).checkError();
}
/**
* 查询一批用户在指定模板下的未读站内信userType 固定 ADMIN由实现层处理
*
* <p>供业务方做"未读不重发"类判定(如临期/逾期告警);
* 与发送同挂在本 API复用既有 Feign 注册,消息域的跨模块入口保持唯一。</p>
*/
@PostMapping(PREFIX + "/unread-list-by-template-codes")
@Operation(summary = "查询一批用户在指定模板下的未读站内信")
CommonResult<List<NotifyUnreadMessageRespDTO>> getUnreadNotifyMessageListByTemplateCodes(
@Valid @RequestBody NotifyUnreadMessageListReqDTO reqDTO);
}

View File

@@ -1,5 +1,6 @@
package com.njcn.rdms.module.system.api.notify.dto;
import com.njcn.rdms.module.system.enums.notify.NotifyMessageLevelConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@@ -28,4 +29,7 @@ public class NotifySingleSendReqDTO {
@Schema(description = "模板参数(占位符 -> 值)", example = "{\"taskName\":\"联调\"}")
private Map<String, Object> templateParams;
@Schema(description = "消息等级1普通/2提醒/3警告/4严重默认普通", example = "1")
private Integer level = NotifyMessageLevelConstants.NORMAL;
}

View File

@@ -0,0 +1,32 @@
package com.njcn.rdms.module.system.api.notify.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 查询一批用户在指定模板下的未读站内信 Request DTO。
*
* <p>业务方按模板维度查未读(如临期/逾期告警的"未读不重发"判定),
* userType 在能力层固定 ADMIN不暴露给业务方与发送口径一致。</p>
*
* @author hongawen
*/
@Schema(description = "RPC 服务 - 查询未读站内信 Request DTO")
@Data
@Accessors(chain = true)
public class NotifyUnreadMessageListReqDTO {
@Schema(description = "接收用户编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024,2048]")
@NotEmpty(message = "用户编号列表不能为空")
private List<Long> userIds;
@Schema(description = "站内信模板编码列表", requiredMode = Schema.RequiredMode.REQUIRED,
example = "[\"due_alert_overdue_owner\"]")
@NotEmpty(message = "模板编码列表不能为空")
private List<String> templateCodes;
}

View File

@@ -0,0 +1,30 @@
package com.njcn.rdms.module.system.api.notify.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Map;
/**
* 未读站内信 Response DTO按模板查询的精简视图
*
* <p>只回传业务判定需要的三个字段;正文等展示字段不在跨模块契约里暴露。</p>
*
* @author hongawen
*/
@Schema(description = "RPC 服务 - 未读站内信 Response DTO")
@Data
@Accessors(chain = true)
public class NotifyUnreadMessageRespDTO {
@Schema(description = "接收用户编号", example = "1024")
private Long userId;
@Schema(description = "模板编码", example = "due_alert_overdue_owner")
private String templateCode;
@Schema(description = "发送时的模板参数(含业务附加参数,如 objectType/objectId")
private Map<String, Object> templateParams;
}

View File

@@ -0,0 +1,26 @@
package com.njcn.rdms.module.system.enums.notify;
/**
* 站内信消息等级常量(值 1-4数字越大越严重
*
* <p>等级「值」供代码逻辑引用(如告警按场景定级);等级「展示」(名字/颜色) 走字典
* {@link #DICT_TYPE},运维可调、不发版。本类不做合法集合校验、不做枚举全集
* 沿用本仓库「DB 动态配置字段不做代码侧校验」习惯)。</p>
*/
public final class NotifyMessageLevelConstants {
private NotifyMessageLevelConstants() {
}
/** 普通(默认,灰) */
public static final int NORMAL = 1;
/** 提醒(黄) */
public static final int REMIND = 2;
/** 警告(橙) */
public static final int WARN = 3;
/** 严重(红) */
public static final int SEVERE = 4;
/** 等级展示字典类型(前端拉取渲染徽标) */
public static final String DICT_TYPE = "notify_message_level";
}