추론자동제외

This commit is contained in:
Moon
2026-01-22 21:06:20 +09:00
parent 83333250b4
commit 860ebe9295
7 changed files with 128 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
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;
@@ -63,4 +64,13 @@ public class MapSheetMngFileJobCoreService {
public Integer findNotYetMapSheetMng() {
return mapSheetMngFileJobRepository.findNotYetMapSheetMng();
}
public Long findByHstMapSheetBeforeYyyyListCount(int strtYyyy, int endYyyy, String mapSheetNum){
return mapSheetMngFileJobRepository.findByHstMapSheetBeforeYyyyListCount(strtYyyy, endYyyy, mapSheetNum);
}
public void updateException5kMapSheet(String mapSheetNum){
mapSheetMngFileJobRepository.updateException5kMapSheet(mapSheetNum);
}
}

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.scheduler;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
import java.util.List;
@@ -18,4 +19,8 @@ public interface MapSheetMngFileJobRepositoryCustom {
public void mngDataState(int mngYyyy, String mngState);
public Integer findNotYetMapSheetMng();
public Long findByHstMapSheetBeforeYyyyListCount(int strtYyyy, int endYyyy, String mapSheetNum);
public void updateException5kMapSheet(String mapSheetNum);
}

View File

@@ -1,8 +1,11 @@
package com.kamco.cd.kamcoback.postgres.repository.scheduler;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheetMngEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
@@ -15,6 +18,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@@ -168,6 +172,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
.set(mapSheetMngHstEntity.mapSheetPath, updateReq.getMapSheetPath())
.set(mapSheetMngHstEntity.syncTfwFileName, updateReq.getSyncTfwFileName())
.set(mapSheetMngHstEntity.syncTifFileName, updateReq.getSyncTifFileName())
.set(mapSheetMngHstEntity.useInference, updateReq.getUseInference())
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
.execute();
} else {
@@ -185,6 +190,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
.set(mapSheetMngHstEntity.mapSheetPath, updateReq.getMapSheetPath())
.set(mapSheetMngHstEntity.syncTfwFileName, updateReq.getSyncTfwFileName())
.set(mapSheetMngHstEntity.syncTifFileName, updateReq.getSyncTifFileName())
.set(mapSheetMngHstEntity.useInference, updateReq.getUseInference())
.where(mapSheetMngHstEntity.hstUid.eq(updateReq.getHstUid()))
.execute();
}
@@ -213,6 +219,7 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
mapSheetMngHstEntity.mapSheetPath,
mapSheetMngHstEntity.syncCheckTfwFileName,
mapSheetMngHstEntity.syncCheckTifFileName,
mapSheetMngHstEntity.useInference,
mapSheetMngEntity.mngPath))
.from(mapSheetMngHstEntity)
.join(mapSheetMngEntity)
@@ -226,4 +233,33 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport
return foundContent;
}
@Override
public Long findByHstMapSheetBeforeYyyyListCount(int strtYyyy, int endYyyy, String mapSheetNum) {
Long countQuery =
queryFactory
.select(mapSheetMngHstEntity.mngYyyy.count())
.from(mapSheetMngHstEntity)
.where(mapSheetMngHstEntity.mngYyyy.goe(strtYyyy)
.and(mapSheetMngHstEntity.mngYyyy.loe(endYyyy))
.and(mapSheetMngHstEntity.mapSheetNum.eq(mapSheetNum))
.and(mapSheetMngHstEntity.useInference.eq("USE"))
.and(mapSheetMngHstEntity.syncState.eq("DONE")
.or(mapSheetMngHstEntity.syncCheckState.eq("DONE")))
)
.fetchOne();
return countQuery;
}
@Override
public void updateException5kMapSheet(String mapSheetNum){
long updateCount =
queryFactory
.update(mapInkx5kEntity)
.set(mapInkx5kEntity.useInference, CommonUseStatus.EXCEPT)
.where(mapInkx5kEntity.mapidcdNo.eq(mapSheetNum))
.execute();
}
}

