영상관리 수정

This commit is contained in:
2025-12-24 16:49:07 +09:00
parent 808524764d
commit d64d0a7c7c
5 changed files with 142 additions and 167 deletions

View File

@@ -2,7 +2,6 @@ package com.kamco.cd.kamcoback.common.utils;
import static java.lang.String.CASE_INSENSITIVE_ORDER; 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 io.swagger.v3.oas.annotations.media.Schema;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@@ -457,15 +456,13 @@ public class FIleChecker {
return FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension, 100, "name", 0, 100); return FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension, 100, "name", 0, 100);
} }
public static int getFileCountFromAllDepth( public static int getFileCountFromAllDepth(String dir, String targetFileNm, String extension) {
String dir, String targetFileNm, String extension) {
List<FIleChecker.Basic> basicList = List<FIleChecker.Basic> basicList =
FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension); FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension);
return (int) basicList.stream() return (int)
.filter(dto -> dto.getExtension().toString().equals(extension)) basicList.stream().filter(dto -> dto.getExtension().toString().equals(extension)).count();
.count();
} }
public static Long getFileTotSize(List<FIleChecker.Basic> files) { public static Long getFileTotSize(List<FIleChecker.Basic> files) {
@@ -478,8 +475,7 @@ public class FIleChecker {
return fileTotSize; return fileTotSize;
} }
public static boolean validationMultipart(MultipartFile mfile) public static boolean validationMultipart(MultipartFile mfile) {
{
// 파일 유효성 검증 // 파일 유효성 검증
if (mfile == null || mfile.isEmpty() || mfile.getSize() == 0) { if (mfile == null || mfile.isEmpty() || mfile.getSize() == 0) {
return false; return false;

View File

@@ -178,9 +178,8 @@ public class MapSheetMngApiController {
@RequestParam(value = "hstUid", required = false) Long hstUid, @RequestParam(value = "hstUid", required = false) Long hstUid,
@RequestParam(value = "overwrite", required = false) boolean overwrite) { @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 = "영상관리 > 파일조회") @Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회")

View File

@@ -92,26 +92,27 @@ public class MapSheetMngDto {
public String getMngState() { public String getMngState() {
if (this.syncStateDoneCnt == 0)return "NOTYET"; if (this.syncStateDoneCnt == 0) return "NOTYET";
else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; 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"; return "DONE";
} }
public String getSyncState() { public String getSyncState() {
if (this.syncStateDoneCnt == 0)return "NOTYET"; if (this.syncStateDoneCnt == 0) return "NOTYET";
else if (this.syncStateDoneCnt < this.syncTotCnt)return "PROCESSING"; else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING";
return "DONE"; return "DONE";
} }
public String getDataCheckState() { public String getDataCheckState() {
if (this.syncDataCheckDoneCnt == 0)return "NOTYET"; if (this.syncDataCheckDoneCnt == 0) return "NOTYET";
else if (this.syncDataCheckDoneCnt < this.syncTotCnt)return "PROCESSING"; else if (this.syncDataCheckDoneCnt < this.syncTotCnt) return "PROCESSING";
return "DONE"; return "DONE";
} }
@@ -138,8 +139,6 @@ public class MapSheetMngDto {
return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt; return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt;
} }
public String getMngStateName() { public String getMngStateName() {
String enumId = this.mngState; String enumId = this.mngState;
if (enumId == null || enumId.isEmpty()) { if (enumId == null || enumId.isEmpty()) {
@@ -254,8 +253,6 @@ public class MapSheetMngDto {
this.errorCheckTifFileName = errorCheckTifFileName; this.errorCheckTifFileName = errorCheckTifFileName;
} }
private String getSyncStateName(String enumId) { private String getSyncStateName(String enumId) {
if (enumId == null || enumId.isEmpty()) { if (enumId == null || enumId.isEmpty()) {
enumId = "NOTYET"; enumId = "NOTYET";

View File

@@ -33,7 +33,6 @@ public class MapSheetMngService {
private final MapSheetMngCoreService mapSheetMngCoreService; private final MapSheetMngCoreService mapSheetMngCoreService;
private final FileConfig fileConfig; private final FileConfig fileConfig;
@Value("${file.sync-root-dir}") @Value("${file.sync-root-dir}")
private String syncRootDir; private String syncRootDir;
@@ -85,7 +84,8 @@ public class MapSheetMngService {
} }
@Transactional @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 rootPath = syncRootDir;
String tmpPath = syncTmpDir; String tmpPath = syncTmpDir;
@@ -103,32 +103,30 @@ public class MapSheetMngService {
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR"); return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
} }
//업로드 파일 사이즈,확장자명 체크 // 업로드 파일 사이즈,확장자명 체크
dmlReturn = this.validationFile(tfwFile, tifFile); 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()); MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
String targetYearDir = mngDto.getMngPath(); String targetYearDir = mngDto.getMngPath();
// 중복체크 // 중복체크
if( !overwrite ) { if (!overwrite) {
int tfwCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); int tfwCnt =
int tifCnt = FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw"); FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
int tifCnt =
FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
if (tfwCnt > 0 || tifCnt > 0) { if (tfwCnt > 0 || tifCnt > 0) {
String tfwtifMsg = ""; String tfwtifMsg = "";
if (tfwCnt > 0) if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename();
tfwtifMsg = tfwFile.getOriginalFilename(); if (tifCnt > 0) {
if (tifCnt > 0) { if (tfwCnt > 0) tfwtifMsg = "," + tifFile.getOriginalFilename();
if (tfwCnt > 0) else tfwtifMsg = tifFile.getOriginalFilename();
tfwtifMsg = "," + tifFile.getOriginalFilename();
else
tfwtifMsg = tifFile.getOriginalFilename();
}
return new DmlReturn("duplicate", tfwtifMsg);
} }
return new DmlReturn("duplicate", tfwtifMsg);
}
} }
File directory = new File(tmpPath); File directory = new File(tmpPath);
@@ -214,12 +212,13 @@ public class MapSheetMngService {
return new DmlReturn("success", "파일 업로드 완료되었습니다."); return new DmlReturn("success", "파일 업로드 완료되었습니다.");
} }
public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile) public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile) {
{ if (!FIleChecker.validationMultipart(tfwFile)) return new DmlReturn("fail", "TFW SIZE 오류");
if( !FIleChecker.validationMultipart(tfwFile) )return new DmlReturn("fail", "TFW SIZE 오류"); else if (!FIleChecker.validationMultipart(tifFile)) return new DmlReturn("fail", "TFW SIZE 오류");
else if( !FIleChecker.validationMultipart(tifFile) )return new DmlReturn("fail", "TFW SIZE 오류"); else if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw"))
else if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw"))return new DmlReturn("fail", "TFW FILENAME ERROR"); return new DmlReturn("fail", "TFW FILENAME ERROR");
else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif"))return new DmlReturn("fail", "TIF FILENAME ERROR"); else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif"))
return new DmlReturn("fail", "TIF FILENAME ERROR");
return new DmlReturn("success", "파일체크"); return new DmlReturn("success", "파일체크");
} }

View File

@@ -79,7 +79,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
mapSheetMngEntity.mngState, mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState, mapSheetMngEntity.syncState,
mapSheetMngEntity.syncCheckState, mapSheetMngEntity.syncCheckState,
mapSheetMngHstEntity.count().as("syncTotalCnt"), mapSheetMngHstEntity.count().as("syncTotalCnt"),
new CaseBuilder() new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("DONE")) .when(mapSheetMngHstEntity.dataState.eq("DONE"))
@@ -87,13 +86,11 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.otherwise(0L) .otherwise(0L)
.sum() .sum()
.as("syncStateDoneCnt"), .as("syncStateDoneCnt"),
new CaseBuilder() new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.ne("NOTYET")) .when(mapSheetMngHstEntity.syncState.ne("NOTYET"))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
new CaseBuilder() new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))
.then(1L) .then(1L)
@@ -108,7 +105,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
new CaseBuilder() new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))
.then(1L) .then(1L)
@@ -123,7 +119,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
new CaseBuilder() new CaseBuilder()
.when( .when(
mapSheetMngHstEntity mapSheetMngHstEntity
@@ -146,23 +141,20 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
new CaseBuilder()
new CaseBuilder() .when(mapSheetMngHstEntity.syncState.eq("NOFILE"))
.when(mapSheetMngHstEntity.syncState.eq("NOFILE")) .then(1L)
.then(1L) .otherwise(0L)
.otherwise(0L) .sum(),
.sum(), new CaseBuilder()
new CaseBuilder() .when(
.when( mapSheetMngHstEntity
mapSheetMngHstEntity .syncCheckState
.syncCheckState .eq("DONE")
.eq("DONE") .and(mapSheetMngHstEntity.syncState.eq("NOFILE")))
.and(mapSheetMngHstEntity.syncState.eq("NOFILE"))) .then(1L)
.then(1L) .otherwise(0L)
.otherwise(0L) .sum(),
.sum(),
mapSheetMngEntity.createdDttm, mapSheetMngEntity.createdDttm,
mapSheetMngHstEntity.syncEndDttm.max())) mapSheetMngHstEntity.syncEndDttm.max()))
.from(mapSheetMngEntity) .from(mapSheetMngEntity)
@@ -221,102 +213,94 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
MapSheetMngDto.MngDto.class, MapSheetMngDto.MngDto.class,
Expressions.numberTemplate( Expressions.numberTemplate(
Integer.class, Integer.class,
"row_number() over(order by {0} desc)", "row_number() over(order by {0} desc)",
mapSheetMngEntity.createdDttm), mapSheetMngEntity.createdDttm),
mapSheetMngEntity.mngYyyy, mapSheetMngEntity.mngYyyy,
mapSheetMngEntity.mngPath, mapSheetMngEntity.mngPath,
mapSheetMngEntity.mngState, mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState, mapSheetMngEntity.syncState,
mapSheetMngEntity.syncCheckState, mapSheetMngEntity.syncCheckState,
mapSheetMngHstEntity.count().as("syncTotalCnt"),
mapSheetMngHstEntity.count().as("syncTotalCnt"), new CaseBuilder()
new CaseBuilder() .when(mapSheetMngHstEntity.dataState.eq("DONE"))
.when(mapSheetMngHstEntity.dataState.eq("DONE")) .then(1L)
.then(1L) .otherwise(0L)
.otherwise(0L) .sum()
.sum() .as("syncStateDoneCnt"),
.as("syncStateDoneCnt"), new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.ne("NOTYET"))
new CaseBuilder() .then(1L)
.when(mapSheetMngHstEntity.syncState.ne("NOTYET")) .otherwise(0L)
.then(1L) .sum(),
.otherwise(0L) new CaseBuilder()
.sum(), .when(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))
.then(1L)
new CaseBuilder() .otherwise(0L)
.when(mapSheetMngHstEntity.syncState.eq("NOTPAIR")) .sum(),
.then(1L) new CaseBuilder()
.otherwise(0L) .when(
.sum(), mapSheetMngHstEntity
new CaseBuilder() .syncCheckState
.when( .eq("DONE")
mapSheetMngHstEntity .and(mapSheetMngHstEntity.syncState.eq("NOTPAIR")))
.syncCheckState .then(1L)
.eq("DONE") .otherwise(0L)
.and(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))) .sum(),
.then(1L) new CaseBuilder()
.otherwise(0L) .when(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))
.sum(), .then(1L)
.otherwise(0L)
new CaseBuilder() .sum(),
.when(mapSheetMngHstEntity.syncState.eq("DUPLICATE")) new CaseBuilder()
.then(1L) .when(
.otherwise(0L) mapSheetMngHstEntity
.sum(), .syncCheckState
new CaseBuilder() .eq("DONE")
.when( .and(mapSheetMngHstEntity.syncState.eq("DUPLICATE")))
mapSheetMngHstEntity .then(1L)
.syncCheckState .otherwise(0L)
.eq("DONE") .sum(),
.and(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))) new CaseBuilder()
.then(1L) .when(
.otherwise(0L) mapSheetMngHstEntity
.sum(), .syncState
.eq("TYPEERROR")
new CaseBuilder() .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))
.when( .then(1L)
mapSheetMngHstEntity .otherwise(0L)
.syncState .sum(),
.eq("TYPEERROR") new CaseBuilder()
.or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))) .when(
.then(1L) mapSheetMngHstEntity
.otherwise(0L) .syncCheckState
.sum(), .eq("DONE")
new CaseBuilder() .and(
.when( mapSheetMngHstEntity
mapSheetMngHstEntity .syncState
.syncCheckState .eq("TYPEERROR")
.eq("DONE") .or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))))
.and( .then(1L)
mapSheetMngHstEntity .otherwise(0L)
.syncState .sum(),
.eq("TYPEERROR") new CaseBuilder()
.or(mapSheetMngHstEntity.syncState.eq("SIZEERROR")))) .when(mapSheetMngHstEntity.syncState.eq("NOFILE"))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
new CaseBuilder()
new CaseBuilder() .when(
.when(mapSheetMngHstEntity.syncState.eq("NOFILE")) mapSheetMngHstEntity
.then(1L) .syncCheckState
.otherwise(0L) .eq("DONE")
.sum(), .and(mapSheetMngHstEntity.syncState.eq("NOFILE")))
new CaseBuilder() .then(1L)
.when( .otherwise(0L)
mapSheetMngHstEntity .sum(),
.syncCheckState mapSheetMngEntity.createdDttm,
.eq("DONE") mapSheetMngHstEntity.syncEndDttm.max()))
.and(mapSheetMngHstEntity.syncState.eq("NOFILE")))
.then(1L)
.otherwise(0L)
.sum(),
mapSheetMngEntity.createdDttm,
mapSheetMngHstEntity.syncEndDttm.max()))
.from(mapSheetMngEntity) .from(mapSheetMngEntity)
.leftJoin(mapSheetMngHstEntity) .leftJoin(mapSheetMngHstEntity)
.on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy)) .on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
@@ -339,7 +323,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
mapSheetMngHstEntity.syncState.ne("DONE").and(mapSheetMngHstEntity.syncState.ne("NOTYET"))); mapSheetMngHstEntity.syncState.ne("DONE").and(mapSheetMngHstEntity.syncState.ne("NOTYET")));
if (searchReq.getSyncState() != null && !searchReq.getSyncState().isEmpty()) { 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()) { if (searchReq.getSyncCheckState() != null && !searchReq.getSyncCheckState().isEmpty()) {