feat: 到期提醒丰富内容

This commit is contained in:
caiyuchao
2025-09-04 17:10:26 +08:00
parent a746d8503e
commit 20bb20b29b

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.agt.framework.common.pojo.CommonResult;
import org.agt.module.license.dal.dataobject.alert.AlertDO;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import org.agt.module.license.dal.dataobject.license.LicenseDO;
@@ -17,10 +18,13 @@ import org.agt.module.system.api.mail.MailSendApi;
import org.agt.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
import org.agt.module.system.api.notify.NotifyMessageSendApi;
import org.agt.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import org.agt.module.system.api.user.AdminUserApi;
import org.agt.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
@@ -60,6 +64,9 @@ public class LicenseTask {
@Resource
private NotifyMessageSendApi notifySendApi;
@Resource
private AdminUserApi adminUserApi;
@Scheduled(cron = "*/5 * * * * ?")
public void task() {
licenseService.genLicenseTask();
@@ -104,6 +111,20 @@ public class LicenseTask {
templateParams.put("sn", licenseDO.getSerialNo());
templateParams.put("days", day);
try {
templateParams.put("expiryDate", licenseDO.getExpiryDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
if (projectDO.getBusinessOwner() != null) {
CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(projectDO.getBusinessOwner());
templateParams.put("businessOwner", user.getData().getNickname());
}
if (projectDO.getTechnicalOwnerA() != null) {
CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(projectDO.getTechnicalOwnerA());
templateParams.put("technicalOwnerA", user.getData().getNickname());
}
} catch (Exception e) {
log.error("到期提醒邮件的到期时间和负责人查询错误", e);
}
templateParams.put("customer", customerDO.getName());
templateParams.put("project", projectDO.getName());
log.info("已发送到期提醒邮件:{}", licenseDO.getSerialNo());