9 changed files with 123 additions and 30 deletions
			
			
		| @ -0,0 +1,43 @@ | |||||||
|  | package com.hnac.hzims.safeproduct.jobs; | ||||||
|  | 
 | ||||||
|  | import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; | ||||||
|  | import com.hnac.hzims.safeproduct.enums.TrainStatusEnum; | ||||||
|  | import com.hnac.hzims.safeproduct.service.ITrainPlanService; | ||||||
|  | import com.xxl.job.core.biz.model.ReturnT; | ||||||
|  | import com.xxl.job.core.handler.annotation.XxlJob; | ||||||
|  | import org.springblade.core.tool.utils.DateUtil; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.stereotype.Component; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 演练模块定时任务 | ||||||
|  |  * | ||||||
|  |  * @author liwen | ||||||
|  |  * @date 2023-12-27 | ||||||
|  |  */ | ||||||
|  | @Component | ||||||
|  | public class TrainJob { | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     ITrainPlanService trainPlanService; | ||||||
|  | 
 | ||||||
|  |     @XxlJob("autoChangeTrainPlanStatus") | ||||||
|  |     public ReturnT<String> autoChangeTrainPlanStatus(String param) { | ||||||
|  |         // 获取时间范围
 | ||||||
|  |         Date current = DateUtil.now(); | ||||||
|  |         Date before = DateUtil.minusDays(current, 1); | ||||||
|  |         String today = DateUtil.format(current, "yyyy-mm-dd hh:MM:ss"); | ||||||
|  |         String yesterday = DateUtil.format(before, "yyyy-mm-dd hh:MM:ss"); | ||||||
|  |         // 查询前一天的超时未完成培训计划
 | ||||||
|  |         List<TrainPlanEntity> list = trainPlanService.getWaitingTrainPlanInTimeRange(yesterday, today); | ||||||
|  |         list.forEach(x -> { | ||||||
|  |             x.setTrainStatus(TrainStatusEnum.UNFINISHED.getValue()); | ||||||
|  |         }); | ||||||
|  |         // 将状态置为未完成
 | ||||||
|  |         boolean flag = trainPlanService.updateBatchById(list); | ||||||
|  |         return flag ? ReturnT.SUCCESS : ReturnT.FAIL; | ||||||
|  |     } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue