优化类型判断

This commit is contained in:
沈健
2021-05-18 19:49:59 +08:00
parent ae5041e93f
commit e622b12ca7
4 changed files with 52 additions and 23 deletions
@@ -10,5 +10,6 @@ class Temp {
if (val == 1.0) {
println(true)
}
}
}
@@ -96,11 +96,13 @@ class AroundExportByNewWay {
Map<Integer, List> map = new HashedMap()
Integer key = 1;
def ret = []
AtomicInteger totalCount = new AtomicInteger()
for (List<Object> district : data) {
def district_code = district.get(2)
def name = district.get(3)
if (com.fangjia.script.coredata.util.CollectionUtils.isNotEmpty(resultMap.get(district_code + name))) {
totalCount.incrementAndGet()
List currRet = resultMap.get(district_code + name)
Collections.sort(currRet)
ret.addAll(currRet)
@@ -116,6 +118,7 @@ class AroundExportByNewWay {
//FileUtils.batchCreateFile(map.get(k), "F:\\数据\\重庆农商行\\周边配套"+ k + ".dat", headArr, "utf-8")
EasyExcel.write("F:\\数据\\重庆农商行\\周边配套(文件"+ k + ")V1.xlsx").head(head).sheet("周边配套").doWrite(map.get(k));
}
print(totalCount.get() + " " + (totalCount.get() / data.size()))
printUnMatched(unMatchedMap)
executorService.shutdown()
}
@@ -154,19 +157,28 @@ class AroundExportByNewWay {
com.fangjia.script.util.ExcelUtils.write("F:\\数据\\重庆农商行\\周边配套未匹配.xlsx", ret, "周边配套");
}
static String formatType(String type) {
if (type.startsWith("09")) {
return "医院";
} else if (type.startsWith('1505')) {
return "地铁";
} else if (type.startsWith('1507')) {
return "公交";
} else if (type.startsWith("16")) {
return "银行";
} else if (type.startsWith("14")) {
return "学校";
} else if (type.startsWith("06")) {
return "商场"
static String formatType(String typeStr) {
def types = []
if (typeStr.indexOf("|") > -1) {
types = typeStr.split("\\|")
} else {
types =[typeStr]
}
for (def type : types) {
if (type.startsWith("09")) {
return "医院";
} else if (type.startsWith('1505')) {
return "地铁";
} else if (type.startsWith('1507')) {
return "公交";
} else if (type.startsWith("16")) {
return "银行";
} else if (type.startsWith("14")) {
return "学校";
} else if (type.startsWith("06")) {
return "商场"
}
}
return "未知"
}
}
@@ -89,16 +89,7 @@ class SeaweedExport {
ret[1] = obj.estate_company
ret[2] = SeaweedUtils.formatCubagePercent(obj.cubage_percent)
ret[3] = SeaweedUtils.formatVirescencePercent(obj.virescence_percent)
if (obj.alias) {
// 小区可能存在多个别名
def temp = []
for (def a : obj.alias) {
temp.add(a)
}
String als = temp.join(",")
ret[4] = als.length() > 20 ? "" : als
}
ret[4] = SeaweedUtils.formatAlias(obj.alias)
ret[5] = SeaweedUtils.formatCarSiteCount(obj.car_site_count)
ret[6] = SeaweedUtils.calcCarAndHouseholdRadio(obj.car_site_count, obj.household_count)
ret[7] = ""
@@ -155,4 +155,29 @@ class SeaweedUtils {
}
return ""
}
/**
* 标准化别名输出
*/
static formatAlias(def alias) {
if (alias) {
// 小区可能存在多个别名
def temp = []
int len = 0
for (def a : alias) {
len += a.toString().length()
if (len > 20) {
return temp.join(",")
}
temp.add(a)
}
return temp.join(",")
}
return ""
}
static void main(String[] args) {
def alias = ["金杏一村","金杏一村","金杏一村","金杏一村","金杏一村", "金杏二村"]
println(formatAlias(alias))
}
}