Merge pull request 'feat: polishing' (#121) from feat/dean/KC-68-other into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/121
This commit is contained in:
admin
2025-12-30 10:12:45 +09:00
18 changed files with 368 additions and 45 deletions

View File

@@ -0,0 +1,22 @@
package com.kamco.cd.kamcoback.common.enums;
import lombok.EqualsAndHashCode;
import lombok.Getter;
public class ApiConfigEnum {
@Getter
@EqualsAndHashCode(of = "enumValue")
public static class EnumDto<T> {
private final T enumValue;
private final String id;
private final String text;
public EnumDto(T enumValue, String id, String text) {
this.enumValue = enumValue;
this.id = id;
this.text = text;
}
}
}

View File

@@ -0,0 +1,40 @@
package com.kamco.cd.kamcoback.common.enums;
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* Common usage status used across the system.
*
* <p>This enum represents whether a resource is active, excluded from processing, or inactive. It
* is commonly used for filtering, business rules, and status management.
*/
@Getter
@AllArgsConstructor
public enum CommonUseStatus implements EnumType {
// @formatter:off
USE("USE", "Active", 100)
/** Actively used and available */
,
EXCEPT("EXCEPT", "Excluded", 200)
/** Explicitly excluded from use or processing */
,
NOT_USE("NOT_USE", "Inactive", 999)
/** Not used or disabled */
;
// @formatter:on
private String id;
private String text;
private int ordering;
public static CommonUseStatus getEnumById(String id) {
return Arrays.stream(CommonUseStatus.values())
.filter(x -> x.getId().equals(id))
.findFirst()
.orElse(CommonUseStatus.NOT_USE);
}
}

View File

@@ -40,9 +40,9 @@ public class MapSheetMngApiV2Controller {
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@GetMapping("/mng-year-list")
public ApiResponseDto<MapSheetMngDto.ResisterYearList> findMapSheetMngYyyyList() {
public ApiResponseDto<MapSheetMngDto.ResisterYearList> getListMapListYYYYLimit10() {
List<Integer> years = mapSheetMngService.findMapSheetMngYyyyList();
List<Integer> years = mapSheetMngService.getListMapListYYYYLimit10();
// 현재 년도 가져온다
int currentYear = Year.now().getValue();

View File

@@ -2,12 +2,14 @@ package com.kamco.cd.kamcoback.mapsheet.dto;
import com.kamco.cd.kamcoback.common.enums.MngStateType;
import com.kamco.cd.kamcoback.common.enums.SyncStateType;
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
import com.kamco.cd.kamcoback.common.utils.enums.Enums;
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -350,4 +352,58 @@ public class MapSheetMngDto {
this.years = years;
}
}
@Getter
@AllArgsConstructor
public enum MapSheetState implements EnumType {
// @formatter:off
DONE("완료"),
NOTYET("처리대기");
// @formatter:on
private final String message;
@Override
public String getId() {
return name();
}
@Override
public String getText() {
return message;
}
}
// 연도리스틀 조회시 사용하는 request Dto
@Getter
@Setter
@NoArgsConstructor
public static class YearSearchReq {
private String status;
// 페이징 파라미터
private int page = 0;
private int size = 20;
private String sort;
@Builder
public YearSearchReq(String status, int page, int size, String sort) {
this.status = status;
this.page = page;
this.size = size;
this.sort = sort;
}
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);
}
}
}

View File

@@ -12,13 +12,16 @@ import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.ErrorDataDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.ErrorSearchReq;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngFilesDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
import jakarta.validation.Valid;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Comparator;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
@@ -51,6 +54,16 @@ public class MapSheetMngService {
return mapSheetMngCoreService.findMapSheetMngYyyyList();
}
public List<Integer> getListMapListYYYYLimit10() {
YearSearchReq req = YearSearchReq.builder().status("NOTYET").page(0).size(10).build();
// List조회
Page<YearEntity> years = mapSheetMngCoreService.getListMapListYYYYWithPaging(req);
return years.map(YearEntity::getYyyy).getContent().stream()
.sorted(Comparator.reverseOrder())
.toList();
}
public MngDto findMapSheetMng(int mngYyyy) {
return mapSheetMngCoreService.findMapSheetMng(mngYyyy);
}

View File