View File

@@ -42,7 +42,7 @@ public class MapSheetMngFileJobController {
}
}
@Scheduled(fixedDelay = 1000 * 5)
@Scheduled(fixedDelay = 1000 * 10)
public void mngFileSyncJob00() {
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
@@ -50,6 +50,7 @@ public class MapSheetMngFileJobController {
mapSheetMngFileJobService.checkMapSheetFileProcess(0, mngSyncPageSize);
}
@Scheduled(fixedDelay = 1000 * 5)
public void mngFileSyncJob01() {
if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return;
@@ -122,6 +123,8 @@ public class MapSheetMngFileJobController {
mapSheetMngFileJobService.checkMapSheetFileProcess(9, mngSyncPageSize);
}
// 3. 외부에서 플래그를 변경할 수 있는 Setter 메서드
public void setSchedulerEnabled(boolean enabled) {
this.isSchedulerEnabled = enabled;

View File

@@ -76,7 +76,7 @@ public class MapSheetMngDto {
private String mapSheetPath;
private String syncTifFileName;
private String syncTfwFileName;
private String useInference;
private String syncMngPath;
}
@@ -114,6 +114,18 @@ public class MapSheetMngDto {
private Long fileSize;
}
@Schema(name = "MngListCompareDto", description = "영상파일 비교가능 이전년도정보")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class MngListCompareDto {
private String mngYyyy;
private String mapSheetNum;
private Integer beforeYear;
}
@Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴")
@Getter
@Setter

View File

@@ -3,10 +3,14 @@ package com.kamco.cd.kamcoback.scheduler.service;
import static java.lang.String.CASE_INSENSITIVE_ORDER;
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
import com.kamco.cd.kamcoback.common.utils.FIleChecker.Basic;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileJobCoreService;
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.DmlReturn;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngFileAddReq;
import com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.MngHstDto;
import java.io.File;
import java.io.IOException;
@@ -45,6 +49,14 @@ public class MapSheetMngFileJobService {
@Value("${file.sync-file-extention}")
private String syncFileExtention;
@Value("${file.sync-auto-exception-start-year}")
private int syncAutoExceptionStartYear;
@Value("${file.sync-auto-exception-before-year-cnt}")
private int syncAutoExceptionBeforeYearCnt;
public Integer checkMngFileSync() {
return mapSheetMngFileJobCoreService.findNotYetMapSheetMng();
}
@@ -62,7 +74,7 @@ public class MapSheetMngFileJobService {
int mngYyyy = 0;
SrchFilesDepthDto srchDto = new SrchFilesDepthDto();
List<FIleChecker.Basic> basicList = new ArrayList<>();
List<Basic> basicList = new ArrayList<>();
if (mapSheetFileNotYetList.size() >= 1) {
mngYyyy = mapSheetFileNotYetList.get(0).getMngYyyy();
@@ -70,8 +82,13 @@ public class MapSheetMngFileJobService {
for (MngHstDto item : mapSheetFileNotYetList) {
//5K도엽 자동추론제외
Long exceptCheckCnt = this.mapSheetAutoExceptionUpdate(item.getMngYyyy(), item.getMapSheetNum());
// 도엽별 파일 체크 진행중으로 변경
item.setDataState("PROCESSING");
item.setUseInference("USE");
if( exceptCheckCnt == 0 )item.setUseInference("EXCEPT");
mngHstDataSyncStateUpdate(item);
// 1. MngHstDto 객체의 필드 값에 접근
@@ -121,12 +138,12 @@ public class MapSheetMngFileJobService {
if (tfwCnt == 0 && tifCnt == 0) syncState = "NOFILE";
for (FIleChecker.Basic item2 : basicList) {
for (Basic item2 : basicList) {
// System.out.println("path: " + item2.getParentPath());
// System.out.println("path: " + item2.getFileNm());
// System.out.println("path: " + item2.getFullPath());
MapSheetMngDto.MngFileAddReq addReq = new MapSheetMngDto.MngFileAddReq();
MngFileAddReq addReq = new MngFileAddReq();
addReq.setMngYyyy(item.getMngYyyy());
addReq.setMapSheetNum(item.getMapSheetNum());
addReq.setRefMapSheetNum(item.getRefMapSheetNum());
@@ -175,14 +192,19 @@ public class MapSheetMngFileJobService {
}
addReq.setFileState(fileState);
MapSheetMngDto.DmlReturn DmlReturn = mngDataSave(addReq);
DmlReturn DmlReturn = mngDataSave(addReq);
}
// 도엽별 파일 체크 완료로 변경
item.setDataState("DONE");
if (syncState.isEmpty()) syncState = "DONE";
item.setSyncState(syncState);
mngHstDataSyncStateUpdate(item);
}
Long notyetCnt = this.mngDataStateDoneUpdate(mngYyyy);
@@ -211,6 +233,33 @@ public class MapSheetMngFileJobService {
return notyetCnt;
}
public Long mapSheetAutoExceptionUpdate(int mngYyyy, String mapSheetNum) {
//2025년 이전 파일싱크는 무조건 이전3년이 존재하지 않으므로 자동추론제외를 진행하지 않는다.(전년도 파일이 무조건 존재하는 것으로 리턴)
if( syncAutoExceptionStartYear > mngYyyy )return 1L;
//List<String> mapSheetNums = new ArrayList<>();
//mapSheetNums.add(mapSheetNum);
int strtYyyy = mngYyyy - syncAutoExceptionBeforeYearCnt;
int endYyyy = mngYyyy - 1;
//이전년도가 3개년인 도엽 확인
Long beforeCnt = mapSheetMngFileJobCoreService.findByHstMapSheetBeforeYyyyListCount(strtYyyy, endYyyy, mapSheetNum);
System.out.println("mapSheetAutoExceptionUpdate mapSheetNum == " +mapSheetNum);
System.out.println("mapSheetAutoExceptionUpdate strtYyyy == " +strtYyyy);
System.out.println("mapSheetAutoExceptionUpdate endYyyy == " +endYyyy);
System.out.println("mapSheetAutoExceptionUpdate beforeCnt == " +beforeCnt);
if( beforeCnt == 0 )
{
System.out.println("mapSheetAutoExceptionUpdate inference == 자동추론제외");
mapSheetMngFileJobCoreService.updateException5kMapSheet(mapSheetNum);
}
return beforeCnt;
}
public List<MngHstDto> findTargetMapSheetFileList(long targetNum, int pageSize) {
return mapSheetMngFileJobCoreService.findTargetMapSheetFileList(targetNum, pageSize);
}
@@ -219,11 +268,14 @@ public class MapSheetMngFileJobService {
return mapSheetMngFileJobCoreService.findByMngYyyyTargetMapSheetNotYetCount(mngYyyy);
}
public MapSheetMngDto.DmlReturn mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto UpdateReq) {
public DmlReturn mngHstDataSyncStateUpdate(MngHstDto UpdateReq) {
return mapSheetMngFileJobCoreService.mngHstDataSyncStateUpdate(UpdateReq);
}
public MapSheetMngDto.DmlReturn mngDataSave(MapSheetMngDto.MngFileAddReq AddReq) {
public DmlReturn mngDataSave(MngFileAddReq AddReq) {
return mapSheetMngFileJobCoreService.mngFileSave(AddReq);
}

View File

@@ -91,6 +91,8 @@ file:
sync-root-dir: /kamco-nfs/images/
sync-tmp-dir: ${file.sync-root-dir}/tmp
sync-file-extention: tfw,tif
sync-auto-exception-start-year: 2025
sync-auto-exception-before-year-cnt: 3
#dataset-dir: D:/kamco-nfs/dataset/
dataset-dir: /kamco-nfs/dataset/export/