영상관리 수정 반영
This commit is contained in:
@@ -32,6 +32,8 @@ import org.geotools.gce.geotiff.GeoTiffReader;
|
||||
|
||||
public class FIleChecker {
|
||||
|
||||
static SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static boolean isValidFile(String pathStr) {
|
||||
|
||||
Path path = Paths.get(pathStr);
|
||||
@@ -210,7 +212,7 @@ public class FIleChecker {
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("gdalinfo 출력: " + line);
|
||||
// System.out.println("gdalinfo 출력: " + line);
|
||||
if (line.contains("Driver: GTiff/GeoTIFF")) {
|
||||
hasDriver = true;
|
||||
break;
|
||||
@@ -254,34 +256,131 @@ public class FIleChecker {
|
||||
return hasDriver;
|
||||
}
|
||||
|
||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
private final String fileNm;
|
||||
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 parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
String extension,
|
||||
long fileSize,
|
||||
String lastModified) {
|
||||
this.fileNm = fileNm;
|
||||
this.parentFolderNm = parentFolderNm;
|
||||
this.parentPath = parentPath;
|
||||
this.fullPath = fullPath;
|
||||
this.extension = extension;
|
||||
this.fileSize = fileSize;
|
||||
this.lastModified = lastModified;
|
||||
public static boolean mkDir(String dirPath)
|
||||
{
|
||||
Path uploadTargetPath = Paths.get(dirPath);
|
||||
try {
|
||||
Files.createDirectories(uploadTargetPath);
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Folder> getFolderAll(String dirPath, String sortType, int maxDepth) {
|
||||
|
||||
Path startPath = Paths.get(dirPath);
|
||||
|
||||
List<Folder> folderList = List.of();
|
||||
|
||||
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
||||
|
||||
folderList =
|
||||
stream
|
||||
.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 file = new File(fullPath);
|
||||
int childCnt = getChildFolderCount(file);
|
||||
String lastModified = getLastModified(file);
|
||||
|
||||
return new Folder(
|
||||
folderNm,
|
||||
parentFolderNm,
|
||||
parentPath,
|
||||
fullPath,
|
||||
depth,
|
||||
childCnt,
|
||||
lastModified,
|
||||
isValid);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (sortType.equals("name") || sortType.equals("name asc")) {
|
||||
folderList.sort(
|
||||
Comparator.comparing(
|
||||
Folder::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
||||
));
|
||||
} else if (sortType.equals("name desc")) {
|
||||
folderList.sort(
|
||||
Comparator.comparing(
|
||||
Folder::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
||||
)
|
||||
.reversed());
|
||||
} else if (sortType.equals("dttm desc")) {
|
||||
folderList.sort(
|
||||
Comparator.comparing(
|
||||
Folder::getLastModified, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
||||
)
|
||||
.reversed());
|
||||
} else {
|
||||
folderList.sort(
|
||||
Comparator.comparing(
|
||||
Folder::getLastModified, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
|
||||
));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return folderList;
|
||||
}
|
||||
|
||||
public static List<Folder> getFolderAll(String dirPath) {
|
||||
return getFolderAll(dirPath, "name", 1);
|
||||
}
|
||||
|
||||
public static List<Folder> getFolderAll(String dirPath, String sortType) {
|
||||
return getFolderAll(dirPath, sortType, 1);
|
||||
}
|
||||
|
||||
public static int getChildFolderCount(String dirPath) {
|
||||
File directory = new File(dirPath);
|
||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||
|
||||
int childCnt = 0;
|
||||
if (childFolders != null) {
|
||||
childCnt = childFolders.length;
|
||||
}
|
||||
|
||||
return childCnt;
|
||||
}
|
||||
|
||||
public static int getChildFolderCount(File directory) {
|
||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||
|
||||
int childCnt = 0;
|
||||
if (childFolders != null) {
|
||||
childCnt = childFolders.length;
|
||||
}
|
||||
|
||||
return childCnt;
|
||||
}
|
||||
|
||||
public static String getLastModified(String dirPath) {
|
||||
File file = new File(dirPath);
|
||||
return dttmFormat.format(new Date(file.lastModified()));
|
||||
}
|
||||
|
||||
public static String getLastModified(File file) {
|
||||
return dttmFormat.format(new Date(file.lastModified()));
|
||||
}
|
||||
|
||||
public static List<Basic> getFilesFromAllDepth(
|
||||
@@ -303,10 +402,7 @@ public class FIleChecker {
|
||||
List<Basic> fileList = new ArrayList<>();
|
||||
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// int fileTotCnt = 0;
|
||||
// long fileTotSize = 0;
|
||||
|
||||
Predicate<Path> isTarget =
|
||||
Predicate<Path> isTargetName =
|
||||
p -> {
|
||||
if (targetFileNm == null
|
||||
|| targetFileNm.trim().isEmpty()
|
||||
@@ -328,7 +424,7 @@ public class FIleChecker {
|
||||
|| extension.equals("*")
|
||||
|| targetExtensions.contains(extractExtension(p)))
|
||||
.sorted(getFileComparator(sortType))
|
||||
.filter(isTarget)
|
||||
.filter(isTargetName)
|
||||
.skip(startPos)
|
||||
.limit(limit)
|
||||
.map(
|
||||
@@ -357,6 +453,15 @@ public class FIleChecker {
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public static List<Basic> getFilesFromAllDepth(
|
||||
String dir,
|
||||
String targetFileNm,
|
||||
String extension) {
|
||||
|
||||
return FIleChecker.getFilesFromAllDepth(
|
||||
dir, targetFileNm, extension, 100, "name", 0, 100);
|
||||
}
|
||||
|
||||
public static Long getFileTotSize(List<FIleChecker.Basic> files) {
|
||||
|
||||
Long fileTotSize = 0L;
|
||||
@@ -367,6 +472,21 @@ public class FIleChecker {
|
||||
return fileTotSize;
|
||||
}
|
||||
|
||||
public static boolean checkExtensions(String fileName, String ext)
|
||||
{
|
||||
if( fileName == null )return false;
|
||||
|
||||
if (!fileName
|
||||
.substring(fileName.lastIndexOf('.') + 1)
|
||||
.toLowerCase()
|
||||
.equals(ext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> createExtensionSet(String extensionString) {
|
||||
if (extensionString == null || extensionString.isBlank()) {
|
||||
return Set.of();
|
||||
@@ -420,11 +540,6 @@ public class FIleChecker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdalinfo 실행 파일 경로를 찾습니다.
|
||||
*
|
||||
* @return gdalinfo 경로 (찾지 못하면 null)
|
||||
*/
|
||||
private static String findGdalinfoPath() {
|
||||
// 일반적인 설치 경로 확인
|
||||
String[] possiblePaths = {
|
||||
@@ -443,12 +558,6 @@ public class FIleChecker {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 명령어가 사용 가능한지 확인합니다.
|
||||
*
|
||||
* @param command 명령어 경로
|
||||
* @return 사용 가능 여부
|
||||
*/
|
||||
private static boolean isCommandAvailable(String command) {
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(command, "--version");
|
||||
@@ -469,4 +578,66 @@ public class FIleChecker {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "Folder", description = "폴더 정보")
|
||||
@Getter
|
||||
public static class Folder {
|
||||
private final String folderNm;
|
||||
private final String parentFolderNm;
|
||||
private final String parentPath;
|
||||
private final String fullPath;
|
||||
private final int depth;
|
||||
private final long childCnt;
|
||||
private final String lastModified;
|
||||
private final Boolean isValid;
|
||||
|
||||
public Folder(
|
||||
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;
|
||||
this.fullPath = fullPath;
|
||||
this.depth = depth;
|
||||
this.childCnt = childCnt;
|
||||
this.lastModified = lastModified;
|
||||
this.isValid = isValid;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
private final String fileNm;
|
||||
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 parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
String extension,
|
||||
long fileSize,
|
||||
String lastModified) {
|
||||
this.fileNm = fileNm;
|
||||
this.parentFolderNm = parentFolderNm;
|
||||
this.parentPath = parentPath;
|
||||
this.fullPath = fullPath;
|
||||
this.extension = extension;
|
||||
this.fileSize = fileSize;
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.springframework.stereotype.Component;
|
||||
@Setter
|
||||
public class FileConfig {
|
||||
|
||||
// private String rootSyncDir = "D:\\app\\original-images\\";
|
||||
// private String tmpSyncDir = rootSyncDir+"tmp\\";
|
||||
//private String rootSyncDir = "D:\\app\\original-images\\";
|
||||
//private String tmpSyncDir = rootSyncDir + "tmp\\";
|
||||
|
||||
private String rootSyncDir = "/app/original-images/";
|
||||
private String tmpSyncDir = rootSyncDir + "tmp/";
|
||||
|
||||
@@ -95,10 +95,10 @@ public class FileDto {
|
||||
private final String dirPath;
|
||||
private final int folderTotCnt;
|
||||
private final int folderErrTotCnt;
|
||||
private final List<FolderDto> folders;
|
||||
private final List<FIleChecker.Folder> folders;
|
||||
|
||||
public FoldersDto(
|
||||
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
|
||||
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FIleChecker.Folder> folders) {
|
||||
|
||||
this.dirPath = dirPath;
|
||||
this.folderTotCnt = folderTotCnt;
|
||||
|
||||
@@ -234,6 +234,17 @@ public class MapSheetMngDto {
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "SyncCheckStateReqUpdateDto", description = "영상관리 오류처리 상태변경요청")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SyncCheckStateReqUpdateDto {
|
||||
private Long hstUid;
|
||||
private String filePath;
|
||||
private String syncCheckTfwFileName;
|
||||
private String syncCheckTifFileName;
|
||||
private String syncCheckState;
|
||||
}
|
||||
|
||||
@Schema(name = "MngFIleDto", description = "관리파일정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -294,25 +305,5 @@ public class MapSheetMngDto {
|
||||
private Long fileSize;
|
||||
}
|
||||
|
||||
@Schema(name = "ReqUpdateErrorCheckStateDto", description = "영상관리 오류데이터 체크결과 수정요청")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ReqUpdateErrorCheckStateDto {
|
||||
|
||||
private Long hstUid;
|
||||
private String errorCheckState;
|
||||
private String errorCheckTfwFileName;
|
||||
private String errorCheckTifFileName;
|
||||
/*
|
||||
public reqErrorDataCheckStateDto(
|
||||
Long hstUid,
|
||||
String errorCheckState,
|
||||
String errorCheckTfwFileName,
|
||||
String errorCheckTifFileName) {
|
||||
this.hstUid = hstUid;
|
||||
this.errorCheckState = errorCheckState;
|
||||
this.errorCheckTfwFileName = errorCheckTfwFileName;
|
||||
this.errorCheckTifFileName = errorCheckTifFileName;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@ import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||
import com.kamco.cd.kamcoback.common.exception.DuplicateFileException;
|
||||
import com.kamco.cd.kamcoback.common.exception.ValidationException;
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.common.utils.NameValidator;
|
||||
import com.kamco.cd.kamcoback.config.FileConfig;
|
||||
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;
|
||||
@@ -17,21 +15,17 @@ import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileCheckerCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngFileRepository;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -56,85 +50,16 @@ public class MapSheetMngFileCheckerService {
|
||||
|
||||
Path startPath = Paths.get(fileConfig.getRootSyncDir() + srchDto.getDirPath());
|
||||
String dirPath = fileConfig.getRootSyncDir() + srchDto.getDirPath();
|
||||
String sortType = "name desc";
|
||||
|
||||
// Path startPath = Paths.get(fileConfig.getRootSyncDir()+srchDto.getDirPath());
|
||||
// String dirPath = fileConfig.getRootSyncDir()+srchDto.getDirPath();
|
||||
List<FIleChecker.Folder> folderList = FIleChecker.getFolderAll(dirPath);
|
||||
|
||||
int maxDepth = 1;
|
||||
int folderTotCnt = folderList.size();
|
||||
int folderErrTotCnt =
|
||||
(int)
|
||||
folderList.stream().filter(dto -> dto.getIsValid().toString().equals("false")).count();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderList);
|
||||
}
|
||||
|
||||
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||
|
||||
@@ -65,17 +65,6 @@ public class MapSheetMngService {
|
||||
return mapSheetMngCoreService.mngDataSave(AddReq);
|
||||
}
|
||||
|
||||
/*
|
||||
public MapSheetMngDto.DmlReturn uploadFile(MultipartFile file, Long hstUid) {
|
||||
return mapSheetMngCoreService.uploadFile(file, hstUid);
|
||||
}
|
||||
|
||||
public MapSheetMngDto.DmlReturn deleteFile(MapSheetMngDto.DeleteFileReq req) {
|
||||
return mapSheetMngCoreService.deleteFile(req);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
||||
return mapSheetMngCoreService.uploadProcess(hstUidList);
|
||||
}
|
||||
@@ -88,12 +77,22 @@ public class MapSheetMngService {
|
||||
public DmlReturn uploadPair(
|
||||
MultipartFile tfwFile,
|
||||
MultipartFile tifFile,
|
||||
// String targetPath,
|
||||
Long hstUid) {
|
||||
|
||||
String rootPath = fileConfig.getRootSyncDir();
|
||||
String tmpPath = fileConfig.getTmpSyncDir();
|
||||
|
||||
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||
if (errDto == null) {
|
||||
return new DmlReturn("fail", "NO hstUid Data");
|
||||
}
|
||||
|
||||
//파일검증용 임시저장 폴더 확인
|
||||
if( ! FIleChecker.mkDir(tmpPath) )
|
||||
{
|
||||
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
||||
}
|
||||
|
||||
// 파일 유효성 검증
|
||||
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
||||
return new DmlReturn("fail", "TFW SIZE 오류");
|
||||
@@ -101,35 +100,27 @@ public class MapSheetMngService {
|
||||
return new DmlReturn("fail", "TIF SIZE 오류");
|
||||
}
|
||||
|
||||
if (!tfwFile
|
||||
.getOriginalFilename()
|
||||
.substring(tfwFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||
.toLowerCase()
|
||||
.equals("tfw")) {
|
||||
//확장자명 체크
|
||||
if( ! FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw") )
|
||||
{
|
||||
return new DmlReturn("fail", "TFW FILENAME ERROR");
|
||||
} else if (!tifFile
|
||||
.getOriginalFilename()
|
||||
.substring(tifFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||
.toLowerCase()
|
||||
.equals("tif")) {
|
||||
}
|
||||
else if( ! FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif") )
|
||||
{
|
||||
return new DmlReturn("fail", "TIF FILENAME ERROR");
|
||||
}
|
||||
|
||||
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||
if (errDto == null) {
|
||||
return new DmlReturn("fail", "NO hstUid Data");
|
||||
}
|
||||
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
|
||||
|
||||
String targetYearDir = mngDto.getMngPath();
|
||||
|
||||
//중복체크
|
||||
List<FIleChecker.Basic> basicTfwList =
|
||||
FIleChecker.getFilesFromAllDepth(
|
||||
targetYearDir, tfwFile.getOriginalFilename(), "tfw", 100, "name", 0, 100);
|
||||
targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||
|
||||
List<FIleChecker.Basic> basicTifList =
|
||||
FIleChecker.getFilesFromAllDepth(
|
||||
targetYearDir, tifFile.getOriginalFilename(), "tif", 100, "name", 0, 100);
|
||||
targetYearDir, tifFile.getOriginalFilename(), "tif");
|
||||
|
||||
int tfwCnt =
|
||||
(int)
|
||||
@@ -148,7 +139,7 @@ public class MapSheetMngService {
|
||||
String tifMsg = "";
|
||||
if (tfwCnt > 0) tfwMsg = tfwFile.getOriginalFilename();
|
||||
if (tifCnt > 0) tifMsg = tifFile.getOriginalFilename();
|
||||
return new DmlReturn("fail", tfwMsg + "," + tifMsg + " DUPLICATE ERROR");
|
||||
return new DmlReturn("duplicate", tfwMsg + "," + tifMsg);
|
||||
}
|
||||
|
||||
File directory = new File(tmpPath);
|
||||
@@ -168,7 +159,7 @@ public class MapSheetMngService {
|
||||
if (!FIleChecker.cmmndGdalInfo(tifTmpPath)) return new DmlReturn("fail", "TIF TYPE ERROR");
|
||||
if (!FIleChecker.checkTfw(tfwTmpPath)) return new DmlReturn("fail", "TFW TYPE ERROR");
|
||||
|
||||
// 싱크파일목록 가저오기
|
||||
// 싱크파일목록으로 업로드 경로 확인
|
||||
List<MngFilesDto> mngFiles = mapSheetMngCoreService.findIdToMapSheetFileList(hstUid);
|
||||
String uploadPath = "";
|
||||
for (MngFilesDto dto : mngFiles) {
|
||||
@@ -178,8 +169,8 @@ public class MapSheetMngService {
|
||||
|
||||
Path tfwTargetPath = null;
|
||||
Path tifTargetPath = null;
|
||||
Path uploadTargetPath = null;
|
||||
|
||||
//파일이 존재하지 않을 경우(0개) 해당년도 다른 파일경로로 참조
|
||||
if (uploadPath.isEmpty()) {
|
||||
MngFilesDto filesDto =
|
||||
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
|
||||
@@ -189,11 +180,13 @@ public class MapSheetMngService {
|
||||
tifTargetPath = Paths.get(uploadPath).resolve(tifFile.getOriginalFilename());
|
||||
}
|
||||
|
||||
// String searchDir =
|
||||
//업로드 경로 확인(없으면 생성)
|
||||
if( ! FIleChecker.mkDir(uploadPath) )
|
||||
{
|
||||
return new DmlReturn("fail", "CREATE FOLDER ERROR");
|
||||
}
|
||||
|
||||
try {
|
||||
uploadTargetPath = Paths.get(uploadPath);
|
||||
Files.createDirectories(uploadTargetPath);
|
||||
Files.move(tfwTmpSavePath, tfwTargetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(tifTmpSavePath, tifTargetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
@@ -201,8 +194,13 @@ public class MapSheetMngService {
|
||||
}
|
||||
|
||||
// hst업데이트
|
||||
mapSheetMngCoreService.updateMapSheetMngHstSyncCheckState(
|
||||
hstUid, uploadPath, tfwFile.getOriginalFilename(), tifFile.getOriginalFilename());
|
||||
MapSheetMngDto.SyncCheckStateReqUpdateDto updReqSyncCheckState = new MapSheetMngDto.SyncCheckStateReqUpdateDto();
|
||||
updReqSyncCheckState.setHstUid(hstUid);
|
||||
updReqSyncCheckState.setFilePath(uploadPath);
|
||||
updReqSyncCheckState.setSyncCheckTfwFileName(tfwFile.getOriginalFilename());
|
||||
updReqSyncCheckState.setSyncCheckTifFileName(tifFile.getOriginalFilename());
|
||||
updReqSyncCheckState.setSyncCheckState("DONE");
|
||||
mapSheetMngCoreService.updateMapSheetMngHstSyncCheckState(updReqSyncCheckState);
|
||||
// 파일정보 업데이트
|
||||
mapSheetMngCoreService.deleteByHstUidMngFile(hstUid);
|
||||
|
||||
@@ -233,8 +231,13 @@ public class MapSheetMngService {
|
||||
@Transactional
|
||||
public DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
|
||||
|
||||
long hstUid = 0;
|
||||
//hstUid = 149049;
|
||||
|
||||
for (Long uid : fileUids) {
|
||||
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findIdToMapSheetFile(uid);
|
||||
hstUid = dto.getHstUid();
|
||||
|
||||
String filePath = dto.getFilePath() + "/" + dto.getFileName();
|
||||
Path path = Paths.get(filePath);
|
||||
try {
|
||||
@@ -250,6 +253,9 @@ public class MapSheetMngService {
|
||||
DmlReturn dmlReturn = mapSheetMngCoreService.deleteByFileUidMngFile(uid);
|
||||
}
|
||||
|
||||
//중복제거 확인후 처리상태(DONE)변경
|
||||
if( hstUid > 0 )mapSheetMngCoreService.updateByHstUidSyncCheckState(hstUid);
|
||||
|
||||
return new DmlReturn("success", fileUids.size() + "개 파일이 삭제되었습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,8 @@ public class MapSheetMngCoreService {
|
||||
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
|
||||
}
|
||||
|
||||
public void updateMapSheetMngHstSyncCheckState(
|
||||
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
|
||||
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(
|
||||
hstUid, uploadPath, syncCheckTfwFileName, syncCheckTifFileName);
|
||||
public void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto) {
|
||||
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(reqDto);
|
||||
}
|
||||
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
@@ -245,4 +243,28 @@ public class MapSheetMngCoreService {
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");
|
||||
}
|
||||
|
||||
public MapSheetMngDto.DmlReturn updateByHstUidSyncCheckState(Long hstUid) {
|
||||
|
||||
MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto = new MapSheetMngDto.SyncCheckStateReqUpdateDto();
|
||||
reqDto.setHstUid(hstUid);
|
||||
|
||||
List<MapSheetMngDto.MngFilesDto> filesDto = mapSheetMngRepository.findHstUidToMapSheetFileList(hstUid);
|
||||
for (MapSheetMngDto.MngFilesDto dto : filesDto) {
|
||||
if( dto.getFileExt().equals("tif"))reqDto.setSyncCheckTifFileName(dto.getFileName());
|
||||
else if( dto.getFileExt().equals("tfw"))reqDto.setSyncCheckTfwFileName(dto.getFileName());
|
||||
reqDto.setFilePath(dto.getFilePath());
|
||||
}
|
||||
|
||||
String fileState = "DONE";
|
||||
if( filesDto.size() > 2 )fileState = "DONE";
|
||||
|
||||
reqDto.setSyncCheckState(fileState);
|
||||
|
||||
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(reqDto);
|
||||
mapSheetMngRepository.updateByHstUidMngFileState(hstUid, fileState);
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", hstUid + " : 상태변경되었습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,9 @@ public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq);
|
||||
|
||||
void updateMapSheetMngHstSyncCheckState(
|
||||
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName);
|
||||
void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto updReq);
|
||||
|
||||
void updateByHstUidMngFileState(Long hstUid, String fileState);
|
||||
|
||||
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
||||
|
||||
@@ -547,19 +547,18 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapSheetMngHstSyncCheckState(
|
||||
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
|
||||
public void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto updReq) {
|
||||
|
||||
long execCount =
|
||||
queryFactory
|
||||
.update(mapSheetMngHstEntity)
|
||||
.set(mapSheetMngHstEntity.syncCheckState, "DONE")
|
||||
.set(mapSheetMngHstEntity.mapSheetPath, uploadPath)
|
||||
.set(mapSheetMngHstEntity.syncCheckTfwFileName, syncCheckTfwFileName)
|
||||
.set(mapSheetMngHstEntity.syncCheckTifFileName, syncCheckTifFileName)
|
||||
.set(mapSheetMngHstEntity.syncCheckState, updReq.getSyncCheckState())
|
||||
.set(mapSheetMngHstEntity.mapSheetPath, updReq.getFilePath())
|
||||
.set(mapSheetMngHstEntity.syncCheckTfwFileName, updReq.getSyncCheckTfwFileName())
|
||||
.set(mapSheetMngHstEntity.syncCheckTifFileName, updReq.getSyncCheckTifFileName())
|
||||
.set(mapSheetMngHstEntity.syncCheckStrtDttm, ZonedDateTime.now())
|
||||
.set(mapSheetMngHstEntity.syncCheckEndDttm, ZonedDateTime.now())
|
||||
.where(mapSheetMngHstEntity.hstUid.eq(hstUid))
|
||||
.where(mapSheetMngHstEntity.hstUid.eq(updReq.getHstUid()))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@@ -633,6 +632,17 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByHstUidMngFileState(Long hstUid, String fileState) {
|
||||
long execCount =
|
||||
queryFactory
|
||||
.update(mapSheetMngFileEntity)
|
||||
.set(mapSheetMngFileEntity.fileState, fileState)
|
||||
.where(mapSheetMngFileEntity.hstUid.eq(hstUid))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
||||
long fileCount =
|
||||
|
||||
Reference in New Issue
Block a user