status 체크 후 pnu cnt update 로 수정

This commit is contained in:
2026-03-05 11:32:43 +09:00
parent 9b504396bc
commit a3b2fd0c73
6 changed files with 20 additions and 63 deletions

View File

@@ -15,8 +15,8 @@ public class GukYuinPnuCntUpdateJobCoreService {
}
@Transactional
public int updateGukYuinContListPnuUpdateCnt(String uid) {
return gukYuinPnuCntUpdateRepository.updateGukYuinContListPnuUpdateCnt(uid);
public void updateGukYuinContListPnuUpdateCnt() {
gukYuinPnuCntUpdateRepository.updateGukYuinContListPnuUpdateCnt();
}
@Transactional

View File

@@ -2,7 +2,7 @@ package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
public interface GukYuinPnuCntUpdateJobRepositoryCustom {
int updateGukYuinContListPnuUpdateCnt(String uid);
void updateGukYuinContListPnuUpdateCnt();
void updateGukYuinApplyStatus(String uid, String status);
}

View File

@@ -20,30 +20,20 @@ public class GukYuinPnuCntUpdateJobRepositoryImpl
@PersistenceContext private EntityManager em;
@Override
public int updateGukYuinContListPnuUpdateCnt(String uid) {
public void updateGukYuinContListPnuUpdateCnt() {
String sql =
"""
WITH target_geo AS (
SELECT DISTINCT g.geo_uid
FROM tb_map_sheet_anal_data_inference_geom g
JOIN tb_map_sheet_anal_data_inference d ON d.data_uid = g.data_uid
JOIN tb_map_sheet_anal_inference i ON i.anal_uid = d.anal_uid
JOIN tb_map_sheet_learn l ON l.id = i.learn_id
WHERE l.uid = ?
),
pnu_cnt AS (
SELECT p.geo_uid, COUNT(*)::int AS cnt
FROM tb_pnu p
JOIN target_geo t ON t.geo_uid = p.geo_uid
GROUP BY p.geo_uid
)
UPDATE tb_map_sheet_anal_data_inference_geom geo
SET pnu = pnu_cnt.cnt
FROM pnu_cnt
WHERE geo.geo_uid = pnu_cnt.geo_uid
""";
update tb_map_sheet_anal_data_inference_geom p
set pnu = c_count.actual_count
from (
select geo_uid, count(*) actual_count
from tb_pnu
group by geo_uid
) c_count
where p.geo_uid = c_count.geo_uid and p.pnu != c_count.actual_count;
""";
return jdbcTemplate.update(sql, uid);
jdbcTemplate.update(sql);
}
@Override

View File

@@ -6,7 +6,6 @@ import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiLabelJobService;
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiPnuCntUpdateJobService;
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiPnuJobService;
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStatusJobService;
import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStbltJobService;
@@ -50,7 +49,6 @@ public class SchedulerApiController {
private final MapSheetMngFileJobController mapSheetMngFileJobController;
private final InferenceResultShpService inferenceResultShpService;
private final GukYuinApiService gukYuinApiService;
private final GukYuinApiPnuCntUpdateJobService gukYuinApiPnuCntUpdateJobService;
@Operation(summary = "국유인 탐지객체 조회 PNU 업데이트 스케줄링", description = "국유인 탐지객체 조회 PNU 업데이트 스케줄링")
@GetMapping("/gukyuin/pnu")
@@ -62,7 +60,7 @@ public class SchedulerApiController {
@Operation(summary = "국유인 등록 상태 체크 스케줄링", description = "국유인 등록 상태 체크 스케줄링")
@GetMapping("/gukyuin/status")
public ApiResponseDto<Void> findGukYuinMastCompleteYn() {
gukYuinApiStatusJobService.findGukYuinMastCompleteYn();
gukYuinApiStatusJobService.findGukYuinPnuCntUpdate();
return ApiResponseDto.ok(null);
}
@@ -186,11 +184,4 @@ public class SchedulerApiController {
@PathVariable String uid, @PathVariable int updateCnt) {
return ApiResponseDto.ok(gukYuinApiService.updateStbltRandomData(uid, updateCnt));
}
@Operation(summary = "pnu 연동 이후 pnu cnt, 상태 업데이트", description = "pnu 연동 이후 pnu cnt, 상태 업데이트")
@GetMapping("/gukyuin/pnu-cnt/{uid}")
public ApiResponseDto<Void> updateGukYuinContListPnuUpdateCnt(@PathVariable String uid) {
gukYuinApiPnuCntUpdateJobService.updateGukYuinContListPnuUpdateCnt(uid);
return ApiResponseDto.ok(null);
}
}

View File

@@ -1,24 +0,0 @@
package com.kamco.cd.kamcoback.scheduler.service;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
import com.kamco.cd.kamcoback.postgres.core.GukYuinPnuCntUpdateJobCoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
@Log4j2
@Service
@RequiredArgsConstructor
public class GukYuinApiPnuCntUpdateJobService {
private final GukYuinPnuCntUpdateJobCoreService gukYuinPnuCntUpdateJobCoreService;
public void updateGukYuinContListPnuUpdateCnt(String uid) {
int execCnt = gukYuinPnuCntUpdateJobCoreService.updateGukYuinContListPnuUpdateCnt(uid);
if (execCnt > 0) {
gukYuinPnuCntUpdateJobCoreService.updateGukYuinApplyStatus(
uid, GukYuinStatus.PNU_COMPLETED.getId());
}
}
}

View File

@@ -33,8 +33,8 @@ public class GukYuinApiStatusJobService {
return "local".equalsIgnoreCase(profile);
}
/** 국유인 연동 후, 100% 되었는지 확인하는 스케줄링 매 10분마다 호출 */
public void findGukYuinMastCompleteYn() {
/** 매일 00시에 pnu cnt 업데이트 */
public void findGukYuinPnuCntUpdate() {
List<LearnKeyDto> list =
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
@@ -57,9 +57,9 @@ public class GukYuinApiStatusJobService {
Integer progress =
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
if (progress != null && progress == 100) {
gukYuinPnuCntUpdateJobCoreService.updateGukYuinContListPnuUpdateCnt(dto.getUid());
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
dto.getId(), GukYuinStatus.PNU_COMPLETED);
gukYuinPnuCntUpdateJobCoreService.updateGukYuinContListPnuUpdateCnt();
gukYuinPnuCntUpdateJobCoreService.updateGukYuinApplyStatus(
dto.getUid(), GukYuinStatus.PNU_COMPLETED.getId());
}
} catch (Exception e) {
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);