@@ -1,7 +1,10 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx50kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.kamco.cd.kamcoback.postgres.repository.scene.MapInkx50kRepository;
import com.kamco.cd.kamcoback.postgres.repository.scene.MapInkx5kRepository;
@@ -9,12 +12,16 @@ import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.UseInferReq;
import jakarta.persistence.EntityNotFoundException;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.locationtech.jts.geom.Polygon;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@RequiredArgsConstructor
public class MapInkxMngCoreService {
@@ -24,7 +31,7 @@ public class MapInkxMngCoreService {
// 목록
public Page<MapInkxMngDto.MapList> findMapInkxMngList(
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal) {
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal) {
return mapInkx5kRepository.findMapInkxMngList(searchReq, useInference, searchVal);
}
@@ -37,21 +44,20 @@ public class MapInkxMngCoreService {
return new ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 등록된 도엽코드 입니다.");
}
Integer fid50k = mapInkx50kRepository.findByMapidCdParentNo(req.getMapidcdNo());
if (fid50k == null) {
MapInkx50kEntity mapInkx50k = mapInkx50kRepository.findByMapidCdParentNo(req.getMapidcdNo());
if (mapInkx50k == null) {
return new ResponseObj(ApiResponseCode.NOT_FOUND_DATA, "1:50,000 도엽의 정보가 없습니다. 관리자에게 문의하세요.");
}
MapInkx5kEntity entity =
new MapInkx5kEntity(
req.getMapidcdNo(), req.getMapidNm(), map_polygon, fid50k, "USE" // 기본은 USE로
);
new MapInkx5kEntity(req.getMapidcdNo(), req.getMapidNm(), map_polygon, mapInkx50k);
mapInkx5kRepository.save(entity);
return new ResponseObj(ApiResponseCode.OK, "");
}
// 도엽의 사용여부를 변경한다.
public ResponseObj updateUseInference(@Valid UseInferReq useInferReq) {
Optional<MapInkx5kEntity> entity =
Optional.ofNullable(
@@ -62,4 +68,37 @@ public class MapInkxMngCoreService {
entity.get().updateUseInference(useInferReq.getUseInference());
return new ResponseObj(ApiResponseCode.OK, "");
}
/**
* Updates the inference usage status of a given map sheet (도엽) based on the provided scene ID and
* usage status. 도엽의 사용여부를 변경한다.
*
* @param sceneId5k the unique identifier for the map sheet whose usage status is being updated
* @param useStatus the new usage status to be set for the specified map sheet
* @return a ResponseObj indicating the outcome of the operation, including a response code and
* message
* @throws EntityNotFoundException if no map sheet is found for the provided scene ID
*/
@Transactional
public MapSheet updateUseInference(
@NotNull String sceneId5k, @NotNull CommonUseStatus useStatus) {
log.debug("[updateUseInference]CHANGE_SCENE STATUS start: {}", sceneId5k);
// 5k도엽 정보를 가져온다.
MapInkx5kEntity getScene5k =
mapInkx5kRepository
.findByMapidCdNoInfo(sceneId5k)
.orElseThrow(() -> new EntityNotFoundException("도엽정보를 찾을 수 없습니다."));
log.debug(
"[updateUseInference]CHANGE_SCENE STATUS: {} |BEFORE {} |AFTER {}",
sceneId5k,
getScene5k.getUseInference(),
useStatus);
// 상태를 업데이트한다.
getScene5k.updateUseInference(useStatus);
return getScene5k.toEntity();
}
}

View File

@@ -1,8 +1,10 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
import jakarta.persistence.EntityNotFoundException;
import jakarta.validation.Valid;
@@ -13,6 +15,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
@@ -31,6 +34,18 @@ public class MapSheetMngCoreService {
return mapSheetMngRepository.findMapSheetMngYyyyList();
}
/**
* 영상등록이 가능한 연도리스트
*
* @param req
* @return
*/
@Transactional(readOnly = true)
public Page<YearEntity> getListMapListYYYYWithPaging(YearSearchReq req) {
return mapSheetMngRepository.getYears(req);
}
public MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy) {
return mapSheetMngRepository.findMapSheetMng(mngYyyy);
}

View File

@@ -1,13 +1,19 @@
package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import lombok.Getter;
@@ -39,22 +45,28 @@ public class MapInkx5kEntity extends CommonDateEntity {
@Column(name = "geom")
private Geometry geom;
@Column(name = "fid_k50")
private Integer fidK50;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fid_k50", referencedColumnName = "fid")
private MapInkx50kEntity mapInkx50k;
// 사용상태 USE,
@Column(name = "use_inference")
private String useInference;
@Enumerated(EnumType.STRING)
private CommonUseStatus useInference;
// Constructor
public MapInkx5kEntity(
String mapidcdNo, String mapidNm, Geometry geom, Integer fidK50, String useInference) {
String mapidcdNo, String mapidNm, Geometry geom, MapInkx50kEntity mapInkx50k) {
this.mapidcdNo = mapidcdNo;
this.mapidNm = mapidNm;
this.geom = geom;
this.fidK50 = fidK50;
this.useInference = useInference;
this.mapInkx50k = mapInkx50k;
// 생성시 default 사용함 (사용,제외,사용안함)
this.useInference = CommonUseStatus.USE;
}
public void updateUseInference(String useInference) {
// 변경 사용상태 (추론사용여부)
public void updateUseInference(CommonUseStatus useInference) {
this.useInference = useInference;
}

View File

@@ -1,37 +1,92 @@
package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
/**
* This class represents the entity for managing the history of map sheets. It is mapped to the
* database table "tb_map_sheet_mng_hst" and contains various properties related to the 1:5k map
* sheet information, as well as metadata for file synchronization and management.
*
* <p>This entity: - Includes a primary key (hstUid) for unique identification. - Maintains
* information associated with map sheets such as code, name, scale ratio, and paths. - Tracks
* states, timestamps, and data synchronization details. - Maintains relationships with the
* `MapInkx5kEntity` entity through a many-to-one association. - Provides functionality to update
* file information and sizes (`tifSizeBytes`, `tfwSizeBytes`, and `totalSizeBytes`).
*
* <p>It extends the `CommonDateEntity` class to include common date management fields, such as
* creation and modification timestamps.
*
* <p>The `@Getter` annotation generates getter methods for all fields, while the access to setters
* is restricted to enforce controlled modifications. The entity uses `@NoArgsConstructor` with
* `AccessLevel.PROTECTED` to restrict direct instantiation. The `updateFileInfos` method allows
* dynamic updates of specific file information.
*
* <p>Fields include: - hstUid: Unique identifier for the history record. - mngYyyy: Year associated
* with the management record. - mapInkx5kByCode: Reference to the related `MapInkx5kEntity` object.
* - mapSheetNum: Map sheet number identifying specific map. - mapSheetName: Name of the map sheet.
* - mapSheetCodeSrc: Source code of the map sheet. - scaleRatio: Scale ratio of the map. -
* dataState: State/status of the map sheet data. - dataStateDttm: Timestamp of the data state. -
* useInference: Indicator or metadata for inference usage. - useInferenceDttm: Timestamp for
* inference-related use. - mapSheetPath: Path or location of the map sheet file. - refMapSheetNum:
* Reference to a related map sheet number. - createdUid: User ID of the record creator. -
* updatedUid: User ID of the last updater. - syncState and related fields: Fields to manage
* synchronization states and processes. - tifSizeBytes, tfwSizeBytes, totalSizeBytes: Fields to
* track file size details. - sync file name fields: Stores names of files relevant for
* synchronization and verification.
*
* <p>This entity is essential for tracking and managing map sheet revisions, status, and usage in a
* system leveraging 1:5k map data.
*/
@Getter
@Setter
// entity의 접근제어를 위해 @setter를 사용 x
// @Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
// 영상관리이력
@Table(name = "tb_map_sheet_mng_hst")
public class MapSheetMngHstEntity extends CommonDateEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "hst_uid")
private Long hstUid;
private Long hstUid; // id
@Column(name = "mng_yyyy")
private Integer mngYyyy;
private Integer mngYyyy; // 년도
@Column(name = "map_sheet_code")
private Integer mapSheetCode;
// JPA 연관관계: MapInkx5k 참조 (PK 기반) 소속도엽번호 1:5k
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "map_sheet_code", referencedColumnName = "fid")
private MapInkx5kEntity mapInkx5kByCode;
// TODO 1:5k 관련 정보 추후 제거 필요
@Column(name = "map_sheet_num")
private String mapSheetNum;
private String mapSheetNum; // 도엽번호
@Column(name = "map_sheet_name")
private String mapSheetName;
// TODO END
// 도엽파일이 저장된 경로
@Column(name = "map_sheet_code_src")
private Integer mapSheetCodeSrc;
// 도엽비율?
@Column(name = "scale_ratio")
private Integer scaleRatio;
@@ -103,4 +158,13 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
@Size(max = 100)
@Column(name = "sync_check_tfw_file_name", length = 100)
private String syncCheckTfwFileName;
// 파일정보 업데이트
public void updateFileInfos(Long tifSizeBytes, Long tfwSizeBytes) {
tifSizeBytes = tifSizeBytes == null ? 0L : tifSizeBytes;
tfwSizeBytes = tfwSizeBytes == null ? 0L : tfwSizeBytes;
this.tifSizeBytes = tifSizeBytes;
this.tfwSizeBytes = tfwSizeBytes;
this.totalSizeBytes = tifSizeBytes + tfwSizeBytes;
}
}

View File

@@ -1,7 +1,9 @@
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
import jakarta.validation.Valid;
import java.util.List;
import java.util.Optional;
@@ -61,4 +63,6 @@ public interface MapSheetMngRepositoryCustom {
void updateHstFileSizes(Long hstUid, long tifSizeBytes, long tfwSizeBytes, long totalSizeBytes);
int findByYearFileNameFileCount(int mngYyyy, String fileName);
Page<YearEntity> getYears(YearSearchReq req);
}

View File

@@ -8,7 +8,10 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSh
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.entity.QYearEntity;
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
@@ -390,10 +393,9 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
queryFactory
.select(mapSheetMngHstEntity.hstUid.count())
.from(mapSheetMngHstEntity)
.innerJoin(mapInkx5kEntity)
.on(mapSheetMngHstEntity.mapSheetCode.eq(mapInkx5kEntity.fid))
.leftJoin(mapInkx50kEntity)
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid))
.innerJoin(mapInkx5kEntity, mapSheetMngHstEntity.mapInkx5kByCode)
.fetchJoin()
.leftJoin(mapInkx5kEntity.mapInkx50k, mapInkx50kEntity)
.where(whereBuilder)
.fetchOne();
@@ -795,6 +797,35 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
query.executeUpdate();
}
@Override
public Page<YearEntity> getYears(YearSearchReq req) {
Pageable pageable = req.toPageable();
// LISTS
List<YearEntity> content =
queryFactory
.selectFrom(yearEntity)
.where(eqYearStatus(yearEntity, req.getStatus()))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(yearEntity.yyyy.asc())
.fetch();
// count 쿼리
Long total =
queryFactory
.select(yearEntity.yyyy.count())
.from(yearEntity)
.where(eqYearStatus(yearEntity, req.getStatus()))
.fetchOne();
return new PageImpl<>(content, pageable, total);
}
private BooleanExpression eqYearStatus(QYearEntity years, String status) {
if (status == null) {
return null;
}
return years.status.eq(status);
}
private NumberExpression<Integer> rowNum() {
return Expressions.numberTemplate(
Integer.class, "row_number() over(order by {0} desc)", mapSheetMngHstEntity.createdDate);

View File

@@ -1,6 +1,8 @@
package com.kamco.cd.kamcoback.postgres.repository.scene;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx50kEntity;
public interface MapInkx50kRepositoryCustom {
Integer findByMapidCdParentNo(String mapidcdNo);
MapInkx50kEntity findByMapidCdParentNo(String mapidcdNo);
}

View File

@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.repository.scene;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx50kEntity.mapInkx50kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx50kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
@@ -17,11 +18,10 @@ public class MapInkx50kRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public Integer findByMapidCdParentNo(String mapidcdNo) {
public MapInkx50kEntity findByMapidCdParentNo(String mapidcdNo) {
String parentCd = mapidcdNo.substring(0, 5);
return queryFactory
.select(mapInkx50kEntity.fid)
.from(mapInkx50kEntity)
.selectFrom(mapInkx50kEntity)
.where(mapInkx50kEntity.mapidcdNo.eq(parentCd))
.fetchOne();
}

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.scene;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.MapList;
@@ -12,7 +13,7 @@ public interface MapInkx5kRepositoryCustom {
List<MapInkx5kEntity> listGetScenes5k(List<String> codes);
Page<MapList> findMapInkxMngList(
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal);
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal);
Long findByMapidCdNoExists(String mapidcdNo);

View File

@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.scene;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx50kEntity.mapInkx50kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
@@ -42,7 +43,7 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
@Override
public Page<MapList> findMapInkxMngList(
searchReq searchReq, String useInference, String searchVal) {
searchReq searchReq, CommonUseStatus useInference, String searchVal) {
Pageable pageable = searchReq.toPageable();
List<MapInkxMngDto.MapList> foundContent =
@@ -65,8 +66,8 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
// mapInkx5kEntity.modifiedDate),
mapInkx5kEntity.useInference))
.from(mapInkx5kEntity)
.innerJoin(mapInkx50kEntity)
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid))
.innerJoin(mapInkx5kEntity.mapInkx50k, mapInkx50kEntity)
.fetchJoin()
.where(searchUseInference(useInference), searchValueMapCdNm(searchVal))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
@@ -77,8 +78,8 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
queryFactory
.select(mapInkx5kEntity.count())
.from(mapInkx5kEntity)
.innerJoin(mapInkx50kEntity)
.on(mapInkx5kEntity.fidK50.intValue().eq(mapInkx50kEntity.fid))
.innerJoin(mapInkx5kEntity.mapInkx50k, mapInkx50kEntity)
.fetchJoin()
.where(searchUseInference(useInference), searchValueMapCdNm(searchVal))
.fetchOne();
@@ -103,7 +104,7 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
.fetchOne());
}
private BooleanExpression searchUseInference(String useInference) {
private BooleanExpression searchUseInference(CommonUseStatus useInference) {
if (Objects.isNull(useInference)) {
return null;
}

View File

@@ -1,7 +1,10 @@
package com.kamco.cd.kamcoback.scene;
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
import com.kamco.cd.kamcoback.scene.service.MapInkxMngService;
import io.swagger.v3.oas.annotations.Operation;
@@ -46,7 +49,7 @@ public class MapInkxMngApiController {
public ApiResponseDto<Page<MapInkxMngDto.MapList>> findMapInkxMngList(
@RequestParam int page,
@RequestParam(defaultValue = "20") int size,
@RequestParam(required = false) String useInference,
@RequestParam(required = false) CommonUseStatus useInference,
@RequestParam(required = false) String searchVal) {
MapInkxMngDto.searchReq searchReq = new MapInkxMngDto.searchReq(page, size, "");
return ApiResponseDto.ok(
@@ -108,6 +111,7 @@ public class MapInkxMngApiController {
@RequestBody
@Valid
MapInkxMngDto.UseInferReq useInferReq) {
return ApiResponseDto.okObject(mapInkxMngService.updateUseInference(useInferReq));
mapInkxMngService.updateUseInference(useInferReq);
return ApiResponseDto.okObject(new ResponseObj(ApiResponseCode.OK, ""));
}
}

View File

@@ -1,9 +1,11 @@
package com.kamco.cd.kamcoback.scene.dto;
import com.fasterxml.jackson.databind.JsonNode;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.EntityNotFoundException;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@@ -48,7 +50,6 @@ public class MapInkxMngDto {
private String mapidcdNo;
private String mapidNm;
private JsonNode geom;
private Integer fidK50;
private String useInference;
private ZonedDateTime createdDttm;
private ZonedDateTime updatedDttm;
@@ -152,6 +153,18 @@ public class MapInkxMngDto {
public static class UseInferReq {
private String mapidcdNo;
private String useInference;
private CommonUseStatus useInference; // 변경하고자하는 상태
public void valid() {
if (mapidcdNo == null || mapidcdNo.isEmpty()) {
throw new IllegalArgumentException("도엽번호는 필수 입력값입니다.");
}
// 공백제거
mapidcdNo = mapidcdNo.trim();
if (!mapidcdNo.matches("^\\d{8}$")) {
throw new EntityNotFoundException("도엽번호는 8자리 숫자로 구성되어야 합니다.");
}
}
}
}

View File

@@ -1,6 +1,8 @@
package com.kamco.cd.kamcoback.scene.service;
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
import com.kamco.cd.kamcoback.postgres.core.MapInkxMngCoreService;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.MapList;
@@ -15,6 +17,7 @@ import org.locationtech.jts.geom.LinearRing;
import org.locationtech.jts.geom.PrecisionModel;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@@ -23,7 +26,7 @@ public class MapInkxMngService {
private final MapInkxMngCoreService mapInkxMngCoreService;
public Page<MapList> findMapInkxMngList(
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal) {
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal) {
return mapInkxMngCoreService.findMapInkxMngList(searchReq, useInference, searchVal);
}
@@ -52,7 +55,10 @@ public class MapInkxMngService {
return mapInkxMngCoreService.saveMapInkx5k(req, GEOMETRY_FACTORY.createPolygon(shell));
}
public ResponseObj updateUseInference(@Valid UseInferReq useInferReq) {
return mapInkxMngCoreService.updateUseInference(useInferReq);
// 도엽의 상태를 업데이트한다.
@Transactional
public MapSheet updateUseInference(@Valid UseInferReq useInferReq) {
return mapInkxMngCoreService.updateUseInference(
useInferReq.getMapidcdNo(), useInferReq.getUseInference());
}
}