ty
11 months ago
14 changed files with 187 additions and 40 deletions
@ -0,0 +1,31 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.enums; |
||||||
|
|
||||||
|
/** |
||||||
|
* 培训计划状态枚举类 |
||||||
|
* |
||||||
|
* @author liwen |
||||||
|
* @date 2023-12-27 |
||||||
|
*/ |
||||||
|
public enum TrainStatusEnum { |
||||||
|
|
||||||
|
WAITING("WAITING", "未开始"), |
||||||
|
UNFINISHED("UNFINISHED", "未完成"), |
||||||
|
FINISHED("FINISHED", "已完成"); |
||||||
|
|
||||||
|
private final String value; |
||||||
|
|
||||||
|
private final String desc; |
||||||
|
|
||||||
|
TrainStatusEnum(String value, String desc) { |
||||||
|
this.value = value; |
||||||
|
this.desc = desc; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDesc() { |
||||||
|
return desc; |
||||||
|
} |
||||||
|
} |
@ -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