영상관리 재반영
This commit is contained in:
@@ -5,7 +5,6 @@ import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngFileCheckerRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -59,12 +58,4 @@ public class MapSheetMngFileCheckerCoreService {
|
||||
public Optional<MapSheetMngHstEntity> findHstByUid(Long hstUid) {
|
||||
return mapSheetMngRepository.findMapSheetMngHstInfo(hstUid);
|
||||
}
|
||||
|
||||
public void updateHstSyncCheckStart(Long hstUid) {
|
||||
mapSheetMngRepository.updateHstSyncCheck(hstUid, null, ZonedDateTime.now(), null);
|
||||
}
|
||||
|
||||
public void updateHstSyncCheckEnd(Long hstUid, String state) {
|
||||
mapSheetMngRepository.updateHstSyncCheck(hstUid, state, null, ZonedDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface MapSheetMngFileRepository extends JpaRepository<MapSheetMngFileEntity, Long> {
|
||||
boolean existsByFileNameAndFilePath(String fileName, String filePath);
|
||||
|
||||
void deleteByFileNameAndFilePath(String fileName, String filePath);
|
||||
|
||||
// 추가: 특정 경로에서 파일명 목록으로 중복 조회
|
||||
List<MapSheetMngFileEntity> findByFilePathAndFileNameIn(String filePath, List<String> fileNames);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
@@ -27,7 +26,4 @@ public interface MapSheetMngRepositoryCustom {
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
||||
|
||||
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
|
||||
|
||||
// 동기화 점검 상태/시간 업데이트 (state/start/end 각각 null이면 기존값 유지)
|
||||
void updateHstSyncCheck(Long hstUid, String state, ZonedDateTime start, ZonedDateTime end);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSh
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
||||
@@ -19,7 +20,10 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.hibernate.query.Query;
|
||||
@@ -172,62 +176,133 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()));
|
||||
|
||||
// syncStateFilter 조건 추가
|
||||
if (searchReq.getSyncStateFilter() != null && !searchReq.getSyncStateFilter().isEmpty()) {
|
||||
whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncStateFilter()));
|
||||
} else {
|
||||
// 기본: 오류 상태만 조회 (NOFILE, NOTPAIR, DUPLICATE, SIZEERROR, TYPEERROR)
|
||||
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()));
|
||||
whereBuilder.and(
|
||||
mapSheetMngHstEntity.syncState.ne("DONE").and(mapSheetMngHstEntity.syncState.ne("NOTYET")));
|
||||
|
||||
if (searchReq.getSyncState() != null && !searchReq.getSyncState().isEmpty()) {
|
||||
if (searchReq.getSyncState().equals("NOTPAIR")) {
|
||||
whereBuilder.and(
|
||||
mapSheetMngHstEntity
|
||||
.syncState
|
||||
.eq("NOTPAIR")
|
||||
.or(mapSheetMngHstEntity.syncState.eq("NOFILE")));
|
||||
} else if (searchReq.getSyncState().equals("FAULT")) {
|
||||
whereBuilder.and(
|
||||
mapSheetMngHstEntity
|
||||
.syncState
|
||||
.eq("SIZEERROR")
|
||||
.or(mapSheetMngHstEntity.syncState.eq("TYPEERROR")));
|
||||
} else {
|
||||
whereBuilder.and(mapSheetMngHstEntity.syncState.eq(searchReq.getSyncState()));
|
||||
}
|
||||
}
|
||||
|
||||
if (searchReq.getSyncCheckState() != null && !searchReq.getSyncCheckState().isEmpty()) {
|
||||
whereBuilder.and(mapSheetMngHstEntity.syncCheckState.eq(searchReq.getSyncCheckState()));
|
||||
}
|
||||
|
||||
if (searchReq.getSearchValue() != null && !searchReq.getSearchValue().isEmpty()) {
|
||||
whereBuilder.and(
|
||||
mapSheetMngHstEntity
|
||||
.syncState
|
||||
.eq("NOFILE")
|
||||
.or(mapSheetMngHstEntity.syncState.eq("NOTPAIR"))
|
||||
.or(mapSheetMngHstEntity.syncState.eq("DUPLICATE"))
|
||||
.or(mapSheetMngHstEntity.syncState.eq("SIZEERROR"))
|
||||
.or(mapSheetMngHstEntity.syncState.eq("TYPEERROR")));
|
||||
.mapSheetNum
|
||||
.eq(searchReq.getSearchValue())
|
||||
.or(mapSheetMngHstEntity.refMapSheetNum.eq(searchReq.getSearchValue()))
|
||||
.or(
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 0, 6))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.likeIgnoreCase(searchReq.getSearchValue()))
|
||||
.or(
|
||||
Expressions.stringTemplate(
|
||||
"concat({0},substring({1}, 6, 8))",
|
||||
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum)
|
||||
.likeIgnoreCase(searchReq.getSearchValue())));
|
||||
}
|
||||
|
||||
// 검색어 조건 추가
|
||||
if (searchReq.getSearchValue() != null && !searchReq.getSearchValue().isEmpty()) {
|
||||
whereBuilder.and(mapSheetErrorSearchValue(searchReq));
|
||||
}
|
||||
|
||||
List<MapSheetMngDto.ErrorDataDto> foundContent =
|
||||
List<Tuple> tuples =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MapSheetMngDto.ErrorDataDto.class,
|
||||
mapSheetMngHstEntity.hstUid,
|
||||
rowNum(),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0}, {1})",
|
||||
mapSheetMngHstEntity.mapSheetName, mapInkx50kEntity.mapidcdNo),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0}, substring({1}, {2}, {3}))",
|
||||
mapSheetMngHstEntity.mapSheetName, mapSheetMngHstEntity.mapSheetNum, 6, 8),
|
||||
mapSheetMngHstEntity.mapSheetCodeSrc,
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYY-MM-DD')", mapSheetMngHstEntity.createdDate),
|
||||
mapSheetMngHstEntity.dataState,
|
||||
mapSheetMngHstEntity.syncState,
|
||||
mapSheetMngHstEntity.syncCheckState,
|
||||
mapSheetMngHstEntity.syncCheckStrtDttm,
|
||||
mapSheetMngHstEntity.syncCheckEndDttm))
|
||||
mapSheetMngHstEntity.hstUid,
|
||||
mapSheetMngHstEntity.mapSheetName,
|
||||
mapInkx5kEntity.mapidNm,
|
||||
mapSheetMngHstEntity.mapSheetNum,
|
||||
mapSheetMngHstEntity.mapSheetCodeSrc,
|
||||
mapSheetMngHstEntity.createdDate,
|
||||
mapSheetMngHstEntity.syncState,
|
||||
mapSheetMngHstEntity.syncCheckState,
|
||||
mapSheetMngFileEntity.fileUid,
|
||||
mapSheetMngFileEntity.filePath,
|
||||
mapSheetMngFileEntity.fileName,
|
||||
mapSheetMngFileEntity.fileSize,
|
||||
mapSheetMngFileEntity.fileState)
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
|
||||
.leftJoin(mapInkx50kEntity)
|
||||
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
|
||||
.on(mapSheetMngHstEntity.mapSheetNum.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.leftJoin(mapSheetMngFileEntity)
|
||||
.on(mapSheetMngFileEntity.hstUid.eq(mapSheetMngHstEntity.hstUid))
|
||||
.where(whereBuilder)
|
||||
.orderBy(mapSheetMngHstEntity.createdDate.desc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetMngHstEntity.createdDate.desc())
|
||||
.fetch();
|
||||
|
||||
Map<Long, MapSheetMngDto.ErrorDataDto> resultMap = new LinkedHashMap<>();
|
||||
|
||||
for (Tuple t : tuples) {
|
||||
|
||||
Long hstUid = t.get(mapSheetMngHstEntity.hstUid);
|
||||
|
||||
MapSheetMngDto.ErrorDataDto dto =
|
||||
resultMap.computeIfAbsent(
|
||||
hstUid,
|
||||
id -> {
|
||||
String map50kName =
|
||||
t.get(mapSheetMngHstEntity.mapSheetName)
|
||||
+ t.get(mapSheetMngHstEntity.mapSheetNum).substring(0, 5);
|
||||
|
||||
String map5kName =
|
||||
t.get(mapSheetMngHstEntity.mapSheetName)
|
||||
+ t.get(mapSheetMngHstEntity.mapSheetNum).substring(5, 8);
|
||||
|
||||
String mapSrcName =
|
||||
t.get(mapSheetMngHstEntity.mapSheetName)
|
||||
+ t.get(mapSheetMngHstEntity.mapSheetNum).substring(5, 8);
|
||||
|
||||
MapSheetMngDto.ErrorDataDto newDto =
|
||||
new MapSheetMngDto.ErrorDataDto(
|
||||
id,
|
||||
map50kName,
|
||||
map5kName,
|
||||
mapSrcName,
|
||||
t.get(mapSheetMngHstEntity.mapSheetCodeSrc),
|
||||
t.get(mapSheetMngHstEntity.createdDate),
|
||||
t.get(mapSheetMngHstEntity.syncState),
|
||||
t.get(mapSheetMngHstEntity.syncCheckState));
|
||||
|
||||
newDto.setFileArray(new ArrayList<>());
|
||||
return newDto;
|
||||
});
|
||||
|
||||
// 파일 정보가 있는 경우만 추가
|
||||
Long fileUid = t.get(mapSheetMngFileEntity.fileUid);
|
||||
if (fileUid != null) {
|
||||
MapSheetMngDto.MngFIleDto fileDto = new MapSheetMngDto.MngFIleDto();
|
||||
fileDto.setFileUid(fileUid);
|
||||
fileDto.setFilePath(t.get(mapSheetMngFileEntity.filePath));
|
||||
fileDto.setFileName(t.get(mapSheetMngFileEntity.fileName));
|
||||
fileDto.setFileSize(t.get(mapSheetMngFileEntity.fileSize));
|
||||
fileDto.setFileState(t.get(mapSheetMngFileEntity.fileState));
|
||||
fileDto.setHstUid(hstUid);
|
||||
|
||||
dto.getFileArray().add(fileDto);
|
||||
}
|
||||
}
|
||||
|
||||
List<MapSheetMngDto.ErrorDataDto> foundContent = new ArrayList<>(resultMap.values());
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetMngHstEntity.hstUid.count())
|
||||
|
||||
Reference in New Issue
Block a user