diff --git a/src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java b/src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java index d5a77592..7284bcf1 100644 --- a/src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java @@ -373,6 +373,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl recipientEmails = new LinkedHashSet<>(); + appendEmailRecipients(recipientEmails, leader.getEmail()); + appendEmailRecipients(recipientEmails, leader.getEmail2()); + if (recipientEmails.isEmpty()) { + log.warn("试验负责人 {} 未配置邮箱(email/email2),跳过驳回提醒通知", leader.getUsername()); + return; + } + + MailSendAddressData mailSendData = qcMapper.getSendMailFromAddress(); + if (mailSendData == null) { + log.error("邮件发送配置未设置,无法发送试验负责人驳回提醒通知"); + return; + } + + String rejectNodeCode = (approvalData != null && StringUtils.isNotBlank(approvalData.getNodeCode())) + ? approvalData.getNodeCode() : "未知审批节点"; + String targetNode = StringUtils.isNotBlank(targetNodeCode) ? targetNodeCode : "技术经理审批"; + String rejectComment = (approvalData != null && StringUtils.isNotBlank(approvalData.getComment())) + ? approvalData.getComment().trim() : "(无)"; + + String subject = String.format("【工程试验申请驳回提醒】%s - %s", + entity.getApplyNo(), entity.getTitle() != null ? entity.getTitle() : ""); + String body = "" + + "

尊敬的 " + leader.getUsername() + ":

" + + "

您好!您负责的工程试验申请单已被驳回,请及时登录系统查看详情并处理。

" + + "

试验单号:" + entity.getApplyNo() + "

" + + "

驳回节点:" + rejectNodeCode + "

" + + "

审批意见:" + rejectComment + "

" + + "

前往工程试验申请管理页面

" + + "

发送时间:" + + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + + "

"; + + MailUtil.sendMail(subject, body, recipientEmails.toArray(new String[0]), mailSendData); + log.info("已向试验负责人 {} ({}) 发送驳回提醒通知,试验单: {}", + leader.getUsername(), String.join(";", recipientEmails), entity.getApplyNo()); + + SendMailRecord mailRecord = new SendMailRecord(); + mailRecord.setType("工程试验申请试验负责人驳回提醒"); + mailRecord.setDocumentNo(entity.getApplyNo()); + mailRecord.setRecipient(String.join(";", recipientEmails)); + mailRecord.setSendDate(new Date()); + qcMapper.saveSendMailRecord(mailRecord); + } catch (Exception e) { + log.error("发送试验负责人驳回提醒邮件失败,试验单: {}, 错误: {}", entity.getApplyNo(), e.getMessage(), e); + } + } + /** * 经理层审批全部通过后(进入计划员排产节点时)通知试验负责人:其负责的试验申请单已审批通过 */