| | |
| | | |
| | | import java.util.List; |
| | | import com.ard.common.utils.DateUtils; |
| | | import com.ard.common.utils.file.FileUtils; |
| | | import com.ard.common.utils.uuid.IdUtils; |
| | | 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; |
| | | |
| | | /** |
| | | * 航线(kmz)Service业务层处理 |
| | |
| | | |
| | | @Autowired |
| | | private ArdRouteInformationMapper ardRouteInformationMapper; |
| | | |
| | | @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.getUavRouteReq() != null){ |
| | | |
| | | } |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInformation.getUavRouteReq(), ardRouteInformation.getFileName()); |
| | | // 将KmzResult中的信息设置到ardRouteInformation中 |
| | | ardRouteInformation.setFileNameNew(kmzResult.getFileNameNew()); |
| | | ardRouteInformation.setMinioUpPath(kmzResult.getMinioUpPath()); |
| | | ardRouteInformation.setUpPath(kmzResult.getUpPath()); |
| | | ardRouteInformation.setUpFileSize(kmzResult.getUpFileSize()); |
| | | ardRouteInformationMapper.insertArdRouteInformation(ardRouteInformation); |
| | | return kmzResult.getUpPath(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deleteArdRouteInformationByIds(String[] ids) { |
| | | // 删除航线(kmz)文件 |
| | | for (String id : ids) { |
| | | ArdRouteInformation information = ardRouteInformationMapper.selectArdRouteInformationById(id); |
| | | ossService.deleteObject("kmz", information.getMinioUpPath()); |
| | | } |
| | | return ardRouteInformationMapper.deleteArdRouteInformationByIds(ids); |
| | | } |
| | | |
| | |
| | | return ardRouteInformationMapper.deleteArdRouteInformationById(id); |
| | | } |
| | | |
| | | /** |
| | | * 导入航线(kmz)文件 |
| | | * |
| | | * @param file 文件 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public MinioUploadResult uploadArdRouteInformation(MultipartFile file) { |
| | | try { |
| | | String url = ossService.upload("kmz",file); |
| | | 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); |
| | | return MinioUploadResult.builder() |
| | | .url(url) |
| | | .newFileName(FileUtils.getName(url)) |
| | | .originalFilename(file.getOriginalFilename()) |
| | | .build(); |
| | | }catch (Exception e){ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据文件名称查询航线信息 |
| | | * |
| | | * @param name 文件名称 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public ArdRouteInformation selectArdRouteInformationByName(String name) { |
| | | return ardRouteInformationMapper.selectArdRouteInformationByName(name); |
| | | } |
| | | |
| | | } |