@@ -43,7 +43,7 @@ public class EditInspectionRequest { | |||
private Integer inspectionLine; | |||
/** | |||
* 巡检任务类型: 1 临时巡检(目前只有该一种类型) | |||
* 巡检任务类型: 0周期任务 1 单次任务 | |||
*/ | |||
private Integer type; | |||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.InspectionTaskTypeEnum; | |||
import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.code.inspection.ResubmitInspectionCodeEnum; | |||
@@ -201,6 +202,7 @@ public class ResubmitInspectionService { | |||
String code = DateUtils.generateCode("GSDC"); | |||
inspection.setCode(code); | |||
inspection.setId(""); | |||
inspection.setType(InspectionTaskTypeEnum.TEMPORARY_INSPECTION.getCode()); // 更改为“单次任务”类型 | |||
inspection.setTenantId(tenantId); | |||
inspection.setDeptId(dept.getId()); | |||
inspection.setCreateUser(user.getId()); |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.service.report.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.conver.InspectionFileConverMapper; | |||
@@ -10,7 +11,9 @@ import com.tuoheng.admin.enums.InspectionFileStatusEnum; | |||
import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
import com.tuoheng.admin.enums.code.report.QueryInspectionReportCodeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionFileHandleReportVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionFileReportVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionReportVo; | |||
@@ -58,6 +61,12 @@ public class QueryInspectionHandleReportService { | |||
@Autowired | |||
private InspectionFileHandleMapper inspectionFileHandleMapper; | |||
@Autowired | |||
private AirportService airportService; | |||
@Autowired | |||
private RoadInformationMapper roadInformationMapper; | |||
public JsonResult getInspectionHandleReport(String id) { | |||
log.info("进入查看巡检处理报告业务"); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
@@ -149,13 +158,46 @@ public class QueryInspectionHandleReportService { | |||
inspectionReportVo.setInspectionResultVoList(inspectionResultVoList); | |||
inspectionReportVo.setInspectionFileReportVoList(inspectionFileHandleVoList); | |||
// 机场任务没有设备名称,暂定使用机场名称作为设备名称 | |||
if (InspectionTypeEnum.AIRPORT.getCode() == report.getInspectionType()) { | |||
inspectionReportVo.setEquipmentName(report.getAirportName()); | |||
//设备名称 机场任务没有设备名称,暂定使用机场名称作为设备名称 | |||
AirportInfoVo airport = this.getAirport(report); | |||
RoadInformation road = this.getRoad(report); | |||
if (InspectionTypeEnum.AIRPORT.getCode() == report.getInspectionType() && ObjectUtil.isNotEmpty(airport)) { | |||
inspectionReportVo.setEquipmentName(airport.getName()); | |||
inspectionReportVo.setAirportName(airport.getName()); | |||
inspectionReportVo.setRoadName(road.getName()); | |||
} | |||
return inspectionReportVo; | |||
} | |||
/** | |||
* 查询机场 | |||
* @param report | |||
* @return | |||
*/ | |||
private AirportInfoVo getAirport(Report report) { | |||
String airportIds = String.valueOf(report.getAirportId()); | |||
List<AirportInfoVo> airportInfoVoList = airportService.getAirportInfoList(airportIds); | |||
if (CollectionUtil.isEmpty(airportInfoVoList)) { | |||
return null; | |||
} | |||
return airportInfoVoList.get(0); | |||
} | |||
/** | |||
* 查询公路 | |||
* @param report | |||
* @return | |||
*/ | |||
private RoadInformation getRoad(Report report) { | |||
String roadId = report.getRoadId(); | |||
RoadInformation roadInformation = roadInformationMapper.selectById(roadId); | |||
if (ObjectUtil.isEmpty(roadInformation)) { | |||
return null; | |||
} | |||
return roadInformation; | |||
} | |||
private List<InspectionFileHandle> getInspectionFileHandleList(List<InspectionFile> inspectionFileList) { | |||
List<String> inspectionFileIdList = inspectionFileList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||
List<InspectionFileHandle> inspectionFileHandleList = null; |
@@ -1,18 +1,17 @@ | |||
package com.tuoheng.admin.service.report.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.conver.InspectionFileConverMapper; | |||
import com.tuoheng.admin.conver.ReportConverMapper; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.InspectionFileStatusEnum; | |||
import com.tuoheng.admin.enums.InspectionTypeEnum; | |||
import com.tuoheng.admin.enums.code.report.QueryInspectionReportCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionFileMapper; | |||
import com.tuoheng.admin.mapper.QuestionTypeMapper; | |||
import com.tuoheng.admin.mapper.ReportMapper; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionFileReportVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionReportVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionResultVo; | |||
@@ -49,6 +48,12 @@ public class QueryInspectionReportService { | |||
@Autowired | |||
private QuestionTypeMapper questionTypeMapper; | |||
@Autowired | |||
private AirportService airportService; | |||
@Autowired | |||
private RoadInformationMapper roadInformationMapper; | |||
public JsonResult getInspectionReport(String id) { | |||
log.info("进入查看巡检报告业务"); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
@@ -103,6 +108,7 @@ public class QueryInspectionReportService { | |||
.eq(InspectionFile::getMark, 1)); | |||
String deptName = this.getDeptName(report.getDeptId()); | |||
List<InspectionResultVo> inspectionResultVoList = this.buildInspectionResult(report); | |||
List<InspectionFileReportVo> inspectionFileHandleVoList = InspectionFileConverMapper.INSTANCE.fromInspectionFileListToInspectionFileHandleVoList(inspectionFileList); | |||
if (CollectionUtil.isNotEmpty(inspectionFileHandleVoList)) { | |||
for (InspectionFileReportVo inspectionFileReportVo : inspectionFileHandleVoList) { | |||
@@ -111,16 +117,51 @@ public class QueryInspectionReportService { | |||
inspectionFileReportVo.setFileOriginal(CommonConfig.imageURL + inspectionFileReportVo.getFileOriginal()); | |||
} | |||
} | |||
// 机场任务没有设备名称,暂定使用机场名称作为设备名称 | |||
if (InspectionTypeEnum.AIRPORT.getCode() == report.getInspectionType()) { | |||
inspectionReportVo.setEquipmentName(report.getAirportName()); | |||
AirportInfoVo airport = this.getAirport(report); | |||
RoadInformation road = this.getRoad(report); | |||
//设备名称 机场任务没有设备名称,暂定使用机场名称作为设备名称 | |||
if (InspectionTypeEnum.AIRPORT.getCode() == report.getInspectionType() && ObjectUtil.isNotEmpty(airport)) { | |||
inspectionReportVo.setEquipmentName(airport.getName()); | |||
inspectionReportVo.setAirportName(airport.getName()); | |||
inspectionReportVo.setRoadName(road.getName()); | |||
} | |||
inspectionReportVo.setDeptName(deptName); | |||
inspectionReportVo.setInspectionResultVoList(inspectionResultVoList); | |||
inspectionReportVo.setInspectionFileReportVoList(inspectionFileHandleVoList); | |||
return inspectionReportVo; | |||
} | |||
/** | |||
* 查询机场 | |||
* @param report | |||
* @return | |||
*/ | |||
private AirportInfoVo getAirport(Report report) { | |||
String airportIds = String.valueOf(report.getAirportId()); | |||
List<AirportInfoVo> airportInfoVoList = airportService.getAirportInfoList(airportIds); | |||
if (CollectionUtil.isEmpty(airportInfoVoList)) { | |||
return null; | |||
} | |||
return airportInfoVoList.get(0); | |||
} | |||
/** | |||
* 查询公路 | |||
* @param report | |||
* @return | |||
*/ | |||
private RoadInformation getRoad(Report report) { | |||
String roadId = report.getRoadId(); | |||
RoadInformation roadInformation = roadInformationMapper.selectById(roadId); | |||
if (ObjectUtil.isEmpty(roadInformation)) { | |||
return null; | |||
} | |||
return roadInformation; | |||
} | |||
/** | |||
* 获取部门路名称 | |||
*/ |
@@ -18,13 +18,13 @@ import net.sf.saxon.functions.Current; | |||
import org.springframework.stereotype.Component; | |||
import javax.annotation.Resource; | |||
import java.text.SimpleDateFormat; | |||
import java.util.*; | |||
@Slf4j | |||
@Component | |||
public class InspectionTimeOutTask { | |||
@Resource | |||
private InspectionMapper inspectionMapper; | |||
@@ -33,13 +33,12 @@ public class InspectionTimeOutTask { | |||
@XxlJob("inspectionTimeOutTaskHandler") | |||
public void inspectionExecuteHandler() { | |||
Date startTime = null; //当前时间 | |||
String taskBeginTime = null; //一小时之前 | |||
String msg = ""; | |||
log.info("=================================开始执行超时任务定时器任务调度================================="); | |||
Date startTime; | |||
String taskBeginTime = null; | |||
try { | |||
startTime = DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.now()), DateUtils.YYYY_MM_DD); | |||
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); | |||
startTime = new Date(System.currentTimeMillis()); | |||
taskBeginTime = DateUtils.addDateTimeToStr(startTime, 0, -1, 0, 0); | |||
} catch (Exception e) { | |||
log.error("获取开始时间异常:{}", e); | |||
@@ -48,32 +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) { | |||
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode()); | |||
inspectionMapper.updateById(inspection); | |||
msg = "任务执行超过一小时 默认失败"; | |||
this.insertInspectionHistory(inspection,msg); | |||
log.info("修改结果: 任务状态为" + inspection.getStatus()); | |||
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()); | |||
} | |||
} | |||
} |
@@ -2,7 +2,7 @@ spring: | |||
# 注册中心consul地址 | |||
cloud: | |||
consul: | |||
host: localhost # consul 所在服务地址 | |||
host: 192.168.11.13 # consul 所在服务地址 | |||
port: 8500 # consul 服务端口 | |||
discovery: | |||
# 是否启用服务发现 | |||
@@ -11,7 +11,7 @@ spring: | |||
register: false | |||
deregister: false | |||
## consul ip地址 | |||
hostname: localhost | |||
hostname: 192.168.11.13 | |||
# 注册到consul的服务名称 | |||
service-name: ${spring.application.name} # 服务提供者名称 | |||
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID |
@@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<sql id="selectInspectionVo"> | |||
select id, tenant_id, dept_id, code, name, type, road_id, road_name, section_id, section_name, inspection_type, | |||
inspectionCycleI, airport_task_id, airport_id, drone_id, airport_name, inspection_line, inspection_line_name, | |||
inspection_cycle_id, airport_task_id, airport_id, drone_id, airport_name, inspection_line, inspection_line_name, | |||
equipment_id, equipment_name, equipment_mount_id, equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, | |||
flight_hand, flight_hand_name, inspection_time, execution_start_time, execution_end_time, is_live, is_taken, is_tilt, | |||
video_url, ai_video_url, report_url, srt_url, status, analyse_status, progressbar, note, weather, | |||
@@ -328,15 +328,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<if test="droneId != null"> | |||
drone_id = #{droneId}, | |||
</if> | |||
<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> |
@@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> | |||
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | |||
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | |||
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> | |||
<if test="request.type != null and (request.type == 0 or request.type == 1 or request.type == 2)"> and type = #{request.type} </if> | |||
<if test="request.deptIdList != null and request.deptIdList.size() > 0"> | |||
and dept_id in | |||
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")"> |
@@ -56,7 +56,7 @@ public class InspectionQuery extends BaseQuery { | |||
private String inspectionLineName; | |||
/** | |||
* 巡检任务类型 1 临时巡检 | |||
* 巡检任务类型 0周期任务 1 单次任务|周期子任务 2 应急任务 | |||
*/ | |||
private Integer type; | |||
@@ -80,7 +80,7 @@ public class InspectionServiceImpl implements IInspectionService { | |||
String tenantId = user.getTenantId(); | |||
query.setTenantId(tenantId); | |||
query.setType(1); | |||
// query.setType(1); | |||
//初始部门id | |||
String deptIdInt = query.getDeptId(); | |||
@@ -242,7 +242,7 @@ public class InspectionServiceImpl implements IInspectionService { | |||
private Map<Integer, AirportLineVo> getAirportLineMap(List<InspectionInfoVo> inspectionInfoVoList) { | |||
List<Integer> airportLineIdList = inspectionInfoVoList.stream().map(o -> o.getInspectionLine()).collect(Collectors.toList()); | |||
airportLineIdList = airportLineIdList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(x->x))), ArrayList::new)); | |||
// airportLineIdList = airportLineIdList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(x->x))), ArrayList::new)); | |||
List<AirportLineVo> airportLineVoList = getAirLineListService.getList(null, airportLineIdList); | |||
if (CollectionUtil.isEmpty(airportLineVoList)) { | |||
return null; |
@@ -82,7 +82,7 @@ | |||
<if test="request.inspectionType !=null"> | |||
and ti.inspection_type = #{request.inspectionType} | |||
</if> | |||
<if test="request.type !=null"> | |||
<if test="request.type !=null and (request.type == 0 or request.type == 1)"> | |||
and ti.type = #{request.type} | |||
</if> | |||
<if test="request.startTimeDate !=null and request.endTimeDate !=null"> |