파일 체크 수정 및 패키지 분리
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
@@ -125,23 +126,6 @@ public class MapSheetMngCoreService {
|
||||
}
|
||||
|
||||
|
||||
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
||||
int count = 0;
|
||||
|
||||
//대상파일목록 가저오기
|
||||
Page<ImageryDto.SyncDto> pageImagerySyncDto = mapSheetMngRepository.findImageryList(searchReq);
|
||||
//List<ImagerySyncDto> imagerySyncDtoList = pageImagerySyncDto.getContent();
|
||||
|
||||
for (ImageryDto.SyncDto dto : pageImagerySyncDto.getContent()) {
|
||||
// 여기에 처리 로직 작성
|
||||
System.out.println("ID: " + dto.getId());
|
||||
|
||||
// 예: 특정 작업 수행
|
||||
// someService.process(dto);
|
||||
}
|
||||
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
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 jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MapSheetMngFileCheckerCoreService {
|
||||
|
||||
private final MapSheetMngFileCheckerRepository mapSheetMngFileCheckerRepository;
|
||||
|
||||
private static final String ORIGINAL_IMAGES_PATH = "/app/original-images";
|
||||
|
||||
@Value("{spring.profiles.active}")
|
||||
private String activeEnv;
|
||||
|
||||
|
||||
public MapSheetMngDto.DmlReturn syncProcess(ImageryDto.searchReq searchReq) {
|
||||
int count = 0;
|
||||
|
||||
//대상파일목록 가저오기
|
||||
Page<ImageryDto.SyncDto> pageImagerySyncDto = mapSheetMngFileCheckerRepository.findImagerySyncList(searchReq);
|
||||
|
||||
|
||||
for (ImageryDto.SyncDto dto : pageImagerySyncDto.getContent()) {
|
||||
|
||||
boolean isTfwFile = true;
|
||||
isTfwFile = FIleChecker.checkTfw(dto.getMiddlePath()+dto.getFilename());
|
||||
|
||||
//boolean isCogTiffFile = true;
|
||||
//isCogTiffFile = FIleChecker.checkGeoTiff("D:\\kamco_cog\\36713\\36713073_cog.tif");
|
||||
|
||||
boolean isGdalInfoTiffFile = true;
|
||||
//isGdalInfoTiffFile = FIleChecker.cmmndGdalInfo("D:\\kamco_cog\\36713\\36713073_cog.tif");
|
||||
isGdalInfoTiffFile = FIleChecker.cmmndGdalInfo("D:/kamco_cog/36713/36713073_cog.tif");
|
||||
|
||||
System.out.println("isTfwFile == " + isTfwFile);
|
||||
System.out.println("isGdalInfoTiffFile == " + isGdalInfoTiffFile);
|
||||
// 여기에 처리 로직 작성
|
||||
|
||||
|
||||
// 예: 특정 작업 수행
|
||||
// someService.process(dto);
|
||||
}
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface MapSheetMngFileCheckerRepository
|
||||
extends JpaRepository<MapSheetMngEntity, Long>, MapSheetMngFileCheckerRepositoryCustom {}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface MapSheetMngFileCheckerRepositoryCustom {
|
||||
|
||||
Page<ImageryDto.SyncDto> findImagerySyncList(ImageryDto.@Valid searchReq searchReq);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QImageryEntity.imageryEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
public class MapSheetMngFileCheckerRepositoryImpl extends QuerydslRepositorySupport
|
||||
implements MapSheetMngFileCheckerRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
public MapSheetMngFileCheckerRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||
super(MapSheetMngHstEntity.class);
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<ImageryDto.SyncDto> findImagerySyncList(ImageryDto.@Valid searchReq searchReq) {
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
|
||||
if (searchReq.getMngYyyy() != null) {
|
||||
whereBuilder.and(imageryEntity.year.eq(searchReq.getMngYyyy()));
|
||||
}
|
||||
|
||||
List<ImageryDto.SyncDto> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ImageryDto.SyncDto.class,
|
||||
imageryEntity.id,
|
||||
imageryEntity.year,
|
||||
imageryEntity.scene50k,
|
||||
imageryEntity.scene5k,
|
||||
imageryEntity.middlePath,
|
||||
imageryEntity.cogMiddlePath,
|
||||
imageryEntity.filename,
|
||||
imageryEntity.cogFilename,
|
||||
mapSheetMngHstEntity.hstUid
|
||||
)
|
||||
)
|
||||
.from(imageryEntity)
|
||||
.leftJoin(mapSheetMngHstEntity).on(
|
||||
imageryEntity.year.eq(mapSheetMngHstEntity.mngYyyy)
|
||||
.and(imageryEntity.scene5k.eq(mapSheetMngHstEntity.mapSheetNum.stringValue())))
|
||||
.where(whereBuilder)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
//.orderBy(mapSheetMngEntity.createdDttm.desc())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(imageryEntity.id.count())
|
||||
.from(imageryEntity)
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private NumberExpression<Integer> rowNum() {
|
||||
return Expressions.numberTemplate(
|
||||
Integer.class, "row_number() over(order by {0} desc)", mapSheetMngHstEntity.createdDate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,5 @@ public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
||||
|
||||
Page<ImageryDto.SyncDto> findImageryList(ImageryDto.@Valid searchReq searchReq);
|
||||
|
||||
}
|
||||
|
||||
@@ -141,48 +141,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ImageryDto.SyncDto> findImageryList(ImageryDto.@Valid searchReq searchReq) {
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
|
||||
if (searchReq.getMngYyyy() != null) {
|
||||
whereBuilder.and(imageryEntity.year.eq(searchReq.getMngYyyy()));
|
||||
}
|
||||
|
||||
List<ImageryDto.SyncDto> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ImageryDto.SyncDto.class,
|
||||
imageryEntity.id,
|
||||
imageryEntity.year,
|
||||
imageryEntity.scene50k,
|
||||
imageryEntity.scene5k,
|
||||
imageryEntity.middlePath,
|
||||
imageryEntity.cogMiddlePath,
|
||||
imageryEntity.filename,
|
||||
imageryEntity.cogFilename
|
||||
)
|
||||
)
|
||||
.from(imageryEntity)
|
||||
.where(whereBuilder)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
//.orderBy(mapSheetMngEntity.createdDttm.desc())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(imageryEntity.id.count())
|
||||
.from(imageryEntity)
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) {
|
||||
@@ -214,7 +172,4 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user