diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillAgriculture.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillAgriculture.groovy new file mode 100644 index 000000000..99acbc19c --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillAgriculture.groovy @@ -0,0 +1,56 @@ +package com.fangjia.script.temp.shenjian.address + +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.fangjia.script.util.ProvinceData +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.apache.commons.lang3.StringUtils + +final DBCollection townConn = MongoUtils.getCollectionByName("fangjia_crawl", "regionalism_code", "192.168.0.235", 27018) + +ExcelUtils.multiThreadingModify("D:\\Users\\Domi\\Documents\\知识库\\重庆农商行\\重庆农商行测试地址(估家科技)V2.xlsx", { + List item -> + def id = item['A'] + def province = item['D'] + def city = item['E'] + def area = item['F'] + def township = item['G'] + def community = item['H'] + if (StringUtils.isBlank(city)) { + return ; + } + if (ProvinceData.isGovernmentCity(city)) { + townConn.find(new BasicDBObject("province", "重庆市") + .append("region", area + "区") + .append("street", township) + .append("juweihui", community), new BasicDBObject()).limit(1).each { + obj -> + item['T'] = obj.juweihui_type + } + if (item['T'] == null) { + townConn.find(new BasicDBObject("province", "重庆市") + .append("region", area + "区") + .append("juweihui", community), new BasicDBObject()).limit(1).each { + obj -> + item['T'] = obj.juweihui_type + } + } + } else { + townConn.find(new BasicDBObject("city", city + "市") + .append("region", area + "区") + .append("street", township) + .append("juweihui", community), new BasicDBObject()).limit(1).each { + obj -> + item['T'] = obj.juweihui_type + } + if (item['T'] == null) { + townConn.find(new BasicDBObject("city", city + "市") + .append("region", area + "区") + .append("juweihui", community), new BasicDBObject()).limit(1).each { + obj -> + item['T'] = obj.juweihui_type + } + } + } +}) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillNullTownshipAndComm.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillNullTownshipAndComm.groovy new file mode 100644 index 000000000..13e8d4b8b --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillNullTownshipAndComm.groovy @@ -0,0 +1,23 @@ +package com.fangjia.script.temp.shenjian.address + +import com.fangjia.script.util.ExcelUtils + +Map> map = new HashMap<>() +List> readList = ExcelUtils.read("D:\\Users\\Domi\\Documents\\知识库\\重庆农商行\\(曹合1 )重庆农商行测试地址V8-1(街道、社区、街道代码补充)处理--新-芝.xlsx") +for (List result : readList) { + map.put(result.get(0), result) +} +ExcelUtils.multiThreadingModify("D:\\Users\\Domi\\Documents\\知识库\\重庆农商行\\重庆农商行测试地址V11(优化详细地址) .xlsx", { + List item -> + def id = item['A'] + def township = item['G'] + def community = item['H'] + if (org.apache.commons.lang.StringUtils.isBlank(township)) { + item['G'] = map[id]['F'] + item['Y'] = '人工乡镇' + } + if (org.apache.commons.lang.StringUtils.isBlank(community)) { + item['H'] = map[id]['G'] + item['Z'] = '人工社区' + } +}) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillTownshipAndCommunityFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillTownshipAndCommunityFromExcel.groovy index 79cf910db..eca8609f9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillTownshipAndCommunityFromExcel.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillTownshipAndCommunityFromExcel.groovy @@ -13,27 +13,45 @@ ExcelUtils.multiThreadingModify("D:\\Users\\Domi\\Documents\\知识 def community = item['H'] String detailAddr = item['I'] + + if (detailAddr == '重庆市云阳县双江街道恒生场2-02') { + print("test") + } // 不包含街道与居委 if (StringUtils.isNotBlank(township) && StringUtils.isNotBlank(community) && !detailAddr.contains(township) && !detailAddr.contains(community) ) { if (StringUtils.isNotBlank(area)) { - int index = detailAddr.indexOf(area + "区") + area.length() + 2 - item['K'] = detailAddr.substring(0, index) + township + community + - detailAddr.substring(index) + if (detailAddr.indexOf(area + "区") > 0) { + int index = detailAddr.indexOf(area + "区") + area.length() + 1 + item['K'] = detailAddr.substring(0, index) + township + community + + detailAddr.substring(index) + } else if (detailAddr.indexOf(area + "县") > 0) { + int index = detailAddr.indexOf(area + "县") + area.length() + 1 + item['K'] = detailAddr.substring(0, index) + township + community + + detailAddr.substring(index) + } } // 不包含社区 } else if (StringUtils.isNotBlank(township) && StringUtils.isNotBlank(community) && detailAddr.contains(township) && !detailAddr.contains(community)) { - int index = detailAddr.indexOf(township) + township.length() + 1 - item['K'] = detailAddr.substring(0, index) + community + - detailAddr.substring(index) + if (detailAddr.indexOf(township) > 0) { + int index = detailAddr.indexOf(township) + township.length() + item['K'] = detailAddr.substring(0, index) + community + + detailAddr.substring(index) + } } // 只不包含街道 else if (StringUtils.isNotBlank(township) && StringUtils.isNotBlank(community) && !detailAddr.contains(township) && detailAddr.contains(community)) { if (StringUtils.isNotBlank(area)) { - int index = detailAddr.indexOf(area + "区") + area.length() + 2 - item['K'] = detailAddr.substring(0, index) + township + - detailAddr.substring(index) + if (detailAddr.indexOf(area + "区") > 0) { + int index = detailAddr.indexOf(area + "区") + area.length() + 1 + item['K'] = detailAddr.substring(0, index) + township + + detailAddr.substring(index) + } else if (detailAddr.indexOf(area + "县") > 0) { + int index = detailAddr.indexOf(area + "县") + area.length() + 1 + item['K'] = detailAddr.substring(0, index) + township + + detailAddr.substring(index) + } } } }) \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/GetAddressDetail.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/GetAddressDetail.groovy index b77b6d36c..b8833c3fa 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/GetAddressDetail.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/GetAddressDetail.groovy @@ -12,9 +12,8 @@ ners = ["houseno", "cellno", "floorno", "roomno"] Pattern GROUP_PATTERN = Pattern.compile("[一二三四五六七八九十甲乙丙丁\\d]+组") ExcelUtils.multiThreadingModify("D:\\Users\\Domi\\Documents\\知识库\\重庆农商行\\重庆农商行测试地址V11(优化详细地址) .xlsx",{List item-> - if (StringUtils.isNotBlank(item["J"])) { - //item["I"] = item["J"] - //item["W"] = "详细地址替换" + if (StringUtils.isNotBlank(item["K"])) { + item["I"] = item["K"] } // def addr = item["B"].toString() // def detailAddr = item["I"]?.toString()