From 2b8df9f5452218cad1f012a008acea724de81fff Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 05 七月 2023 10:45:56 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/ILocationService.java         |    6 +-
 src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java   |   19 +++++++--
 src/main/java/com/yssh/dao/LocationMapper.java               |   10 +++--
 src/main/java/com/yssh/service/ISuYuanService.java           |    2 +
 src/main/java/com/yssh/service/impl/LocationServiceImpl.java |   13 +++---
 src/main/resources/mapping/LocationMapper.xml                |    9 ++++
 src/main/java/com/yssh/controller/SuYuanController.java      |    7 +++
 7 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/yssh/controller/SuYuanController.java b/src/main/java/com/yssh/controller/SuYuanController.java
index f1948a9..08de5b6 100644
--- a/src/main/java/com/yssh/controller/SuYuanController.java
+++ b/src/main/java/com/yssh/controller/SuYuanController.java
@@ -174,4 +174,11 @@
     public Result selectSuYuan700ById(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
         return Result.OK(suYuanService.selectSuYuan700ById(id, date));
     }
+
+    @ApiOperation(value = "鏍规嵁缁忕含搴︽煡璇㈠湴鍚�", notes = "鏍规嵁缁忕含搴︽煡璇㈠湴鍚�")
+    @ApiOperationSupport(order = 15)
+    @GetMapping("/selectAddrByXY")
+    public Result selectAddrByXY(@RequestParam(value = "x", required = true) double x, @RequestParam(value = "y", required = true) double y) {
+        return Result.OK(suYuanService.selectAddrByXY(x, y));
+    }
 }
diff --git a/src/main/java/com/yssh/dao/LocationMapper.java b/src/main/java/com/yssh/dao/LocationMapper.java
index cd5f0cb..ac9715f 100644
--- a/src/main/java/com/yssh/dao/LocationMapper.java
+++ b/src/main/java/com/yssh/dao/LocationMapper.java
@@ -8,16 +8,18 @@
 
 /**
  * @author wMeng
- * @ClassName YsshLocationMapper
- * @Description TODO
  * @date 2022/10/30 13:37
- * @Version 1.0
+ * @version 1.0
  */
 @Mapper
 public interface LocationMapper {
-
     List<Location> query(@Param("name") String name, @Param("type") String type);
+
     List<Location> getAll();
+
     int insertLocation(Location ysshLocation);
+
     int deleteLocation(String id);
+
+    List<Location> selectByXY(@Param("x") double x, @Param("y") double y);
 }
diff --git a/src/main/java/com/yssh/service/ILocationService.java b/src/main/java/com/yssh/service/ILocationService.java
index ec6e322..78a2b18 100644
--- a/src/main/java/com/yssh/service/ILocationService.java
+++ b/src/main/java/com/yssh/service/ILocationService.java
@@ -6,14 +6,14 @@
 
 /**
  * @author wMeng
- * @ClassName YsshLocationService
- * @Description TODO
  * @date 2022/10/30 13:25
- * @Version 1.0
+ * @version 1.0
  */
 public interface ILocationService {
     List<Location> query(String name, String type);
+
     List<Location> getAll();
+
     int insertLocation(Location ysshLocation);
 
     int deleteLocation(String id);
diff --git a/src/main/java/com/yssh/service/ISuYuanService.java b/src/main/java/com/yssh/service/ISuYuanService.java
index 38b0ac8..6816e77 100644
--- a/src/main/java/com/yssh/service/ISuYuanService.java
+++ b/src/main/java/com/yssh/service/ISuYuanService.java
@@ -36,4 +36,6 @@
 	public List<List<Coordinate>> selectRects(Double[] x, Double[] y);
 
 	public SuYuan700 selectSuYuan700ById(String id, Date date);
+
+	public String selectAddrByXY(double x, double y);
 }
diff --git a/src/main/java/com/yssh/service/impl/LocationServiceImpl.java b/src/main/java/com/yssh/service/impl/LocationServiceImpl.java
index bf2a157..7060dc2 100644
--- a/src/main/java/com/yssh/service/impl/LocationServiceImpl.java
+++ b/src/main/java/com/yssh/service/impl/LocationServiceImpl.java
@@ -3,37 +3,38 @@
 import com.yssh.dao.LocationMapper;
 import com.yssh.entity.Location;
 import com.yssh.service.ILocationService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
  * @author wMeng
- * @ClassName YsshLocationServiceImpl
- * @Description TODO
  * @date 2022/10/30 13:25
- * @Version 1.0
+ * @version 1.0
  */
 @Service
 public class LocationServiceImpl implements ILocationService {
-    @Autowired
+    @Resource
     private LocationMapper mapper;
+
     @Override
     public List<Location> query(String name, String type) {
         return mapper.query(name, type);
     }
+
     @Override
     public List<Location> getAll() {
         return mapper.getAll();
     }
+
     @Override
     public int insertLocation(Location location) {
         return mapper.insertLocation(location);
     }
+
     @Override
     public int deleteLocation(String id) {
         return mapper.deleteLocation(id);
     }
-
 }
diff --git a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
index f50492a..8e07d94 100644
--- a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
+++ b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
@@ -4,7 +4,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import com.yssh.dao.QxshMapper;
+import com.yssh.dao.*;
 import com.yssh.entity.*;
 import com.yssh.utils.*;
 import org.slf4j.Logger;
@@ -13,9 +13,6 @@
 import org.springframework.stereotype.Service;
 
 import com.google.common.collect.Lists;
-import com.yssh.dao.DictRecordMapper;
-import com.yssh.dao.FeedbackMapper;
-import com.yssh.dao.SuYuanMapper;
 import com.yssh.service.IAsyncService;
 import com.yssh.service.ICommonService;
 import com.yssh.service.ISuYuanService;
@@ -43,6 +40,9 @@
 
 	@Resource
 	private QxshMapper qxshMapper;
+
+	@Resource
+	private LocationMapper locationMapper;
 
 	//@Transactional
 	//@Override
@@ -301,4 +301,15 @@
 
 		return suYuanMapper.selectSuYuan700ById(id, time);
 	}
+
+	@Override
+	public String selectAddrByXY(double x, double y) {
+		List<Location> locations = locationMapper.selectByXY(x, y);
+		if (null != locations && locations.size() > 0) {
+			return locations.get(0).getName();
+		}
+
+
+		return null;
+	}
 }
diff --git a/src/main/resources/mapping/LocationMapper.xml b/src/main/resources/mapping/LocationMapper.xml
index a54d0d7..b99aa66 100644
--- a/src/main/resources/mapping/LocationMapper.xml
+++ b/src/main/resources/mapping/LocationMapper.xml
@@ -12,6 +12,15 @@
     <sql id="locationSql">
     	SELECT id, name, type, format(lon, 6) lon, format(lat, 6) lat FROM location
     </sql>
+
+    <select id="selectByXY" resultMap="locationResult">
+        <include refid="locationSql"></include>
+        <where>
+            lon between (#{x} - 0.000027) and (#{x} + 0.000027)
+            and
+            lat between (#{y} - 0.000027) and (#{y} + 0.000027)
+        </where>
+    </select>
     
     <select id="query" resultMap="locationResult">
     	<include refid="locationSql"></include>

--
Gitblit v1.9.3