파일 체크 수정 및 패키지 분리
This commit is contained in:
@@ -73,7 +73,10 @@ public class FIleChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean checkTfw(File file) {
|
public static boolean checkTfw(String filePath) {
|
||||||
|
|
||||||
|
File file = new File(filePath);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -100,7 +103,14 @@ public class FIleChecker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkGeoTiff(File file) {
|
public static boolean checkGeoTiff(String filePath) {
|
||||||
|
|
||||||
|
File file = new File(filePath);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
GeoTiffReader reader = null;
|
GeoTiffReader reader = null;
|
||||||
try {
|
try {
|
||||||
// 1. 파일 포맷 및 헤더 확인
|
// 1. 파일 포맷 및 헤더 확인
|
||||||
@@ -130,27 +140,65 @@ public class FIleChecker {
|
|||||||
|
|
||||||
public static Boolean cmmndGdalInfo(String filePath) {
|
public static Boolean cmmndGdalInfo(String filePath) {
|
||||||
|
|
||||||
|
File file = new File(filePath);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String resStr = "";
|
String resStr = "";
|
||||||
boolean hasDriver = false;
|
boolean hasDriver = false;
|
||||||
|
|
||||||
try {
|
|
||||||
// 리눅스/맥용
|
// 리눅스/맥용
|
||||||
ProcessBuilder pb = new ProcessBuilder("sh", "-c", "gdalinfo "+filePath+" | grep -i 'Geo'");
|
//ProcessBuilder pb = new ProcessBuilder("sh", "-c", "gdalinfo "+filePath+" | grep -i 'Geo'");
|
||||||
|
|
||||||
|
List<String> command = new ArrayList<>();
|
||||||
|
|
||||||
//윈도우용
|
//윈도우용
|
||||||
//ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "gdalinfo " + filePath + " | findstr /i \"Geo\"");
|
command.add("cmd.exe"); // 윈도우 명령 프롬프트 실행
|
||||||
Process process = pb.start();
|
command.add("/c"); // 명령어를 수행하고 종료한다는 옵션
|
||||||
|
command.add("C:\\Program Files\\QGIS 3.44.4\\bin\\gdalinfo");
|
||||||
|
command.add(filePath);
|
||||||
|
command.add("|");
|
||||||
|
command.add("findstr");
|
||||||
|
command.add("/i");
|
||||||
|
command.add("Geo");
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
/*
|
||||||
String line;
|
command.add("sh"); // 윈도우 명령 프롬프트 실행
|
||||||
|
command.add("-c"); // 명령어를 수행하고 종료한다는 옵션
|
||||||
|
command.add("gdalinfo");
|
||||||
|
command.add(filePath);
|
||||||
|
command.add("|");
|
||||||
|
command.add("grep");
|
||||||
|
command.add("-i");
|
||||||
|
command.add("Geo");
|
||||||
|
*/
|
||||||
|
|
||||||
while ((line = reader.readLine()) != null) {
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||||
if (line.contains("Driver: GTiff")) hasDriver = true;
|
processBuilder.redirectErrorStream(true);
|
||||||
//if (line.contains("Size is")) hasSize = true;
|
|
||||||
//if (line.contains("FAILURE:")) hasFailure = true;
|
try {
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
|
||||||
|
// 인코딩은 윈도우 한글 환경에 맞게 MS949로 지정
|
||||||
|
BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(process.getInputStream()));
|
||||||
|
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
//System.out.println(line);
|
||||||
|
if( line.contains("Driver: GTiff/GeoTIFF")) {
|
||||||
|
hasDriver = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasDriver;
|
return hasDriver;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,62 +32,6 @@ public class MapSheetMngApiController {
|
|||||||
private final CommonCodeService commonCodeService;
|
private final CommonCodeService commonCodeService;
|
||||||
private final MapSheetMngService mapSheetMngService;
|
private final MapSheetMngService mapSheetMngService;
|
||||||
|
|
||||||
@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("/folder-list")
|
|
||||||
public ApiResponseDto<FoldersDto> getDir(@RequestBody SrchFoldersDto srchDto) {
|
|
||||||
return ApiResponseDto.createOK(mapSheetMngService.getFolderAll(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-list")
|
|
||||||
public ApiResponseDto<FilesDto> getFiles(@RequestBody SrchFilesDto srchDto) {
|
|
||||||
|
|
||||||
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 SrchFilesDepthDto srchDto) {
|
|
||||||
|
|
||||||
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 오류데이터 목록 조회
|
* 오류데이터 목록 조회
|
||||||
*
|
*
|
||||||
@@ -120,26 +64,6 @@ public class MapSheetMngApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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("/sync-process")
|
|
||||||
public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadProcess(
|
|
||||||
@RequestBody @Valid ImageryDto.searchReq searchReq) {
|
|
||||||
return ApiResponseDto.ok(mapSheetMngService.syncProcess(searchReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hstUidList
|
* @param hstUidList
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.kamco.cd.kamcoback.mapsheet;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||||
|
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FoldersDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.service.MapSheetMngFileCheckerService;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.service.MapSheetMngService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Tag(name = "영상 관리", description = "영상 관리 API")
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping({"/api/mapsheet"})
|
||||||
|
public class MapSheetMngFileCheckerApiController {
|
||||||
|
|
||||||
|
private final CommonCodeService commonCodeService;
|
||||||
|
private final MapSheetMngFileCheckerService mapSheetMngFileCheckerService;
|
||||||
|
|
||||||
|
@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("/folder-list")
|
||||||
|
public ApiResponseDto<FoldersDto> getDir(@RequestBody SrchFoldersDto srchDto) {
|
||||||
|
return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFolderAll(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-list")
|
||||||
|
public ApiResponseDto<FilesDto> getFiles(@RequestBody SrchFilesDto srchDto) {
|
||||||
|
|
||||||
|
return ApiResponseDto.createOK(mapSheetMngFileCheckerService.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 SrchFilesDepthDto srchDto) {
|
||||||
|
|
||||||
|
return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFilesDepthAll(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("/sync-process")
|
||||||
|
public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadProcess(
|
||||||
|
@RequestBody @Valid ImageryDto.searchReq searchReq) {
|
||||||
|
return ApiResponseDto.ok(mapSheetMngFileCheckerService.syncProcess(searchReq));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,9 @@ public class FileDto {
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class SrchFoldersDto {
|
public static class SrchFoldersDto {
|
||||||
@NotNull private String dirPath;
|
@Schema(description = "디렉토리경로", example = "D:\\kamco")
|
||||||
|
@NotNull
|
||||||
|
private String dirPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -0,0 +1,310 @@
|
|||||||
|
package com.kamco.cd.kamcoback.mapsheet.service;
|
||||||
|
|
||||||
|
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.NameValidator;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FolderDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FoldersDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileCheckerCoreService;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public class MapSheetMngFileCheckerService {
|
||||||
|
|
||||||
|
private final MapSheetMngFileCheckerCoreService mapSheetMngFileCheckerCoreService;
|
||||||
|
|
||||||
|
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||||
|
|
||||||
|
System.out.println("getFolderAll === ");
|
||||||
|
|
||||||
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
|
String dirPath = srchDto.getDirPath();
|
||||||
|
|
||||||
|
int maxDepth = 1;
|
||||||
|
|
||||||
|
int folderTotCnt = 0;
|
||||||
|
int folderErrTotCnt = 0;
|
||||||
|
|
||||||
|
List<FolderDto> folderDtoList = List.of();
|
||||||
|
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
||||||
|
|
||||||
|
folderDtoList =
|
||||||
|
stream
|
||||||
|
// 1. 디렉토리만 필터링
|
||||||
|
.filter(Files::isDirectory)
|
||||||
|
.filter(p -> !p.toString().equals(dirPath))
|
||||||
|
.map(
|
||||||
|
path -> {
|
||||||
|
int depth = path.getNameCount();
|
||||||
|
|
||||||
|
String folderNm = path.getFileName().toString();
|
||||||
|
String parentFolderNm = path.getParent().getFileName().toString();
|
||||||
|
String parentPath = path.getParent().toString();
|
||||||
|
String fullPath = path.toAbsolutePath().toString();
|
||||||
|
|
||||||
|
boolean isValid =
|
||||||
|
!NameValidator.containsKorean(folderNm)
|
||||||
|
&& !NameValidator.containsWhitespaceRegex(folderNm);
|
||||||
|
|
||||||
|
File directory = new File(fullPath);
|
||||||
|
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||||
|
|
||||||
|
long childCnt = 0;
|
||||||
|
if (childFolders != null) {
|
||||||
|
childCnt = childFolders.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileTime time = null;
|
||||||
|
String lastModified = "";
|
||||||
|
try {
|
||||||
|
time = Files.getLastModifiedTime(path);
|
||||||
|
lastModified = dttmFormat.format(new Date(time.toMillis()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FolderDto(
|
||||||
|
folderNm,
|
||||||
|
parentFolderNm,
|
||||||
|
parentPath,
|
||||||
|
fullPath,
|
||||||
|
depth,
|
||||||
|
childCnt,
|
||||||
|
lastModified,
|
||||||
|
isValid);
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
folderDtoList.sort(
|
||||||
|
Comparator.comparing(
|
||||||
|
FolderDto::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
||||||
|
)
|
||||||
|
.reversed());
|
||||||
|
|
||||||
|
folderTotCnt = folderDtoList.size();
|
||||||
|
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);
|
||||||
|
|
||||||
|
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||||
|
|
||||||
|
String dirPath = srchDto.getDirPath();
|
||||||
|
String extension = srchDto.getExtension();
|
||||||
|
String sortType = srchDto.getSortType();
|
||||||
|
int startPos = srchDto.getStartPos();
|
||||||
|
int endPos = srchDto.getEndPos();
|
||||||
|
File dir = new File(dirPath);
|
||||||
|
File[] fileList = dir.listFiles();
|
||||||
|
|
||||||
|
List<FileDto.Basic> files = new ArrayList<>();
|
||||||
|
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
int fileListPos = 0;
|
||||||
|
int fileTotCnt = 0;
|
||||||
|
long fileTotSize = 0;
|
||||||
|
|
||||||
|
if (fileList != null) {
|
||||||
|
if (sortType.equals("name")) {
|
||||||
|
Arrays.sort(fileList);
|
||||||
|
} else if (sortType.equals("date")) {
|
||||||
|
Arrays.sort(fileList, Comparator.comparingLong(File::lastModified));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (File file : fileList) {
|
||||||
|
if (file.isFile()) { // 파일인 경우만
|
||||||
|
if (extension.equals("*") || file.getName().endsWith("." + extension)) {
|
||||||
|
|
||||||
|
fileListPos = fileListPos + 1;
|
||||||
|
|
||||||
|
if (startPos <= fileListPos && endPos >= fileListPos) {
|
||||||
|
|
||||||
|
// 생성자를 통해 객체를 만들고 리스트에 추가
|
||||||
|
String fileName = file.getName();
|
||||||
|
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, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
||||||
|
|
||||||
|
fileTotCnt = fileTotCnt + 1;
|
||||||
|
fileTotSize = fileTotSize + fileSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FilesDto(dirPath, fileTotCnt, fileTotSize, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilesDto getFilesDepthAll(SrchFilesDepthDto srchDto) {
|
||||||
|
|
||||||
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
|
int maxDepth = srchDto.getMaxDepth();
|
||||||
|
String dirPath = srchDto.getDirPath();
|
||||||
|
String extension = srchDto.getExtension();
|
||||||
|
String sortType = srchDto.getSortType();
|
||||||
|
|
||||||
|
int startPos = srchDto.getStartPos();
|
||||||
|
int endPos = srchDto.getEndPos();
|
||||||
|
int limit = endPos - startPos + 1;
|
||||||
|
|
||||||
|
Set<String> targetExtensions = createExtensionSet(extension);
|
||||||
|
|
||||||
|
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)
|
||||||
|
.filter(
|
||||||
|
p ->
|
||||||
|
extension == null
|
||||||
|
|| extension.equals("")
|
||||||
|
|| extension.equals("*")
|
||||||
|
|| targetExtensions.contains(extractExtension(p)))
|
||||||
|
.sorted(getFileComparator(sortType))
|
||||||
|
.skip(startPos)
|
||||||
|
.limit(limit)
|
||||||
|
.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());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FilesDto(dirPath, fileTotCnt, fileTotSize, fileDtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> createExtensionSet(String extensionString) {
|
||||||
|
if (extensionString == null || extensionString.isBlank()) {
|
||||||
|
return Set.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
// "java, class" -> ["java", " class"] -> [".java", ".class"]
|
||||||
|
return Arrays.stream(extensionString.split(","))
|
||||||
|
.map(ext -> ext.trim())
|
||||||
|
.filter(ext -> !ext.isEmpty())
|
||||||
|
.map(ext -> "." + ext.toLowerCase())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String extractExtension(Path path) {
|
||||||
|
String filename = path.getFileName().toString();
|
||||||
|
int lastDotIndex = filename.lastIndexOf('.');
|
||||||
|
|
||||||
|
// 확장자가 없거나 파일명이 .으로 끝나는 경우
|
||||||
|
if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1) {
|
||||||
|
return ""; // 빈 문자열 반환
|
||||||
|
}
|
||||||
|
|
||||||
|
// 확장자 추출 및 소문자 변환
|
||||||
|
return filename.substring(lastDotIndex).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comparator<Path> getFileComparator(String sortType) {
|
||||||
|
|
||||||
|
// 파일 이름 비교 기본 Comparator (대소문자 무시)
|
||||||
|
Comparator<Path> nameComparator =
|
||||||
|
Comparator.comparing(path -> path.getFileName().toString(), CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
|
Comparator<Path> dateComparator =
|
||||||
|
Comparator.comparing(
|
||||||
|
path -> {
|
||||||
|
try {
|
||||||
|
return Files.getLastModifiedTime(path);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return FileTime.fromMillis(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ("name desc".equalsIgnoreCase(sortType)) {
|
||||||
|
return nameComparator.reversed();
|
||||||
|
} else if ("date".equalsIgnoreCase(sortType)) {
|
||||||
|
return dateComparator;
|
||||||
|
} else if ("date desc".equalsIgnoreCase(sortType)) {
|
||||||
|
return dateComparator.reversed();
|
||||||
|
} else {
|
||||||
|
return nameComparator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
||||||
|
return mapSheetMngFileCheckerCoreService.syncProcess(searchReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -42,90 +42,7 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
|
|
||||||
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
|
||||||
|
|
||||||
Path startPath = Paths.get(srchDto.getDirPath());
|
|
||||||
String dirPath = srchDto.getDirPath();
|
|
||||||
|
|
||||||
int maxDepth = 1;
|
|
||||||
|
|
||||||
int folderTotCnt = 0;
|
|
||||||
int folderErrTotCnt = 0;
|
|
||||||
|
|
||||||
List<FolderDto> folderDtoList = List.of();
|
|
||||||
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
|
||||||
|
|
||||||
folderDtoList =
|
|
||||||
stream
|
|
||||||
// 1. 디렉토리만 필터링
|
|
||||||
.filter(Files::isDirectory)
|
|
||||||
.filter(p -> !p.toString().equals(dirPath))
|
|
||||||
.map(
|
|
||||||
path -> {
|
|
||||||
int depth = path.getNameCount();
|
|
||||||
|
|
||||||
String folderNm = path.getFileName().toString();
|
|
||||||
String parentFolderNm = path.getParent().getFileName().toString();
|
|
||||||
String parentPath = path.getParent().toString();
|
|
||||||
String fullPath = path.toAbsolutePath().toString();
|
|
||||||
|
|
||||||
boolean isValid =
|
|
||||||
!NameValidator.containsKorean(folderNm)
|
|
||||||
&& !NameValidator.containsWhitespaceRegex(folderNm);
|
|
||||||
|
|
||||||
File directory = new File(fullPath);
|
|
||||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
|
||||||
|
|
||||||
long childCnt = 0;
|
|
||||||
if (childFolders != null) {
|
|
||||||
childCnt = childFolders.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileTime time = null;
|
|
||||||
String lastModified = "";
|
|
||||||
try {
|
|
||||||
time = Files.getLastModifiedTime(path);
|
|
||||||
lastModified = dttmFormat.format(new Date(time.toMillis()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new FolderDto(
|
|
||||||
folderNm,
|
|
||||||
parentFolderNm,
|
|
||||||
parentPath,
|
|
||||||
fullPath,
|
|
||||||
depth,
|
|
||||||
childCnt,
|
|
||||||
lastModified,
|
|
||||||
isValid);
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
folderDtoList.sort(
|
|
||||||
Comparator.comparing(
|
|
||||||
FolderDto::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
|
||||||
)
|
|
||||||
.reversed());
|
|
||||||
|
|
||||||
folderTotCnt = folderDtoList.size();
|
|
||||||
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);
|
|
||||||
|
|
||||||
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||||
|
|
||||||
@@ -320,8 +237,6 @@ public class MapSheetMngService {
|
|||||||
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
|
||||||
return mapSheetMngCoreService.syncProcess(searchReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.core;
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
@@ -125,23 +126,6 @@ public class MapSheetMngCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
//대상파일목록 가저오기
|
|
||||||
Page<ImageryDto.SyncDto> pageImagerySyncDto = mapSheetMngRepository.findImageryList(searchReq);
|
|
||||||
//List<ImagerySyncDto> imagerySyncDtoList = pageImagerySyncDto.getContent();
|
|
||||||
|
|
||||||
for (ImageryDto.SyncDto dto : pageImagerySyncDto.getContent()) {
|
|
||||||
// 여기에 처리 로직 작성
|
|
||||||
System.out.println("ID: " + dto.getId());
|
|
||||||
|
|
||||||
// 예: 특정 작업 수행
|
|
||||||
// someService.process(dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngFileCheckerRepository;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MapSheetMngFileCheckerCoreService {
|
||||||
|
|
||||||
|
private final MapSheetMngFileCheckerRepository mapSheetMngFileCheckerRepository;
|
||||||
|
|
||||||
|
private static final String ORIGINAL_IMAGES_PATH = "/app/original-images";
|
||||||
|
|
||||||
|
@Value("{spring.profiles.active}")
|
||||||
|
private String activeEnv;
|
||||||
|
|
||||||
|
|
||||||
|
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
//대상파일목록 가저오기
|
||||||
|
Page<ImageryDto.SyncDto> pageImagerySyncDto = mapSheetMngFileCheckerRepository.findImagerySyncList(searchReq);
|
||||||
|
|
||||||
|
|
||||||
|
for (ImageryDto.SyncDto dto : pageImagerySyncDto.getContent()) {
|
||||||
|
|
||||||
|
boolean isTfwFile = true;
|
||||||
|
isTfwFile = FIleChecker.checkTfw(dto.getMiddlePath()+dto.getFilename());
|
||||||
|
|
||||||
|
//boolean isCogTiffFile = true;
|
||||||
|
//isCogTiffFile = FIleChecker.checkGeoTiff("D:\\kamco_cog\\36713\\36713073_cog.tif");
|
||||||
|
|
||||||
|
boolean isGdalInfoTiffFile = true;
|
||||||
|
//isGdalInfoTiffFile = FIleChecker.cmmndGdalInfo("D:\\kamco_cog\\36713\\36713073_cog.tif");
|
||||||
|
isGdalInfoTiffFile = FIleChecker.cmmndGdalInfo("D:/kamco_cog/36713/36713073_cog.tif");
|
||||||
|
|
||||||
|
System.out.println("isTfwFile == " + isTfwFile);
|
||||||
|
System.out.println("isGdalInfoTiffFile == " + isGdalInfoTiffFile);
|
||||||
|
// 여기에 처리 로직 작성
|
||||||
|
|
||||||
|
|
||||||
|
// 예: 특정 작업 수행
|
||||||
|
// someService.process(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface MapSheetMngFileCheckerRepository
|
||||||
|
extends JpaRepository<MapSheetMngEntity, Long>, MapSheetMngFileCheckerRepositoryCustom {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
|
public interface MapSheetMngFileCheckerRepositoryCustom {
|
||||||
|
|
||||||
|
Page<ImageryDto.SyncDto> findImagerySyncList(ImageryDto.@Valid searchReq searchReq);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||||
|
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QImageryEntity.imageryEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
|
import com.querydsl.core.BooleanBuilder;
|
||||||
|
import com.querydsl.core.types.Projections;
|
||||||
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
|
import com.querydsl.core.types.dsl.NumberExpression;
|
||||||
|
import com.querydsl.core.types.dsl.StringExpression;
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||||
|
|
||||||
|
public class MapSheetMngFileCheckerRepositoryImpl extends QuerydslRepositorySupport
|
||||||
|
implements MapSheetMngFileCheckerRepositoryCustom {
|
||||||
|
|
||||||
|
private final JPAQueryFactory queryFactory;
|
||||||
|
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||||
|
|
||||||
|
public MapSheetMngFileCheckerRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||||
|
super(MapSheetMngHstEntity.class);
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ImageryDto.SyncDto> findImagerySyncList(ImageryDto.@Valid searchReq searchReq) {
|
||||||
|
|
||||||
|
Pageable pageable = searchReq.toPageable();
|
||||||
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||||
|
|
||||||
|
if (searchReq.getMngYyyy() != null) {
|
||||||
|
whereBuilder.and(imageryEntity.year.eq(searchReq.getMngYyyy()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ImageryDto.SyncDto> foundContent =
|
||||||
|
queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
ImageryDto.SyncDto.class,
|
||||||
|
imageryEntity.id,
|
||||||
|
imageryEntity.year,
|
||||||
|
imageryEntity.scene50k,
|
||||||
|
imageryEntity.scene5k,
|
||||||
|
imageryEntity.middlePath,
|
||||||
|
imageryEntity.cogMiddlePath,
|
||||||
|
imageryEntity.filename,
|
||||||
|
imageryEntity.cogFilename,
|
||||||
|
mapSheetMngHstEntity.hstUid
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(imageryEntity)
|
||||||
|
.leftJoin(mapSheetMngHstEntity).on(
|
||||||
|
imageryEntity.year.eq(mapSheetMngHstEntity.mngYyyy)
|
||||||
|
.and(imageryEntity.scene5k.eq(mapSheetMngHstEntity.mapSheetNum.stringValue())))
|
||||||
|
.where(whereBuilder)
|
||||||
|
.offset(pageable.getOffset())
|
||||||
|
.limit(pageable.getPageSize())
|
||||||
|
//.orderBy(mapSheetMngEntity.createdDttm.desc())
|
||||||
|
.fetch();
|
||||||
|
|
||||||
|
Long countQuery =
|
||||||
|
queryFactory
|
||||||
|
.select(imageryEntity.id.count())
|
||||||
|
.from(imageryEntity)
|
||||||
|
.where(whereBuilder)
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private NumberExpression<Integer> rowNum() {
|
||||||
|
return Expressions.numberTemplate(
|
||||||
|
Integer.class, "row_number() over(order by {0} desc)", mapSheetMngHstEntity.createdDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,5 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
||||||
|
|
||||||
Page<ImageryDto.SyncDto> findImageryList(ImageryDto.@Valid searchReq searchReq);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,48 +141,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ImageryDto.SyncDto> findImageryList(ImageryDto.@Valid searchReq searchReq) {
|
|
||||||
|
|
||||||
Pageable pageable = searchReq.toPageable();
|
|
||||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
|
||||||
|
|
||||||
if (searchReq.getMngYyyy() != null) {
|
|
||||||
whereBuilder.and(imageryEntity.year.eq(searchReq.getMngYyyy()));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ImageryDto.SyncDto> foundContent =
|
|
||||||
queryFactory
|
|
||||||
.select(
|
|
||||||
Projections.constructor(
|
|
||||||
ImageryDto.SyncDto.class,
|
|
||||||
imageryEntity.id,
|
|
||||||
imageryEntity.year,
|
|
||||||
imageryEntity.scene50k,
|
|
||||||
imageryEntity.scene5k,
|
|
||||||
imageryEntity.middlePath,
|
|
||||||
imageryEntity.cogMiddlePath,
|
|
||||||
imageryEntity.filename,
|
|
||||||
imageryEntity.cogFilename
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(imageryEntity)
|
|
||||||
.where(whereBuilder)
|
|
||||||
.offset(pageable.getOffset())
|
|
||||||
.limit(pageable.getPageSize())
|
|
||||||
//.orderBy(mapSheetMngEntity.createdDttm.desc())
|
|
||||||
.fetch();
|
|
||||||
|
|
||||||
Long countQuery =
|
|
||||||
queryFactory
|
|
||||||
.select(imageryEntity.id.count())
|
|
||||||
.from(imageryEntity)
|
|
||||||
.where(whereBuilder)
|
|
||||||
.fetchOne();
|
|
||||||
|
|
||||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) {
|
public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) {
|
||||||
@@ -214,7 +172,4 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user