|
@@ -690,16 +690,15 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return ResponseJson.error("第" + i + 1 + "行详细地址不能为空");
|
|
|
}
|
|
|
// 校验经纬度
|
|
|
- cell = authPartyRow.getCell(3);
|
|
|
- String lngAndLat = null;
|
|
|
+ //根据详细信息获取经纬度
|
|
|
+ String lngAndLat = getGeographyinfoByAddress(address, "c50591640d1beb90207a2e4ce892e8f3");
|
|
|
+// String lngAndLat = null;
|
|
|
BigDecimal lng = null;
|
|
|
BigDecimal lat = null;
|
|
|
- if(null != cell){
|
|
|
- cell.setCellType(CellType.STRING);
|
|
|
- lngAndLat = cell.getStringCellValue();
|
|
|
-// String[] split = lngAndLat.split(",");
|
|
|
-// lng = new BigDecimal(split[0]);
|
|
|
-// lat = new BigDecimal(split[1]);
|
|
|
+ if(StringUtils.isNotEmpty(lngAndLat)){
|
|
|
+ String[] split = lngAndLat.split(",");
|
|
|
+ lng = new BigDecimal(split[0]);
|
|
|
+ lat = new BigDecimal(split[1]);
|
|
|
}
|
|
|
// if (StringUtils.isBlank(lngAndLat)) {
|
|
|
// return ResponseJson.error("第" + i + 1 + "行经纬度不能为空");
|
|
@@ -803,6 +802,39 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return ResponseJson.success("导入成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 调用高德地图api根据详细地址获取对应经纬度
|
|
|
+ * @param address 详细地址
|
|
|
+ * @param key api KEY
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getGeographyinfoByAddress(String address,String key){
|
|
|
+ String url="https://restapi.amap.com/v3/geocode/geo?address="+address+"&key="+key;
|
|
|
+ CloseableHttpClient closeableHttpClient= HttpClients.createDefault();
|
|
|
+ HttpGet httpGet=new HttpGet(url);
|
|
|
+ CloseableHttpResponse response=null;
|
|
|
+ try {
|
|
|
+ response=closeableHttpClient.execute(httpGet);
|
|
|
+ HttpEntity entity=response.getEntity();
|
|
|
+ String result= EntityUtils.toString(entity, StandardCharsets.UTF_8);
|
|
|
+ JSONObject jsonObject=JSONObject.parseObject(result);
|
|
|
+ String geocodesStr=jsonObject.getString("geocodes");
|
|
|
+ JSONArray geocodesArr = JSONObject.parseArray(geocodesStr);
|
|
|
+ EntityUtils.consume(entity);
|
|
|
+ if(null!=geocodesArr){
|
|
|
+ String geo=geocodesArr.getString(0);
|
|
|
+ JSONObject geocodes=JSONObject.parseObject(geo);
|
|
|
+ String location=geocodes.getString("location");
|
|
|
+ return location;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取机构关联的机构信息
|
|
|
* 1.7.4版本:
|