국유인 스케줄러 분리
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinLabelJobRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GukYuinLabelJobCoreService {
|
||||||
|
|
||||||
|
private final GukYuinLabelJobRepository gukYuinLabelRepository;
|
||||||
|
|
||||||
|
public GukYuinLabelJobCoreService(GukYuinLabelJobRepository gukYuinLabelRepository) {
|
||||||
|
this.gukYuinLabelRepository = gukYuinLabelRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
gukYuinLabelRepository.updateGukYuinApplyStateComplete(id, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus) {
|
||||||
|
return gukYuinLabelRepository.findGukyuinApplyStatusUidList(gukYuinStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
return gukYuinLabelRepository.upsertMapSheetDataAnalGeomPnu(chnDtctObjtId, pnuList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
return gukYuinLabelRepository.findYesterdayLabelingCompleteList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
gukYuinLabelRepository.updateAnalDataInferenceGeomSendDttm(geoUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinPnuJobRepository;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GukYuinPnuJobCoreService {
|
||||||
|
|
||||||
|
private final GukYuinPnuJobRepository gukYuinPnuRepository;
|
||||||
|
|
||||||
|
public GukYuinPnuJobCoreService(GukYuinPnuJobRepository gukYuinPnuRepository) {
|
||||||
|
this.gukYuinPnuRepository = gukYuinPnuRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
gukYuinPnuRepository.updateGukYuinApplyStateComplete(id, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus) {
|
||||||
|
return gukYuinPnuRepository.findGukyuinApplyStatusUidList(gukYuinStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
return gukYuinPnuRepository.upsertMapSheetDataAnalGeomPnu(chnDtctObjtId, pnuList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
return gukYuinPnuRepository.findYesterdayLabelingCompleteList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
gukYuinPnuRepository.updateAnalDataInferenceGeomSendDttm(geoUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGukYuinMastRegResult(Basic resultBody) {
|
||||||
|
gukYuinPnuRepository.updateGukYuinMastRegResult(resultBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGukYuinMastRegRemove(Basic resultBody) {
|
||||||
|
gukYuinPnuRepository.updateGukYuinMastRegRemove(resultBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt) {
|
||||||
|
gukYuinPnuRepository.updateInferenceGeomDataPnuCnt(chnDtctObjtId, pnuCnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId) {
|
||||||
|
return gukYuinPnuRepository.findMapSheetAnalDataInferenceGeomUid(chnDtctObjtId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertGeoUidPnuData(Long geoUid, String[] pnuList) {
|
||||||
|
gukYuinPnuRepository.insertGeoUidPnuData(geoUid, pnuList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||||
|
return gukYuinPnuRepository.findMapSheetLearnInfo(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||||
|
return gukYuinPnuRepository.findMapSheetLearnYearStage(compareYyyy, targetYyyy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||||
|
gukYuinPnuRepository.updateAnalInferenceApplyDttm(registRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||||
|
return gukYuinPnuRepository.findLabelingCompleteSendList(yesterday);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinStbltJobRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GukYuinStbltJobCoreService {
|
||||||
|
|
||||||
|
private final GukYuinStbltJobRepository gukYuinStbltRepository;
|
||||||
|
|
||||||
|
public GukYuinStbltJobCoreService(GukYuinStbltJobRepository gukYuinStbltRepository) {
|
||||||
|
this.gukYuinStbltRepository = gukYuinStbltRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
gukYuinStbltRepository.updateGukYuinApplyStateComplete(id, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus) {
|
||||||
|
return gukYuinStbltRepository.findGukyuinApplyStatusUidList(gukYuinStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
return gukYuinStbltRepository.upsertMapSheetDataAnalGeomPnu(chnDtctObjtId, pnuList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
return gukYuinStbltRepository.findYesterdayLabelingCompleteList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
gukYuinStbltRepository.updateAnalDataInferenceGeomSendDttm(geoUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 GukYuinLabelJobRepository
|
||||||
|
extends JpaRepository<MapSheetLearnEntity, Long>, GukYuinLabelJobRepositoryCustom {}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface GukYuinLabelJobRepositoryCustom {
|
||||||
|
|
||||||
|
void updateGukYuinMastRegResult(Basic resultBody);
|
||||||
|
|
||||||
|
void updateGukYuinMastRegRemove(Basic resultBody);
|
||||||
|
|
||||||
|
void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt);
|
||||||
|
|
||||||
|
Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId);
|
||||||
|
|
||||||
|
void insertGeoUidPnuData(Long geoUid, String[] pnuList);
|
||||||
|
|
||||||
|
void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status);
|
||||||
|
|
||||||
|
List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus);
|
||||||
|
|
||||||
|
long upsertMapSheetDataAnalGeomPnu(String uid, String[] pnuList);
|
||||||
|
|
||||||
|
LearnInfo findMapSheetLearnInfo(UUID uuid);
|
||||||
|
|
||||||
|
Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy);
|
||||||
|
|
||||||
|
void updateAnalInferenceApplyDttm(Basic registRes);
|
||||||
|
|
||||||
|
List<GeomUidDto> findYesterdayLabelingCompleteList();
|
||||||
|
|
||||||
|
void updateAnalDataInferenceGeomSendDttm(Long geoUid);
|
||||||
|
|
||||||
|
List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday);
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||||
|
import com.querydsl.core.types.Projections;
|
||||||
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
|
import com.querydsl.core.types.dsl.NumberExpression;
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.PersistenceContext;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinLabelJobRepositoryImpl implements GukYuinLabelJobRepositoryCustom {
|
||||||
|
|
||||||
|
private final JPAQueryFactory queryFactory;
|
||||||
|
@PersistenceContext private EntityManager em;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegResult(Basic resultBody) {
|
||||||
|
|
||||||
|
int excnPgrt = Integer.parseInt(resultBody.getExcnPgrt());
|
||||||
|
int stage = Integer.parseInt(resultBody.getChnDtctSno());
|
||||||
|
GukYuinStatus status = GukYuinStatus.IN_PROGRESS;
|
||||||
|
if (excnPgrt == 100) {
|
||||||
|
status = GukYuinStatus.GUK_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.stage, stage)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.set(mapSheetLearnEntity.chnDtctMstId, resultBody.getChnDtctMstId())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegRemove(Basic resultBody) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, GukYuinStatus.CANCELED.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, pnuCnt)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId) {
|
||||||
|
return queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertGeoUidPnuData(Long geoUid, String[] pnuList) {
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> status) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnKeyDto.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.chnDtctMstId))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.applyStatus.in(status))
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
long length = pnuList.length;
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, length)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
Long geoUid =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
long succCnt = 0;
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
long result =
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
if (result > 0) {
|
||||||
|
succCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnInfo.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uuid,
|
||||||
|
mapSheetLearnEntity.compareYyyy,
|
||||||
|
mapSheetLearnEntity.targetYyyy,
|
||||||
|
mapSheetLearnEntity.stage,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.applyStatus))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||||
|
NumberExpression<Integer> stageExpr =
|
||||||
|
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(stageExpr.max().coalesce(0))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(
|
||||||
|
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
||||||
|
mapSheetLearnEntity.targetYyyy.eq(targetYyyy),
|
||||||
|
mapSheetLearnEntity.applyStatus.isNotNull(),
|
||||||
|
mapSheetLearnEntity.applyStatus.ne(GukYuinStatus.PENDING.getId()))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||||
|
Long learnId =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetLearnEntity.id)
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(registRes.getChnDtctId()))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalInferenceEntity)
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinUsed, "Y")
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinApplyDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalInferenceEntity.learnId.eq(learnId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime todayStart = ZonedDateTime.now(zone).toLocalDate().atStartOfDay(zone);
|
||||||
|
ZonedDateTime yesterdayStart = todayStart.minusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(yesterdayStart)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(todayStart));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
GeomUidDto.class,
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.innerJoin(mapSheetAnalInferenceEntity)
|
||||||
|
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||||
|
.innerJoin(mapSheetLearnEntity)
|
||||||
|
.on(
|
||||||
|
mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id),
|
||||||
|
mapSheetLearnEntity.applyStatus.in(
|
||||||
|
GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_COMPLETED.getId()))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.labelSendDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.eq(geoUid))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||||
|
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime from = yesterday.atStartOfDay(zone);
|
||||||
|
ZonedDateTime to = from.plusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(from)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(to));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LabelSendDto.class,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid,
|
||||||
|
labelingAssignmentEntity.workerUid,
|
||||||
|
labelingAssignmentEntity.workStatDttm,
|
||||||
|
labelingAssignmentEntity.inspectorUid,
|
||||||
|
labelingAssignmentEntity.inspectStatDttm,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.labelSendDttm))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.id.eq(id))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 GukYuinPnuJobRepository
|
||||||
|
extends JpaRepository<MapSheetLearnEntity, Long>, GukYuinPnuJobRepositoryCustom {}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface GukYuinPnuJobRepositoryCustom {
|
||||||
|
|
||||||
|
void updateGukYuinMastRegResult(Basic resultBody);
|
||||||
|
|
||||||
|
void updateGukYuinMastRegRemove(Basic resultBody);
|
||||||
|
|
||||||
|
void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt);
|
||||||
|
|
||||||
|
Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId);
|
||||||
|
|
||||||
|
void insertGeoUidPnuData(Long geoUid, String[] pnuList);
|
||||||
|
|
||||||
|
void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status);
|
||||||
|
|
||||||
|
List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus);
|
||||||
|
|
||||||
|
long upsertMapSheetDataAnalGeomPnu(String uid, String[] pnuList);
|
||||||
|
|
||||||
|
LearnInfo findMapSheetLearnInfo(UUID uuid);
|
||||||
|
|
||||||
|
Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy);
|
||||||
|
|
||||||
|
void updateAnalInferenceApplyDttm(Basic registRes);
|
||||||
|
|
||||||
|
List<GeomUidDto> findYesterdayLabelingCompleteList();
|
||||||
|
|
||||||
|
void updateAnalDataInferenceGeomSendDttm(Long geoUid);
|
||||||
|
|
||||||
|
List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday);
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||||
|
import com.querydsl.core.types.Projections;
|
||||||
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
|
import com.querydsl.core.types.dsl.NumberExpression;
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.PersistenceContext;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinPnuJobRepositoryImpl implements GukYuinPnuJobRepositoryCustom {
|
||||||
|
|
||||||
|
private final JPAQueryFactory queryFactory;
|
||||||
|
@PersistenceContext private EntityManager em;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegResult(Basic resultBody) {
|
||||||
|
|
||||||
|
int excnPgrt = Integer.parseInt(resultBody.getExcnPgrt());
|
||||||
|
int stage = Integer.parseInt(resultBody.getChnDtctSno());
|
||||||
|
GukYuinStatus status = GukYuinStatus.IN_PROGRESS;
|
||||||
|
if (excnPgrt == 100) {
|
||||||
|
status = GukYuinStatus.GUK_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.stage, stage)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.set(mapSheetLearnEntity.chnDtctMstId, resultBody.getChnDtctMstId())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegRemove(Basic resultBody) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, GukYuinStatus.CANCELED.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, pnuCnt)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId) {
|
||||||
|
return queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertGeoUidPnuData(Long geoUid, String[] pnuList) {
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> status) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnKeyDto.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.chnDtctMstId))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.applyStatus.in(status))
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
long length = pnuList.length;
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, length)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
Long geoUid =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
long succCnt = 0;
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
long result =
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
if (result > 0) {
|
||||||
|
succCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnInfo.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uuid,
|
||||||
|
mapSheetLearnEntity.compareYyyy,
|
||||||
|
mapSheetLearnEntity.targetYyyy,
|
||||||
|
mapSheetLearnEntity.stage,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.applyStatus))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||||
|
NumberExpression<Integer> stageExpr =
|
||||||
|
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(stageExpr.max().coalesce(0))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(
|
||||||
|
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
||||||
|
mapSheetLearnEntity.targetYyyy.eq(targetYyyy),
|
||||||
|
mapSheetLearnEntity.applyStatus.isNotNull(),
|
||||||
|
mapSheetLearnEntity.applyStatus.ne(GukYuinStatus.PENDING.getId()))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||||
|
Long learnId =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetLearnEntity.id)
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(registRes.getChnDtctId()))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalInferenceEntity)
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinUsed, "Y")
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinApplyDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalInferenceEntity.learnId.eq(learnId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime todayStart = ZonedDateTime.now(zone).toLocalDate().atStartOfDay(zone);
|
||||||
|
ZonedDateTime yesterdayStart = todayStart.minusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(yesterdayStart)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(todayStart));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
GeomUidDto.class,
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.innerJoin(mapSheetAnalInferenceEntity)
|
||||||
|
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||||
|
.innerJoin(mapSheetLearnEntity)
|
||||||
|
.on(
|
||||||
|
mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id),
|
||||||
|
mapSheetLearnEntity.applyStatus.in(
|
||||||
|
GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_COMPLETED.getId()))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.labelSendDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.eq(geoUid))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||||
|
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime from = yesterday.atStartOfDay(zone);
|
||||||
|
ZonedDateTime to = from.plusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(from)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(to));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LabelSendDto.class,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid,
|
||||||
|
labelingAssignmentEntity.workerUid,
|
||||||
|
labelingAssignmentEntity.workStatDttm,
|
||||||
|
labelingAssignmentEntity.inspectorUid,
|
||||||
|
labelingAssignmentEntity.inspectStatDttm,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.labelSendDttm))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.id.eq(id))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 GukYuinStbltJobRepository
|
||||||
|
extends JpaRepository<MapSheetLearnEntity, Long>, GukYuinStbltJobRepositoryCustom {}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface GukYuinStbltJobRepositoryCustom {
|
||||||
|
|
||||||
|
void updateGukYuinMastRegResult(Basic resultBody);
|
||||||
|
|
||||||
|
void updateGukYuinMastRegRemove(Basic resultBody);
|
||||||
|
|
||||||
|
void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt);
|
||||||
|
|
||||||
|
Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId);
|
||||||
|
|
||||||
|
void insertGeoUidPnuData(Long geoUid, String[] pnuList);
|
||||||
|
|
||||||
|
void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status);
|
||||||
|
|
||||||
|
List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus);
|
||||||
|
|
||||||
|
long upsertMapSheetDataAnalGeomPnu(String uid, String[] pnuList);
|
||||||
|
|
||||||
|
LearnInfo findMapSheetLearnInfo(UUID uuid);
|
||||||
|
|
||||||
|
Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy);
|
||||||
|
|
||||||
|
void updateAnalInferenceApplyDttm(Basic registRes);
|
||||||
|
|
||||||
|
List<GeomUidDto> findYesterdayLabelingCompleteList();
|
||||||
|
|
||||||
|
void updateAnalDataInferenceGeomSendDttm(Long geoUid);
|
||||||
|
|
||||||
|
List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday);
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||||
|
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||||
|
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||||
|
import com.querydsl.core.types.Projections;
|
||||||
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
|
import com.querydsl.core.types.dsl.NumberExpression;
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.PersistenceContext;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinStbltJobRepositoryImpl implements GukYuinStbltJobRepositoryCustom {
|
||||||
|
|
||||||
|
private final JPAQueryFactory queryFactory;
|
||||||
|
@PersistenceContext private EntityManager em;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegResult(Basic resultBody) {
|
||||||
|
|
||||||
|
int excnPgrt = Integer.parseInt(resultBody.getExcnPgrt());
|
||||||
|
int stage = Integer.parseInt(resultBody.getChnDtctSno());
|
||||||
|
GukYuinStatus status = GukYuinStatus.IN_PROGRESS;
|
||||||
|
if (excnPgrt == 100) {
|
||||||
|
status = GukYuinStatus.GUK_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.stage, stage)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.set(mapSheetLearnEntity.chnDtctMstId, resultBody.getChnDtctMstId())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGukYuinMastRegRemove(Basic resultBody) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, GukYuinStatus.CANCELED.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInferenceGeomDataPnuCnt(String chnDtctObjtId, long pnuCnt) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, pnuCnt)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long findMapSheetAnalDataInferenceGeomUid(String chnDtctObjtId) {
|
||||||
|
return queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertGeoUidPnuData(Long geoUid, String[] pnuList) {
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> status) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnKeyDto.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.chnDtctMstId))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.applyStatus.in(status))
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||||
|
long length = pnuList.length;
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.pnu, length)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
Long geoUid =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
long succCnt = 0;
|
||||||
|
for (String pnu : pnuList) {
|
||||||
|
long result =
|
||||||
|
queryFactory
|
||||||
|
.insert(pnuEntity)
|
||||||
|
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||||
|
.values(geoUid, pnu, ZonedDateTime.now())
|
||||||
|
.execute();
|
||||||
|
if (result > 0) {
|
||||||
|
succCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnInfo.class,
|
||||||
|
mapSheetLearnEntity.id,
|
||||||
|
mapSheetLearnEntity.uuid,
|
||||||
|
mapSheetLearnEntity.compareYyyy,
|
||||||
|
mapSheetLearnEntity.targetYyyy,
|
||||||
|
mapSheetLearnEntity.stage,
|
||||||
|
mapSheetLearnEntity.uid,
|
||||||
|
mapSheetLearnEntity.applyStatus))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||||
|
NumberExpression<Integer> stageExpr =
|
||||||
|
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(stageExpr.max().coalesce(0))
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(
|
||||||
|
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
||||||
|
mapSheetLearnEntity.targetYyyy.eq(targetYyyy),
|
||||||
|
mapSheetLearnEntity.applyStatus.isNotNull(),
|
||||||
|
mapSheetLearnEntity.applyStatus.ne(GukYuinStatus.PENDING.getId()))
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||||
|
Long learnId =
|
||||||
|
queryFactory
|
||||||
|
.select(mapSheetLearnEntity.id)
|
||||||
|
.from(mapSheetLearnEntity)
|
||||||
|
.where(mapSheetLearnEntity.uid.eq(registRes.getChnDtctId()))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalInferenceEntity)
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinUsed, "Y")
|
||||||
|
.set(mapSheetAnalInferenceEntity.gukyuinApplyDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalInferenceEntity.learnId.eq(learnId))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime todayStart = ZonedDateTime.now(zone).toLocalDate().atStartOfDay(zone);
|
||||||
|
ZonedDateTime yesterdayStart = todayStart.minusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(yesterdayStart)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(todayStart));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
GeomUidDto.class,
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.innerJoin(mapSheetAnalInferenceEntity)
|
||||||
|
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||||
|
.innerJoin(mapSheetLearnEntity)
|
||||||
|
.on(
|
||||||
|
mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id),
|
||||||
|
mapSheetLearnEntity.applyStatus.in(
|
||||||
|
GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_COMPLETED.getId()))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.labelSendDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.eq(geoUid))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||||
|
|
||||||
|
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||||
|
ZonedDateTime from = yesterday.atStartOfDay(zone);
|
||||||
|
ZonedDateTime to = from.plusDays(1);
|
||||||
|
|
||||||
|
BooleanExpression isYesterday =
|
||||||
|
labelingAssignmentEntity
|
||||||
|
.inspectStatDttm
|
||||||
|
.goe(from)
|
||||||
|
.and(labelingAssignmentEntity.inspectStatDttm.lt(to));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LabelSendDto.class,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.resultUid,
|
||||||
|
labelingAssignmentEntity.workerUid,
|
||||||
|
labelingAssignmentEntity.workStatDttm,
|
||||||
|
labelingAssignmentEntity.inspectorUid,
|
||||||
|
labelingAssignmentEntity.inspectStatDttm,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.labelSendDttm))
|
||||||
|
.from(labelingAssignmentEntity)
|
||||||
|
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||||
|
.on(
|
||||||
|
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||||
|
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||||
|
queryFactory
|
||||||
|
.update(mapSheetLearnEntity)
|
||||||
|
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||||
|
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||||
|
.where(mapSheetLearnEntity.id.eq(id))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
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.GukYuinDto.GeomUidDto;
|
|
||||||
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;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Log4j2
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class GukYuinApiJobService {
|
|
||||||
|
|
||||||
private final GukYuinApiService gukYuinApiService;
|
|
||||||
private final GukYuinJobCoreService gukYuinJobCoreService;
|
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
|
||||||
private String profile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 실행중인 profile
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isLocalProfile() {
|
|
||||||
return "local".equalsIgnoreCase(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 국유인 연동 후, 100% 되었는지 확인하는 스케줄링 매 10분마다 호출 */
|
|
||||||
@Scheduled(cron = "0 0/10 * * * *")
|
|
||||||
public void findGukYuinMastCompleteYn() {
|
|
||||||
if (isLocalProfile()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<LearnKeyDto> list =
|
|
||||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
|
|
||||||
List.of(GukYuinStatus.IN_PROGRESS.getId()));
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LearnKeyDto dto : list) {
|
|
||||||
try {
|
|
||||||
ResultDto result = gukYuinApiService.detail(dto.getChnDtctMstId());
|
|
||||||
|
|
||||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
|
||||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
|
||||||
|
|
||||||
Integer progress =
|
|
||||||
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
|
|
||||||
if (progress != null && progress == 100) {
|
|
||||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
|
||||||
dto.getId(), GukYuinStatus.GUK_COMPLETED);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 국유인 등록 완료 후, 탐지객체 조회해서 PNU 업데이트 하는 스케줄링 하루 1번 새벽 1시에 실행 */
|
|
||||||
@Scheduled(cron = "0 0 1 * * *")
|
|
||||||
public void findGukYuinContListPnuUpdate() {
|
|
||||||
if (isLocalProfile()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<LearnKeyDto> list =
|
|
||||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
|
|
||||||
List.of(GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_FAILED.getId()));
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LearnKeyDto dto : list) {
|
|
||||||
try {
|
|
||||||
long succCnt = processUid(dto.getChnDtctMstId(), dto.getUid());
|
|
||||||
if (succCnt > 0) {
|
|
||||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
|
||||||
dto.getId(), GukYuinStatus.PNU_COMPLETED);
|
|
||||||
} else {
|
|
||||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
|
||||||
dto.getId(), GukYuinStatus.PNU_FAILED);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("[GUKYUIN] failed uid={}", dto.getUid(), e);
|
|
||||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
|
||||||
dto.getId(), GukYuinStatus.PNU_FAILED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long processUid(String chnDtctMstId, String uid) {
|
|
||||||
long succCnt = 0;
|
|
||||||
ResultDto result = gukYuinApiService.detail(chnDtctMstId);
|
|
||||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
|
||||||
return succCnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
|
||||||
String chnDtctCnt = basic.getChnDtctCnt();
|
|
||||||
if (chnDtctCnt == null || chnDtctCnt.isEmpty()) {
|
|
||||||
return succCnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
// page 계산
|
|
||||||
int pageSize = 100;
|
|
||||||
int totalCount = Integer.parseInt(chnDtctCnt);
|
|
||||||
int totalPages = (totalCount + pageSize - 1) / pageSize;
|
|
||||||
|
|
||||||
for (int page = 0; page < totalPages; page++) {
|
|
||||||
succCnt += processPage(uid, page, pageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return succCnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private long processPage(String uid, int page, int pageSize) {
|
|
||||||
long result = 0;
|
|
||||||
ResultContDto cont = gukYuinApiService.findChnContList(uid, page, pageSize);
|
|
||||||
if (cont == null || cont.getResult().isEmpty()) {
|
|
||||||
return result; // 외부 API 이상 방어
|
|
||||||
}
|
|
||||||
|
|
||||||
// pnuList 업데이트
|
|
||||||
|
|
||||||
for (ChngDetectContDto.ContBasic contBasic : cont.getResult()) {
|
|
||||||
if (contBasic.getPnuList() == null || contBasic.getChnDtctObjtId() == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
long upsertCnt =
|
|
||||||
gukYuinJobCoreService.upsertMapSheetDataAnalGeomPnu(
|
|
||||||
contBasic.getChnDtctObjtId(), contBasic.getPnuList());
|
|
||||||
result += upsertCnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 어제 라벨링 검수 완료된 것 -> 국유인에 전송 */
|
|
||||||
@Scheduled(cron = "0 0 1 * * *")
|
|
||||||
public void findLabelingCompleteSend() {
|
|
||||||
|
|
||||||
List<GeomUidDto> list = gukYuinJobCoreService.findYesterdayLabelingCompleteList();
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GeomUidDto dto : list) {
|
|
||||||
gukYuinApiService.updateChnDtctObjtLabelingYn(dto.getResultUid(), "Y");
|
|
||||||
|
|
||||||
// inference_geom 에 label_send_dttm 업데이트 하기
|
|
||||||
gukYuinJobCoreService.updateAnalDataInferenceGeomSendDttm(dto.getGeoUid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package com.kamco.cd.kamcoback.scheduler.service;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.NetUtils;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultPnuDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||||
|
import com.kamco.cd.kamcoback.log.dto.EventStatus;
|
||||||
|
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.core.GukYuinLabelJobCoreService;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinApiLabelJobService {
|
||||||
|
|
||||||
|
private final GukYuinLabelJobCoreService gukYuinLabelJobCoreService;
|
||||||
|
|
||||||
|
private final ExternalHttpClient externalHttpClient;
|
||||||
|
private final NetUtils netUtils = new NetUtils();
|
||||||
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
|
||||||
|
private final UserUtil userUtil;
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profile;
|
||||||
|
|
||||||
|
@Value("${gukyuin.url}")
|
||||||
|
private String gukyuinUrl;
|
||||||
|
|
||||||
|
@Value("${gukyuin.cdi}")
|
||||||
|
private String gukyuinCdiUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실행중인 profile
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isLocalProfile() {
|
||||||
|
return "local".equalsIgnoreCase(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 어제 라벨링 검수 완료된 것 -> 국유인에 전송
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 1 * * *")
|
||||||
|
public void findLabelingCompleteSend() {
|
||||||
|
if (isLocalProfile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GeomUidDto> list = gukYuinLabelJobCoreService.findYesterdayLabelingCompleteList();
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GeomUidDto gto : list) {
|
||||||
|
String url = gukyuinCdiUrl + "/rlb/objt/" + gto.getResultUid() + "/lbl/" + "Y";
|
||||||
|
|
||||||
|
ExternalCallResult<ResultPnuDto> result =
|
||||||
|
externalHttpClient.call(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
null,
|
||||||
|
netUtils.jsonHeaders(),
|
||||||
|
ChngDetectContDto.ResultPnuDto.class);
|
||||||
|
|
||||||
|
ChngDetectContDto.ResultPnuDto dto = result.body();
|
||||||
|
|
||||||
|
this.insertGukyuinAuditLog(
|
||||||
|
EventType.MODIFIED.getId(),
|
||||||
|
netUtils.getLocalIP(),
|
||||||
|
userUtil.getId(),
|
||||||
|
url.replace(gukyuinUrl, ""),
|
||||||
|
null,
|
||||||
|
result.body().getSuccess());
|
||||||
|
|
||||||
|
// inference_geom 에 label_send_dttm 업데이트 하기
|
||||||
|
gukYuinLabelJobCoreService.updateAnalDataInferenceGeomSendDttm(gto.getGeoUid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
|
||||||
|
public void insertGukyuinAuditLog(
|
||||||
|
String actionType,
|
||||||
|
String myIp,
|
||||||
|
Long userUid,
|
||||||
|
String requestUri,
|
||||||
|
Object requestBody,
|
||||||
|
boolean successFail) {
|
||||||
|
try {
|
||||||
|
AuditLogEntity log =
|
||||||
|
new AuditLogEntity(
|
||||||
|
userUid,
|
||||||
|
EventType.fromName(actionType),
|
||||||
|
successFail ? EventStatus.SUCCESS : EventStatus.FAILED,
|
||||||
|
"GUKYUIN", // 메뉴도 국유인으로 하나 따기
|
||||||
|
myIp,
|
||||||
|
requestUri,
|
||||||
|
requestBody == null ? null : ApiLogFunction.cutRequestBody(requestBody.toString()),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
auditLogRepository.save(log);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
package com.kamco.cd.kamcoback.scheduler.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.NetUtils;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ContBasic;
|
||||||
|
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.log.dto.EventStatus;
|
||||||
|
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.core.GukYuinPnuJobCoreService;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinApiPnuJobService {
|
||||||
|
|
||||||
|
private final GukYuinApiService gukYuinApiService;
|
||||||
|
private final GukYuinPnuJobCoreService gukYuinPnuJobCoreService;
|
||||||
|
private final ExternalHttpClient externalHttpClient;
|
||||||
|
private final NetUtils netUtils = new NetUtils();
|
||||||
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
|
||||||
|
private final UserUtil userUtil;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profile;
|
||||||
|
|
||||||
|
@Value("${gukyuin.url}")
|
||||||
|
private String gukyuinUrl;
|
||||||
|
|
||||||
|
@Value("${gukyuin.cdi}")
|
||||||
|
private String gukyuinCdiUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실행중인 profile
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isLocalProfile() {
|
||||||
|
return "local".equalsIgnoreCase(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 국유인 등록 완료 후, 탐지객체 조회해서 PNU 업데이트 하는 스케줄링 하루 1번 새벽 1시에 실행 */
|
||||||
|
@Scheduled(cron = "0 0 1 * * *")
|
||||||
|
public void findGukYuinContListPnuUpdate() {
|
||||||
|
if (isLocalProfile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LearnKeyDto> list =
|
||||||
|
gukYuinPnuJobCoreService.findGukyuinApplyStatusUidList(
|
||||||
|
List.of(GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_FAILED.getId()));
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (LearnKeyDto dto : list) {
|
||||||
|
try {
|
||||||
|
long succCnt = processUid(dto.getChnDtctMstId(), dto.getUid());
|
||||||
|
if (succCnt > 0) {
|
||||||
|
gukYuinPnuJobCoreService.updateGukYuinApplyStateComplete(
|
||||||
|
dto.getId(), GukYuinStatus.PNU_COMPLETED);
|
||||||
|
} else {
|
||||||
|
gukYuinPnuJobCoreService.updateGukYuinApplyStateComplete(
|
||||||
|
dto.getId(), GukYuinStatus.PNU_FAILED);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[GUKYUIN] failed uid={}", dto.getUid(), e);
|
||||||
|
gukYuinPnuJobCoreService.updateGukYuinApplyStateComplete(
|
||||||
|
dto.getId(), GukYuinStatus.PNU_FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long processUid(String chnDtctMstId, String uid) {
|
||||||
|
long succCnt = 0;
|
||||||
|
String url = gukyuinCdiUrl + "/chn/mast/list/" + chnDtctMstId;
|
||||||
|
|
||||||
|
ExternalCallResult<ResultDto> response =
|
||||||
|
externalHttpClient.call(
|
||||||
|
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.ResultDto.class);
|
||||||
|
|
||||||
|
this.insertGukyuinAuditLog(
|
||||||
|
EventType.DETAIL.getId(),
|
||||||
|
netUtils.getLocalIP(),
|
||||||
|
userUtil.getId(),
|
||||||
|
url.replace(gukyuinUrl, ""),
|
||||||
|
null,
|
||||||
|
response.body().getSuccess());
|
||||||
|
|
||||||
|
ResultDto result = response.body();
|
||||||
|
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
||||||
|
String chnDtctCnt = basic.getChnDtctCnt();
|
||||||
|
if (chnDtctCnt == null || chnDtctCnt.isEmpty()) {
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// page 계산
|
||||||
|
int pageSize = 100;
|
||||||
|
int totalCount = Integer.parseInt(chnDtctCnt);
|
||||||
|
int totalPages = (totalCount + pageSize - 1) / pageSize;
|
||||||
|
|
||||||
|
for (int page = 0; page < totalPages; page++) {
|
||||||
|
succCnt += processPage(uid, page, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return succCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long processPage(String uid, int page, int pageSize) {
|
||||||
|
long result = 0;
|
||||||
|
String url =
|
||||||
|
gukyuinCdiUrl + "/chn/cont/" + uid + "?pageIndex=" + page + "&pageSize=" + pageSize;
|
||||||
|
|
||||||
|
ExternalCallResult<ChngDetectContDto.ResultContDto> response =
|
||||||
|
externalHttpClient.call(
|
||||||
|
url,
|
||||||
|
HttpMethod.GET,
|
||||||
|
null,
|
||||||
|
netUtils.jsonHeaders(),
|
||||||
|
ChngDetectContDto.ResultContDto.class);
|
||||||
|
|
||||||
|
List<ContBasic> contList = response.body().getResult();
|
||||||
|
if (contList == null || contList.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ContBasic cont : contList) {
|
||||||
|
String[] pnuList = cont.getPnuList();
|
||||||
|
long pnuCnt = pnuList == null ? 0 : pnuList.length;
|
||||||
|
if (cont.getChnDtctObjtId() != null) {
|
||||||
|
gukYuinPnuJobCoreService.updateInferenceGeomDataPnuCnt(cont.getChnDtctObjtId(), pnuCnt);
|
||||||
|
|
||||||
|
if (pnuCnt > 0) {
|
||||||
|
Long geoUid =
|
||||||
|
gukYuinPnuJobCoreService.findMapSheetAnalDataInferenceGeomUid(
|
||||||
|
cont.getChnDtctObjtId());
|
||||||
|
gukYuinPnuJobCoreService.insertGeoUidPnuData(geoUid, pnuList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.insertGukyuinAuditLog(
|
||||||
|
EventType.LIST.getId(),
|
||||||
|
netUtils.getLocalIP(),
|
||||||
|
userUtil.getId(),
|
||||||
|
url.replace(gukyuinUrl, ""),
|
||||||
|
null,
|
||||||
|
response.body().getSuccess());
|
||||||
|
|
||||||
|
ResultContDto cont = response.body();
|
||||||
|
if (cont == null || cont.getResult().isEmpty()) {
|
||||||
|
return result; // 외부 API 이상 방어
|
||||||
|
}
|
||||||
|
|
||||||
|
// pnuList 업데이트
|
||||||
|
|
||||||
|
for (ChngDetectContDto.ContBasic contBasic : cont.getResult()) {
|
||||||
|
if (contBasic.getPnuList() == null || contBasic.getChnDtctObjtId() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long upsertCnt =
|
||||||
|
gukYuinPnuJobCoreService.upsertMapSheetDataAnalGeomPnu(
|
||||||
|
contBasic.getChnDtctObjtId(), contBasic.getPnuList());
|
||||||
|
result += upsertCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
|
||||||
|
public void insertGukyuinAuditLog(
|
||||||
|
String actionType,
|
||||||
|
String myIp,
|
||||||
|
Long userUid,
|
||||||
|
String requestUri,
|
||||||
|
Object requestBody,
|
||||||
|
boolean successFail) {
|
||||||
|
try {
|
||||||
|
AuditLogEntity log =
|
||||||
|
new AuditLogEntity(
|
||||||
|
userUid,
|
||||||
|
EventType.fromName(actionType),
|
||||||
|
successFail ? EventStatus.SUCCESS : EventStatus.FAILED,
|
||||||
|
"GUKYUIN", // 메뉴도 국유인으로 하나 따기
|
||||||
|
myIp,
|
||||||
|
requestUri,
|
||||||
|
requestBody == null ? null : ApiLogFunction.cutRequestBody(requestBody.toString()),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
auditLogRepository.save(log);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
package com.kamco.cd.kamcoback.scheduler.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.NetUtils;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
|
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.log.dto.EventStatus;
|
||||||
|
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.core.GukYuinJobCoreService;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinApiStatusJobService {
|
||||||
|
|
||||||
|
private final ExternalHttpClient externalHttpClient;
|
||||||
|
private final NetUtils netUtils = new NetUtils();
|
||||||
|
private final GukYuinJobCoreService gukYuinJobCoreService;
|
||||||
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
|
||||||
|
private final UserUtil userUtil;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profile;
|
||||||
|
|
||||||
|
@Value("${gukyuin.url}")
|
||||||
|
private String gukyuinUrl;
|
||||||
|
|
||||||
|
@Value("${gukyuin.cdi}")
|
||||||
|
private String gukyuinCdiUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실행중인 profile
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isLocalProfile() {
|
||||||
|
return "local".equalsIgnoreCase(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 국유인 연동 후, 100% 되었는지 확인하는 스케줄링 매 10분마다 호출 */
|
||||||
|
@Scheduled(cron = "0 0/10 * * * *")
|
||||||
|
public void findGukYuinMastCompleteYn() {
|
||||||
|
if (isLocalProfile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LearnKeyDto> list =
|
||||||
|
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
|
||||||
|
List.of(GukYuinStatus.IN_PROGRESS.getId()));
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (LearnKeyDto dto : list) {
|
||||||
|
try {
|
||||||
|
String url = gukyuinCdiUrl + "/chn/mast/list/" + dto.getChnDtctMstId();
|
||||||
|
|
||||||
|
ExternalCallResult<ResultDto> response =
|
||||||
|
externalHttpClient.call(
|
||||||
|
url,
|
||||||
|
HttpMethod.GET,
|
||||||
|
null,
|
||||||
|
netUtils.jsonHeaders(),
|
||||||
|
ChngDetectMastDto.ResultDto.class);
|
||||||
|
|
||||||
|
this.insertGukyuinAuditLog(
|
||||||
|
EventType.DETAIL.getId(),
|
||||||
|
netUtils.getLocalIP(),
|
||||||
|
userUtil.getId(),
|
||||||
|
url.replace(gukyuinUrl, ""),
|
||||||
|
null,
|
||||||
|
response.body().getSuccess());
|
||||||
|
|
||||||
|
ResultDto result = response.body();
|
||||||
|
|
||||||
|
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||||
|
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
||||||
|
|
||||||
|
Integer progress =
|
||||||
|
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
|
||||||
|
if (progress != null && progress == 100) {
|
||||||
|
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||||
|
dto.getId(), GukYuinStatus.GUK_COMPLETED);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
|
||||||
|
public void insertGukyuinAuditLog(
|
||||||
|
String actionType,
|
||||||
|
String myIp,
|
||||||
|
Long userUid,
|
||||||
|
String requestUri,
|
||||||
|
Object requestBody,
|
||||||
|
boolean successFail) {
|
||||||
|
try {
|
||||||
|
AuditLogEntity log =
|
||||||
|
new AuditLogEntity(
|
||||||
|
userUid,
|
||||||
|
EventType.fromName(actionType),
|
||||||
|
successFail ? EventStatus.SUCCESS : EventStatus.FAILED,
|
||||||
|
"GUKYUIN", // 메뉴도 국유인으로 하나 따기
|
||||||
|
myIp,
|
||||||
|
requestUri,
|
||||||
|
requestBody == null ? null : ApiLogFunction.cutRequestBody(requestBody.toString()),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
auditLogRepository.save(log);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package com.kamco.cd.kamcoback.scheduler.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.NetUtils;
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
|
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.log.dto.EventStatus;
|
||||||
|
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.core.GukYuinJobCoreService;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GukYuinApiStbltJobService {
|
||||||
|
|
||||||
|
private final ExternalHttpClient externalHttpClient;
|
||||||
|
private final NetUtils netUtils = new NetUtils();
|
||||||
|
private final GukYuinJobCoreService gukYuinStbltJobCoreService;
|
||||||
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
|
||||||
|
private final UserUtil userUtil;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profile;
|
||||||
|
|
||||||
|
@Value("${gukyuin.url}")
|
||||||
|
private String gukyuinUrl;
|
||||||
|
|
||||||
|
@Value("${gukyuin.cdi}")
|
||||||
|
private String gukyuinCdiUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실행중인 profile
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isLocalProfile() {
|
||||||
|
return "local".equalsIgnoreCase(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 국유인 연동 후, 100% 되었는지 확인하는 스케줄링 매 10분마다 호출
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/10 * * * *")
|
||||||
|
public void findGukYuinMastCompleteYn() {
|
||||||
|
if (isLocalProfile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LearnKeyDto> list =
|
||||||
|
gukYuinStbltJobCoreService.findGukyuinApplyStatusUidList(
|
||||||
|
List.of(GukYuinStatus.IN_PROGRESS.getId()));
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (LearnKeyDto dto : list) {
|
||||||
|
try {
|
||||||
|
String url = gukyuinCdiUrl + "/chn/mast/list/" + dto.getChnDtctMstId();
|
||||||
|
|
||||||
|
ExternalCallResult<ResultDto> response =
|
||||||
|
externalHttpClient.call(
|
||||||
|
url,
|
||||||
|
HttpMethod.GET,
|
||||||
|
null,
|
||||||
|
netUtils.jsonHeaders(),
|
||||||
|
ChngDetectMastDto.ResultDto.class);
|
||||||
|
|
||||||
|
this.insertGukyuinAuditLog(
|
||||||
|
EventType.DETAIL.getId(),
|
||||||
|
netUtils.getLocalIP(),
|
||||||
|
userUtil.getId(),
|
||||||
|
url.replace(gukyuinUrl, ""),
|
||||||
|
null,
|
||||||
|
response.body().getSuccess());
|
||||||
|
|
||||||
|
ResultDto result = response.body();
|
||||||
|
|
||||||
|
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||||
|
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
||||||
|
|
||||||
|
Integer progress =
|
||||||
|
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
|
||||||
|
if (progress != null && progress == 100) {
|
||||||
|
gukYuinStbltJobCoreService.updateGukYuinApplyStateComplete(
|
||||||
|
dto.getId(), GukYuinStatus.GUK_COMPLETED);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
|
||||||
|
public void insertGukyuinAuditLog(
|
||||||
|
String actionType,
|
||||||
|
String myIp,
|
||||||
|
Long userUid,
|
||||||
|
String requestUri,
|
||||||
|
Object requestBody,
|
||||||
|
boolean successFail) {
|
||||||
|
try {
|
||||||
|
AuditLogEntity log =
|
||||||
|
new AuditLogEntity(
|
||||||
|
userUid,
|
||||||
|
EventType.fromName(actionType),
|
||||||
|
successFail ? EventStatus.SUCCESS : EventStatus.FAILED,
|
||||||
|
"GUKYUIN", // 메뉴도 국유인으로 하나 따기
|
||||||
|
myIp,
|
||||||
|
requestUri,
|
||||||
|
requestBody == null ? null : ApiLogFunction.cutRequestBody(requestBody.toString()),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
auditLogRepository.save(log);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user