Browse Source

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_lc into feature_v1.0

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
117484bb7b
7 changed files with 36 additions and 9 deletions
  1. +2
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/config/SystemConstant.java
  2. +10
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/dto/index/AirportDetailDto.java
  3. +5
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java
  4. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/UpdateEmergencyMissionStatusService.java
  5. +15
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportCallBackUpdateStatusService.java
  6. +2
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java
  7. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java

+ 2
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/config/SystemConstant.java View File

String API_AIRPORT_POINT_FLIGH = "/api/airportInterface/createPointLine"; String API_AIRPORT_POINT_FLIGH = "/api/airportInterface/createPointLine";


/** /**
* 机场平台:定点飞行
* 机场平台:控制无人机
*/ */
String API_AIRPORT_DRONE_CONTROL = "/api/createPointLine/droneCommand";
String API_AIRPORT_DRONE_CONTROL = "/api/airportInterface/droneCommand";


} }

+ 10
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/dto/index/AirportDetailDto.java View File

*/ */
private String wdir; private String wdir;


/**
* 风向名称
*/
private String wdirName;

/** /**
* 大气压力 * 大气压力
*/ */
*/ */
private String mountName; private String mountName;


/**
* 降雨量
*/
private String rainfull;

} }

+ 5
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java View File

JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData()); JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData());
JSONObject wthJson = dataObject.getJSONObject("WTH"); JSONObject wthJson = dataObject.getJSONObject("WTH");
if(Objects.nonNull(wthJson)){ if(Objects.nonNull(wthJson)){
JSONObject parmJson = wthJson.getJSONObject("parm");
JSONObject parmJson = wthJson.getJSONObject("parmNew");


BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportDetailDto.setHum(hum + "rh"); airportDetailDto.setHum(hum + "rh");
airportDetailDto.setTmp(tmp + "℃"); airportDetailDto.setTmp(tmp + "℃");


airportDetailDto.setWspd(parmJson.getString("WSPD") + "m/s") airportDetailDto.setWspd(parmJson.getString("WSPD") + "m/s")
.setWdir(parmJson.getString("WDIR") + "度");
.setWdir(parmJson.getString("WDIR") + "度")
.setRainfull(parmJson.getString("Rainfull") + "mm")
.setWdirName(parmJson.getString("WDIRNAME"));
//用角度表示风向,是把圆周分成360度,北风(N)是0度(即360度),东风(E)是90度,南风(S)是180度,西风(W)是270度 //用角度表示风向,是把圆周分成360度,北风(N)是0度(即360度),东风(E)是90度,南风(S)是180度,西风(W)是270度
BigDecimal hpa = parmJson.getBigDecimal("Hpa"); BigDecimal hpa = parmJson.getBigDecimal("Hpa");
if(hpa != null){ if(hpa != null){
} }
JSONObject tahJson = dataObject.getJSONObject("TAH"); JSONObject tahJson = dataObject.getJSONObject("TAH");
if(Objects.nonNull(tahJson)){ if(Objects.nonNull(tahJson)){
JSONObject parmJson = tahJson.getJSONObject("parm");
JSONObject parmJson = tahJson.getJSONObject("parmNew");
BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportDetailDto.setHum(hum + "rh"); airportDetailDto.setHum(hum + "rh");
BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/UpdateEmergencyMissionStatusService.java View File

* @param oldMission * @param oldMission
*/ */
public void updateStatus(ThMission oldMission, Integer status) { public void updateStatus(ThMission oldMission, Integer status) {
log.info("进入修改应急任务数据");
log.info("进入修改应急任务数据, type:{}, emergencyDataMissionId:{}, status={}", oldMission.getType(), oldMission.getEmergencyDataMissionId(), status);
if (1 == oldMission.getType()) { if (1 == oldMission.getType()) {
return; return;
} }

+ 15
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportCallBackUpdateStatusService.java View File



Integer status = null; Integer status = null;
if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) { if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) {
log.info("被硬件调用,存任务状态:执行中");
// ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode()); // ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode());
Assert.notNull(thMission, "飞行任务不能为空!"); Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission, AirPortTaskStatusEnum.FLIGHT); ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission, AirPortTaskStatusEnum.FLIGHT);
try { try {
//开始分析 //开始分析
log.info("被硬件调用,存任务状态:开始分析");
JSONObject jsonObject = this.startAI(missionStatusRequest); JSONObject jsonObject = this.startAI(missionStatusRequest);
thMissionUpdate.setRequestId(jsonObject.getJSONObject("data").getString("requestId")); thMissionUpdate.setRequestId(jsonObject.getJSONObject("data").getString("requestId"));
thMissionUpdate.setAipullUrl(jsonObject.getJSONObject("data").getString("aipullUrl")); thMissionUpdate.setAipullUrl(jsonObject.getJSONObject("data").getString("aipullUrl"));
thMissionUpdate.setAiplayUrl(jsonObject.getJSONObject("data").getString("aiplayUrl")); thMissionUpdate.setAiplayUrl(jsonObject.getJSONObject("data").getString("aiplayUrl"));
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.WAITING.getCode()); thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.WAITING.getCode());


log.info("修改飞行状态:{}", JSONObject.toJSONString(thMissionUpdate));
log.info("被硬件调用,原任务状态:status:{}", thMission.getStatus());
thMissionMapper.updateById(thMissionUpdate); thMissionMapper.updateById(thMissionUpdate);


status = TaskStatusEnum.FLIGHT.getCode(); status = TaskStatusEnum.FLIGHT.getCode();
status = TaskStatusEnum.FAIL.getCode(); status = TaskStatusEnum.FAIL.getCode();
// throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务分析失败!"); // throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务分析失败!");
} }
log.info("机场平台回调,执行中,开始修改应急任务数据");
updateEmergencyMissionStatusService.updateStatus(thMission, status); updateEmergencyMissionStatusService.updateStatus(thMission, status);
log.info("机场平台回调,执行中,修改应急任务数据结束");
} else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) { } else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) {
log.info("被硬件调用,存任务状态:已完成");
// 机场飞行完成,立即修改任务状态为已完成 // 机场飞行完成,立即修改任务状态为已完成
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
thMissionUpdate.setId(Integer.parseInt(missionStatusRequest.getRequestId())); thMissionUpdate.setId(Integer.parseInt(missionStatusRequest.getRequestId()));
thMissionUpdate.setWeather(""); thMissionUpdate.setWeather("");
log.info("获取天气信息失败,请重试"); log.info("获取天气信息失败,请重试");
} }

