영상관리 수정
This commit is contained in:
@@ -178,6 +178,10 @@ public class MapSheetMngApiController {
|
|||||||
return ApiResponseDto.ok(mapSheetMngService.updateExceptUseInference(hstUidList));
|
return ApiResponseDto.ok(mapSheetMngService.updateExceptUseInference(hstUidList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
@Operation(summary = "페어 파일 업로드", description = "TFW/TIF 두 파일을 쌍으로 업로드 및 검증")
|
@Operation(summary = "페어 파일 업로드", description = "TFW/TIF 두 파일을 쌍으로 업로드 및 검증")
|
||||||
@PostMapping(value = "/upload-pair", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/upload-pair", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadPair(
|
public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadPair(
|
||||||
@@ -190,8 +194,6 @@ public class MapSheetMngApiController {
|
|||||||
mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite));
|
mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite));
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회")
|
@Operation(summary = "영상관리 > 파일조회", description = "영상관리 > 파일조회")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@@ -207,33 +209,13 @@ public class MapSheetMngApiController {
|
|||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
@GetMapping("/mng-file-list")
|
@GetMapping("/mng-file-list")
|
||||||
public ApiResponseDto<List<MapSheetMngDto.MngFilesDto>> findHstUidToMapSheetFileList(
|
public ApiResponseDto<List<MapSheetMngDto.MngFilesDto>> findByHstUidMapSheetFileList(
|
||||||
@RequestParam @Valid Long hstUid) {
|
@RequestParam @Valid Long hstUid) {
|
||||||
return ApiResponseDto.ok(mapSheetMngService.findHstUidToMapSheetFileList(hstUid));
|
return ApiResponseDto.ok(mapSheetMngService.findByHstUidMapSheetFileList(hstUid));
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "영상관리 > 파일삭제", description = "영상관리 > 파일삭제")
|
|
||||||
@ApiResponses(
|
|
||||||
value = {
|
|
||||||
@ApiResponse(
|
|
||||||
responseCode = "201",
|
|
||||||
description = "파일삭제 처리 성공",
|
|
||||||
content =
|
|
||||||
@Content(
|
|
||||||
mediaType = "application/json",
|
|
||||||
schema = @Schema(implementation = Long.class))),
|
|
||||||
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
|
||||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
|
||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
||||||
})
|
|
||||||
@PutMapping("/del-mng-files")
|
|
||||||
public ApiResponseDto<MapSheetMngDto.DmlReturn> deleteByFileUidMngFile(
|
|
||||||
@RequestParam @Valid List<Long> fileUids) {
|
|
||||||
return ApiResponseDto.ok(mapSheetMngService.deleteByFileUidMngFile(fileUids));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "영상관리 > 파일사용설정", description = "영상관리 > 파일사용설정(중복파일제거 및 선택파일사용설정)")
|
@Operation(summary = "영상관리 > 파일사용설정 및 중복제거", description = "영상관리 >파일사용설정 및 중복제거(중복파일제거 및 선택파일사용설정)")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
|
|||||||
@@ -90,16 +90,7 @@ public class MapSheetMngDto {
|
|||||||
@JsonFormatDttm private ZonedDateTime rgstStrtDttm;
|
@JsonFormatDttm private ZonedDateTime rgstStrtDttm;
|
||||||
@JsonFormatDttm private ZonedDateTime rgstEndDttm;
|
@JsonFormatDttm private ZonedDateTime rgstEndDttm;
|
||||||
|
|
||||||
public String getMngState() {
|
|
||||||
|
|
||||||
if (this.syncStateDoneCnt == 0) return "NOTYET";
|
|
||||||
else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING";
|
|
||||||
|
|
||||||
if ((this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0)
|
|
||||||
return "TAKINGERROR";
|
|
||||||
|
|
||||||
return "DONE";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSyncState() {
|
public String getSyncState() {
|
||||||
|
|
||||||
@@ -139,8 +130,22 @@ public class MapSheetMngDto {
|
|||||||
return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt;
|
return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getMngState() {
|
||||||
|
|
||||||
|
String mngState = "DONE";
|
||||||
|
|
||||||
|
if (this.syncStateDoneCnt == 0) mngState = "NOTYET";
|
||||||
|
else if (this.syncStateDoneCnt < this.syncTotCnt) mngState = "PROCESSING";
|
||||||
|
|
||||||
|
if ((this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0)
|
||||||
|
mngState = "TAKINGERROR";
|
||||||
|
|
||||||
|
return mngState;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMngStateName() {
|
public String getMngStateName() {
|
||||||
String enumId = this.mngState;
|
String enumId = this.getMngState();
|
||||||
if (enumId == null || enumId.isEmpty()) {
|
if (enumId == null || enumId.isEmpty()) {
|
||||||
enumId = "NOTYET";
|
enumId = "NOTYET";
|
||||||
}
|
}
|
||||||
@@ -148,6 +153,7 @@ public class MapSheetMngDto {
|
|||||||
MngStateType type = Enums.fromId(MngStateType.class, enumId);
|
MngStateType type = Enums.fromId(MngStateType.class, enumId);
|
||||||
return type.getText();
|
return type.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema(name = "ErrorSearchReq", description = "영상관리 오류데이터 검색 요청")
|
@Schema(name = "ErrorSearchReq", description = "영상관리 오류데이터 검색 요청")
|
||||||
|
|||||||
@@ -73,13 +73,11 @@ public class MapSheetMngService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public DmlReturn mngDataSave(AddReq AddReq) {
|
public DmlReturn mngDataSave(AddReq addReq) {
|
||||||
return mapSheetMngCoreService.mngDataSave(AddReq);
|
int execCnt = mapSheetMngCoreService.mngDataSave(addReq);
|
||||||
|
return new MapSheetMngDto.DmlReturn("success", addReq.getMngYyyy()+"년, "+execCnt+"건 생성");
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
|
||||||
return mapSheetMngCoreService.uploadProcess(hstUidList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
public DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
||||||
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
return mapSheetMngCoreService.updateExceptUseInference(hstUidList);
|
||||||
@@ -129,7 +127,7 @@ public class MapSheetMngService {
|
|||||||
if (!FIleChecker.checkTfw(tfwTmpPath)) return new DmlReturn("fail", "TFW TYPE ERROR");
|
if (!FIleChecker.checkTfw(tfwTmpPath)) return new DmlReturn("fail", "TFW TYPE ERROR");
|
||||||
|
|
||||||
// 싱크파일목록으로 업로드 경로 확인
|
// 싱크파일목록으로 업로드 경로 확인
|
||||||
List<MngFilesDto> mngFiles = mapSheetMngCoreService.findIdToMapSheetFileList(hstUid);
|
List<MngFilesDto> mngFiles = mapSheetMngCoreService.findByHstUidMapSheetFileList(hstUid);
|
||||||
String uploadPath = "";
|
String uploadPath = "";
|
||||||
for (MngFilesDto dto : mngFiles) {
|
for (MngFilesDto dto : mngFiles) {
|
||||||
uploadPath = dto.getFilePath();
|
uploadPath = dto.getFilePath();
|
||||||
@@ -197,24 +195,10 @@ public class MapSheetMngService {
|
|||||||
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
public List<MngFilesDto> findByHstUidMapSheetFileList(Long hstUid) {
|
||||||
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
return mapSheetMngCoreService.findByHstUidMapSheetFileList(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
|
|
||||||
|
|
||||||
long hstUid = 0;
|
|
||||||
|
|
||||||
for (Long uid : fileUids) {
|
|
||||||
mapSheetMngCoreService.deleteByFileUidMngFile(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 중복제거 확인후 처리상태(DONE)변경
|
|
||||||
//if (hstUid > 0) mapSheetMngCoreService.updateByHstUidSyncCheckState(hstUid);
|
|
||||||
|
|
||||||
return new DmlReturn("success", fileUids.size() + "개 파일이 삭제되었습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public DmlReturn setUseByFileUidMngFile(List<Long> fileUids) {
|
public DmlReturn setUseByFileUidMngFile(List<Long> fileUids) {
|
||||||
@@ -223,21 +207,29 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
DmlReturn dmlReturn = new DmlReturn("success", "정상처리되었습니다.");
|
DmlReturn dmlReturn = new DmlReturn("success", "정상처리되었습니다.");
|
||||||
|
|
||||||
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findByFileUidMapSheetFile(fileUids.get(0));
|
MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto = new MapSheetMngDto.SyncCheckStateReqUpdateDto();
|
||||||
hstUid = dto.getHstUid();
|
|
||||||
|
|
||||||
mapSheetMngCoreService.deleteByNotInFileUidMngFile(hstUid, fileUids);
|
|
||||||
|
|
||||||
for (Long uid : fileUids) {
|
for (Long uid : fileUids) {
|
||||||
|
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findByFileUidMapSheetFile(uid);
|
||||||
|
|
||||||
|
reqDto.setHstUid(dto.getHstUid());
|
||||||
|
reqDto.setFilePath(dto.getFilePath());
|
||||||
|
reqDto.setSyncCheckState("DONE");
|
||||||
|
|
||||||
|
if (dto.getFileExt().equals("tif")) reqDto.setSyncCheckTifFileName(dto.getFileName());
|
||||||
|
else if (dto.getFileExt().equals("tfw")) reqDto.setSyncCheckTfwFileName(dto.getFileName());
|
||||||
|
|
||||||
mapSheetMngCoreService.updateByFileUidFileState(uid, "DONE");
|
mapSheetMngCoreService.updateByFileUidFileState(uid, "DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//선택제외 삭제처리
|
||||||
|
mapSheetMngCoreService.deleteByNotInFileUidMngFile(reqDto.getHstUid(), fileUids);
|
||||||
|
//Hst(내역) 테이블 상태 업데이트
|
||||||
|
mapSheetMngCoreService.updateByHstUidSyncCheckState(reqDto);
|
||||||
|
|
||||||
return new DmlReturn("success", fileUids.size() + "개 파일이 사용설정되었습니다.");
|
return new DmlReturn("success", fileUids.size() + "개 파일이 사용설정되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile)
|
public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile)
|
||||||
{
|
{
|
||||||
if( !FIleChecker.validationMultipart(tfwFile) )return new DmlReturn("fail", "TFW SIZE 오류");
|
if( !FIleChecker.validationMultipart(tfwFile) )return new DmlReturn("fail", "TFW SIZE 오류");
|
||||||
@@ -253,9 +245,6 @@ public class MapSheetMngService {
|
|||||||
int tfwCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tfwFileName);
|
int tfwCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tfwFileName);
|
||||||
int tifCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tifFileName);
|
int tifCnt = mapSheetMngCoreService.findByYearFileNameFileCount(mngYyyy, tifFileName);
|
||||||
|
|
||||||
System.out.println("tfwCnt ==" + tfwCnt);
|
|
||||||
System.out.println("tifCnt ==" + tifCnt);
|
|
||||||
|
|
||||||
if (tfwCnt > 0 || tifCnt > 0) {
|
if (tfwCnt > 0 || tifCnt > 0) {
|
||||||
String resMsg = "";
|
String resMsg = "";
|
||||||
if (tfwCnt > 0)
|
if (tfwCnt > 0)
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ public class MapSheetMngCoreService {
|
|||||||
|
|
||||||
private final MapSheetMngRepository mapSheetMngRepository;
|
private final MapSheetMngRepository mapSheetMngRepository;
|
||||||
|
|
||||||
private static final String ORIGINAL_IMAGES_PATH = "/app/original-images";
|
|
||||||
|
|
||||||
@Value("{spring.profiles.active}")
|
@Value("{spring.profiles.active}")
|
||||||
private String activeEnv;
|
private String activeEnv;
|
||||||
|
|
||||||
@@ -53,7 +51,6 @@ public class MapSheetMngCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int findByYearFileNameFileCount(int mngYyyy, String fileName) {
|
public int findByYearFileNameFileCount(int mngYyyy, String fileName) {
|
||||||
return mapSheetMngRepository.findByYearFileNameFileCount(mngYyyy, fileName);
|
return mapSheetMngRepository.findByYearFileNameFileCount(mngYyyy, fileName);
|
||||||
}
|
}
|
||||||
@@ -61,7 +58,6 @@ public class MapSheetMngCoreService {
|
|||||||
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
||||||
|
|
||||||
mapSheetMngRepository.mngFileSave(addReq);
|
mapSheetMngRepository.mngFileSave(addReq);
|
||||||
// int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
|
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
|
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
|
||||||
}
|
}
|
||||||
@@ -79,8 +75,8 @@ public class MapSheetMngCoreService {
|
|||||||
return mapSheetMngRepository.findMapSheetError(hstUid);
|
return mapSheetMngRepository.findMapSheetError(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid) {
|
public List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid) {
|
||||||
return mapSheetMngRepository.findIdToMapSheetFileList(hstUid);
|
return mapSheetMngRepository.findByHstUidMapSheetFileList(hstUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
|
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
|
||||||
@@ -91,91 +87,7 @@ public class MapSheetMngCoreService {
|
|||||||
return mapSheetMngRepository.findByFileUidMapSheetFile(fileUid);
|
return mapSheetMngRepository.findByFileUidMapSheetFile(fileUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
|
|
||||||
int count = 0;
|
|
||||||
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
|
||||||
for (Long hstUid : hstUidList) {
|
|
||||||
Optional<MapSheetMngHstEntity> entity =
|
|
||||||
Optional.ofNullable(
|
|
||||||
mapSheetMngRepository
|
|
||||||
.findMapSheetMngHstInfo(hstUid)
|
|
||||||
.orElseThrow(EntityNotFoundException::new));
|
|
||||||
|
|
||||||
String localPath = "";
|
|
||||||
String rootDir = ORIGINAL_IMAGES_PATH + "/" + entity.get().getMngYyyy();
|
|
||||||
if (activeEnv.equals("local")) {
|
|
||||||
rootDir = localPath + rootDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = entity.get().getMapSheetNum();
|
|
||||||
String[] extensions = {"tif", "tfw"};
|
|
||||||
boolean flag = allExtensionsExist(rootDir, filename, extensions);
|
|
||||||
if (flag) {
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 파일 크기 계산 및 저장
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(rootDir))) {
|
|
||||||
List<Path> matched =
|
|
||||||
paths
|
|
||||||
.filter(Files::isRegularFile)
|
|
||||||
.filter(
|
|
||||||
p -> {
|
|
||||||
String name = p.getFileName().toString();
|
|
||||||
return name.equals(filename + ".tif") || name.equals(filename + ".tfw");
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
long tifSize =
|
|
||||||
matched.stream()
|
|
||||||
.filter(p -> p.getFileName().toString().endsWith(".tif"))
|
|
||||||
.mapToLong(
|
|
||||||
p -> {
|
|
||||||
try {
|
|
||||||
return Files.size(p);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
long tfwSize =
|
|
||||||
matched.stream()
|
|
||||||
.filter(p -> p.getFileName().toString().endsWith(".tfw"))
|
|
||||||
.mapToLong(
|
|
||||||
p -> {
|
|
||||||
try {
|
|
||||||
return Files.size(p);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
entity.get().setTifSizeBytes(tifSize);
|
|
||||||
entity.get().setTfwSizeBytes(tfwSize);
|
|
||||||
entity.get().setTotalSizeBytes(tifSize + tfwSize);
|
|
||||||
|
|
||||||
// 엔터티 저장 -> 커스텀 업데이트로 변경
|
|
||||||
mapSheetMngRepository.updateHstFileSizes(
|
|
||||||
entity.get().getHstUid(), tifSize, tfwSize, tifSize + tfwSize);
|
|
||||||
} catch (IOException e) {
|
|
||||||
// 크기 계산 실패 시 0으로 저장
|
|
||||||
entity.get().setTifSizeBytes(0L);
|
|
||||||
entity.get().setTfwSizeBytes(0L);
|
|
||||||
entity.get().setTotalSizeBytes(0L);
|
|
||||||
mapSheetMngRepository.updateHstFileSizes(entity.get().getHstUid(), 0L, 0L, 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
MapSheetMngDto.DataState dataState =
|
|
||||||
flag ? MapSheetMngDto.DataState.SUCCESS : MapSheetMngDto.DataState.FAIL;
|
|
||||||
entity.get().updateDataState(dataState);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
public MapSheetMngDto.DmlReturn updateExceptUseInference(@Valid List<Long> hstUidList) {
|
||||||
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
|
||||||
@@ -192,40 +104,9 @@ public class MapSheetMngCoreService {
|
|||||||
return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다.");
|
return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 특정 파일명 + 여러 확장자가 모두 존재하는지 확인
|
|
||||||
*
|
|
||||||
* @param rootDir 검색할 최상위 디렉토리
|
|
||||||
* @param filename 파일명 (확장자 제외)
|
|
||||||
* @param extensions 확인할 확장자 배열 (예: {"tif", "tfw"})
|
|
||||||
* @return 모든 확장자가 존재하면 true, 하나라도 없으면 false
|
|
||||||
*/
|
|
||||||
public static boolean allExtensionsExist(String rootDir, String filename, String... extensions) {
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(rootDir))) {
|
|
||||||
|
|
||||||
// 모든 파일명을 Set으로 저장
|
|
||||||
Set<String> fileNames =
|
|
||||||
paths
|
|
||||||
.filter(Files::isRegularFile)
|
|
||||||
.map(p -> p.getFileName().toString())
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
// 모든 확장자 파일 존재 여부 확인
|
public int mngDataSave(@Valid MapSheetMngDto.AddReq addReq) {
|
||||||
for (String ext : extensions) {
|
|
||||||
String target = filename + "." + ext;
|
|
||||||
if (!fileNames.contains(target)) {
|
|
||||||
return false; // 하나라도 없으면 false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true; // 모두 존재하면 true
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException("File search error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn mngDataSave(@Valid MapSheetMngDto.AddReq addReq) {
|
|
||||||
|
|
||||||
MapSheetMngEntity entity = new MapSheetMngEntity();
|
MapSheetMngEntity entity = new MapSheetMngEntity();
|
||||||
entity.setMngYyyy(addReq.getMngYyyy());
|
entity.setMngYyyy(addReq.getMngYyyy());
|
||||||
@@ -234,10 +115,10 @@ public class MapSheetMngCoreService {
|
|||||||
mapSheetMngRepository.deleteByMngYyyyMngAll(addReq.getMngYyyy());
|
mapSheetMngRepository.deleteByMngYyyyMngAll(addReq.getMngYyyy());
|
||||||
|
|
||||||
MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
|
MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
|
||||||
int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
|
int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy(), saved.getMngPath());
|
||||||
mapSheetMngRepository.updateYearState(saved.getMngYyyy(), "DONE");
|
mapSheetMngRepository.updateYearState(saved.getMngYyyy(), "DONE");
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString());
|
return hstCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
public List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||||
@@ -248,37 +129,13 @@ public class MapSheetMngCoreService {
|
|||||||
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
|
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn updateByHstUidSyncCheckState(Long hstUid) {
|
public void updateByHstUidSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto) {
|
||||||
|
|
||||||
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.updateMapSheetMngHstSyncCheckState(reqDto);
|
||||||
mapSheetMngRepository.updateByHstUidMngFileState(hstUid, fileState);
|
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", hstUid + " : 상태변경되었습니다.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn updateByFileUidFileState(Long fileUid, String fileState) {
|
public void updateByFileUidFileState(Long fileUid, String fileState) {
|
||||||
|
|
||||||
mapSheetMngRepository.updateByFileUidMngFileState(fileUid, fileState);
|
mapSheetMngRepository.updateByFileUidMngFileState(fileUid, fileState);
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 상태변경되었습니다.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteByNotInFileUidMngFile(Long hstUid, List<Long> fileUids){
|
public void deleteByNotInFileUidMngFile(Long hstUid, List<Long> fileUids){
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
||||||
|
|
||||||
int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy);
|
int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy, String mngPath);
|
||||||
|
|
||||||
List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid);
|
List<MapSheetMngDto.MngFilesDto> findHstUidToMapSheetFileList(Long hstUid);
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid);
|
MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid);
|
||||||
|
|
||||||
List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid);
|
List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid);
|
||||||
|
|
||||||
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
||||||
|
|
||||||
|
|||||||
@@ -448,10 +448,11 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid) {
|
public List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid) {
|
||||||
|
|
||||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||||
whereBuilder.and(mapSheetMngFileEntity.hstUid.eq(hstUid));
|
whereBuilder.and(mapSheetMngFileEntity.hstUid.eq(hstUid));
|
||||||
|
whereBuilder.and(mapSheetMngFileEntity.fileDel.eq(false));
|
||||||
|
|
||||||
List<MapSheetMngDto.MngFilesDto> foundContent =
|
List<MapSheetMngDto.MngFilesDto> foundContent =
|
||||||
queryFactory
|
queryFactory
|
||||||
@@ -725,13 +726,14 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {
|
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy, String mngPath) {
|
||||||
|
|
||||||
String sql =
|
String sql =
|
||||||
"""
|
"""
|
||||||
INSERT INTO tb_map_sheet_mng_hst
|
INSERT INTO tb_map_sheet_mng_hst
|
||||||
(
|
(
|
||||||
mng_yyyy
|
mng_yyyy
|
||||||
|
,map_sheet_path
|
||||||
,map_sheet_code
|
,map_sheet_code
|
||||||
,map_sheet_num
|
,map_sheet_num
|
||||||
,map_sheet_name
|
,map_sheet_name
|
||||||
@@ -741,14 +743,15 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
,use_inference
|
,use_inference
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
:mngYyyy as mng_yyyy
|
:mngYyyy as mng_yyyy,
|
||||||
,fid as map_sheet_code
|
:mngPath as map_sheet_path,
|
||||||
,mapidcd_no::INTEGER as map_sheet_num
|
fid as map_sheet_code,
|
||||||
,mapid_nm as map_sheet_name
|
mapidcd_no as map_sheet_num,
|
||||||
,fid as map_sheet_code_src
|
mapid_nm as map_sheet_name,
|
||||||
,5000 as scale_ratio
|
fid as map_sheet_code_src,
|
||||||
,((mapidcd_no::INTEGER)/1000) as ref_map_sheet_num
|
5000 as scale_ratio,
|
||||||
,use_inference
|
((mapidcd_no::INTEGER)/1000) as ref_map_sheet_num,
|
||||||
|
use_inference
|
||||||
from
|
from
|
||||||
tb_map_inkx_5k
|
tb_map_inkx_5k
|
||||||
""";
|
""";
|
||||||
@@ -756,6 +759,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
// Native Query 생성 및 실행
|
// Native Query 생성 및 실행
|
||||||
Query query = (Query) em.createNativeQuery(sql);
|
Query query = (Query) em.createNativeQuery(sql);
|
||||||
query.setParameter("mngYyyy", mngYyyy);
|
query.setParameter("mngYyyy", mngYyyy);
|
||||||
|
query.setParameter("mngPath", mngPath);
|
||||||
|
|
||||||
int exeCnt = query.executeUpdate(); // 실행 (영향받은 행의 개수 반환)
|
int exeCnt = query.executeUpdate(); // 실행 (영향받은 행의 개수 반환)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user