|
|
@@ -1,11 +1,15 @@ |
|
|
|
package com.tuoheng.admin.service.airportline.query.inspection; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.tuoheng.admin.constant.SystemConstant; |
|
|
|
import com.tuoheng.admin.entity.Inspection; |
|
|
|
import com.tuoheng.admin.enums.code.AriportCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.tzhl.response.FlyLinePointResult; |
|
|
|
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse; |
|
|
|
import com.tuoheng.admin.tzhl.service.airportline.TZHLGetAirportLineListService; |
|
|
|
import com.tuoheng.admin.vo.airport.AirPortLineLocationVo; |
|
|
|
import com.tuoheng.admin.vo.airport.AirPortStatusVO; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
@@ -18,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@@ -31,6 +36,9 @@ import java.util.List; |
|
|
|
@Service |
|
|
|
public class QueryAirportLineByAirportService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TZHLGetAirportLineListService tzhlGetAirportLineListService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据任务ID获取航线,从机场平台获取 |
|
|
|
* |
|
|
@@ -44,7 +52,27 @@ public class QueryAirportLineByAirportService { |
|
|
|
log.info("根据任务ID获取航线:校验参数失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
List<AirPortLineLocationVo> airPortLineLocationVoList = this.getAirPortLocation(inspectionLine); |
|
|
|
|
|
|
|
TZHLAirportLineResponse tzhlAirportLineResponse = tzhlGetAirportLineListService.getAirportLineById(inspection.getInspectionLine()); |
|
|
|
if (ObjectUtil.isEmpty(tzhlAirportLineResponse)) { |
|
|
|
log.info("根据任务ID获取航线:航线不存在:{}", inspection.getInspectionLine()); |
|
|
|
return JsonResult.error("航线不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
List<FlyLinePointResult> points = tzhlAirportLineResponse.getPoints(); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(points)) { |
|
|
|
log.info("根据任务ID获取航线:航线点集合为空"); |
|
|
|
return JsonResult.error("航线点集合为空"); |
|
|
|
} |
|
|
|
List<AirPortLineLocationVo> airPortLineLocationVoList = new ArrayList<>(); |
|
|
|
AirPortLineLocationVo airPortLineLocationVo; |
|
|
|
for (FlyLinePointResult flyLinePointResult : points) { |
|
|
|
airPortLineLocationVo = new AirPortLineLocationVo(); |
|
|
|
airPortLineLocationVo.setLat(flyLinePointResult.getLatitude()); |
|
|
|
airPortLineLocationVo.setLon(flyLinePointResult.getLongitude()); |
|
|
|
airPortLineLocationVoList.add(airPortLineLocationVo); |
|
|
|
} |
|
|
|
return JsonResult.success(airPortLineLocationVoList); |
|
|
|
} |
|
|
|
|
|
|
@@ -56,25 +84,4 @@ public class QueryAirportLineByAirportService { |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
private List<AirPortLineLocationVo> getAirPortLocation(Long inspectionLine) { |
|
|
|
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LOCATION; |
|
|
|
String param = "id=" + inspectionLine; |
|
|
|
String airPortLineLocationStr = HttpUtils.sendGet(url, param); |
|
|
|
if (StringUtils.isEmpty(airPortLineLocationStr)) { |
|
|
|
log.info("调用机场平台,查询航线:机场接口返回数据为空"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
JsonResult jsonResult = JacksonUtil.json2pojo(airPortLineLocationStr, JsonResult.class); |
|
|
|
if (0 != jsonResult.getCode()) { |
|
|
|
log.info("调用机场平台,查询航线:机场接口返回状态失败"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(jsonResult.getData())) { |
|
|
|
log.info("调用机场平台,查询航线:机场接口返回数据为空"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<AirPortLineLocationVo> airPortLineLocationVoList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirPortLineLocationVo.class); |
|
|
|
return airPortLineLocationVoList; |
|
|
|
} |
|
|
|
|
|
|
|
} |