Browse Source

1.根据区域ID获取元素信息时,增加距离排序

hellohaidie 3 months ago
parent
commit
0be721cb80

+ 7 - 0
src/main/java/com/lqkj/link/module/zone/repository/GeomInfoRepository.java

@@ -13,6 +13,13 @@ import java.util.Map;
13
 @Repository
13
 @Repository
14
 public interface GeomInfoRepository extends JpaRepository<GeomInfo, String> {
14
 public interface GeomInfoRepository extends JpaRepository<GeomInfo, String> {
15
 
15
 
16
+    @Query(nativeQuery = true,
17
+        value = "with t1 as(select zone_id, st_makepoint(" +
18
+                    "(init_location -> 'translation' ->> 'x')::float8, " +
19
+                    "(init_location -> 'translation' ->> 'y')::float8, " +
20
+                    "(init_location -> 'translation' ->> 'z')::float8) as init from zone_info where zone_id = :zoneId) " +
21
+                "select gi.* from geom_info gi, t1 where gi.zone_id = t1.zone_id order by st_distance(gi.geom, t1.init) "
22
+    )
16
     List<GeomInfo> findAllByZoneId(Integer zoneId);
23
     List<GeomInfo> findAllByZoneId(Integer zoneId);
17
 
24
 
18
     @Modifying
25
     @Modifying