src/main/java/com/yssh/dao/LocationMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/entity/Location.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/ILocationService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/impl/LocationServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/utils/CalculateUtils.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapping/LocationMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/yssh/dao/LocationMapper.java
@@ -22,4 +22,6 @@ int deleteLocation(String id); List<Location> selectByXY(@Param("x") double x, @Param("y") double y); List<Location> selectVocAddrs(); } src/main/java/com/yssh/entity/Location.java
@@ -7,28 +7,26 @@ import lombok.Data; /** * 厂区热点点位 * @author wMeng * @ClassName YsshLocation * @Description 厂区热点点位 * @date 2022/10/30 13:16 * @Version 1.0 * @version 1.0 */ @Data @ApiModel(value = "厂区热点点位",description = "厂区热点点位") public class Location implements Serializable{ public class Location implements Serializable { private static final long serialVersionUID = -2728687771987124891L; @ApiModelProperty(value = "主键") private int id; private int id; @ApiModelProperty(value = "点位名称") private String name; private String name; @ApiModelProperty(value = "点位类型") private String type; private String type; @ApiModelProperty(value = "点位经度") private float lon; private double lon; @ApiModelProperty(value = "点位纬度") private float lat; private double lat; public int getId() { return id; @@ -54,19 +52,19 @@ this.type = type; } public float getLon() { public double getLon() { return lon; } public void setLon(float lon) { public void setLon(double lon) { this.lon = lon; } public float getLat() { public double getLat() { return lat; } public void setLat(float lat) { public void setLat(double lat) { this.lat = lat; } } src/main/java/com/yssh/service/ILocationService.java
@@ -17,4 +17,6 @@ int insertLocation(Location ysshLocation); int deleteLocation(String id); List<Location> selectVocAddrs(double x, double y); } src/main/java/com/yssh/service/impl/LocationServiceImpl.java
@@ -3,9 +3,11 @@ import com.yssh.dao.LocationMapper; import com.yssh.entity.Location; import com.yssh.service.ILocationService; import com.yssh.utils.CalculateUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** @@ -17,6 +19,8 @@ public class LocationServiceImpl implements ILocationService { @Resource private LocationMapper mapper; private static List<Location> vocAddrs = null; @Override public List<Location> query(String name, String type) { @@ -37,4 +41,27 @@ public int deleteLocation(String id) { return mapper.deleteLocation(id); } @Override public List<Location> selectVocAddrs(double x, double y) { if (null == vocAddrs) { vocAddrs = mapper.selectVocAddrs(); for (Location loc : vocAddrs) { double X = CalculateUtils.getLon((int) loc.getLon(), (int) loc.getLat()); double Y = CalculateUtils.getLat((int) loc.getLon(), (int) loc.getLat()); loc.setLon(X); loc.setLat(Y); } } List<Location> list = new ArrayList<>(); for (Location loc : vocAddrs) { if (Math.abs(loc.getLon() - x) <= 0.00009 && Math.abs(loc.getLat() - y) <= 0.00009) { list.add(loc); } } return list; } } src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
@@ -44,6 +44,9 @@ @Resource private LocationMapper locationMapper; @Resource private LocationServiceImpl locService; //@Transactional //@Override @Async("threadPoolTaskExecutor") @@ -309,6 +312,10 @@ return locations.get(0).getName(); } locations = locService.selectVocAddrs(x, y); if (null != locations && locations.size() > 0) { return locations.get(0).getName(); } return null; } src/main/java/com/yssh/utils/CalculateUtils.java
@@ -1,7 +1,6 @@ package com.yssh.utils; import java.awt.geom.Point2D; import java.text.SimpleDateFormat; import java.util.*; import com.yssh.entity.Coordinate; src/main/resources/mapping/LocationMapper.xml
@@ -16,11 +16,17 @@ <select id="selectByXY" resultMap="locationResult"> <include refid="locationSql"></include> <where> lon between (#{x} - 0.000027) and (#{x} + 0.000027) lon between (#{x} - 0.000045) and (#{x} + 0.000045) and lat between (#{y} - 0.000027) and (#{y} + 0.000027) lat between (#{y} - 0.000045) and (#{y} + 0.000045) </where> </select> <select id="selectVocAddrs" resultMap="locationResult"> select id, x "lon", y "lat", addr "name" from voc_addr where length(addr) > 0; </select> <select id="query" resultMap="locationResult"> <include refid="locationSql"></include>