7 changed files with 130 additions and 5 deletions
@ -0,0 +1,62 @@
|
||||
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.social.SocialClientApi; |
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
||||
import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoRespVO; |
||||
import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.redisson.executor.TasksService; |
||||
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 TaskSendStartMessageJob implements JobHandler { |
||||
|
||||
@Resource |
||||
TaskInfoService taskInfoService; |
||||
|
||||
@Resource |
||||
SocialClientApi socialClientApi; |
||||
|
||||
@Override |
||||
public String execute(String param) throws Exception { |
||||
//要发送的信息
|
||||
List<TaskInfoRespVO> beforeTaskInfoList = taskInfoService.getBeforeTaskInfoList(); |
||||
beforeTaskInfoList.forEach(beforeTaskInfo -> { |
||||
beforeTaskInfo.getEnterpriseIdeTasks().forEach(x ->{ |
||||
if(x.getUserId()!= null){ |
||||
try { |
||||
//发送消息);
|
||||
SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); |
||||
reqDTO.setUserType(1); |
||||
reqDTO.setTemplateTitle("环保任务通知"); |
||||
reqDTO.setPage("pages/index"); |
||||
reqDTO.setUserId(x.getUserId()); |
||||
Map<String, String> message = new HashMap<>(); |
||||
message.put("thing2", beforeTaskInfo.getTitle()); |
||||
message.put("time3", DateUtil.format(beforeTaskInfo.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
||||
message.put("thing4", beforeTaskInfo.getDescription()); |
||||
message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
||||
reqDTO.setMessages(message); |
||||
socialClientApi.sendWxaSubscribeMessage(reqDTO); |
||||
} |
||||
catch (Exception e){ |
||||
log.error("任务发送通知错误:",e.toString()); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
}); |
||||
}); |
||||
return "发送消息任务数量:"+ beforeTaskInfoList.size(); |
||||
} |
||||
} |
Loading…
Reference in new issue