From ef4cd488270b2a435626d229b07b7ea6022fad46 Mon Sep 17 00:00:00 2001 From: teddy Date: Fri, 26 Dec 2025 15:20:16 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=81=EC=83=81=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=A3=BC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapsheet/MapSheetMngApiController.java | 89 +++++++++---------- .../mapsheet/dto/MapSheetMngDto.java | 4 - .../mapsheet/service/MapSheetMngService.java | 82 +++++++++-------- .../postgres/core/MapSheetMngCoreService.java | 21 +---- .../entity/MapSheetMngFileEntity.java | 1 - .../mapsheet/MapSheetMngRepositoryImpl.java | 49 +++++----- 6 files changed, 115 insertions(+), 131 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 103d93e2..f733eb8b 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java @@ -185,13 +185,13 @@ public class MapSheetMngApiController { @Operation(summary = "페어 파일 업로드", description = "TFW/TIF 두 파일을 쌍으로 업로드 및 검증") @PostMapping(value = "/upload-pair", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ApiResponseDto uploadPair( - @RequestPart("tfw") MultipartFile tfwFile, - @RequestPart("tif") MultipartFile tifFile, - @RequestParam(value = "hstUid", required = false) Long hstUid, - @RequestParam(value = "overwrite", required = false) boolean overwrite) { + @RequestPart("tfw") MultipartFile tfwFile, + @RequestPart("tif") MultipartFile tifFile, + @RequestParam(value = "hstUid", required = false) Long hstUid, + @RequestParam(value = "overwrite", required = false) boolean overwrite) { return ApiResponseDto.createOK( - mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite)); + mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite)); } @Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회") @@ -214,42 +214,41 @@ public class MapSheetMngApiController { return ApiResponseDto.ok(mapSheetMngService.findByHstUidMapSheetFileList(hstUid)); } - - @Operation(summary = "영상관리 > 파일사용설정 및 중복제거", description = "영상관리 >파일사용설정 및 중복제거(중복파일제거 및 선택파일사용설정)") + @Operation( + summary = "영상관리 > 파일사용설정 및 중복제거", + description = "영상관리 >파일사용설정 및 중복제거(중복파일제거 및 선택파일사용설정)") @ApiResponses( - value = { - @ApiResponse( - responseCode = "201", - description = "파일사용설정 처리 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Long.class))), - @ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "201", + description = "파일사용설정 처리 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = Long.class))), + @ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PutMapping("/update-use-mng-files") public ApiResponseDto updateUseByFileUidMngFile( - @RequestParam @Valid List fileUids) { + @RequestParam @Valid List fileUids) { return ApiResponseDto.ok(mapSheetMngService.setUseByFileUidMngFile(fileUids)); } - - @Operation(summary = "폴더 조회", description = "폴더 조회 (ROOT:/app/original-images 이하로 경로입력)") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "조회 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = CommonCodeDto.Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "200", + description = "조회 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = CommonCodeDto.Basic.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PostMapping("/folder-list") public ApiResponseDto getDir(@RequestBody SrchFoldersDto srchDto) { @@ -258,22 +257,20 @@ public class MapSheetMngApiController { @Operation(summary = "지정폴더내 파일목록 조회", description = "지정폴더내 파일목록 조회") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "조회 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = CommonCodeDto.Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "200", + description = "조회 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = CommonCodeDto.Basic.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PostMapping("/file-list") public ApiResponseDto getFiles(@RequestBody SrchFilesDto srchDto) { return ApiResponseDto.createOK(mapSheetMngService.getFilesAll(srchDto)); } - - } diff --git a/src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/MapSheetMngDto.java b/src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/MapSheetMngDto.java index 9e5b0b38..920c7edc 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/MapSheetMngDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/MapSheetMngDto.java @@ -90,8 +90,6 @@ public class MapSheetMngDto { @JsonFormatDttm private ZonedDateTime rgstStrtDttm; @JsonFormatDttm private ZonedDateTime rgstEndDttm; - - public String getSyncState() { if (this.syncStateDoneCnt == 0) return "NOTYET"; @@ -130,7 +128,6 @@ public class MapSheetMngDto { return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt; } - public String getMngState() { String mngState = "DONE"; @@ -153,7 +150,6 @@ public class MapSheetMngDto { MngStateType type = Enums.fromId(MngStateType.class, enumId); return type.getText(); } - } @Schema(name = "ErrorSearchReq", description = "영상관리 오류데이터 검색 요청") 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 1e57c4b4..c7ff1203 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 @@ -14,7 +14,6 @@ import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngDto; import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngFilesDto; import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService; import jakarta.validation.Valid; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -75,16 +74,16 @@ public class MapSheetMngService { @Transactional public DmlReturn mngDataSave(AddReq addReq) { int execCnt = mapSheetMngCoreService.mngDataSave(addReq); - return new MapSheetMngDto.DmlReturn("success", addReq.getMngYyyy()+"년, "+execCnt+"건 생성"); + return new MapSheetMngDto.DmlReturn("success", addReq.getMngYyyy() + "년, " + execCnt + "건 생성"); } - public DmlReturn updateExceptUseInference(@Valid List hstUidList) { return mapSheetMngCoreService.updateExceptUseInference(hstUidList); } @Transactional - public DmlReturn uploadPair(MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) { + public DmlReturn uploadPair( + MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) { String rootPath = syncRootDir; String tmpPath = syncTmpDir; @@ -102,26 +101,29 @@ public class MapSheetMngService { return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR"); } - //업로드 파일 사이즈,확장자명 체크 + // 업로드 파일 사이즈,확장자명 체크 dmlReturn = this.validationFile(tfwFile, tifFile); - if( dmlReturn.getFlag().equals("fail") )return dmlReturn; - + if (dmlReturn.getFlag().equals("fail")) return dmlReturn; MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy()); String targetYearDir = mngDto.getMngPath(); // 중복체크 - if( !overwrite ) { - dmlReturn = this.duplicateFile(errDto.getMngYyyy(), tfwFile.getOriginalFilename(), tifFile.getOriginalFilename()); - if( dmlReturn.getFlag().equals("duplicate") )return dmlReturn; + if (!overwrite) { + dmlReturn = + this.duplicateFile( + errDto.getMngYyyy(), tfwFile.getOriginalFilename(), tifFile.getOriginalFilename()); + if (dmlReturn.getFlag().equals("duplicate")) return dmlReturn; } - //멀티파트 파일 tmp폴더 저장(파일형식 체크를 위해) + // 멀티파트 파일 tmp폴더 저장(파일형식 체크를 위해) String tfwTmpPath = tmpPath + tfwFile.getOriginalFilename(); String tifTmpPath = tmpPath + tifFile.getOriginalFilename(); - 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(tfwFile, tfwTmpPath)) + 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.checkTfw(tfwTmpPath)) return new DmlReturn("fail", "TFW TYPE ERROR"); @@ -134,7 +136,6 @@ public class MapSheetMngService { break; } - Path tfwTmpSavePath = Paths.get(tfwTmpPath); Path tifTmpSavePath = Paths.get(tifTmpPath); Path tfwTargetPath = null; @@ -199,7 +200,6 @@ public class MapSheetMngService { return mapSheetMngCoreService.findByHstUidMapSheetFileList(hstUid); } - @Transactional public DmlReturn setUseByFileUidMngFile(List fileUids) { @@ -207,7 +207,8 @@ public class MapSheetMngService { DmlReturn dmlReturn = new DmlReturn("success", "정상처리되었습니다."); - MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto = new MapSheetMngDto.SyncCheckStateReqUpdateDto(); + MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto = + new MapSheetMngDto.SyncCheckStateReqUpdateDto(); for (Long uid : fileUids) { MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findByFileUidMapSheetFile(uid); @@ -222,39 +223,36 @@ public class MapSheetMngService { mapSheetMngCoreService.updateByFileUidFileState(uid, "DONE"); } - //선택제외 삭제처리 + // 선택제외 삭제처리 mapSheetMngCoreService.deleteByNotInFileUidMngFile(reqDto.getHstUid(), fileUids); - //Hst(내역) 테이블 상태 업데이트 + // Hst(내역) 테이블 상태 업데이트 mapSheetMngCoreService.updateByHstUidSyncCheckState(reqDto); return new DmlReturn("success", fileUids.size() + "개 파일이 사용설정되었습니다."); } - public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile) - { - if( !FIleChecker.validationMultipart(tfwFile) )return new DmlReturn("fail", "TFW SIZE 오류"); - else if( !FIleChecker.validationMultipart(tifFile) )return new DmlReturn("fail", "TFW SIZE 오류"); - else if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw"))return new DmlReturn("fail", "TFW FILENAME ERROR"); - else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif"))return new DmlReturn("fail", "TIF FILENAME ERROR"); + public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile) { + if (!FIleChecker.validationMultipart(tfwFile)) return new DmlReturn("fail", "TFW SIZE 오류"); + else if (!FIleChecker.validationMultipart(tifFile)) return new DmlReturn("fail", "TFW SIZE 오류"); + else if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw")) + return new DmlReturn("fail", "TFW FILENAME ERROR"); + else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif")) + return new DmlReturn("fail", "TIF FILENAME ERROR"); return new DmlReturn("success", "파일체크"); } - public DmlReturn duplicateFile(int mngYyyy, String tfwFileName, String tifFileName) - { + public DmlReturn duplicateFile(int mngYyyy, String tfwFileName, String tifFileName) { int tfwCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tfwFileName); int tifCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tifFileName); if (tfwCnt > 0 || tifCnt > 0) { String resMsg = ""; - if (tfwCnt > 0) - resMsg = tfwFileName; + if (tfwCnt > 0) resMsg = tfwFileName; if (tifCnt > 0) { - if (tfwCnt > 0) - resMsg = resMsg + "," + tifFileName; - else - resMsg = tifFileName; + if (tfwCnt > 0) resMsg = resMsg + "," + tifFileName; + else resMsg = tifFileName; } return new DmlReturn("duplicate", resMsg); } @@ -272,8 +270,8 @@ public class MapSheetMngService { int folderTotCnt = folderList.size(); int folderErrTotCnt = - (int) - folderList.stream().filter(dto -> dto.getIsValid().toString().equals("false")).count(); + (int) + folderList.stream().filter(dto -> dto.getIsValid().toString().equals("false")).count(); return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderList); } @@ -285,14 +283,14 @@ public class MapSheetMngService { int endPos = srchDto.getEndPos(); List files = - FIleChecker.getFilesFromAllDepth( - srchDto.getDirPath(), - "*", - srchDto.getExtension(), - 1, - srchDto.getSortType(), - startPos, - endPos); + FIleChecker.getFilesFromAllDepth( + srchDto.getDirPath(), + "*", + srchDto.getExtension(), + 1, + srchDto.getSortType(), + startPos, + endPos); int fileListPos = 0; int fileTotCnt = files.size(); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngCoreService.java index 706be684..9850f882 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngCoreService.java @@ -6,16 +6,9 @@ import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity; import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository; import jakarta.persistence.EntityNotFoundException; import jakarta.validation.Valid; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; @@ -50,7 +43,6 @@ public class MapSheetMngCoreService { mapSheetMngRepository.deleteByHstUidMngFile(hstUid); } - public int findByYearFileNameFileCount(int mngYyyy, String fileName) { return mapSheetMngRepository.findByYearFileNameFileCount(mngYyyy, fileName); } @@ -87,8 +79,6 @@ public class MapSheetMngCoreService { return mapSheetMngRepository.findByFileUidMapSheetFile(fileUid); } - - public MapSheetMngDto.DmlReturn updateExceptUseInference(@Valid List hstUidList) { if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) { for (Long hstUid : hstUidList) { @@ -104,8 +94,6 @@ public class MapSheetMngCoreService { return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다."); } - - public int mngDataSave(@Valid MapSheetMngDto.AddReq addReq) { MapSheetMngEntity entity = new MapSheetMngEntity(); @@ -115,7 +103,9 @@ public class MapSheetMngCoreService { mapSheetMngRepository.deleteByMngYyyyMngAll(addReq.getMngYyyy()); MapSheetMngEntity saved = mapSheetMngRepository.save(entity); - int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy(), saved.getMngPath()); + int hstCnt = + mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst( + saved.getMngYyyy(), saved.getMngPath()); mapSheetMngRepository.updateYearState(saved.getMngYyyy(), "DONE"); return hstCnt; @@ -133,14 +123,11 @@ public class MapSheetMngCoreService { mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(reqDto); } - public void updateByFileUidFileState(Long fileUid, String fileState) { mapSheetMngRepository.updateByFileUidMngFileState(fileUid, fileState); } - public void deleteByNotInFileUidMngFile(Long hstUid, List fileUids){ + public void deleteByNotInFileUidMngFile(Long hstUid, List fileUids) { mapSheetMngRepository.deleteByNotInFileUidMngFile(hstUid, fileUids); } - - } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetMngFileEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetMngFileEntity.java index ac87f1d4..cadf2ce2 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetMngFileEntity.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetMngFileEntity.java @@ -60,5 +60,4 @@ public class MapSheetMngFileEntity { @ColumnDefault("false") @Column(name = "file_del", nullable = false) private Boolean fileDel = false; - } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/mapsheet/MapSheetMngRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/mapsheet/MapSheetMngRepositoryImpl.java index cd22a0f0..1226813b 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/mapsheet/MapSheetMngRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/mapsheet/MapSheetMngRepositoryImpl.java @@ -648,8 +648,8 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport public void deleteByFileUidMngFile(Long fileUid) { long fileCount = queryFactory - .update(mapSheetMngFileEntity) - .set(mapSheetMngFileEntity.fileDel, true) + .update(mapSheetMngFileEntity) + .set(mapSheetMngFileEntity.fileDel, true) .where(mapSheetMngFileEntity.fileUid.eq(fileUid)) .execute(); } @@ -665,34 +665,41 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport } @Override - public void deleteByNotInFileUidMngFile(Long hstUid, List fileUids){ + public void deleteByNotInFileUidMngFile(Long hstUid, List fileUids) { long execCount = - queryFactory - .update(mapSheetMngFileEntity) - .set(mapSheetMngFileEntity.fileDel, true) - .where(mapSheetMngFileEntity.hstUid.eq(hstUid) - .and(mapSheetMngFileEntity.fileUid.notIn(fileUids))) - .execute(); + queryFactory + .update(mapSheetMngFileEntity) + .set(mapSheetMngFileEntity.fileDel, true) + .where( + mapSheetMngFileEntity + .hstUid + .eq(hstUid) + .and(mapSheetMngFileEntity.fileUid.notIn(fileUids))) + .execute(); } @Override public void updateByFileUidMngFileState(Long fileUid, String fileState) { long execCount = - queryFactory - .update(mapSheetMngFileEntity) - .set(mapSheetMngFileEntity.fileState, fileState) - .where(mapSheetMngFileEntity.fileUid.eq(fileUid)) - .execute(); + queryFactory + .update(mapSheetMngFileEntity) + .set(mapSheetMngFileEntity.fileState, fileState) + .where(mapSheetMngFileEntity.fileUid.eq(fileUid)) + .execute(); } @Override - public int findByYearFileNameFileCount(int mngYyyy, String fileName){ - Long execCount = queryFactory - .select(mapSheetMngFileEntity.count()) - .from(mapSheetMngFileEntity) - .where(mapSheetMngFileEntity.mngYyyy.eq(mngYyyy) - .and(mapSheetMngFileEntity.fileName.eq(fileName))) - .fetchOne(); + public int findByYearFileNameFileCount(int mngYyyy, String fileName) { + Long execCount = + queryFactory + .select(mapSheetMngFileEntity.count()) + .from(mapSheetMngFileEntity) + .where( + mapSheetMngFileEntity + .mngYyyy + .eq(mngYyyy) + .and(mapSheetMngFileEntity.fileName.eq(fileName))) + .fetchOne(); return Math.toIntExact(execCount); }