Merge pull request 'feat/dev_251201' (#112) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/112
This commit is contained in:
@@ -9,10 +9,10 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MngStateType implements EnumType {
|
public enum MngStateType implements EnumType {
|
||||||
NOTYET("미처리"),
|
NOTYET("동기화 시작"),
|
||||||
PROCESSING("진행중"),
|
PROCESSING("데이터 체크"),
|
||||||
DONE("싱크완료"),
|
DONE("동기화작업종료"),
|
||||||
COMPLETE("작업완료");
|
TAKINGERROR("오류 데이터 처리중");
|
||||||
|
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ public enum SyncStateType implements EnumType {
|
|||||||
NOFILE("파일없음"),
|
NOFILE("파일없음"),
|
||||||
NOTPAIR("페어파일누락"),
|
NOTPAIR("페어파일누락"),
|
||||||
DUPLICATE("파일중복"),
|
DUPLICATE("파일중복"),
|
||||||
SIZEERROR("파일용량오류"),
|
TYPEERROR("손상파일"),
|
||||||
TYPEERROR("파일형식오류"),
|
|
||||||
DONE("완료");
|
DONE("완료");
|
||||||
|
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import lombok.Getter;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.geotools.coverage.grid.GridCoverage2D;
|
import org.geotools.coverage.grid.GridCoverage2D;
|
||||||
import org.geotools.gce.geotiff.GeoTiffReader;
|
import org.geotools.gce.geotiff.GeoTiffReader;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
public class FIleChecker {
|
public class FIleChecker {
|
||||||
|
|
||||||
@@ -455,6 +456,15 @@ 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(String dir, String targetFileNm, String extension) {
|
||||||
|
|
||||||
|
List<FIleChecker.Basic> basicList =
|
||||||
|
FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension);
|
||||||
|
|
||||||
|
return (int)
|
||||||
|
basicList.stream().filter(dto -> dto.getExtension().toString().equals(extension)).count();
|
||||||
|
}
|
||||||
|
|
||||||
public static Long getFileTotSize(List<FIleChecker.Basic> files) {
|
public static Long getFileTotSize(List<FIleChecker.Basic> files) {
|
||||||
|
|
||||||
Long fileTotSize = 0L;
|
Long fileTotSize = 0L;
|
||||||
@@ -465,6 +475,15 @@ public class FIleChecker {
|
|||||||
return fileTotSize;
|
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) {
|
public static boolean checkExtensions(String fileName, String ext) {
|
||||||
if (fileName == null) return false;
|
if (fileName == null) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class MapSheetMngApiController {
|
|||||||
@RequestPart("tif") MultipartFile tifFile,
|
@RequestPart("tif") MultipartFile tifFile,
|
||||||
@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(
|
return ApiResponseDto.createOK(
|
||||||
mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite));
|
mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,38 @@ public class MapSheetMngDto {
|
|||||||
private Long syncDuplicateExecCnt;
|
private Long syncDuplicateExecCnt;
|
||||||
private Long syncFaultCnt;
|
private Long syncFaultCnt;
|
||||||
private Long syncFaultExecCnt;
|
private Long syncFaultExecCnt;
|
||||||
|
private Long syncNoFileCnt;
|
||||||
|
private Long syncNoFileExecCnt;
|
||||||
@JsonFormatDttm private ZonedDateTime rgstStrtDttm;
|
@JsonFormatDttm private ZonedDateTime rgstStrtDttm;
|
||||||
@JsonFormatDttm private ZonedDateTime rgstEndDttm;
|
@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() {
|
public double getSyncStateDoneRate() {
|
||||||
if (this.syncTotCnt == null || this.syncTotCnt == 0) {
|
if (this.syncTotCnt == null || this.syncTotCnt == 0) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.nio.file.Paths;
|
|||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -32,6 +33,15 @@ public class MapSheetMngService {
|
|||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
private final FileConfig fileConfig;
|
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<MngDto> findMapSheetMngList() {
|
public List<MngDto> findMapSheetMngList() {
|
||||||
return mapSheetMngCoreService.findMapSheetMngList();
|
return mapSheetMngCoreService.findMapSheetMngList();
|
||||||
}
|
}
|
||||||
@@ -77,8 +87,10 @@ public class MapSheetMngService {
|
|||||||
public DmlReturn uploadPair(
|
public DmlReturn uploadPair(
|
||||||
MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) {
|
MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) {
|
||||||
|
|
||||||
String rootPath = fileConfig.getRootSyncDir();
|
String rootPath = syncRootDir;
|
||||||
String tmpPath = fileConfig.getTmpSyncDir();
|
String tmpPath = syncTmpDir;
|
||||||
|
|
||||||
|
DmlReturn dmlReturn = new DmlReturn("success", "UPLOAD COMPLETE");
|
||||||
|
|
||||||
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||||
|
|
||||||
@@ -91,43 +103,21 @@ public class MapSheetMngService {
|
|||||||
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 파일 유효성 검증
|
// 업로드 파일 사이즈,확장자명 체크
|
||||||
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
dmlReturn = this.validationFile(tfwFile, tifFile);
|
||||||
return new DmlReturn("fail", "TFW SIZE 오류");
|
if (dmlReturn.getFlag().equals("fail")) return dmlReturn;
|
||||||
} else if (tifFile == null || tifFile.isEmpty() || tifFile.getSize() == 0) {
|
|
||||||
return new DmlReturn("fail", "TIF SIZE 오류");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 확장자명 체크
|
|
||||||
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());
|
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
|
||||||
String targetYearDir = mngDto.getMngPath();
|
String targetYearDir = mngDto.getMngPath();
|
||||||
|
|
||||||
// 중복체크
|
// 중복체크
|
||||||
List<FIleChecker.Basic> basicTfwList =
|
if (!overwrite) {
|
||||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
|
||||||
|
|
||||||
List<FIleChecker.Basic> basicTifList =
|
|
||||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif");
|
|
||||||
|
|
||||||
int tfwCnt =
|
int tfwCnt =
|
||||||
(int)
|
FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||||
basicTfwList.stream()
|
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
|
||||||
.count();
|
|
||||||
|
|
||||||
int tifCnt =
|
int tifCnt =
|
||||||
(int)
|
FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||||
basicTifList.stream()
|
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
|
||||||
.count();
|
|
||||||
|
|
||||||
if (!overwrite) {
|
|
||||||
if (tfwCnt > 0 || tifCnt > 0) {
|
if (tfwCnt > 0 || tifCnt > 0) {
|
||||||
String tfwtifMsg = "";
|
String tfwtifMsg = "";
|
||||||
if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename();
|
if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename();
|
||||||
@@ -222,6 +212,17 @@ public class MapSheetMngService {
|
|||||||
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
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<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
public List<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||||
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
mapSheetMngEntity.mngState,
|
mapSheetMngEntity.mngState,
|
||||||
mapSheetMngEntity.syncState,
|
mapSheetMngEntity.syncState,
|
||||||
mapSheetMngEntity.syncCheckState,
|
mapSheetMngEntity.syncCheckState,
|
||||||
mapSheetMngHstEntity.count(),
|
mapSheetMngHstEntity.count().as("syncTotalCnt"),
|
||||||
new CaseBuilder()
|
new CaseBuilder()
|
||||||
.when(mapSheetMngHstEntity.dataState.eq("DONE"))
|
.when(mapSheetMngHstEntity.dataState.eq("DONE"))
|
||||||
.then(1L)
|
.then(1L)
|
||||||
@@ -141,6 +141,20 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.then(1L)
|
.then(1L)
|
||||||
.otherwise(0L)
|
.otherwise(0L)
|
||||||
.sum(),
|
.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,
|
mapSheetMngEntity.createdDttm,
|
||||||
mapSheetMngHstEntity.syncEndDttm.max()))
|
mapSheetMngHstEntity.syncEndDttm.max()))
|
||||||
.from(mapSheetMngEntity)
|
.from(mapSheetMngEntity)
|
||||||
@@ -209,7 +223,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
mapSheetMngEntity.mngState,
|
mapSheetMngEntity.mngState,
|
||||||
mapSheetMngEntity.syncState,
|
mapSheetMngEntity.syncState,
|
||||||
mapSheetMngEntity.syncCheckState,
|
mapSheetMngEntity.syncCheckState,
|
||||||
mapSheetMngHstEntity.count(),
|
mapSheetMngHstEntity.count().as("syncTotalCnt"),
|
||||||
new CaseBuilder()
|
new CaseBuilder()
|
||||||
.when(mapSheetMngHstEntity.dataState.eq("DONE"))
|
.when(mapSheetMngHstEntity.dataState.eq("DONE"))
|
||||||
.then(1L)
|
.then(1L)
|
||||||
@@ -271,6 +285,20 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.then(1L)
|
.then(1L)
|
||||||
.otherwise(0L)
|
.otherwise(0L)
|
||||||
.sum(),
|
.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,
|
mapSheetMngEntity.createdDttm,
|
||||||
mapSheetMngHstEntity.syncEndDttm.max()))
|
mapSheetMngHstEntity.syncEndDttm.max()))
|
||||||
.from(mapSheetMngEntity)
|
.from(mapSheetMngEntity)
|
||||||
@@ -295,23 +323,6 @@ 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()) {
|
||||||
/*
|
|
||||||
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()));
|
whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,17 +64,8 @@ management:
|
|||||||
include:
|
include:
|
||||||
- "health"
|
- "health"
|
||||||
|
|
||||||
# GeoJSON 파일 모니터링 설정
|
|
||||||
geojson:
|
file:
|
||||||
monitor:
|
sync-root-dir: /app/original-images/
|
||||||
watch-directory: ~/geojson/upload
|
sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||||
processed-directory: ~/geojson/processed
|
sync-file-extention: tfw,tif
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user