Merge pull request '영상관리 파일 업로드 추가' (#76) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/76
This commit is contained in:
@@ -12,6 +12,9 @@ import org.springframework.stereotype.Component;
|
|||||||
@Setter
|
@Setter
|
||||||
public class FileConfig {
|
public class FileConfig {
|
||||||
|
|
||||||
// private String rootSyncDir = "D:\\app\\original-images";
|
// private String rootSyncDir = "D:\\app\\original-images\\";
|
||||||
private String rootSyncDir = "/app/original-images";
|
// private String tmpSyncDir = rootSyncDir+"tmp\\";
|
||||||
|
|
||||||
|
private String rootSyncDir = "/app/original-images/";
|
||||||
|
private String tmpSyncDir = rootSyncDir + "tmp/";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class MapSheetMngDto {
|
|||||||
|
|
||||||
private int rowNum;
|
private int rowNum;
|
||||||
private int mngYyyy;
|
private int mngYyyy;
|
||||||
|
private String mngPath;
|
||||||
private String mngState;
|
private String mngState;
|
||||||
private String syncState;
|
private String syncState;
|
||||||
private String syncDataCheckState;
|
private String syncDataCheckState;
|
||||||
@@ -166,9 +167,10 @@ public class MapSheetMngDto {
|
|||||||
@Setter
|
@Setter
|
||||||
public static class ErrorDataDto {
|
public static class ErrorDataDto {
|
||||||
|
|
||||||
// private Integer rowNum;
|
|
||||||
private Long hstUid;
|
private Long hstUid;
|
||||||
|
private Integer mngYyyy;
|
||||||
private String mapSheetNum;
|
private String mapSheetNum;
|
||||||
|
private String refMapSheetNum;
|
||||||
private String map50kName;
|
private String map50kName;
|
||||||
private String map5kName;
|
private String map5kName;
|
||||||
private String mapSrcName;
|
private String mapSrcName;
|
||||||
@@ -189,6 +191,9 @@ public class MapSheetMngDto {
|
|||||||
|
|
||||||
public ErrorDataDto(
|
public ErrorDataDto(
|
||||||
Long hstUid,
|
Long hstUid,
|
||||||
|
Integer mngYyyy,
|
||||||
|
String mapSheetNum,
|
||||||
|
String refMapSheetNum,
|
||||||
String map50kName,
|
String map50kName,
|
||||||
String map5kName,
|
String map5kName,
|
||||||
String mapSrcName,
|
String mapSrcName,
|
||||||
@@ -201,6 +206,9 @@ public class MapSheetMngDto {
|
|||||||
String errorCheckTfwFileName,
|
String errorCheckTfwFileName,
|
||||||
String errorCheckTifFileName) {
|
String errorCheckTifFileName) {
|
||||||
this.hstUid = hstUid;
|
this.hstUid = hstUid;
|
||||||
|
this.mngYyyy = mngYyyy;
|
||||||
|
this.mapSheetNum = mapSheetNum;
|
||||||
|
this.refMapSheetNum = refMapSheetNum;
|
||||||
this.map50kName = map50kName;
|
this.map50kName = map50kName;
|
||||||
this.map5kName = map5kName;
|
this.map5kName = map5kName;
|
||||||
this.mapSrcName = mapSrcName;
|
this.mapSrcName = mapSrcName;
|
||||||
@@ -250,6 +258,24 @@ public class MapSheetMngDto {
|
|||||||
private String message;
|
private String message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Schema(name = "MngFileAddReq", description = "영상관리파일 등록 요청")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class MngFileAddReq {
|
||||||
|
|
||||||
|
private int mngYyyy;
|
||||||
|
private String mapSheetNum;
|
||||||
|
private String refMapSheetNum;
|
||||||
|
private String filePath;
|
||||||
|
private String fileName;
|
||||||
|
private String fileExt;
|
||||||
|
private Long hstUid;
|
||||||
|
private Long fileSize;
|
||||||
|
private String fileState;
|
||||||
|
}
|
||||||
|
|
||||||
@Schema(name = "MngFilesDto", description = "영상파일내역 검색 리턴")
|
@Schema(name = "MngFilesDto", description = "영상파일내역 검색 리턴")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -267,4 +293,26 @@ public class MapSheetMngDto {
|
|||||||
private Long hstUid;
|
private Long hstUid;
|
||||||
private Long fileSize;
|
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;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,18 @@ package com.kamco.cd.kamcoback.mapsheet.service;
|
|||||||
|
|
||||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto;
|
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||||
|
import com.kamco.cd.kamcoback.config.FileConfig;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.Basic;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
|
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.SrchFilesDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.ErrorDataDto;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.ErrorSearchReq;
|
||||||
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngFilesDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngFilesDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -16,6 +22,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.attribute.FileTime;
|
import java.nio.file.attribute.FileTime;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -39,6 +46,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
public class MapSheetMngService {
|
public class MapSheetMngService {
|
||||||
|
|
||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
|
private final FileConfig fileConfig;
|
||||||
|
|
||||||
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||||
|
|
||||||
@@ -50,7 +58,7 @@ public class MapSheetMngService {
|
|||||||
File dir = new File(dirPath);
|
File dir = new File(dirPath);
|
||||||
File[] fileList = dir.listFiles();
|
File[] fileList = dir.listFiles();
|
||||||
|
|
||||||
List<FileDto.Basic> files = new ArrayList<>();
|
List<Basic> files = new ArrayList<>();
|
||||||
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
int fileListPos = 0;
|
int fileListPos = 0;
|
||||||
@@ -85,7 +93,7 @@ public class MapSheetMngService {
|
|||||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||||
|
|
||||||
files.add(
|
files.add(
|
||||||
new FileDto.Basic(
|
new Basic(
|
||||||
fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
||||||
|
|
||||||
fileTotCnt = fileTotCnt + 1;
|
fileTotCnt = fileTotCnt + 1;
|
||||||
@@ -113,7 +121,7 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
Set<String> targetExtensions = createExtensionSet(extension);
|
Set<String> targetExtensions = createExtensionSet(extension);
|
||||||
|
|
||||||
List<FileDto.Basic> fileDtoList = new ArrayList<>();
|
List<Basic> fileDtoList = new ArrayList<>();
|
||||||
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
int fileTotCnt = 0;
|
int fileTotCnt = 0;
|
||||||
@@ -147,13 +155,13 @@ public class MapSheetMngService {
|
|||||||
long fileSize = file.length();
|
long fileSize = file.length();
|
||||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||||
|
|
||||||
return new FileDto.Basic(
|
return new Basic(
|
||||||
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
fileTotCnt = fileDtoList.size();
|
fileTotCnt = fileDtoList.size();
|
||||||
fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
|
fileTotSize = fileDtoList.stream().mapToLong(Basic::getFileSize).sum();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
|
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
|
||||||
@@ -215,7 +223,7 @@ public class MapSheetMngService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapSheetMngDto.MngDto> findMapSheetMngList() {
|
public List<MngDto> findMapSheetMngList() {
|
||||||
return mapSheetMngCoreService.findMapSheetMngList();
|
return mapSheetMngCoreService.findMapSheetMngList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,29 +231,28 @@ public class MapSheetMngService {
|
|||||||
return mapSheetMngCoreService.findMapSheetMngYyyyList();
|
return mapSheetMngCoreService.findMapSheetMngYyyyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy) {
|
public MngDto findMapSheetMng(int mngYyyy) {
|
||||||
return mapSheetMngCoreService.findMapSheetMng(mngYyyy);
|
return mapSheetMngCoreService.findMapSheetMng(mngYyyy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public MapSheetMngDto.DmlReturn mngComplete(int mngYyyy) {
|
public DmlReturn mngComplete(int mngYyyy) {
|
||||||
|
|
||||||
mapSheetMngCoreService.MapSheetMngComplete(mngYyyy);
|
mapSheetMngCoreService.MapSheetMngComplete(mngYyyy);
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", "작업완료 처리되었습니다.");
|
return new DmlReturn("success", "작업완료 처리되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
public Page<ErrorDataDto> findMapSheetErrorList(@Valid ErrorSearchReq searchReq) {
|
||||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
|
||||||
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid) {
|
public ErrorDataDto findMapSheetError(Long hstUid) {
|
||||||
return mapSheetMngCoreService.findMapSheetError(hstUid);
|
return mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public MapSheetMngDto.DmlReturn mngDataSave(MapSheetMngDto.AddReq AddReq) {
|
public DmlReturn mngDataSave(AddReq AddReq) {
|
||||||
return mapSheetMngCoreService.mngDataSave(AddReq);
|
return mapSheetMngCoreService.mngDataSave(AddReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,11 +267,11 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
public DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
||||||
return mapSheetMngCoreService.uploadProcess(hstUidList);
|
return mapSheetMngCoreService.uploadProcess(hstUidList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
public DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
||||||
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +282,9 @@ public class MapSheetMngService {
|
|||||||
// String targetPath,
|
// String targetPath,
|
||||||
Long hstUid) {
|
Long hstUid) {
|
||||||
|
|
||||||
|
String rootPath = fileConfig.getRootSyncDir();
|
||||||
|
String tmpPath = fileConfig.getTmpSyncDir();
|
||||||
|
|
||||||
// 파일 유효성 검증
|
// 파일 유효성 검증
|
||||||
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
||||||
return new DmlReturn("fail", "TFW SIZE 오류");
|
return new DmlReturn("fail", "TFW SIZE 오류");
|
||||||
@@ -287,15 +297,68 @@ public class MapSheetMngService {
|
|||||||
.substring(tfwFile.getOriginalFilename().lastIndexOf('.') + 1)
|
.substring(tfwFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.equals("tfw")) {
|
.equals("tfw")) {
|
||||||
return new DmlReturn("fail", "TFW TYPE ERROR");
|
return new DmlReturn("fail", "TFW FILENAME ERROR");
|
||||||
} else if (!tifFile
|
} else if (!tifFile
|
||||||
.getOriginalFilename()
|
.getOriginalFilename()
|
||||||
.substring(tifFile.getOriginalFilename().lastIndexOf('.') + 1)
|
.substring(tifFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.equals("tif")) {
|
.equals("tif")) {
|
||||||
return new DmlReturn("fail", "TIF TYPE ERROR");
|
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);
|
||||||
|
|
||||||
|
List<FIleChecker.Basic> basicTifList =
|
||||||
|
FIleChecker.getFilesFromAllDepth(
|
||||||
|
targetYearDir, tifFile.getOriginalFilename(), "tif", 100, "name", 0, 100);
|
||||||
|
|
||||||
|
int tfwCnt =
|
||||||
|
(int)
|
||||||
|
basicTfwList.stream()
|
||||||
|
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
||||||
|
.count();
|
||||||
|
|
||||||
|
int tifCnt =
|
||||||
|
(int)
|
||||||
|
basicTifList.stream()
|
||||||
|
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
||||||
|
.count();
|
||||||
|
|
||||||
|
if (tfwCnt > 0 || tifCnt > 0) {
|
||||||
|
String tfwMsg = "";
|
||||||
|
String tifMsg = "";
|
||||||
|
if (tfwCnt > 0) tfwMsg = tfwFile.getOriginalFilename();
|
||||||
|
if (tifCnt > 0) tifMsg = tifFile.getOriginalFilename();
|
||||||
|
return new DmlReturn("fail", tfwMsg + "," + tifMsg + " DUPLICATE ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
|
File directory = new File(tmpPath);
|
||||||
|
String tfwTmpPath = tmpPath + tfwFile.getOriginalFilename();
|
||||||
|
Path tfwTmpSavePath = Paths.get(tfwTmpPath);
|
||||||
|
String tifTmpPath = tmpPath + tifFile.getOriginalFilename();
|
||||||
|
Path tifTmpSavePath = Paths.get(tifTmpPath);
|
||||||
|
boolean fileUpload = true;
|
||||||
|
try {
|
||||||
|
tfwFile.transferTo(tfwTmpSavePath);
|
||||||
|
tifFile.transferTo(tifTmpSavePath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
return new DmlReturn("fail", "UPLOAD ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
List<MngFilesDto> mngFiles = mapSheetMngCoreService.findIdToMapSheetFileList(hstUid);
|
||||||
String uploadPath = "";
|
String uploadPath = "";
|
||||||
@@ -304,28 +367,80 @@ public class MapSheetMngService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path tfwTargetPath = null;
|
||||||
|
Path tifTargetPath = null;
|
||||||
|
Path uploadTargetPath = null;
|
||||||
|
|
||||||
if (uploadPath.isEmpty()) {
|
if (uploadPath.isEmpty()) {
|
||||||
// ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
MngFilesDto filesDto =
|
||||||
// uploadPath = FileConfig.rootSyncDir+"\\"+errDto.getMapSheetNum();
|
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
|
||||||
|
String referPath = filesDto.getFilePath();
|
||||||
|
uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum();
|
||||||
|
tfwTargetPath = Paths.get(uploadPath).resolve(tfwFile.getOriginalFilename());
|
||||||
|
tifTargetPath = Paths.get(uploadPath).resolve(tifFile.getOriginalFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
// tfw가 있는 경우
|
// String searchDir =
|
||||||
// tif가 있는 경우
|
|
||||||
|
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) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// hst업데이트
|
||||||
|
mapSheetMngCoreService.updateMapSheetMngHstSyncCheckState(
|
||||||
|
hstUid, uploadPath, tfwFile.getOriginalFilename(), tifFile.getOriginalFilename());
|
||||||
|
// 파일정보 업데이트
|
||||||
|
mapSheetMngCoreService.deleteByHstUidMngFile(hstUid);
|
||||||
|
|
||||||
|
MapSheetMngDto.MngFileAddReq addReq = new MapSheetMngDto.MngFileAddReq();
|
||||||
|
addReq.setMngYyyy(errDto.getMngYyyy());
|
||||||
|
addReq.setMapSheetNum(errDto.getMapSheetNum());
|
||||||
|
addReq.setRefMapSheetNum(errDto.getRefMapSheetNum());
|
||||||
|
addReq.setFilePath(uploadPath);
|
||||||
|
addReq.setFileName(tfwFile.getOriginalFilename());
|
||||||
|
addReq.setFileExt("tfw");
|
||||||
|
addReq.setFileSize(tfwFile.getSize());
|
||||||
|
addReq.setHstUid(errDto.getHstUid());
|
||||||
|
addReq.setFileState("DONE");
|
||||||
|
|
||||||
|
mapSheetMngCoreService.mngFileSave(addReq);
|
||||||
|
|
||||||
|
addReq.setFileExt("tif");
|
||||||
|
addReq.setFileSize(tifFile.getSize());
|
||||||
|
mapSheetMngCoreService.mngFileSave(addReq);
|
||||||
|
|
||||||
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
public List<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||||
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
|
public DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
|
||||||
|
|
||||||
for (Long uid : fileUids) {
|
for (Long uid : fileUids) {
|
||||||
MapSheetMngDto.DmlReturn dmlReturn = mapSheetMngCoreService.deleteByFileUidMngFile(uid);
|
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findIdToMapSheetFile(uid);
|
||||||
|
String filePath = dto.getFilePath() + "/" + dto.getFileName();
|
||||||
|
Path path = Paths.get(filePath);
|
||||||
|
try {
|
||||||
|
boolean isDeleted = Files.deleteIfExists(path);
|
||||||
|
if (isDeleted) {
|
||||||
|
System.out.println("파일 삭제 성공: " + filePath);
|
||||||
|
} else {
|
||||||
|
System.out.println("삭제 실패: 파일이 존재하지 않습니다.");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("파일 삭제 중 오류 발생: " + e.getMessage());
|
||||||
|
}
|
||||||
|
DmlReturn dmlReturn = mapSheetMngCoreService.deleteByFileUidMngFile(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", fileUids.size() + "개 파일이 삭제되었습니다.");
|
return new DmlReturn("success", fileUids.size() + "개 파일이 삭제되었습니다.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,24 @@ public class MapSheetMngCoreService {
|
|||||||
mapSheetMngRepository.MapSheetMngComplete(mngYyyy);
|
mapSheetMngRepository.MapSheetMngComplete(mngYyyy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByHstUidMngFile(@Valid Long hstUid) {
|
||||||
|
mapSheetMngRepository.deleteByHstUidMngFile(hstUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
||||||
|
|
||||||
|
mapSheetMngRepository.mngFileSave(addReq);
|
||||||
|
// int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
|
||||||
|
|
||||||
|
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMapSheetMngHstSyncCheckState(
|
||||||
|
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
|
||||||
|
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(
|
||||||
|
hstUid, uploadPath, syncCheckTfwFileName, syncCheckTifFileName);
|
||||||
|
}
|
||||||
|
|
||||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||||
return mapSheetMngRepository.findMapSheetErrorList(searchReq);
|
return mapSheetMngRepository.findMapSheetErrorList(searchReq);
|
||||||
@@ -61,6 +79,14 @@ public class MapSheetMngCoreService {
|
|||||||
return mapSheetMngRepository.findIdToMapSheetFileList(hstUid);
|
return mapSheetMngRepository.findIdToMapSheetFileList(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
|
||||||
|
return mapSheetMngRepository.findYyyyToMapSheetFilePathRefer(mngYyyy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid) {
|
||||||
|
return mapSheetMngRepository.findIdToMapSheetFile(fileUid);
|
||||||
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
||||||
@@ -214,6 +240,7 @@ public class MapSheetMngCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(Long fileUid) {
|
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(Long fileUid) {
|
||||||
|
|
||||||
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
|
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");
|
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
void deleteByFileUidMngFile(Long fileUid);
|
void deleteByFileUidMngFile(Long fileUid);
|
||||||
|
|
||||||
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy);
|
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy);
|
||||||
|
|
||||||
void deleteByMngYyyyMngAll(int mngYyyy);
|
void deleteByMngYyyyMngAll(int mngYyyy);
|
||||||
|
|
||||||
@@ -35,6 +35,13 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
void deleteByMngYyyyMngFile(int mngYyyy);
|
void deleteByMngYyyyMngFile(int mngYyyy);
|
||||||
|
|
||||||
|
void deleteByHstUidMngFile(Long hstUid);
|
||||||
|
|
||||||
|
void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq);
|
||||||
|
|
||||||
|
void updateMapSheetMngHstSyncCheckState(
|
||||||
|
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName);
|
||||||
|
|
||||||
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
||||||
|
|
||||||
@@ -42,5 +49,7 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid);
|
List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid);
|
||||||
|
|
||||||
|
MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid);
|
||||||
|
|
||||||
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
|
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
|
|||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -72,6 +73,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
"row_number() over(order by {0} desc)",
|
"row_number() over(order by {0} desc)",
|
||||||
mapSheetMngEntity.createdDttm),
|
mapSheetMngEntity.createdDttm),
|
||||||
mapSheetMngEntity.mngYyyy,
|
mapSheetMngEntity.mngYyyy,
|
||||||
|
mapSheetMngEntity.mngPath,
|
||||||
mapSheetMngEntity.mngState,
|
mapSheetMngEntity.mngState,
|
||||||
mapSheetMngEntity.syncState,
|
mapSheetMngEntity.syncState,
|
||||||
mapSheetMngEntity.syncCheckState,
|
mapSheetMngEntity.syncCheckState,
|
||||||
@@ -194,6 +196,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
"row_number() over(order by {0} desc)",
|
"row_number() over(order by {0} desc)",
|
||||||
mapSheetMngEntity.createdDttm),
|
mapSheetMngEntity.createdDttm),
|
||||||
mapSheetMngEntity.mngYyyy,
|
mapSheetMngEntity.mngYyyy,
|
||||||
|
mapSheetMngEntity.mngPath,
|
||||||
mapSheetMngEntity.mngState,
|
mapSheetMngEntity.mngState,
|
||||||
mapSheetMngEntity.syncState,
|
mapSheetMngEntity.syncState,
|
||||||
mapSheetMngEntity.syncCheckState,
|
mapSheetMngEntity.syncCheckState,
|
||||||
@@ -336,6 +339,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
MapSheetMngDto.ErrorDataDto.class,
|
MapSheetMngDto.ErrorDataDto.class,
|
||||||
mapSheetMngHstEntity.hstUid,
|
mapSheetMngHstEntity.hstUid,
|
||||||
|
mapSheetMngHstEntity.mngYyyy,
|
||||||
|
mapSheetMngHstEntity.mapSheetNum,
|
||||||
|
mapSheetMngHstEntity.refMapSheetNum,
|
||||||
Expressions.stringTemplate(
|
Expressions.stringTemplate(
|
||||||
"concat({0},substring({1}, 0, 6))",
|
"concat({0},substring({1}, 0, 6))",
|
||||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||||
@@ -391,7 +397,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
MapSheetMngDto.ErrorDataDto.class,
|
MapSheetMngDto.ErrorDataDto.class,
|
||||||
mapSheetMngHstEntity.hstUid,
|
mapSheetMngHstEntity.hstUid,
|
||||||
|
mapSheetMngHstEntity.mngYyyy,
|
||||||
mapSheetMngHstEntity.mapSheetNum,
|
mapSheetMngHstEntity.mapSheetNum,
|
||||||
|
mapSheetMngHstEntity.refMapSheetNum,
|
||||||
Expressions.stringTemplate(
|
Expressions.stringTemplate(
|
||||||
"concat({0},substring({1}, 0, 6))",
|
"concat({0},substring({1}, 0, 6))",
|
||||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||||
@@ -476,7 +484,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy) {
|
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
|
||||||
|
|
||||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||||
whereBuilder.and(mapSheetMngFileEntity.mngYyyy.eq(mngYyyy));
|
whereBuilder.and(mapSheetMngFileEntity.mngYyyy.eq(mngYyyy));
|
||||||
@@ -497,11 +505,38 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
mapSheetMngFileEntity.fileSize))
|
mapSheetMngFileEntity.fileSize))
|
||||||
.from(mapSheetMngFileEntity)
|
.from(mapSheetMngFileEntity)
|
||||||
.where(whereBuilder)
|
.where(whereBuilder)
|
||||||
|
.orderBy(mapSheetMngFileEntity.fileUid.desc())
|
||||||
|
.limit(1)
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
|
|
||||||
return foundContent;
|
return foundContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid) {
|
||||||
|
|
||||||
|
MapSheetMngDto.MngFilesDto foundContent =
|
||||||
|
queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
MapSheetMngDto.MngFilesDto.class,
|
||||||
|
mapSheetMngFileEntity.fileUid,
|
||||||
|
mapSheetMngFileEntity.mngYyyy,
|
||||||
|
mapSheetMngFileEntity.mapSheetNum,
|
||||||
|
mapSheetMngFileEntity.refMapSheetNum,
|
||||||
|
mapSheetMngFileEntity.filePath,
|
||||||
|
mapSheetMngFileEntity.fileName,
|
||||||
|
mapSheetMngFileEntity.fileExt,
|
||||||
|
mapSheetMngFileEntity.hstUid,
|
||||||
|
mapSheetMngFileEntity.fileSize))
|
||||||
|
.from(mapSheetMngFileEntity)
|
||||||
|
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
return foundContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void MapSheetMngComplete(int mngYyyy) {
|
public void MapSheetMngComplete(int mngYyyy) {
|
||||||
long execCount =
|
long execCount =
|
||||||
queryFactory
|
queryFactory
|
||||||
@@ -511,6 +546,23 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMapSheetMngHstSyncCheckState(
|
||||||
|
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
|
||||||
|
|
||||||
|
long execCount =
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetMngHstEntity)
|
||||||
|
.set(mapSheetMngHstEntity.syncCheckState, "DONE")
|
||||||
|
.set(mapSheetMngHstEntity.mapSheetPath, uploadPath)
|
||||||
|
.set(mapSheetMngHstEntity.syncCheckTfwFileName, syncCheckTfwFileName)
|
||||||
|
.set(mapSheetMngHstEntity.syncCheckTifFileName, syncCheckTifFileName)
|
||||||
|
.set(mapSheetMngHstEntity.syncCheckStrtDttm, ZonedDateTime.now())
|
||||||
|
.set(mapSheetMngHstEntity.syncCheckEndDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetMngHstEntity.hstUid.eq(hstUid))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByMngYyyyMngAll(int mngYyyy) {
|
public void deleteByMngYyyyMngAll(int mngYyyy) {
|
||||||
|
|
||||||
@@ -564,14 +616,51 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByFileUidMngFile(Long fileUid) {
|
public void deleteByHstUidMngFile(Long hstUid) {
|
||||||
long deletedFileCount =
|
long deletedFileCount =
|
||||||
|
queryFactory
|
||||||
|
.delete(mapSheetMngFileEntity)
|
||||||
|
.where(mapSheetMngFileEntity.fileUid.eq(hstUid))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByFileUidMngFile(Long fileUid) {
|
||||||
|
long fileCount =
|
||||||
queryFactory
|
queryFactory
|
||||||
.delete(mapSheetMngFileEntity)
|
.delete(mapSheetMngFileEntity)
|
||||||
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
|
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
||||||
|
long fileCount =
|
||||||
|
queryFactory
|
||||||
|
.insert(mapSheetMngFileEntity)
|
||||||
|
.columns(
|
||||||
|
mapSheetMngFileEntity.mngYyyy,
|
||||||
|
mapSheetMngFileEntity.mapSheetNum,
|
||||||
|
mapSheetMngFileEntity.refMapSheetNum,
|
||||||
|
mapSheetMngFileEntity.filePath,
|
||||||
|
mapSheetMngFileEntity.fileName,
|
||||||
|
mapSheetMngFileEntity.fileExt,
|
||||||
|
mapSheetMngFileEntity.hstUid,
|
||||||
|
mapSheetMngFileEntity.fileSize,
|
||||||
|
mapSheetMngFileEntity.fileState)
|
||||||
|
.values(
|
||||||
|
addReq.getMngYyyy(),
|
||||||
|
addReq.getMapSheetNum(),
|
||||||
|
addReq.getRefMapSheetNum(),
|
||||||
|
addReq.getFilePath(),
|
||||||
|
addReq.getFileName(),
|
||||||
|
addReq.getFileExt(),
|
||||||
|
addReq.getHstUid(),
|
||||||
|
addReq.getFileSize(),
|
||||||
|
addReq.getFileState())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {
|
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user