Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201

# Conflicts:
#	src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/FileDto.java
#	src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java
#	src/main/java/com/kamco/cd/kamcoback/postgres/entity/CommonCodeEntity.java
This commit is contained in:
2025-12-03 18:50:34 +09:00
13 changed files with 366 additions and 95 deletions

View File

@@ -67,6 +67,27 @@ public class MapSheetMngApiController {
return ApiResponseDto.createOK(mapSheetMngService.getFilesAll(srchDto));
}
@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)
})
@PostMapping("/file-all-list")
public ApiResponseDto<FilesDto> getAllFiles(@RequestBody SrchFilesDto srchDto) {
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
}
/**
* 오류데이터 목록 조회
*

View File

@@ -23,10 +23,15 @@ public class FileDto {
@NoArgsConstructor
@AllArgsConstructor
public static class SrchFilesDto {
@Schema(description = "디렉토리경로", example = "/data")
@NotNull private String dirPath;
@Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
@NotNull private String extension;
@Schema(description = "파일명(name), 최종수정일(date)", example = "name")
@NotNull private String sortType;
@Schema(description = "파일시작위치", example = "1")
@NotNull private Integer startPos;
@Schema(description = "파일종료위치", example = "100")
@NotNull private Integer endPos;
}
@@ -43,14 +48,14 @@ public class FileDto {
private final Boolean isValid;
public FolderDto(
String folderNm,
String parentFolderNm,
String parentPath,
String fullPath,
int depth,
long childCnt,
String lastModified,
Boolean isValid) {
String folderNm,
String parentFolderNm,
String parentPath,
String fullPath,
int depth,
long childCnt,
String lastModified,
Boolean isValid) {
this.folderNm = folderNm;
this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath;
@@ -70,8 +75,7 @@ public class FileDto {
private final int folderErrTotCnt;
private final List<FolderDto> folders;
public FoldersDto(
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
public FoldersDto(String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
this.dirPath = dirPath;
this.folderTotCnt = folderTotCnt;
@@ -80,20 +84,26 @@ public class FileDto {
}
}
@Schema(name = "File Basic", description = "파일 기본 정보")
@Getter
public static class Basic {
private final String fileNm;
private final String filePath;
private final String parentFolderNm;
private final String parentPath;
private final String fullPath;
private final String extension;
private final long fileSize;
private final String lastModified;
public Basic(
String fileNm, String filePath, String extension, long fileSize, String lastModified) {
String fileNm, String parentFolderNm, String parentPath, String fullPath, String extension, long fileSize, String lastModified) {
this.fileNm = fileNm;
this.filePath = filePath;
this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath;
this.fullPath = fullPath;
this.extension = extension;
this.fileSize = fileSize;
this.lastModified = lastModified;

View File

@@ -37,6 +37,7 @@ public class MapSheetMngService {
private final MapSheetMngCoreService mapSheetMngCoreService;
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
Path startPath = Paths.get(srchDto.getDirPath());
@@ -66,11 +67,8 @@ public class MapSheetMngService {
String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString();
boolean isValid = true;
if (NameValidator.containsKorean(folderNm)
|| NameValidator.containsWhitespaceRegex(folderNm)) {
isValid = false;
}
boolean isValid = !NameValidator.containsKorean(folderNm) &&
!NameValidator.containsWhitespaceRegex(folderNm);
File directory = new File(fullPath);
File[] childFolders = directory.listFiles(File::isDirectory);
@@ -81,26 +79,24 @@ public class MapSheetMngService {
}
FileTime time = null;
String lastModified = "";
try {
time = Files.getLastModifiedTime(path);
lastModified = dttmFormat.format(new Date(time.toMillis()));
} catch (IOException e) {
throw new RuntimeException(e);
}
String lastModified = dttmFormat.format(new Date(time.toMillis()));
FolderDto folderDto =
new FolderDto(
folderNm,
parentFolderNm,
parentPath,
fullPath,
depth,
childCnt,
lastModified,
isValid);
return folderDto;
return new FolderDto(
folderNm,
parentFolderNm,
parentPath,
fullPath,
depth,
childCnt,
lastModified,
isValid
);
})
.collect(Collectors.toList());
@@ -112,19 +108,17 @@ public class MapSheetMngService {
folderTotCnt = folderDtoList.size();
folderErrTotCnt =
(int)
folderDtoList.stream()
.filter(dto -> dto.getIsValid().toString().equals("false"))
.count();
folderErrTotCnt = (int)folderDtoList.stream()
.filter(dto -> dto.getIsValid().toString().equals("false") )
.count();
} catch (IOException e) {
throw new RuntimeException(e);
}
FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
// FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
return foldersDto;
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
}
public FilesDto getFilesAll(SrchFilesDto srchDto) {
@@ -161,12 +155,17 @@ public class MapSheetMngService {
// 생성자를 통해 객체를 만들고 리스트에 추가
String fileName = file.getName();
String filePath = file.getAbsolutePath();
String parentPath = file.getParent();
String fullPath = file.getAbsolutePath();
String ext = FilenameUtils.getExtension(fileName);
Path path = Paths.get(parentPath);
String parentFolderNm = path.getFileName().toString();
long fileSize = file.length();
String lastModified = dttmFormat.format(new Date(file.lastModified()));
files.add(new FileDto.Basic(fileName, filePath, ext, fileSize, lastModified));
files.add(new FileDto.Basic(fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
fileTotCnt = fileTotCnt + 1;
fileTotSize = fileTotSize + fileSize;
@@ -181,6 +180,61 @@ public class MapSheetMngService {
return filesDto;
}
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
int maxDepth = 20;
Path startPath = Paths.get(srchDto.getDirPath());
String dirPath = srchDto.getDirPath();
String extension = srchDto.getExtension();
List<FileDto.Basic> fileDtoList = new ArrayList<>();
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int fileTotCnt = 0;
long fileTotSize = 0;
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
fileDtoList =
stream
.filter(Files::isRegularFile)
.map(
path -> {
int depth = path.getNameCount();
String fileNm = path.getFileName().toString();
String ext = FilenameUtils.getExtension(fileNm);
String parentFolderNm = path.getParent().getFileName().toString();
String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString();
File file = new File(fullPath);
long fileSize = file.length();
String lastModified = dttmFormat.format(new Date(file.lastModified()));
return new FileDto.Basic(fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
})
.collect(Collectors.toList());
fileTotCnt = fileDtoList.size();
fileTotSize = fileDtoList.stream()
.mapToLong(FileDto.Basic::getFileSize)
.sum();
} catch (IOException e) {
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
}
FilesDto filesDto = new FilesDto(dirPath, fileTotCnt, fileTotSize, fileDtoList);
return filesDto;
}
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq) {
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);