企业证件管理 到期前十五天预警、已经到期证件提醒
This commit is contained in:
parent
e4ab8609c0
commit
7fdf6100bb
|
@ -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<EnterpriseInformationDO> wrapper = new LambdaQueryWrapper<EnterpriseInformationDO>()
|
||||
.eq(EnterpriseInformationDO::getId, certificate.getInformationId());
|
||||
EnterpriseInformationDO enterpriseInformation = enterpriseInformationMapper.selectOne(wrapper);
|
||||
//证书已经过期
|
||||
if(expiryDate.isBefore(today)){
|
||||
Map<String, Object> 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<String, Object> templateParams = new HashMap<>();
|
||||
|
||||
LambdaQueryWrapper<EnterpriseInformationDO> wrapper = new LambdaQueryWrapper<EnterpriseInformationDO>()
|
||||
.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<String, Object> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CredentialManagementDO> credentialManagementDOS = credentialManagementMapper.selectList();
|
||||
List<CredentialManagementDO> list = credentialManagementDOS.stream().filter(data -> data.getStatus() != null &&
|
||||
data.getStatus().equals("已通过审核")).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
//public List<Map<String, Object>> getAllCertificates() {
|
||||
|
|
Loading…
Reference in New Issue