Browse Source

修改成高德地图api

liyg 2 years ago
parent
commit
0b1feba7b7

+ 4 - 0
pom.xml

@@ -141,6 +141,10 @@
             <version>RELEASE</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 17 - 10
src/main/java/com/steerinfo/dil/controller/OffSiteTransportationController.java

@@ -2,6 +2,7 @@ package com.steerinfo.dil.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.steerinfo.dil.gaode.SearchPoint2;
 import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
 import com.steerinfo.dil.service.ITmstruckReceiptResultService;
 import com.steerinfo.dil.service.impl.OffSiteTransportationServiceImpl;
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.MediaType;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
@@ -67,6 +69,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
     private String suffix;
     @Autowired
     private RedisTemplate redisTemplate;
+    private String gaodeTonken = "6488b963467353c2837c955cbb03104f";
 
     @Autowired
     ITmstruckReceiptResultService tmstruckReceiptResultService;
@@ -359,18 +362,22 @@ public class OffSiteTransportationController extends BaseRESTfulController {
         String netValidationResult = zhongJiaoXingLu.netValidation(capacityNumber);
         Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
         if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
-            String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
-            SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
-            String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
-            SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
+            String searchPointJson = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+ URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
+            SearchPoint2 searchPoint= (SearchPoint2) DataConversionTool.jsonToBean(searchPointJson, SearchPoint2.class);
+            String searchPointJson2 = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
+            SearchPoint2 searchPoint2= (SearchPoint2) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint2.class);
             //运单生成之后保存
             HashMap<String,String> redisMap=new HashMap<>();
-            String startLon=searchPoint.getResult().getLocation().getLng().toString().length()>9?searchPoint.getResult().getLocation().getLng().toString().substring(0,9):searchPoint.getResult().getLocation().getLng().toString();
-            String startLat=searchPoint.getResult().getLocation().getLat().toString().length()>9?searchPoint.getResult().getLocation().getLat().toString().substring(0,8):searchPoint.getResult().getLocation().getLat().toString();
-            redisMap.put("startLonlat", startLon+","+startLat);
-            String endLon= searchPoint2.getResult().getLocation().getLng().toString().length()>9?searchPoint2.getResult().getLocation().getLng().toString().substring(0,9):searchPoint2.getResult().getLocation().getLng().toString();
-            String endLat= searchPoint2.getResult().getLocation().getLat().toString().length()>9?searchPoint2.getResult().getLocation().getLat().toString().substring(0,8):searchPoint2.getResult().getLocation().getLat().toString();
-            redisMap.put("endLonlat",endLon+","+endLat);
+            String location = searchPoint.getGeocodes().get(0).getLocation();
+            String[] split = StringUtils.split(location, ",");
+            String Lng = split[0];
+            String Lat = split[1];
+            redisMap.put("startLonlat", Lng.substring(0, 9) + "," + Lat.substring(0, 8));
+            String location2 = searchPoint2.getGeocodes().get(0).getLocation();
+            String[] split2 = StringUtils.split(location2, ",");
+            String Lng2 = split2[0];
+            String Lat2 = split2[1];
+            redisMap.put("endLonlat", Lng2.substring(0, 9) + "," + Lat2.substring(0, 8));
             redisMap.put("vclN", capacityNumber);
             redisMap.put("vco","2");
             SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");

+ 97 - 0
src/main/java/com/steerinfo/dil/gaode/Geocodes.java

@@ -0,0 +1,97 @@
+package com.steerinfo.dil.gaode;
+
+import lombok.Data;
+
+import java.util.Arrays;
+
+/**
+ * @program: Test
+ * @description
+ * @author: Dengyu
+ * @create: 2022-07-11 17:51
+ **/
+@Data
+public class Geocodes {
+    private String formatted_address;
+    private String country;
+    private String province;
+    private String citycode;
+    private String city;
+    private String district;
+    private String adcode;
+    private String location;
+    private String level;
+
+
+    public String getFormatted_address() {
+        return formatted_address;
+    }
+
+    public void setFormatted_address(String formatted_address) {
+        this.formatted_address = formatted_address;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+
+    public String getCitycode() {
+        return citycode;
+    }
+
+    public void setCitycode(String citycode) {
+        this.citycode = citycode;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getDistrict() {
+        return district;
+    }
+
+    public void setDistrict(String district) {
+        this.district = district;
+    }
+
+    public String getAdcode() {
+        return adcode;
+    }
+
+    public void setAdcode(String adcode) {
+        this.adcode = adcode;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+}

+ 60 - 0
src/main/java/com/steerinfo/dil/gaode/SearchPoint2.java

@@ -0,0 +1,60 @@
+package com.steerinfo.dil.gaode;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @program: Test
+ * @description
+ * @author: Dengyu
+ * @create: 2022-07-11 17:50
+ **/
+@Data
+public class SearchPoint2 {
+    private String status;
+    private String info;
+    private List<Geocodes> geocodes;
+    private String infocode;
+    private int count;
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    public List<Geocodes> getGeocodes() {
+        return geocodes;
+    }
+
+    public void setGeocodes(List<Geocodes> geocodes) {
+        this.geocodes = geocodes;
+    }
+
+    public String getInfocode() {
+        return infocode;
+    }
+
+    public void setInfocode(String infocode) {
+        this.infocode = infocode;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+}

File diff suppressed because it is too large
+ 404 - 350
src/main/java/com/steerinfo/route/service/impl/RouteServiceImpl.java


Some files were not shown because too many files changed in this diff