|
|
|
@ -373,6 +373,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx |
|
|
|
apply.setStatus("已驳回"); |
|
|
|
apply.setCurrentStep("已驳回"); |
|
|
|
this.updateById(apply); |
|
|
|
sendProjectLeaderRejectedNotification(apply, data, targetNodeCode); |
|
|
|
} |
|
|
|
log.info("审批驳回,返回节点:{}", targetNodeCode); |
|
|
|
} |
|
|
|
@ -2413,6 +2414,65 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 审批驳回后通知试验负责人:提醒其到申请页面查看详情 |
|
|
|
*/ |
|
|
|
private void sendProjectLeaderRejectedNotification(ErfExpApply entity, ErfFlowApprovalData approvalData, String targetNodeCode) { |
|
|
|
try { |
|
|
|
UserEmailInfoDto leader = resolveProjectLeaderEmailInfo(entity); |
|
|
|
if (leader == null) { |
|
|
|
log.warn("无法解析试验负责人邮箱,跳过驳回提醒通知: applyNo={}", entity.getApplyNo()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Set<String> 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 = "<html><body>" |
|
|
|
+ "<h3>尊敬的 " + leader.getUsername() + ":</h3>" |
|
|
|
+ "<p>您好!您负责的工程试验申请单已被驳回,请及时登录系统查看详情并处理。</p>" |
|
|
|
+ "<p><strong>试验单号:</strong>" + entity.getApplyNo() + "</p>" |
|
|
|
+ "<p><strong>驳回节点:</strong>" + rejectNodeCode + "</p>" |
|
|
|
+ "<p><strong>审批意见:</strong>" + rejectComment + "</p>" |
|
|
|
+ "<br/><p><a style='color:#0f84b0;' href='" + APPLY_PAGE_URL + "'>前往工程试验申请管理页面</a></p>" |
|
|
|
+ "<br/><p style='color:#888;'>发送时间:" |
|
|
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) |
|
|
|
+ "</p></body></html>"; |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 经理层审批全部通过后(进入计划员排产节点时)通知试验负责人:其负责的试验申请单已审批通过 |
|
|
|
*/ |
|
|
|
|