영상관리 수정 및 추가

This commit is contained in:
Moon
2025-12-11 17:15:48 +09:00
parent 2b38a317ba
commit dbb0dea7ad
12 changed files with 218 additions and 53 deletions

View File

@@ -1,6 +1,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.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
import jakarta.persistence.EntityNotFoundException;
@@ -67,9 +68,11 @@ public class MapSheetMngCoreService {
count += 1;
}
/*
MapSheetMngDto.DataState dataState =
flag ? MapSheetMngDto.DataState.SUCCESS : MapSheetMngDto.DataState.FAIL;
entity.get().updateDataState(dataState);
*/
}
}
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
@@ -84,7 +87,7 @@ public class MapSheetMngCoreService {
.findMapSheetMngHstInfo(hstUid)
.orElseThrow(EntityNotFoundException::new));
entity.get().updateUseInference(true);
// entity.get().updateUseInference(true);
}
}
return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다.");
@@ -122,4 +125,15 @@ public class MapSheetMngCoreService {
throw new RuntimeException("File search error", e);
}
}
public MapSheetMngDto.DmlReturn mngDataSave(@Valid MapSheetMngDto.AddReq addReq) {
MapSheetMngEntity entity = new MapSheetMngEntity();
entity.setMngYyyy(addReq.getMngYyyy());
entity.setMngPath(addReq.getMngPath());
MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString());
}
}

View File

@@ -5,7 +5,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@@ -18,30 +18,32 @@ public class MapSheetMngEntity {
@Id
@Column(name = "mng_yyyy", nullable = false)
private Integer id;
private Integer mngYyyy;
@Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "mng_state", length = 20)
private String mngState;
private String mngState = "NOTYET";
@Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "sync_state", length = 20)
private String syncState;
private String syncState = "NOTYET";
@Column(name = "mng_state_dttm")
private OffsetDateTime mngStateDttm;
private ZonedDateTime mngStateDttm = ZonedDateTime.now();
@Column(name = "sync_state_dttm")
private OffsetDateTime syncStateDttm;
private ZonedDateTime syncStateDttm = ZonedDateTime.now();
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
private ZonedDateTime createdDttm = ZonedDateTime.now();
@Column(name = "created_uid")
private Long createdUid;
@Column(name = "updated_dttm")
private OffsetDateTime updatedDttm;
private ZonedDateTime updatedDttm = ZonedDateTime.now();
@Column(name = "updated_uid")
private Long updatedUid;
@@ -50,4 +52,21 @@ public class MapSheetMngEntity {
@ColumnDefault("'NULL::character varying'")
@Column(name = "mng_path")
private String mngPath;
@Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "sync_check_state", length = 20)
private String syncCheckState = "NOTYET";
@Column(name = "sync_strt_dttm")
private ZonedDateTime syncStrtDttm;
@Column(name = "sync_end_dttm")
private ZonedDateTime syncEndDttm;
@Column(name = "sync_check_strt_dttm")
private ZonedDateTime syncCheckStrtDttm;
@Column(name = "sync_check_end_dttm")
private ZonedDateTime syncCheckEndDttm;
}

View File

@@ -1,8 +1,8 @@
package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import lombok.Getter;
import lombok.Setter;
@@ -35,9 +35,8 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
@Column(name = "scale_ratio")
private Integer scaleRatio;
@Column(name = "data_state")
@Enumerated(EnumType.STRING)
private MapSheetMngDto.DataState dataState;
@Column(name = "data_state", length = 20)
private String dataState;
@Column(name = "data_state_dttm")
private ZonedDateTime dataStateDttm;
@@ -60,13 +59,23 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
@Column(name = "updated_uid")
private Long updatedUid;
public void updateDataState(MapSheetMngDto.DataState dataState) {
this.dataState = dataState;
this.dataStateDttm = ZonedDateTime.now();
}
@Size(max = 20)
@Column(name = "sync_state", length = 20)
private String syncState;
public void updateUseInference(Boolean useInference) {
this.useInference = useInference;
this.useInferenceDttm = ZonedDateTime.now();
}
@Size(max = 20)
@Column(name = "sync_check_state", length = 20)
private String syncCheckState;
@Column(name = "sync_strt_dttm")
private ZonedDateTime syncStrtDttm;
@Column(name = "sync_end_dttm")
private ZonedDateTime syncEndDttm;
@Column(name = "sync_check_strt_dttm")
private ZonedDateTime syncCheckStrtDttm;
@Column(name = "sync_check_end_dttm")
private ZonedDateTime syncCheckEndDttm;
}

View File

@@ -7,6 +7,7 @@ import java.util.Optional;
import org.springframework.data.domain.Page;
public interface MapSheetMngRepositoryCustom {
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq);

View File

@@ -10,6 +10,7 @@ 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.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression;
@@ -64,7 +65,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
.where(
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
mapSheetErrorSearchValue(searchReq))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
@@ -81,7 +82,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
.where(
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
// mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
mapSheetErrorSearchValue(searchReq))
.fetchOne();
@@ -96,9 +97,30 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
BooleanBuilder whereBuilder = new BooleanBuilder();
if (searchReq.getMngYyyy() != null) {
whereBuilder.and(mapSheetMngEntity.id.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 =
queryFactory
.select(
@@ -108,30 +130,52 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
Integer.class,
"row_number() over(order by {0} desc)",
mapSheetMngEntity.createdDttm),
mapSheetMngEntity.id,
mapSheetMngEntity.mngYyyy,
mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState,
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.mngStateDttm),
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.syncStateDttm),
mapSheetMngEntity.mngPath,
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.createdDttm),
mapSheetMngEntity.createdUid,
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.updatedDttm),
mapSheetMngEntity.updatedUid))
mapSheetMngEntity.syncCheckState,
mapSheetMngHstEntity.count(),
new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.eq("DONE"))
.then(1L)
.otherwise(0L)
.sum()
.as("syncStateDoneCnt"),
new CaseBuilder()
.when(mapSheetMngHstEntity.syncCheckState.eq("DONE"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("NOT"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("TYPEERROR"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("SIZEERROR"))
.then(1L)
.otherwise(0L)
.sum(),
mapSheetMngHstEntity.syncStrtDttm.min(),
mapSheetMngHstEntity.syncCheckEndDttm.max()))
.from(mapSheetMngEntity)
.leftJoin(mapSheetMngHstEntity)
.on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
.where(whereBuilder)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(mapSheetMngEntity.createdDttm.desc())
.groupBy(mapSheetMngEntity.mngYyyy)
.fetch();
Long countQuery =
queryFactory
.select(mapSheetMngEntity.id.count())
.select(mapSheetMngEntity.mngYyyy.count())
.from(mapSheetMngEntity)
.where(whereBuilder)
.fetchOne();