국유인 API 진행중
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package com.kamco.cd.kamcoback.scheduler.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||
import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.GukYuinJobCoreService;
|
||||
import java.util.List;
|
||||
@@ -31,23 +35,24 @@ public class GukYuinApiJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/10 * * * *")
|
||||
@Scheduled(cron = "0 * * * * *") // 0 0/10 * * * *
|
||||
public void findGukYuinMastCompleteYn() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
// if (isLocalProfile()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
List<String> list = gukYuinJobCoreService.findGukyuinApplyIngUidList();
|
||||
List<LearnKeyDto> list =
|
||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(GukYuinStatus.IN_PROGRESS);
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String uid : list) {
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
ResultDto result = gukYuinApiService.listChnDtctId(uid);
|
||||
ResultDto result = gukYuinApiService.detail(dto.getChnDtctMstId());
|
||||
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
log.warn("[GUKYUIN] empty result uid={}", uid);
|
||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -56,10 +61,11 @@ public class GukYuinApiJobService {
|
||||
Integer progress =
|
||||
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
|
||||
if (progress != null && progress == 100) {
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(uid);
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.GUK_COMPLETED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[GUKYUIN] failed uid={}", uid, e);
|
||||
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,5 +75,62 @@ public class GukYuinApiJobService {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<LearnKeyDto> list =
|
||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(GukYuinStatus.GUK_COMPLETED);
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
processUid(dto.getChnDtctMstId(), dto.getUid());
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.PNU_COMPLETED);
|
||||
} catch (Exception e) {
|
||||
log.error("[GUKYUIN] failed uid={}", dto.getUid(), e);
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.PNU_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processUid(String chnDtctMstId, String uid) {
|
||||
ResultDto result = gukYuinApiService.detail(chnDtctMstId);
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
||||
String chnDtctCnt = basic.getChnDtctCnt();
|
||||
if (chnDtctCnt == null || chnDtctCnt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// page 계산
|
||||
int pageSize = 100;
|
||||
int totalCount = Integer.parseInt(chnDtctCnt);
|
||||
int totalPages = (totalCount + pageSize - 1) / pageSize;
|
||||
|
||||
for (int page = 0; page < totalPages; page++) {
|
||||
processPage(uid, page, pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void processPage(String uid, int page, int pageSize) {
|
||||
ResultContDto cont = gukYuinApiService.findChnContList(uid, page, pageSize);
|
||||
if (cont == null || cont.getResult().isEmpty()) {
|
||||
return; // 외부 API 이상 방어
|
||||
}
|
||||
|
||||
// pnuList 업데이트
|
||||
for (ChngDetectContDto.ContBasic contBasic : cont.getResult()) {
|
||||
if (contBasic.getPnuList() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
gukYuinJobCoreService.upsertMapSheetDataAnalGeomPnu(
|
||||
contBasic.getChnDtctObjtId(), contBasic.getPnuList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user