동영상관리 추가 및 수정

This commit is contained in:
Moon
2025-12-12 13:58:35 +09:00
parent dc0f0d9be8
commit b76f2331f1
7 changed files with 261 additions and 126 deletions

View File

@@ -26,17 +26,7 @@ public class MapSheetMngApiController {
private final CommonCodeService commonCodeService; private final CommonCodeService commonCodeService;
private final MapSheetMngService mapSheetMngService; private final MapSheetMngService mapSheetMngService;
/**
* 오류데이터 목록 조회
*
* @param searchReq
* @return
*/
@PostMapping("/error-list")
public ApiResponseDto<Page<MapSheetMngDto.ErrorDataDto>> findMapSheetErrorList(
@RequestBody @Valid MapSheetMngDto.searchReq searchReq) {
return ApiResponseDto.ok(mapSheetMngService.findMapSheetErrorList(searchReq));
}
@Operation(summary = "영상데이터관리목록 조회", description = "영상데이터관리목록 조회") @Operation(summary = "영상데이터관리목록 조회", description = "영상데이터관리목록 조회")
@ApiResponses( @ApiResponses(
@@ -53,7 +43,7 @@ public class MapSheetMngApiController {
}) })
@PostMapping("/mng-list") @PostMapping("/mng-list")
public ApiResponseDto<Page<MapSheetMngDto.MngDto>> findMapSheetMngList( public ApiResponseDto<Page<MapSheetMngDto.MngDto>> findMapSheetMngList(
@RequestBody @Valid MapSheetMngDto.searchReq searchReq) { @RequestBody MapSheetMngDto.MngSearchReq searchReq) {
return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngList(searchReq)); return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngList(searchReq));
} }
@@ -77,6 +67,21 @@ public class MapSheetMngApiController {
return ApiResponseDto.ok(mapSheetMngService.mngDataSave(AddReq)); return ApiResponseDto.ok(mapSheetMngService.mngDataSave(AddReq));
} }
/**
* 오류데이터 목록 조회
*
* @param searchReq
* @return
*/
@PostMapping("/error-list")
public ApiResponseDto<Page<MapSheetMngDto.ErrorDataDto>> findMapSheetErrorList(
@RequestBody @Valid MapSheetMngDto.ErrorSearchReq searchReq) {
return ApiResponseDto.ok(mapSheetMngService.findMapSheetErrorList(searchReq));
}
/** /**
* @param hstUidList * @param hstUidList
* @return * @return
@@ -86,7 +91,7 @@ public class MapSheetMngApiController {
value = { value = {
@ApiResponse( @ApiResponse(
responseCode = "201", responseCode = "201",
description = "공통코드 저장 성공", description = "업로드 처리 성공",
content = content =
@Content( @Content(
mediaType = "application/json", mediaType = "application/json",

View File

@@ -14,12 +14,12 @@ import org.springframework.data.domain.Sort;
public class MapSheetMngDto { public class MapSheetMngDto {
@Schema(name = "searchReq", description = "영상관리 오류데이터 검색 요청") @Schema(name = "MngSearchReq", description = "영상관리 검색 요청")
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class searchReq { public static class MngSearchReq {
// 페이징 파라미터 // 페이징 파라미터
@Schema(description = "페이지 번호 (0부터 시작) ", example = "0") @Schema(description = "페이지 번호 (0부터 시작) ", example = "0")
@@ -28,42 +28,14 @@ public class MapSheetMngDto {
@Schema(description = "페이지 크기", example = "20") @Schema(description = "페이지 크기", example = "20")
private int size = 20; private int size = 20;
@Schema(description = "정렬", example = "id desc")
private String sort;
@Schema(description = "검색어", example = "부산3959")
private String searchValue;
@Schema(description = "년도", example = "2025") @Schema(description = "년도", example = "2025")
private Integer mngYyyy; private Integer mngYyyy;
public Pageable toPageable() { public Pageable toPageable() {
if (sort != null && !sort.isEmpty()) {
String[] sortParams = sort.split(",");
String property = sortParams[0];
Sort.Direction direction =
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
return PageRequest.of(page, size, Sort.by(direction, property));
}
return PageRequest.of(page, size); return PageRequest.of(page, size);
} }
} }
@Schema(name = "ErrorDataDto", description = "영상관리 오류데이터 검색 리턴")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class ErrorDataDto {
private Long hstUid;
private Integer rowNum;
private String map50kName;
private String map5kName;
private Integer mapCodeSrc;
private String createdDttm;
private DataState dataState;
}
@Schema(name = "MngAddReq", description = "영상관리 생성 요청") @Schema(name = "MngAddReq", description = "영상관리 생성 요청")
@Getter @Getter
@Setter @Setter
@@ -98,6 +70,64 @@ public class MapSheetMngDto {
@JsonFormatDttm private ZonedDateTime rgstEndDttm; @JsonFormatDttm private ZonedDateTime rgstEndDttm;
} }
@Schema(name = "ErrorSearchReq", description = "영상관리 오류데이터 검색 요청")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class ErrorSearchReq {
// 페이징 파라미터
@Schema(description = "페이지 번호 (0부터 시작) ", example = "0")
private int page = 0;
@Schema(description = "페이지 크기", example = "20")
private int size = 20;
@Schema(description = "정렬", example = "id desc")
private String sort;
@Schema(description = "검색어", example = "부산3959")
private String searchValue;
@Schema(description = "년도", example = "2025")
private Integer mngYyyy;
public Pageable toPageable() {
if (sort != null && !sort.isEmpty()) {
String[] sortParams = sort.split(",");
String property = sortParams[0];
Sort.Direction direction =
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
return PageRequest.of(page, size, Sort.by(direction, property));
}
return PageRequest.of(page, size);
}
}
@Schema(name = "ErrorDataDto", description = "영상관리 오류데이터 검색 리턴")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class ErrorDataDto {
private Long hstUid;
private Integer rowNum;
private String map50kName;
private String map5kName;
private Integer mapCodeSrc;
private String createdDttm;
private DataState dataState;
}
@Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴") @Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴")
@Getter @Getter
@Setter @Setter

View File

@@ -213,16 +213,17 @@ public class MapSheetMngService {
} }
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList( public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
return mapSheetMngCoreService.findMapSheetErrorList(searchReq); return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
} }
public Page<MapSheetMngDto.MngDto> findMapSheetMngList( public Page<MapSheetMngDto.MngDto> findMapSheetMngList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.MngSearchReq searchReq) {
return mapSheetMngCoreService.findMapSheetMngList(searchReq); return mapSheetMngCoreService.findMapSheetMngList(searchReq);
} }
public MapSheetMngDto.DmlReturn mngDataSave(@Valid MapSheetMngDto.AddReq AddReq) { @Transactional
public MapSheetMngDto.DmlReturn mngDataSave(MapSheetMngDto.AddReq AddReq) {
return mapSheetMngCoreService.mngDataSave(AddReq); return mapSheetMngCoreService.mngDataSave(AddReq);
} }

View File

@@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
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;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@@ -33,12 +34,12 @@ public class MapSheetMngCoreService {
private String activeEnv; private String activeEnv;
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList( public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.@Valid ErrorSearchReq searchReq) {
return mapSheetMngRepository.findMapSheetErrorList(searchReq); return mapSheetMngRepository.findMapSheetErrorList(searchReq);
} }
public Page<MapSheetMngDto.MngDto> findMapSheetMngList( public Page<MapSheetMngDto.MngDto> findMapSheetMngList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.@Valid MngSearchReq searchReq) {
return mapSheetMngRepository.findMapSheetMngList(searchReq); return mapSheetMngRepository.findMapSheetMngList(searchReq);
} }
@@ -132,7 +133,10 @@ public class MapSheetMngCoreService {
entity.setMngYyyy(addReq.getMngYyyy()); entity.setMngYyyy(addReq.getMngYyyy());
entity.setMngPath(addReq.getMngPath()); entity.setMngPath(addReq.getMngPath());
//mapSheetMngRepository.deleteMngAll(addReq.getMngYyyy());
MapSheetMngEntity saved = mapSheetMngRepository.save(entity); MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
int hstCnt = mapSheetMngRepository.insertMapSheetOrgDataToMapSheetMngHst(saved.getMngYyyy());
return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString()); return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString());
} }

View File

@@ -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;
}

View File

@@ -8,10 +8,15 @@ import org.springframework.data.domain.Page;
public interface MapSheetMngRepositoryCustom { 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); Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid);
int insertMapSheetOrgDataToMapSheetMngHst(int mngYyyy);
void deleteMngAll(int mngYyyy);
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid ErrorSearchReq searchReq);
} }

View File

@@ -15,10 +15,13 @@ import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import org.hibernate.query.Query;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@@ -31,67 +34,18 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
private final JPAQueryFactory queryFactory; private final JPAQueryFactory queryFactory;
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)"); private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
@PersistenceContext
private EntityManager em;
public MapSheetMngRepositoryImpl(JPAQueryFactory queryFactory) { public MapSheetMngRepositoryImpl(JPAQueryFactory queryFactory) {
super(MapSheetMngHstEntity.class); super(MapSheetMngHstEntity.class);
this.queryFactory = queryFactory; 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 @Override
public Page<MapSheetMngDto.MngDto> findMapSheetMngList( public Page<MapSheetMngDto.MngDto> findMapSheetMngList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.MngSearchReq searchReq) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
BooleanBuilder whereBuilder = new BooleanBuilder(); BooleanBuilder whereBuilder = new BooleanBuilder();
@@ -100,27 +54,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
whereBuilder.and(mapSheetMngEntity.mngYyyy.eq(searchReq.getMngYyyy())); 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 = List<MapSheetMngDto.MngDto> foundContent =
queryFactory queryFactory
.select( .select(
@@ -183,6 +116,107 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
return new PageImpl<>(foundContent, pageable, countQuery); 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 @Override
public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) { public Optional<MapSheetMngHstEntity> findMapSheetMngHstInfo(Long hstUid) {
return Optional.ofNullable( return Optional.ofNullable(
@@ -192,12 +226,14 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.fetchOne()); .fetchOne());
} }
private NumberExpression<Integer> rowNum() { private NumberExpression<Integer> rowNum() {
return Expressions.numberTemplate( return Expressions.numberTemplate(
Integer.class, "row_number() over(order by {0} desc)", mapSheetMngHstEntity.createdDate); 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())) { if (Objects.isNull(searchReq.getSearchValue())) {
return null; return null;
} }