Merge pull request 'feat/dev_251201' (#112) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/112
This commit is contained in:
@@ -177,6 +177,7 @@ public class MapSheetMngApiController {
|
||||
@RequestPart("tif") MultipartFile tifFile,
|
||||
@RequestParam(value = "hstUid", required = false) Long hstUid,
|
||||
@RequestParam(value = "overwrite", required = false) boolean overwrite) {
|
||||
|
||||
return ApiResponseDto.createOK(
|
||||
mapSheetMngService.uploadPair(tfwFile, tifFile, hstUid, overwrite));
|
||||
}
|
||||
|
||||
@@ -86,9 +86,38 @@ public class MapSheetMngDto {
|
||||
private Long syncDuplicateExecCnt;
|
||||
private Long syncFaultCnt;
|
||||
private Long syncFaultExecCnt;
|
||||
private Long syncNoFileCnt;
|
||||
private Long syncNoFileExecCnt;
|
||||
@JsonFormatDttm private ZonedDateTime rgstStrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime rgstEndDttm;
|
||||
|
||||
public String getMngState() {
|
||||
|
||||
if (this.syncStateDoneCnt == 0) return "NOTYET";
|
||||
else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING";
|
||||
|
||||
if ((this.syncNotPaireExecCnt + this.syncDuplicateExecCnt + this.syncFaultExecCnt) > 0)
|
||||
return "TAKINGERROR";
|
||||
|
||||
return "DONE";
|
||||
}
|
||||
|
||||
public String getSyncState() {
|
||||
|
||||
if (this.syncStateDoneCnt == 0) return "NOTYET";
|
||||
else if (this.syncStateDoneCnt < this.syncTotCnt) return "PROCESSING";
|
||||
|
||||
return "DONE";
|
||||
}
|
||||
|
||||
public String getDataCheckState() {
|
||||
|
||||
if (this.syncDataCheckDoneCnt == 0) return "NOTYET";
|
||||
else if (this.syncDataCheckDoneCnt < this.syncTotCnt) return "PROCESSING";
|
||||
|
||||
return "DONE";
|
||||
}
|
||||
|
||||
public double getSyncStateDoneRate() {
|
||||
if (this.syncTotCnt == null || this.syncTotCnt == 0) {
|
||||
return 0.0;
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,6 +33,15 @@ public class MapSheetMngService {
|
||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||
private final FileConfig fileConfig;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
public List<MngDto> findMapSheetMngList() {
|
||||
return mapSheetMngCoreService.findMapSheetMngList();
|
||||
}
|
||||
@@ -77,8 +87,10 @@ public class MapSheetMngService {
|
||||
public DmlReturn uploadPair(
|
||||
MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) {
|
||||
|
||||
String rootPath = fileConfig.getRootSyncDir();
|
||||
String tmpPath = fileConfig.getTmpSyncDir();
|
||||
String rootPath = syncRootDir;
|
||||
String tmpPath = syncTmpDir;
|
||||
|
||||
DmlReturn dmlReturn = new DmlReturn("success", "UPLOAD COMPLETE");
|
||||
|
||||
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||
|
||||
@@ -91,43 +103,21 @@ public class MapSheetMngService {
|
||||
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
||||
}
|
||||
|
||||
// 파일 유효성 검증
|
||||
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
|
||||
return new DmlReturn("fail", "TFW SIZE 오류");
|
||||
} else if (tifFile == null || tifFile.isEmpty() || tifFile.getSize() == 0) {
|
||||
return new DmlReturn("fail", "TIF SIZE 오류");
|
||||
}
|
||||
|
||||
// 확장자명 체크
|
||||
if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw")) {
|
||||
return new DmlReturn("fail", "TFW FILENAME ERROR");
|
||||
} else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif")) {
|
||||
return new DmlReturn("fail", "TIF FILENAME ERROR");
|
||||
}
|
||||
// 업로드 파일 사이즈,확장자명 체크
|
||||
dmlReturn = this.validationFile(tfwFile, tifFile);
|
||||
if (dmlReturn.getFlag().equals("fail")) return dmlReturn;
|
||||
|
||||
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
|
||||
String targetYearDir = mngDto.getMngPath();
|
||||
|
||||
// 중복체크
|
||||
List<FIleChecker.Basic> basicTfwList =
|
||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||
|
||||
List<FIleChecker.Basic> basicTifList =
|
||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif");
|
||||
|
||||
int tfwCnt =
|
||||
(int)
|
||||
basicTfwList.stream()
|
||||
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
||||
.count();
|
||||
|
||||
int tifCnt =
|
||||
(int)
|
||||
basicTifList.stream()
|
||||
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
||||
.count();
|
||||
|
||||
if (!overwrite) {
|
||||
|
||||
int tfwCnt =
|
||||
FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||
int tifCnt =
|
||||
FIleChecker.getFileCountFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||
|
||||
if (tfwCnt > 0 || tifCnt > 0) {
|
||||
String tfwtifMsg = "";
|
||||
if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename();
|
||||
@@ -222,6 +212,17 @@ public class MapSheetMngService {
|
||||
return new DmlReturn("success", "파일 업로드 완료되었습니다.");
|
||||
}
|
||||
|
||||
public DmlReturn validationFile(MultipartFile tfwFile, MultipartFile tifFile) {
|
||||
if (!FIleChecker.validationMultipart(tfwFile)) return new DmlReturn("fail", "TFW SIZE 오류");
|
||||
else if (!FIleChecker.validationMultipart(tifFile)) return new DmlReturn("fail", "TFW SIZE 오류");
|
||||
else if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw"))
|
||||
return new DmlReturn("fail", "TFW FILENAME ERROR");
|
||||
else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif"))
|
||||
return new DmlReturn("fail", "TIF FILENAME ERROR");
|
||||
|
||||
return new DmlReturn("success", "파일체크");
|
||||
}
|
||||
|
||||
public List<MngFilesDto> findHstUidToMapSheetFileList(Long hstUid) {
|
||||
return mapSheetMngCoreService.findHstUidToMapSheetFileList(hstUid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user