Browse Source

修改飞行日志返回success后,轮询飞行数据和调DSP的顺序

tags/v1.3.1
wanjing 1 year ago
parent
commit
9332793763
2 changed files with 6 additions and 10 deletions
  1. +3
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java
  2. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java

+ 3
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java View File

String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_DATA; String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_DATA;
JSONObject jsonObject = this.jsonObjectRequest(inspection); JSONObject jsonObject = this.jsonObjectRequest(inspection);
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject); String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject);
log.info("获取飞行数据, dataJson:{}", dataJson);

List<TZHLAirportFlightDataResponse> flightDataHlList = JSON.parseArray(dataJson, TZHLAirportFlightDataResponse.class); List<TZHLAirportFlightDataResponse> flightDataHlList = JSON.parseArray(dataJson, TZHLAirportFlightDataResponse.class);


log.info("获取飞行数据, flightDataHlList size:{}", flightDataHlList.size());

// 查询到的数据入库 // 查询到的数据入库
this.addFlightDataHl(inspection, flightDataHlList); this.addFlightDataHl(inspection, flightDataHlList);
} }
* @return * @return
*/ */
private void addFlightDataHl(Inspection inspection, List<TZHLAirportFlightDataResponse> flightDataHlList) { private void addFlightDataHl(Inspection inspection, List<TZHLAirportFlightDataResponse> flightDataHlList) {
log.info("开始飞行数据保存入库");
log.info("飞行数据保存入库, inspectionId:{}", inspection.getId());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (CollectionUtil.isNotEmpty(flightDataHlList) && flightDataHlList.size() != 0) { if (CollectionUtil.isNotEmpty(flightDataHlList) && flightDataHlList.size() != 0) {
List<FlightDataHl> flightDataHls = new ArrayList<>(flightDataHlList.size()); List<FlightDataHl> flightDataHls = new ArrayList<>(flightDataHlList.size());
e.printStackTrace(); e.printStackTrace();
} }
flightDataHl.setCreateUser(inspection.getCreateUser()); flightDataHl.setCreateUser(inspection.getCreateUser());

flightDataHls.add(flightDataHl); flightDataHls.add(flightDataHl);
log.info("结束飞行数据保存入库, flightDataHls:{}", flightDataHls);

} }
CommonUtils.batchOperate((x) -> flightDataHlMapper.addBatch(x),flightDataHls,1000); CommonUtils.batchOperate((x) -> flightDataHlMapper.addBatch(x),flightDataHls,1000);


flightDataHls = flightDataHls.stream().sorted(Comparator.comparing(FlightDataHl::getCreateTime).reversed()).collect(Collectors.toList()); flightDataHls = flightDataHls.stream().sorted(Comparator.comparing(FlightDataHl::getCreateTime).reversed()).collect(Collectors.toList());
//倒序排列的第一个最新数据保存到缓存 //倒序排列的第一个最新数据保存到缓存
redisUtils.set(inspection.getId(), flightDataHls.get(0), 10); redisUtils.set(inspection.getId(), flightDataHls.get(0), 10);

} }
} }
return; return;

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java View File

log.info("获取飞行日志,status=success,inspectionId={}, title={}", inspection.getId(), flyLogResponse.getTitle()); log.info("获取飞行日志,status=success,inspectionId={}, title={}", inspection.getId(), flyLogResponse.getTitle());
if (InspectionStatusEnum.IN_FLIGHT.getCode() == inspection.getStatus()) { if (InspectionStatusEnum.IN_FLIGHT.getCode() == inspection.getStatus()) {
log.info("获取飞行日志,该任务状态已经改是飞行中,inspectionid={}", inspection.getId()); log.info("获取飞行日志,该任务状态已经改是飞行中,inspectionid={}", inspection.getId());
return;
// return;
} }
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode()); inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());
inspection.setUpdateUser(""); inspection.setUpdateUser("");


log.info("获取飞行日志,status=success,修改任务状态,inspectionId={}, status={}", inspection.getId(), inspection.getStatus()); log.info("获取飞行日志,status=success,修改任务状态,inspectionId={}, status={}", inspection.getId(), inspection.getStatus());


this.exec(inspection.getId());

AirportDto airportDto = tzhlGetAirportListService.getAirport(inspection.getAirportId()); AirportDto airportDto = tzhlGetAirportListService.getAirport(inspection.getAirportId());
if (ObjectUtil.isEmpty(airportDto)) { if (ObjectUtil.isEmpty(airportDto)) {
log.info("获取飞行日志,获取推流地址失败,inspectionId={}", inspection.getId()); log.info("获取飞行日志,获取推流地址失败,inspectionId={}", inspection.getId());
log.info("获取飞行日志,获取推流地址,通知DSP失败"); log.info("获取飞行日志,获取推流地址,通知DSP失败");
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode()); inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
} }

this.exec(inspection.getId());
} }


@Async @Async

Loading…
Cancel
Save