영상관리파일싱크 추가
This commit is contained in:
@@ -2,7 +2,6 @@ package com.kamco.cd.kamcoback.common.utils;
|
|||||||
|
|
||||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.FileDto;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -207,7 +206,6 @@ public class FIleChecker {
|
|||||||
return hasDriver;
|
return hasDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||||
@Getter
|
@Getter
|
||||||
public static class Basic {
|
public static class Basic {
|
||||||
@@ -238,9 +236,14 @@ public class FIleChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Basic> getFilesFromAllDepth(
|
||||||
|
String dir,
|
||||||
public static List<Basic> getFilesFromAllDepth(String dir, String targetFileNm, String extension, int maxDepth, String sortType, int startPos, int limit) {
|
String targetFileNm,
|
||||||
|
String extension,
|
||||||
|
int maxDepth,
|
||||||
|
String sortType,
|
||||||
|
int startPos,
|
||||||
|
int limit) {
|
||||||
|
|
||||||
Path startPath = Paths.get(dir);
|
Path startPath = Paths.get(dir);
|
||||||
String dirPath = dir;
|
String dirPath = dir;
|
||||||
@@ -265,9 +268,7 @@ public class FIleChecker {
|
|||||||
|| extension.equals("*")
|
|| extension.equals("*")
|
||||||
|| targetExtensions.contains(extractExtension(p)))
|
|| targetExtensions.contains(extractExtension(p)))
|
||||||
.sorted(getFileComparator(sortType))
|
.sorted(getFileComparator(sortType))
|
||||||
.filter(
|
.filter(p -> p.getFileName().toString().contains(targetFileNm))
|
||||||
p -> p.getFileName().toString().contains(targetFileNm)
|
|
||||||
)
|
|
||||||
.skip(startPos)
|
.skip(startPos)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.map(
|
.map(
|
||||||
@@ -289,7 +290,6 @@ public class FIleChecker {
|
|||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
|
System.err.println("파일 I/O 오류 발생: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,6 @@ public class FIleChecker {
|
|||||||
return fileList;
|
return fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Set<String> createExtensionSet(String extensionString) {
|
public static Set<String> createExtensionSet(String extensionString) {
|
||||||
if (extensionString == null || extensionString.isBlank()) {
|
if (extensionString == null || extensionString.isBlank()) {
|
||||||
return Set.of();
|
return Set.of();
|
||||||
@@ -350,5 +349,4 @@ public class FIleChecker {
|
|||||||
return nameComparator;
|
return nameComparator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,4 @@ 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 rootSyncDir = "/app/original-images";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,12 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.core;
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.scheduler.MapSheetMngFileJobRepository;
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
|
||||||
import com.kamco.cd.kamcoback.postgres.repository.scheduler.MapSheetMngFileJobRepository;
|
|
||||||
import jakarta.persistence.EntityNotFoundException;
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -38,14 +25,14 @@ public class MapSheetMngFileJobCoreService {
|
|||||||
return mapSheetMngFileJobRepository.findTargetMapSheetFileList(targetNum, pageSize);
|
return mapSheetMngFileJobRepository.findTargetMapSheetFileList(targetNum, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn mngHstDataSyncStateUpdate(@Valid MapSheetMngDto.MngHstDto updateReq) {
|
public MapSheetMngDto.DmlReturn mngHstDataSyncStateUpdate(
|
||||||
|
@Valid MapSheetMngDto.MngHstDto updateReq) {
|
||||||
|
|
||||||
mapSheetMngFileJobRepository.mngHstDataSyncStateUpdate(updateReq);
|
mapSheetMngFileJobRepository.mngHstDataSyncStateUpdate(updateReq);
|
||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", updateReq.getHstUid() + "");
|
return new MapSheetMngDto.DmlReturn("success", updateReq.getHstUid() + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
|
||||||
|
|
||||||
MapSheetMngFileEntity entity = new MapSheetMngFileEntity();
|
MapSheetMngFileEntity entity = new MapSheetMngFileEntity();
|
||||||
@@ -64,5 +51,4 @@ public class MapSheetMngFileJobCoreService {
|
|||||||
|
|
||||||
return new MapSheetMngDto.DmlReturn("success", saved.getFileUid().toString());
|
return new MapSheetMngDto.DmlReturn("success", saved.getFileUid().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,9 @@ public class MapSheetMngFileEntity {
|
|||||||
|
|
||||||
@Column(name = "file_size")
|
@Column(name = "file_size")
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
|
@Size(max = 20)
|
||||||
|
@Column(name = "file_state", length = 20)
|
||||||
|
private String fileState;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.scheduler;
|
package com.kamco.cd.kamcoback.postgres.repository.scheduler;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepositoryCustom;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface MapSheetMngFileJobRepository
|
public interface MapSheetMngFileJobRepository
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package com.kamco.cd.kamcoback.postgres.repository.scheduler;
|
|||||||
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
public interface MapSheetMngFileJobRepositoryCustom {
|
public interface MapSheetMngFileJobRepositoryCustom {
|
||||||
@@ -15,6 +12,4 @@ public interface MapSheetMngFileJobRepositoryCustom {
|
|||||||
void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq);
|
void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq);
|
||||||
|
|
||||||
List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize);
|
List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq) {
|
public void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq) {
|
||||||
|
|
||||||
if (updateReq.getSyncState().equals("DONE")) {
|
if (updateReq.getSyncState().equals("DONE")) {
|
||||||
@@ -119,8 +118,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.set(mapSheetMngHstEntity.syncEndDttm, ZonedDateTime.now())
|
.set(mapSheetMngHstEntity.syncEndDttm, ZonedDateTime.now())
|
||||||
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
long updateCount =
|
long updateCount =
|
||||||
queryFactory
|
queryFactory
|
||||||
.update(mapSheetMngHstEntity)
|
.update(mapSheetMngHstEntity)
|
||||||
@@ -132,13 +130,10 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize)
|
public List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize) {
|
||||||
{
|
|
||||||
// Pageable pageable = searchReq.toPageable();
|
// Pageable pageable = searchReq.toPageable();
|
||||||
|
|
||||||
List<MngHstDto> foundContent =
|
List<MngHstDto> foundContent =
|
||||||
@@ -157,21 +152,17 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
mapSheetMngHstEntity.syncEndDttm,
|
mapSheetMngHstEntity.syncEndDttm,
|
||||||
mapSheetMngHstEntity.syncCheckStrtDttm,
|
mapSheetMngHstEntity.syncCheckStrtDttm,
|
||||||
mapSheetMngHstEntity.syncCheckEndDttm,
|
mapSheetMngHstEntity.syncCheckEndDttm,
|
||||||
|
mapSheetMngEntity.mngPath))
|
||||||
mapSheetMngEntity.mngPath
|
|
||||||
))
|
|
||||||
.from(mapSheetMngHstEntity)
|
.from(mapSheetMngHstEntity)
|
||||||
.join(mapSheetMngEntity).on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
|
.join(mapSheetMngEntity)
|
||||||
|
.on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
|
||||||
.where(
|
.where(
|
||||||
mapSheetMngHstEntity.syncState.eq("NOTYET"),
|
mapSheetMngHstEntity.syncState.eq("NOTYET"),
|
||||||
mapSheetMngHstEntity.hstUid.mod(10L).eq(targetNum)
|
mapSheetMngHstEntity.hstUid.mod(10L).eq(targetNum))
|
||||||
).limit(pageSize)
|
.limit(pageSize)
|
||||||
.orderBy(mapSheetMngHstEntity.hstUid.asc())
|
.orderBy(mapSheetMngHstEntity.hstUid.asc())
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
return foundContent;
|
return foundContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -40,14 +39,11 @@ public class MapSheetMngFileJobApiController {
|
|||||||
})
|
})
|
||||||
@PutMapping("/mng-sync-job")
|
@PutMapping("/mng-sync-job")
|
||||||
public ApiResponseDto<String> mngSyncOnOff(
|
public ApiResponseDto<String> mngSyncOnOff(
|
||||||
@RequestParam boolean jobStart,
|
@RequestParam boolean jobStart, @RequestParam int pageSize) {
|
||||||
@RequestParam int pageSize) {
|
|
||||||
|
|
||||||
mapSheetMngFileJobController.setSchedulerEnabled(jobStart);
|
mapSheetMngFileJobController.setSchedulerEnabled(jobStart);
|
||||||
mapSheetMngFileJobController.setMngSyncPageSize(pageSize);
|
mapSheetMngFileJobController.setMngSyncPageSize(pageSize);
|
||||||
|
|
||||||
return ApiResponseDto.createOK("OK");
|
return ApiResponseDto.createOK("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,8 @@ public class MapSheetMngFileJobController {
|
|||||||
private final MapSheetMngFileJobService mapSheetMngFileJobService;
|
private final MapSheetMngFileJobService mapSheetMngFileJobService;
|
||||||
|
|
||||||
// 현재 상태 확인용 Getter
|
// 현재 상태 확인용 Getter
|
||||||
@Getter
|
@Getter private boolean isSchedulerEnabled = false;
|
||||||
private boolean isSchedulerEnabled = false;
|
@Getter private int mngSyncPageSize = 20;
|
||||||
@Getter
|
|
||||||
private int mngSyncPageSize = 20;
|
|
||||||
|
|
||||||
// 매일 새벽 3시에 실행 (초 분 시 일 월 요일)
|
// 매일 새벽 3시에 실행 (초 분 시 일 월 요일)
|
||||||
@Scheduled(fixedDelay = 5000)
|
@Scheduled(fixedDelay = 5000)
|
||||||
@@ -99,8 +97,6 @@ public class MapSheetMngFileJobController {
|
|||||||
mapSheetMngFileJobService.checkMapSheetFileProcess(9, mngSyncPageSize);
|
mapSheetMngFileJobService.checkMapSheetFileProcess(9, mngSyncPageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 3. 외부에서 플래그를 변경할 수 있는 Setter 메서드
|
// 3. 외부에서 플래그를 변경할 수 있는 Setter 메서드
|
||||||
public void setSchedulerEnabled(boolean enabled) {
|
public void setSchedulerEnabled(boolean enabled) {
|
||||||
this.isSchedulerEnabled = enabled;
|
this.isSchedulerEnabled = enabled;
|
||||||
@@ -111,6 +107,4 @@ public class MapSheetMngFileJobController {
|
|||||||
this.mngSyncPageSize = pageSize;
|
this.mngSyncPageSize = pageSize;
|
||||||
System.out.println("스케줄러 처리 개수 변경됨: " + pageSize);
|
System.out.println("스케줄러 처리 개수 변경됨: " + pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.kamco.cd.kamcoback.scheduler.dto;
|
package com.kamco.cd.kamcoback.scheduler.dto;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -10,7 +9,6 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
|
|
||||||
public class MapSheetMngDto {
|
public class MapSheetMngDto {
|
||||||
|
|
||||||
@@ -78,7 +76,6 @@ public class MapSheetMngDto {
|
|||||||
private String syncMngPath;
|
private String syncMngPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Schema(name = "MngFileAddReq", description = "영상관리파일 등록 요청")
|
@Schema(name = "MngFileAddReq", description = "영상관리파일 등록 요청")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -113,9 +110,6 @@ public class MapSheetMngDto {
|
|||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴")
|
@Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -125,5 +119,4 @@ public class MapSheetMngDto {
|
|||||||
private String flag;
|
private String flag;
|
||||||
private String message;
|
private String message;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,12 @@ package com.kamco.cd.kamcoback.scheduler.service;
|
|||||||
|
|
||||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.FileDto;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.FileDto.FilesDto;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.FileDto.SrchFilesDepthDto;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.FileDto.SrchFilesDto;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngDto;
|
|
||||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileJobCoreService;
|
|
||||||
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
|
||||||
|
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||||
import com.kamco.cd.kamcoback.common.utils.NameValidator;
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileJobCoreService;
|
||||||
import com.kamco.cd.kamcoback.config.FileConfig;
|
import com.kamco.cd.kamcoback.scheduler.dto.FileDto;
|
||||||
|
import com.kamco.cd.kamcoback.scheduler.dto.FileDto.SrchFilesDepthDto;
|
||||||
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
|
||||||
|
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -34,7 +27,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -73,26 +65,37 @@ public class MapSheetMngFileJobService {
|
|||||||
srchDto.setFileNm(item.getMapSheetNum());
|
srchDto.setFileNm(item.getMapSheetNum());
|
||||||
// srchDto.setFileNm("34602047");
|
// srchDto.setFileNm("34602047");
|
||||||
|
|
||||||
System.out.println("UID: " + hstUid + ", 상태: " + syncState + ", 관리경로: " + item.getSyncMngPath() + ", 파일명 " + item.getMapSheetNum() + " .tif,tfw");
|
System.out.println(
|
||||||
|
"UID: "
|
||||||
|
+ hstUid
|
||||||
|
+ ", 상태: "
|
||||||
|
+ syncState
|
||||||
|
+ ", 관리경로: "
|
||||||
|
+ item.getSyncMngPath()
|
||||||
|
+ ", 파일명 "
|
||||||
|
+ item.getMapSheetNum()
|
||||||
|
+ " .tif,tfw");
|
||||||
|
|
||||||
// 도엽번호로 파일 찾기
|
// 도엽번호로 파일 찾기
|
||||||
// basicList = this.getFilesDepthAll(srchDto);
|
// basicList = this.getFilesDepthAll(srchDto);
|
||||||
|
|
||||||
basicList = FIleChecker.getFilesFromAllDepth(srchDto.getDirPath(), srchDto.getFileNm(),
|
basicList =
|
||||||
srchDto.getExtension(), srchDto.getMaxDepth(), srchDto.getSortType(), 0, 100);
|
FIleChecker.getFilesFromAllDepth(
|
||||||
|
srchDto.getDirPath(),
|
||||||
|
srchDto.getFileNm(),
|
||||||
|
srchDto.getExtension(),
|
||||||
|
srchDto.getMaxDepth(),
|
||||||
|
srchDto.getSortType(),
|
||||||
|
0,
|
||||||
|
100);
|
||||||
|
|
||||||
int tfwCnt =
|
int tfwCnt =
|
||||||
(int)
|
(int)
|
||||||
basicList.stream()
|
basicList.stream().filter(dto -> dto.getExtension().toString().equals("tfw")).count();
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
|
||||||
.count();
|
|
||||||
|
|
||||||
int tifCnt =
|
int tifCnt =
|
||||||
(int)
|
(int)
|
||||||
basicList.stream()
|
basicList.stream().filter(dto -> dto.getExtension().toString().equals("tif")).count();
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
|
||||||
.count();
|
|
||||||
|
|
||||||
syncState = "";
|
syncState = "";
|
||||||
syncCheckState = "";
|
syncCheckState = "";
|
||||||
@@ -116,21 +119,37 @@ public class MapSheetMngFileJobService {
|
|||||||
|
|
||||||
fileState = "DONE";
|
fileState = "DONE";
|
||||||
if (item2.getExtension().equals("tfw")) {
|
if (item2.getExtension().equals("tfw")) {
|
||||||
if( tifCnt == 0){fileState = "NOTPAIR";syncState = fileState;}
|
if (tifCnt == 0) {
|
||||||
else if( tfwCnt > 1){fileState = "DUPLICATE";syncState = fileState;}
|
fileState = "NOTPAIR";
|
||||||
else if( item2.getFileSize() == 0 ){fileState = "SIZEERROR";syncState = fileState;}
|
syncState = fileState;
|
||||||
else if( ! FIleChecker.checkTfw(item2.getFullPath()) ){fileState = "TYPEERROR";syncState = fileState;}
|
} else if (tfwCnt > 1) {
|
||||||
|
fileState = "DUPLICATE";
|
||||||
|
syncState = fileState;
|
||||||
|
} else if (item2.getFileSize() == 0) {
|
||||||
|
fileState = "SIZEERROR";
|
||||||
|
syncState = fileState;
|
||||||
|
} else if (!FIleChecker.checkTfw(item2.getFullPath())) {
|
||||||
|
fileState = "TYPEERROR";
|
||||||
|
syncState = fileState;
|
||||||
|
}
|
||||||
|
} else if (item2.getExtension().equals("tif")) {
|
||||||
|
if (tfwCnt == 0) {
|
||||||
|
fileState = "NOTPAIR";
|
||||||
|
syncState = fileState;
|
||||||
|
} else if (tifCnt > 1) {
|
||||||
|
fileState = "DUPLICATE";
|
||||||
|
syncState = fileState;
|
||||||
|
} else if (item2.getFileSize() == 0) {
|
||||||
|
fileState = "SIZEERROR";
|
||||||
|
syncState = fileState;
|
||||||
|
} else if (!FIleChecker.cmmndGdalInfo(item2.getFullPath())) {
|
||||||
|
fileState = "TYPEERROR";
|
||||||
|
syncState = fileState;
|
||||||
}
|
}
|
||||||
else if(item2.getExtension().equals("tif") ){
|
|
||||||
if( tfwCnt == 0){fileState = "NOTPAIR";syncState = fileState;}
|
|
||||||
else if( tifCnt > 1){fileState = "DUPLICATE";syncState = fileState;}
|
|
||||||
else if( item2.getFileSize() == 0 ){fileState = "SIZEERROR";syncState = fileState;}
|
|
||||||
else if( ! FIleChecker.cmmndGdalInfo(item2.getFullPath()) ){fileState = "TYPEERROR";syncState = fileState;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addReq.setFileState(fileState);
|
addReq.setFileState(fileState);
|
||||||
MapSheetMngDto.DmlReturn DmlReturn = mngDataSave(addReq);
|
MapSheetMngDto.DmlReturn DmlReturn = mngDataSave(addReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 도엽별 파일 체크 완료로 변경
|
// 도엽별 파일 체크 완료로 변경
|
||||||
@@ -142,20 +161,16 @@ public class MapSheetMngFileJobService {
|
|||||||
// srchDto.
|
// srchDto.
|
||||||
|
|
||||||
// 2. 출력
|
// 2. 출력
|
||||||
//System.out.println("UID: " + hstUid + ", 상태: " + syncState + ", 관리경로: " + item.getSyncMngPath());
|
// System.out.println("UID: " + hstUid + ", 상태: " + syncState + ", 관리경로: " +
|
||||||
|
// item.getSyncMngPath());
|
||||||
|
|
||||||
// 3. (필요하다면) 다른 로직 수행
|
// 3. (필요하다면) 다른 로직 수행
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkIsNoFile(List<FileDto.Basic> basicList)
|
public int checkIsNoFile(List<FileDto.Basic> basicList) {
|
||||||
{
|
if (basicList == null || basicList.size() == 0) {
|
||||||
if( basicList == null || basicList.size() == 0 )
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +189,6 @@ public class MapSheetMngFileJobService {
|
|||||||
return mapSheetMngFileJobCoreService.mngFileSave(AddReq);
|
return mapSheetMngFileJobCoreService.mngFileSave(AddReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<FileDto.Basic> getFilesDepthAll(SrchFilesDepthDto srchDto) {
|
public List<FileDto.Basic> getFilesDepthAll(SrchFilesDepthDto srchDto) {
|
||||||
|
|
||||||
Path startPath = Paths.get(srchDto.getDirPath());
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
@@ -208,9 +222,7 @@ public class MapSheetMngFileJobService {
|
|||||||
|| extension.equals("*")
|
|| extension.equals("*")
|
||||||
|| targetExtensions.contains(extractExtension(p)))
|
|| targetExtensions.contains(extractExtension(p)))
|
||||||
.sorted(getFileComparator(sortType))
|
.sorted(getFileComparator(sortType))
|
||||||
.filter(
|
.filter(p -> p.getFileName().toString().contains(targetFileNm))
|
||||||
p -> p.getFileName().toString().contains(targetFileNm)
|
|
||||||
)
|
|
||||||
.skip(startPos)
|
.skip(startPos)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.map(
|
.map(
|
||||||
@@ -242,7 +254,6 @@ public class MapSheetMngFileJobService {
|
|||||||
return fileDtoList;
|
return fileDtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<String> createExtensionSet(String extensionString) {
|
public Set<String> createExtensionSet(String extensionString) {
|
||||||
if (extensionString == null || extensionString.isBlank()) {
|
if (extensionString == null || extensionString.isBlank()) {
|
||||||
return Set.of();
|
return Set.of();
|
||||||
@@ -295,5 +306,4 @@ public class MapSheetMngFileJobService {
|
|||||||
return nameComparator;
|
return nameComparator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user