Browse Source

接口: 任务·已取消

pull/356/head
suqin 9 months ago
parent
commit
0cc929530c
9 changed files with 128 additions and 1 deletions
  1. +11
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/EditInspectionCodeEnum.java
  3. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionMapper.java
  4. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/cycle/AddInspectionCycleRequest.java
  5. +35
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/QueryInspectionPageListRequest.java
  6. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java
  7. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java
  8. +39
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java
  9. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 11
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java View File

@@ -188,4 +188,15 @@ public class InspectionController {
return iInspectionService.updateTaskByCode(request);
}

/**
* 取消任务
*
* @param id
* @return
*/
@PostMapping("/cancelTask/{id}")
public JsonResult cancelTask(@PathVariable("id") String id) {
log.info("进入取消任务接口, id={}", id);
return iInspectionService.cancelTask(id);
}
}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/EditInspectionCodeEnum.java View File

@@ -22,6 +22,8 @@ public enum EditInspectionCodeEnum {
INSPECTION_IS_NOT_EXIST(1230308, "任务不存在"),
INSPECTION_IS_NOT_WAIT_FLIGHT(1230309, "非待飞行任务,不可修改"),
INSPECTION_IS_EXECUTED(1230310, "任务已执行,不可修改"),
INSPECTION_IS_NOT_TO_BE_EXECUTED(1230314, "任务不是待执行状态,不可取消"),
INSPECTION_CANCEL_FAILED(1230315, "任务取消失败"),
ROAD_IS_NOT_EXIST(1230311, "公路不存在"),
SECTION_IS_NOT_EXIST(1230312, "路段不存在"),
NON_DEPT_ADMIN_NOT_EDIT(1230313, "非本部门管理员不能修改");

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionMapper.java View File

@@ -77,4 +77,6 @@ public interface InspectionMapper extends BaseMapper<Inspection> {

Inspection selectInspectionByAirport(@Param("id") Integer id);

int cancelTask(Inspection inspection);

}

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/cycle/AddInspectionCycleRequest.java View File

@@ -50,11 +50,21 @@ public class AddInspectionCycleRequest {
*/
private Integer airportId;

/**
* 巡检机场名称
*/
private Integer airportName;

/**
* 航线id
*/
private Integer airportLineId;

/**
* 航线名称
*/
private Integer inspectionLineName;

/**
* 航线长度
*/

+ 35
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/QueryInspectionPageListRequest.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.admin.request.inspection;

import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.List;

@@ -36,7 +37,7 @@ public class QueryInspectionPageListRequest extends BaseQuery {
private Integer inspectionLine;

/**
* 巡检任务类型: 1 临时巡检 2 应急任务
* 巡检任务类型: 0:周期巡检 1: 临时巡检 2: 应急巡检
*/
private Integer type;

@@ -65,4 +66,37 @@ public class QueryInspectionPageListRequest extends BaseQuery {
*/
private String tenantId;

/**
* 周期性任务Id
*/
private String inspectionCycleId;

/**
* 计划巡检开始时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private String inspectionTimeBegin;

/**
* 计划巡检截止时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private String inspectionTimeEnd;

/**
* 单次任务标识(0:否、1:是),单次任务只查询“待执行”状态的单次任务
*/
private Integer singleTask;

/**
* 实际巡检开始时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private String executionTimeBegin;

/**
* 实际巡检截止时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private String executionTimeEnd;
}

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java View File

@@ -152,4 +152,11 @@ public interface IInspectionService {
* @return
*/
JsonResult videoByAirportId(Integer id);

/**
* 根据任务id,若状态为“待执行”则可取消此任务
* @param inspectionId
* @return
*/
JsonResult cancelTask(String inspectionId);
}

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java View File

@@ -299,4 +299,14 @@ public class InspectionServiceImpl implements IInspectionService {
return queryVideoService.videoByAirportId(id);
}

/**
* 根据任务id,若状态为“待执行”则可取消此任务
* @param inspectionId
* @return
*/
@Override
public JsonResult cancelTask(String inspectionId) {
return updateInspectionService.cancelTask(inspectionId);
}

}

+ 39
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java View File

@@ -183,4 +183,43 @@ public class UpdateInspectionService {
}
return JsonResult.success();
}

/**
* 根据任务id,若状态为“待执行”则可取消此任务
*
* @param inspectionId
* @return
*/
public JsonResult cancelTask(String inspectionId) {
log.info("进入取消任务业务接口");
if (ObjectUtil.isEmpty(inspectionId)) {
log.info("取消任务业务接口:校验失败:{}", "任务ID为空");
return JsonResult.error(EditInspectionCodeEnum.ID_IS_NULL.getCode(), EditInspectionCodeEnum.ID_IS_NULL.getMsg());
}
// 查询巡检任务当前信息
Inspection inspection = inspectionMapper.selectById(inspectionId);
if (ObjectUtil.isNull(inspection)) {
log.info("取消任务业务接口:校验失败:{}", "任务不存在");
return JsonResult.error(EditInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), EditInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
// 任务不是“待执行”状态,不可取消
if (InspectionStatusEnum.WAIT_FLIGHT.getCode() != inspection.getStatus()) {
log.info("取消任务业务接口:取消任务失败:{}", "任务不是待执行状态,不可取消");
return JsonResult.error(EditInspectionCodeEnum.INSPECTION_IS_NOT_TO_BE_EXECUTED.getCode(), EditInspectionCodeEnum.INSPECTION_IS_NOT_TO_BE_EXECUTED.getMsg());
}
// 任务为“待执行”状态,可取消
User user = CurrentUserUtil.getUserInfo();
inspection.setExecutionStartTime(DateUtils.now());
inspection.setUpdateUser(user.getId());
inspection.setUpdateTime(DateUtils.now());
int rowId = inspectionMapper.cancelTask(inspection);
log.info("取消任务业务接口, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
log.info("取消任务业务接口:取消任务失败");
return JsonResult.error(EditInspectionCodeEnum.INSPECTION_CANCEL_FAILED.getCode(), EditInspectionCodeEnum.INSPECTION_CANCEL_FAILED.getMsg());
}
log.info("取消任务业务接口:取消任务成功:{}", inspection);
return JsonResult.success();
}

}

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml View File

@@ -378,4 +378,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from th_inspection where id = #{id}
</delete>

<update id="cancelTask" parameterType="com.tuoheng.admin.entity.Inspection">
update th_inspection
set status = 16,
update_user = #{updateUser},
update_time = #{updateTime},
execution_start_time = #{executionStartTime}
where status = 5
and mark = 1
and tenant_id = #{tenantId}
and id = #{id}
</update>

</mapper>

Loading…
Cancel
Save