Переглянути джерело

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

pull/380/head
suqin 10 місяці тому
джерело
коміт
6ff0fa82e8
3 змінених файлів з 42 додано та 15 видалено
  1. +5
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java
  2. +6
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java
  3. +31
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/task/InspectionTimeOutTask.java

+ 5
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java Переглянути файл

@@ -86,11 +86,11 @@ public class DeleteInspectionService {
}

// 判断是否有删除权限
result = this.checkPermission(tenantId, userId, inspection);
if (0 != result.getCode()) {
log.info("删除任务接口:没有权限,{}", result.getMsg());
return result;
}
// result = this.checkPermission(tenantId, userId, inspection);
// if (0 != result.getCode()) {
// log.info("删除任务接口:没有权限,{}", result.getMsg());
// return result;
// }

// 设置该删除务的操作用户,时间
inspection.setUpdateUser(userId);

+ 6
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java Переглянути файл

@@ -68,12 +68,12 @@ public class UpdateInspectionService {
log.info("修改任务业务接口:校验失败:{}", result.getMsg());
return result;
}
Inspection inspectionOld = (Inspection) result.getData();
result = checkPermissions(user, inspectionOld.getCreateUser());
if (0 != result.getCode()) {
log.info("修改任务业务接口:校验权限失败:{}", result.getMsg());
return result;
}
// Inspection inspectionOld = (Inspection) result.getData();
// result = checkPermissions(user, inspectionOld.getCreateUser());
// if (0 != result.getCode()) {
// log.info("修改任务业务接口:校验权限失败:{}", result.getMsg());
// return result;
// }

Inspection inspection = InspectionConverMapper.INSTANCE.fromEditInspectionRequestToInspection(editInspectionRequest);
inspection.setUpdateUser(user.getId());

+ 31
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/task/InspectionTimeOutTask.java Переглянути файл

@@ -2,13 +2,19 @@ package com.tuoheng.admin.task;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionHistory;
import com.tuoheng.admin.enums.AirPortTaskStatusEnum;
import com.tuoheng.admin.enums.InspectionExecutionStatusEnum;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
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 net.sf.saxon.functions.Current;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
@@ -22,11 +28,16 @@ public class InspectionTimeOutTask {
@Resource
private InspectionMapper inspectionMapper;

@Resource
private InspectionHistoryMapper inspectionHistoryMapper;

@XxlJob("inspectionTimeOutTaskHandler")
public void inspectionExecuteHandler() {

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

try {
startTime = DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.now()), DateUtils.YYYY_MM_DD);
taskBeginTime = DateUtils.addDateTimeToStr(startTime, 0, -1, 0, 0);
@@ -37,16 +48,32 @@ public class InspectionTimeOutTask {
//以现在时间为节点 查询一小时之前的所有机场里的状态为 准备中,飞行中的已开始执行的任务
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) //已开始执行的任务
.eq(Inspection::getInspectionType, AirPortTaskStatusEnum.FLIGHT.getCode()) //机场巡逻
.eq(Inspection::getExecutionStatus, InspectionExecutionStatusEnum.EXECUTED.getCode()) //已开始执行的任务
.le(Inspection::getExecutionStartTime, taskBeginTime) //一个小时之前就开始
.eq(BaseEntity::getMark, MarkEnum.VALID.getCode()));

for (Inspection inspection : newInspections) {
inspection.setStatus(7);
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
inspectionMapper.updateById(inspection);
msg = "任务执行超过一小时 默认失败";
this.insertInspectionHistory(inspection,msg);
}
}


/**
* 保存到历史记录表
* @param inspection
* @param msg
*/
private void insertInspectionHistory(Inspection inspection, String msg) {
InspectionHistory inspectionHistory = new InspectionHistory();
inspectionHistory.setTenantId(inspection.getTenantId());
inspectionHistory.setInspectionId(inspection.getId());
inspectionHistory.setHistoryName(msg);
inspectionHistory.setCreateUser(inspection.getCreateUser());
inspectionHistory.setCreateTime(DateUtils.now());
inspectionHistoryMapper.insert(inspectionHistory);
}

}

Завантаження…
Відмінити
Зберегти