diff --git a/ruoyi/pom.xml b/ruoyi/pom.xml index 87dc5b2e3..5526b8dcd 100644 --- a/ruoyi/pom.xml +++ b/ruoyi/pom.xml @@ -48,6 +48,14 @@ test + + + com.squareup.okhttp3 + okhttp + 3.8.1 + test + + org.springframework.boot diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/GDConvertCordinateResult.java b/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/GDConvertCordinateResult.java new file mode 100644 index 000000000..f7808b4f8 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/GDConvertCordinateResult.java @@ -0,0 +1,37 @@ +package com.ruoyi.project.data.basis.domain; + +/** + * 高德坐标系 + * + * @author lihe + */ +public class GDConvertCordinateResult { + + private Integer status; + private String info; + private String locations; + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + + public String getLocations() { + return locations; + } + + public void setLocations(String locations) { + this.locations = locations; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/UvCommunityGeo.java b/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/UvCommunityGeo.java new file mode 100644 index 000000000..2f8522a75 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/basis/domain/UvCommunityGeo.java @@ -0,0 +1,58 @@ +package com.ruoyi.project.data.basis.domain; + +import java.math.BigDecimal; + +/** + * 小区坐标 + * + * @author lihe + */ +public class UvCommunityGeo { + + private String communityId; + private BigDecimal baiduLng; + private BigDecimal baiduLat; + private BigDecimal gaodeLng; + private BigDecimal gaodeLat; + + + public String getCommunityId() { + return communityId; + } + + public void setCommunityId(String communityId) { + this.communityId = communityId; + } + + public BigDecimal getBaiduLng() { + return baiduLng; + } + + public void setBaiduLng(BigDecimal baiduLng) { + this.baiduLng = baiduLng; + } + + public BigDecimal getBaiduLat() { + return baiduLat; + } + + public void setBaiduLat(BigDecimal baiduLat) { + this.baiduLat = baiduLat; + } + + public BigDecimal getGaodeLng() { + return gaodeLng; + } + + public void setGaodeLng(BigDecimal gaodeLng) { + this.gaodeLng = gaodeLng; + } + + public BigDecimal getGaodeLat() { + return gaodeLat; + } + + public void setGaodeLat(BigDecimal gaodeLat) { + this.gaodeLat = gaodeLat; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/basis/mapper/UvCommunityGeoMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/basis/mapper/UvCommunityGeoMapper.java new file mode 100644 index 000000000..faa8cd0c9 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/basis/mapper/UvCommunityGeoMapper.java @@ -0,0 +1,33 @@ +package com.ruoyi.project.data.basis.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.project.data.basis.domain.UVBasePrice; +import com.ruoyi.project.data.basis.domain.UVBasePriceQueryModel; +import com.ruoyi.project.data.basis.domain.UvCommunityGeo; + +import java.util.List; + +/** + * 小区坐标Mapper + * + * @author lihe + */ +@DS("teemlink") +public interface UvCommunityGeoMapper { + + /** + * 获取所有 + * + * @return + */ + List all(); + + /** + * 更新高德坐标 + * + * @param uvCommunityGeo + * @return + */ + int updateGaoDeCoordinate(UvCommunityGeo uvCommunityGeo); + +} diff --git a/ruoyi/src/main/resources/application-routine.yml b/ruoyi/src/main/resources/application-routine.yml new file mode 100644 index 000000000..ecb11c819 --- /dev/null +++ b/ruoyi/src/main/resources/application-routine.yml @@ -0,0 +1,80 @@ +ruoyi: + # 名称 + name: RuoYi + # 版本 + version: 2.2.0 + # 版权年份 + copyrightYear: 2019 + # 实例演示开关 + demoEnabled: true + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: false + +# web服务器配置 +server: + port: 9700 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + max-threads: 800 + # Tomcat启动初始化的线程数,默认值25 + min-spare-threads: 30 + +spring: + datasource: + dynamic: + primary: master + hikari: + connection-timeout: 30000 + validation-timeout: 30000 + idle-timeout: 30000 + max-lifetime: 30000 + max-pool-size: 30 + min-idle: 10 + initialization-fail-timeout: 30000 + connection-init-sql: select 1 + connection-test-query: select 1 + is-auto-commit: true + is-read-only: false + datasource: + master: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://172.16.30.243:6060/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: LOLm2dI2UQF#RxOf + teemlink: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=obpm_LianCheng_Data + username: sa + password: Lcdatacenter_888 + oldProd: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://139.196.201.83:8433;DatabaseName=LC_DataCenter + username: sa + password: lc1234 + compute: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_calc + username: sa + password: Lcdatacenter_888 + clean: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_clean + username: sa + password: Lcdatacenter_888 + calc: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=CALC + username: purple + password: liancheng + spider: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=TEST + username: purple + password: liancheng \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/UvCommunityGeoMapper.xml b/ruoyi/src/main/resources/mybatis/data/UvCommunityGeoMapper.xml new file mode 100644 index 000000000..62e83435a --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/UvCommunityGeoMapper.xml @@ -0,0 +1,14 @@ + + + + + + update gis_community set gaode_lng=#{gaodeLng},gaode_lat=#{gaodeLat},update_time=getdate() where + community_id=#{communityId} + + \ No newline at end of file diff --git a/ruoyi/src/test/java/com/ruoyi/routine/GeoTests.java b/ruoyi/src/test/java/com/ruoyi/routine/GeoTests.java new file mode 100644 index 000000000..8d852fa6b --- /dev/null +++ b/ruoyi/src/test/java/com/ruoyi/routine/GeoTests.java @@ -0,0 +1,83 @@ +package com.ruoyi.routine; + +import com.alibaba.fastjson.JSON; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.RuoYiApplication; +import com.ruoyi.project.data.basis.domain.GDConvertCordinateResult; +import com.ruoyi.project.data.basis.domain.UvCommunityGeo; +import com.ruoyi.project.data.basis.mapper.UvCommunityGeoMapper; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.security.web.PortResolverImpl; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class) +@ActiveProfiles("uat") +public class GeoTests { + + @Autowired + private UvCommunityGeoMapper uvCommunityGeoMapper; + + /** + * 小区坐标,百度转高德 + */ + @Test + @DS("teemlink") + public void convertBd2Gd() { + List communityGeoList = uvCommunityGeoMapper.all(); + + OkHttpClient client = new OkHttpClient(); + String baseUrl = "https://restapi.amap.com/v3/assistant/coordinate/convert?key" + + "=4b331b88b71252b7db756603a2562737"; + + // + communityGeoList.parallelStream().forEach(communityGeo -> { + + StringBuilder sb = new StringBuilder(baseUrl); + sb.append(String.format("&locations=%s,%s&coordsys=baidu", communityGeo.getBaiduLng(), + communityGeo.getBaiduLat())); + + Request request = new Request.Builder() + .url(sb.toString()) + .build(); + try (Response response = client.newCall(request).execute()) { + String content = response.body().string(); +// System.out.println(content); + GDConvertCordinateResult priceApiResult = JSON.parseObject(content, + GDConvertCordinateResult.class); + if (Objects.equals(1, priceApiResult.getStatus())) { + String[] coordinates = priceApiResult.getLocations().split(","); + communityGeo.setGaodeLng(new BigDecimal(coordinates[0])); + communityGeo.setGaodeLat(new BigDecimal(coordinates[1])); + uvCommunityGeoMapper.updateGaoDeCoordinate(communityGeo); + } + +// System.out.println(priceApiResult); +// if (null != priceApiResult && priceApiResult.getStatus()) { +// jdbcTemplate.update("update collateral set total_price=? where id=?", +// new Object[]{priceApiResult.getUeasPrice(), x.getId()}); +// } + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + +}