|
|
@@ -9,6 +9,9 @@ import com.tuoheng.admin.conver.InspectionConverMapper; |
|
|
|
import com.tuoheng.admin.entity.domain.FlightData; |
|
|
|
import com.tuoheng.admin.entity.domain.Inspection; |
|
|
|
import com.tuoheng.admin.entity.domain.InspectionHistory; |
|
|
|
import com.tuoheng.admin.entity.vo.airport.AirportInfoVo; |
|
|
|
import com.tuoheng.admin.entity.vo.airport.AirportLineVo; |
|
|
|
import com.tuoheng.admin.entity.vo.inspection.InspectionVo; |
|
|
|
import com.tuoheng.admin.enums.InspectionStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionTaskTypeEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionTypeEnum; |
|
|
@@ -17,6 +20,7 @@ import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnu |
|
|
|
import com.tuoheng.admin.mapper.FlightDataMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionHistoryMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.service.third.airport.AirportService; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.entity.vo.inspection.InspectionDetailsVo; |
|
|
|
import com.tuoheng.admin.utils.TimeUtil; |
|
|
@@ -24,10 +28,15 @@ import com.tuoheng.common.core.utils.CommonNumberTypeUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@@ -50,17 +59,19 @@ public class QueryInspectionDetailsByIdService { |
|
|
|
@Autowired |
|
|
|
private FlightDataMapper flightDataMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AirportService airportService; |
|
|
|
|
|
|
|
public JsonResult getInspectionDetails(String id) { |
|
|
|
log.info("进入查询巡检任务详情业务"); |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
JsonResult result = this.check(tenantId, id); |
|
|
|
|
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
Inspection inspection = (Inspection) result.getData(); |
|
|
|
|
|
|
|
InspectionDetailsVo inspectionDetailsVo = InspectionConverMapper.INSTANCE.fromInspectionToInspectionDetailsVo(inspection); |
|
|
|
|
|
|
|
//获取最后一次的飞行时间 获取飞行里程 只有机场任务才有里程和失败记录 |
|
|
@@ -75,12 +86,53 @@ public class QueryInspectionDetailsByIdService { |
|
|
|
inspectionDetailsVo.setInspectionHistoryList(inspectionHistoryList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Inspection> inspectionList = new ArrayList<>(); |
|
|
|
inspectionList.add(inspection); |
|
|
|
AirportInfoVo airport = this.getAirport(inspection); |
|
|
|
AirportLineVo airportLine = this.getAirportLine(inspectionList); |
|
|
|
|
|
|
|
//机场名称 |
|
|
|
if (ObjectUtil.isNotEmpty(airport)) { |
|
|
|
inspectionDetailsVo.setAirportName(airport.getName()); |
|
|
|
} |
|
|
|
//航线名称 |
|
|
|
if (ObjectUtil.isNotEmpty(airportLine)) { |
|
|
|
inspectionDetailsVo.setInspectionLineName(airportLine.getFileName()); |
|
|
|
} |
|
|
|
return JsonResult.success(inspectionDetailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询机场 |
|
|
|
* @param inspection |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private AirportInfoVo getAirport(Inspection inspection) { |
|
|
|
String airportIds = String.valueOf(inspection.getAirportId()); |
|
|
|
List<AirportInfoVo> airportInfoVoList = airportService.getAirportInfoList(airportIds); |
|
|
|
if (CollectionUtil.isEmpty(airportInfoVoList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return airportInfoVoList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查航线 |
|
|
|
* @param inspectionList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private AirportLineVo getAirportLine(List<Inspection> inspectionList) { |
|
|
|
List<Integer> airportLineIdList = inspectionList.stream().map(o -> o.getInspectionLine()).collect(Collectors.toList()); |
|
|
|
List<AirportLineVo> airportLineVoList = airportService.getAirportLineListByAirportIdAndLineIdList(null, airportLineIdList); |
|
|
|
if (CollectionUtil.isEmpty(airportLineVoList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return airportLineVoList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void getFlyTimeAndMileage(Inspection inspection, InspectionDetailsVo inspectionDetailsVo) { |
|
|
|
//任务判断 |
|
|
|
if(inspectionDetailsVo.getStatus().equals(InspectionStatusEnum.FLIGHT_COMPLETED.getCode()) |
|
|
@@ -100,7 +152,6 @@ public class QueryInspectionDetailsByIdService { |
|
|
|
inspectionDetailsVo.setMileage(round + "公里"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |