영상관리 chunk, uploadPair 로직 수정
This commit is contained in:
@@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -322,6 +323,7 @@ public class MapSheetMngApiController {
|
||||
@PostMapping(value = "/file-chunk-upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ApiResponseDto<ModelUploadResDto> fileChunkUpload(
|
||||
@RequestParam("hstUid") Long hstUid,
|
||||
@RequestParam("uuid") UUID uuid,
|
||||
@RequestParam("fileName") String fileName,
|
||||
@RequestParam("fileSize") long fileSize,
|
||||
@RequestParam("chunkIndex") Integer chunkIndex,
|
||||
@@ -338,6 +340,7 @@ public class MapSheetMngApiController {
|
||||
upAddReqDto.setChunkIndex(chunkIndex);
|
||||
upAddReqDto.setChunkTotalIndex(chunkTotalIndex);
|
||||
upAddReqDto.setUploadDivi(uploadDivi);
|
||||
upAddReqDto.setUuid(uuid);
|
||||
upAddReqDto.setFinalPath(syncRootDir);
|
||||
upAddReqDto.setTempPath(syncRootTmpDir);
|
||||
|
||||
|
||||
@@ -258,6 +258,7 @@ public class MapSheetMngDto {
|
||||
private String mapSheetPath;
|
||||
|
||||
private UUID uuid;
|
||||
private String uploadId;
|
||||
|
||||
// private List<MngFIleDto> fileArray;
|
||||
|
||||
@@ -278,7 +279,8 @@ public class MapSheetMngDto {
|
||||
String errorCheckTfwFileName,
|
||||
String errorCheckTifFileName,
|
||||
String mapSheetPath,
|
||||
UUID uuid) {
|
||||
UUID uuid,
|
||||
String uploadId) {
|
||||
this.hstUid = hstUid;
|
||||
this.mngYyyy = mngYyyy;
|
||||
this.mapSheetNum = mapSheetNum;
|
||||
@@ -298,6 +300,7 @@ public class MapSheetMngDto {
|
||||
this.errorCheckTifFileName = errorCheckTifFileName;
|
||||
this.mapSheetPath = mapSheetPath;
|
||||
this.uuid = uuid;
|
||||
this.uploadId = uploadId;
|
||||
}
|
||||
|
||||
private String getSyncStateName(String enumId) {
|
||||
|
||||
@@ -148,7 +148,7 @@ public class MapSheetMngService {
|
||||
|
||||
// 멀티파트 파일 tmp폴더 저장(파일형식 체크를 위해)
|
||||
String tfwTmpPath = tmpPath + tfwFile.getOriginalFilename();
|
||||
String tifTmpPath = tmpPath + tifFile;
|
||||
// String tifTmpPath = tmpPath + tifFile;
|
||||
|
||||
if (!FIleChecker.multipartSaveTo(tfwFile, tfwTmpPath)) {
|
||||
return new DmlReturn("fail", "UPLOAD ERROR");
|
||||
@@ -393,7 +393,6 @@ public class MapSheetMngService {
|
||||
uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum();
|
||||
}
|
||||
|
||||
upAddReqDto.setUuid(errDto.getUuid());
|
||||
upAddReqDto.setFinalPath(uploadPath + "/");
|
||||
upAddReqDto.setTempPath(upAddReqDto.getTempPath() + "/");
|
||||
|
||||
@@ -402,7 +401,7 @@ public class MapSheetMngService {
|
||||
ModelUploadResDto modelUploadResDto = new ModelUploadResDto();
|
||||
|
||||
// 병합 다 했는데 gdalinfo 가 fail 이면 삭제?
|
||||
if (upRes.getRes().equals("MERGED")) {
|
||||
if (upAddReqDto.getStatus().equals("MERGED")) {
|
||||
if (!FIleChecker.cmmndGdalInfo(upRes.getFilePath() + "/" + upRes.getFileName())) {
|
||||
Path filePath = Paths.get(upRes.getFilePath());
|
||||
Files.deleteIfExists(filePath);
|
||||
@@ -410,6 +409,10 @@ public class MapSheetMngService {
|
||||
modelUploadResDto.setResMsg("TIF TYPE ERROR");
|
||||
return modelUploadResDto;
|
||||
}
|
||||
|
||||
// upload_id, uuid 를 update
|
||||
mapSheetMngCoreService.updateMapSheetMngHstUploadId(
|
||||
hstUid, upAddReqDto.getUuid(), upRes.getUploadId());
|
||||
}
|
||||
|
||||
modelUploadResDto.setRes(upRes.getRes());
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -319,5 +320,8 @@ public class MapSheetMngCoreService {
|
||||
public List<MngListCompareDto> getByHstMapSheetCompareList(int mngYyyy, List<String> mapId) {
|
||||
return mapSheetMngRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
||||
}
|
||||
;
|
||||
|
||||
public void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId) {
|
||||
mapSheetMngRepository.updateMapSheetMngHstUploadId(hstUid, uuid, uploadId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,9 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
|
||||
@Column(name = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@Column(name = "upload_id")
|
||||
private String uploadId;
|
||||
|
||||
// 파일정보 업데이트
|
||||
public void updateFileInfos(Long tifSizeBytes, Long tfwSizeBytes) {
|
||||
tifSizeBytes = tifSizeBytes == null ? 0L : tifSizeBytes;
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface MapSheetMngRepositoryCustom {
|
||||
@@ -77,4 +78,6 @@ public interface MapSheetMngRepositoryCustom {
|
||||
Page<YearEntity> getYears(YearSearchReq req);
|
||||
|
||||
List<ImageFeature> getSceneInference(String yyyy, List<String> mapSheetNums);
|
||||
|
||||
void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
@@ -460,7 +461,8 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetMngHstEntity.syncCheckTfwFileName,
|
||||
mapSheetMngHstEntity.syncCheckTifFileName,
|
||||
mapSheetMngHstEntity.mapSheetPath,
|
||||
mapSheetMngHstEntity.uuid))
|
||||
mapSheetMngHstEntity.uuid,
|
||||
mapSheetMngHstEntity.uploadId))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(
|
||||
@@ -526,7 +528,8 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetMngHstEntity.syncCheckTfwFileName,
|
||||
mapSheetMngHstEntity.syncCheckTifFileName,
|
||||
mapSheetMngHstEntity.mapSheetPath,
|
||||
mapSheetMngHstEntity.uuid))
|
||||
mapSheetMngHstEntity.uuid,
|
||||
mapSheetMngHstEntity.uploadId))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
|
||||
@@ -1075,6 +1078,16 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId) {
|
||||
queryFactory
|
||||
.update(mapSheetMngHstEntity)
|
||||
.set(mapSheetMngHstEntity.uploadId, uploadId)
|
||||
.set(mapSheetMngHstEntity.uuid, uuid)
|
||||
.where(mapSheetMngHstEntity.hstUid.eq(hstUid))
|
||||
.execute();
|
||||
}
|
||||
|
||||
private BooleanExpression eqYearStatus(QYearEntity years, String status) {
|
||||
if (status == null) {
|
||||
return null;
|
||||
|
||||
@@ -43,6 +43,7 @@ public class UploadDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class UploadAddReq {
|
||||
|
||||
@Schema(description = "업로드 ID", example = "각데이터의 식별키")
|
||||
private String uploadId;
|
||||
|
||||
@@ -144,6 +145,7 @@ public class UploadDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class uploadDto {
|
||||
|
||||
@Schema(description = "업로드 ID", example = "각데이터의 식별키")
|
||||
private String uploadId;
|
||||
|
||||
@@ -189,6 +191,7 @@ public class UploadDto {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class UploadRes {
|
||||
|
||||
private String res;
|
||||
private String resMsg;
|
||||
private UUID uuid;
|
||||
@@ -196,6 +199,7 @@ public class UploadDto {
|
||||
private String fileName;
|
||||
private int chunkIndex;
|
||||
private int chunkTotalIndex;
|
||||
private String uploadId;
|
||||
|
||||
public double getUploadRate() {
|
||||
if (this.chunkTotalIndex == 0) {
|
||||
|
||||
@@ -60,7 +60,9 @@ public class UploadService {
|
||||
UploadDto.UploadRes upRes = new UploadDto.UploadRes();
|
||||
|
||||
long datasetId = 0;
|
||||
if (upAddReqDto.getDatasetId() != null) datasetId = upAddReqDto.getDatasetId();
|
||||
if (upAddReqDto.getDatasetId() != null) {
|
||||
datasetId = upAddReqDto.getDatasetId();
|
||||
}
|
||||
String uploadId = System.currentTimeMillis() + "";
|
||||
// UUID uuid = UUID.randomUUID();
|
||||
UUID uuid = upAddReqDto.getUuid();
|
||||
@@ -86,7 +88,9 @@ public class UploadService {
|
||||
|
||||
// 세션 신규,중복체크(초기화 포함)
|
||||
UploadDto.uploadDto dto = this.checkUploadSession(upAddReqDto, upRes);
|
||||
if (!upRes.getRes().equals("success")) return upRes;
|
||||
if (!upRes.getRes().equals("success")) {
|
||||
return upRes;
|
||||
}
|
||||
|
||||
status = FileUploadStatus.UPLOADING.name();
|
||||
upAddReqDto.setStatus(status);
|
||||
@@ -97,7 +101,9 @@ public class UploadService {
|
||||
}
|
||||
|
||||
// 폴더 생성 및 체크
|
||||
if (!checkChunkFoler(upRes, tmpDataSetDir, fianlDir)) return upRes;
|
||||
if (!checkChunkFoler(upRes, tmpDataSetDir, fianlDir)) {
|
||||
return upRes;
|
||||
}
|
||||
|
||||
// chunk저장하기
|
||||
if (!FIleChecker.multipartChunkSaveTo(file, tmpDataSetDir, chunkIndex)) {
|
||||
@@ -232,7 +238,10 @@ public class UploadService {
|
||||
uploadSessionCoreService.updateUploadSessionStatus(upAddReqDto);
|
||||
}
|
||||
|
||||
if (dto != null) upRes.setUuid(dto.getUuid());
|
||||
if (dto != null) {
|
||||
upRes.setUuid(dto.getUuid());
|
||||
upRes.setUploadId(dto.getUploadId());
|
||||
}
|
||||
|
||||
upRes.setChunkIndex(upAddReqDto.getChunkIndex());
|
||||
upRes.setChunkTotalIndex(upAddReqDto.getChunkTotalIndex());
|
||||
|
||||
Reference in New Issue
Block a user