Merge remote-tracking branch 'origin/master'

This commit is contained in:
majintao
2024-12-18 14:07:05 +08:00
3 changed files with 233 additions and 5 deletions
@@ -778,7 +778,229 @@ public class AddrSvcController {
return mav;
}
/**
/**
* 对私涉农识别
*/
public Object residentialVillageIdentifyAction(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 enterpriseVillageIdentifyAction(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
@@ -4209,13 +4209,13 @@ class CommonDatautils {
static def findAllNewPoiDatas(city){
String sql = "select pname,cityname,adname,name,address,location,type,id from poi_amap_2024 where cityname='${city}'"
String sql = "select pname,cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'"
def rets = []
def index= 0
ElasticUtils.executeSqlQuery(sql, { map->
// if(map.address && map.address.contains("五角场")){
index++
rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y]
rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y, "parent_id":map.parent]
// }
})
return rets;
@@ -40,11 +40,12 @@ class NewGaoDePoiBatch extends BaseBatch{
@Override
void process(Object args) {
run()
// oldPoiMagre()
}
def run(){
if (CommonDatautils.isWindow()) {
TAGS = getAllPoiType("D:\\数据\\福建省_POI_GCJ02_20240630\\POI分类白名单.xlsx")
TAGS = getAllPoiType("D:\\数据\\数据建设\\Poi\\POI分类白名单.xlsx")
}else{
TAGS = getAllPoiType("/home/goojia/gj/POI_TYPES.xlsx")
}
@@ -145,6 +146,7 @@ class NewGaoDePoiBatch extends BaseBatch{
saveObj.data_id = map.map_id
saveObj.data_source = "高德地图"
saveObj.data_source_year = "2024-11"
saveObj.parent_id = map.parent_id
if(saveObj.cat && TAGS.contains(saveObj.cat)){
saveObj.status = 0
@@ -314,7 +316,7 @@ class NewGaoDePoiBatch extends BaseBatch{
rows.each{map->
// def map = rows.get(key)
request.add(new IndexRequest("didata_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON));
request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON));
// 批量提交数据
if (request.numberOfActions() >= batchSize) {
@@ -346,4 +348,8 @@ class NewGaoDePoiBatch extends BaseBatch{
}
def oldPoiMagre(){
}
}