Преглед на файлове

1、解决高速飞手任务在智飞平台上传文件和视频时报系统访问异常

2、优化定时任务代码
pull/379/head
suqin преди 10 месеца
родител
ревизия
cd5a1501a7
променени са 2 файла, в които са добавени 16 реда и са изтрити 20 реда
  1. +12
    -19
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/task/InspectionTimeOutTask.java
  2. +4
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 12
- 19
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/task/InspectionTimeOutTask.java Целия файл

@@ -25,7 +25,6 @@ import java.util.*;
@Component
public class InspectionTimeOutTask {


@Resource
private InspectionMapper inspectionMapper;

@@ -35,15 +34,11 @@ public class InspectionTimeOutTask {
@XxlJob("inspectionTimeOutTaskHandler")
public void inspectionExecuteHandler() {
log.info("=================================开始执行超时任务定时器任务调度=================================");

Date startTime = null; //当前时间
String taskBeginTime = null; //一小时之前
String msg = "";

Date startTime;
String taskBeginTime = null;
try {
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
startTime = new Date(System.currentTimeMillis());
// 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);
@@ -52,38 +47,36 @@ public class InspectionTimeOutTask {
//以现在时间为节点 查询一小时之前的所有机场里的状态为 准备中,飞行中的已开始执行的任务
List<Inspection> newInspections = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.in(Inspection::getStatus, InspectionStatusEnum.PREPARING.getCode(), InspectionStatusEnum.IN_FLIGHT.getCode())
.eq(Inspection::getInspectionType, AirPortTaskStatusEnum.FLIGHT.getCode()) //机场巡逻
.eq(Inspection::getExecutionStatus, InspectionExecutionStatusEnum.EXECUTED.getCode()) //已开始执行的任务
.le(Inspection::getExecutionStartTime, taskBeginTime) //一个小时之前就开始
.eq(Inspection::getInspectionType, AirPortTaskStatusEnum.FLIGHT.getCode())
.eq(Inspection::getExecutionStatus, InspectionExecutionStatusEnum.EXECUTED.getCode())
.le(Inspection::getExecutionStartTime, taskBeginTime)
.eq(BaseEntity::getMark, MarkEnum.VALID.getCode()));
log.info("执行定时执行飞行任务:机场任务数" + newInspections.size());

for (Inspection inspection : newInspections) {
log.info("修改任务状态为失败" + inspection.getStatus());
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
inspectionMapper.updateById(inspection);
log.info("修改结果: 任务状态为" + inspection.getStatus());
msg = "任务执行超过一小时 默认失败";
log.info("超时任务保存到历史记录表中");
this.insertInspectionHistory(inspection,msg);
this.insertInspectionHistory(inspection);
}
log.info("=================================结束执行超时任务定时器任务调度=================================");

}

/**
* 保存到历史记录表
* @param inspection
* @param msg
*/
private void insertInspectionHistory(Inspection inspection, String msg) {
private void insertInspectionHistory(Inspection inspection) {
InspectionHistory inspectionHistory = new InspectionHistory();
inspectionHistory.setTenantId(inspection.getTenantId());
inspectionHistory.setInspectionId(inspection.getId());
inspectionHistory.setHistoryName(msg);
inspectionHistory.setHistoryName("任务执行超过一小时 默认失败");
inspectionHistory.setCreateUser(inspection.getCreateUser());
inspectionHistory.setCreateTime(DateUtils.now());
inspectionHistoryMapper.insert(inspectionHistory);
Integer count = inspectionHistoryMapper.insert(inspectionHistory);
if (count <= 0) {
log.info("超时任务保存到历史记录表中失败,inspectionId:{}", inspection.getId());
}
}

}

+ 4
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml Целия файл

@@ -328,15 +328,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="droneId != null">
drone_id = #{droneId},
</if>
<if test="airportName != null">
<!-- <if test="airportName != null">
airport_name = #{airportName},
</if>
-->
<if test="inspectionLine != null">
inspection_line = #{inspectionLine},
</if>
<!--
<if test="inspectionLineName != null">
inspection_line_name = #{inspectionLineName},
</if>
-->
<if test="progressbar != null">
progressbar = #{progressbar},
</if>

Loading…
Отказ
Запис