|
|
@@ -50,9 +50,11 @@ public class FlyDataService { |
|
|
|
private TZHLGetAirportListService getAirportListService; |
|
|
|
|
|
|
|
public void getFlyData(Inspection inspection) { |
|
|
|
log.info("执行获取飞行数据操作,inspection:{}",inspection.toString()); |
|
|
|
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_DATA; |
|
|
|
JSONObject jsonObject = this.jsonObjectRequest(inspection); |
|
|
|
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject); |
|
|
|
log.info("获取飞行数据dataJson:{}",dataJson); |
|
|
|
|
|
|
|
List<TZHLAirportFlightDataResponse> flightDataHlList = JSON.parseArray(dataJson, TZHLAirportFlightDataResponse.class); |
|
|
|
|
|
|
@@ -67,6 +69,7 @@ public class FlyDataService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void addFlightDataHl(Inspection inspection, List<TZHLAirportFlightDataResponse> flightDataHlList) { |
|
|
|
log.info("开始飞行数据保存入库"); |
|
|
|
if(CollectionUtil.isNotEmpty(flightDataHlList) && flightDataHlList.size() != 0){ |
|
|
|
List<FlightDataHl> flightDataHls = new ArrayList<>(flightDataHlList.size()); |
|
|
|
for (TZHLAirportFlightDataResponse responseData : flightDataHlList) { |
|
|
@@ -84,9 +87,11 @@ public class FlyDataService { |
|
|
|
throw new SecurityException("飞行数据插入失败"); |
|
|
|
} |
|
|
|
flightDataHls.add(flightDataHl); |
|
|
|
log.info("结束飞行数据保存入库, flightDataHls:{}",flightDataHls); |
|
|
|
|
|
|
|
} |
|
|
|
//将最新的一条数据存入缓存,并设置过期时间 |
|
|
|
log.info("开始存入最新一条数据于缓存中"); |
|
|
|
if(CollectionUtil.isNotEmpty(flightDataHls) && flightDataHls.size()>0){ |
|
|
|
flightDataHls = flightDataHls.stream().sorted(Comparator.comparing(FlightDataHl::getCreateTime).reversed()).collect(Collectors.toList()); |
|
|
|
//倒序排列的第一个最新数据保存到缓存 |