|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.tuoheng.admin.service.airData.syncdata; |
|
|
|
|
|
|
|
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; |
|
|
@@ -9,6 +10,7 @@ import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; |
|
|
|
import com.tuoheng.admin.entity.third.LingXiuDataResponse; |
|
|
|
import com.tuoheng.admin.enums.AirportLineEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionTypeEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.AirDataMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
@@ -20,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@@ -135,33 +138,39 @@ public class SyncAirDataService { |
|
|
|
log.info("灵嗅设备推送数据,serial为空"); |
|
|
|
return JsonResult.error("灵嗅设备推送数据,serial为空"); |
|
|
|
} |
|
|
|
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery() |
|
|
|
|
|
|
|
//先查询一个任务判断状态(获取最新的一条任务) |
|
|
|
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() |
|
|
|
.eq(Inspection::getMark, 1) |
|
|
|
.eq(Inspection::getEquipmentMountCode, response.getSerial()) |
|
|
|
.eq(Inspection::getStatus, 10) |
|
|
|
.orderByDesc(Inspection::getCreateTime)); |
|
|
|
log.info("查询的正在飞行的巡检任务,inspection={}",inspection); |
|
|
|
//Inspection inspection = this.getInspection(response.getSerial()); |
|
|
|
if (ObjectUtil.isNull(inspection)) { |
|
|
|
.eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode()) |
|
|
|
.orderByDesc(Inspection::getCreateTime) |
|
|
|
.last(" limit 1")); |
|
|
|
if(CollectionUtil.isEmpty(inspectionList) || inspectionList.size() == 0){ |
|
|
|
return JsonResult.error("未查询出最新的一条人工执飞任务"); |
|
|
|
} |
|
|
|
Inspection inspection = inspectionList.get(0); |
|
|
|
if (ObjectUtil.isNotNull(inspection)) { |
|
|
|
log.info("正在飞行的飞手任务,inspection={}",inspection); |
|
|
|
}else if(ObjectUtil.isNull(inspection)){ |
|
|
|
//再查询最新的一条任务 |
|
|
|
inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() |
|
|
|
.eq(Inspection::getMark, 1) |
|
|
|
.eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode()) |
|
|
|
.orderByDesc(Inspection::getCreateTime) |
|
|
|
.last(" limit 1")); |
|
|
|
if(CollectionUtil.isEmpty(inspectionList) || inspectionList.size() == 0){ |
|
|
|
return JsonResult.error("未查询出最新的一条机场巡检任务"); |
|
|
|
} |
|
|
|
inspection = inspectionList.get(0); |
|
|
|
}else { |
|
|
|
log.info("没有正在飞行的任务,无法关联推送的灵嗅数据,serial={}", response.getSerial()); |
|
|
|
return JsonResult.error("没有正在飞行的任务"); |
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.success(inspection); |
|
|
|
} |
|
|
|
|
|
|
|
// private Inspection getInspection(String serial) { |
|
|
|
// |
|
|
|
// Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() |
|
|
|
// .eq(Inspection::getEquipmentMountCode, serial) |
|
|
|
// .eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode()) |
|
|
|
// .eq(Inspection::getMark, MarkEnum.VALID.getCode()) |
|
|
|
// .orderByDesc(Inspection::getCreateTime)); |
|
|
|
// if (ObjectUtil.isNull(inspection)) { |
|
|
|
// return null; |
|
|
|
// } |
|
|
|
// return inspection; |
|
|
|
// } |
|
|
|
|
|
|
|
private String getValue(Map<String, Object> airDataMap, String key) { |
|
|
|
if (airDataMap.containsKey(key)) { |
|
|
|
return airDataMap.get(key) == null ? "" : (String) airDataMap.get(key).toString(); |