@@ -40,8 +40,8 @@ public interface SystemConstant { | |||
String API_AIRPORT_POINT_FLIGH = "/api/airportInterface/createPointLine"; | |||
/** | |||
* 机场平台:定点飞行 | |||
* 机场平台:控制无人机 | |||
*/ | |||
String API_AIRPORT_DRONE_CONTROL = "/api/createPointLine/droneCommand"; | |||
String API_AIRPORT_DRONE_CONTROL = "/api/airportInterface/droneCommand"; | |||
} |
@@ -26,6 +26,11 @@ public class AirportDetailDto { | |||
*/ | |||
private String wdir; | |||
/** | |||
* 风向名称 | |||
*/ | |||
private String wdirName; | |||
/** | |||
* 大气压力 | |||
*/ | |||
@@ -51,4 +56,9 @@ public class AirportDetailDto { | |||
*/ | |||
private String mountName; | |||
/** | |||
* 降雨量 | |||
*/ | |||
private String rainfull; | |||
} |
@@ -98,7 +98,7 @@ public class IndexServiceImpl implements IndexService { | |||
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData()); | |||
JSONObject wthJson = dataObject.getJSONObject("WTH"); | |||
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); | |||
airportDetailDto.setHum(hum + "rh"); | |||
@@ -106,7 +106,9 @@ public class IndexServiceImpl implements IndexService { | |||
airportDetailDto.setTmp(tmp + "℃"); | |||
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度 | |||
BigDecimal hpa = parmJson.getBigDecimal("Hpa"); | |||
if(hpa != null){ | |||
@@ -116,7 +118,7 @@ public class IndexServiceImpl implements IndexService { | |||
} | |||
JSONObject tahJson = dataObject.getJSONObject("TAH"); | |||
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); | |||
airportDetailDto.setHum(hum + "rh"); | |||
BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); |
@@ -23,7 +23,7 @@ public class UpdateEmergencyMissionStatusService { | |||
* @param oldMission | |||
*/ | |||
public void updateStatus(ThMission oldMission, Integer status) { | |||
log.info("进入修改应急任务数据"); | |||
log.info("进入修改应急任务数据, type:{}, emergencyDataMissionId:{}, status={}", oldMission.getType(), oldMission.getEmergencyDataMissionId(), status); | |||
if (1 == oldMission.getType()) { | |||
return; | |||
} |
@@ -62,11 +62,13 @@ public class AirportCallBackUpdateStatusService { | |||
Integer status = null; | |||
if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) { | |||
log.info("被硬件调用,存任务状态:执行中"); | |||
// ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode()); | |||
Assert.notNull(thMission, "飞行任务不能为空!"); | |||
ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission, AirPortTaskStatusEnum.FLIGHT); | |||
try { | |||
//开始分析 | |||
log.info("被硬件调用,存任务状态:开始分析"); | |||
JSONObject jsonObject = this.startAI(missionStatusRequest); | |||
thMissionUpdate.setRequestId(jsonObject.getJSONObject("data").getString("requestId")); | |||
thMissionUpdate.setAipullUrl(jsonObject.getJSONObject("data").getString("aipullUrl")); | |||
@@ -75,7 +77,7 @@ public class AirportCallBackUpdateStatusService { | |||
thMissionUpdate.setAiplayUrl(jsonObject.getJSONObject("data").getString("aiplayUrl")); | |||
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.WAITING.getCode()); | |||
log.info("修改飞行状态:{}", JSONObject.toJSONString(thMissionUpdate)); | |||
log.info("被硬件调用,原任务状态:status:{}", thMission.getStatus()); | |||
thMissionMapper.updateById(thMissionUpdate); | |||
status = TaskStatusEnum.FLIGHT.getCode(); | |||
@@ -88,8 +90,11 @@ public class AirportCallBackUpdateStatusService { | |||
status = TaskStatusEnum.FAIL.getCode(); | |||
// throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务分析失败!"); | |||
} | |||
log.info("机场平台回调,执行中,开始修改应急任务数据"); | |||
updateEmergencyMissionStatusService.updateStatus(thMission, status); | |||
log.info("机场平台回调,执行中,修改应急任务数据结束"); | |||
} else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) { | |||
log.info("被硬件调用,存任务状态:已完成"); | |||
// 机场飞行完成,立即修改任务状态为已完成 | |||
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); | |||
thMissionUpdate.setId(Integer.parseInt(missionStatusRequest.getRequestId())); | |||
@@ -103,20 +108,28 @@ public class AirportCallBackUpdateStatusService { | |||
thMissionUpdate.setWeather(""); | |||
log.info("获取天气信息失败,请重试"); | |||
} | |||
log.info("被硬件调用,任务状态:status:{}", thMissionUpdate.getStatus()); | |||
thMissionMapper.updateById(thMissionUpdate); | |||
status = TaskStatusEnum.COMPLETE.getCode(); | |||
log.info("机场平台回调,已完成,开始修改应急任务数据"); | |||
updateEmergencyMissionStatusService.updateStatus(thMission, status); | |||
log.info("机场平台回调,已完成,修改应急任务数据结束"); | |||
//硬件停止后,停止AI分析 | |||
this.stopAI(missionStatusRequest, thMission); | |||
} else { | |||
log.info("机场平台回调,修改任务状态,不存在的任务状态"); | |||
throw new ServiceException(ServiceExceptionEnum.TASK_NOT_STATUS); | |||
} | |||
log.info("机场平台回调,修改任务状态结束"); | |||
return true; | |||
} | |||
private JSONObject startAI(MissionStatusRequest missionStatusRequest) throws ServiceException { | |||
log.info("开始AI分析"); | |||
//任务调用完成之后,调用发送通道,请求DSP需要分析 | |||
//调用DSP接口 | |||
JSONObject request = new JSONObject(); | |||
@@ -157,6 +170,7 @@ public class AirportCallBackUpdateStatusService { | |||
} | |||
private Boolean stopAI(MissionStatusRequest missionStatusRequest, ThMission thMission) { | |||
log.info("停止AI分析"); | |||
Assert.notNull(thMission, "飞行任务不能为空!"); | |||
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); | |||
thMissionUpdate.setId(thMission.getId()); |
@@ -23,13 +23,14 @@ public class DroneControlService { | |||
public JsonResult execute(DroneControlRequest request) { | |||
log.info("进入调用机场平台,操作无人机"); | |||
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()); | |||
log.info("调用机场平台,操作无人机: url:{}", url); | |||
log.info("调用机场平台,操作无人机: jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
log.info("调用机场平台,操作无人机: airPortStr:{}", airPortStr); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject); | |||
return JsonResult.error(-1, "机场接口返回数据为空"); |
@@ -240,7 +240,7 @@ public class PointFlightService { | |||
mission.setCode(code); | |||
mission.setName("应急任务" + code); | |||
mission.setTenantId(user.getTenantId()); | |||
mission.setStatus(2); | |||
mission.setType(2); | |||
mission.setInspectionType(InspectionTypeEnum.AIRPORT.getCode()); | |||
mission.setAirportId(request.getAirportId()); | |||
mission.setAirportName(request.getAirportName()); |