Merge pull request '모델학습관리 > 목록 API 메모,작성자 추가로 인한 수정' (#118) from feat/training_260202 into develop
Reviewed-on: #118
This commit was merged in pull request #118.
This commit is contained in:
@@ -6,7 +6,7 @@ import com.kamco.cd.training.dataset.dto.DatasetDto.DatasetReq;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetDto.SelectDataSet;
|
||||
import com.kamco.cd.training.model.dto.ModelConfigDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.Basic;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.ListDto;
|
||||
import com.kamco.cd.training.model.service.ModelTrainMngService;
|
||||
import com.kamco.cd.training.train.service.ModelTestMetricsJobService;
|
||||
import com.kamco.cd.training.train.service.ModelTrainMetricsJobService;
|
||||
@@ -55,7 +55,7 @@ public class ModelTrainMngApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/list")
|
||||
public ApiResponseDto<Page<Basic>> findByModelList(
|
||||
public ApiResponseDto<Page<ListDto>> findByModelList(
|
||||
@Parameter(
|
||||
description = "상태코드",
|
||||
example = "IN_PROGRESS",
|
||||
|
||||
@@ -218,4 +218,98 @@ public class ModelTrainMngDto {
|
||||
@Schema(description = "메모", example = "메모 입니다.")
|
||||
private String memo;
|
||||
}
|
||||
|
||||
@Schema(name = "모델학습관리 목록", description = "모델학습관리 목록")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class ListDto {
|
||||
|
||||
private Long id;
|
||||
private UUID uuid;
|
||||
private String modelVer;
|
||||
@JsonFormatDttm private ZonedDateTime startDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1EndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2EndDttm;
|
||||
private String step1Status;
|
||||
private String step2Status;
|
||||
private String statusCd;
|
||||
private String trainType;
|
||||
private String modelNo;
|
||||
private Long currentAttemptId;
|
||||
private String requestPath;
|
||||
|
||||
private String packingState;
|
||||
private ZonedDateTime packingStrtDttm;
|
||||
private ZonedDateTime packingEndDttm;
|
||||
|
||||
private String memo;
|
||||
private String userNm;
|
||||
|
||||
public String getStatusName() {
|
||||
if (this.statusCd == null || this.statusCd.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.statusCd).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.statusCd; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep1StatusName() {
|
||||
if (this.step1Status == null || this.step1Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step1Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step1Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep2StatusName() {
|
||||
if (this.step2Status == null || this.step2Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step2Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step2Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getTrainTypeName() {
|
||||
if (this.trainType == null || this.trainType.isBlank()) return null;
|
||||
try {
|
||||
return TrainType.valueOf(this.trainType).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.trainType; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDuration(ZonedDateTime start, ZonedDateTime end) {
|
||||
if (start == null || end == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long totalSeconds = Math.abs(Duration.between(start, end).getSeconds());
|
||||
|
||||
long hours = totalSeconds / 3600;
|
||||
long minutes = (totalSeconds % 3600) / 60;
|
||||
long seconds = totalSeconds % 60;
|
||||
|
||||
return String.format("%d시간 %d분 %d초", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public String getStep1Duration() {
|
||||
return formatDuration(this.step1StrtDttm, this.step1EndDttm);
|
||||
}
|
||||
|
||||
public String getStep2Duration() {
|
||||
return formatDuration(this.step2StrtDttm, this.step2EndDttm);
|
||||
}
|
||||
|
||||
public String getPackingDuration() {
|
||||
return formatDuration(this.packingStrtDttm, this.packingEndDttm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ModelTrainMngService {
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 모델 목록
|
||||
*/
|
||||
public Page<ModelTrainMngDto.Basic> getModelList(SearchReq searchReq) {
|
||||
public Page<ModelTrainMngDto.ListDto> getModelList(SearchReq searchReq) {
|
||||
return modelTrainMngCoreService.findByModelList(searchReq);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.kamco.cd.training.dataset.dto.DatasetDto.DatasetReq;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetDto.SelectDataSet;
|
||||
import com.kamco.cd.training.model.dto.ModelConfigDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.Basic;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.ListDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.TrainingDataset;
|
||||
import com.kamco.cd.training.postgres.entity.ModelConfigEntity;
|
||||
import com.kamco.cd.training.postgres.entity.ModelDatasetEntity;
|
||||
@@ -53,9 +53,10 @@ public class ModelTrainMngCoreService {
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 모델 목록
|
||||
*/
|
||||
public Page<Basic> findByModelList(ModelTrainMngDto.SearchReq searchReq) {
|
||||
Page<ModelMasterEntity> entityPage = modelMngRepository.findByModels(searchReq);
|
||||
return entityPage.map(ModelMasterEntity::toDto);
|
||||
public Page<ListDto> findByModelList(ModelTrainMngDto.SearchReq searchReq) {
|
||||
// Page<ModelMasterEntity> entityPage = modelMngRepository.findByModels(searchReq);
|
||||
// return entityPage.map(ModelMasterEntity::toDto);
|
||||
return modelMngRepository.findByModels(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.ListDto;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import com.kamco.cd.training.train.dto.TrainRunRequest;
|
||||
import java.util.Optional;
|
||||
@@ -15,7 +16,7 @@ public interface ModelMngRepositoryCustom {
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
Page<ModelMasterEntity> findByModels(ModelTrainMngDto.SearchReq searchReq);
|
||||
Page<ListDto> findByModels(ModelTrainMngDto.SearchReq searchReq);
|
||||
|
||||
Optional<ModelMasterEntity> findByUuid(UUID uuid);
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import static com.kamco.cd.training.postgres.entity.QMemberEntity.memberEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelConfigEntity.modelConfigEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelHyperParamEntity.modelHyperParamEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMasterEntity;
|
||||
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.ListDto;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import com.kamco.cd.training.train.dto.TrainRunRequest;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
@@ -34,7 +36,7 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<ModelMasterEntity> findByModels(ModelTrainMngDto.SearchReq req) {
|
||||
public Page<ListDto> findByModels(ModelTrainMngDto.SearchReq req) {
|
||||
Pageable pageable = req.toPageable();
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
|
||||
@@ -52,9 +54,36 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
|
||||
builder.and(modelMasterEntity.delYn.isFalse());
|
||||
|
||||
List<ModelMasterEntity> content =
|
||||
List<ListDto> content =
|
||||
queryFactory
|
||||
.selectFrom(modelMasterEntity)
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ListDto.class,
|
||||
modelMasterEntity.id,
|
||||
modelMasterEntity.uuid,
|
||||
modelMasterEntity.modelVer,
|
||||
modelMasterEntity.strtDttm,
|
||||
modelMasterEntity.step1StrtDttm,
|
||||
modelMasterEntity.step1EndDttm,
|
||||
modelMasterEntity.step2StrtDttm,
|
||||
modelMasterEntity.step2EndDttm,
|
||||
modelMasterEntity.step1State,
|
||||
modelMasterEntity.step2State,
|
||||
modelMasterEntity.statusCd,
|
||||
modelMasterEntity.trainType,
|
||||
modelMasterEntity.modelNo,
|
||||
modelMasterEntity.currentAttemptId,
|
||||
modelMasterEntity.requestPath,
|
||||
modelMasterEntity.packingState,
|
||||
modelMasterEntity.packingStrtDttm,
|
||||
modelMasterEntity.packingEndDttm,
|
||||
modelConfigEntity.memo,
|
||||
memberEntity.name))
|
||||
.from(modelMasterEntity)
|
||||
.innerJoin(modelConfigEntity)
|
||||
.on(modelMasterEntity.id.eq(modelConfigEntity.model.id))
|
||||
.leftJoin(memberEntity)
|
||||
.on(modelMasterEntity.createdUid.eq(memberEntity.id))
|
||||
.where(builder)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
@@ -66,6 +95,10 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
queryFactory
|
||||
.select(modelMasterEntity.count())
|
||||
.from(modelMasterEntity)
|
||||
.innerJoin(modelConfigEntity)
|
||||
.on(modelMasterEntity.id.eq(modelConfigEntity.model.id))
|
||||
.leftJoin(memberEntity)
|
||||
.on(modelMasterEntity.createdUid.eq(memberEntity.id))
|
||||
.where(builder)
|
||||
.fetchOne();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user