페어파일업로드, 파일삭제 수정

This commit is contained in:
Moon
2025-12-18 16:25:59 +09:00
parent dd02e5d886
commit 8684965ac9
6 changed files with 386 additions and 62 deletions

View File

@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
import jakarta.persistence.EntityNotFoundException;
@@ -49,6 +50,28 @@ public class MapSheetMngCoreService {
mapSheetMngRepository.MapSheetMngComplete(mngYyyy);
}
public void deleteByHstUidMngFile(@Valid Long hstUid) {
mapSheetMngRepository.deleteByHstUidMngFile(hstUid);
}
public MapSheetMngDto.DmlReturn mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
mapSheetMngRepository.mngFileSave(addReq);
// int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
}
public void updateMapSheetMngHstSyncCheckState(
Long hstUid,
String uploadPath,
String syncCheckTfwFileName,
String syncCheckTifFileName){
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(hstUid, uploadPath, syncCheckTfwFileName, syncCheckTifFileName);
}
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
return mapSheetMngRepository.findMapSheetErrorList(searchReq);
@@ -58,10 +81,21 @@ public class MapSheetMngCoreService {
return mapSheetMngRepository.findMapSheetError(hstUid);
}
public List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid) {
return mapSheetMngRepository.findIdToMapSheetFileList(hstUid);
}
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
return mapSheetMngRepository.findYyyyToMapSheetFilePathRefer(mngYyyy);
}
public MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid) {
return mapSheetMngRepository.findIdToMapSheetFile(fileUid);
}
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
int count = 0;
if (!Objects.isNull(hstUidList) && !hstUidList.isEmpty()) {
@@ -215,6 +249,7 @@ public class MapSheetMngCoreService {
}
public MapSheetMngDto.DmlReturn deleteByFileUidMngFile(Long fileUid) {
mapSheetMngRepository.deleteByFileUidMngFile(fileUid);
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");

View File

@@ -15,6 +15,8 @@ public interface MapSheetMngRepositoryCustom {
MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy);
void MapSheetMngComplete(int mngYyyy);
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
@@ -25,7 +27,7 @@ public interface MapSheetMngRepositoryCustom {
void deleteByFileUidMngFile(Long fileUid);
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy);
MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy);
void deleteByMngYyyyMngAll(int mngYyyy);
@@ -35,12 +37,23 @@ public interface MapSheetMngRepositoryCustom {
void deleteByMngYyyyMngFile(int mngYyyy);
void deleteByHstUidMngFile(Long hstUid);
void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq);
void updateMapSheetMngHstSyncCheckState(
Long hstUid,
String uploadPath,
String syncCheckTfwFileName,
String syncCheckTifFileName);
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
MapSheetMngDto.ErrorDataDto findMapSheetError(Long hstUid);
List<MapSheetMngDto.MngFilesDto> findIdToMapSheetFileList(Long hstUid);
MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid);
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
}

View File

