From dabc47389c1453d84b8c92a3aa88b3dd5b5b5f79 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Fri, 4 Mar 2022 18:13:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=8D=E5=BA=86=E5=86=9C?= =?UTF-8?q?=E5=95=86=E8=A1=8C=E6=B5=8B=E8=AF=95=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../address/FillNullTownshipAndComm.groovy | 23 ++++++++++++ .../FillTownshipAndCommunityFromExcel.groovy | 36 ++++++++++++++----- .../shenjian/address/GetAddressDetail.groovy | 5 ++- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/FillNullTownshipAndComm.groovy 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()