|
|
@@ -2,6 +2,8 @@ package com.aoyang.tms.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aoyang.common.param.PageParam;
|
|
|
import com.aoyang.common.result.Result;
|
|
|
import com.aoyang.tms.common.ErrCodeEnum;
|
|
|
@@ -24,10 +26,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.cloud.netflix.ribbon.apache.HttpClientUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import sun.net.www.http.HttpClient;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URL;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
@@ -135,5 +140,38 @@ public class WorkOrderManageController {
|
|
|
// return new Result<>(flag);
|
|
|
// }
|
|
|
|
|
|
+ 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];
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String log = "116.42654793612228";
|
|
|
+ String lat = "39.944177062241515";
|
|
|
+ System.out.println("@@@ " + getProvince(log, lat));
|
|
|
+ }
|
|
|
|
|
|
}
|