log.info("被硬件调用,任务状态:status:{}", thMissionUpdate.getStatus());
thMissionMapper.updateById(thMissionUpdate); thMissionMapper.updateById(thMissionUpdate);


status = TaskStatusEnum.COMPLETE.getCode(); status = TaskStatusEnum.COMPLETE.getCode();

log.info("机场平台回调,已完成,开始修改应急任务数据");
updateEmergencyMissionStatusService.updateStatus(thMission, status); updateEmergencyMissionStatusService.updateStatus(thMission, status);
log.info("机场平台回调,已完成,修改应急任务数据结束");


//硬件停止后,停止AI分析 //硬件停止后,停止AI分析
this.stopAI(missionStatusRequest, thMission); this.stopAI(missionStatusRequest, thMission);
} else { } else {
log.info("机场平台回调,修改任务状态,不存在的任务状态");
throw new ServiceException(ServiceExceptionEnum.TASK_NOT_STATUS); throw new ServiceException(ServiceExceptionEnum.TASK_NOT_STATUS);
} }
log.info("机场平台回调,修改任务状态结束");
return true; return true;
} }


private JSONObject startAI(MissionStatusRequest missionStatusRequest) throws ServiceException { private JSONObject startAI(MissionStatusRequest missionStatusRequest) throws ServiceException {
log.info("开始AI分析");
//任务调用完成之后,调用发送通道,请求DSP需要分析 //任务调用完成之后,调用发送通道,请求DSP需要分析
//调用DSP接口 //调用DSP接口
JSONObject request = new JSONObject(); JSONObject request = new JSONObject();
} }


private Boolean stopAI(MissionStatusRequest missionStatusRequest, ThMission thMission) { private Boolean stopAI(MissionStatusRequest missionStatusRequest, ThMission thMission) {
log.info("停止AI分析");
Assert.notNull(thMission, "飞行任务不能为空!"); Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
thMissionUpdate.setId(thMission.getId()); thMissionUpdate.setId(thMission.getId());

+ 2
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/DroneControlService.java View File

public JsonResult execute(DroneControlRequest request) { public JsonResult execute(DroneControlRequest request) {
log.info("进入调用机场平台,操作无人机"); log.info("进入调用机场平台,操作无人机");
this.check(request); this.check(request);
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_POINT_FLIGH;
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL;
JSONObject jsonObject = new JSONObject().parseObject(request.getValue()); JSONObject jsonObject = new JSONObject().parseObject(request.getValue());


log.info("调用机场平台,操作无人机: url:{}", url); log.info("调用机场平台,操作无人机: url:{}", url);
log.info("调用机场平台,操作无人机: jsonObject:{}", jsonObject); log.info("调用机场平台,操作无人机: jsonObject:{}", jsonObject);


String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
log.info("调用机场平台,操作无人机: airPortStr:{}", airPortStr);
if (StringUtils.isEmpty(airPortStr)) { if (StringUtils.isEmpty(airPortStr)) {
log.info("执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject); log.info("执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject);
return JsonResult.error(-1, "机场接口返回数据为空"); return JsonResult.error(-1, "机场接口返回数据为空");

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java View File

mission.setCode(code); mission.setCode(code);
mission.setName("应急任务" + code); mission.setName("应急任务" + code);
mission.setTenantId(user.getTenantId()); mission.setTenantId(user.getTenantId());
mission.setStatus(2);
mission.setType(2);
mission.setInspectionType(InspectionTypeEnum.AIRPORT.getCode()); mission.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
mission.setAirportId(request.getAirportId()); mission.setAirportId(request.getAirportId());
mission.setAirportName(request.getAirportName()); mission.setAirportName(request.getAirportName());

Loading…
Cancel
Save