lyhzzz 2 yıl önce
ebeveyn
işleme
79b0614c6e

+ 1 - 0
src/main/java/com/fdkankan/sale/service/impl/RepairInfoService.java

@@ -184,6 +184,7 @@ public class RepairInfoService {
                     switch (repairLogVo.getRepairStatus()){
                         case 41 : repairLogVo.setRepairStatus(50);break;
                         case 90 : repairLogVo.setRepairStatus(100);break;
+                        case 82 : repairLogVo.setRepairStatus(100);break;
                         case 91 : repairLogVo.setRepairStatus(100);break;
                     }
                     logVo = getNextStepVo(repairLogVo);

+ 100 - 0
src/main/java/com/fdkankan/sale/util/ProvinceUtils.java

@@ -0,0 +1,100 @@
+package com.fdkankan.sale.util;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.print.DocFlavor;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Objects;
+
+@Slf4j
+public class ProvinceUtils {
+
+
+    public static void main(String[] args) {
+
+        String province = pointsToLocationsAll("103.84288546165004,1.3600005166350961");
+        System.out.println(province);
+    }
+
+    public static String getProvince(String log, String lat ){
+        //lat 小  log  大
+        //参数解释: 纬度,经度 type 001 (100代表道路,010代表POI,001代表门址,111可以同时显示前三项)
+        String urlString = "http://gc.ditu.aliyun.com/regeocoding?l="+lat+","+log+"&type=010";
+        String res = "";
+        try {
+            URL url = new URL(urlString);
+            java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();
+            conn.setDoOutput(true);
+            conn.setRequestMethod("POST");
+            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream(),"UTF-8"));
+            String line;
+            while ((line = in.readLine()) != null) {
+                res += line+"\n";
+            }
+            in.close();
+        } catch (Exception e) {
+            System.out.println("error in wapaction,and e is " + e.getMessage());
+        }
+        System.out.println(res);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        JSONArray jsonArray = JSON.parseArray(jsonObject.getString("addrList"));
+        JSONObject jsonObject1 = jsonArray.getJSONObject(0);
+        String arr[] = jsonObject1.get("admName").toString().split(",");
+        System.out.println(arr[0]);
+        return arr[0];
+    }
+
+    /**
+     * 根据经纬度转地址
+     * @param points
+     * @return
+     */
+    public static String amapKey = "3609daa52e8ae4493393292213e2fb98";
+
+    public static String pointsToLocationsAll(String points) {
+        //将GPS坐标转化为高德地图坐标的URL后再去请求位置信息
+        try {
+            points = URLEncoder.encode(points,"UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        String convertUrl =
+                "https://restapi.amap.com/v3/assistant/coordinate/convert?locations="+points+"&coordsys=gps&key="+amapKey;
+        //GPS坐标转为高德地图坐标
+        String s = HttpUtil.get(convertUrl);
+        JSONObject jsonObject = JSON.parseObject(s);
+        String status = (String) jsonObject.get("status");
+        if(Objects.equals(status,"0")){
+            throw new RuntimeException("远程调用经纬度转化出错");
+        }
+        String locations = (String) jsonObject.get("locations");
+        String formattedAmapPoints = null;
+        try {
+            formattedAmapPoints = URLEncoder.encode(locations.replaceAll(";", "|"), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        String locationUrl = "https://restapi.amap.com/v3/geocode/regeo?output=json&location="+formattedAmapPoints+"&key="+amapKey+"&radius=1000&batch=true";
+        String s1 = HttpUtil.get(locationUrl);
+        //获取转地址后的结果
+        JSONObject parseObject = JSON.parseObject(s1);
+        String status1 = (String) parseObject.get("status");
+        if(Objects.equals(status1,"0")){
+            throw new RuntimeException("根据经纬度获取具体地址出错");
+        }
+        JSONArray regeocodes = parseObject.getJSONArray("regeocodes");
+        String formattedAddress = "";
+        for (Object regeocode : regeocodes) {
+            JSONObject object = (JSONObject) regeocode;
+            formattedAddress = (String)object.get("formatted_address");
+        }
+        log.info("经纬度【{}】转化为具体地点【{}】",points,formattedAddress);
+        return formattedAddress;
+    }
+
+}