From 7fdf6100bb4dd6e1c2ae5058e98cc10f78c56cd3 Mon Sep 17 00:00:00 2001 From: lc <15038716315@163.com> Date: Wed, 19 Jun 2024 11:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E8=AF=81=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E5=88=B0=E6=9C=9F=E5=89=8D=E5=8D=81=E4=BA=94?= =?UTF-8?q?=E5=A4=A9=E9=A2=84=E8=AD=A6=E3=80=81=E5=B7=B2=E7=BB=8F=E5=88=B0?= =?UTF-8?q?=E6=9C=9F=E8=AF=81=E4=BB=B6=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/credentialManagementJob.java | 52 +++++++++++++++---- .../CredentialManagementServiceImpl.java | 20 ++++--- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/dal/dataobject/job/credentialManagementJob.java b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/dal/dataobject/job/credentialManagementJob.java index f0abd99..d61cb67 100644 --- a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/dal/dataobject/job/credentialManagementJob.java +++ b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/dal/dataobject/job/credentialManagementJob.java @@ -1,16 +1,13 @@ package cn.iocoder.yudao.module.fta.dal.dataobject.job; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.module.fta.dal.dataobject.enterpriseinformation.CredentialManagementDO; import cn.iocoder.yudao.module.fta.dal.dataobject.enterpriseinformation.EnterpriseInformationDO; import cn.iocoder.yudao.module.fta.dal.mysql.enterpriseinformation.EnterpriseInformationMapper; import cn.iocoder.yudao.module.fta.service.enterpriseinformation.CredentialManagementService; -import cn.iocoder.yudao.module.fta.service.enterpriseinformation.EnterpriseInformationService; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -32,10 +29,11 @@ public class credentialManagementJob implements JobHandler { private NotifyMessageSendApi notifySendApi; @Resource private CredentialManagementService credentialManagementService; - + @Resource private EnterpriseInformationMapper enterpriseInformationMapper; /** + * 证件即将过期提醒 * 每天凌晨1点执行一次 */ public void checkCertificateExpiration() { @@ -45,18 +43,29 @@ public class credentialManagementJob implements JobHandler { //查询到到期时间 credentialManagementService.getAllCertificates().forEach(certificate -> { LocalDate expiryDate = certificate.getExpiryDate(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .eq(EnterpriseInformationDO::getId, certificate.getInformationId()); + EnterpriseInformationDO enterpriseInformation = enterpriseInformationMapper.selectOne(wrapper); + //证书已经过期 + if(expiryDate.isBefore(today)){ + Map templateParams = new HashMap<>(); + String templateCode = "fta_credential_management_overdue"; + templateParams.put("enterpriseName",certificate.getEnterpriseName()); + judgementCertificate(certificate, templateParams); + templateParams.put("expiryDate",certificate.getExpiryDate().toString()); + notifySendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO() + .setUserId(Long.parseLong(enterpriseInformation.getCreator())).setTemplateCode(templateCode).setTemplateParams(templateParams)); + } long daysUntilExpiration = ChronoUnit.DAYS.between(today, expiryDate); Map templateParams = new HashMap<>(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper() - .eq(EnterpriseInformationDO::getId, certificate.getInformationId()); - EnterpriseInformationDO enterpriseInformation = enterpriseInformationMapper.selectOne(wrapper); String templateCode = "fta_credential_management"; - templateParams.put("idType","安全证"); + templateParams.put("enterpriseName",certificate.getEnterpriseName()); + judgementCertificate(certificate, templateParams); // 如果到期时间和当前时间相差15天,则发送通知 - if (daysUntilExpiration == daysDifference) { + if (daysUntilExpiration <= daysDifference && today.isBefore(expiryDate)) { // 执行你的逻辑,例如发送通知 log.info("[checkCertificateExpiration][证书 {} 到期时间与当前时间相差 {} 天]", certificate.getCertificateNumber(), daysDifference); // 这里可以添加发送通知的逻辑 @@ -67,8 +76,31 @@ public class credentialManagementJob implements JobHandler { }); } + /** + *判断证件 + * @param certificate 证件信息 + * @param templateParams + */ + private static void judgementCertificate(CredentialManagementDO certificate, Map templateParams) { + switch (certificate.getIdType()){ + case 0: + templateParams.put("idType","安全员证"); + break; + case 1: + templateParams.put("idType","安全负责人证"); + break; + case 2: + templateParams.put("idType","危险品证"); + break; + default: + templateParams.put("idType","证件"); + break; + } + } + @Override public String execute(String param) throws Exception { + checkCertificateExpiration(); return null; } } diff --git a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/CredentialManagementServiceImpl.java b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/CredentialManagementServiceImpl.java index 817bc9c..bd6657a 100644 --- a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/CredentialManagementServiceImpl.java +++ b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/CredentialManagementServiceImpl.java @@ -1,25 +1,20 @@ package cn.iocoder.yudao.module.fta.service.enterpriseinformation; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.fta.controller.admin.enterpriseinformation.vo.CredentialManagementPageReqVO; import cn.iocoder.yudao.module.fta.controller.admin.enterpriseinformation.vo.CredentialManagementSaveReqVO; import cn.iocoder.yudao.module.fta.dal.dataobject.enterpriseinformation.CredentialManagementDO; import cn.iocoder.yudao.module.fta.dal.mysql.enterpriseinformation.CredentialManagementMapper; -import com.sun.deploy.security.CredentialInfo; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.HashMap; +import javax.annotation.Resource; import java.util.List; -import java.util.Map; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.fta.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.fta.enums.ErrorCodeConstants.CREDENTIAL_MANAGEMENT_NOT_EXISTS; /** * 企业证件 Service 实现类 @@ -80,7 +75,10 @@ public class CredentialManagementServiceImpl implements CredentialManagementServ /** * 1、查询出所有的CredentialManagementDO信息 */ - return credentialManagementMapper.selectList(); + List credentialManagementDOS = credentialManagementMapper.selectList(); + List list = credentialManagementDOS.stream().filter(data -> data.getStatus() != null && + data.getStatus().equals("已通过审核")).collect(Collectors.toList()); + return list; } //public List> getAllCertificates() { @@ -124,4 +122,4 @@ public class CredentialManagementServiceImpl implements CredentialManagementServ // CredentialInfo credentialInfo = new CredentialInfo(informationId, expiryDate); // certificates.add(credentialInfo); //} -} \ No newline at end of file +}