파일경로를 application.yml에서 가져올수있게 동적으로 처리

This commit is contained in:
2026-02-26 11:46:17 +09:00
parent 2508f59a72
commit ee76389d6c
12 changed files with 361 additions and 421 deletions

View File

@@ -47,6 +47,10 @@ public class MapSheetMngService {
private final UploadService uploadService;
private final UserUtil userUtil = new UserUtil();
@Value("${file.root}")
private String nfsRootDir;
@Value("${file.sync-root-dir}")
private String syncRootDir;
@@ -70,8 +74,8 @@ public class MapSheetMngService {
// List조회
Page<YearEntity> years = mapSheetMngCoreService.getListMapListYYYYWithPaging(req);
return years.map(YearEntity::getYyyy).getContent().stream()
.sorted(Comparator.reverseOrder())
.toList();
.sorted(Comparator.reverseOrder())
.toList();
}
public MngDto findMapSheetMng(int mngYyyy) {
@@ -109,9 +113,8 @@ public class MapSheetMngService {
@Transactional
public DmlReturn uploadPair(
MultipartFile tfwFile, String tifFile, Long hstUid, Long tifFileSize) {
MultipartFile tfwFile, String tifFile, Long hstUid, Long tifFileSize) {
String rootPath = syncRootDir;
String tmpPath = syncTmpDir;
DmlReturn dmlReturn = new DmlReturn("success", "UPLOAD COMPLETE");
@@ -133,6 +136,7 @@ public class MapSheetMngService {
return dmlReturn;
}
//TODO 삭제?
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
// 중복체크 -> 도엽50k/uuid 경로에 업로드 할 거라 overwrite 되지 않음
@@ -179,27 +183,27 @@ public class MapSheetMngService {
// 파일이 존재하지 않을 경우(0개) 해당년도 다른 파일경로로 참조
if (uploadPath.isEmpty()) {
MngFilesDto filesDto =
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
String referPath = filesDto.getFilePath();
Path path = Paths.get(referPath);
boolean isFiveDigitNumber =
path.getFileName() != null && path.getFileName().toString().matches("\\d{5}");
path.getFileName() != null && path.getFileName().toString().matches("\\d{5}");
log.info("isFiveDigitNumber : " + isFiveDigitNumber);
if (isFiveDigitNumber) {
uploadPath =
Paths.get(referPath).getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum()
+ "/"
+ errDto.getUuid();
Paths.get(referPath).getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum()
+ "/"
+ errDto.getUuid();
} else {
uploadPath =
Paths.get(referPath).getParent().getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum()
+ "/"
+ errDto.getUuid();
Paths.get(referPath).getParent().getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum()
+ "/"
+ errDto.getUuid();
}
}
@@ -226,7 +230,7 @@ public class MapSheetMngService {
// hst업데이트
MapSheetMngDto.SyncCheckStateReqUpdateDto updReqSyncCheckState =
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
updReqSyncCheckState.setHstUid(hstUid);
updReqSyncCheckState.setFilePath(uploadPath);
updReqSyncCheckState.setSyncCheckTfwFileName(tfwFile.getOriginalFilename());
@@ -273,7 +277,7 @@ public class MapSheetMngService {
DmlReturn dmlReturn = new DmlReturn("success", "정상처리되었습니다.");
MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto =
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
for (Long uid : fileUids) {
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findByFileUidMapSheetFile(uid);
@@ -340,13 +344,13 @@ public class MapSheetMngService {
log.info("[FIND_FOLDER] DIR : {}", dirPath);
List<FIleChecker.Folder> folderList =
FIleChecker.getFolderAll(dirPath).stream()
.filter(dir -> dir.getIsValid().equals(true))
.toList();
FIleChecker.getFolderAll(dirPath, nfsRootDir).stream()
.filter(dir -> dir.getIsValid().equals(true))
.toList();
int folderTotCnt = folderList.size();
int folderErrTotCnt =
(int) folderList.stream().filter(dto -> dto.getIsValid().equals(false)).count();
(int) folderList.stream().filter(dto -> dto.getIsValid().equals(false)).count();
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderList);
}
@@ -358,14 +362,14 @@ public class MapSheetMngService {
int endPos = srchDto.getEndPos();
List<FIleChecker.Basic> 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();
@@ -382,18 +386,18 @@ public class MapSheetMngService {
List<MngDto> mngList = mapSheetMngCoreService.findMapSheetMngList();
List<MngYyyyDto> yearList =
mngList.stream()
.filter(
dto -> "DONE".equals(dto.getMngState()) || "TAKINGERROR".equals(dto.getMngState()))
.map(dto -> new MngYyyyDto(dto.getMngYyyy(), dto.getMngPath()))
.toList();
mngList.stream()
.filter(
dto -> "DONE".equals(dto.getMngState()) || "TAKINGERROR".equals(dto.getMngState()))
.map(dto -> new MngYyyyDto(dto.getMngYyyy(), dto.getMngPath()))
.toList();
return yearList;
}
@Transactional
public ModelUploadResDto uploadChunkMapSheetFile(
Long hstUid, UploadAddReq upAddReqDto, MultipartFile chunkFile) throws IOException {
Long hstUid, UploadAddReq upAddReqDto, MultipartFile chunkFile) throws IOException {
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
@@ -407,20 +411,20 @@ public class MapSheetMngService {
if (uploadPath.isEmpty()) {
MngFilesDto filesDto =
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
String referPath = filesDto.getFilePath();
Path path = Paths.get(referPath);
boolean isFiveDigitNumber =
path.getFileName() != null && path.getFileName().toString().matches("\\d{5}");
path.getFileName() != null && path.getFileName().toString().matches("\\d{5}");
log.info("isFiveDigitNumber : " + isFiveDigitNumber);
if (isFiveDigitNumber) {
uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum();
} else {
uploadPath =
Paths.get(referPath).getParent().getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum();
Paths.get(referPath).getParent().getParent().toString()
+ "/"
+ errDto.getRefMapSheetNum();
}
}
@@ -443,7 +447,7 @@ public class MapSheetMngService {
// upload_id, uuid 를 update
mapSheetMngCoreService.updateMapSheetMngHstUploadId(
hstUid, upAddReqDto.getUuid(), upRes.getUploadId());
hstUid, upAddReqDto.getUuid(), upRes.getUploadId());
}
modelUploadResDto.setRes(upRes.getRes());