영상관리 수정
This commit is contained in:
@@ -19,13 +19,11 @@ import java.nio.file.Paths;
|
|||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@@ -76,18 +74,19 @@ public class MapSheetMngService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public DmlReturn uploadPair(MultipartFile tfwFile, MultipartFile tifFile, Long hstUid) {
|
public DmlReturn uploadPair(
|
||||||
|
MultipartFile tfwFile, MultipartFile tifFile, Long hstUid, Boolean overwrite) {
|
||||||
|
|
||||||
String rootPath = fileConfig.getRootSyncDir();
|
String rootPath = fileConfig.getRootSyncDir();
|
||||||
String tmpPath = fileConfig.getTmpSyncDir();
|
String tmpPath = fileConfig.getTmpSyncDir();
|
||||||
|
|
||||||
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
|
||||||
|
|
||||||
if (errDto == null) {
|
if (errDto == null) {
|
||||||
return new DmlReturn("fail", "NO hstUid Data");
|
return new DmlReturn("fail", "NO hstUid Data");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 파일검증용 임시저장 폴더 확인
|
// 파일검증용 임시저장 폴더 확인
|
||||||
log.info("TmpPath > {}", tmpPath);
|
|
||||||
if (!FIleChecker.mkDir(tmpPath)) {
|
if (!FIleChecker.mkDir(tmpPath)) {
|
||||||
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
|
||||||
}
|
}
|
||||||
@@ -111,36 +110,38 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
// 중복체크
|
// 중복체크
|
||||||
List<FIleChecker.Basic> basicTfwList =
|
List<FIleChecker.Basic> basicTfwList =
|
||||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
|
||||||
|
|
||||||
List<FIleChecker.Basic> basicTifList =
|
List<FIleChecker.Basic> basicTifList =
|
||||||
FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif");
|
FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif");
|
||||||
|
|
||||||
int tfwCnt =
|
int tfwCnt =
|
||||||
(int)
|
(int)
|
||||||
basicTfwList.stream()
|
basicTfwList.stream()
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
.filter(dto -> dto.getExtension().toString().equals("tfw"))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
int tifCnt =
|
int tifCnt =
|
||||||
(int)
|
(int)
|
||||||
basicTifList.stream()
|
basicTifList.stream()
|
||||||
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
.filter(dto -> dto.getExtension().toString().equals("tif"))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
if (tfwCnt > 0 || tifCnt > 0) {
|
if (!overwrite) {
|
||||||
String tfwtifMsg = "";
|
if (tfwCnt > 0 || tifCnt > 0) {
|
||||||
if (tfwCnt > 0) {
|
String tfwtifMsg = "";
|
||||||
tfwtifMsg = tfwFile.getOriginalFilename();
|
|
||||||
}
|
|
||||||
if (tifCnt > 0) {
|
|
||||||
if (tfwCnt > 0) {
|
if (tfwCnt > 0) {
|
||||||
tfwtifMsg = "," + tifFile.getOriginalFilename();
|
tfwtifMsg = tfwFile.getOriginalFilename();
|
||||||
} else {
|
|
||||||
tfwtifMsg = tifFile.getOriginalFilename();
|
|
||||||
}
|
}
|
||||||
|
if (tifCnt > 0) {
|
||||||
|
if (tfwCnt > 0) {
|
||||||
|
tfwtifMsg = "," + tifFile.getOriginalFilename();
|
||||||
|
} else {
|
||||||
|
tfwtifMsg = tifFile.getOriginalFilename();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new DmlReturn("duplicate", tfwtifMsg);
|
||||||
}
|
}
|
||||||
return new DmlReturn("duplicate", tfwtifMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File directory = new File(tmpPath);
|
File directory = new File(tmpPath);
|
||||||
@@ -178,7 +179,7 @@ public class MapSheetMngService {
|
|||||||
// 파일이 존재하지 않을 경우(0개) 해당년도 다른 파일경로로 참조
|
// 파일이 존재하지 않을 경우(0개) 해당년도 다른 파일경로로 참조
|
||||||
if (uploadPath.isEmpty()) {
|
if (uploadPath.isEmpty()) {
|
||||||
MngFilesDto filesDto =
|
MngFilesDto filesDto =
|
||||||
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
|
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
|
||||||
String referPath = filesDto.getFilePath();
|
String referPath = filesDto.getFilePath();
|
||||||
uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum();
|
uploadPath = Paths.get(referPath).getParent().toString() + "/" + errDto.getRefMapSheetNum();
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,7 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
// hst업데이트
|
// hst업데이트
|
||||||
MapSheetMngDto.SyncCheckStateReqUpdateDto updReqSyncCheckState =
|
MapSheetMngDto.SyncCheckStateReqUpdateDto updReqSyncCheckState =
|
||||||
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
|
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
|
||||||
updReqSyncCheckState.setHstUid(hstUid);
|
updReqSyncCheckState.setHstUid(hstUid);
|
||||||
updReqSyncCheckState.setFilePath(uploadPath);
|
updReqSyncCheckState.setFilePath(uploadPath);
|
||||||
updReqSyncCheckState.setSyncCheckTfwFileName(tfwFile.getOriginalFilename());
|
updReqSyncCheckState.setSyncCheckTfwFileName(tfwFile.getOriginalFilename());
|
||||||
|
|||||||
Reference in New Issue
Block a user