From 1967a9d7cdf56670f101926e1f4da0ce6da310da Mon Sep 17 00:00:00 2001 From: "gayoun.park" Date: Mon, 26 Jan 2026 19:34:23 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=81=EC=83=81=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20>=20uploadPair=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapsheet/MapSheetMngApiController.java | 4 +- .../mapsheet/service/MapSheetMngService.java | 46 +++++++++++++------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java b/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java index c613f2ad..1ea19aad 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java @@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.io.IOException; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; @@ -325,7 +326,8 @@ public class MapSheetMngApiController { @RequestParam("fileSize") long fileSize, @RequestParam("chunkIndex") Integer chunkIndex, @RequestParam("chunkTotalIndex") Integer chunkTotalIndex, - @RequestPart("chunkFile") MultipartFile chunkFile) { + @RequestPart("chunkFile") MultipartFile chunkFile) + throws IOException { String uploadDivi = "mapsheet"; diff --git a/src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java b/src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java index e2ab15e0..2b2ce6a0 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java @@ -134,7 +134,7 @@ public class MapSheetMngService { MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy()); String targetYearDir = mngDto.getMngPath(); - // 중복체크 -> 도엽/uuid_yyyyMMddhhmmss 경로에 업로드 할 거라 overwrite 되지 않음 + // 중복체크 -> 도엽/uuid 경로에 업로드 할 거라 overwrite 되지 않음 // if (!overwrite) { // dmlReturn = // this.duplicateFile( @@ -151,13 +151,13 @@ public class MapSheetMngService { if (!FIleChecker.multipartSaveTo(tfwFile, tfwTmpPath)) { return new DmlReturn("fail", "UPLOAD ERROR"); } - if (!FIleChecker.multipartSaveTo(tifFile, tifTmpPath)) { - return new DmlReturn("fail", "UPLOAD ERROR"); - } + // if (!FIleChecker.multipartSaveTo(tifFile, tifTmpPath)) { + // return new DmlReturn("fail", "UPLOAD ERROR"); + // } - if (!FIleChecker.cmmndGdalInfo(tifTmpPath)) { - return new DmlReturn("fail", "TIF TYPE ERROR"); - } + // if (!FIleChecker.cmmndGdalInfo(tifTmpPath)) { + // return new DmlReturn("fail", "TIF TYPE ERROR"); + // } if (!FIleChecker.checkTfw(tfwTmpPath)) { return new DmlReturn("fail", "TFW TYPE ERROR"); } @@ -166,12 +166,12 @@ public class MapSheetMngService { List mngFiles = mapSheetMngCoreService.findByHstUidMapSheetFileList(hstUid); String uploadPath = ""; for (MngFilesDto dto : mngFiles) { - uploadPath = dto.getFilePath(); + uploadPath = dto.getFilePath() + "/" + errDto.getUuid(); break; } Path tfwTmpSavePath = Paths.get(tfwTmpPath); - Path tifTmpSavePath = Paths.get(tifTmpPath); + // Path tifTmpSavePath = Paths.get(tifTmpPath); Path tfwTargetPath = null; Path tifTargetPath = null; @@ -180,7 +180,12 @@ public class MapSheetMngService { MngFilesDto filesDto = mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy()); String referPath = filesDto.getFilePath(); - uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum(); + uploadPath = + Paths.get(referPath).getParent().toString() + + "/" + + errDto.getRefMapSheetNum() + + "/" + + errDto.getUuid(); } // 업로드 경로 확인(없으면 생성) @@ -191,9 +196,13 @@ public class MapSheetMngService { tfwTargetPath = Paths.get(uploadPath).resolve(tfwFile.getOriginalFilename()); tifTargetPath = Paths.get(uploadPath).resolve(tifFile.getOriginalFilename()); + if (!Files.exists(tifTargetPath)) { + return new DmlReturn("fail", "TIF 파일이 정상적으로 업로드 되지 않았습니다. 확인해주세요."); + } + try { Files.move(tfwTmpSavePath, tfwTargetPath, StandardCopyOption.REPLACE_EXISTING); - Files.move(tifTmpSavePath, tifTargetPath, StandardCopyOption.REPLACE_EXISTING); + // Files.move(tifTmpSavePath, tifTargetPath, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); } @@ -365,9 +374,8 @@ public class MapSheetMngService { @Transactional public ModelUploadResDto uploadChunkMapSheetFile( - Long hstUid, UploadAddReq upAddReqDto, MultipartFile chunkFile) { + Long hstUid, UploadAddReq upAddReqDto, MultipartFile chunkFile) throws IOException { - // String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid); // 싱크파일목록으로 업로드 경로 확인 @@ -392,6 +400,18 @@ public class MapSheetMngService { UploadDto.UploadRes upRes = uploadService.uploadChunk(upAddReqDto, chunkFile); ModelUploadResDto modelUploadResDto = new ModelUploadResDto(); + + // 병합 다 했는데 gdalinfo 가 fail 이면 삭제? + if (upRes.getRes().equals("MERGED")) { + if (!FIleChecker.cmmndGdalInfo(upRes.getFilePath() + "/" + upRes.getFileName())) { + Path filePath = Paths.get(upRes.getFilePath()); + Files.deleteIfExists(filePath); + modelUploadResDto.setRes("fail"); + modelUploadResDto.setResMsg("TIF TYPE ERROR"); + return modelUploadResDto; + } + } + modelUploadResDto.setRes(upRes.getRes()); modelUploadResDto.setResMsg(upRes.getResMsg()); modelUploadResDto.setUuid(upRes.getUuid());