|
|
@@ -0,0 +1,52 @@ |
|
|
|
package com.tuoheng.admin.task; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.tuoheng.admin.entity.Inspection; |
|
|
|
import com.tuoheng.admin.enums.InspectionStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.common.core.common.BaseEntity; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
public class InspectionTimeOutTask { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
private InspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
@XxlJob("inspectionTimeOutTaskHandler") |
|
|
|
public void inspectionExecuteHandler() { |
|
|
|
|
|
|
|
Date startTime = null; //当前时间 |
|
|
|
String taskBeginTime = null; //一小时之前 |
|
|
|
try { |
|
|
|
startTime = DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.now()), DateUtils.YYYY_MM_DD); |
|
|
|
taskBeginTime = DateUtils.addDateTimeToStr(startTime, 0, -1, 0, 0); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("获取开始时间异常:{}", e); |
|
|
|
} |
|
|
|
|
|
|
|
//以现在时间为节点 查询一小时之前的所有机场里的状态为 准备中,飞行中的已开始执行的任务 |
|
|
|
List<Inspection> newInspections = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() |
|
|
|
.in(Inspection::getStatus, InspectionStatusEnum.PREPARING.getCode(), InspectionStatusEnum.IN_FLIGHT.getCode()) |
|
|
|
.eq(Inspection::getInspectionType, 2) //机场巡逻 |
|
|
|
.eq(Inspection::getExecutionStatus, 2) //已开始执行的任务 |
|
|
|
.le(Inspection::getExecutionStartTime, taskBeginTime) //一个小时之前就开始 |
|
|
|
.eq(BaseEntity::getMark, MarkEnum.VALID.getCode())); |
|
|
|
|
|
|
|
for (Inspection inspection : newInspections) { |
|
|
|
inspection.setStatus(7); |
|
|
|
inspectionMapper.updateById(inspection); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |