南京银行、光大涉农,我们城市不空,与齐梁不一致用我们的
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
<div id="allmap" style="width:1024px;height:600px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<input id="saveOrUpdate" type="button" value="提交"/>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
@@ -83,6 +84,48 @@
|
||||
|
||||
map.centerAndZoom(polygon.getBounds().getCenter(), 13);
|
||||
map.addOverlay(polygon); //增加多边形
|
||||
// 添加可编辑功能
|
||||
polygon.enableEditing();
|
||||
|
||||
$("#saveOrUpdate").click(function(){
|
||||
// 更新表单中的点位置数据
|
||||
updatePolygonPoints();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../developmentZone/saveOrUpdate',
|
||||
data: $("#form1").serialize(),
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(data) {
|
||||
alert(data.msg);
|
||||
location.href="list";
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 更新表单中的多边形点位置数据
|
||||
function updatePolygonPoints() {
|
||||
var polygons = map.getOverlays(BMap.Polygon);
|
||||
for (var i = 0; i < polygons.length; i++) {
|
||||
// 确保当前对象是一个多边形对象
|
||||
if (polygons[i] instanceof BMap.Polygon) {
|
||||
var points = polygons[i].getPath();
|
||||
var bdShape = [];
|
||||
for (var j = 0; j < points.length; j++) {
|
||||
var location = [];
|
||||
location.push(points[j].lng);
|
||||
location.push(points[j].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
// 将更新后的点位置数据更新到表单中
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<@menuitem uri='/agentMaster/listMaster' text="中介公司" />
|
||||
<@menuitem uri='/mortgageInfo/list' text="抵押品" />
|
||||
<@menuitem uri='/developmentZone/list' text="开发区" />
|
||||
<@menuitem uri='/township/list' text="乡镇街道" />
|
||||
</ul>
|
||||
</li>
|
||||
<li class="menu">
|
||||
|
||||
+7
-4
@@ -450,14 +450,17 @@ public class AddrSvcController {
|
||||
Map<String, String> map = senRequest(address, qltype);
|
||||
// 涉农结果不一样
|
||||
if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) {
|
||||
//有市辖建制镇,用我们
|
||||
if ("是".equals(result.get("administrativeTowns"))) {
|
||||
basicModel.setResult(result);
|
||||
//有市辖建制镇, 或者城市不一样 用我们
|
||||
if (result.containsKey("city")) {
|
||||
if ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) {
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
} else {
|
||||
map.put("addrVerify", result.getString("addrVerify"));
|
||||
map.put("addrVerify", "地址有效");
|
||||
map.put("typeName", areaMap.get(map.get("typeCode")));
|
||||
basicModel.setResult(map);
|
||||
}
|
||||
|
||||
} else {
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
|
||||
+192
-1
@@ -6,9 +6,28 @@ import com.fangjia.open.interceptors.Role;
|
||||
import com.fangjia.open.model.AddressModel;
|
||||
import com.fangjia.open.model.BasicModel;
|
||||
import com.fangjia.open.model.RestfulModelAndView;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Authenticator;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,6 +37,18 @@ import java.util.Map;
|
||||
@Authority(role = Role.USER)
|
||||
public class GdBankController {
|
||||
|
||||
private static final Map<String, String> areaMap = new HashMap<String, String>() {
|
||||
{
|
||||
// 添加键值对到 Map 中
|
||||
put("111", "主城区");
|
||||
put("112", "城乡结合区");
|
||||
put("121", "镇中心区");
|
||||
put("122", "镇乡结合区");
|
||||
put("123", "特殊区域");
|
||||
put("210", "村庄");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 涉农识别-新规
|
||||
*
|
||||
@@ -31,12 +62,14 @@ public class GdBankController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
||||
return mav;
|
||||
}
|
||||
String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null;
|
||||
String address = model.getAddress();
|
||||
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
|
||||
params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null);
|
||||
params.put("type", type);
|
||||
params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null);
|
||||
params.put("address", model.getAddress());
|
||||
params.put("showFullValue", "2");
|
||||
@@ -54,12 +87,67 @@ public class GdBankController {
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
//我们的结果
|
||||
JSONObject result = json.getJSONObject("result");
|
||||
if (("是").equals(result.get("countyLevelCity"))){
|
||||
result.put("prefectureLevelCity", "否");
|
||||
} else if(("否").equals(result.get("countyLevelCity"))){
|
||||
result.put("prefectureLevelCity", "是");
|
||||
}
|
||||
//我们省级及以上有开发区,直接用我们的结果
|
||||
if (result.containsKey("devDistrictName")) {
|
||||
basicModel.setResult(result);
|
||||
|
||||
} else {
|
||||
try {
|
||||
//如果是江苏省或者浙江省 调用齐梁的结果
|
||||
if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) {
|
||||
|
||||
//结果比较,如果涉农结果不一致
|
||||
//调用齐梁 type :1 对公 0 对私
|
||||
//我们 type :1 对私 2 对共
|
||||
String qltype = "2".equals(type) ? "1" : "0";
|
||||
Map<String, String> map = senRequest(address, qltype);
|
||||
// 涉农结果不一样
|
||||
if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) {
|
||||
//有市辖建制镇, 或者城市不一样 用我们
|
||||
if (result.containsKey("city")) {
|
||||
if ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) {
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
} else {
|
||||
if (("是").equals(result.get("countyLevelCity"))){
|
||||
map.put("prefectureLevelCity", "否");
|
||||
} else if(("否").equals(result.get("countyLevelCity"))){
|
||||
map.put("prefectureLevelCity", "是");
|
||||
}
|
||||
map.put("addrVerify", "地址有效");
|
||||
map.put("countyLevelCity",result.getString("countyLevelCity"));
|
||||
map.put("typeName", areaMap.get(map.get("typeCode")));
|
||||
basicModel.setResult(map);
|
||||
}
|
||||
|
||||
} else {
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
|
||||
} else {
|
||||
basicModel.setResult(result);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
@@ -68,4 +156,107 @@ public class GdBankController {
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
private static Map<String, String> senRequest(String address, String type) throws IOException {
|
||||
String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign";
|
||||
String proxyHost = "tunnel2.qg.net";
|
||||
int proxyPort = 14186;
|
||||
final String proxyUsername = "113BBC06";
|
||||
final String proxyPassword = "3B2FBD05B0AF";
|
||||
String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}";
|
||||
String authKey = proxyUsername;
|
||||
String password = proxyPassword;
|
||||
String auth = authKey + ":" + password;
|
||||
String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8")));
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(targetURL);
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray());
|
||||
}
|
||||
});
|
||||
httpPost.setHeader("Content-Type", "application/json");
|
||||
httpPost.setHeader("Accept", "*/*");
|
||||
httpPost.setHeader("Host", "146.56.217.44:9010");
|
||||
httpPost.setHeader("Proxy-Authorization", authHeader);
|
||||
StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(stringEntity);
|
||||
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
int retryCount = 2; // 设置重试次数
|
||||
int retryDelay = 10; // 设置重试延迟时间(毫秒)
|
||||
boolean success = false;
|
||||
for (int i = 0; i < retryCount; i++) {
|
||||
try {
|
||||
httpResponse = httpClient.execute(httpPost);
|
||||
success = true;
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
System.err.println("代理请求失败,进行重试...");
|
||||
try {
|
||||
Thread.sleep(retryDelay);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
String responseString = EntityUtils.toString(responseEntity);
|
||||
|
||||
// 使用 Gson 解析 JSON 字符串
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class);
|
||||
|
||||
|
||||
// 创建 Map 存储各个值
|
||||
Map<String, String> dataMap = new HashMap<String, String>();
|
||||
|
||||
// 获取各个值并放入 Map
|
||||
// dataMap.put("code", jsonObject.get("code").getAsString());
|
||||
// dataMap.put("msg", jsonObject.get("msg").getAsString());
|
||||
JsonElement dataElement = jsonObject.get("data");
|
||||
if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) {
|
||||
JsonObject data = dataElement.getAsJsonObject();
|
||||
// 在这里继续处理 data 对象
|
||||
|
||||
if (data != null && !data.isJsonNull()) {
|
||||
|
||||
// dataMap.put("version", data.get("version").getAsString());
|
||||
dataMap.put("province", data.get("province").getAsString());
|
||||
dataMap.put("city", data.get("city").getAsString());
|
||||
dataMap.put("district", data.get("district").getAsString());
|
||||
dataMap.put("town", data.get("town").getAsString());
|
||||
dataMap.put("committee", data.get("village").getAsString());
|
||||
dataMap.put("provinceCode", data.get("provinceCode").getAsString());
|
||||
dataMap.put("cityCode", data.get("cityCode").getAsString());
|
||||
dataMap.put("districtCode", data.get("districtCode").getAsString());
|
||||
dataMap.put("townCode", data.get("townCode").getAsString());
|
||||
dataMap.put("committeeCode", data.get("villageCode").getAsString());
|
||||
dataMap.put("typeCode", data.get("areaCode").getAsString());
|
||||
dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农");
|
||||
dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是");
|
||||
// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空
|
||||
JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray();
|
||||
|
||||
if (indusParkList != null) {
|
||||
JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class);
|
||||
dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString());
|
||||
dataMap.put("devDistrict", "是");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse.close();
|
||||
return dataMap;
|
||||
} else {
|
||||
System.err.println("重试次数已用完,请求失败。");
|
||||
}
|
||||
|
||||
httpClient.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user