重新打包
This commit is contained in:
parent
92471c02fa
commit
6e003adc8c
@ -7,6 +7,11 @@ public class AddressBean {
|
|||||||
*/
|
*/
|
||||||
private boolean success;
|
private boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省的编码
|
* 省的编码
|
||||||
*/
|
*/
|
||||||
@ -63,6 +68,14 @@ public class AddressBean {
|
|||||||
this.success = success;
|
this.success = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getProCode() {
|
public String getProCode() {
|
||||||
return proCode;
|
return proCode;
|
||||||
}
|
}
|
||||||
@ -139,6 +152,7 @@ public class AddressBean {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "AddressBean{" +
|
return "AddressBean{" +
|
||||||
"success=" + success +
|
"success=" + success +
|
||||||
|
", message='" + message + '\'' +
|
||||||
", proCode='" + proCode + '\'' +
|
", proCode='" + proCode + '\'' +
|
||||||
", proName='" + proName + '\'' +
|
", proName='" + proName + '\'' +
|
||||||
", cityCode='" + cityCode + '\'' +
|
", cityCode='" + cityCode + '\'' +
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.xkrs.utilsnew;
|
package com.xkrs.utilsnew;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.xkrs.model.bean.AddressBean;
|
import com.xkrs.model.bean.AddressBean;
|
||||||
import com.xkrs.model.vo.TianDiTuGeocodeVo;
|
import com.xkrs.model.vo.TianDiTuGeocodeVo;
|
||||||
import org.apache.hc.core5.util.TextUtils;
|
import org.apache.hc.core5.util.TextUtils;
|
||||||
@ -14,12 +15,15 @@ public class FirePointAddressUtils {
|
|||||||
* 使用网络方式解析地址信息
|
* 使用网络方式解析地址信息
|
||||||
*/
|
*/
|
||||||
public static AddressBean analysisWithNetwork(double longitude, double latitude) {
|
public static AddressBean analysisWithNetwork(double longitude, double latitude) {
|
||||||
|
AddressBean addressBean = new AddressBean();
|
||||||
|
String geocodeStr = "";
|
||||||
try {
|
try {
|
||||||
TianDiTuGeocodeVo geocode = TianDiTuApiUtil.geocode(longitude, latitude);
|
TianDiTuGeocodeVo geocode = TianDiTuApiUtil.geocode(longitude, latitude);
|
||||||
|
geocodeStr = JSON.toJSONString(geocode);
|
||||||
TianDiTuGeocodeVo.ResultDTO.AddressComponentDTO addressComponent = geocode.result.addressComponent;
|
TianDiTuGeocodeVo.ResultDTO.AddressComponentDTO addressComponent = geocode.result.addressComponent;
|
||||||
//填充AddressBean数据
|
//填充AddressBean数据
|
||||||
AddressBean addressBean = new AddressBean();
|
|
||||||
addressBean.setSuccess(true);
|
addressBean.setSuccess(true);
|
||||||
|
addressBean.setMessage("");
|
||||||
addressBean.setProCode(StrUtil.isEmpty(addressComponent.provinceCode) ? "" : addressComponent.provinceCode.substring(3, 9));
|
addressBean.setProCode(StrUtil.isEmpty(addressComponent.provinceCode) ? "" : addressComponent.provinceCode.substring(3, 9));
|
||||||
addressBean.setProName(addressComponent.province);
|
addressBean.setProName(addressComponent.province);
|
||||||
addressBean.setCityCode(StrUtil.isEmpty(addressComponent.cityCode) ? "" : addressComponent.cityCode.substring(3, 9));
|
addressBean.setCityCode(StrUtil.isEmpty(addressComponent.cityCode) ? "" : addressComponent.cityCode.substring(3, 9));
|
||||||
@ -32,10 +36,10 @@ public class FirePointAddressUtils {
|
|||||||
return addressBean;
|
return addressBean;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
addressBean.setSuccess(false);
|
||||||
|
addressBean.setMessage("longitude=" + longitude + ",latitude=" + latitude + ",geocode=" + geocodeStr + ",message=" + e.getMessage());
|
||||||
|
return addressBean;
|
||||||
}
|
}
|
||||||
AddressBean addressBean = new AddressBean();
|
|
||||||
addressBean.setSuccess(false);
|
|
||||||
return addressBean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +76,7 @@ public class FirePointAddressUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AddressBean addressBean = analysisWithNetwork(120.98, 36.78);
|
AddressBean addressBean = analysisWithNetwork(109.6981278, 19.8897095);
|
||||||
System.out.println(addressBean.toString());
|
System.out.println(addressBean.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user