실패 메시지 저장 추가
This commit is contained in:
@@ -30,6 +30,7 @@ import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetAnalDataInfe
|
||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearn5kRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.scene.MapInkx5kRepository;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -436,13 +437,25 @@ public class InferenceResultCoreService {
|
||||
/**
|
||||
* 모델별 도엽별 실패여부 저장
|
||||
*
|
||||
* @param uuid learn 테이블 uuid
|
||||
* @param failMapIds 실패한 도엽 목록
|
||||
* @param type 모델타입
|
||||
* @param uuid uuid
|
||||
* @param jobDto job정보
|
||||
* @param type 모델 타입
|
||||
*/
|
||||
@Transactional
|
||||
public void saveFail5k(UUID uuid, List<Long> failMapIds, String type) {
|
||||
mapSheetLearn5kRepository.saveFail5k(uuid, failMapIds, type);
|
||||
public void saveFail5k(UUID uuid, JobStatusDto jobDto, String type) {
|
||||
mapSheetLearn5kRepository.saveFail5k(uuid, jobDto, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델별 도엽별 성공 job id저장
|
||||
*
|
||||
* @param uuid uuid
|
||||
* @param jobDto job정보
|
||||
* @param type 모델 타입
|
||||
*/
|
||||
@Transactional
|
||||
public void saveJobId(UUID uuid, JobStatusDto jobDto, String type) {
|
||||
mapSheetLearn5kRepository.saveFail5k(uuid, jobDto, type);
|
||||
}
|
||||
|
||||
public Long getInferenceLearnIdByUuid(UUID uuid) {
|
||||
@@ -486,4 +499,12 @@ public class InferenceResultCoreService {
|
||||
public List<String> getInferenceRunMapId(UUID uuid) {
|
||||
return mapSheetLearn5kRepository.getInferenceRunMapId(uuid);
|
||||
}
|
||||
|
||||
public List<Long> findFail5kList(UUID uuid, List<Long> failMapIds, String type) {
|
||||
return mapSheetLearn5kRepository.findFail5kList(uuid, failMapIds, type);
|
||||
}
|
||||
|
||||
public List<Long> findCompleted5kList(UUID uuid, List<Long> completedIds, String type) {
|
||||
return mapSheetLearn5kRepository.findCompleted5kList(uuid, completedIds, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,4 +63,22 @@ public class MapSheetLearn5kEntity {
|
||||
|
||||
@Column(name = "is_m3_fail")
|
||||
private Boolean isM3Fail = false;
|
||||
|
||||
@Column(name = "m1_error_message")
|
||||
private String m1ErrorMessage;
|
||||
|
||||
@Column(name = "m2_error_message")
|
||||
private String m2ErrorMessage;
|
||||
|
||||
@Column(name = "m3_error_message")
|
||||
private String m3ErrorMessage;
|
||||
|
||||
@Column(name = "m1_job_id")
|
||||
private Long m1JobId;
|
||||
|
||||
@Column(name = "m2_job_id")
|
||||
private Long m2JobId;
|
||||
|
||||
@Column(name = "m3_job_id")
|
||||
private Long m3JobId;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface MapSheetLearn5kRepositoryCustom {
|
||||
|
||||
void saveFail5k(UUID uuid, List<Long> failMapIds, String type);
|
||||
void saveFail5k(UUID uuid, JobStatusDto jobDto, String type);
|
||||
|
||||
void saveJobId(UUID uuid, JobStatusDto jobDto, String type);
|
||||
|
||||
List<Long> findFail5kList(UUID uuid, List<Long> failIds, String type);
|
||||
|
||||
List<Long> findCompleted5kList(UUID uuid, List<Long> completedIds, String type);
|
||||
|
||||
List<String> getInferenceRunMapId(UUID uuid);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,13 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kE
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearn5kEntity.mapSheetLearn5kEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.dsl.BooleanPath;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberPath;
|
||||
import com.querydsl.core.types.dsl.StringPath;
|
||||
import com.querydsl.jpa.JPAExpressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -19,49 +24,183 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
@Override
|
||||
public void saveFail5k(UUID uuid, List<Long> failMapIds, String type) {
|
||||
if (failMapIds == null || failMapIds.isEmpty()) {
|
||||
public void saveFail5k(UUID uuid, JobStatusDto jobDto, String type) {
|
||||
if (uuid == null || jobDto == null || type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Long id =
|
||||
queryFactory
|
||||
.select(mapSheetLearnEntity.id)
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
BooleanPath target;
|
||||
final BooleanPath failPath;
|
||||
final NumberPath<Long> jobIdPath;
|
||||
final StringPath errorMsgPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1":
|
||||
target = mapSheetLearn5kEntity.isM1Fail;
|
||||
break;
|
||||
case "M2":
|
||||
target = mapSheetLearn5kEntity.isM2Fail;
|
||||
break;
|
||||
case "M3":
|
||||
target = mapSheetLearn5kEntity.isM3Fail;
|
||||
break;
|
||||
default:
|
||||
case "M1" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m1ErrorMessage;
|
||||
}
|
||||
case "M2" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m2ErrorMessage;
|
||||
}
|
||||
case "M3" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m3ErrorMessage;
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var learnIdSubQuery =
|
||||
JPAExpressions.select(mapSheetLearnEntity.id)
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid));
|
||||
|
||||
queryFactory
|
||||
.update(mapSheetLearn5kEntity)
|
||||
.set(target, true)
|
||||
.set(failPath, Boolean.TRUE)
|
||||
.set(jobIdPath, jobDto.getId())
|
||||
.set(errorMsgPath, jobDto.getErrorMessage())
|
||||
.where(
|
||||
mapSheetLearn5kEntity
|
||||
.learn
|
||||
.id
|
||||
.eq(id)
|
||||
.and(mapSheetLearn5kEntity.mapSheetNum.in(failMapIds)))
|
||||
.eq(learnIdSubQuery)
|
||||
.and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId()))))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveJobId(UUID uuid, JobStatusDto jobDto, String type) {
|
||||
if (uuid == null || jobDto == null || type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final BooleanPath failPath;
|
||||
final NumberPath<Long> jobIdPath;
|
||||
final StringPath errorMsgPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
}
|
||||
case "M2" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
}
|
||||
case "M3" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var learnIdSubQuery =
|
||||
JPAExpressions.select(mapSheetLearnEntity.id)
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid));
|
||||
|
||||
queryFactory
|
||||
.update(mapSheetLearn5kEntity)
|
||||
.set(failPath, Boolean.FALSE)
|
||||
.set(jobIdPath, jobDto.getId())
|
||||
.where(
|
||||
mapSheetLearn5kEntity
|
||||
.learn
|
||||
.id
|
||||
.eq(learnIdSubQuery)
|
||||
.and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId()))))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> findFail5kList(UUID uuid, List<Long> failIds, String type) {
|
||||
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
|
||||
if (uuid == null || failIds == null || failIds.isEmpty() || type == null) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
builder.and(mapSheetLearnEntity.uuid.eq(uuid));
|
||||
|
||||
NumberPath<Long> jobIdPath;
|
||||
BooleanPath failPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
}
|
||||
case "M2" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
}
|
||||
case "M3" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(jobIdPath)
|
||||
.from(mapSheetLearn5kEntity)
|
||||
.join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity)
|
||||
.where(
|
||||
mapSheetLearnEntity
|
||||
.uuid
|
||||
.eq(uuid)
|
||||
.and(failPath.isFalse().or(failPath.isNull()))
|
||||
.and(jobIdPath.in(failIds)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> findCompleted5kList(UUID uuid, List<Long> completedIds, String type) {
|
||||
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
|
||||
if (uuid == null || completedIds == null || completedIds.isEmpty() || type == null) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
builder.and(mapSheetLearnEntity.uuid.eq(uuid));
|
||||
|
||||
NumberPath<Long> jobIdPath;
|
||||
BooleanPath failPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
}
|
||||
case "M2" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
}
|
||||
case "M3" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(jobIdPath)
|
||||
.from(mapSheetLearn5kEntity)
|
||||
.join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid).and(jobIdPath.in(completedIds)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInferenceRunMapId(UUID uuid) {
|
||||
return queryFactory
|
||||
|
||||
Reference in New Issue
Block a user