학습결과 파일 베스트 에폭 제외 삭제 추가, 납품데이터 등록 비동기 수정
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.training.common.enums.LearnDataRegister;
|
||||
import com.kamco.cd.training.common.enums.LearnDataType;
|
||||
import com.kamco.cd.training.common.exception.NotFoundException;
|
||||
@@ -15,6 +14,7 @@ import com.kamco.cd.training.postgres.entity.DatasetEntity;
|
||||
import com.kamco.cd.training.postgres.entity.DatasetObjEntity;
|
||||
import com.kamco.cd.training.postgres.repository.dataset.DatasetObjRepository;
|
||||
import com.kamco.cd.training.postgres.repository.dataset.DatasetRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -23,16 +23,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DatasetCoreService
|
||||
implements BaseCoreService<DatasetDto.Basic, Long, DatasetDto.SearchReq> {
|
||||
|
||||
private final DatasetRepository datasetRepository;
|
||||
private final DatasetObjRepository datasetObjRepository;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 학습 데이터 삭제
|
||||
@@ -221,7 +220,6 @@ public class DatasetCoreService
|
||||
return datasetRepository.insertDatasetMngData(mngRegDto);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void insertDatasetObj(DatasetObjRegDto objRegDto) {
|
||||
datasetObjRepository.insertDatasetObj(objRegDto);
|
||||
}
|
||||
@@ -230,22 +228,26 @@ public class DatasetCoreService
|
||||
return datasetObjRepository.getFilePathByUUIDPathType(uuid, pathType);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void insertDatasetTestObj(DatasetObjRegDto objRegDto) {
|
||||
datasetObjRepository.insertDatasetTestObj(objRegDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 학습데이터셋 마스터 상태 변경
|
||||
*
|
||||
* @param datasetUid 학습데이터셋 마스터 id
|
||||
* @param register 상태
|
||||
*/
|
||||
@Transactional
|
||||
public void updateDatasetUploadStatus(Long datasetUid) {
|
||||
public void updateDatasetUploadStatus(Long datasetUid, LearnDataRegister register) {
|
||||
DatasetEntity entity =
|
||||
datasetRepository
|
||||
.findById(datasetUid)
|
||||
.orElseThrow(() -> new NotFoundException("데이터셋을 찾을 수 없습니다. ID: " + datasetUid));
|
||||
|
||||
entity.setStatus(LearnDataRegister.COMPLETED.getId());
|
||||
entity.setStatus(register.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void insertDatasetValObj(DatasetObjRegDto objRegDto) {
|
||||
datasetObjRepository.insertDatasetValObj(objRegDto);
|
||||
}
|
||||
@@ -253,4 +255,15 @@ public class DatasetCoreService
|
||||
public Long findDatasetByUidExistsCnt(String uid) {
|
||||
return datasetRepository.findDatasetByUidExistsCnt(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터셋 등록 실패시 Obj 데이터 정리
|
||||
*
|
||||
* @param datasetUid 모델 마스터 id
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteAllDatasetObj(Long datasetUid) {
|
||||
int cnt = datasetObjRepository.deleteAllDatasetObj(datasetUid);
|
||||
log.info("datasetUid={} 데이터셋 실패 - 전체 삭제 완료. 총 {}건", datasetUid, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,6 +341,20 @@ public class ModelTrainMngCoreService {
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델관리 조회
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public ModelTrainMngDto.Basic findModelByUuid(UUID uuid) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + uuid));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/** 마스터를 IN_PROGRESS로 전환하고, 현재 실행 jobId를 연결 - UI/중단/상태조회 모두 currentAttemptId를 기준으로 동작 */
|
||||
@Transactional
|
||||
public void markInProgress(Long modelId, Long jobId) {
|
||||
|
||||
@@ -24,4 +24,12 @@ public interface DatasetObjRepositoryCustom {
|
||||
void insertDatasetTestObj(DatasetObjRegDto objRegDto);
|
||||
|
||||
void insertDatasetValObj(DatasetObjRegDto objRegDto);
|
||||
|
||||
/**
|
||||
* 데이터셋 등록 실패시 Obj 데이터 정리
|
||||
*
|
||||
* @param datasetUid
|
||||
* @return
|
||||
*/
|
||||
int deleteAllDatasetObj(Long datasetUid);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final QDatasetEntity dataset = datasetEntity;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@PersistenceContext EntityManager em;
|
||||
|
||||
@@ -55,7 +56,6 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
|
||||
@Override
|
||||
public void insertDatasetTestObj(DatasetObjRegDto objRegDto) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json;
|
||||
Geometry geometry;
|
||||
String geometryJson;
|
||||
@@ -99,7 +99,6 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
|
||||
@Override
|
||||
public void insertDatasetValObj(DatasetObjRegDto objRegDto) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json;
|
||||
String geometryJson;
|
||||
try {
|
||||
@@ -219,7 +218,6 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
|
||||
@Override
|
||||
public void insertDatasetObj(DatasetObjRegDto objRegDto) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json;
|
||||
String geometryJson;
|
||||
try {
|
||||
@@ -276,4 +274,38 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
.where(datasetObjEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllDatasetObj(Long datasetUid) {
|
||||
int cnt = 0;
|
||||
cnt =
|
||||
em.createNativeQuery(
|
||||
"""
|
||||
delete from tb_dataset_obj
|
||||
where dataset_uid = ?
|
||||
""")
|
||||
.setParameter(1, datasetUid)
|
||||
.executeUpdate();
|
||||
|
||||
cnt +=
|
||||
em.createNativeQuery(
|
||||
"""
|
||||
delete from tb_dataset_val_obj
|
||||
where dataset_uid = ?
|
||||
""")
|
||||
.setParameter(1, datasetUid)
|
||||
.executeUpdate();
|
||||
|
||||
cnt +=
|
||||
em.createNativeQuery(
|
||||
"""
|
||||
delete from tb_dataset_test_obj
|
||||
where dataset_uid = ?
|
||||
""")
|
||||
.setParameter(1, datasetUid)
|
||||
.executeUpdate();
|
||||
|
||||
em.clear();
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user