| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ard.route.util.ToolUtils.*; |
| | | import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity; |
| | | |
| | | /** |
| | | * 航线(kmz)Service业务层处理 |
| | |
| | | } 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"); |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | 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()); |
| | | } |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | 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().getRoutePointList() != null) { |
| | | return ardRouteInfo.getUavRouteReq().getRoutePointList().size(); |
| | | 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())); |
| | | ossDockService.deleteObject("kmz", subStringMinioUrlName(information.getPath1())); |
| | | 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); |
| | | String urlDock = ossDockService.upload("kmz",file); |
| | | ArdRouteInfo information = new ArdRouteInfo(); |
| | | information.setName(file.getOriginalFilename()); |
| | | information.setPath(url); |
| | | information.setPath1(urlDock); |
| | | information.setGroupId("0"); // 默认分组 |
| | | information.setReadOnly("1"); // 默认只读 |
| | | // 生成kmz文件实体类加工 |
| | | |
| | | // 增加航线实体类信息 |
| | | insertRouteInfomation(information); |
| | | 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)) |
| | |
| | | ardRouteInfo.setId(IdUtils.simpleUUID()); |
| | | ardRouteInfo.setCreateTime(DateUtils.getNowDate()); |
| | | ardRouteInfo.setUpdateTime(DateUtils.getNowDate()); |
| | | ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo); |
| | | ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo)); |
| | | } |
| | | |
| | | /** |