feat/infer_dev_260211 #131
@@ -0,0 +1,26 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinPnuCntUpdateJobRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class GukYuinPnuCntUpdateJobCoreService {
|
||||
|
||||
private final GukYuinPnuCntUpdateJobRepository gukYuinPnuCntUpdateRepository;
|
||||
|
||||
public GukYuinPnuCntUpdateJobCoreService(
|
||||
GukYuinPnuCntUpdateJobRepository gukYuinPnuCntUpdateRepository) {
|
||||
this.gukYuinPnuCntUpdateRepository = gukYuinPnuCntUpdateRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int updateGukYuinContListPnuUpdateCnt(String uid) {
|
||||
return gukYuinPnuCntUpdateRepository.updateGukYuinContListPnuUpdateCnt(uid);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateGukYuinApplyStatus(String uid, String status) {
|
||||
gukYuinPnuCntUpdateRepository.updateGukYuinApplyStatus(uid, status);
|
||||
}
|
||||
}
|
||||
@@ -401,15 +401,15 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
// pnu가 들어온 경우
|
||||
boolean hasPnu = pnu != null && !pnu.isBlank();
|
||||
|
||||
// pnu 가 없을 때
|
||||
if (!hasPnu) {
|
||||
builder.and(
|
||||
mapSheetAnalDataInferenceGeomEntity
|
||||
.resultUid
|
||||
.eq(chnDtctId)
|
||||
.eq(cdObjectId)
|
||||
.or(mapSheetAnalDataInferenceGeomEntity.resultUid.in(cdObjectIds)));
|
||||
}
|
||||
|
||||
// List<ChangeDetectionDto.PolygonQueryData> list =
|
||||
JPAQuery<PolygonQueryData> query =
|
||||
queryFactory
|
||||
.select(
|
||||
@@ -436,11 +436,8 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
|
||||
.innerJoin(mapSheetLearnEntity)
|
||||
.on(mapSheetLearnEntity.id.eq(mapSheetAnalInferenceEntity.learnId));
|
||||
// .where(builder)
|
||||
// .orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc());
|
||||
// .fetch();
|
||||
|
||||
// 🔥 pnu 조건이면 tb_pnu join 추가
|
||||
// pnu 조건이면 tb_pnu join 추가
|
||||
if (hasPnu) {
|
||||
query
|
||||
.innerJoin(pnuEntity)
|
||||
@@ -499,15 +496,15 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
// pnu가 들어온 경우
|
||||
boolean hasPnu = pnu != null && !pnu.isBlank();
|
||||
|
||||
// pnu 가 없을 때
|
||||
if (!hasPnu) {
|
||||
builder.and(
|
||||
mapSheetAnalDataInferenceGeomEntity
|
||||
.resultUid
|
||||
.eq(chnDtctId)
|
||||
.eq(cdObjectId)
|
||||
.or(mapSheetAnalDataInferenceGeomEntity.resultUid.in(cdObjectIds)));
|
||||
}
|
||||
|
||||
// List<ChangeDetectionDto.PointQueryData> list =
|
||||
JPAQuery<PointQueryData> query =
|
||||
queryFactory
|
||||
.select(
|
||||
@@ -528,10 +525,8 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
|
||||
.innerJoin(mapSheetLearnEntity)
|
||||
.on(mapSheetLearnEntity.id.eq(mapSheetAnalInferenceEntity.learnId));
|
||||
// .where(builder)
|
||||
// .fetch();
|
||||
|
||||
// 🔥 pnu 조건이면 tb_pnu join 추가
|
||||
// pnu 조건이면 tb_pnu join 추가
|
||||
if (hasPnu) {
|
||||
query
|
||||
.innerJoin(pnuEntity)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface GukYuinPnuCntUpdateJobRepository
|
||||
extends JpaRepository<MapSheetLearnEntity, Long>, GukYuinPnuCntUpdateJobRepositoryCustom {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||
|
||||
public interface GukYuinPnuCntUpdateJobRepositoryCustom {
|
||||
|
||||
int updateGukYuinContListPnuUpdateCnt(String uid);
|
||||
|
||||
void updateGukYuinApplyStatus(String uid, String status);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class GukYuinPnuCntUpdateJobRepositoryImpl
|
||||
implements GukYuinPnuCntUpdateJobRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
@PersistenceContext private EntityManager em;
|
||||
|
||||
@Override
|
||||
public int updateGukYuinContListPnuUpdateCnt(String uid) {
|
||||
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
|
||||
""";
|
||||
|
||||
return jdbcTemplate.update(sql, uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGukYuinApplyStatus(String uid, String status) {
|
||||
queryFactory
|
||||
.update(mapSheetLearnEntity)
|
||||
.set(mapSheetLearnEntity.applyStatus, status)
|
||||
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||
.where(mapSheetLearnEntity.uid.eq(uid))
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -49,6 +50,7 @@ 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")
|
||||
@@ -184,4 +186,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user