| | |
| | | package com.ard.work.service.impl; |
| | | |
| | | import com.ard.common.constant.CacheConstants; |
| | | import com.ard.common.core.redis.RedisCache; |
| | | import com.ard.common.exception.ServiceException; |
| | | import com.ard.common.utils.StringUtils; |
| | | import com.ard.data.noflyzone.domain.ArdNoFlyZone; |
| | | import com.ard.data.noflyzone.domain.Vertex; |
| | | import com.ard.data.noflyzone.service.IArdNoFlyZoneService; |
| | | import com.ard.data.noflyzone.utils.NoFlyZoneUtils; |
| | | import com.ard.common.exception.ControlException; |
| | | import com.ard.work.aspect.annotation.CheckControlRight; |
| | | import com.ard.work.aspect.annotation.CheckDroneStatus; |
| | | import com.ard.work.aspect.annotation.CheckNoFlyZone; |
| | | import com.ard.work.aspect.annotation.CheckTakeoffAltitude; |
| | | import com.ard.work.component.forest.TyClient; |
| | | import com.ard.work.component.netty.TcpClientUtil; |
| | |
| | | import com.ard.work.service.IArdServerInfoService; |
| | | import com.ard.work.service.ITyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private IArdDroneInfoService ardDroneService; |
| | | @Resource |
| | | private IArdNoFlyZoneService ardNoFlyZoneService; |
| | | @Resource |
| | | private TyClient tyClient; |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * 获取边缘服务器token信息 |
| | |
| | | public BoxStreamUrlReceiver getBoxLiveUrl(String boxSn) { |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | } |
| | | |
| | | |
| | | TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(ardDroneInfo.getServerId(), |
| | | boxSn); |
| | | return boxLiveUrl == null ? null : boxLiveUrl.getContent(); |
| | |
| | | String boxSn = boxHistoryDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行起飞指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(ardDroneInfo.getServerId(), |
| | | boxHistoryDTO); |
| | |
| | | String boxSn = boxPhotosDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行起飞指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(ardDroneInfo.getServerId(), |
| | | boxPhotosDTO); |
| | |
| | | String boxSn = boxSettingsDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(ardDroneInfo.getServerId(), boxSettingsDTO); |
| | | return result.getState() == 1; |
| | |
| | | String boxSn = returnHeightSettingDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ReturnHeightSettingCmd returnHeightSettingCmd = new ReturnHeightSettingCmd(returnHeightSettingDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), returnHeightSettingCmd); |
| | |
| | | String boxSn = returnPointSettingDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ReturnPointSettingCmd returnPointSettingCmd = new ReturnPointSettingCmd(returnPointSettingDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), returnPointSettingCmd); |
| | |
| | | String boxSn = videoStreamSettingDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | VideoStreamSettingCmd videoStreamSettingCmd = new VideoStreamSettingCmd(videoStreamSettingDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), videoStreamSettingCmd); |
| | |
| | | String boxSn = angleControlDto.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | AngleControlCmd controlAngleCommand = new AngleControlCmd(angleControlDto); |
| | | this.sendMessage(ardDroneInfo.getServerId(), controlAngleCommand); |
| | |
| | | String boxSn = absAngleControlDto.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | AbsAngleControlCmd absAngleControlCommand = new AbsAngleControlCmd(absAngleControlDto); |
| | | this.sendMessage(ardDroneInfo.getServerId(), absAngleControlCommand); |
| | |
| | | String boxSn = speedControlDto.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | SpeedControlCmd speedControlCommand = new SpeedControlCmd(speedControlDto); |
| | | this.sendMessage(ardDroneInfo.getServerId(), speedControlCommand); |
| | |
| | | /** |
| | | * 设置相机模式 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean updateCameraMode(CameraModeDTO cameraModeDTO) { |
| | | String boxSn = cameraModeDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | CameraModeCmd cameraModeCommand = new CameraModeCmd(cameraModeDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), cameraModeCommand); |
| | |
| | | /** |
| | | * 拍照 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean capturePic(CapturePicDTO capturePicDto) { |
| | | String boxSn = capturePicDto.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | //设置相机模式为拍照模式 |
| | | updateCameraMode(CameraModeDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build()); |
| | |
| | | /** |
| | | * 录像 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean record(RecordDTO recordDto) { |
| | | String boxSn = recordDto.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | BaseCmd baseCmd; |
| | | if (recordDto.getIsRecord()) { |
| | |
| | | String boxSn = zoomDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ZoomCmd zoomCommand = new ZoomCmd(zoomDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), zoomCommand); |
| | |
| | | String boxSn = zoomToLevelDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ZoomToLevelCmd zoomToLevelCommand = new ZoomToLevelCmd(zoomToLevelDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), zoomToLevelCommand); |
| | |
| | | /** |
| | | * 切换摄像头 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean switchCamera(SwitchCameraDTO switchCameraDTO) { |
| | | String boxSn = switchCameraDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | SwitchCameraCmd switchCameraCmd = new SwitchCameraCmd(switchCameraDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), switchCameraCmd); |
| | |
| | | /** |
| | | * 切换视频源 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean switchSource(SwitchSourceDTO switchSourceDTO) { |
| | | String boxSn = switchSourceDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | SwitchSourceCmd switchSourceCmd = new SwitchSourceCmd(switchSourceDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), switchSourceCmd); |
| | |
| | | /** |
| | | * 打开或关闭照片回传 |
| | | */ |
| | | @CheckControlRight(UavControlType.PAYLOAD) |
| | | @Override |
| | | public Boolean photoReturnToggle(PhotoReturnToggleDTO photoReturnToggleDTO) { |
| | | String boxSn = photoReturnToggleDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | PhotoReturnToggleCmd photoReturnToggleCmd = new PhotoReturnToggleCmd(photoReturnToggleDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), photoReturnToggleCmd); |
| | |
| | | /** |
| | | * 切换无人机控制权 |
| | | */ |
| | | @CheckDroneStatus |
| | | @Override |
| | | public Boolean switchUavControl(SwitchUavControlDTO switchUavControlDTO) { |
| | | String boxSn = switchUavControlDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | SwitchUavControlCmd switchUavControlCmd = new SwitchUavControlCmd(switchUavControlDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), switchUavControlCmd); |
| | |
| | | String boxSn = takeOffDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | TakeOffCmd takeOffCmd = new TakeOffCmd(takeOffDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), takeOffCmd); |
| | |
| | | String boxSn = returnHomeDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ReturnHomeCmd returnHomeCmd = new ReturnHomeCmd(returnHomeDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), returnHomeCmd); |
| | |
| | | String boxSn = returnHomeCancelDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | ReturnHomeCancelCmd returnHomeCancelCmd = new ReturnHomeCancelCmd(returnHomeCancelDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), returnHomeCancelCmd); |
| | |
| | | String boxSn = landDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | LandCmd landCmd = new LandCmd(landDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), landCmd); |
| | |
| | | String boxSn = landCancelDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | LandCancelCmd landCancelCmd = new LandCancelCmd(landCancelDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), landCancelCmd); |
| | |
| | | String boxSn = landForcedDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | LandForcedCmd landForcedCmd = new LandForcedCmd(landForcedDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), landForcedCmd); |
| | |
| | | String boxSn = flyControlDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | FlyControlCmd flyControlCmd = new FlyControlCmd(flyControlDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), flyControlCmd); |
| | |
| | | */ |
| | | @CheckControlRight(UavControlType.FLY) |
| | | @CheckTakeoffAltitude(minAltitude = 30.0) |
| | | @CheckNoFlyZone |
| | | @Override |
| | | public Boolean flyPointControl(FlyPointControlDTO flyPointControlDTO) { |
| | | String boxSn = flyPointControlDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | } |
| | | // 判断目标点是否经过禁飞区 |
| | | List<ArdNoFlyZone> ardNoFlyZones = ardNoFlyZoneService.selectArdNoFlyZoneList(new ArdNoFlyZone()); |
| | | if (!ardNoFlyZones.isEmpty()) { |
| | | Vertex vertex = new Vertex(flyPointControlDTO.getLongitude(), flyPointControlDTO.getLatitude()); |
| | | boolean inNoFlyZones = NoFlyZoneUtils.isInNoFlyZones(vertex, ardNoFlyZones); |
| | | if (inNoFlyZones) { |
| | | throw new ServiceException("目标点在禁飞区内,无法执行指令, boxSn: " + boxSn); |
| | | } |
| | | } |
| | | |
| | | FlyPointControlCmd flyPointControlCmd = new FlyPointControlCmd(flyPointControlDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCmd); |
| | | return true; |
| | |
| | | String boxSn = flyPointControlCancelDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | } |
| | | |
| | | |
| | | FlyPointControlCancelCmd flyPointControlCancelCmd = new FlyPointControlCancelCmd(flyPointControlCancelDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCancelCmd); |
| | | return true; |
| | |
| | | String boxSn = emeragencyBrakeDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | } |
| | | |
| | | |
| | | EmergencyBrakeCmd emergencyBrakeCmd = new EmergencyBrakeCmd(emeragencyBrakeDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), emergencyBrakeCmd); |
| | | return true; |
| | |
| | | String boxSn = speakModeSwitchDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | SpeakModeSwitchCmd speakModeSwitchCmd = new SpeakModeSwitchCmd(speakModeSwitchDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), speakModeSwitchCmd); |
| | |
| | | String boxSn = textSpeakDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | TextSpeakCmd textSpeakCmd = new TextSpeakCmd(textSpeakDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), textSpeakCmd); |
| | |
| | | String boxSn = realSpeakDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | RealSpeakCmd realSpeakCmd = new RealSpeakCmd(realSpeakDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), realSpeakCmd); |
| | |
| | | String boxSn = recordSpeakDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | RecordSpeakCmd recordSpeakCmd = new RecordSpeakCmd(recordSpeakDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), recordSpeakCmd); |
| | |
| | | String boxSn = volumeSettingDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | VolumeSettingCmd volumeSettingCmd = new VolumeSettingCmd(volumeSettingDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), volumeSettingCmd); |
| | |
| | | String boxSn = loopSettingDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | LoopSettingCmd loopSettingCmd = new LoopSettingCmd(loopSettingDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), loopSettingCmd); |
| | |
| | | String boxSn = stopSpeakDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | StopSpeakCmd stopSpeakCmd = new StopSpeakCmd(stopSpeakDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), stopSpeakCmd); |
| | |
| | | /** |
| | | * 航线上传 |
| | | */ |
| | | @CheckControlRight(UavControlType.FLY) |
| | | @Override |
| | | public Boolean wayLineUpload(WayLineUploadDTO wayLineUploadDTO) { |
| | | String boxSn = wayLineUploadDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | //wayLineUploadDTO.setWayLineData(this.CreatePlanLineData());//设置航线数据 |
| | | WayLineUploadCmd wayLineUploadCmd = new WayLineUploadCmd(wayLineUploadDTO); |
| | |
| | | String boxSn = wayLineBeginDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | WayLineBeginCmd wayLineBeginCmd = new WayLineBeginCmd(wayLineBeginDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), wayLineBeginCmd); |
| | |
| | | String boxSn = wayLinePauseDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | WayLinePauseCmd wayLinePauseCmd = new WayLinePauseCmd(wayLinePauseDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), wayLinePauseCmd); |
| | |
| | | String boxSn = wayLineResumeDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | WayLineResumeCmd wayLineResumeCmd = new WayLineResumeCmd(wayLineResumeDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), wayLineResumeCmd); |
| | |
| | | String boxSn = wayLineEndDTO.getBoxSn(); |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | if (ardDroneInfo == null) { |
| | | throw new ServiceException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | // ✅ 判断无人机是否在线 |
| | | if (!isDroneOnline(boxSn)) { |
| | | throw new ServiceException("无人机离线,无法执行指令, boxSn: " + boxSn); |
| | | throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn); |
| | | } |
| | | WayLineEndCmd wayLineEndCmd = new WayLineEndCmd(wayLineEndDTO); |
| | | this.sendMessage(ardDroneInfo.getServerId(), wayLineEndCmd); |
| | |
| | | private void sendMessage(String key, BaseCmd msg) { |
| | | TcpClientUtil.sendMessage(key, msg); |
| | | } |
| | | |
| | | // 判断无人机是否在线 |
| | | private boolean isDroneOnline(String boxSn) { |
| | | if (StringUtils.isBlank(boxSn)) { |
| | | return false; |
| | | } |
| | | Object obj = redisCache.getCacheObject(CacheConstants.UAV_ONLINE_KEY + boxSn); |
| | | return obj != null; |
| | | } |
| | | |
| | | } |