review-to-geojson 로그작성,prod수정, spotless

This commit is contained in:
2026-03-02 21:01:14 +09:00
parent 2ea6a62730
commit a9d9aa746f
19 changed files with 71 additions and 51 deletions

View File

@@ -15,7 +15,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Log4j2
@@ -36,8 +35,8 @@ public class TrainingDataLabelJobService {
public void runTask() {
// 프록시를 통해 호출해야 @Transactional이 적용됨
applicationContext
.getBean(TrainingDataLabelJobService.class)
.assignReviewerYesterdayLabelComplete(null);
.getBean(TrainingDataLabelJobService.class)
.assignReviewerYesterdayLabelComplete(null);
}
@Transactional
@@ -48,7 +47,7 @@ public class TrainingDataLabelJobService {
log.info("=== baseDate : {}", baseDate);
log.info("=== baseDate 있으면 해당 일자, 없으면 어제일자로 조회");
List<Tasks> tasks =
trainingDataLabelJobCoreService.findCompletedYesterdayUnassigned(baseDate);
trainingDataLabelJobCoreService.findCompletedYesterdayUnassigned(baseDate);
log.info("[Step 1-2] 목록 객체 건수 count : {}", tasks == null ? 0 : tasks.size());
if (tasks.isEmpty()) {
@@ -59,7 +58,7 @@ public class TrainingDataLabelJobService {
// 회차별로 그룹핑
log.info("[Step 2-1] 회차별로 그룹핑 시작");
Map<Long, List<Tasks>> taskByRound =
tasks.stream().collect(Collectors.groupingBy(Tasks::getAnalUid));
tasks.stream().collect(Collectors.groupingBy(Tasks::getAnalUid));
// 회차별 분배
log.info("[Step 3-1] 회차별로 분배 시작");
@@ -71,7 +70,7 @@ public class TrainingDataLabelJobService {
log.info("[Step 3-2] 수행하는 회차 analUid: {}", analUid);
log.info("해당 회차에 라벨링 할당받은 검수자별 완료 건수 count(), 완료한 게 적은 순으로 해야 일이 한 사람에게 몰리지 않음");
List<InspectorPendingDto> pendings =
trainingDataLabelJobCoreService.findInspectorPendingByRound(analUid);
trainingDataLabelJobCoreService.findInspectorPendingByRound(analUid);
log.info("검수자 수: {}", pendings == null ? 0 : pendings.size());
if (pendings.isEmpty()) {
@@ -81,7 +80,7 @@ public class TrainingDataLabelJobService {
log.info("[Step 4-1] 검수자 사번 List 생성");
List<String> reviewerIds =
pendings.stream().map(InspectorPendingDto::getInspectorUid).toList();
pendings.stream().map(InspectorPendingDto::getInspectorUid).toList();
// Lock 걸릴 수 있기 때문에 엔티티 조회하는 Repository 에서 구현
log.info("[Step 4-2] 검수자 테이블 lock 걸리지 않게 처리");
@@ -95,23 +94,23 @@ public class TrainingDataLabelJobService {
// reviewer별 batch update
log.info("[Step 5-3] 검수자별 할당 데이터를 batch update 시작");
assignMap.forEach(
(reviewerId, assignedTasks) -> {
if (assignedTasks.isEmpty()) {
log.info("[Step 5-4] 할당된 데이터 없으면 return");
return;
}
(reviewerId, assignedTasks) -> {
if (assignedTasks.isEmpty()) {
log.info("[Step 5-4] 할당된 데이터 없으면 return");
return;
}
List<UUID> assignmentUids =
assignedTasks.stream().map(Tasks::getAssignmentUid).toList();
log.info("[Step 6-1] 할당 작업에 검수자 아이디 update");
log.info("==== 검수자 사번: {}", reviewerId);
log.info("==== 할당 갯수: {}", assignmentUids == null ? 0 : assignmentUids.size());
trainingDataLabelJobCoreService.assignReviewerBatch(assignmentUids, reviewerId);
List<UUID> assignmentUids =
assignedTasks.stream().map(Tasks::getAssignmentUid).toList();
log.info("[Step 6-1] 할당 작업에 검수자 아이디 update");
log.info("==== 검수자 사번: {}", reviewerId);
log.info("==== 할당 갯수: {}", assignmentUids == null ? 0 : assignmentUids.size());
trainingDataLabelJobCoreService.assignReviewerBatch(assignmentUids, reviewerId);
log.info("[Step 7-1] geom 테이블에 검수 상태 update");
List<Long> geomUids = assignedTasks.stream().map(Tasks::getInferenceUid).toList();
trainingDataLabelJobCoreService.updateGeomUidTestState(geomUids);
});
log.info("[Step 7-1] geom 테이블에 검수 상태 update");
List<Long> geomUids = assignedTasks.stream().map(Tasks::getInferenceUid).toList();
trainingDataLabelJobCoreService.updateGeomUidTestState(geomUids);
});
}
} catch (Exception e) {
log.error("배치 처리 중 예외", e);
@@ -120,7 +119,7 @@ public class TrainingDataLabelJobService {
}
private Map<String, List<Tasks>> distributeByLeastPending(
List<Tasks> tasks, List<String> reviewerIds) {
List<Tasks> tasks, List<String> reviewerIds) {
Map<String, List<Tasks>> result = new LinkedHashMap<>();
// 순서 유지 중요 (ASC 정렬된 상태)

View File

@@ -84,28 +84,28 @@ mapsheet:
baseurl: /app/detect/result #현재사용안함
file:
sync-root-dir: /data/images/
sync-tmp-dir: /data/repo/tmp # image upload temp dir
sync-root-dir: /kamco-nfs/images/
sync-tmp-dir: /kamco-nfs/repo/tmp # image upload temp dir
sync-file-extention: tfw,tif
#dataset-dir: D:/data/model_output/ #변경 model_output
dataset-dir: /data/model_output/export/ # 마운트경로 AI 추론결과
#dataset-dir: D:/kamco-nfs/model_output/ #변경 model_output
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
dataset-tmp-dir: ${file.dataset-dir}tmp/
#model-dir: D:/data/ckpt/model/
model-dir: /data/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
#model-dir: D:/kamco-nfs/ckpt/model/
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
model-tmp-dir: ${file.model-dir}tmp/
model-file-extention: pth,json,py
pt-path: /data/ckpt/v6-cls-checkpoints/
pt-path: /kamco-nfs/ckpt/v6-cls-checkpoints/
pt-FileName: yolov8_6th-6m.pt
dataset-response: /data/dataset/response/
dataset-response: /kamco-nfs/dataset/response/
inference:
url: http://127.0.0.1:8000/jobs
batch-url: http://127.0.0.1:8000/batches
geojson-dir: /data/requests/ # 학습서버에서 트레이닝한 모델업로드경로
jar-path: /data/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
geojson-dir: /kamco-nfs/requests/ # 학습서버에서 트레이닝한 모델업로드경로
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
inference-server-name: server1,server2,server3,server4
gukyuin:
@@ -113,7 +113,7 @@ gukyuin:
cdi: ${gukyuin.url}/api/kcd/cdi
training-data:
geojson-dir: /data/dataset/request/
geojson-dir: /kamco-nfs/dataset/request/
layer:
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com

View File

@@ -18,7 +18,6 @@ import java.util.Objects;
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;
import org.springframework.transaction.annotation.Transactional;
@@ -40,53 +39,69 @@ public class TrainingDataReviewJobService {
return "local".equalsIgnoreCase(profile);
}
@Scheduled(cron = "0 0 2 * * *")
public void runTask() {
exportGeojsonLabelingGeom(null);
}
@Transactional
public void exportGeojsonLabelingGeom(LocalDate baseDate) {
//
// if (isLocalProfile()) {
// return;
// }
// 1) 경로/파일명 결정
String targetDir =
"local".equals(profile) ? System.getProperty("user.home") + "/geojson" : trainingDataDir;
log.info("[Step 1-1] geojson 파일 생성할 경로: {}", targetDir);
// 2) 진행중인 회차 중, complete_cnt 가 존재하는 회차 목록 가져오기
log.info("[Step 1-2] 진행중인 회차 중, complete_cnt 가 존재하는 회차 목록 가져오기");
List<AnalCntInfo> analList = trainingDataReviewJobCoreService.findAnalCntInfoList();
log.info("[Step 1-3] 회차 리스트 건수: {}", analList == null ? 0 : analList.size());
if (analList.isEmpty()) {
log.info("[Step 1-4] 회차 리스트 없어 return 하고 종료");
return;
}
for (AnalCntInfo info : analList) {
log.info("[Step 2-1] 회차 폴리곤 전체 건수 == 파일 생성 건수 같은지 확인");
log.info("=== info.getAllCnt(): {}", info.getAllCnt());
log.info("=== info.getFileCnt(): {}", info.getFileCnt());
if (Objects.equals(info.getAllCnt(), info.getFileCnt())) {
log.info("[Step 2-2] 회차 폴리곤 전체 건수 == 파일 생성 건수 같아서 파일 생성 진행하지 않음 continue");
continue;
}
String resultUid = info.getResultUid(); // 회차의 대문자 uid (폴더명으로 사용)
// 3) 회차 + 어제까지 검수 완료된 총 데이터의 도엽별 목록 가져오기
log.info("[Step 3-1] 회차 + 어제까지 검수 완료된 총 데이터의 도엽별 목록 가져오기");
List<AnalMapSheetList> analMapList =
trainingDataReviewJobCoreService.findCompletedAnalMapSheetList(
info.getAnalUid(), baseDate);
log.info("=== analMapList cnt: {}", analMapList == null ? 0 : analMapList.size());
if (analMapList.isEmpty()) {
log.info("[Step 3-2] 도엽 목록 조회되지 않아 continue");
continue;
}
log.info("[Step 4-1] 도엽별 geom 데이터 가지고 와서 geojson 만들기 시작");
for (AnalMapSheetList mapSheet : analMapList) {
// 4) 도엽별 geom 데이터 가지고 와서 geojson 만들기
log.info("[Step 4-2] 도엽별 검수완료된 폴리곤 데이터 목록 조회");
List<CompleteLabelData> completeList =
trainingDataReviewJobCoreService.findCompletedYesterdayLabelingList(
info.getAnalUid(), mapSheet.getMapSheetNum(), baseDate);
log.info("=== completeList size: {}", completeList == null ? 0 : completeList.size());
if (!completeList.isEmpty()) {
log.info("[Step 4-3] 목록에서 filter로 geoUid List 생성, 폴리곤 feature별 리스트 생성");
List<Long> geoUids = completeList.stream().map(CompleteLabelData::getGeoUid).toList();
List<GeoJsonFeature> features = completeList.stream().map(GeoJsonFeature::from).toList();
// 5) 파일서버에 uid 폴더 생성 후 업로드 하기
log.info("[Step 5-1] 파일서버에 uid 폴더 생성 후 업로드 하기 시작");
FeatureCollection collection = new FeatureCollection(features);
String filename =
String.format(
@@ -96,15 +111,21 @@ public class TrainingDataReviewJobService {
mapSheet.getTargetYyyy(),
mapSheet.getMapSheetNum());
log.info("=== filename: {}", filename);
log.info("=== 회차의 uid: {}", resultUid);
Path outputPath = Paths.get(targetDir + "/" + resultUid, filename);
log.info("=== outputPath: {}", outputPath);
try {
log.info("[Step 6-1] Uid로 폴더 생성");
Files.createDirectories(outputPath.getParent());
log.info("[Step 6-2] geoJson 파일 생성");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.writeValue(outputPath.toFile(), collection);
// geoUids : file_create_yn = true 로 업데이트
log.info("[Step 6-3] learn_data_geom 에 file_create_yn = true 로 업데이트");
trainingDataReviewJobCoreService.updateLearnDataGeomFileCreateYn(geoUids);
} catch (IOException e) {

View File

@@ -84,28 +84,28 @@ mapsheet:
baseurl: /app/detect/result #현재사용안함
file:
sync-root-dir: /data/images/
sync-tmp-dir: /data/repo/tmp # image upload temp dir
sync-root-dir: /kamco-nfs/images/
sync-tmp-dir: /kamco-nfs/repo/tmp # image upload temp dir
sync-file-extention: tfw,tif
#dataset-dir: D:/data/model_output/ #변경 model_output
dataset-dir: /data/model_output/export/ # 마운트경로 AI 추론결과
#dataset-dir: D:/kamco-nfs/model_output/ #변경 model_output
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
dataset-tmp-dir: ${file.dataset-dir}tmp/
#model-dir: D:/data/ckpt/model/
model-dir: /data/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
#model-dir: D:/kamco-nfs/ckpt/model/
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
model-tmp-dir: ${file.model-dir}tmp/
model-file-extention: pth,json,py
pt-path: /data/ckpt/v6-cls-checkpoints/
pt-path: /kamco-nfs/ckpt/v6-cls-checkpoints/
pt-FileName: yolov8_6th-6m.pt
dataset-response: /data/dataset/response/
dataset-response: /kamco-nfs/dataset/response/
inference:
url: http://127.0.0.1:8000/jobs
batch-url: http://127.0.0.1:8000/batches
geojson-dir: /data/requests/ # 학습서버에서 트레이닝한 모델업로드경로
jar-path: /data/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
geojson-dir: /kamco-nfs/requests/ # 학습서버에서 트레이닝한 모델업로드경로
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
inference-server-name: server1,server2,server3,server4
gukyuin:
@@ -113,7 +113,7 @@ gukyuin:
cdi: ${gukyuin.url}/api/kcd/cdi
training-data:
geojson-dir: /data/dataset/request/
geojson-dir: /kamco-nfs/dataset/request/
layer:
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com