| | |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.project.system.service.ISysNoticeService; |
| | | import com.ruoyi.project.system.domain.SysNotice; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.DayOfWeek; |
| | |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | @Autowired |
| | | private ISysNoticeService sysNoticeService; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | |
| | | // 2. 创建并保存巡检任务记录 - 这就是您提供的代码应该放的位置 |
| | | DeviceMaintenance deviceMaintenance = createInspectionTask(timingTask); |
| | | deviceMaintenanceService.save(deviceMaintenance); |
| | | |
| | | // 给执行人发送系统通知 |
| | | if (timingTask.getExecutorId() != null) { |
| | | SysNotice notice = new SysNotice(); |
| | | notice.setNoticeTitle("新保养任务提醒"); |
| | | notice.setNoticeType("1"); // 1 通知 |
| | | notice.setNoticeContent("您有一个新的设备保养任务需要执行,设备名称:" + timingTask.getTaskName()); |
| | | notice.setStatus("0"); // 正常 |
| | | notice.setConsigneeId(timingTask.getExecutorId()); |
| | | notice.setSenderId(0L); // 0代表系统发送 |
| | | notice.setTenantId(timingTask.getTenantId()); |
| | | sysNoticeService.insertNotice(notice); |
| | | } |
| | | |
| | | // 3. 更新定时任务的执行时间 |
| | | if (!tasks.isEmpty()) { |
| | |
| | | inspectionTask.setDeviceLedgerId(timingTask.getTaskId()); |
| | | inspectionTask.setMaintenancePlanTime(LocalDateTime.now()); |
| | | inspectionTask.setMaintenanceActuallyName(timingTask.getMaintenancePerson()); |
| | | inspectionTask.setExecutorId(timingTask.getExecutorId()); |
| | | inspectionTask.setMaintenanceType(timingTask.getMaintenanceType()); |
| | | inspectionTask.setFrequencyType(timingTask.getFrequencyType()); |
| | | inspectionTask.setFrequencyDetail(timingTask.getFrequencyDetail()); |
| | | inspectionTask.setTenantId(timingTask.getTenantId()); |