| | |
| | | import com.ard.oss.model.MinioUploadResult; |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.route.domain.route.ArdRouteInformation; |
| | | import com.ard.route.domain.vo.KmzResultVo; |
| | | import com.ard.route.service.UavRouteService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ard.route.mapper.ArdRouteInformationMapper; |
| | | import com.ard.route.service.IArdRouteInformationService; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ard.route.util.ToolUtils.extractFilePath; |
| | | import static com.ard.route.util.ToolUtils.getFileNameWithoutExtension; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private OssServiceContext ossService; |
| | | |
| | | @Autowired |
| | | private UavRouteService routeService; |
| | | |
| | | /** |
| | | * 查询航线(kmz) |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertArdRouteInformation(ArdRouteInformation ardRouteInformation) { |
| | | public String insertArdRouteInformation(ArdRouteInformation ardRouteInformation) { |
| | | ardRouteInformation.setId(IdUtils.simpleUUID()); |
| | | ardRouteInformation.setCreateTime(DateUtils.getNowDate()); |
| | | return ardRouteInformationMapper.insertArdRouteInformation(ardRouteInformation); |
| | | if (ardRouteInformation.getFolderId() == null){ |
| | | ardRouteInformation.setFolderId("0"); |
| | | } |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInformation.getUavRouteReq(), ardRouteInformation.getFileName()); |
| | | ardRouteInformationMapper.insertArdRouteInformation(assembly(ardRouteInformation,kmzResult)); |
| | | return kmzResult.getUpPath(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public int updateArdRouteInformation(ArdRouteInformation ardRouteInformation) { |
| | | ardRouteInformation.setUpdateTime(DateUtils.getNowDate()); |
| | | return ardRouteInformationMapper.updateArdRouteInformation(ardRouteInformation); |
| | | KmzResultVo kmzResult = new KmzResultVo(); |
| | | // 获取源文件名字 |
| | | ArdRouteInformation route = ardRouteInformationMapper.selectArdRouteInformationById(ardRouteInformation.getId()); |
| | | if (route.getFileName().equals(ardRouteInformation.getFileName())) { |
| | | kmzResult = routeService.updateKmz(ardRouteInformation.getUavRouteReq(), ardRouteInformation.getFileName()); |
| | | }else { |
| | | kmzResult = routeService.updateKmzNew(ardRouteInformation.getUavRouteReq(), route.getFileName(),ardRouteInformation.getFileName()); |
| | | } |
| | | if ("更新航线kmz文件失败".equals(kmzResult.getData())) { |
| | | return 0; |
| | | } |
| | | return ardRouteInformationMapper.updateArdRouteInformation(assembly(ardRouteInformation,kmzResult)); |
| | | } |
| | | |
| | | //组装数据 |
| | | private ArdRouteInformation assembly(ArdRouteInformation information,KmzResultVo kmzResult){ |
| | | information.setFileNameNew(kmzResult.getFileNameNew()); |
| | | information.setMinioUpPath(kmzResult.getMinioUpPath()); |
| | | information.setUpPath(kmzResult.getUpPath()); |
| | | information.setUpFileSize(kmzResult.getUpFileSize()); |
| | | return information; |
| | | } |
| | | |
| | | /** |
| | |
| | | // 删除航线(kmz)文件 |
| | | for (String id : ids) { |
| | | ArdRouteInformation information = ardRouteInformationMapper.selectArdRouteInformationById(id); |
| | | ossService.deleteObject("kmz", information.getUpPath()); |
| | | ossService.deleteObject("kmz", information.getMinioUpPath()); |
| | | } |
| | | return ardRouteInformationMapper.deleteArdRouteInformationByIds(ids); |
| | | } |
| | |
| | | ArdRouteInformation information = new ArdRouteInformation(); |
| | | information.setFileName(file.getOriginalFilename()); |
| | | information.setFileNameNew(getFileNameWithoutExtension(url)); |
| | | information.setMinioUpPath(extractFilePath(url)); |
| | | information.setUpPath(url); |
| | | information.setUpFileSize((double) file.getSize()); |
| | | insertArdRouteInformation(information); |
| | | insertRouteInformation(information); |
| | | return MinioUploadResult.builder() |
| | | .url(url) |
| | | .newFileName(FileUtils.getName(url)) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据文件名称查询航线信息 |
| | | * |
| | | * @param name 文件名称 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public ArdRouteInformation selectArdRouteInformationByName(String name) { |
| | | return ardRouteInformationMapper.selectArdRouteInformationByName(name); |
| | | } |
| | | |
| | | /** |
| | | * 修改航线分组ID |
| | | * |
| | | * @param id ID |
| | | * @param folderId 分组ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateRouteInformationFolderId(String id, String folderId) { |
| | | return ardRouteInformationMapper.updateRouteInformationFolderId(id, folderId); |
| | | } |
| | | |
| | | /** |
| | | * 数据新增航线信息 |
| | | */ |
| | | private void insertRouteInformation(ArdRouteInformation ardRouteInformation){ |
| | | ardRouteInformation.setId(IdUtils.simpleUUID()); |
| | | ardRouteInformation.setCreateTime(DateUtils.getNowDate()); |
| | | ardRouteInformationMapper.insertArdRouteInformation(ardRouteInformation); |
| | | } |
| | | |
| | | } |