동영상관리 추가 및 수정
This commit is contained in:
@@ -20,6 +20,7 @@ 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;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,12 +34,12 @@ public class MapSheetMngCoreService {
|
||||
private String activeEnv;
|
||||
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||
return mapSheetMngRepository.findMapSheetErrorList(searchReq);
|
||||
}
|
||||
|
||||
public Page<MapSheetMngDto.MngDto> findMapSheetMngList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
MapSheetMngDto.@Valid MngSearchReq searchReq) {
|
||||
return mapSheetMngRepository.findMapSheetMngList(searchReq);
|
||||
}
|
||||
|
||||
@@ -132,7 +133,10 @@ public class MapSheetMngCoreService {
|
||||
entity.setMngYyyy(addReq.getMngYyyy());
|
||||
entity.setMngPath(addReq.getMngPath());
|
||||
|
||||
//mapSheetMngRepository.deleteMngAll(addReq.getMngYyyy());
|
||||
|
||||
MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
|
||||
int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
|
||||
|
||||
return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_map_sheet_mng_files")
|
||||
public class MapSheetMngFileEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "file_uid", nullable = false)
|
||||
private Long fileUid;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "mng_yyyy", nullable = false)
|
||||
private Integer mngYyyy;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "map_sheet_num", nullable = false)
|
||||
private Integer mapSheetNum;
|
||||
|
||||
@Column(name = "ref_map_sheet_num")
|
||||
private Integer refMapSheetNum;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "file_path")
|
||||
private String filePath;
|
||||
|
||||
@Size(max = 100)
|
||||
@Column(name = "file_name", length = 100)
|
||||
private String fileName;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "file_ext", length = 20)
|
||||
private String fileExt;
|
||||
|
||||
@Column(name = "mng_uid")
|
||||
private Long mngUid;
|
||||
|
||||
@Column(name = "hst_uid")
|
||||
private Long hstUid;
|
||||
|
||||
}
|
||||
@@ -8,10 +8,15 @@ import org.springframework.data.domain.Page;
|
||||
|
||||
public interface MapSheetMngRepositoryCustom {
|
||||
|
||||
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq);
|
||||
|
||||
Page<MapSheetMngDto.MngDto> findMapSheetMngList(MapSheetMngDto.@Valid searchReq searchReq);
|
||||
Page<MapSheetMngDto.MngDto> findMapSheetMngList(MapSheetMngDto.MngSearchReq searchReq);
|
||||
|
||||
Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
|
||||
|
||||
int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy);
|
||||
|
||||
void deleteMngAll(int mngYyyy);
|
||||
|
||||
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,13 @@ 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.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -31,67 +34,18 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
public MapSheetMngRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||
super(MapSheetMngHstEntity.class);
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
List<MapSheetMngDto.ErrorDataDto> foundContent =
|
||||
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))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
|
||||
.leftJoin(mapInkx50kEntity)
|
||||
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
|
||||
.where(
|
||||
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
|
||||
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
|
||||
mapSheetErrorSearchValue(searchReq))
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetMngHstEntity.createdDate.desc())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetMngHstEntity.hstUid.count())
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
|
||||
.leftJoin(mapInkx50kEntity)
|
||||
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
|
||||
.where(
|
||||
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
|
||||
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
|
||||
mapSheetErrorSearchValue(searchReq))
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MapSheetMngDto.MngDto> findMapSheetMngList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
MapSheetMngDto.MngSearchReq searchReq) {
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
@@ -100,27 +54,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
whereBuilder.and(mapSheetMngEntity.mngYyyy.eq(searchReq.getMngYyyy()));
|
||||
}
|
||||
|
||||
/*
|
||||
QMapSheetMngEntity m = mapSheetMngEntity;
|
||||
QMapSheetMngHstEntity h = mapSheetMngHstEntity;
|
||||
|
||||
List<MapSheetSummaryDto> summaryContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MapSheetSummaryDto.class,
|
||||
mapSheetMngHstEntity.mngYyyy,
|
||||
mapSheetMngHstEntity.mngYyyy.count().as("syncTotCnt"),
|
||||
new CaseBuilder()
|
||||
.when(mapSheetMngHstEntity.syncState.eq("DONE")).then(1L).otherwise(0L)
|
||||
.sum().as("syncStateDoneCnt")
|
||||
))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.groupBy(mapSheetMngHstEntity.mngYyyy) // mng_yyyy 별로 그룹핑
|
||||
.fetch();
|
||||
|
||||
*/
|
||||
|
||||
List<MapSheetMngDto.MngDto> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
@@ -183,6 +116,107 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
List<MapSheetMngDto.ErrorDataDto> foundContent =
|
||||
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))
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
|
||||
.leftJoin(mapInkx50kEntity)
|
||||
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
|
||||
.where(
|
||||
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
|
||||
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
|
||||
mapSheetErrorSearchValue(searchReq))
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetMngHstEntity.createdDate.desc())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetMngHstEntity.hstUid.count())
|
||||
.from(mapSheetMngHstEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
|
||||
.leftJoin(mapInkx50kEntity)
|
||||
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
|
||||
.where(
|
||||
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
|
||||
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
|
||||
mapSheetErrorSearchValue(searchReq))
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMngAll(int mngYyyy){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy) {
|
||||
|
||||
String sql = """
|
||||
INSERT INTO tb_map_sheet_mng_hst
|
||||
(
|
||||
mng_yyyy
|
||||
,map_sheet_code
|
||||
,map_sheet_num
|
||||
,map_sheet_name
|
||||
,map_sheet_code_src
|
||||
,scale_ratio
|
||||
,ref_map_sheet_num
|
||||
,use_inference
|
||||
)
|
||||
select
|
||||
:mngYyyy as mng_yyyy
|
||||
,fid as map_sheet_code
|
||||
,mapidcd_no::INTEGER as map_sheet_num
|
||||
,mapid_nm as map_sheet_name
|
||||
,fid as map_sheet_code_src
|
||||
,5000 as scale_ratio
|
||||
,((mapidcd_no::INTEGER)/1000) as ref_map_sheet_num
|
||||
,use_inference
|
||||
from
|
||||
tb_map_inkx_5k
|
||||
""";
|
||||
|
||||
// Native Query 생성 및 실행
|
||||
Query query = (Query) em.createNativeQuery(sql);
|
||||
query.setParameter("mngYyyy", mngYyyy);
|
||||
|
||||
int exeCnt = query.executeUpdate(); // 실행 (영향받은 행의 개수 반환)
|
||||
|
||||
return exeCnt;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) {
|
||||
return Optional.ofNullable(
|
||||
@@ -192,12 +226,14 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private NumberExpression<Integer> rowNum() {
|
||||
return Expressions.numberTemplate(
|
||||
Integer.class, "row_number() over(order by {0} desc)", mapSheetMngHstEntity.createdDate);
|
||||
}
|
||||
|
||||
private BooleanExpression mapSheetErrorSearchValue(MapSheetMngDto.searchReq searchReq) {
|
||||
private BooleanExpression mapSheetErrorSearchValue(MapSheetMngDto.ErrorSearchReq searchReq) {
|
||||
if (Objects.isNull(searchReq.getSearchValue())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user