feat/infer_dev_260107 #41
@@ -187,6 +187,29 @@ public class GukYuinApiController {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findChnContList(chnDtctId, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 조회 (탐지객체 1건 조회)", description = "탐지객체 조회 (탐지객체 1건 조회)")
|
||||
@GetMapping("/chn/cont/{chnDtctId}/objt/{chnDtctObjtId}")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "목록 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
public ApiResponseDto<ChngDetectContDto.ResultContDto> findChnPnuToContObject(
|
||||
@PathVariable String chnDtctId,
|
||||
@PathVariable String chnDtctObjtId,
|
||||
@RequestParam(defaultValue = "0") Integer pageIndex,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
return ApiResponseDto.ok(
|
||||
gukYuinApiService.findChnPnuToContObject(chnDtctId, chnDtctObjtId, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 조회 (PNU에 해당하는 탐지객체)", description = "탐지객체 조회 (PNU에 해당하는 탐지객체)")
|
||||
@GetMapping("/chn/cont/{chnDtctId}/pnu/{pnu}")
|
||||
@ApiResponses(
|
||||
@@ -250,7 +273,7 @@ public class GukYuinApiController {
|
||||
@Parameter(description = "uuid", example = "7a593d0e-76a8-4b50-8978-9af1fbe871af")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.connectChnMastRegist(uuid));
|
||||
return ApiResponseDto.okObject(gukYuinApiService.connectChnMastRegist(uuid));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨 전송 완료 리스트", description = "라벨 전송 완료 리스트")
|
||||
@@ -259,4 +282,42 @@ public class GukYuinApiController {
|
||||
@Parameter(description = "어제 날짜", example = "2026-01-29") LocalDate yesterday) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findLabelingCompleteSendList(yesterday));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 적합여부 조회 (리스트조회)", description = "탐지객체 적합여부 조회 (리스트조회)")
|
||||
@GetMapping("/rlb/dtct/{chnDtctId}")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "목록 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
public ApiResponseDto<ChngDetectMastDto.RlbDtctDto> findRlbDtctList(
|
||||
@PathVariable String chnDtctId) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findRlbDtctList(chnDtctId));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 적합여부 조회 (리스트조회)", description = "탐지객체 적합여부 조회 (리스트조회)")
|
||||
@GetMapping("/rlb/objt/{chnDtctObjtId}")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "목록 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
public ApiResponseDto<ChngDetectMastDto.RlbDtctDto> findRlbDtctObject(
|
||||
@PathVariable String chnDtctObjtId) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findRlbDtctObject(chnDtctObjtId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,4 +228,64 @@ public class ChngDetectMastDto {
|
||||
private String error;
|
||||
private String path;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RlbDtctDto {
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
private List<RlbDtctMastDto> result;
|
||||
private Boolean success;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RlbDtctMastDto {
|
||||
|
||||
private String pnuDtctId;
|
||||
private String pnu;
|
||||
private String lrmSyncYmd;
|
||||
private String pnuSyncYmd;
|
||||
private String mpqdNo; // 도엽번호
|
||||
private String cprsYr; // 비교년도
|
||||
private String crtrYr; // 기준년도
|
||||
private String chnDtctSno; // 회차
|
||||
private String chnDtctId;
|
||||
|
||||
private String chnDtctMstId;
|
||||
private String chnDtctObjtId;
|
||||
private String chnDtctContId;
|
||||
private String chnCd;
|
||||
private String chnDtctProb;
|
||||
|
||||
private String bfClsCd; // 이전분류코드
|
||||
private String bfClsProb; // 이전분류정확도
|
||||
private String afClsCd; // 이후분류코드
|
||||
private String afClsProb; // 이후분류정확도
|
||||
|
||||
private String pnuSqms;
|
||||
private String pnuDtctSqms;
|
||||
private String chnDtctSqms;
|
||||
private String stbltYn;
|
||||
private String incyCd;
|
||||
private String incyRsnCont;
|
||||
private String lockYn;
|
||||
private String lblYn;
|
||||
private String chgYn;
|
||||
private String rsatctNo;
|
||||
private String rmk;
|
||||
|
||||
private String crtDt; // 생성일시
|
||||
private String crtEpno; // 생성사원번호
|
||||
private String crtIp; // 생성사원아이피
|
||||
private String chgDt;
|
||||
private String chgEpno;
|
||||
private String chgIp;
|
||||
private String delYn; // 삭제여부
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ public class GukYuinDto {
|
||||
private Integer stage;
|
||||
private String uid;
|
||||
private String applyStatus;
|
||||
private Boolean applyYn;
|
||||
|
||||
public Boolean getApplyYn() {
|
||||
return this.applyYn != null && this.applyYn;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -19,11 +19,11 @@ import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ErrorResDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.RlbDtctDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFailCode;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkableRes;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||
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.GukYuinCoreService;
|
||||
@@ -250,7 +250,11 @@ public class GukYuinApiService {
|
||||
|
||||
List<ContBasic> contList = result.body().getResult();
|
||||
if (contList == null || contList.isEmpty()) {
|
||||
return new ResultContDto();
|
||||
return new ResultContDto(
|
||||
result.body().getCode(),
|
||||
result.body().getMessage(),
|
||||
result.body().getResult(),
|
||||
result.body().getSuccess());
|
||||
}
|
||||
|
||||
for (ContBasic cont : contList) {
|
||||
@@ -395,8 +399,7 @@ public class GukYuinApiService {
|
||||
public ResponseObj connectChnMastRegist(UUID uuid) {
|
||||
// uuid로 추론 회차 조회
|
||||
LearnInfo info = gukyuinCoreService.findMapSheetLearnInfo(uuid);
|
||||
if (info.getApplyStatus() != null
|
||||
&& !info.getApplyStatus().equals(GukYuinStatus.PENDING.getId())) {
|
||||
if (info.getApplyYn() != null && info.getApplyYn()) {
|
||||
return new ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 국유인 연동을 한 회차입니다.");
|
||||
}
|
||||
|
||||
@@ -429,4 +432,72 @@ public class GukYuinApiService {
|
||||
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||
return gukyuinCoreService.findLabelingCompleteSendList(yesterday);
|
||||
}
|
||||
|
||||
public ResultContDto findChnPnuToContObject(
|
||||
String chnDtctId, String chnDtctObjtId, Integer pageIndex, Integer pageSize) {
|
||||
|
||||
String url =
|
||||
gukyuinCdiUrl
|
||||
+ "/chn/cont/"
|
||||
+ chnDtctId
|
||||
+ "/chnDtctObjtId/"
|
||||
+ chnDtctObjtId
|
||||
+ "?pageIndex="
|
||||
+ pageIndex
|
||||
+ "&pageSize="
|
||||
+ pageSize;
|
||||
|
||||
ExternalCallResult<ChngDetectContDto.ResultContDto> result =
|
||||
externalHttpClient.call(
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
netUtils.jsonHeaders(),
|
||||
ChngDetectContDto.ResultContDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.DETAIL.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body() != null && result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
|
||||
public ChngDetectMastDto.RlbDtctDto findRlbDtctList(String chnDtctId) {
|
||||
|
||||
String url = gukyuinCdiUrl + "/rlb/dtct/" + chnDtctId;
|
||||
|
||||
ExternalCallResult<ChngDetectMastDto.RlbDtctDto> result =
|
||||
externalHttpClient.call(
|
||||
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.RlbDtctDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.LIST.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body() != null && result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
|
||||
public RlbDtctDto findRlbDtctObject(String chnDtctObjtId) {
|
||||
|
||||
String url = gukyuinCdiUrl + "/rlb/objt/" + chnDtctObjtId;
|
||||
|
||||
ExternalCallResult<ChngDetectMastDto.RlbDtctDto> result =
|
||||
externalHttpClient.call(
|
||||
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.RlbDtctDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.DETAIL.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body() != null && result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,6 +534,10 @@ public class InferenceDetailDto {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getApplyYn() {
|
||||
return this.applyYn != null && this.applyYn;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -184,11 +184,14 @@ public class MapSheetMngDto {
|
||||
}
|
||||
|
||||
public long getSyncErrorTotCnt() {
|
||||
return this.syncNotPaireCnt + this.syncDuplicateCnt + this.syncFaultCnt;
|
||||
return this.syncNotPaireCnt + this.syncDuplicateCnt + this.syncFaultCnt + this.syncNoFileCnt;
|
||||
}
|
||||
|
||||
public long getSyncErrorExecTotCnt() {
|
||||
return this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt;
|
||||
return this.syncNotPaireExecCnt
|
||||
+ this.syncDuplicateExecCnt
|
||||
+ this.syncFaultExecCnt
|
||||
+ this.syncNoFileExecCnt;
|
||||
}
|
||||
|
||||
public String getMngState() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom {
|
||||
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||
.set(mapSheetLearnEntity.chnDtctMstId, resultBody.getChnDtctMstId())
|
||||
.set(mapSheetLearnEntity.applyYn, true)
|
||||
.set(mapSheetLearnEntity.applyDttm, ZonedDateTime.now())
|
||||
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||
.execute();
|
||||
}
|
||||
@@ -152,7 +154,8 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom {
|
||||
mapSheetLearnEntity.targetYyyy,
|
||||
mapSheetLearnEntity.stage,
|
||||
mapSheetLearnEntity.uid,
|
||||
mapSheetLearnEntity.applyStatus))
|
||||
mapSheetLearnEntity.applyStatus,
|
||||
mapSheetLearnEntity.applyYn))
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
|
||||
.leftJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(whereBuilder)
|
||||
.where(mapInkx5kEntity.useInference.eq(CommonUseStatus.USE))
|
||||
// .offset(pageable.getOffset())
|
||||
// .limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetMngEntity.mngYyyy.desc())
|
||||
@@ -254,7 +254,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
public MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy) {
|
||||
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
whereBuilder.and(mapSheetMngEntity.mngYyyy.eq(mngYyyy));
|
||||
whereBuilder
|
||||
.and(mapSheetMngEntity.mngYyyy.eq(mngYyyy))
|
||||
.and(mapInkx5kEntity.useInference.eq(CommonUseStatus.USE));
|
||||
|
||||
MapSheetMngDto.MngDto foundContent =
|
||||
queryFactory
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,21 +38,6 @@ public class MapSheetMngFileJobService {
|
||||
|
||||
private final MapSheetMngFileJobCoreService mapSheetMngFileJobCoreService;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
@Value("${file.sync-auto-exception-start-year}")
|
||||
private int syncAutoExceptionStartYear;
|
||||
|
||||
@Value("${file.sync-auto-exception-before-year-cnt}")
|
||||
private int syncAutoExceptionBeforeYearCnt;
|
||||
|
||||
public Integer checkMngFileSync() {
|
||||
return mapSheetMngFileJobCoreService.findNotYetMapSheetMng();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user