[DAT] 新增失败时发邮件

This commit is contained in:
liu.zixi
2025-10-21 16:58:29 +08:00
parent fe688de8aa
commit 67dfee1f07

View File

@@ -14,7 +14,6 @@ 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.assistance.service.ISmtpEmailService;
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
import com.xboe.module.boecase.dao.CasesDao;
@@ -77,9 +76,6 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
@Autowired
private IAiAccessTokenService aiAccessTokenService;
@Autowired
private IEmailService emailService;
@Autowired
private ISmtpEmailService smtpEmailService;
@@ -1197,6 +1193,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
* 根据文件状态更新日志记录
*/
private void updateLogStatusByFileStatus(CaseDocumentLog caseLog, String fileStatus) {
boolean needToSendEmail = false;
try {
boolean needUpdate = false;
@@ -1213,7 +1210,8 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
caseLog.setOptStatus(CaseDocumentLogOptStatusEnum.SUCCESS.getCode());
caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.FAILED.getCode());
needUpdate = true;
log.error("文档处理失败更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
needToSendEmail = true;
log.error("文档处理失败需要发送邮件更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
} else {
// 其他状态uploaded、texted、vectoring不做数据变更
log.info("文档状态为{}暂不更新数据库taskId: {}", fileStatus, caseLog.getTaskId());
@@ -1231,6 +1229,28 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
} catch (Exception e) {
log.error("更新日志状态异常taskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus, e);
}
if (needToSendEmail) {
String subject = "【知识处理报警】AI平台处理失败-操作类型:【" + CaseDocumentLogOptTypeEnum.CREATE.getDesc() + "";
StringBuilder content = new StringBuilder();
content.append("您好知识处理流程中AI平台业务处理失败具体信息如下<br/><br/>");
content.append("案例标题:").append(caseLog.getCaseTitle()).append("<br/>");
content.append("操作类型:").append(CaseDocumentLogOptTypeEnum.CREATE.getDesc()).append("<br/>");
content.append("调用时间:").append(caseLog.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);
smtpEmailService.sendMailBySmtp(to, subject, content.toString(), null);
} catch (Exception e) {
log.error("发送业务处理失败告警邮件失败", e);
}
}
}
}
/**