| package com.matrix.system.job; | 
|   | 
| import com.matrix.component.rabbitmq.RabiitMqTemplate; | 
| import com.matrix.core.tools.LogUtil; | 
| import com.matrix.system.hive.bean.SysProjServices; | 
| import com.matrix.system.hive.dao.SysProjServicesDao; | 
| import com.matrix.system.hive.plugin.util.CollectionUtils; | 
| import com.matrix.system.shopXcx.mqTask.MQTaskRouting; | 
| import com.matrix.system.wechart.templateMsg.UniformMsgParam; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.beans.factory.annotation.Value; | 
| import org.springframework.scheduling.annotation.Scheduled; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.List; | 
| import java.util.stream.Collectors; | 
|   | 
| /** | 
|  * 预约服务到时提醒 | 
|  * @author 姜友瑶 | 
|  */ | 
| @Component | 
| public class ServiceOvertimeNoticeJob { | 
|   | 
|     @Autowired | 
|     private SysProjServicesDao projServicesDao; | 
|   | 
|     @Value("${evn}") | 
|     private  String evn; | 
|   | 
|     @Autowired | 
|     private RabiitMqTemplate rabiitMqTemplate; | 
|   | 
|     /** | 
|      * 每分钟执行一次 | 
|      */ | 
|     @Scheduled(cron = "0/30 * * * * ?") | 
|     public void serviceOvertimeNotice() { | 
|   | 
|         List<SysProjServices> needNoticeService=projServicesDao.selectNeedNoticeService(); | 
|         if(CollectionUtils.isNotEmpty(needNoticeService)){ | 
|             LogUtil.debug("执行服务单预约到时提醒任务,本次通知对象"+ needNoticeService.stream().map(SysProjServices::getVipName).collect(Collectors.joining(","))); | 
|             for(SysProjServices projServices : needNoticeService){ | 
|                 //发送微信公众号提醒 | 
|                 UniformMsgParam uniformMsgParam=new UniformMsgParam(projServices.getCompanyId(),UniformMsgParam.GZH_YYDS); | 
|                 uniformMsgParam.put("serviceId",projServices.getId()); | 
|                 rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); | 
|             } | 
|             List<Long> noticedIds = needNoticeService.stream().map(SysProjServices::getId).collect(Collectors.toList()); | 
|             projServicesDao.updateNoticeTimes(noticedIds); | 
|         }else{ | 
|             LogUtil.debug("暂无需要提醒的服务单"); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
| } |