@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.dto.ReversalFlightDto; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.entity.request.airport.ReversalFlightRequest; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -61,15 +62,25 @@ public class AirPortController { | |||
return airportService.getAirportVideo(droneId); | |||
} | |||
/** | |||
* 无人机悬停 | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/hover") | |||
public JsonResult hover(@RequestBody DroneHoverRequest request){ | |||
log.info("进入无人机悬停接口,request={}",request); | |||
return airportService.hover(request); | |||
} | |||
/** | |||
* 无人机返仓 | |||
* @param dto | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/reversalFlight") | |||
public JsonResult reversalFlight(@RequestBody ReversalFlightDto dto){ | |||
log.info("进入无人机返航接口:dto={}",dto); | |||
public JsonResult reversalFlight(@RequestBody ReversalFlightRequest request){ | |||
log.info("进入无人机返航接口: request={}", request); | |||
return JsonResult.success(); | |||
} | |||
@@ -0,0 +1,31 @@ | |||
package com.tuoheng.admin.entity.request.airport; | |||
import lombok.Data; | |||
/** | |||
* 无人机悬停请求参数 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-05-25 | |||
*/ | |||
@Data | |||
public class DroneHoverRequest { | |||
/** | |||
* 任务id | |||
*/ | |||
private String inspectiontId; | |||
/** | |||
* 机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 校验数字符 | |||
*/ | |||
private String zhilin; | |||
} |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.admin.entity.dto; | |||
package com.tuoheng.admin.entity.request.airport; | |||
import lombok.Data; | |||
@@ -8,18 +8,16 @@ import lombok.Data; | |||
* @Date 2023/3/14 | |||
*/ | |||
@Data | |||
public class ReversalFlightDto { | |||
public class ReversalFlightRequest { | |||
/** | |||
* 应急事故id | |||
*/ | |||
private String accidentId; | |||
/** | |||
* 校验数字符 | |||
*/ | |||
private String zhilin; | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
public interface AirportService { | |||
@@ -15,4 +16,13 @@ public interface AirportService { | |||
JsonResult getAirportVideo(Integer droneId); | |||
/** | |||
* | |||
* 无人机悬停 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
JsonResult hover(DroneHoverRequest request); | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.service.third.airport.drone.DroneService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -23,6 +25,9 @@ public class AirportServiceImpl implements AirportService { | |||
@Autowired | |||
private GetAirportVideoService getAirportVideoService; | |||
@Autowired | |||
private DroneService droneService; | |||
@Override | |||
public JsonResult getAirportList() { | |||
return getAirportListService.getAirportList(); | |||
@@ -47,4 +52,10 @@ public class AirportServiceImpl implements AirportService { | |||
public JsonResult getAirportVideo(Integer droneId) { | |||
return getAirportVideoService.getAirportVideo(droneId); | |||
} | |||
@Override | |||
public JsonResult hover(DroneHoverRequest request) { | |||
return droneService.hover(request.getAirportId(), request.getInspectiontId()); | |||
} | |||
} |
@@ -9,5 +9,9 @@ public interface DroneService { | |||
*/ | |||
JsonResult continuee(Integer airportId, String inspectionId); | |||
/** | |||
* 无人机悬停 | |||
*/ | |||
JsonResult hover(Integer airportId, String inspectionId); | |||
} |
@@ -1,5 +1,7 @@ | |||
package com.tuoheng.admin.service.third.airport.drone; | |||
import com.tuoheng.admin.service.third.airport.drone.continuee.DroneContinueService; | |||
import com.tuoheng.admin.service.third.airport.drone.hover.DroneHoverService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -12,8 +14,16 @@ public class DroneServiceImpl implements DroneService { | |||
@Autowired | |||
private DroneContinueService droneContinueService; | |||
@Autowired | |||
private DroneHoverService droneHoverService; | |||
@Override | |||
public JsonResult continuee(Integer airportId, String inspectionId) { | |||
return droneContinueService.continuee(airportId, inspectionId); | |||
} | |||
@Override | |||
public JsonResult hover(Integer airportId, String inspectionId) { | |||
return droneHoverService.hover(airportId, inspectionId); | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.admin.service.third.airport.drone; | |||
package com.tuoheng.admin.service.third.airport.drone.continuee; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; |
@@ -0,0 +1,87 @@ | |||
package com.tuoheng.admin.service.third.airport.drone.hover; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.HttpUtils; | |||
import com.tuoheng.common.core.utils.JacksonUtil; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Slf4j | |||
@Service | |||
public class DroneHoverService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
/** | |||
* 调用机场平台,原无人机悬停 | |||
* | |||
* @param airportId 机场Id | |||
* @param inspectionId 任务Id | |||
*/ | |||
public JsonResult hover(Integer airportId, String inspectionId) { | |||
//校验 | |||
JsonResult jsonResult = this.check(inspectionId); | |||
if(0 != jsonResult.getCode()){ | |||
log.info("无人机悬停, 参数检验失败"); | |||
return JsonResult.error(jsonResult.getCode(),jsonResult.getMsg()); | |||
} | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("zhilin", "01"); | |||
jsonObject.put("airportId", airportId); | |||
jsonObject.put("taskId", inspectionId); | |||
jsonObject.put("msg", "悬停"); | |||
log.info("调用机场,无人机悬停:url:{}", url); | |||
log.info("调用机场,无人机悬停:jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("调用机场,无人机悬停:机场接口返回数据为空,悬停失败,jsonObject:{}", jsonObject); | |||
throw new com.aliyun.oss.ServiceException("机场接口返回数据为空,悬停失败"); | |||
} | |||
jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("调用机场,无人机悬停:悬停失败,jsonResult:{}", jsonResult.getMsg()); | |||
throw new ServiceException("机场平台返回,悬停失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
log.info("无人机悬停,任务ID为空"); | |||
throw new ServiceException("任务ID为空"); | |||
} | |||
// 判断任务是否存在 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getId, id) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
log.info("无人机悬停,任务不存在"); | |||
throw new ServiceException("任务不存在"); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
} |