Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.2.0^2
wanjing 1 year ago
parent
commit
be9f787cd1
1 changed files with 25 additions and 17 deletions
  1. +25
    -17
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ReversalFlightService.java

+ 25
- 17
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ReversalFlightService.java View File

@@ -1,8 +1,8 @@
package com.tuoheng.admin.service.third.airport;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
@@ -32,33 +32,41 @@ public class ReversalFlightService {

/**
* 应急飞行(回仓)
*
* @param request
* @return
*/
public JsonResult reversalFlight(ReversalFlightRequest request) {

log.info("进入调用机场平台,执行定点飞行");
log.info("进入调用机场平台,执行定点飞行, airportId={}", request.getAirportId());
//校验传参
if(null == request.getAirportId()){
throw new ServiceException("机场id为空");
if (null == request.getAirportId()) {
throw new ServiceException("机场id为空");
}
// 根据机场查询对应应急任务
// 正常由机场平台会回调改状态,为防止机场平台回调出问题,此时将应急任务状态改为已完成
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getAirportId, request.getAirportId())
.eq(Inspection::getType, 2)
.eq(Inspection::getMark, MarkEnum.VALID.getCode())
.eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode()));
if (ObjectUtil.isNotNull(inspection)) {
// 修改原巡检任务状态为已完成
inspection.setStatus(InspectionStatusEnum.FLIGHT_COMPLETED.getCode());
inspectionMapper.updateById(inspection);
}
//根据任务对应的机场查询对应任务id
// Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
// .eq(Inspection::getAirportId, request.getAirportId())
// .eq(Inspection::getMark, MarkEnum.VALID.getCode())
// .eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode()));

request.setZhilin("03");
//调用机场平台让飞机返航
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL;
JSONObject jsonObject = new JSONObject();
jsonObject.put("airportId",request.getAirportId());
jsonObject.put("zhilin",request.getZhilin());
jsonObject.put("msg","回仓");
log.info("调用机场平台,无人机执行定点飞行返航:url:{}",url);
log.info("调用机场平台,原无人机执行定点飞行返航,jsonObject:{}",jsonObject);
jsonObject.put("airportId", request.getAirportId());
jsonObject.put("zhilin", request.getZhilin());
jsonObject.put("msg", "回仓");
log.info("调用机场平台,无人机执行定点飞行返航:url:{}", url);
log.info("调用机场平台,原无人机执行定点飞行返航,jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
log.info("调用无人机平台,操作无人机:airPortStr:{}",airPortStr);
log.info("调用无人机平台,操作无人机:airPortStr:{}", airPortStr);
if (StringUtils.isEmpty(airPortStr)) {
log.info("原无人机执行定点飞行返航:机场接口返回数据为空,返航失败,jsonObject:{}", jsonObject);
throw new ServiceException("机场接口返回数据为空,返航失败");
@@ -66,7 +74,7 @@ public class ReversalFlightService {
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("调用机场平台,无人机执行定点飞行:返航失败,jsonResult:{}", jsonResult.getMsg());
return JsonResult.error(-1,"机场平台返回失败");
return JsonResult.error(-1, "机场平台返回失败");
}
log.info("调用无人机平台返航结束");
return JsonResult.success();

Loading…
Cancel
Save