| | |
| | | package com.ard.route.service.impl; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.ard.common.exception.ControlException; |
| | | import com.ard.common.utils.DateUtils; |
| | | import com.ard.common.utils.SecurityUtils; |
| | | import com.ard.common.utils.file.FileUtils; |
| | | import com.ard.common.utils.uuid.IdUtils; |
| | | import com.ard.data.noflyzone.domain.ArdNoFlyZone; |
| | |
| | | import com.ard.data.noflyzone.service.IArdNoFlyZoneService; |
| | | import com.ard.data.noflyzone.utils.NoFlyZoneUtils; |
| | | import com.ard.framework.web.service.TokenService; |
| | | import com.ard.inspection.domain.ArdPointCloud; |
| | | import com.ard.inspection.mapper.ArdPointCloudMapper; |
| | | import com.ard.oss.model.MinioUploadResult; |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.route.domain.djuav.ActionGroupReq; |
| | |
| | | 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.ArdRouteCloud; |
| | | import com.ard.route.domain.route.ArdRouteInfo; |
| | | import com.ard.route.domain.route.ArdRouteMission; |
| | | import com.ard.route.domain.vo.KmzResultVo; |
| | | import com.ard.route.mapper.ArdRouteCloudMapper; |
| | | import com.ard.route.mapper.ArdRouteInfoMapper; |
| | | import com.ard.route.mapper.ArdRouteMissionMapper; |
| | | import com.ard.route.service.IArdRouteInfoService; |
| | |
| | | import com.ard.work.service.ITyService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ard.common.utils.SecurityUtils.getUsername; |
| | | import static com.ard.route.enums.kml.DroneEnumValueEnums.M350_RTK; |
| | | import static com.ard.route.util.InitializationUtils.divided_23; |
| | | import static com.ard.route.util.InitializationUtils.divided23; |
| | | import static com.ard.route.util.ToolUtils.*; |
| | | import static com.ard.route.util.UavRouteReqUtils.buildWayLineUploadDTO; |
| | | import static com.ard.route.util.UavRouteReqUtils.fileConversionEntity; |
| | |
| | | @Autowired |
| | | private ArdRouteMissionMapper ardRouteMissionMapper; |
| | | |
| | | @Autowired |
| | | private ArdPointCloudMapper ardPointCloudMapper; |
| | | |
| | | @Autowired |
| | | private ArdRouteCloudMapper ardRouteCloudMapper; |
| | | |
| | | @Resource |
| | | private IArdNoFlyZoneService ardNoFlyZoneService; |
| | | |
| | |
| | | ArdRouteInfo ardRouteInfo = ardRouteInfoMapper.selectArdRouteInfoById(id); |
| | | try { |
| | | if (ardRouteInfo != null) { |
| | | if (ardRouteInfo.getRouteData() != null){ |
| | | ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData())); |
| | | if ("3".equals(ardRouteInfo.getType())) { |
| | | if (ardRouteInfo.getRouteData() != null){ |
| | | UavRouteReq uavRouteReq = new UavRouteReq(); |
| | | BeanUtils.copyProperties(deserialize(ardRouteInfo.getRouteData()), uavRouteReq); |
| | | ardRouteInfo.setUavRouteReq(uavRouteReq); |
| | | } |
| | | } else { |
| | | if (ardRouteInfo.getRouteData() != null){ |
| | | ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData())); |
| | | } |
| | | } |
| | | if (ardRouteInfo.getCloudData() != null){ |
| | | ardRouteInfo.setArdPointCloudList(deserializeLs(ardRouteInfo.getCloudData())); |
| | | } |
| | | } |
| | | } catch (IOException | ClassNotFoundException e) { |
| | |
| | | */ |
| | | @Override |
| | | public String insertArdRouteInfo(ArdRouteInfo ardRouteInfo) { |
| | | if ("3".equals(ardRouteInfo.getType())) { |
| | | checkRouteMissionStatus(ardRouteInfo,"1"); |
| | | checkRouteMissionStatus(ardRouteInfo,"2"); |
| | | } |
| | | checkRouteMissionStatus(ardRouteInfo,"1"); |
| | | checkRouteMissionStatus(ardRouteInfo,"2"); |
| | | ardRouteInfo.setId(IdUtils.simpleUUID()); |
| | | ardRouteInfo.setCreateTime(DateUtils.getNowDate()); |
| | | ardRouteInfo.setUpdateTime(DateUtils.getNowDate()); // 修改时间,用于排序 |
| | | if (ardRouteInfo.getGroupId() == null){ |
| | | ardRouteInfo.setGroupId("0"); |
| | | } |
| | | if ("3".equals(ardRouteInfo.getType())){ |
| | | ardRouteInfo.getUavRouteReq().setHeightMode("EGM96"); |
| | | }else { |
| | | ardRouteInfo.getUavRouteReq().setHeightMode("relativeToStartPoint"); |
| | | } |
| | | ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft())); |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(),ardRouteInfo.getName()); |
| | | zoomProcessing(ardRouteInfo); |
| | | ardRouteInfo.setPath(kmzResult.getPath()); |
| | | ardRouteInfo.setReadOnly("0"); |
| | | insertRoutePointCloud(ardRouteInfo); |
| | | ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo)); |
| | | return kmzResult.getPath(); |
| | | } |
| | | |
| | | /** |
| | | * 新增航信信息时,修改点云数据 |
| | | * 同时增加航线与点云关联关系表数据 |
| | | */ |
| | | private void insertRoutePointCloud(ArdRouteInfo ardRouteInfo) { |
| | | List<ArdRouteCloud> cloudList = new ArrayList<>(); |
| | | if (ardRouteInfo.getArdPointCloudList() != null){ |
| | | for (ArdPointCloud cloudId : ardRouteInfo.getArdPointCloudList()) { |
| | | ArdRouteCloud cloud = new ArdRouteCloud(); |
| | | cloud.setRouteId(ardRouteInfo.getId()); |
| | | cloud.setCloudId(cloudId.getId()); |
| | | cloudId.setAssociatedState("1"); |
| | | cloudList.add(cloud); |
| | | cloudId.setUpdateTime(DateUtils.getNowDate()); |
| | | ardPointCloudMapper.updateArdPointCloud(cloudId); |
| | | } |
| | | ardRouteCloudMapper.batchRouteCloud(cloudList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | validateForCreate(mission); |
| | | break; |
| | | case "2": |
| | | bindRoute(mission, ardRouteInfo); |
| | | bindRoute(mission,ardRouteInfo); |
| | | break; |
| | | case "3": |
| | | executeMission(mission); |
| | | executeMission(mission,ardRouteInfo); |
| | | break; |
| | | default: |
| | | throw new RuntimeException("不支持的操作类型!!!"); |
| | | } |
| | | }else { |
| | | throw new RuntimeException("航线任务不存在!!!"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void bindRoute(ArdRouteMission mission, ArdRouteInfo routeInfo) { |
| | | if (!"0".equals(mission.getRouteId())) { |
| | | if (mission.getRouteId() != null) { |
| | | throw new RuntimeException("航线任务下已绑定航线,不可创建新航线信息!!!"); |
| | | } |
| | | mission.setRouteId(routeInfo.getId()); |
| | | ardRouteMissionMapper.updateArdRouteMission(mission); |
| | | } |
| | | |
| | | private void executeMission(ArdRouteMission mission) { |
| | | private void executeMission(ArdRouteMission mission,ArdRouteInfo ardRouteInfo) { |
| | | if ("0".equals(mission.getExecuteStatus())) { |
| | | mission.setRouteId(ardRouteInfo.getId()); |
| | | mission.setExecuteStatus("1"); |
| | | mission.setExecuteBy(getUsername()); |
| | | mission.setExecuteName(SecurityUtils.getUsername()); |
| | | mission.setExecuteTime(DateUtils.getNowDate()); |
| | | mission.setUpdateTime(DateUtils.getNowDate()); |
| | | ardRouteMissionMapper.updateArdRouteMission(mission); |
| | |
| | | for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) { |
| | | for (PointActionReq action : actionGroupReq.getActions()) { |
| | | if (action.getZoom() != null){ |
| | | action.setZoom(divided_23(action.getZoom())); |
| | | action.setZoom(divided23(action.getZoom())); |
| | | } |
| | | } |
| | | } |
| | |
| | | private ArdRouteInfo dataProcessing(ArdRouteInfo ardRouteInfo) { |
| | | // 航线数据 |
| | | byte[] routeData = null; |
| | | byte[] cloudData = null; |
| | | try { |
| | | if (ardRouteInfo.getUavRouteReq() != null){ |
| | | routeData = serialize(ardRouteInfo.getUavRouteReq()); |
| | | } |
| | | if (ardRouteInfo.getArdPointCloudList() != null){ |
| | | cloudData = serialize(ardRouteInfo.getArdPointCloudList()); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | ardRouteInfo.setRouteData(routeData); |
| | | ardRouteInfo.setCloudData(cloudData); |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | return ardRouteInfo; |
| | | } |
| | |
| | | ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(id); |
| | | try { |
| | | route.setUavRouteReq((UavRouteReq) deserialize(route.getRouteData())); |
| | | if (route.getCloudData() != null){ |
| | | route.setArdPointCloudList(deserializeLs(route.getCloudData())); |
| | | } |
| | | } catch (IOException | ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | WaylineInfo WaylineInfo = new WaylineInfo(); |
| | | WaylineInfo.setBoxSn(boxSn); |
| | | WaylineInfo.setWaylineId(route.getId()); |
| | | WaylineInfo.setRouteName(route.getName()); |
| | | UavWaylineCache.put(WaylineInfo); |
| | | // 4.调用接口 |
| | | tyService.wayLineUpload(wayLineUploadDTO); |
| | |
| | | @Override |
| | | public Boolean routeBegins(String id,String boxSn) { |
| | | ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(id); |
| | | // 判断是否循环航线 |
| | | if (null != route && "0".equals(route.getIsLoop())){ |
| | | deleteArdRouteInfoById(id); |
| | | if ("3".equals(route.getType())) { |
| | | checkRouteMissionStatus(route,"3"); |
| | | if (null != route){ |
| | | // 判断是否循环航线 |
| | | if ("0".equals(route.getIsLoop())){ |
| | | deleteArdRouteInfoById(id); |
| | | } |
| | | checkRouteMissionStatus(route,"3"); |
| | | } |
| | | WayLineBeginDTO wayLineBeginDTO = new WayLineBeginDTO(boxSn); |
| | | tyService.wayLineBegin(wayLineBeginDTO); |