라벨링작업 관리 목록조회 수정

This commit is contained in:
2026-01-05 14:39:08 +09:00
parent 3bc801053a
commit 539831c712
7 changed files with 103 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -113,7 +114,7 @@ public class InnopamApiController {
return detectMastService.selectDetectMast(dtctMstId);
}
@Operation(summary = "탐지객체 PNU 리스트 조회", description = "탐지객체 PNU 리스트 조회")
@Operation(summary = "탐지객체 랜덤 PNU 리스트 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다")
@ApiResponses(
value = {
@ApiResponse(
@@ -149,4 +150,29 @@ public class InnopamApiController {
detectMastSearch.setFeatureId(featureId);
return new FeaturePnuDto();
}
@Operation(
summary = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)",
description = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "pnu 업데이트 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Integer.class))),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PutMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}")
public Integer updatePnuList(
@PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable String dtctSno) {
DetectMastSearch detectMastSearch = new DetectMastSearch();
detectMastSearch.setCprsAdYr(cprsAfYr);
detectMastSearch.setCprsBfYr(cprsBfYr);
detectMastSearch.setDtctSno(Integer.parseInt(dtctSno));
return detectMastService.updatePnuData(detectMastSearch);
}
}

View File

@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import com.kamco.cd.kamcoback.Innopam.postgres.repository.DetectMastRepository;
import java.util.List;
@@ -59,4 +60,8 @@ public class DetectMastCoreService {
DetectMastEntity detectMastEntity = detectMastRepository.findPnuData(detectMast);
return detectMastEntity.getPathNm();
}
public Integer updatePnu(List<FeaturePnuDto> list) {
return detectMastRepository.updateGeomPnu(list);
}
}

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.Innopam.postgres.repository;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import java.util.List;
@@ -9,4 +10,6 @@ public interface DetectMastRepositoryCustom {
public List<DetectMastEntity> findDetectMastList(DetectMastSearch detectMast);
public DetectMastEntity findPnuData(DetectMastSearch detectMast);
Integer updateGeomPnu(List<FeaturePnuDto> list);
}

View File

@@ -2,10 +2,14 @@ package com.kamco.cd.kamcoback.Innopam.postgres.repository;
import static com.kamco.cd.kamcoback.Innopam.postgres.entity.QDetectMastEntity.detectMastEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@@ -15,7 +19,9 @@ import org.springframework.stereotype.Repository;
@RequiredArgsConstructor
public class DetectMastRepositoryImpl implements DetectMastRepositoryCustom {
private final EntityManager em;
private final JPAQueryFactory queryFactory;
private final ObjectMapper objectMapper;
@Override
public List<DetectMastEntity> findDetectMastList(DetectMastSearch detectMast) {
@@ -56,4 +62,33 @@ public class DetectMastRepositoryImpl implements DetectMastRepositoryCustom {
.where(whereBuilder)
.fetchOne();
}
@Override
public Integer updateGeomPnu(List<FeaturePnuDto> list) {
if (list == null || list.isEmpty()) {
return 0;
}
String sql =
"""
UPDATE tb_map_sheet_anal_data_inference_geom g
SET pnu = j.pnu
FROM (
SELECT
(elem->>'featureId')::uuid AS feature_uuid,
(elem->>'pnu')::bigint AS pnu
FROM jsonb_array_elements(CAST(:json AS jsonb)) AS elem
) j
WHERE g.uuid = j.feature_uuid;
""";
String json = "";
try {
json = objectMapper.writeValueAsString(list);
} catch (JsonProcessingException e) {
throw new RuntimeException("PNU 업데이트 실패", e);
}
return em.createNativeQuery(sql).setParameter("json", json).executeUpdate();
}
}

View File

@@ -57,12 +57,34 @@ public class DetectMastService {
String dirPath =
"local".equals(profile)
? "/Users/bokmin/detect/result/2023_2024/4"
? "/Users/bokmin/detect/result/"
+ detectMast.getCprsBfYr()
+ "_"
+ detectMast.getCprsAdYr()
+ "/"
+ detectMast.getDtctSno()
: detectMastCoreService.findPnuData(detectMast);
return extractFeaturePnusRandom(dirPath);
}
@Transactional
public Integer updatePnuData(DetectMastSearch detectMast) {
String dirPath =
"local".equals(profile)
? "/Users/bokmin/detect/result/"
+ detectMast.getCprsBfYr()
+ "_"
+ detectMast.getCprsAdYr()
+ "/"
+ detectMast.getDtctSno()
: detectMastCoreService.findPnuData(detectMast);
List<FeaturePnuDto> list = extractFeaturePnusRandom(dirPath);
return detectMastCoreService.updatePnu(list);
}
/** 하위 폴더까지 .geojson 파일들에서 polygon_id만 뽑음 병렬처리(parallel) 제거: IO + parallel은 거의 항상 느려짐 */
private List<FeaturePnuDto> extractFeaturePnusRandom(String dirPath) {

View File

@@ -5,7 +5,6 @@ import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
@@ -16,8 +15,7 @@ import org.springframework.stereotype.Repository;
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
private final JPAQueryFactory queryFactory;
@PersistenceContext private final EntityManager em;
private final EntityManager em;
/** tb_map_sheet_anal_data_inference */
private final QMapSheetAnalDataInferenceEntity inferenceEntity =

View File

@@ -124,7 +124,15 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
mapSheetAnalInferenceEntity.stage,
mapSheetAnalDataInferenceEntity.createdDttm.min(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
new CaseBuilder()
.when(
mapSheetAnalDataInferenceGeomEntity
.pnu
.isNotNull()
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L)))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
.then(1L)