|
|
|
@ -3,12 +3,16 @@ package cn.iocoder.yudao.module.system.job;
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
|
|
|
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.social.SocialClientApi; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.QualificationExpiredVO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.inspectionslog.InspectionsLogDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; |
|
|
|
|
import cn.iocoder.yudao.module.system.service.inspectionslog.InspectionsLogService; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -16,56 +20,56 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
|
@Slf4j |
|
|
|
|
public class QualificationTimeOutSendStartMessageJob implements JobHandler { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
InspectionsLogService inspectionsLogService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
SocialClientApi socialClientApi; |
|
|
|
|
@Resource |
|
|
|
|
EnterpriseInspectionsMapper enterpriseInspectionsMapper; |
|
|
|
|
EnterpriseQualificationMapper enterpriseQualificationMapper; |
|
|
|
|
@Resource |
|
|
|
|
EnterpriseService enterpriseService; |
|
|
|
|
NotifyMessageSendApi notifyMessageSendApi; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String execute(String param) throws Exception { |
|
|
|
|
//要发送的信息
|
|
|
|
|
|
|
|
|
|
final Long id = Long.valueOf(param); |
|
|
|
|
final InspectionsLogDO inspectionsLog = inspectionsLogService.getInspectionsLog(id); |
|
|
|
|
if (inspectionsLog != null && inspectionsLog.getCreator() != null) { |
|
|
|
|
|
|
|
|
|
final EnterpriseInspectionsDO enterpriseInspectionsDO = enterpriseInspectionsMapper.selectById(id); |
|
|
|
|
if (enterpriseInspectionsDO != null) { |
|
|
|
|
final EnterpriseDO enterprise = enterpriseService.getEnterprise(enterpriseInspectionsDO.getEnterpriseId()); |
|
|
|
|
final List<QualificationExpiredVO> qualificationExpiredVOS = enterpriseQualificationMapper.expiredList(); |
|
|
|
|
if (qualificationExpiredVOS != null && qualificationExpiredVOS.size() > 0) { |
|
|
|
|
|
|
|
|
|
qualificationExpiredVOS.forEach(item->{ |
|
|
|
|
try { |
|
|
|
|
Long userId = Long.valueOf(inspectionsLog.getCreator()); |
|
|
|
|
//发送消息);
|
|
|
|
|
//发送消息
|
|
|
|
|
SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); |
|
|
|
|
reqDTO.setUserType(1); |
|
|
|
|
reqDTO.setTemplateTitle("环保任务通知"); |
|
|
|
|
reqDTO.setPage("sub/task/detail?id="+inspectionsLog.getInspectionsId()); |
|
|
|
|
reqDTO.setUserId(userId); |
|
|
|
|
reqDTO.setTemplateTitle("认证到期提醒"); |
|
|
|
|
reqDTO.setPage("sub/enterprise/detail?id="+item.getEnterpriseId()); |
|
|
|
|
reqDTO.setUserId(item.getUserId()); |
|
|
|
|
Map<String, String> message = new HashMap<>(); |
|
|
|
|
message.put("thing2", enterprise.getEnterprisesName()); |
|
|
|
|
message.put("time3", DateUtil.format(inspectionsLog.getCorrectionTime(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
|
|
|
|
// message.put("thing4", beforeTaskInfo.getDescription());
|
|
|
|
|
// message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY));
|
|
|
|
|
message.put("phrase1", item.getEnterpriseName()); |
|
|
|
|
message.put("data2", DateUtil.format(item.getExpiryDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
|
|
|
|
|
|
|
|
|
reqDTO.setMessages(message); |
|
|
|
|
socialClientApi.sendWxaSubscribeMessage(reqDTO); |
|
|
|
|
|
|
|
|
|
//保存站内信
|
|
|
|
|
NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO(); |
|
|
|
|
notifyMessage.setUserId(Long.valueOf(item.getUserId())); |
|
|
|
|
notifyMessage.setTemplateCode("qualification_expiry_date"); |
|
|
|
|
Map<String, Object> templateParams = new HashMap<>(); |
|
|
|
|
templateParams.put("title", item.getEnterpriseName()); |
|
|
|
|
templateParams.put("expiryDate", item.getExpiryDate()); |
|
|
|
|
notifyMessage.setTemplateParams(templateParams); |
|
|
|
|
notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); |
|
|
|
|
} |
|
|
|
|
catch (Exception e){ |
|
|
|
|
log.error("任务发送通知错误:",e.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return "发送整个信息成功"; |
|
|
|
|