From d8501b0c70ef0fe6b757ec248056507152fcf2d9 Mon Sep 17 00:00:00 2001 From: Moon Date: Wed, 24 Dec 2025 13:58:46 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapsheet/service/MapSheetMngService.java | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) 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 2518388b..f2dc422f 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 @@ -108,37 +108,30 @@ public class MapSheetMngService { String targetYearDir = mngDto.getMngPath(); // 중복체크 - List basicTfwList = - FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); - - List basicTifList = - FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif"); - - int tfwCnt = - (int) - basicTfwList.stream() - .filter(dto -> dto.getExtension().toString().equals("tfw")) - .count(); - - int tifCnt = - (int) - basicTifList.stream() - .filter(dto -> dto.getExtension().toString().equals("tif")) - .count(); - if( !overwrite ) { - if (tfwCnt > 0 || tifCnt > 0) { - String tfwtifMsg = ""; - if (tfwCnt > 0) - tfwtifMsg = tfwFile.getOriginalFilename(); - if (tifCnt > 0) { + + /* + List basicTfwList = + FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); + + List basicTifList = + FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif"); + */ + int tfwCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); + int tifCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); + + if (tfwCnt > 0 || tifCnt > 0) { + String tfwtifMsg = ""; if (tfwCnt > 0) - tfwtifMsg = "," + tifFile.getOriginalFilename(); - else - tfwtifMsg = tifFile.getOriginalFilename(); + tfwtifMsg = tfwFile.getOriginalFilename(); + if (tifCnt > 0) { + if (tfwCnt > 0) + tfwtifMsg = "," + tifFile.getOriginalFilename(); + else + tfwtifMsg = tifFile.getOriginalFilename(); + } + return new DmlReturn("duplicate", tfwtifMsg); } - return new DmlReturn("duplicate", tfwtifMsg); - } } File directory = new File(tmpPath); From eea2933aa2cd65d4204368d16310c97172f99f9c Mon Sep 17 00:00:00 2001 From: Moon Date: Wed, 24 Dec 2025 16:44:04 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=EC=98=81=EC=83=81=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kamcoback/common/enums/MngStateType.java | 8 +- .../kamcoback/common/enums/SyncStateType.java | 3 +- .../kamcoback/common/utils/FIleChecker.java | 23 ++ .../mapsheet/MapSheetMngApiController.java | 6 +- .../mapsheet/dto/MapSheetMngDto.java | 32 +++ .../mapsheet/service/MapSheetMngService.java | 49 ++-- .../mapsheet/MapSheetMngRepositoryImpl.java | 211 ++++++++++-------- 7 files changed, 211 insertions(+), 121 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/common/enums/MngStateType.java b/src/main/java/com/kamco/cd/kamcoback/common/enums/MngStateType.java index 377c1fec..202e3757 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/enums/MngStateType.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/enums/MngStateType.java @@ -9,10 +9,10 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum MngStateType implements EnumType { - NOTYET("미처리"), - PROCESSING("진행중"), - DONE("싱크완료"), - COMPLETE("작업완료"); + NOTYET("동기화 시작"), + PROCESSING("데이터 체크"), + DONE("동기화작업종료"), + TAKINGERROR("오류 데이터 처리중"); private final String desc; diff --git a/src/main/java/com/kamco/cd/kamcoback/common/enums/SyncStateType.java b/src/main/java/com/kamco/cd/kamcoback/common/enums/SyncStateType.java index f4a4ac6b..fc06e79b 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/enums/SyncStateType.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/enums/SyncStateType.java @@ -13,8 +13,7 @@ public enum SyncStateType implements EnumType { NOFILE("파일없음"), NOTPAIR("페어파일누락"), DUPLICATE("파일중복"), - SIZEERROR("파일용량오류"), - TYPEERROR("파일형식오류"), + TYPEERROR("손상파일"), DONE("완료"); private final String desc; diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java index 7c188676..3dd7854b 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java @@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.common.utils; import static java.lang.String.CASE_INSENSITIVE_ORDER; +import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn; import io.swagger.v3.oas.annotations.media.Schema; import java.io.BufferedReader; import java.io.File; @@ -29,6 +30,7 @@ import lombok.Getter; import org.apache.commons.io.FilenameUtils; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.gce.geotiff.GeoTiffReader; +import org.springframework.web.multipart.MultipartFile; public class FIleChecker { @@ -455,6 +457,17 @@ public class FIleChecker { return FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension, 100, "name", 0, 100); } + public static int getFileCountFromAllDepth( + String dir, String targetFileNm, String extension) { + + List basicList = + FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension); + + return (int) basicList.stream() + .filter(dto -> dto.getExtension().toString().equals(extension)) + .count(); + } + public static Long getFileTotSize(List files) { Long fileTotSize = 0L; @@ -465,6 +478,16 @@ public class FIleChecker { return fileTotSize; } + public static boolean validationMultipart(MultipartFile mfile) + { + // 파일 유효성 검증 + if (mfile == null || mfile.isEmpty() || mfile.getSize() == 0) { + return false; + } + + return true; + } + public static boolean checkExtensions(String fileName, String ext) { if (fileName == null) return false; 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 32c8520f..695dcebf 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java @@ -177,8 +177,10 @@ public class MapSheetMngApiController { @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)); + + + + return ApiResponseDto.createOK(mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite)); } @Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회") 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 f4ee99b2..905ada7b 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 @@ -85,9 +85,37 @@ public class MapSheetMngDto { private Long syncDuplicateExecCnt; private Long syncFaultCnt; private Long syncFaultExecCnt; + private Long syncNoFileCnt; + private Long syncNoFileExecCnt; @JsonFormatDttm private ZonedDateTime rgstStrtDttm; @JsonFormatDttm private ZonedDateTime rgstEndDttm; + public String getMngState() { + + if (this.syncStateDoneCnt == 0)return "NOTYET"; + else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; + + if( (this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0 )return "TAKINGERROR"; + + return "DONE"; + } + + public String getSyncState() { + + if (this.syncStateDoneCnt == 0)return "NOTYET"; + else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; + + return "DONE"; + } + + public String getDataCheckState() { + + if (this.syncDataCheckDoneCnt == 0)return "NOTYET"; + else if (this.syncDataCheckDoneCnt < this.syncTotCnt)return "PROCESSING"; + + return "DONE"; + } + public double getSyncStateDoneRate() { if (this.syncTotCnt == null || this.syncTotCnt == 0) { return 0.0; @@ -110,6 +138,8 @@ public class MapSheetMngDto { return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt; } + + public String getMngStateName() { String enumId = this.mngState; if (enumId == null || enumId.isEmpty()) { @@ -224,6 +254,8 @@ public class MapSheetMngDto { this.errorCheckTifFileName = errorCheckTifFileName; } + + private String getSyncStateName(String enumId) { if (enumId == null || enumId.isEmpty()) { enumId = "NOTYET"; 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 f2dc422f..c93a2382 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 @@ -19,6 +19,7 @@ import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,6 +33,16 @@ public class MapSheetMngService { private final MapSheetMngCoreService mapSheetMngCoreService; private final FileConfig fileConfig; + + @Value("${file.sync-root-dir}") + private String syncRootDir; + + @Value("${file.sync-tmp-dir}") + private String syncTmpDir; + + @Value("${file.sync-file-extention}") + private String syncFileExtention; + public List findMapSheetMngList() { return mapSheetMngCoreService.findMapSheetMngList(); } @@ -76,8 +87,10 @@ public class MapSheetMngService { @Transactional public DmlReturn uploadPair(MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) { - String rootPath = fileConfig.getRootSyncDir(); - String tmpPath = fileConfig.getTmpSyncDir(); + String rootPath = syncRootDir; + String tmpPath = syncTmpDir; + + DmlReturn dmlReturn = new DmlReturn("success", "UPLOAD COMPLETE"); ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid); @@ -90,19 +103,10 @@ public class MapSheetMngService { return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR"); } - // 파일 유효성 검증 - if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) { - return new DmlReturn("fail", "TFW SIZE 오류"); - } else if (tifFile == null || tifFile.isEmpty() || tifFile.getSize() == 0) { - return new DmlReturn("fail", "TIF SIZE 오류"); - } + //업로드 파일 사이즈,확장자명 체크 + dmlReturn = this.validationFile(tfwFile, tifFile); + if( dmlReturn.getFlag().equals("fail") )return dmlReturn; - // 확장자명 체크 - 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"); - } MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy()); String targetYearDir = mngDto.getMngPath(); @@ -110,13 +114,6 @@ public class MapSheetMngService { // 중복체크 if( !overwrite ) { - /* - List basicTfwList = - FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); - - List basicTifList = - FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif"); - */ int tfwCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); int tifCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); @@ -217,6 +214,16 @@ public class MapSheetMngService { return new DmlReturn("success", "파일 업로드 완료되었습니다."); } + 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 List findHstUidToMapSheetFileList(Long hstUid) { return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid); } 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 add560c9..76b53ae1 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 @@ -79,18 +79,21 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport mapSheetMngEntity.mngState, mapSheetMngEntity.syncState, mapSheetMngEntity.syncCheckState, - mapSheetMngHstEntity.count(), + + mapSheetMngHstEntity.count().as("syncTotalCnt"), new CaseBuilder() .when(mapSheetMngHstEntity.dataState.eq("DONE")) .then(1L) .otherwise(0L) .sum() .as("syncStateDoneCnt"), + new CaseBuilder() .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) .then(1L) .otherwise(0L) .sum(), + new CaseBuilder() .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) .then(1L) @@ -105,6 +108,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), + new CaseBuilder() .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) .then(1L) @@ -119,6 +123,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), + new CaseBuilder() .when( mapSheetMngHstEntity @@ -141,6 +146,23 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), + + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) + .then(1L) + .otherwise(0L) + .sum(), + + mapSheetMngEntity.createdDttm, mapSheetMngHstEntity.syncEndDttm.max())) .from(mapSheetMngEntity) @@ -199,80 +221,102 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport queryFactory .select( Projections.constructor( - MapSheetMngDto.MngDto.class, - Expressions.numberTemplate( - Integer.class, - "row_number() over(order by {0} desc)", - mapSheetMngEntity.createdDttm), - mapSheetMngEntity.mngYyyy, - mapSheetMngEntity.mngPath, - mapSheetMngEntity.mngState, - mapSheetMngEntity.syncState, - mapSheetMngEntity.syncCheckState, - mapSheetMngHstEntity.count(), - new CaseBuilder() - .when(mapSheetMngHstEntity.dataState.eq("DONE")) - .then(1L) - .otherwise(0L) - .sum() - .as("syncStateDoneCnt"), - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncState - .eq("TYPEERROR") - .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and( - mapSheetMngHstEntity - .syncState - .eq("TYPEERROR") - .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))) - .then(1L) - .otherwise(0L) - .sum(), - mapSheetMngEntity.createdDttm, - mapSheetMngHstEntity.syncEndDttm.max())) + MapSheetMngDto.MngDto.class, + Expressions.numberTemplate( + Integer.class, + "row_number() over(order by {0} desc)", + mapSheetMngEntity.createdDttm), + mapSheetMngEntity.mngYyyy, + mapSheetMngEntity.mngPath, + mapSheetMngEntity.mngState, + mapSheetMngEntity.syncState, + mapSheetMngEntity.syncCheckState, + + mapSheetMngHstEntity.count().as("syncTotalCnt"), + new CaseBuilder() + .when(mapSheetMngHstEntity.dataState.eq("DONE")) + .then(1L) + .otherwise(0L) + .sum() + .as("syncStateDoneCnt"), + + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) + .then(1L) + .otherwise(0L) + .sum(), + + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))) + .then(1L) + .otherwise(0L) + .sum(), + + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))) + .then(1L) + .otherwise(0L) + .sum(), + + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncState + .eq("TYPEERROR") + .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and( + mapSheetMngHstEntity + .syncState + .eq("TYPEERROR") + .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))) + .then(1L) + .otherwise(0L) + .sum(), + + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) + .then(1L) + .otherwise(0L) + .sum(), + + + mapSheetMngEntity.createdDttm, + mapSheetMngHstEntity.syncEndDttm.max())) .from(mapSheetMngEntity) .leftJoin(mapSheetMngHstEntity) .on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy)) @@ -295,24 +339,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport mapSheetMngHstEntity.syncState.ne("DONE").and(mapSheetMngHstEntity.syncState.ne("NOTYET"))); if (searchReq.getSyncState() != null && !searchReq.getSyncState().isEmpty()) { - /* - if (searchReq.getSyncState().equals("NOTPAIR")) { - whereBuilder.and( - mapSheetMngHstEntity - .syncState - .eq("NOTPAIR") - .or(mapSheetMngHstEntity.syncState.eq("NOFILE"))); - } else if (searchReq.getSyncState().equals("FAULT")) { - whereBuilder.and( - mapSheetMngHstEntity - .syncState - .eq("SIZEERROR") - .or(mapSheetMngHstEntity.syncState.eq("TYPEERROR"))); - } else { whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState())); - } - */ - whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState())); } if (searchReq.getSyncCheckState() != null && !searchReq.getSyncCheckState().isEmpty()) { From 6e0e5a80989cc8a83557343aa01fb613af1d139e Mon Sep 17 00:00:00 2001 From: Moon Date: Wed, 24 Dec 2025 16:46:06 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=EC=98=81=EC=83=81=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6b592c27..10aae251 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -64,17 +64,7 @@ management: include: - "health" -# GeoJSON 파일 모니터링 설정 -geojson: - monitor: - watch-directory: ~/geojson/upload - processed-directory: ~/geojson/processed - error-directory: ~/geojson/error - temp-directory: /tmp/geojson_extract - cron-expression: "0/30 * * * * *" # 매 30초마다 실행 - supported-extensions: - - zip - - tar - - tar.gz - - tgz - max-file-size: 104857600 # 100MB +file: + sync-root-dir: /app/original-images/ + sync-tmp-dir: ${file.sync-root-dir}/tmp + sync-file-extention: tfw,tif From 8bed8f5f386d49849e144d1b584d008918fea412 Mon Sep 17 00:00:00 2001 From: Moon Date: Wed, 24 Dec 2025 16:48:57 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=EC=98=81=EC=83=81=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 10aae251..d64d7d1d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -64,6 +64,7 @@ management: include: - "health" + file: sync-root-dir: /app/original-images/ sync-tmp-dir: ${file.sync-root-dir}/tmp From d64d0a7c7cc4a897ad33ae7edfb87230f74caae9 Mon Sep 17 00:00:00 2001 From: teddy Date: Wed, 24 Dec 2025 16:49:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=EC=98=81=EC=83=81=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kamcoback/common/utils/FIleChecker.java | 14 +- .../mapsheet/MapSheetMngApiController.java | 5 +- .../mapsheet/dto/MapSheetMngDto.java | 19 +- .../mapsheet/service/MapSheetMngService.java | 49 ++-- .../mapsheet/MapSheetMngRepositoryImpl.java | 222 ++++++++---------- 5 files changed, 142 insertions(+), 167 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java index 3dd7854b..08b7ab8d 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java @@ -2,7 +2,6 @@ package com.kamco.cd.kamcoback.common.utils; import static java.lang.String.CASE_INSENSITIVE_ORDER; -import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn; import io.swagger.v3.oas.annotations.media.Schema; import java.io.BufferedReader; import java.io.File; @@ -457,15 +456,13 @@ public class FIleChecker { return FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension, 100, "name", 0, 100); } - public static int getFileCountFromAllDepth( - String dir, String targetFileNm, String extension) { + public static int getFileCountFromAllDepth(String dir, String targetFileNm, String extension) { List basicList = - FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension); + FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension); - return (int) basicList.stream() - .filter(dto -> dto.getExtension().toString().equals(extension)) - .count(); + return (int) + basicList.stream().filter(dto -> dto.getExtension().toString().equals(extension)).count(); } public static Long getFileTotSize(List files) { @@ -478,8 +475,7 @@ public class FIleChecker { return fileTotSize; } - public static boolean validationMultipart(MultipartFile mfile) - { + public static boolean validationMultipart(MultipartFile mfile) { // 파일 유효성 검증 if (mfile == null || mfile.isEmpty() || mfile.getSize() == 0) { return false; 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 695dcebf..0a871d75 100644 --- a/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/mapsheet/MapSheetMngApiController.java @@ -178,9 +178,8 @@ public class MapSheetMngApiController { @RequestParam(value = "hstUid", required = false) Long hstUid, @RequestParam(value = "overwrite", required = false) boolean overwrite) { - - - return ApiResponseDto.createOK(mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite)); + return ApiResponseDto.createOK( + mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite)); } @Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회") 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 905ada7b..f76f9143 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 @@ -92,26 +92,27 @@ public class MapSheetMngDto { public String getMngState() { - if (this.syncStateDoneCnt == 0)return "NOTYET"; - else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; + if (this.syncStateDoneCnt == 0) return "NOTYET"; + else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING"; - if( (this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0 )return "TAKINGERROR"; + if ((this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0) + return "TAKINGERROR"; return "DONE"; } public String getSyncState() { - if (this.syncStateDoneCnt == 0)return "NOTYET"; - else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; + if (this.syncStateDoneCnt == 0) return "NOTYET"; + else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING"; return "DONE"; } public String getDataCheckState() { - if (this.syncDataCheckDoneCnt == 0)return "NOTYET"; - else if (this.syncDataCheckDoneCnt < this.syncTotCnt)return "PROCESSING"; + if (this.syncDataCheckDoneCnt == 0) return "NOTYET"; + else if (this.syncDataCheckDoneCnt < this.syncTotCnt) return "PROCESSING"; return "DONE"; } @@ -138,8 +139,6 @@ public class MapSheetMngDto { return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt; } - - public String getMngStateName() { String enumId = this.mngState; if (enumId == null || enumId.isEmpty()) { @@ -254,8 +253,6 @@ public class MapSheetMngDto { this.errorCheckTifFileName = errorCheckTifFileName; } - - private String getSyncStateName(String enumId) { if (enumId == null || enumId.isEmpty()) { enumId = "NOTYET"; 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 c93a2382..e64ada93 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 @@ -33,7 +33,6 @@ public class MapSheetMngService { private final MapSheetMngCoreService mapSheetMngCoreService; private final FileConfig fileConfig; - @Value("${file.sync-root-dir}") private String syncRootDir; @@ -85,7 +84,8 @@ public class MapSheetMngService { } @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; @@ -103,32 +103,30 @@ 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 ) { + if (!overwrite) { - int tfwCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); - int tifCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); + int tfwCnt = + FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); + int tifCnt = + FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); - if (tfwCnt > 0 || tifCnt > 0) { - String tfwtifMsg = ""; - if (tfwCnt > 0) - tfwtifMsg = tfwFile.getOriginalFilename(); - if (tifCnt > 0) { - if (tfwCnt > 0) - tfwtifMsg = "," + tifFile.getOriginalFilename(); - else - tfwtifMsg = tifFile.getOriginalFilename(); - } - return new DmlReturn("duplicate", tfwtifMsg); + if (tfwCnt > 0 || tifCnt > 0) { + String tfwtifMsg = ""; + if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename(); + if (tifCnt > 0) { + if (tfwCnt > 0) tfwtifMsg = "," + tifFile.getOriginalFilename(); + else tfwtifMsg = tifFile.getOriginalFilename(); } + return new DmlReturn("duplicate", tfwtifMsg); + } } File directory = new File(tmpPath); @@ -214,12 +212,13 @@ public class MapSheetMngService { return new DmlReturn("success", "파일 업로드 완료되었습니다."); } - 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", "파일체크"); } 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 76b53ae1..eb512241 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 @@ -79,7 +79,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport mapSheetMngEntity.mngState, mapSheetMngEntity.syncState, mapSheetMngEntity.syncCheckState, - mapSheetMngHstEntity.count().as("syncTotalCnt"), new CaseBuilder() .when(mapSheetMngHstEntity.dataState.eq("DONE")) @@ -87,13 +86,11 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .otherwise(0L) .sum() .as("syncStateDoneCnt"), - new CaseBuilder() .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) .then(1L) .otherwise(0L) .sum(), - new CaseBuilder() .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) .then(1L) @@ -108,7 +105,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), - new CaseBuilder() .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) .then(1L) @@ -123,7 +119,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), - new CaseBuilder() .when( mapSheetMngHstEntity @@ -146,23 +141,20 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport .then(1L) .otherwise(0L) .sum(), - - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) - .then(1L) - .otherwise(0L) - .sum(), - - + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) + .then(1L) + .otherwise(0L) + .sum(), mapSheetMngEntity.createdDttm, mapSheetMngHstEntity.syncEndDttm.max())) .from(mapSheetMngEntity) @@ -221,102 +213,94 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport queryFactory .select( Projections.constructor( - MapSheetMngDto.MngDto.class, - Expressions.numberTemplate( - Integer.class, - "row_number() over(order by {0} desc)", - mapSheetMngEntity.createdDttm), - mapSheetMngEntity.mngYyyy, - mapSheetMngEntity.mngPath, - mapSheetMngEntity.mngState, - mapSheetMngEntity.syncState, - mapSheetMngEntity.syncCheckState, - - mapSheetMngHstEntity.count().as("syncTotalCnt"), - new CaseBuilder() - .when(mapSheetMngHstEntity.dataState.eq("DONE")) - .then(1L) - .otherwise(0L) - .sum() - .as("syncStateDoneCnt"), - - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) - .then(1L) - .otherwise(0L) - .sum(), - - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))) - .then(1L) - .otherwise(0L) - .sum(), - - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))) - .then(1L) - .otherwise(0L) - .sum(), - - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncState - .eq("TYPEERROR") - .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and( - mapSheetMngHstEntity - .syncState - .eq("TYPEERROR") - .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))) - .then(1L) - .otherwise(0L) - .sum(), - - new CaseBuilder() - .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) - .then(1L) - .otherwise(0L) - .sum(), - new CaseBuilder() - .when( - mapSheetMngHstEntity - .syncCheckState - .eq("DONE") - .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) - .then(1L) - .otherwise(0L) - .sum(), - - - mapSheetMngEntity.createdDttm, - mapSheetMngHstEntity.syncEndDttm.max())) + MapSheetMngDto.MngDto.class, + Expressions.numberTemplate( + Integer.class, + "row_number() over(order by {0} desc)", + mapSheetMngEntity.createdDttm), + mapSheetMngEntity.mngYyyy, + mapSheetMngEntity.mngPath, + mapSheetMngEntity.mngState, + mapSheetMngEntity.syncState, + mapSheetMngEntity.syncCheckState, + mapSheetMngHstEntity.count().as("syncTotalCnt"), + new CaseBuilder() + .when(mapSheetMngHstEntity.dataState.eq("DONE")) + .then(1L) + .otherwise(0L) + .sum() + .as("syncStateDoneCnt"), + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.ne("NOTYET")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncState + .eq("TYPEERROR") + .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and( + mapSheetMngHstEntity + .syncState + .eq("TYPEERROR") + .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when(mapSheetMngHstEntity.syncState.eq("NOFILE")) + .then(1L) + .otherwise(0L) + .sum(), + new CaseBuilder() + .when( + mapSheetMngHstEntity + .syncCheckState + .eq("DONE") + .and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) + .then(1L) + .otherwise(0L) + .sum(), + mapSheetMngEntity.createdDttm, + mapSheetMngHstEntity.syncEndDttm.max())) .from(mapSheetMngEntity) .leftJoin(mapSheetMngHstEntity) .on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy)) @@ -339,7 +323,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport mapSheetMngHstEntity.syncState.ne("DONE").and(mapSheetMngHstEntity.syncState.ne("NOTYET"))); if (searchReq.getSyncState() != null && !searchReq.getSyncState().isEmpty()) { - whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState())); + whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState())); } if (searchReq.getSyncCheckState() != null && !searchReq.getSyncCheckState().isEmpty()) {