区分对公对私涉农识别
This commit is contained in:
+223
-1
@@ -778,7 +778,229 @@ public class AddrSvcController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 对私涉农识别
|
||||
*/
|
||||
public Object residentialVillageIdentify(AddressModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getAddress())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
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);
|
||||
String address = model.getAddress();
|
||||
params.put("address", address);
|
||||
String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null;
|
||||
// 对公
|
||||
model.setType("1");
|
||||
String villageType = "2".equals(model.getType()) ? "对公" : "对私";
|
||||
params.put("type", type);
|
||||
params.put("showFullValue", "2");
|
||||
Pager pager = new Pager(1, 1);
|
||||
List<VillageIdentify> villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager);
|
||||
VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null;
|
||||
if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) {
|
||||
Map<String, String> resultMap = new HashMap<String, String>();
|
||||
resultMap.put("province", villageResult.getProvince());
|
||||
resultMap.put("city", villageResult.getCity1());
|
||||
resultMap.put("district", villageResult.getDistrict());
|
||||
resultMap.put("town", villageResult.getTown());
|
||||
resultMap.put("committee", villageResult.getCommittee());
|
||||
resultMap.put("provinceCode", villageResult.getCityCode());
|
||||
resultMap.put("cityCode", villageResult.getCityCode());
|
||||
resultMap.put("districtCode", villageResult.getDistrictCode());
|
||||
resultMap.put("townCode", villageResult.getTownCode());
|
||||
resultMap.put("committeeCode", villageResult.getCommitteeCode());
|
||||
resultMap.put("typeCode", villageResult.getTypeCode());
|
||||
resultMap.put("typeName", villageResult.getTypeName());
|
||||
resultMap.put("verifyFlag", villageResult.getVerifyFlag());
|
||||
resultMap.put("addrVerify", villageResult.getAddrVerify());
|
||||
resultMap.put("countyLevelCity", villageResult.getCountyLevelCity());
|
||||
resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns());
|
||||
resultMap.put("countyGov", villageResult.getCountyGov());
|
||||
resultMap.put("devDistrict", villageResult.getDevDistrict());
|
||||
resultMap.put("devDistrictName", villageResult.getDevDistrictName());
|
||||
resultMap.put("devLevel", villageResult.getDevLevel());
|
||||
resultMap.put("addrArea", villageResult.getAddrArea());
|
||||
BasicModel basicModel = new BasicModel(200, "OK");
|
||||
basicModel.setResult(resultMap);
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
// params.put("showTestValue", "2");
|
||||
Integer radius = model.getRadius();
|
||||
params.put("radius", (radius != null && radius != 0) ? radius.toString() : null);
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (json != null) {
|
||||
int code = json.getInt("msgCode");
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
//我们的结果
|
||||
JSONObject result = json.getJSONObject("result");
|
||||
basicModel.setResult(result);
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对公涉农识别
|
||||
*/
|
||||
public Object enterpriseVillageIdentify(AddressModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getAddress())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
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);
|
||||
String address = model.getAddress();
|
||||
params.put("address", address);
|
||||
String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null;
|
||||
// 对公
|
||||
model.setType("2");
|
||||
String villageType = "2".equals(model.getType()) ? "对公" : "对私";
|
||||
params.put("type", type);
|
||||
params.put("showFullValue", "2");
|
||||
Pager pager = new Pager(1, 1);
|
||||
List<VillageIdentify> villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager);
|
||||
VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null;
|
||||
if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) {
|
||||
Map<String, String> resultMap = new HashMap<String, String>();
|
||||
resultMap.put("province", villageResult.getProvince());
|
||||
resultMap.put("city", villageResult.getCity1());
|
||||
resultMap.put("district", villageResult.getDistrict());
|
||||
resultMap.put("town", villageResult.getTown());
|
||||
resultMap.put("committee", villageResult.getCommittee());
|
||||
resultMap.put("provinceCode", villageResult.getCityCode());
|
||||
resultMap.put("cityCode", villageResult.getCityCode());
|
||||
resultMap.put("districtCode", villageResult.getDistrictCode());
|
||||
resultMap.put("townCode", villageResult.getTownCode());
|
||||
resultMap.put("committeeCode", villageResult.getCommitteeCode());
|
||||
resultMap.put("typeCode", villageResult.getTypeCode());
|
||||
resultMap.put("typeName", villageResult.getTypeName());
|
||||
resultMap.put("verifyFlag", villageResult.getVerifyFlag());
|
||||
resultMap.put("addrVerify", villageResult.getAddrVerify());
|
||||
resultMap.put("countyLevelCity", villageResult.getCountyLevelCity());
|
||||
resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns());
|
||||
resultMap.put("countyGov", villageResult.getCountyGov());
|
||||
resultMap.put("devDistrict", villageResult.getDevDistrict());
|
||||
resultMap.put("devDistrictName", villageResult.getDevDistrictName());
|
||||
resultMap.put("devLevel", villageResult.getDevLevel());
|
||||
resultMap.put("addrArea", villageResult.getAddrArea());
|
||||
BasicModel basicModel = new BasicModel(200, "OK");
|
||||
basicModel.setResult(resultMap);
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
// params.put("showTestValue", "2");
|
||||
Integer radius = model.getRadius();
|
||||
params.put("radius", (radius != null && radius != 0) ? radius.toString() : null);
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (json != null) {
|
||||
int code = json.getInt("msgCode");
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
//我们的结果
|
||||
JSONObject result = json.getJSONObject("result");
|
||||
//我们省级及以上有开发区,直接用我们的结果
|
||||
if (result.containsKey("devDistrictName")) {
|
||||
basicModel.setResult(result);
|
||||
} else if (!"2".equals(type)) { // 对私的不用齐梁
|
||||
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"))) {
|
||||
// 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号
|
||||
if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) {
|
||||
basicModel.setResult(result);
|
||||
mav.setModel(basicModel);
|
||||
return mav;
|
||||
}
|
||||
//有市辖建制镇, 或者城市不一样 用我们
|
||||
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", "地址有效");
|
||||
map.put("addrArea", addrArea(map, type));
|
||||
map.put("countyLevelCity", countyLevelCity(map));
|
||||
map.put("typeName", areaMap.get(map.get("typeCode")));
|
||||
basicModel.setResult(map);
|
||||
}
|
||||
} else {
|
||||
map.put("addrVerify", "地址有效");
|
||||
map.put("addrArea", addrArea(map, type));
|
||||
map.put("countyLevelCity", countyLevelCity(map));
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 涉农识别-新规则-基础版本
|
||||
*
|
||||
* @param model
|
||||
|
||||
Reference in New Issue
Block a user