@@ -19,7 +19,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.validation.Valid;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.hibernate.query.Query;
@@ -72,6 +74,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
"row_number() over(order by {0} desc)",
mapSheetMngEntity.createdDttm),
mapSheetMngEntity.mngYyyy,
mapSheetMngEntity.mngPath,
mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState,
mapSheetMngEntity.syncCheckState,
@@ -194,6 +197,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
"row_number() over(order by {0} desc)",
mapSheetMngEntity.createdDttm),
mapSheetMngEntity.mngYyyy,
mapSheetMngEntity.mngPath,
mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState,
mapSheetMngEntity.syncCheckState,
@@ -336,6 +340,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
Projections.constructor(
MapSheetMngDto.ErrorDataDto.class,
mapSheetMngHstEntity.hstUid,
mapSheetMngHstEntity.mngYyyy,
mapSheetMngHstEntity.mapSheetNum,
mapSheetMngHstEntity.refMapSheetNum,
Expressions.stringTemplate(
"concat({0},substring({1}, 0, 6))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
@@ -386,37 +393,39 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
whereBuilder.and(mapSheetMngHstEntity.hstUid.eq(hstUid));
MapSheetMngDto.ErrorDataDto foundContent =
queryFactory
.select(
Projections.constructor(
MapSheetMngDto.ErrorDataDto.class,
mapSheetMngHstEntity.hstUid,
mapSheetMngHstEntity.mapSheetNum,
Expressions.stringTemplate(
"concat({0},substring({1}, 0, 6))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("map50kName"),
Expressions.stringTemplate(
"concat({0},substring({1}, 6, 8))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("map5kName"),
Expressions.stringTemplate(
"concat({0},substring({1}, 6, 8))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("mapSrcName"),
mapInkx5kEntity.fid,
mapSheetMngHstEntity.createdDate,
mapSheetMngHstEntity.syncState,
mapSheetMngHstEntity.syncTfwFileName,
mapSheetMngHstEntity.syncTifFileName,
mapSheetMngHstEntity.syncCheckState,
mapSheetMngHstEntity.syncCheckTfwFileName,
mapSheetMngHstEntity.syncCheckTifFileName))
.from(mapSheetMngHstEntity)
.innerJoin(mapInkx5kEntity)
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
.where(whereBuilder)
.fetchOne();
queryFactory
.select(
Projections.constructor(
MapSheetMngDto.ErrorDataDto.class,
mapSheetMngHstEntity.hstUid,
mapSheetMngHstEntity.mngYyyy,
mapSheetMngHstEntity.mapSheetNum,
mapSheetMngHstEntity.refMapSheetNum,
Expressions.stringTemplate(
"concat({0},substring({1}, 0, 6))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("map50kName"),
Expressions.stringTemplate(
"concat({0},substring({1}, 6, 8))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("map5kName"),
Expressions.stringTemplate(
"concat({0},substring({1}, 6, 8))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
.as("mapSrcName"),
mapInkx5kEntity.fid,
mapSheetMngHstEntity.createdDate,
mapSheetMngHstEntity.syncState,
mapSheetMngHstEntity.syncTfwFileName,
mapSheetMngHstEntity.syncTifFileName,
mapSheetMngHstEntity.syncCheckState,
mapSheetMngHstEntity.syncCheckTfwFileName,
mapSheetMngHstEntity.syncCheckTifFileName))
.from(mapSheetMngHstEntity)
.innerJoin(mapInkx5kEntity)
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
.where(whereBuilder)
.fetchOne();
return foundContent;
}
@@ -476,7 +485,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePath(int mngYyyy) {
public MapSheetMngDto.MngFilesDto findYyyyToMapSheetFilePathRefer(int mngYyyy) {
BooleanBuilder whereBuilder = new BooleanBuilder();
whereBuilder.and(mapSheetMngFileEntity.mngYyyy.eq(mngYyyy));
@@ -497,11 +506,39 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
mapSheetMngFileEntity.fileSize))
.from(mapSheetMngFileEntity)
.where(whereBuilder)
.orderBy(mapSheetMngFileEntity.fileUid.desc())
.limit(1)
.fetchOne();
return foundContent;
}
@Override
public MapSheetMngDto.MngFilesDto findIdToMapSheetFile(Long fileUid) {
MapSheetMngDto.MngFilesDto foundContent =
queryFactory
.select(
Projections.constructor(
MapSheetMngDto.MngFilesDto.class,
mapSheetMngFileEntity.fileUid,
mapSheetMngFileEntity.mngYyyy,
mapSheetMngFileEntity.mapSheetNum,
mapSheetMngFileEntity.refMapSheetNum,
mapSheetMngFileEntity.filePath,
mapSheetMngFileEntity.fileName,
mapSheetMngFileEntity.fileExt,
mapSheetMngFileEntity.hstUid,
mapSheetMngFileEntity.fileSize))
.from(mapSheetMngFileEntity)
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
.fetchOne();
return foundContent;
}
@Override
public void MapSheetMngComplete(int mngYyyy) {
long execCount =
queryFactory
@@ -511,6 +548,26 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.execute();
}
@Override
public void updateMapSheetMngHstSyncCheckState(
Long hstUid,
String uploadPath,
String syncCheckTfwFileName,
String syncCheckTifFileName){
long execCount =
queryFactory
.update(mapSheetMngHstEntity)
.set(mapSheetMngHstEntity.syncCheckState, "DONE")
.set(mapSheetMngHstEntity.mapSheetPath, uploadPath)
.set(mapSheetMngHstEntity.syncCheckTfwFileName, syncCheckTfwFileName)
.set(mapSheetMngHstEntity.syncCheckTifFileName, syncCheckTifFileName)
.set(mapSheetMngHstEntity.syncCheckStrtDttm, ZonedDateTime.now())
.set(mapSheetMngHstEntity.syncCheckEndDttm, ZonedDateTime.now())
.where(mapSheetMngHstEntity.hstUid.eq(hstUid))
.execute();
}
@Override
public void deleteByMngYyyyMngAll(int mngYyyy) {
@@ -564,14 +621,53 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public void deleteByFileUidMngFile(Long fileUid) {
public void deleteByHstUidMngFile(Long hstUid) {
long deletedFileCount =
queryFactory
.delete(mapSheetMngFileEntity)
.where(mapSheetMngFileEntity.fileUid.eq(hstUid))
.execute();
}
@Override
public void deleteByFileUidMngFile(Long fileUid) {
long fileCount =
queryFactory
.delete(mapSheetMngFileEntity)
.where(mapSheetMngFileEntity.fileUid.eq(fileUid))
.execute();
}
@Override
public void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq){
long fileCount =
queryFactory
.insert(mapSheetMngFileEntity)
.columns(
mapSheetMngFileEntity.mngYyyy,
mapSheetMngFileEntity.mapSheetNum,
mapSheetMngFileEntity.refMapSheetNum,
mapSheetMngFileEntity.filePath,
mapSheetMngFileEntity.fileName,
mapSheetMngFileEntity.fileExt,
mapSheetMngFileEntity.hstUid,
mapSheetMngFileEntity.fileSize,
mapSheetMngFileEntity.fileState
)
.values(
addReq.getMngYyyy(),
addReq.getMapSheetNum(),
addReq.getRefMapSheetNum(),
addReq.getFilePath(),
addReq.getFileName(),
addReq.getFileExt(),
addReq.getHstUid(),
addReq.getFileSize(),
addReq.getFileState()
)
.execute();
}
@Override
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {