|
@@ -105,8 +105,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService {
|
|
|
return result.substring(0,result.lastIndexOf(","));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public Result deviceQuery2(DeviceVo deviceVo) {
|
|
|
+ @Override
|
|
|
+ public Result deviceQuery(DeviceVo deviceVo) {
|
|
|
|
|
|
//构建mysql数据库连接数据源--DataSource
|
|
|
Map<String, Object> mapParams = new HashMap<String, Object>();
|
|
@@ -121,7 +121,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService {
|
|
|
mapParams.put(JDBCDataStoreFactory.DATABASE.key, enterpriseConfig.getDsBaseName());
|
|
|
|
|
|
|
|
|
- String sql = "SELECT *,(st_distance(point(longitude, latitude), point("+deviceVo.getLon()+","+deviceVo.getLat()+"))*111195) AS distance FROM "+enterpriseConfig.getDevice()+" having distance < "+deviceVo.getRadius()*1000+" order by distance asc";
|
|
|
+// String sql = "SELECT *,(st_distance(point(longitude, latitude), point("+deviceVo.getLon()+","+deviceVo.getLat()+"))*111195) AS distance FROM "+enterpriseConfig.getDevice()+" having distance < "+deviceVo.getRadius()*1000+" order by distance asc";
|
|
|
+ String sql = "SELECT *,(6371 * acos (cos ( radians("+deviceVo.getLat()+") )* cos( radians(latitude) )* cos( radians(longitude) - radians("+deviceVo.getLon()+") )+ sin ( radians("+deviceVo.getLat()+"))* sin( radians(latitude) ))) AS distance FROM "+enterpriseConfig.getDevice()+" having distance <"+deviceVo.getRadius()+" order by distance asc";
|
|
|
|
|
|
PageResult pageResult = sqlService.sqlQuery4Mysql(mapParams,sql,null);
|
|
|
|
|
@@ -150,8 +151,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Result deviceQuery(DeviceVo deviceVo) {
|
|
|
+
|
|
|
+ public Result deviceQuery2(DeviceVo deviceVo) {
|
|
|
|
|
|
//数据源
|
|
|
Map<String, Object> entDsParams = new HashMap<String, Object>();
|