스케줄링 수동 호출, 영상관리 싱크 자동추론제외 수정
This commit is contained in:
@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.MapSheetInferenceJobService;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -17,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** SchedulerApiController로 다 옮김 */
|
||||
@Hidden
|
||||
@Tag(name = "스캐쥴러 API", description = "스캐쥴러 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.kamco.cd.kamcoback.scheduler;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiLabelJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiPnuJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStatusJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStbltJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.MemberInactiveJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.TrainingDataLabelJobService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.TrainingDataReviewJobService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "스케줄링 수동 호출 테스트", description = "스케줄링 수동 호출 테스트 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/schedule")
|
||||
public class SchedulerApiController {
|
||||
|
||||
private final GukYuinApiPnuJobService gukYuinApiPnuJobService;
|
||||
private final GukYuinApiStatusJobService gukYuinApiStatusJobService;
|
||||
private final GukYuinApiLabelJobService gukYuinApiLabelJobService;
|
||||
private final GukYuinApiStbltJobService gukYuinApiStbltJobService;
|
||||
private final TrainingDataLabelJobService trainingDataLabelJobService;
|
||||
private final TrainingDataReviewJobService trainingDataReviewJobService;
|
||||
private final MemberInactiveJobService memberInactiveJobService;
|
||||
private final MapSheetMngFileJobController mapSheetMngFileJobController;
|
||||
|
||||
@Operation(summary = "국유인 탐지객체 조회 PNU 업데이트 스케줄링", description = "국유인 탐지객체 조회 PNU 업데이트 스케줄링")
|
||||
@GetMapping("/gukyuin/pnu")
|
||||
public ApiResponseDto<Void> findGukYuinContListPnuUpdate() {
|
||||
gukYuinApiPnuJobService.findGukYuinContListPnuUpdate();
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "국유인 등록 상태 체크 스케줄링", description = "국유인 등록 상태 체크 스케줄링")
|
||||
@GetMapping("/gukyuin/status")
|
||||
public ApiResponseDto<Void> findGukYuinMastCompleteYn() {
|
||||
gukYuinApiStatusJobService.findGukYuinMastCompleteYn();
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "국유인 라벨 완료 전송 스케줄링", description = "국유인 라벨 완료 전송 스케줄링")
|
||||
@GetMapping("/gukyuin/label")
|
||||
public ApiResponseDto<Void> findLabelingCompleteSend(
|
||||
@RequestParam(required = false) LocalDate baseDate) {
|
||||
gukYuinApiLabelJobService.findLabelingCompleteSend(baseDate);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "국유인 실태조사 적합여부 업데이트 스케줄링", description = "국유인 실태조사 적합여부 업데이트 스케줄링")
|
||||
@GetMapping("/gukyuin/stblt")
|
||||
public ApiResponseDto<Void> findGukYuinEligibleForSurvey(
|
||||
@RequestParam(required = false) LocalDate baseDate) {
|
||||
gukYuinApiStbltJobService.findGukYuinEligibleForSurvey(baseDate);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "라벨완료 -> 검수할당 스케줄링",
|
||||
description = "스케줄링이 실패한 경우 수동 호출하는 API, 어제 라벨링 완료된 것을 해당 검수자들에게 할당함")
|
||||
@GetMapping("/label-to-review")
|
||||
public ApiResponseDto<Void> runTrainingReviewSchedule(
|
||||
@RequestParam(required = false) LocalDate baseDate) {
|
||||
trainingDataLabelJobService.assignReviewerYesterdayLabelComplete(baseDate);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "검수완료된 라벨링 geojson 생성 스케줄링", description = "검수완료된 라벨링 geojson 생성")
|
||||
@GetMapping("/review-to-geojson")
|
||||
public ApiResponseDto<Long> runExportGeojsonLabelingGeom(
|
||||
@RequestParam(required = false) LocalDate baseDate) {
|
||||
trainingDataReviewJobService.exportGeojsonLabelingGeom(baseDate);
|
||||
return ApiResponseDto.ok(0L);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "라벨러/검수자 최종로그인 28일 경과 이후 사용중지 스케줄링",
|
||||
description = "라벨러/검수자 최종로그인 28일 경과 이후 사용중지 처리")
|
||||
@GetMapping("/member-inactive-job")
|
||||
public ApiResponseDto<Void> memberInactiveJob() {
|
||||
memberInactiveJobService.memberActive28daysToInactive();
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "영상관리 파일 싱크 스캐쥴러 Start/Stop", description = "영상관리 파일 싱크 스캐쥴러 Start/Stop API")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/mng-sync-job")
|
||||
public ApiResponseDto<String> mngSyncOnOff(
|
||||
@RequestParam boolean jobStart, @RequestParam int pageSize) {
|
||||
|
||||
mapSheetMngFileJobController.setSchedulerEnabled(jobStart);
|
||||
mapSheetMngFileJobController.setMngSyncPageSize(pageSize);
|
||||
|
||||
return ApiResponseDto.createOK("OK");
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class MapSheetMngDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MngDto {
|
||||
|
||||
private int rowNum;
|
||||
private int mngYyyy;
|
||||
private String mngState;
|
||||
@@ -61,6 +62,7 @@ public class MapSheetMngDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MngHstDto {
|
||||
|
||||
private long hstUid;
|
||||
private int mngYyyy;
|
||||
private String mapSheetNum;
|
||||
@@ -86,6 +88,7 @@ public class MapSheetMngDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MngFileAddReq {
|
||||
|
||||
private int mngYyyy;
|
||||
private String mapSheetNum;
|
||||
private String refMapSheetNum;
|
||||
@@ -103,6 +106,7 @@ public class MapSheetMngDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MngFilesDto {
|
||||
|
||||
private long fileUid;
|
||||
private int mngYyyy;
|
||||
private String mapSheetNum;
|
||||
@@ -132,7 +136,19 @@ public class MapSheetMngDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class DmlReturn {
|
||||
|
||||
private String flag;
|
||||
private String message;
|
||||
}
|
||||
|
||||
@Schema(name = "MngYyyyDto", description = "년도 값")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class YearMinMax {
|
||||
|
||||
private Integer minYyyy;
|
||||
private Integer maxYyyy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.GukYuinLabelJobCoreService;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -31,14 +32,18 @@ public class GukYuinApiLabelJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
/** 어제 라벨링 검수 완료된 것 -> 국유인에 전송 */
|
||||
@Scheduled(cron = "0 0 2 * * *")
|
||||
public void findLabelingCompleteSend() {
|
||||
public void runTask() {
|
||||
findLabelingCompleteSend(null);
|
||||
}
|
||||
|
||||
/** 어제 라벨링 검수 완료된 것 -> 국유인에 전송 */
|
||||
public void findLabelingCompleteSend(LocalDate baseDate) {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<GeomUidDto> list = gukYuinLabelJobCoreService.findYesterdayLabelingCompleteList();
|
||||
List<GeomUidDto> list = gukYuinLabelJobCoreService.findYesterdayLabelingCompleteList(baseDate);
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,13 @@ public class GukYuinApiStbltJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
/** 국유인 연동 후, 실태조사 적합여부 확인하여 update */
|
||||
@Scheduled(cron = "0 0 3 * * *")
|
||||
public void findGukYuinEligibleForSurvey() {
|
||||
public void runTask() {
|
||||
findGukYuinEligibleForSurvey(null);
|
||||
}
|
||||
|
||||
/** 국유인 연동 후, 실태조사 적합여부 확인하여 update */
|
||||
public void findGukYuinEligibleForSurvey(LocalDate baseDate) {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
@@ -55,11 +59,16 @@ public class GukYuinApiStbltJobService {
|
||||
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
String yesterday =
|
||||
String targetDate =
|
||||
LocalDate.now(ZoneId.of("Asia/Seoul"))
|
||||
.minusDays(1)
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
RlbDtctDto result = gukYuinApiService.findRlbDtctList(dto.getUid(), yesterday, "Y");
|
||||
|
||||
if (baseDate != null) { // 파라미터가 있으면
|
||||
targetDate = baseDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
}
|
||||
|
||||
RlbDtctDto result = gukYuinApiService.findRlbDtctList(dto.getUid(), targetDate, "Y");
|
||||
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.kamco.cd.kamcoback.scheduler.dto.FileDto.SrchFilesDepthDto;
|
||||
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 com.kamco.cd.kamcoback.scheduler.dto.MapSheetMngDto.YearMinMax;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -212,28 +213,26 @@ public class MapSheetMngFileJobService {
|
||||
return notyetCnt;
|
||||
}
|
||||
|
||||
public Long mapSheetAutoExceptionUpdate(int mngYyyy, String mapSheetNum) {
|
||||
public Long mapSheetAutoExceptionUpdate(Integer mngYyyy, String mapSheetNum) {
|
||||
|
||||
// 2025년 이전 파일싱크는 무조건 이전3년이 존재하지 않으므로 자동추론제외를 진행하지 않는다.(전년도 파일이 무조건 존재하는 것으로 리턴)
|
||||
// if (syncAutoExceptionStartYear > mngYyyy) {
|
||||
// return 1L;
|
||||
// }
|
||||
// tb_year 에 있는 년도 min,max 가져오기
|
||||
YearMinMax yearInfo = mapSheetMngFileJobCoreService.findYearMinMaxInfo();
|
||||
int strtYyyy = yearInfo.getMinYyyy();
|
||||
int endYyyy = yearInfo.getMaxYyyy();
|
||||
|
||||
// int strtYyyy = mngYyyy - syncAutoExceptionBeforeYearCnt + 1;
|
||||
int strtYyyy = 2020;
|
||||
int endYyyy = mngYyyy;
|
||||
|
||||
// 본년도+이전년도가 3개년인 도엽 확인 -> 2020년도부터 현재까지
|
||||
// tb_map_sheet_mng_hst 에 도엽 정보가 하나라도 DONE 인 게 있는지 count 가져오기
|
||||
Long beforeCnt =
|
||||
mapSheetMngFileJobCoreService.findByHstMapSheetBeforeYyyyListCount(
|
||||
strtYyyy, endYyyy, mapSheetNum);
|
||||
mngYyyy, strtYyyy, endYyyy, mapSheetNum);
|
||||
|
||||
if (beforeCnt == 0) {
|
||||
System.out.println("mapSheetAutoExceptionUpdate inference == 자동추론제외");
|
||||
System.out.println("beforeCnt: 0, mapSheetAutoExceptionUpdate inference == 자동추론제외");
|
||||
mapSheetMngFileJobCoreService.updateException5kMapSheet(
|
||||
mapSheetNum, CommonUseStatus.AUTO_EXCEPT);
|
||||
} else {
|
||||
// 하나라도 있으면 USE
|
||||
System.out.println(
|
||||
"beforeCnt: " + beforeCnt + ", mapSheetAutoExceptionUpdate inference == 자동추론제외 해제");
|
||||
mapSheetMngFileJobCoreService.updateException5kMapSheet(mapSheetNum, CommonUseStatus.USE);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.postgres.core.TrainingDataLabelJobCoreService;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.TrainingDataReviewJobDto.InspectorPendingDto;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.TrainingDataReviewJobDto.Tasks;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -13,6 +14,7 @@ import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -22,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
public class TrainingDataLabelJobService {
|
||||
|
||||
private final TrainingDataLabelJobCoreService trainingDataLabelJobCoreService;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
@@ -30,16 +33,24 @@ public class TrainingDataLabelJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public void assignReviewerYesterdayLabelComplete() {
|
||||
public void runTask() {
|
||||
// 프록시를 통해 호출해야 @Transactional이 적용됨
|
||||
applicationContext
|
||||
.getBean(TrainingDataLabelJobService.class)
|
||||
.assignReviewerYesterdayLabelComplete(null);
|
||||
}
|
||||
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
@Transactional
|
||||
public void assignReviewerYesterdayLabelComplete(LocalDate baseDate) {
|
||||
|
||||
// if (isLocalProfile()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
try {
|
||||
List<Tasks> tasks = trainingDataLabelJobCoreService.findCompletedYesterdayUnassigned();
|
||||
List<Tasks> tasks =
|
||||
trainingDataLabelJobCoreService.findCompletedYesterdayUnassigned(baseDate);
|
||||
|
||||
if (tasks.isEmpty()) {
|
||||
return;
|
||||
@@ -88,6 +99,7 @@ public class TrainingDataLabelJobService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("배치 처리 중 예외", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -40,11 +41,15 @@ public class TrainingDataReviewJobService {
|
||||
|
||||
@Transactional
|
||||
@Scheduled(cron = "0 0 2 * * *")
|
||||
public void exportGeojsonLabelingGeom() {
|
||||
public void runTask() {
|
||||
exportGeojsonLabelingGeom(null);
|
||||
}
|
||||
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
public void exportGeojsonLabelingGeom(LocalDate baseDate) {
|
||||
|
||||
// if (isLocalProfile()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 1) 경로/파일명 결정
|
||||
String targetDir =
|
||||
@@ -62,7 +67,8 @@ public class TrainingDataReviewJobService {
|
||||
|
||||
// 3) 회차 + 어제까지 검수 완료된 총 데이터의 도엽별 목록 가져오기
|
||||
List<AnalMapSheetList> analMapList =
|
||||
trainingDataReviewJobCoreService.findCompletedAnalMapSheetList(info.getAnalUid());
|
||||
trainingDataReviewJobCoreService.findCompletedAnalMapSheetList(
|
||||
info.getAnalUid(), baseDate);
|
||||
|
||||
if (analMapList.isEmpty()) {
|
||||
continue;
|
||||
@@ -72,7 +78,7 @@ public class TrainingDataReviewJobService {
|
||||
// 4) 도엽별 geom 데이터 가지고 와서 geojson 만들기
|
||||
List<CompleteLabelData> completeList =
|
||||
trainingDataReviewJobCoreService.findCompletedYesterdayLabelingList(
|
||||
info.getAnalUid(), mapSheet.getMapSheetNum());
|
||||
info.getAnalUid(), mapSheet.getMapSheetNum(), baseDate);
|
||||
|
||||
if (!completeList.isEmpty()) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user