diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index b92dbb1cb..7452bb1b3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -633,7 +633,8 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForH2", databaseId = "h2") @SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForKingBase", databaseId = "kingbase") @SelectProvider(type = ChannelProvider.class, method = "queryListInCircleForPostgresql", databaseId = "postgresql") - List queryListInCircle(Double centerLongitude, Double centerLatitude, Double radius, Integer level, List groupList); + List queryListInCircle(@Param("centerLongitude") Double centerLongitude, @Param("centerLatitude") Double centerLatitude, + @Param("radius") Double radius, @Param("level") Integer level, @Param("groupList") List groupList); @SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForMysql", databaseId = "mysql") @SelectProvider(type = ChannelProvider.class, method = "queryListInPolygonForH2", databaseId = "h2") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java index b2ddee18e..77c4df866 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java @@ -122,7 +122,7 @@ public interface GroupMapper { @Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup} ") List queryByBusinessGroup(@Param("businessGroup") String businessGroup); - @Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup} ") + @Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup}") @MapKey("id") Map queryByBusinessGroupForMap(@Param("businessGroup") String businessGroup); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index e5b175934..b72322e51 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -669,8 +669,9 @@ public class ChannelProvider { } sqlBuild.append(" )"); - sqlBuild.append(" AND coalesce(wdc.gb_longitude, wdc.longitude) >= #{minLongitude} AND coalesce(wdc.gb_longitude, wdc.longitude) <= #{maxLongitude}"); - sqlBuild.append(" AND coalesce(wdc.gb_latitude, wdc.latitude) >= #{minLatitude} AND coalesce(wdc.gb_latitude, wdc.latitude) <= #{maxLatitude}"); + String geomTextBuilder = "point(" + params.get("centerLongitude") + " " + params.get("centerLatitude") + ")"; + + sqlBuild.append("AND ST_Distance_Sphere(point(coalesce(wdc.gb_longitude, wdc.longitude), coalesce(wdc.gb_latitude, wdc.latitude)), ST_GeomFromText('").append(geomTextBuilder).append("')) < #{radius}"); if (params.get("level") != null) { sqlBuild.append(" AND ( map_level <= #{level} || map_level is null )"); @@ -707,7 +708,8 @@ public class ChannelProvider { Point point = pointList.get(i); geomTextBuilder.append(point.getLng()).append(" ").append(point.getLat()); } - sqlBuild.append("AND ST_Within(point(coalesce(wdc.gb_longitude, wdc.longitude), coalesce(wdc.gb_latitude, wdc.latitude)), ST_GeomFromText('").append(geomTextBuilder).append("))'))"); + geomTextBuilder.append("))"); + sqlBuild.append("AND ST_Within(point(coalesce(wdc.gb_longitude, wdc.longitude), coalesce(wdc.gb_latitude, wdc.latitude)), ST_GeomFromText('").append(geomTextBuilder).append("'))"); if (params.get("level") != null) { sqlBuild.append(" AND ( map_level <= #{level} || map_level is null )");