Geojson Polygon DATA Operating System Build Complete - Daniel C No.5
This commit is contained in:
@@ -28,16 +28,21 @@ public class AuthCoreService {
|
||||
|
||||
/**
|
||||
* 시퀀스 id로 관리자 조회
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public AuthDto.Basic findUserById(Long id){
|
||||
UserEntity entity = authRepository.findUserById(id).orElseThrow(() -> new EntityNotFoundException("관리자를 찾을 수 없습니다. " + id));
|
||||
public AuthDto.Basic findUserById(Long id) {
|
||||
UserEntity entity =
|
||||
authRepository
|
||||
.findUserById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("관리자를 찾을 수 없습니다. " + id));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,8 @@ public class ChangeDetectionCoreService {
|
||||
// 중심 좌표 계산
|
||||
Point centroid = polygon.getCentroid();
|
||||
|
||||
return new ChangeDetectionDto.TestDto(p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
return new ChangeDetectionDto.TestDto(
|
||||
p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -39,14 +40,14 @@ public class ChangeDetectionCoreService {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
return list.stream()
|
||||
.map(
|
||||
s -> {
|
||||
try {
|
||||
return mapper.readTree(s);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.map(
|
||||
s -> {
|
||||
try {
|
||||
return mapper.readTree(s);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,9 @@ import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -149,5 +146,4 @@ public class MapSheetAnalDataEntity {
|
||||
|
||||
@Column(name = "ref_map_sheet_num")
|
||||
private Long refMapSheetNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -87,14 +87,12 @@ public class UserEntity {
|
||||
|
||||
public AuthDto.Basic toDto() {
|
||||
return new AuthDto.Basic(
|
||||
this.id,
|
||||
this.userAuth,
|
||||
this.userNm,
|
||||
this.userId,
|
||||
this.empId,
|
||||
this.userEmail,
|
||||
this.createdDttm
|
||||
) ;
|
||||
|
||||
this.id,
|
||||
this.userAuth,
|
||||
this.userNm,
|
||||
this.userId,
|
||||
this.empId,
|
||||
this.userEmail,
|
||||
this.createdDttm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.kamco.cd.kamcoback.postgres.repository;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnDataGeomEntity;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
public interface MapSheetLearnDataGeomRepository
|
||||
@@ -24,4 +28,40 @@ public interface MapSheetLearnDataGeomRepository
|
||||
|
||||
/** 데이터 UID로 기존 지오메트리 데이터 삭제 (재생성 전에 사용) */
|
||||
void deleteByDataUid(Long dataUid);
|
||||
|
||||
/**
|
||||
* PostGIS 함수를 사용하여 geometry 데이터를 직접 삽입
|
||||
* ST_SetSRID(ST_GeomFromGeoJSON(...), 5186) 형식으로 저장
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = """
|
||||
INSERT INTO tb_map_sheet_learn_data_geom (
|
||||
geo_uid, cd_prob, class_before_name, class_before_prob,
|
||||
class_after_name, class_after_prob, map_sheet_num,
|
||||
before_yyyy, after_yyyy, area, geom, geo_type, data_uid,
|
||||
created_dttm, updated_dttm
|
||||
) VALUES (
|
||||
:geoUid, :cdProb, :classBeforeName, :classBeforeProb,
|
||||
:classAfterName, :classAfterProb, :mapSheetNum,
|
||||
:beforeYyyy, :afterYyyy, :area,
|
||||
ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geometryJson AS TEXT)), 5186),
|
||||
:geoType, :dataUid, NOW(), NOW()
|
||||
) ON CONFLICT (geo_uid) DO NOTHING
|
||||
""", nativeQuery = true)
|
||||
void insertWithPostGISGeometry(
|
||||
@Param("geoUid") Long geoUid,
|
||||
@Param("cdProb") Double cdProb,
|
||||
@Param("classBeforeName") String classBeforeName,
|
||||
@Param("classBeforeProb") Double classBeforeProb,
|
||||
@Param("classAfterName") String classAfterName,
|
||||
@Param("classAfterProb") Double classAfterProb,
|
||||
@Param("mapSheetNum") Long mapSheetNum,
|
||||
@Param("beforeYyyy") Integer beforeYyyy,
|
||||
@Param("afterYyyy") Integer afterYyyy,
|
||||
@Param("area") Double area,
|
||||
@Param("geometryJson") String geometryJson,
|
||||
@Param("geoType") String geoType,
|
||||
@Param("dataUid") Long dataUid
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,17 +63,19 @@ public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
|
||||
/**
|
||||
* 유저 시퀀스 id로 조회
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<UserEntity> findUserById(Long id) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory.selectFrom(userEntity).where(userEntity.id.eq(id)).fetchOne());
|
||||
queryFactory.selectFrom(userEntity).where(userEntity.id.eq(id)).fetchOne());
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
@@ -86,25 +88,23 @@ public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
}
|
||||
|
||||
List<Basic> content =
|
||||
queryFactory
|
||||
.select(Projections.constructor(AuthDto.Basic.class,
|
||||
userEntity.id,
|
||||
userEntity.userAuth,
|
||||
userEntity.userNm,
|
||||
userEntity.userId,
|
||||
userEntity.empId,
|
||||
userEntity.userEmail,
|
||||
userEntity.createdDttm
|
||||
))
|
||||
.from(userEntity)
|
||||
.where(
|
||||
builder
|
||||
)
|
||||
.orderBy(userEntity.userId.asc())
|
||||
.fetch();
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
AuthDto.Basic.class,
|
||||
userEntity.id,
|
||||
userEntity.userAuth,
|
||||
userEntity.userNm,
|
||||
userEntity.userId,
|
||||
userEntity.empId,
|
||||
userEntity.userEmail,
|
||||
userEntity.createdDttm))
|
||||
.from(userEntity)
|
||||
.where(builder)
|
||||
.orderBy(userEntity.userId.asc())
|
||||
.fetch();
|
||||
|
||||
long total =
|
||||
queryFactory.select(userEntity.id).from(userEntity).where(builder).fetchCount();
|
||||
long total = queryFactory.select(userEntity.id).from(userEntity).where(builder).fetchCount();
|
||||
return new PageImpl<>(content, pageable, total);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,11 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findPolygonJson(){
|
||||
public List<String> findPolygonJson() {
|
||||
return queryFactory
|
||||
.select(
|
||||
Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom)
|
||||
)
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.orderBy(mapSheetAnalDataGeomEntity.id.desc())
|
||||
.fetch();
|
||||
.select(Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom))
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.orderBy(mapSheetAnalDataGeomEntity.id.desc())
|
||||
.fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user