라벨링툴 라벨러 목록API, spotless
This commit is contained in:
@@ -27,14 +27,14 @@ import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.gce.geotiff.GeoTiffReader;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class FIleChecker {
|
||||
|
||||
@@ -521,14 +521,13 @@ public class FIleChecker {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void unzip(String fileName, String destDirectory ) throws IOException {
|
||||
public static void unzip(String fileName, String destDirectory) throws IOException {
|
||||
File destDir = new File(destDirectory);
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs(); // 대상 폴더가 없으면 생성
|
||||
}
|
||||
|
||||
String zipFilePath = destDirectory+"/"+fileName;
|
||||
String zipFilePath = destDirectory + "/" + fileName;
|
||||
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath))) {
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
@@ -564,7 +563,6 @@ public class FIleChecker {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {
|
||||
File destFile = new File(destinationDir, zipEntry.getName());
|
||||
|
||||
@@ -578,8 +576,6 @@ public class FIleChecker {
|
||||
return destFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean checkExtensions(String fileName, String ext) {
|
||||
if (fileName == null) return false;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import com.kamco.cd.kamcoback.upload.dto.UploadDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -164,8 +163,8 @@ public class ModelMngDto {
|
||||
private String clsModelFileName;
|
||||
private String memo;
|
||||
|
||||
@JsonIgnore private String clsModelVersion;
|
||||
@JsonIgnore private double priority;
|
||||
@JsonIgnore private String clsModelVersion;
|
||||
@JsonIgnore private double priority;
|
||||
@JsonIgnore private UUID uuid;
|
||||
}
|
||||
|
||||
@@ -193,7 +192,6 @@ public class ModelMngDto {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Schema(name = "ModelMetricAddReq", description = "모델 등록 req")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -236,5 +234,4 @@ public class ModelMngDto {
|
||||
return (double) (this.chunkIndex + 1) / (this.chunkTotalIndex + 1) * 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.kamco.cd.kamcoback.model.service;
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker.Basic;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.ModelMetricAddReq;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.ModelUploadResDto;
|
||||
@@ -83,7 +81,6 @@ public class ModelMngService {
|
||||
modelMetricAddReq.setLoss(0);
|
||||
modelMetricAddReq.setIou(0);
|
||||
|
||||
|
||||
modelMngCoreService.insertModelResultMetric(modelMetricAddReq);
|
||||
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseDto.ApiResponseCode.OK, "등록되었습니다.");
|
||||
@@ -91,20 +88,19 @@ public class ModelMngService {
|
||||
|
||||
public ModelUploadResDto uploadChunkModelFile(
|
||||
UploadDto.UploadAddReq upAddReqDto, MultipartFile chunkFile) {
|
||||
UploadDto.UploadRes upRes = uploadService.uploadChunk(upAddReqDto, chunkFile);
|
||||
UploadDto.UploadRes upRes = uploadService.uploadChunk(upAddReqDto, chunkFile);
|
||||
|
||||
ModelUploadResDto modelUploadResDto = new ModelUploadResDto();
|
||||
modelUploadResDto.setRes(upRes.getRes());
|
||||
modelUploadResDto.setResMsg(upRes.getResMsg());
|
||||
modelUploadResDto.setUuid(upRes.getUuid());
|
||||
modelUploadResDto.setFilePath(upRes.getFilePath());
|
||||
modelUploadResDto.setFileName(upRes.getFileName());
|
||||
modelUploadResDto.setChunkIndex(upRes.getChunkIndex());
|
||||
modelUploadResDto.setChunkTotalIndex(upRes.getChunkTotalIndex());
|
||||
// 압축풀기 (String zipFilePath, String destDirectory)
|
||||
|
||||
ModelUploadResDto modelUploadResDto = new ModelUploadResDto();
|
||||
modelUploadResDto.setRes(upRes.getRes());
|
||||
modelUploadResDto.setResMsg(upRes.getResMsg());
|
||||
modelUploadResDto.setUuid(upRes.getUuid());
|
||||
modelUploadResDto.setFilePath(upRes.getFilePath());
|
||||
modelUploadResDto.setFileName(upRes.getFileName());
|
||||
modelUploadResDto.setChunkIndex(upRes.getChunkIndex());
|
||||
modelUploadResDto.setChunkTotalIndex(upRes.getChunkTotalIndex());
|
||||
//압축풀기 (String zipFilePath, String destDirectory)
|
||||
|
||||
if( upRes.getChunkIndex() == upRes.getChunkTotalIndex() ) {
|
||||
if (upRes.getChunkIndex() == upRes.getChunkTotalIndex()) {
|
||||
try {
|
||||
FIleChecker.unzip(upRes.getFileName(), upRes.getFilePath());
|
||||
|
||||
@@ -115,47 +111,37 @@ public class ModelMngService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return modelUploadResDto;
|
||||
}
|
||||
|
||||
public ModelUploadResDto getUnzipModelFiles(String dirPath, ModelUploadResDto modelUploadResDto) {
|
||||
|
||||
//String dirPath = srchDto.getDirPath();
|
||||
// String dirPath = srchDto.getDirPath();
|
||||
int startPos = 0;
|
||||
int endPos = 20;
|
||||
|
||||
List<Basic> files =
|
||||
FIleChecker.getFilesFromAllDepth(
|
||||
dirPath,
|
||||
"*",
|
||||
"pth,py",
|
||||
10,
|
||||
"name",
|
||||
startPos,
|
||||
endPos);
|
||||
FIleChecker.getFilesFromAllDepth(dirPath, "*", "pth,py", 10, "name", startPos, endPos);
|
||||
|
||||
for (Basic dto : files) {
|
||||
// 예: 파일명 출력 및 추가 작업
|
||||
String foldNm = dto.getFullPath().replace(dto.getFileNm(), "");
|
||||
|
||||
if( dto.getExtension().equals("pth") ) {
|
||||
if (dto.getExtension().equals("pth")) {
|
||||
modelUploadResDto.setCdModelPath(foldNm);
|
||||
modelUploadResDto.setCdModelFileName(dto.getFileNm());
|
||||
}else if( dto.getExtension().equals("py") ) {
|
||||
} else if (dto.getExtension().equals("py")) {
|
||||
modelUploadResDto.setCdModelConfigPath(foldNm);
|
||||
modelUploadResDto.setCdModelConfigFileName(dto.getFileNm());
|
||||
}else if( dto.getExtension().equals("json") ) {
|
||||
} else if (dto.getExtension().equals("json")) {
|
||||
modelUploadResDto.setClsModelPath(foldNm);
|
||||
modelUploadResDto.setClsModelFileName(dto.getFileNm());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//int fileListPos = 0;
|
||||
//int fileTotCnt = files.size();
|
||||
//long fileTotSize = FIleChecker.getFileTotSize(files);
|
||||
// int fileListPos = 0;
|
||||
// int fileTotCnt = files.size();
|
||||
// long fileTotSize = FIleChecker.getFileTotSize(files);
|
||||
|
||||
return modelUploadResDto;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.repository.trainingdata.TrainingDataLabelRepository;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TrainingDataLabelCoreService {
|
||||
|
||||
private final TrainingDataLabelRepository trainingDataLabelRepository;
|
||||
|
||||
public Page<LabelingListDto> findLabelingAssignedList(searchReq searchReq, String userId) {
|
||||
return trainingDataLabelRepository.findLabelingAssignedList(searchReq, userId);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,6 @@ public class ModelMngEntity extends CommonDateEntity {
|
||||
@Column(name = "priority")
|
||||
private Double priority;
|
||||
|
||||
|
||||
public void deleted() {
|
||||
this.deleted = true;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,7 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
modelMngEntity.clsModelPath,
|
||||
modelMngEntity.clsModelFileName,
|
||||
modelMngEntity.clsModelVersion,
|
||||
modelMngEntity.priority
|
||||
))
|
||||
modelMngEntity.priority))
|
||||
.from(modelMngEntity)
|
||||
.innerJoin(modelResultMetricEntity)
|
||||
.on(modelMngEntity.modelUid.eq(modelResultMetricEntity.modelUid))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.trainingdata;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface TrainingDataLabelRepository
|
||||
extends JpaRepository<LabelingAssignmentEntity, Long>, TrainingDataLabelRepositoryCustom {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.trainingdata;
|
||||
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface TrainingDataLabelRepositoryCustom {
|
||||
|
||||
Page<LabelingListDto> findLabelingAssignedList(searchReq searchReq, String userId);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.trainingdata;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
implements TrainingDataLabelRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
public TrainingDataLabelRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||
super(LabelingAssignmentEntity.class);
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<LabelingListDto> findLabelingAssignedList(searchReq searchReq, String userId) {
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
List<LabelingListDto> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelingListDto.class,
|
||||
labelingAssignmentEntity.assignmentUid,
|
||||
labelingAssignmentEntity.inferenceGeomUid,
|
||||
labelingAssignmentEntity.workerUid,
|
||||
labelingAssignmentEntity.workState,
|
||||
labelingAssignmentEntity.assignGroupId,
|
||||
mapInkx5kEntity.mapidNm,
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(labelingAssignmentEntity.assignGroupId.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(
|
||||
labelingAssignmentEntity.assignGroupId.asc(),
|
||||
labelingAssignmentEntity.inferenceGeomUid.asc())
|
||||
.fetch();
|
||||
|
||||
Long count =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.assignmentUid.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(labelingAssignmentEntity.assignGroupId.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(list, pageable, count);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.kamco.cd.kamcoback.trainingdata;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.service.TrainingDataLabelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "라벨링 툴 > 라벨러", description = "라벨링 툴 > 라벨러 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/training-data/label")
|
||||
public class TrainingDataLabelApiController {
|
||||
|
||||
private final TrainingDataLabelService trainingDataLabelService;
|
||||
|
||||
@Operation(summary = "목록 조회", description = "라벨 할당 목록 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<Page<LabelingListDto>> findLabelingAssignedList(
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(defaultValue = "20260105001") String userId) {
|
||||
TrainingDataLabelDto.searchReq searchReq = new TrainingDataLabelDto.searchReq(page, size, "");
|
||||
return ApiResponseDto.ok(trainingDataLabelService.findLabelingAssignedList(searchReq, userId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.kamco.cd.kamcoback.trainingdata.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
public class TrainingDataLabelDto {
|
||||
|
||||
@Schema(name = "LabelingListDto", description = "LabelingListDto")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class LabelingListDto {
|
||||
|
||||
private UUID assignmentUid;
|
||||
private Long inferenceGeomUid;
|
||||
private String workerUid;
|
||||
private String workState;
|
||||
private String mapSheetNum;
|
||||
private String mapIdNm;
|
||||
private Long pnu;
|
||||
}
|
||||
|
||||
@Schema(name = "searchReq", description = "검색 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class searchReq {
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.kamco.cd.kamcoback.trainingdata.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.core.TrainingDataLabelCoreService;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
|
||||
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TrainingDataLabelService {
|
||||
|
||||
private final TrainingDataLabelCoreService trainingDataLabelCoreService;
|
||||
|
||||
public TrainingDataLabelService(TrainingDataLabelCoreService trainingDataLabelCoreService) {
|
||||
this.trainingDataLabelCoreService = trainingDataLabelCoreService;
|
||||
}
|
||||
|
||||
public Page<LabelingListDto> findLabelingAssignedList(searchReq searchReq, String userId) {
|
||||
return trainingDataLabelCoreService.findLabelingAssignedList(searchReq, userId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user