Merge pull request 'feat/infer_dev_260107' (#273) from feat/infer_dev_260107 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/273
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.mapsheet.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kamco.cd.kamcoback.common.enums.MngStateType;
|
||||
import com.kamco.cd.kamcoback.common.enums.SyncStateType;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
@@ -53,6 +54,8 @@ public class MapSheetMngDto {
|
||||
|
||||
@Schema(description = "선택폴더경로", example = "D:\\app\\original-images\\2022")
|
||||
private String mngPath;
|
||||
|
||||
@JsonIgnore private Long createdUid;
|
||||
}
|
||||
|
||||
@Schema(name = "DeleteFileReq", description = "파일 삭제 요청")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.mapsheet.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FoldersDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class MapSheetMngService {
|
||||
|
||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||
private final UserUtil userUtil = new UserUtil();
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
@@ -87,6 +89,9 @@ public class MapSheetMngService {
|
||||
|
||||
@Transactional
|
||||
public DmlReturn mngDataSave(AddReq addReq) {
|
||||
|
||||
addReq.setCreatedUid(userUtil.getId());
|
||||
|
||||
int execCnt = mapSheetMngCoreService.mngDataSave(addReq);
|
||||
return new MapSheetMngDto.DmlReturn("success", addReq.getMngYyyy() + "년, " + execCnt + "건 생성");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.MngStateType;
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
@@ -20,6 +21,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -136,6 +138,15 @@ public class MapSheetMngCoreService {
|
||||
MapSheetMngEntity entity = new MapSheetMngEntity();
|
||||
entity.setMngYyyy(addReq.getMngYyyy());
|
||||
entity.setMngPath(addReq.getMngPath());
|
||||
entity.setMngState(MngStateType.NOTYET.name());
|
||||
entity.setSyncState(MngStateType.NOTYET.name());
|
||||
entity.setSyncCheckState(MngStateType.NOTYET.name());
|
||||
entity.setMngStateDttm(ZonedDateTime.now());
|
||||
entity.setCreatedDttm(ZonedDateTime.now());
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
entity.setSyncStateDttm(ZonedDateTime.now());
|
||||
entity.setCreatedUid(addReq.getCreatedUid());
|
||||
entity.setUpdatedUid(addReq.getCreatedUid());
|
||||
|
||||
mapSheetMngRepository.deleteByMngYyyyMngAll(addReq.getMngYyyy());
|
||||
|
||||
|
||||
@@ -51,4 +51,16 @@ public class MapSheetMngFileJobCoreService {
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", saved.getFileUid().toString());
|
||||
}
|
||||
|
||||
public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) {
|
||||
return mapSheetMngFileJobRepository.findByMngYyyyTargetMapSheetNotYetCount(mngYyyy);
|
||||
}
|
||||
|
||||
public void mngDataState(int mngYyyy, String mngState) {
|
||||
mapSheetMngFileJobRepository.mngDataState(mngYyyy, mngState);
|
||||
}
|
||||
|
||||
public Integer findNotYetMapSheetMng() {
|
||||
return mapSheetMngFileJobRepository.findNotYetMapSheetMng();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,10 @@ public interface MapSheetMngFileJobRepositoryCustom {
|
||||
void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq);
|
||||
|
||||
List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize);
|
||||
|
||||
Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy);
|
||||
|
||||
public void mngDataState(int mngYyyy, String mngState);
|
||||
|
||||
public Integer findNotYetMapSheetMng();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,23 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findNotYetMapSheetMng() {
|
||||
Integer countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetMngEntity.mngYyyy)
|
||||
.from(mapSheetMngEntity)
|
||||
.where(
|
||||
mapSheetMngEntity
|
||||
.mngState
|
||||
.eq("NOTYET")
|
||||
.or(mapSheetMngEntity.mngState.eq("PROCESSING")))
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
return countQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MapSheetMngDto.MngDto> findMapSheetMngList(MapSheetMngDto.MngSearchReq searchReq) {
|
||||
|
||||
@@ -106,6 +123,33 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) {
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetMngHstEntity.mngYyyy.count())
|
||||
.from(mapSheetMngHstEntity)
|
||||
.where(
|
||||
mapSheetMngHstEntity
|
||||
.mngYyyy
|
||||
.eq(mngYyyy)
|
||||
.and(mapSheetMngHstEntity.syncState.eq("NOTYET")))
|
||||
.fetchOne();
|
||||
|
||||
return countQuery;
|
||||
}
|
||||
|
||||
public void mngDataState(int mngYyyy, String mngState) {
|
||||
long updateCount =
|
||||
queryFactory
|
||||
.update(mapSheetMngEntity)
|
||||
.set(mapSheetMngEntity.mngState, mngState)
|
||||
.set(mapSheetMngEntity.syncState, mngState)
|
||||
.set(mapSheetMngEntity.syncCheckState, mngState)
|
||||
.where(mapSheetMngEntity.mngYyyy.eq(mngYyyy))
|
||||
.execute();
|
||||
}
|
||||
|
||||
public void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq) {
|
||||
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
@@ -118,7 +162,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
.set(mapSheetMngHstEntity.dataStateDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncState, updateReq.getSyncState())
|
||||
.set(mapSheetMngHstEntity.syncEndDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncCheckState, "DONE")
|
||||
.set(mapSheetMngHstEntity.syncCheckState, "NOTYET")
|
||||
.set(mapSheetMngHstEntity.syncCheckStrtDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncCheckEndDttm, now)
|
||||
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
||||
@@ -132,7 +176,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
.set(mapSheetMngHstEntity.syncState, updateReq.getSyncState())
|
||||
.set(mapSheetMngHstEntity.syncStrtDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncEndDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncCheckState, "PROCESSING")
|
||||
.set(mapSheetMngHstEntity.syncCheckState, "NOTYET")
|
||||
.set(mapSheetMngHstEntity.syncCheckStrtDttm, now)
|
||||
.set(mapSheetMngHstEntity.syncCheckEndDttm, now)
|
||||
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
|
||||
|
||||
@@ -14,93 +14,119 @@ public class MapSheetMngFileJobController {
|
||||
|
||||
// 현재 상태 확인용 Getter
|
||||
@Getter private boolean isSchedulerEnabled = false;
|
||||
@Getter private boolean isFileSyncSchedulerEnabled = false;
|
||||
@Getter private int mngSyncPageSize = 20;
|
||||
|
||||
// 매일 새벽 3시에 실행 (초 분 시 일 월 요일)
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void mngFileSyncJob00() {
|
||||
// 파일싱크 진행여부 확인하기
|
||||
@Scheduled(fixedDelay = 1000 * 10)
|
||||
public void checkMngFileSync() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob00 === " + System.currentTimeMillis());
|
||||
Integer mng = 0;
|
||||
// isFileSyncSchedulerEnabled = false;
|
||||
if (mapSheetMngFileJobService.checkMngFileSync() != null) {
|
||||
mng = mapSheetMngFileJobService.checkMngFileSync();
|
||||
this.isFileSyncSchedulerEnabled = true;
|
||||
System.out.println(
|
||||
"MngFileSyncJob ON --> mngYyyy : "
|
||||
+ mng
|
||||
+ ", currentTime : "
|
||||
+ System.currentTimeMillis());
|
||||
} else {
|
||||
this.isFileSyncSchedulerEnabled = false;
|
||||
System.out.println(
|
||||
"MngFileSyncJob OFF --> mngYyyy : "
|
||||
+ mng
|
||||
+ ", currentTime : "
|
||||
+ System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob00() {
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob 00 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(0, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob01() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob01 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 01 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(1, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob02() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob00 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 02 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(2, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob03() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob03 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 03 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(3, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob04() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob04 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 04 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(4, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob05() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob05 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 05 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(5, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob06() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob06 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 06 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(6, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob07() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob07 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 07 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(7, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob08() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob08 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 08 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(8, mngSyncPageSize);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
@Scheduled(fixedDelay = 1000 * 5)
|
||||
public void mngFileSyncJob09() {
|
||||
if (!isSchedulerEnabled) return;
|
||||
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
|
||||
|
||||
System.out.println("mngFileSyncJob09 === " + System.currentTimeMillis());
|
||||
System.out.println("mngFileSyncJob 09 Processing currentTime : " + System.currentTimeMillis());
|
||||
mapSheetMngFileJobService.checkMapSheetFileProcess(9, mngSyncPageSize);
|
||||
}
|
||||
|
||||
// 3. 외부에서 플래그를 변경할 수 있는 Setter 메서드
|
||||
public void setSchedulerEnabled(boolean enabled) {
|
||||
this.isSchedulerEnabled = enabled;
|
||||
System.out.println("스케줄러 상태 변경됨: " + (enabled ? "ON" : "OFF"));
|
||||
this.isFileSyncSchedulerEnabled = false;
|
||||
System.out.println("스케줄러 동작 상태 변경됨: " + (enabled ? "ON" : "OFF"));
|
||||
}
|
||||
|
||||
public void setMngSyncPageSize(int pageSize) {
|
||||
|
||||
@@ -45,6 +45,10 @@ public class MapSheetMngFileJobService {
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
public Integer checkMngFileSync() {
|
||||
return mapSheetMngFileJobCoreService.findNotYetMapSheetMng();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void checkMapSheetFileProcess(long targetNum, int mngSyncPageSize) {
|
||||
|
||||
@@ -55,10 +59,15 @@ public class MapSheetMngFileJobService {
|
||||
String syncCheckState = "";
|
||||
String fileState = "";
|
||||
String dataState = "";
|
||||
int mngYyyy = 0;
|
||||
|
||||
SrchFilesDepthDto srchDto = new SrchFilesDepthDto();
|
||||
List<FIleChecker.Basic> basicList = new ArrayList<>();
|
||||
|
||||
if (mapSheetFileNotYetList.size() >= 1) {
|
||||
mngYyyy = mapSheetFileNotYetList.get(0).getMngYyyy();
|
||||
}
|
||||
|
||||
for (MngHstDto item : mapSheetFileNotYetList) {
|
||||
|
||||
// 도엽별 파일 체크 진행중으로 변경
|
||||
@@ -113,9 +122,9 @@ public class MapSheetMngFileJobService {
|
||||
if (tfwCnt == 0 && tifCnt == 0) syncState = "NOFILE";
|
||||
|
||||
for (FIleChecker.Basic item2 : basicList) {
|
||||
System.out.println("path: " + item2.getParentPath());
|
||||
System.out.println("path: " + item2.getFileNm());
|
||||
System.out.println("path: " + item2.getFullPath());
|
||||
// System.out.println("path: " + item2.getParentPath());
|
||||
// System.out.println("path: " + item2.getFileNm());
|
||||
// System.out.println("path: " + item2.getFullPath());
|
||||
|
||||
MapSheetMngDto.MngFileAddReq addReq = new MapSheetMngDto.MngFileAddReq();
|
||||
addReq.setMngYyyy(item.getMngYyyy());
|
||||
@@ -136,7 +145,7 @@ public class MapSheetMngFileJobService {
|
||||
fileState = "DUPLICATE";
|
||||
syncState = fileState;
|
||||
} else if (item2.getFileSize() == 0) {
|
||||
fileState = "SIZEERROR";
|
||||
fileState = "TYPEERROR";
|
||||
syncState = fileState;
|
||||
} else if (!FIleChecker.checkTfw(item2.getFullPath())) {
|
||||
fileState = "TYPEERROR";
|
||||
@@ -150,7 +159,7 @@ public class MapSheetMngFileJobService {
|
||||
fileState = "DUPLICATE";
|
||||
syncState = fileState;
|
||||
} else if (item2.getFileSize() == 0) {
|
||||
fileState = "SIZEERROR";
|
||||
fileState = "TYPEERROR";
|
||||
syncState = fileState;
|
||||
} else if (!FIleChecker.cmmndGdalInfo(item2.getFullPath())) {
|
||||
fileState = "TYPEERROR";
|
||||
@@ -167,16 +176,9 @@ public class MapSheetMngFileJobService {
|
||||
if (syncState.isEmpty()) syncState = "DONE";
|
||||
item.setSyncState(syncState);
|
||||
mngHstDataSyncStateUpdate(item);
|
||||
|
||||
// srchDto.
|
||||
|
||||
// 2. 출력
|
||||
// System.out.println("UID: " + hstUid + ", 상태: " + syncState + ", 관리경로: " +
|
||||
// item.getSyncMngPath());
|
||||
|
||||
// 3. (필요하다면) 다른 로직 수행
|
||||
// ...
|
||||
}
|
||||
|
||||
Long notyetCnt = this.mngDataStateDoneUpdate(mngYyyy);
|
||||
}
|
||||
|
||||
public int checkIsNoFile(List<FileDto.Basic> basicList) {
|
||||
@@ -187,10 +189,29 @@ public class MapSheetMngFileJobService {
|
||||
return basicList.size();
|
||||
}
|
||||
|
||||
public Long mngDataStateDoneUpdate(int mngYyyy) {
|
||||
|
||||
Long notyetCnt = 0L;
|
||||
if (mngYyyy > 0) {
|
||||
notyetCnt = findByMngYyyyTargetMapSheetNotYetCount(mngYyyy);
|
||||
if (notyetCnt == 0) {
|
||||
mapSheetMngFileJobCoreService.mngDataState(mngYyyy, "DONE");
|
||||
} else {
|
||||
mapSheetMngFileJobCoreService.mngDataState(mngYyyy, "PROCESSING");
|
||||
}
|
||||
}
|
||||
|
||||
return notyetCnt;
|
||||
}
|
||||
|
||||
public List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize) {
|
||||
return mapSheetMngFileJobCoreService.findTargetMapSheetFileList(targetNum, pageSize);
|
||||
}
|
||||
|
||||
public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) {
|
||||
return mapSheetMngFileJobCoreService.findByMngYyyyTargetMapSheetNotYetCount(mngYyyy);
|
||||
}
|
||||
|
||||
public MapSheetMngDto.DmlReturn mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto UpdateReq) {
|
||||
return mapSheetMngFileJobCoreService.mngHstDataSyncStateUpdate(UpdateReq);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user