| | |
| | | import com.ard.data.noflyzone.utils.NoFlyZoneUtils; |
| | | import com.ard.oss.model.MinioUploadResult; |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.ossdock.service.impl.OssDockServiceContext; |
| | | import com.ard.route.domain.djuav.ActionGroupReq; |
| | | import com.ard.route.domain.djuav.PointActionReq; |
| | | import com.ard.route.domain.djuav.RoutePointReq; |
| | | import com.ard.route.domain.djuav.UavRouteReq; |
| | | import com.ard.route.domain.dto.ArdNoflyDto; |
| | | import com.ard.route.domain.route.ArdRouteInfo; |
| | | import com.ard.route.domain.sixhe.ArdRouteChange; |
| | | import com.ard.route.domain.vo.KmzResultVo; |
| | | import com.ard.route.mapper.ArdRouteInfoMapper; |
| | | import com.ard.route.service.IArdRouteInfoService; |
| | | import com.ard.route.service.UavRouteService; |
| | | import com.ard.work.domain.cache.UavWaylineCache; |
| | | import com.ard.work.domain.dto.state.PointData; |
| | | import com.ard.work.domain.dto.wayline.*; |
| | | import com.ard.work.service.ITyService; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ard.route.util.ToolUtils.*; |
| | | import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity; |
| | | |
| | | /** |
| | | * 航线(kmz)Service业务层处理 |
| | |
| | | |
| | | @Autowired |
| | | private OssServiceContext ossService; |
| | | |
| | | @Autowired |
| | | private OssDockServiceContext ossDockService; |
| | | |
| | | @Autowired |
| | | private UavRouteService routeService; |
| | |
| | | } catch (IOException | ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) { |
| | | routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt")); |
| | | } |
| | | return ardRouteInfo; |
| | | } |
| | | |
| | |
| | | }else if ("0".equals(ardRouteInfo.getOrderByTime())) { |
| | | ardRouteInfo.setOrderByTime("ASC"); |
| | | } |
| | | // List<ArdRouteInfo> list = ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo); |
| | | // for (ArdRouteInfo routeInfo : list) { |
| | | // for (RoutePointReq routePointReq : routeInfo.getUavRouteReq().getRoutePointList()) { |
| | | // routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt")); |
| | | // } |
| | | // } |
| | | return ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo); |
| | | } |
| | | |
| | |
| | | if (ardRouteInfo.getGroupId() == null){ |
| | | ardRouteInfo.setGroupId("0"); |
| | | } |
| | | // 航线数据 |
| | | byte[] routeData; |
| | | try { |
| | | routeData = serialize(ardRouteInfo.getUavRouteReq()); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft())); |
| | | ardRouteInfo.setRouteData(routeData); |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName()); |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(),ardRouteInfo.getName()); |
| | | ardRouteInfo.setPath(kmzResult.getPath()); |
| | | ardRouteInfo.setReadOnly("0"); |
| | | ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo); |
| | | ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo)); |
| | | return kmzResult.getPath(); |
| | | } |
| | | |
| | |
| | | KmzResultVo kmzResult; |
| | | // 获取源文件名字 |
| | | ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(ardRouteInfo.getId()); |
| | | if (route.getName().equals(ardRouteInfo.getName())) { |
| | | kmzResult = routeService.updateKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName()); |
| | | }else { |
| | | kmzResult = routeService.updateKmzNew(ardRouteInfo.getUavRouteReq(), route.getName(), ardRouteInfo.getName()); |
| | | } |
| | | // 先删除航线 |
| | | delOssService(route); |
| | | // 再生成航线 |
| | | kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName()); |
| | | if ("更新航线kmz文件失败".equals(kmzResult.getData())) { |
| | | return 0; |
| | | } |
| | | ardRouteInfo.setPath(kmzResult.getPath()); |
| | | } |
| | | return ardRouteInfoMapper.updateArdRouteInfo(ardRouteInfo); |
| | | ardRouteInfo.setReadOnly("0"); |
| | | return ardRouteInfoMapper.updateArdRouteInfo(dataProcessing(ardRouteInfo)); |
| | | } |
| | | |
| | | // 新增信息加工 |
| | | private ArdRouteInfo dataProcessing(ArdRouteInfo ardRouteInfo) { |
| | | // 航线数据 |
| | | byte[] routeData = null; |
| | | try { |
| | | if (ardRouteInfo.getUavRouteReq() != null){ |
| | | routeData = serialize(ardRouteInfo.getUavRouteReq()); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | ardRouteInfo.setRouteData(routeData); |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | return ardRouteInfo; |
| | | } |
| | | |
| | | // 获取行点总数 |
| | | private Integer getPointCount(ArdRouteInfo ardRouteInfo) { |
| | | if (ardRouteInfo.getUavRouteReq() != null){ |
| | | if (ardRouteInfo.getUavRouteReq().getRoutePointList() != null) { |
| | | return ardRouteInfo.getUavRouteReq().getRoutePointList().size(); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | // 删除航线(kmz)文件 |
| | | for (String id : ids) { |
| | | ArdRouteInfo information = ardRouteInfoMapper.selectArdRouteInfoById(id); |
| | | ossService.deleteObject("kmz", subStringMinioUrlName(information.getPath())); |
| | | delOssService(information); |
| | | } |
| | | return ardRouteInfoMapper.deleteArdRouteInfoByIds(ids); |
| | | } |
| | | |
| | | // 删除minio文件 |
| | | private void delOssService(ArdRouteInfo information){ |
| | | if (information.getPath() != null){ |
| | | ossService.deleteObject("kmz", subStringMinioUrlName(information.getPath())); |
| | | } |
| | | if (information.getPath1() != null){ |
| | | ossDockService.deleteObject("kmz", subStringMinioUrlName(information.getPath1())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public MinioUploadResult uploadArdRouteInfo(MultipartFile file) { |
| | | try { |
| | | // 增加航线实体类信息 |
| | | UavRouteReq uavRouteReq = fileConversionEntity(file); |
| | | ArdRouteInfo ardRouteInfo = new ArdRouteInfo(); |
| | | if (uavRouteReq != null){ |
| | | ardRouteInfo.setUavRouteReq(uavRouteReq); |
| | | ardRouteInfo.setType(templateTypeData(uavRouteReq)); |
| | | ardRouteInfo.setAircraft(droneTypeData(uavRouteReq)); |
| | | } |
| | | // 判断禁飞区 |
| | | // List<RoutePointReq> routePointList = ardRouteInfo.getUavRouteReq().getRoutePointList(); |
| | | // for (RoutePointReq routePointReq : routePointList) { |
| | | // ArdNoflyDto ardNoflyDto = new ArdNoflyDto(); |
| | | // ardNoflyDto.setCurrent(new Vertex(routePointReq.getLongitude(), routePointReq.getLatitude())); |
| | | // verifyNoFlyZone(ardNoflyDto); |
| | | // } |
| | | String url = ossService.upload("kmz",file); |
| | | ArdRouteInfo information = new ArdRouteInfo(); |
| | | information.setName(file.getOriginalFilename()); |
| | | information.setPath(url); |
| | | information.setGroupId("0"); // 默认分组 |
| | | information.setReadOnly("1"); // 默认只读 |
| | | insertRouteInfomation(information); |
| | | String urlDock = ossDockService.upload("kmz",file); |
| | | ardRouteInfo.setName(file.getOriginalFilename()); |
| | | ardRouteInfo.setPath(url); |
| | | ardRouteInfo.setPath1(urlDock); |
| | | ardRouteInfo.setGroupId("0"); // 默认分组 |
| | | ardRouteInfo.setReadOnly("1"); // 默认只读 |
| | | insertRouteInfomation(ardRouteInfo); |
| | | return MinioUploadResult.builder() |
| | | .url(url) |
| | | .newFileName(FileUtils.getName(url)) |
| | |
| | | // 2.将航线信息转换成对应实体类 |
| | | WayLineUploadDTO wayLineUploadDTO = buildWayLineUploadDTO(route); |
| | | wayLineUploadDTO.setBoxSn(boxSn); |
| | | // 3.调用接口 |
| | | // 3.缓存航线信息 |
| | | WaylineInfo WaylineInfo = new WaylineInfo(); |
| | | WaylineInfo.setBoxSn(boxSn); |
| | | WaylineInfo.setWaylineId(route.getId()); |
| | | UavWaylineCache.put(WaylineInfo); |
| | | // 4.调用接口 |
| | | tyService.wayLineUpload(wayLineUploadDTO); |
| | | return true; |
| | | } |
| | |
| | | if (autoFlightSpeed != null){ |
| | | planLineData.setAutoSpeed(8); |
| | | } |
| | | if (globalTransitionalSpeed != null){ |
| | | planLineData.setMaxSpeed(15); |
| | | } |
| | | planLineData.setMaxSpeed(15); |
| | | // if (globalTransitionalSpeed != null){ |
| | | // planLineData.setMaxSpeed(15); |
| | | // } |
| | | if (exitOnRcLostAction != null){ |
| | | planLineData.setFinishedAction(1); |
| | | } |
| | |
| | | if (height != null){ |
| | | pointData.setHeight(height.floatValue()); |
| | | } |
| | | Double longitude = routePointReq.getLatitude(); |
| | | Double longitude = routePointReq.getLongitude(); |
| | | if (longitude != null){ |
| | | pointData.setLng(longitude.floatValue()); |
| | | } |
| | | Double latitude = routePointReq.getLongitude(); |
| | | Double latitude = routePointReq.getLatitude(); |
| | | if (latitude != null){ |
| | | pointData.setLat(latitude.floatValue()); |
| | | } |
| | |
| | | private void insertRouteInfomation(ArdRouteInfo ardRouteInfo){ |
| | | ardRouteInfo.setId(IdUtils.simpleUUID()); |
| | | ardRouteInfo.setCreateTime(DateUtils.getNowDate()); |
| | | ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo); |
| | | ardRouteInfo.setUpdateTime(DateUtils.getNowDate()); |
| | | ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo)); |
| | | } |
| | | |
| | | /** |