mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 11:26:50 +08:00
案例专家:邮件告警逻辑
This commit is contained in:
@@ -56,4 +56,9 @@ public class CaseAiProperties {
|
||||
* 白名单用户列表
|
||||
*/
|
||||
private List<String> whiteUserCodeList;
|
||||
|
||||
/**
|
||||
* AI处理失败告警邮件收件人列表
|
||||
*/
|
||||
private List<String> alertEmailRecipients;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.xboe.enums.CaseDocumentLogCaseStatusEnum;
|
||||
import com.xboe.enums.CaseDocumentLogOptStatusEnum;
|
||||
import com.xboe.enums.CaseDocumentLogOptTypeEnum;
|
||||
import com.xboe.enums.CaseDocumentLogRunStatusEnum;
|
||||
import com.xboe.module.assistance.service.IEmailService;
|
||||
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
|
||||
import com.xboe.module.boecase.dao.CasesDao;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
@@ -70,6 +71,9 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
|
||||
@Autowired
|
||||
private IAiAccessTokenService aiAccessTokenService;
|
||||
|
||||
@Autowired
|
||||
private IEmailService emailService;
|
||||
|
||||
private static final String ACCESS_TOKEN_CACHE_KEY = "case:ai:access_token";
|
||||
|
||||
@Override
|
||||
@@ -897,7 +901,6 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
|
||||
private void saveCaseDocumentLog(String caseId, String caseTitle, String optType,
|
||||
String requestUrl, String requestBody, String responseBody,
|
||||
Integer runStatus, Integer optStatus, Integer caseStatus, String taskId) {
|
||||
try {
|
||||
CaseDocumentLog caseDocumentLog = new CaseDocumentLog();
|
||||
caseDocumentLog.setId(IDGenerator.generate());
|
||||
caseDocumentLog.setTaskId(taskId);
|
||||
@@ -913,10 +916,61 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
|
||||
caseDocumentLog.setCaseStatus(caseStatus);
|
||||
caseDocumentLog.setExecuteDuration(0L);
|
||||
|
||||
try {
|
||||
caseDocumentLogDao.save(caseDocumentLog);
|
||||
log.info("保存CaseDocumentLog成功,logId: {}", caseDocumentLog.getId());
|
||||
} catch (Exception e) {
|
||||
log.error("保存CaseDocumentLog失败", e);
|
||||
}
|
||||
|
||||
// 发送告警邮件逻辑
|
||||
try {
|
||||
// 如果optStatus是失败(2),发送"接口调用失败"告警邮件
|
||||
if (optStatus != null && optStatus.equals(CaseDocumentLogOptStatusEnum.FAILED.getCode())) {
|
||||
String subject = "【知识处理报警】知识处理失败-操作类型:【" + CaseDocumentLogOptTypeEnum.getDescByCode(optType) + "】";
|
||||
StringBuilder content = new StringBuilder();
|
||||
content.append("您好!知识处理流程中,AI接口调用经多次重试后仍失败,具体信息如下:<br/><br/>");
|
||||
content.append("案例标题:").append(caseTitle).append("<br/>");
|
||||
content.append("操作类型:").append(CaseDocumentLogOptTypeEnum.getDescByCode(optType)).append("<br/>");
|
||||
content.append("调用接口:").append(requestUrl).append("<br/>");
|
||||
content.append("调用时间:").append(caseDocumentLog.getOptTime()).append("<br/><br/>");
|
||||
content.append("请及时排查接口可用性、文档信息有效性或AI平台状态,避免影响知识处理进度。");
|
||||
|
||||
// 使用配置的收件人列表
|
||||
List<String> recipients = caseAiProperties.getAlertEmailRecipients();
|
||||
if (recipients != null && !recipients.isEmpty()) {
|
||||
try {
|
||||
String to = String.join(",", recipients);
|
||||
emailService.sendMail(to, subject, content.toString(), null);
|
||||
} catch (Exception e) {
|
||||
log.error("发送接口调用失败告警邮件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果caseStatus是失败(2),发送"业务处理失败"告警邮件
|
||||
if (caseStatus != null && caseStatus.equals(CaseDocumentLogCaseStatusEnum.FAILED.getCode())) {
|
||||
String subject = "【知识处理报警】AI平台处理失败-操作类型:【" + CaseDocumentLogOptTypeEnum.getDescByCode(optType) + "】";
|
||||
StringBuilder content = new StringBuilder();
|
||||
content.append("您好!知识处理流程中,AI平台业务处理失败,具体信息如下:<br/><br/>");
|
||||
content.append("案例标题:").append(caseTitle).append("<br/>");
|
||||
content.append("操作类型:").append(CaseDocumentLogOptTypeEnum.getDescByCode(optType)).append("<br/>");
|
||||
content.append("调用时间:").append(caseDocumentLog.getOptTime()).append("<br/><br/>");
|
||||
content.append("请及时核查文档处理失败原因,或联系AI平台技术支持排查解析问题。");
|
||||
|
||||
// 使用配置的收件人列表
|
||||
List<String> recipients = caseAiProperties.getAlertEmailRecipients();
|
||||
if (recipients != null && !recipients.isEmpty()) {
|
||||
try {
|
||||
String to = String.join(",", recipients);
|
||||
emailService.sendMail(to, subject, content.toString(), null);
|
||||
} catch (Exception e) {
|
||||
log.error("发送业务处理失败告警邮件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发送告警邮件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,8 @@ xboe:
|
||||
ai-api-code: 30800
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
file-upload-callback-url: http://192.168.0.253:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
|
||||
@@ -119,6 +119,8 @@ xboe:
|
||||
ai-api-code: 30800
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
file-upload-callback-url: http://10.251.132.75:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
|
||||
@@ -85,6 +85,8 @@ xboe:
|
||||
ai-api-code: 30800
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
file-upload-callback-url: http://10.251.113.95:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
|
||||
@@ -121,6 +121,8 @@ xboe:
|
||||
file-upload-callback-url: http://10.251.186.27:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
use-white-list: true
|
||||
white-user-code-list: 00004409
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
|
||||
Reference in New Issue
Block a user