페어파일업로드, 파일삭제 수정
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
|
||||
@Setter
|
||||
public class FileConfig {
|
||||
|
||||
// private String rootSyncDir = "D:\\app\\original-images";
|
||||
private String rootSyncDir = "/app/original-images";
|
||||
private String rootSyncDir = "D:\\app\\original-images\\";
|
||||
private String tmpSyncDir = rootSyncDir+"tmp\\";
|
||||
//private String rootSyncDir = "/app/original-images";
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class MapSheetMngDto {
|
||||
public static class MngDto {
|
||||
private int rowNum;
|
||||
private int mngYyyy;
|
||||
private String mngPath;
|
||||
private String mngState;
|
||||
private String syncState;
|
||||
private String syncDataCheckState;
|
||||
@@ -160,9 +161,10 @@ public class MapSheetMngDto {
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ErrorDataDto {
|
||||
// private Integer rowNum;
|
||||
private Long hstUid;
|
||||
private Integer mngYyyy;
|
||||
private String mapSheetNum;
|
||||
private String refMapSheetNum;
|
||||
private String map50kName;
|
||||
private String map5kName;
|
||||
private String mapSrcName;
|
||||
@@ -183,6 +185,9 @@ public class MapSheetMngDto {
|
||||
|
||||
public ErrorDataDto(
|
||||
Long hstUid,
|
||||
Integer mngYyyy,
|
||||
String mapSheetNum,
|
||||
String refMapSheetNum,
|
||||
String map50kName,
|
||||
String map5kName,
|
||||
String mapSrcName,
|
||||
@@ -195,6 +200,9 @@ public class MapSheetMngDto {
|
||||
String errorCheckTfwFileName,
|
||||
String errorCheckTifFileName) {
|
||||
this.hstUid = hstUid;
|
||||
this.mngYyyy = mngYyyy;
|
||||
this.mapSheetNum = mapSheetNum;
|
||||
this.refMapSheetNum = refMapSheetNum;
|
||||
this.map50kName = map50kName;
|
||||
this.map5kName = map5kName;
|
||||
this.mapSrcName = mapSrcName;
|
||||
@@ -218,6 +226,8 @@ public class MapSheetMngDto {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Schema(name = "MngFIleDto", description = "관리파일정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -240,6 +250,23 @@ public class MapSheetMngDto {
|
||||
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 = "영상파일내역 검색 리턴")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -256,4 +283,27 @@ public class MapSheetMngDto {
|
||||
private Long hstUid;
|
||||
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,13 +2,21 @@ package com.kamco.cd.kamcoback.mapsheet.service;
|
||||
|
||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.config.FileConfig;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto;
|
||||
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.SrchFilesDepthDto;
|
||||
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.AddReq;
|
||||
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.ReqUpdateErrorCheckStateDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.File;
|
||||
@@ -16,12 +24,14 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -39,6 +49,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class MapSheetMngService {
|
||||
|
||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||
private final FileConfig fileConfig;
|
||||
|
||||
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||
|
||||
@@ -50,7 +61,7 @@ public class MapSheetMngService {
|
||||
File dir = new File(dirPath);
|
||||
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");
|
||||
|
||||
int fileListPos = 0;
|
||||
@@ -85,7 +96,7 @@ public class MapSheetMngService {
|
||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||
|
||||
files.add(
|
||||
new FileDto.Basic(
|
||||
new Basic(
|
||||
fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
||||
|
||||
fileTotCnt = fileTotCnt + 1;
|
||||
@@ -113,7 +124,7 @@ public class MapSheetMngService {
|
||||
|
||||
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");
|
||||
|
||||
int fileTotCnt = 0;
|
||||
@@ -147,13 +158,13 @@ public class MapSheetMngService {
|
||||
long fileSize = file.length();
|
||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||
|
||||
return new FileDto.Basic(
|
||||
return new Basic(
|
||||
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
fileTotCnt = fileDtoList.size();
|
||||
fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
|
||||
fileTotSize = fileDtoList.stream().mapToLong(Basic::getFileSize).sum();
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
|
||||
@@ -215,7 +226,7 @@ public class MapSheetMngService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MapSheetMngDto.MngDto> findMapSheetMngList() {
|
||||
public List<MngDto> findMapSheetMngList() {
|
||||
return mapSheetMngCoreService.findMapSheetMngList();
|
||||
}
|
||||
|
||||
@@ -225,29 +236,29 @@ public class MapSheetMngService {
|
||||
|
||||
|
||||
|
||||
public MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy) {
|
||||
public MngDto findMapSheetMng(int mngYyyy) {
|
||||
return mapSheetMngCoreService.findMapSheetMng(mngYyyy);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MapSheetMngDto.DmlReturn mngComplete(int mngYyyy) {
|
||||
public DmlReturn mngComplete(int mngYyyy) {
|
||||
|
||||
mapSheetMngCoreService.MapSheetMngComplete(mngYyyy);
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", "작업완료 처리되었습니다.");
|
||||
return new DmlReturn("success", "작업완료 처리되었습니다.");
|
||||
}
|
||||
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||
public Page<ErrorDataDto> findMapSheetErrorList(
|
||||
@Valid ErrorSearchReq searchReq) {
|
||||
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
||||
}
|
||||
|
||||
public MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid) {
|
||||
public ErrorDataDto findMapSheetError(Long hstUid) {
|
||||
return mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MapSheetMngDto.DmlReturn mngDataSave(MapSheetMngDto.AddReq AddReq) {
|
||||
public DmlReturn mngDataSave(AddReq AddReq) {
|
||||
return mapSheetMngCoreService.mngDataSave(AddReq);
|
||||
}
|
||||
|
||||
@@ -262,11 +273,11 @@ public class MapSheetMngService {
|
||||
|
||||
*/
|
||||
|
||||
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
||||
public DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
||||
return mapSheetMngCoreService.uploadProcess(hstUidList);
|
||||
}
|
||||
|
||||
public MapSheetMngDto.DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
||||
public DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
||||
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
||||
}
|
||||
|
||||
@@ -277,6 +288,9 @@ public class MapSheetMngService {
|
||||
// String targetPath,
|
||||
Long hstUid) {
|
||||
|
||||
String rootPath = fileConfig.getRootSyncDir();
|
||||
String tmpPath = fileConfig.getTmpSyncDir();
|
||||
|
||||
// 파일 유효성 검증
|
||||
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
||||
return new DmlReturn("fail", "TFW SIZE 오류");
|
||||
@@ -289,15 +303,75 @@ public class MapSheetMngService {
|
||||
.substring(tfwFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||
.toLowerCase()
|
||||
.equals("tfw")) {
|
||||
return new DmlReturn("fail", "TFW TYPE ERROR");
|
||||
return new DmlReturn("fail", "TFW FILENAME ERROR");
|
||||
} else if (!tifFile
|
||||
.getOriginalFilename()
|
||||
.substring(tifFile.getOriginalFilename().lastIndexOf('.') + 1)
|
||||
.toLowerCase()
|
||||
.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);
|
||||
String uploadPath = "";
|
||||
@@ -306,28 +380,83 @@ public class MapSheetMngService {
|
||||
break;
|
||||
}
|
||||
|
||||
Path tfwTargetPath = null;
|
||||
Path tifTargetPath = null;
|
||||
Path uploadTargetPath = null;
|
||||
|
||||
if (uploadPath.isEmpty()) {
|
||||
// ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||
// uploadPath = FileConfig.rootSyncDir+"\\"+errDto.getMapSheetNum();
|
||||
MngFilesDto filesDto = 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가 있는 경우
|
||||
// tif가 있는 경우
|
||||
//String searchDir =
|
||||
|
||||
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", "파일 업로드 완료되었습니다.");
|
||||
}
|
||||
|
||||
public List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||
public List<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
|
||||
public DmlReturn deleteByFileUidMngFile(List<Long> 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() + "개 파일이 삭제되었습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
@@ -49,6 +50,28 @@ public class MapSheetMngCoreService {
|
||||
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(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||
return mapSheetMngRepository.findMapSheetErrorList(searchReq);
|
||||
@@ -58,10 +81,21 @@ public class MapSheetMngCoreService {
|
||||
return mapSheetMngRepository.findMapSheetError(hstUid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long 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) {
|
||||
int count = 0;
|
||||
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
||||
@@ -215,6 +249,7 @@ public class MapSheetMngCoreService {
|
||||
}
|
||||
|
||||
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(Long fileUid) {
|
||||
|
||||
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");
|
||||
|
||||
@@ -15,6 +15,8 @@ public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy);
|
||||
|
||||
|
||||
|
||||
void MapSheetMngComplete(int mngYyyy);
|
||||
|
||||
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
||||
@@ -25,7 +27,7 @@ public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
void deleteByFileUidMngFile(Long fileUid);
|
||||
|
||||
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy);
|
||||
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy);
|
||||
|
||||
void deleteByMngYyyyMngAll(int mngYyyy);
|
||||
|
||||
@@ -35,12 +37,23 @@ public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
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(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
||||
|
||||
MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid);
|
||||
|
||||
List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid);
|
||||
MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid);
|
||||
|
||||
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.hibernate.query.Query;
|
||||
@@ -72,6 +74,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
"row_number() over(order by {0} desc)",
|
||||
mapSheetMngEntity.createdDttm),
|
||||
mapSheetMngEntity.mngYyyy,
|
||||
mapSheetMngEntity.mngPath,
|
||||
mapSheetMngEntity.mngState,
|
||||
mapSheetMngEntity.syncState,
|
||||
mapSheetMngEntity.syncCheckState,
|
||||
@@ -194,6 +197,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
"row_number() over(order by {0} desc)",
|
||||
mapSheetMngEntity.createdDttm),
|
||||
mapSheetMngEntity.mngYyyy,
|
||||
mapSheetMngEntity.mngPath,
|
||||
mapSheetMngEntity.mngState,
|
||||
mapSheetMngEntity.syncState,
|
||||
mapSheetMngEntity.syncCheckState,
|
||||
@@ -336,6 +340,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
Projections.constructor(
|
||||
MapSheetMngDto.ErrorDataDto.class,
|
||||
mapSheetMngHstEntity.hstUid,
|
||||
mapSheetMngHstEntity.mngYyyy,
|
||||
mapSheetMngHstEntity.mapSheetNum,
|
||||
mapSheetMngHstEntity.refMapSheetNum,
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 0, 6))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
@@ -386,37 +393,39 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
whereBuilder.and(mapSheetMngHstEntity.hstUid.eq(hstUid));
|
||||
|
||||
MapSheetMngDto.ErrorDataDto foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MapSheetMngDto.ErrorDataDto.class,
|
||||
mapSheetMngHstEntity.hstUid,
|
||||
mapSheetMngHstEntity.mapSheetNum,
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 0, 6))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("map50kName"),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 6, 8))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("map5kName"),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 6, 8))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("mapSrcName"),
|
||||
mapInkx5kEntity.fid,
|
||||
mapSheetMngHstEntity.createdDate,
|
||||
mapSheetMngHstEntity.syncState,
|
||||
mapSheetMngHstEntity.syncTfwFileName,
|
||||
mapSheetMngHstEntity.syncTifFileName,
|
||||
mapSheetMngHstEntity.syncCheckState,
|
||||
mapSheetMngHstEntity.syncCheckTfwFileName,
|
||||
mapSheetMngHstEntity.syncCheckTifFileName))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MapSheetMngDto.ErrorDataDto.class,
|
||||
mapSheetMngHstEntity.hstUid,
|
||||
mapSheetMngHstEntity.mngYyyy,
|
||||
mapSheetMngHstEntity.mapSheetNum,
|
||||
mapSheetMngHstEntity.refMapSheetNum,
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 0, 6))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("map50kName"),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 6, 8))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("map5kName"),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 6, 8))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.as("mapSrcName"),
|
||||
mapInkx5kEntity.fid,
|
||||
mapSheetMngHstEntity.createdDate,
|
||||
mapSheetMngHstEntity.syncState,
|
||||
mapSheetMngHstEntity.syncTfwFileName,
|
||||
mapSheetMngHstEntity.syncTifFileName,
|
||||
mapSheetMngHstEntity.syncCheckState,
|
||||
mapSheetMngHstEntity.syncCheckTfwFileName,
|
||||
mapSheetMngHstEntity.syncCheckTifFileName))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
|
||||
return foundContent;
|
||||
}
|
||||
@@ -476,7 +485,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy) {
|
||||
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
|
||||
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
whereBuilder.and(mapSheetMngFileEntity.mngYyyy.eq(mngYyyy));
|
||||
@@ -497,11 +506,39 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetMngFileEntity.fileSize))
|
||||
.from(mapSheetMngFileEntity)
|
||||
.where(whereBuilder)
|
||||
.orderBy(mapSheetMngFileEntity.fileUid.desc())
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
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) {
|
||||
long execCount =
|
||||
queryFactory
|
||||
@@ -511,6 +548,26 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.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
|
||||
public void deleteByMngYyyyMngAll(int mngYyyy) {
|
||||
|
||||
@@ -564,14 +621,53 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByFileUidMngFile(Long fileUid) {
|
||||
public void deleteByHstUidMngFile(Long hstUid) {
|
||||
long deletedFileCount =
|
||||
queryFactory
|
||||
.delete(mapSheetMngFileEntity)
|
||||
.where(mapSheetMngFileEntity.fileUid.eq(hstUid))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByFileUidMngFile(Long fileUid) {
|
||||
long fileCount =
|
||||
queryFactory
|
||||
.delete(mapSheetMngFileEntity)
|
||||
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
|
||||
.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
|
||||
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user