¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.job; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.modules.eam.entity.Equipment; |
| | | import org.jeecg.modules.eam.entity.EquipmentReportRepair; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEquipmentReportRepairService; |
| | | import org.jeecg.modules.eam.service.IPredictiveWorkPlanWarnService; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.quartz.Job; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æè½é |
| | | */ |
| | | public class RepairOrderWarning implements Job { |
| | | @Resource |
| | | private IEquipmentReportRepairService equipmentReportRepairService; |
| | | |
| | | @Resource |
| | | private IEamEquipmentService equipmentService; |
| | | |
| | | @Resource |
| | | private ISysBaseAPI sysBaseAPI; |
| | | |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | LocalDateTime dateBefore3Days = currentDateTime.minusDays(3); |
| | | LocalDateTime dateBefore1Days = currentDateTime.minusDays(1); |
| | | Date result3 = Date.from(dateBefore3Days.atZone(ZoneId.systemDefault()).toInstant()); |
| | | Date result1= Date.from(dateBefore1Days.atZone(ZoneId.systemDefault()).toInstant()); |
| | | List<EquipmentReportRepair> equipmentReportRepairs1 = equipmentReportRepairService.list(new QueryWrapper<EquipmentReportRepair>().lt("fault_time",result1).eq("status","1")); |
| | | List<EquipmentReportRepair> equipmentReportRepairs3 = equipmentReportRepairService.list(new QueryWrapper<EquipmentReportRepair>().lt("fault_time",result3).eq("status","1")); |
| | | for(EquipmentReportRepair equipmentReportRepair1:equipmentReportRepairs1){ |
| | | Equipment equipment1 = equipmentService.getById(equipmentReportRepair1.getEquipmentId()); |
| | | if(StringUtils.isNotBlank(equipment1.getSpecificEquipment())){ |
| | | String teamId = equipment1.getTeamId(); |
| | | if(StringUtils.isNotBlank(teamId)){ |
| | | List<SysUser> sysUsers = sysUserService.list(new QueryWrapper<SysUser>() |
| | | .eq("team_id",teamId) |
| | | .eq("del_flag",0)); |
| | | for(SysUser user:sysUsers){ |
| | | String msg = "ç»ä¸ç¼å·ä¸ºã"+equipment1.getNum()+"ãç设å¤å·²ç»è¶
è¿ä¸å¤©æªç»´ä¿®ï¼è¯·ç§»æ¥è³æ
éæ¥ä¿®æ¥ç"; |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle("æ
éæ¥ä¿®æé"); |
| | | messageDTO.setContent(msg); |
| | | messageDTO.setCategory("æ
éæ¥ä¿®æé"); |
| | | messageDTO.setFromUser("æ
éæ¥ä¿®æéå°å©æ"); |
| | | messageDTO.setToUser(user.getUsername()); |
| | | sysBaseAPI.sendSysAnnouncement(messageDTO); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | for(EquipmentReportRepair equipmentReportRepair3:equipmentReportRepairs3){ |
| | | Equipment equipment3 = equipmentService.getById(equipmentReportRepair3.getEquipmentId()); |
| | | if(StringUtils.isNotBlank(equipment3.getSpecificEquipment())){ |
| | | String teamId = equipment3.getTeamId(); |
| | | if(StringUtils.isNotBlank(teamId)){ |
| | | List<SysUser> sysUsers = sysUserService.list(new QueryWrapper<SysUser>() |
| | | .eq("team_id",teamId) |
| | | .eq("del_flag",0)); |
| | | for(SysUser user:sysUsers){ |
| | | String msg = "ç»ä¸ç¼å·ä¸ºã"+equipment3.getNum()+"ãç设å¤å·²ç»è¶
è¿ä¸å¤©æªç»´ä¿®ï¼è¯·ç§»æ¥è³æ
éæ¥ä¿®æ¥ç"; |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle("æ
éæ¥ä¿®æé"); |
| | | messageDTO.setContent(msg); |
| | | messageDTO.setCategory("æ
éæ¥ä¿®æé"); |
| | | messageDTO.setFromUser("æ
éæ¥ä¿®æéå°å©æ"); |
| | | messageDTO.setToUser(user.getUsername()); |
| | | sysBaseAPI.sendSysAnnouncement(messageDTO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |