From 3ffa943b864670241169bb974844acd37a7412a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E8=89=B3?= Date: Fri, 16 Apr 2021 19:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7Es=E9=A9=B1=E5=8A=A8=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/util/OpenApiClient.groovy | 4 +- .../com/fangjia/script/wenyan/temp/Abc.groovy | 315 ++---------------- .../com/fangjia/script/wenyan/temp/Api.groovy | 122 ++++--- .../fangjia/script/wenyan/temp/Bcc0622.groovy | 213 ++++++++---- 4 files changed, 252 insertions(+), 402 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy index 8c4593f1e..f35379b65 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy @@ -121,9 +121,9 @@ public class OpenApiClient { params.put("suggestName", suggestName) } - String content = new HttpRequest().get("http://192.168.10.199:9180/address/realMatch", params, "utf-8") + String content = new HttpRequest().get("http://open.fangjia.com/address/match", params, "utf-8") while (content == null) { - content = new HttpRequest().get("http://192.168.10.199:9180/address/realMatch", params, "utf-8") + content = new HttpRequest().get("http:///open.fangjia.com/address/match", params, "utf-8") println("${city} ${input} ${cat}程序调用异常") Thread.sleep(6000) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Abc.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Abc.groovy index d561f9f47..0e7cff16b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Abc.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Abc.groovy @@ -1,6 +1,8 @@ package com.fangjia.script.wenyan.temp +import com.fangjia.core.Constants import com.fangjia.core.util.DataUtil +import com.fangjia.core.util.MongoUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.OpenApiClient @@ -9,294 +11,33 @@ import net.sf.json.JSONObject import java.util.regex.Matcher import java.util.regex.Pattern -// -//def map = [:] -//ExcelUtils.read("D:\\商务数据\\上海农商行\\测试数据(上海)-上海农商行第二批0829.xlsx", 1).each {List item-> -// if(item["AF"] && item["AH"]){ -// def key = "${item["AE"]}_${item["AF"]}_${item["AH"]}".toString() -// map.get(key, []) << key -// } -//} -//ExcelUtils.modify("D:\\商务数据\\上海农商行\\测试数据(上海)-上海农商行第二批(房价网交付0905).xlsx", { List item -> -//// if(item["AF"] && item["AH"]){ -//// def key = "${item["AE"]}_${item["AF"]}_${item["AH"]}".toString() -//// List nums = map.get(key) -//// item["AT"] = nums.size() -//// } -// -// def city = "上海" -// def addr = item["AC"] -// if(addr){ -// JSONObject resp = OpenApiClient.addressMatch(city, addr, "property") -// JSONObject searchAddress = resp.getJSONObject("searchAddress") -// println searchAddress -//// item["AD"] = searchAddress.province -//// item["AE"] = searchAddress.city -//// item["AF"] = searchAddress.district -// if(searchAddress.standardAddress){ -//// item["AG"] = searchAddress.street -//// if(searchAddress.streetNumber){ -//// item["AG"] = item["AG"] + searchAddress.streetNumber -//// } -// -// if(searchAddress.township){ -// item["AP"] = searchAddress.township -// } -// } -// -// if(item["AG"]){ -// def addrMap = getRoad(item["AG"]) -// if(addrMap){ -// if(addrMap.road){ -// item["AQ"] = addrMap.road -// } -// if(addrMap.roadNumber){ -// item["AR"] = addrMap.roadNumber -// } -// } -// } -// } -// -// -//// if (item["AH"] && item["AF"]) { -//// BasicDBObject seaweed = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["AE"], item["AF"], item["AH"])) -//// if (seaweed) { -//// if (item["AR"] && item["AS"]) { -//// JSONObject eva = OpenApiClient.evaluateDistrictPrice(seaweed.city, seaweed.region, seaweed.name, item["O"], seaweed.estate_type2, item["AS"].toInteger(), item["AR"].toInteger()) -//// if (eva) { -//// item["AL"] = eva.avgPrice -//// item["AM"] = eva.totalPrice -//// } -//// } else { -//// JSONObject eva = OpenApiClient.evaluateDistrictPrice2(seaweed.city, seaweed.region, seaweed.name, item["O"], seaweed.estate_type2) -//// if (eva) { -//// item["AL"] = eva.avgPrice -//// item["AM"] = eva.totalPrice -//// } -//// } -//// } -//// -//// } -// -//},1) - - -// if(item["AK"] =~ /^\d{4}$/){ -// item["AR"] = item["AK"].toString().substring(0, 2) -// }else if(item["AK"] =~ /^\d{3}$/){ -// item["AR"] = item["AK"].toString().substring(0, 1) -// } -// if(item["AR"] && item["AH"]){ -// def key = "${item["AE"]}_${item["AF"]}_${item["AH"]}".toString() -// List nums = map.get(key) -// nums.sort() -// item["AS"] = nums[nums.size() - 1] -// item["AT"] = nums.unique().size() -// } -// println(item) -// item["AG"] = null -// def city = "上海" -// def addr = item["AC"] -// def area = item["o"] -// JSONObject resp = OpenApiClient.addressMatch(city, addr, "property") -// JSONObject searchAddress = resp.getJSONObject("searchAddress") -// item["AD"] = searchAddress.province -// item["AE"] = searchAddress.city -// item["AF"] = searchAddress.district -// if(searchAddress.standardAddress){ -// item["AG"] = searchAddress.street -// if(searchAddress.streetNumber){ -// item["AG"] = item["AG"] + searchAddress.streetNumber -// } -// } -// -// -// if(resp.getDouble("credit") > 0){ -// item["AE"] = resp.city -// item["AF"] = resp.district -// item["AH"] = resp.name -// JSONObject eva = OpenApiClient.evaluateDistrictPrice2(resp.city, resp.district, resp.name, area, resp.propertyType) -// item["AL"] = eva.avgPrice -// item["AM"] = eva.totalPrice -// item["AN"] = new Date().format("yyyy-MM-dd") -// if(!item["AG"]){ -// item["AG"] = resp.address -// } -// } -// item["AI"] = searchAddress.buildingNumber -// item["AJ"] = searchAddress.unitNumber -// item["AK"] = searchAddress.roomNumber -// println(item) -//},1) -// -def sheetIndexs = ["湘潭": 0, "嘉兴": 1, "苏州": 2] -sheetIndexs.each { String city, int sheetIndex -> -// def map = [:] -// ExcelUtils.read("D:\\商务数据\\上海农商行\\异地测试-上海农商行第二批0828(测试)1.xlsx", sheetIndex).each {List item-> -// if(item["Q"] && item["S"]){ -// def key = "${item["P"]}_${item["Q"]}_${item["S"]}".toString() -// map.get(key, []) << key -// } -// } - ExcelUtils.multiThreadingModify("D:\\商务数据\\上海农商行\\异地测试-上海农商行第二批(房价网交付0905).xlsx", { List item -> -// if(item["Q"] && item["S"]){ -// def key = "${item["P"]}_${item["Q"]}_${item["S"]}".toString() -// List nums = map.get(key) -// nums.sort() -// item["AE"] = nums.size() -// } - -// item["W"] = null -// item["X"] = null - -// BasicDBObject seaweed = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["P"], item["Q"], item["S"])) -// if(seaweed){ -// if(item["AC"] && item["AD"]){ -// JSONObject eva = OpenApiClient.evaluateDistrictPrice(seaweed.city, seaweed.region, seaweed.name, item["L"], seaweed.estate_type2, item["AD"].toInteger(), item["AC"].toInteger()) -// if(eva){ -// item["W"] = eva.avgPrice -// item["X"] = eva.totalPrice -// } -// }else{ -// JSONObject eva = OpenApiClient.evaluateDistrictPrice2(seaweed.city, seaweed.region, seaweed.name, item["L"], seaweed.estate_type2) -// if(eva){ -// item["W"] = eva.avgPrice -// item["X"] = eva.totalPrice -// } -// } -// } -// } -// if(item["AC"] && item["S"]){ -// def key = "${item["P"]}_${item["Q"]}_${item["S"]}".toString() -// List nums = map.get(key) -// nums.sort() -// item["AD"] = nums[nums.size() - 1] -// item["AE"] = nums.unique().size() -// } - -// if(item["V"] =~ /^\d{4}$/){ -// item["AC"] = item["V"].toString().substring(0, 2) -// }else if(item["V"] =~ /^\d{3}$/){ -// item["AC"] = item["V"].toString().substring(0, 1) -// }else if(item["V"] =~ /^\d{6,7}$/){ -// item["AC"] = item["V"].toString().substring(0, 2).replaceAll("^0", "") -// } - - - def addr = item["B"].toString().replaceAll("(", "").replace('区/县', "区").replace("街道/镇", "镇") - .replaceAll(")", "").replaceAll("【.*】", "").replaceAll("室/单元", "号") -// def area = item["L"] - - - def region = null - if (city == "嘉兴") { - region = "嘉善" - } else if (city == "苏州") { - region = "昆山" - } - JSONObject resp = OpenApiClient.addressMatch(city, addr, "property", false, region) - JSONObject searchAddress = resp.getJSONObject("searchAddress") - - def township = "" - if(searchAddress && searchAddress.township){ - item["AP"] = searchAddress.township - township = searchAddress.township - } - if(item["S"]){ - def addrMap = getRoad(item["S"]) - if(addrMap){ - if(addrMap.road){ - def s = addrMap.road; - if(township){ - if(township.contains(s)){ - item["AQ"] = s.replace(township, "") - }else{ - if(township.contains("镇")){ - township = township.replace("镇","") - } - item["AQ"] = s.replace(township, "") - } - }else{ - item["AQ"] = addrMap.road - } - } - if(addrMap.roadNumber){ - item["AR"] = addrMap.roadNumber - } - } - } - - - println searchAddress -// item["O"] = searchAddress.province -// item["P"] = searchAddress.city -// item["Q"] = searchAddress.district -// if (searchAddress.standardAddress) { -// item["R"] = searchAddress.street -// if (searchAddress.streetNumber) { -// item["R"] = item["R"] + searchAddress.streetNumber -// } -// } -// if (resp.getDouble("credit") > 0) { -// item["O"] = resp.province -// item["P"] = resp.city -// item["Q"] = resp.district -// item["S"] = resp.name -// JSONObject eva = OpenApiClient.evaluateDistrictPrice2(resp.city, resp.district, resp.name, area, resp.propertyType) -// item["W"] = eva.avgPrice -// item["X"] = eva.totalPrice -// item["Y"] = new Date().format("yyyy-MM-dd") -// if (!item["R"]) { -// item["R"] = resp.address -// } -// } -// item["T"] = searchAddress.buildingNumber -// item["U"] = searchAddress.unitNumber -// item["V"] = searchAddress.roomNumber -// if(city == "湘潭"){ -// String roomNumber = DataUtil.match(addr, Pattern.compile("\\d+(号|(号房))\$")) -// if(roomNumber){ -// item["V"] = roomNumber.replaceAll("号", '').replaceAll('房', "") -// } -// roomNumber = DataUtil.match(addr, Pattern.compile("\\d{6,8}\$")) -// if(roomNumber){ -// item["V"] = roomNumber.replaceAll("号", '').replaceAll('房', "") -// } -// -// } +def school = MongoUtils.getDbCollection(Constants.FANGJIA_CRAWL_MONGO_URI, "fangjia_craw", "school2") +new File("D:\\数据\\学校数据").eachFile {File file-> + ExcelUtils.read(file.getAbsolutePath(), 0).each {List item-> + BasicDBObject dbo = new BasicDBObject() + dbo.city = item["A"] + dbo.region = item["B"] + dbo.name = item["C"] + dbo.address = item["E"] + dbo.attribute = item["G"] + dbo.property = item["H"] + dbo.category = "小学" + dbo.location = [DataUtil.roundDouble(item["I"], 6), DataUtil.roundDouble(item["J"], 6)] + school.insert(dbo) + println(dbo) + } + ExcelUtils.read(file.getAbsolutePath(), 1).each {List item-> + BasicDBObject dbo = new BasicDBObject() + dbo.city = item["A"] + dbo.region = item["B"] + dbo.name = item["C"] + dbo.address = item["E"] + dbo.attribute = item["G"] + dbo.property = item["H"] + dbo.category = "中学" + dbo.location = [item["I"], item["J"]] + school.save(dbo) println(item) - }, sheetIndex) -} - - -def getRoad(def s){ - def rex = ".*(路|街道|街|大道|巷|道|里).*\\d+(弄|号)\$" - Pattern pattern = Pattern.compile(rex); - Matcher matcher = pattern.matcher(s); - - List list = new ArrayList(); - while (matcher.find()) { - list.add(matcher.group()); } - if(list && list.size()>0){ - def s1 = list[0] - def road = getRexText(s1, ".*(路|街道|街|大道|巷|道|里)") - def num = getRexText(s1, "\\d+") - return ["road":road, "roadNumber":num] - }else{ - def road = getRexText(s, ".*(路|街道|街|大道|巷|道|里)") - return ["road":road] - } - return null -} - -def getRexText(s, regx){ - Pattern pattern = Pattern.compile(regx); - Matcher matcher = pattern.matcher(s); - - while (matcher.find()) { - return matcher.group(); - } - return null; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Api.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Api.groovy index 1c9e130af..3e76b3eef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Api.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Api.groovy @@ -1,9 +1,16 @@ package com.fangjia.script.wenyan.temp +import com.fangjia.core.Constants import com.fangjia.core.ProvinceData import com.fangjia.core.RegionData +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.OpenApiClient +import com.mongodb.BasicDBObject +import net.sf.json.JSONObject import org.apache.commons.lang3.StringUtils +import org.openqa.selenium.json.Json //ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\阳光保险重跑数据(1).xlsx", { List item -> @@ -30,8 +37,6 @@ import org.apache.commons.lang3.StringUtils //}, 0,"结果") - - //ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\阳光保险重跑数据(1).xlsx", { List item -> // if (item["T"] == null || ![1, 2, 4].contains(item["T"].toString().toDouble().toInteger())) { // return @@ -114,43 +119,80 @@ import org.apache.commons.lang3.StringUtils // println("${key} ${names.join(",")}") // } //} -ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\地址标准化.xlsx",{List item-> - String address = ""; - if(StringUtils.isNotBlank(item["B"]) && !ProvinceData.isGovernmentCity(item["B"])){ - address = ProvinceData.getDisplay(item["B"]) +//ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\地址标准化.xlsx",{List item-> +// String address = ""; +// if(StringUtils.isNotBlank(item["B"]) && !ProvinceData.isGovernmentCity(item["B"])){ +// address = ProvinceData.getDisplay(item["B"]) +// } +// if(StringUtils.isNotBlank(item["C"])){ +// String cityDisplay = CityData.getCityDisplay(item["C"]); +// if(cityDisplay != null){ +// address = address + cityDisplay +// }else{ +// address = address + item["C"] + "市" +// } +// } +// if(StringUtils.isNotBlank(item["D"])){ +// String orgDistrict = RegionData.getOrgName(item["C"], item["D"]); +// if(StringUtils.isNotBlank(orgDistrict) && address.indexOf(orgDistrict) == -1){ +// address = address + orgDistrict +// } +// } +// if(StringUtils.isNotBlank(item["E"])){ +// address = address + item["E"] +// } +// if(StringUtils.isNotBlank(item["F"])){ +// address = address + item["F"] +// } +// if(StringUtils.isNotBlank(item["G"])){ +// address = address + item["G"] +// } +// if(StringUtils.isNotBlank(item["H"])){ +// address = address + item["H"] + "栋" +// } +// if(StringUtils.isNotBlank(item["i"])){ +// address = address + item["i"] + "单元" +// } +// if(StringUtils.isNotBlank(item["J"])){ +// address = address + item["J"] + "室" +// } +// item["K"] = address +// println(address) +//}) +def school = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, "fangjia", "guiding_price") +ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\深圳市住建局二手房指导价.xlsx", { List item -> + if (item["G"]) { + BasicDBObject seaweed = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["G"], item["H"], item["I"])) + BasicDBObject guid = new BasicDBObject() + guid.guiding_type = 0 + guid.estate_type = seaweed.estate_type2 + guid.house_type = 0 + guid.c_date = new Date() + guid.guiding_person = "深圳房管局" + guid.guiding_date = Date.parse('yyyyMMdd', '20210411') + guid.category = "district" + guid.guiding_value = (int)item["E"] + guid.name = item["D"] + guid.city = item["G"] + guid.region = item["H"] + guid.name = item["i"] + school.insert(guid) + println(guid) + } - if(StringUtils.isNotBlank(item["C"])){ - String cityDisplay = CityData.getCityDisplay(item["C"]); - if(cityDisplay != null){ - address = address + cityDisplay - }else{ - address = address + item["C"] + "市" - } - } - if(StringUtils.isNotBlank(item["D"])){ - String orgDistrict = RegionData.getOrgName(item["C"], item["D"]); - if(StringUtils.isNotBlank(orgDistrict) && address.indexOf(orgDistrict) == -1){ - address = address + orgDistrict - } - } - if(StringUtils.isNotBlank(item["E"])){ - address = address + item["E"] - } - if(StringUtils.isNotBlank(item["F"])){ - address = address + item["F"] - } - if(StringUtils.isNotBlank(item["G"])){ - address = address + item["G"] - } - if(StringUtils.isNotBlank(item["H"])){ - address = address + item["H"] + "栋" - } - if(StringUtils.isNotBlank(item["i"])){ - address = address + item["i"] + "单元" - } - if(StringUtils.isNotBlank(item["J"])){ - address = address + item["J"] + "室" - } - item["K"] = address - println(address) +// if(!item["F"]){ +// JSONObject resp = OpenApiClient.addressMatch("深圳", item["D"], 'property', false, item["B"]) +// if(resp.id){ +// BasicDBObject seaweed = DbUtils.seaweed.findById(resp.id) +// if(seaweed){ +// item["F"] = seaweed._id.toString() +// item["G"] = seaweed.city +// item["H"] = seaweed.region +// item["I"] = seaweed.name +// } +// println(item) +// } +// +// } + }) \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Bcc0622.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Bcc0622.groovy index 33458dadc..0d24b2d81 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Bcc0622.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Bcc0622.groovy @@ -1,82 +1,149 @@ package com.fangjia.script.wenyan.temp -import com.fangjia.core.util.HouseValidator +import com.fangjia.core.Constants +import com.fangjia.core.util.DateUtil +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.OpenApiClient -import net.sf.json.JSONObject +import com.fangjia.script.util.FangJiaAreaMapUtils +import com.mongodb.BasicDBObject +import org.bson.types.ObjectId -ExcelUtils.multiThreadingModify("D:\\商务数据\\建设银行\\副本5市成交案例(测试).xlsx",{List item-> -// if(item["R"]){ -// return -// } -// def calcDate = null -// if(item["E"]){ -// calcDate = item["E"].toString().substring(0, 10) -// }else{ -// calcDate = item["B"].toString().substring(0, 10) -// } -// def floor = item["I"].toString().toDouble().toInteger().toString() -// def maxFloor = item["J"].toString().toDouble().toInteger().toString() -// def dir = HouseValidator.formatDirectionToCode(item["L"]).toString() -// def fit = HouseValidator.formatFitmentToCode(item["M"]).toString() -// def params =[:] -// params.city = item["F"] -// params.district = item["p"] -// params.name = item['Q'] -// params.size = item["C"].toString() -// params.floor = floor -// params.maxFloor = maxFloor -// params.direction = dir -// params.decoration = fit -// params.calDate = calcDate -// params.__refresh_cache = "1" -// params.scope = "1" -// JSONObject evaResp = OpenApiClient.evaluate(params) -// if(evaResp.result && evaResp.result.credit > 0.4){ -// item["R"] = evaResp.result.totalPrice -// } +def school = MongoUtils.getDbCollection(Constants.FANGJIA_CRAWL_MONGO_URI, "fangjia_craw", "school2") +//school.find(new BasicDBObject("source", "查学区")).each {BasicDBObject item-> +// item.category = item.attribute +// item.attribute = null +// school.save(item) // println(item) - -// if(item["H"] != "中粮云景花园"){ -// return +//} +//ExcelUtils.read("D:\\Users\\wenyan\\Downloads\\无经纬度学校-结果.xlsx").each {List item-> +// if(item["P"] != null){ +// def location = item["P"].split(",") as List +// def data = new BasicDBObject() +// data.map_name = item["N"] +// data.map_region = item["R"] +// data.map_address = item["N"] +// data.map_type = item["S"] +// data.location = [location[0].toString().toDouble(),location[1].toString().toDouble()] +// school.update(new BasicDBObject("_id", new ObjectId(item["A"])), new BasicDBObject('$set', data)) +// println(data) // } - def city = item["F"] - def region = item["G"] - def name = item["H"].toString() - def addr = item["D"] - JSONObject resp = OpenApiClient.addressMatch(city, addr, "property" , false, region, name) - if(resp.name){ - item["p"] = resp.district - item['Q'] = resp.name +//} +regionCodeMap = [:] +def cityCodeMap = ["苏州":"320500","合肥":"340100", "西安":"610000"] +for(def city : cityCodeMap.keySet()){ + def datas = FangJiaAreaMapUtils.convertToOfficials(city); + for(def d : datas){ + regionCodeMap.put(city+"-"+d.fangjia_district, d.district_code) } - println(item) -// def calcDate = null -// if(item["E"]){ -// calcDate = item["E"].toString().substring(0, 10) -// }else{ -// calcDate = item["B"].toString().substring(0, 10) -// } -// def floor = item["I"].toString().toDouble().toInteger().toString() -// def maxFloor = item["J"].toString().toDouble().toInteger().toString() -// def dir = HouseValidator.formatDirectionToCode(item["L"]).toString() -// def fit = HouseValidator.formatFitmentToCode(item["M"]).toString() -// def params =[:] -// params.city = resp.city -// params.district = resp.district -// params.name = resp.name -// params.size = item["C"].toString() -// params.floor = floor -// params.maxFloor = maxFloor -// params.direction = dir -// params.decoration = fit -// params.calDate = calcDate -// params.scope = "1" -// JSONObject evaResp = OpenApiClient.evaluate(params) -// if(evaResp.result && evaResp.result.credit > 0.4){ -// item["R"] = evaResp.result.totalPrice -// } -// println(item) -// } +} +def data = Collections.synchronizedList([]) +data << ["ID","CITYID","DISTID","COMMNAME","LNG","LAT","ADDRESS","PS","PS_ADDR","PS_TYPE","PS_SEQNO","PS_LONGITUDE","PS_LATITUDE","MS","MS_ADDR","MS_TYPE","MS_SEQNO","MS_LONGITUDE","MS_LATITUDE","REMARK","CREATETIME","UPDATETIME","SOURCECODE"] +cityCodeMap.keySet().each {def city-> + DbUtils.multiThreadingExecuteQueryOnSeaweed(DbUtils.buildSeaweedQuery(city),{BasicDBObject seaweed-> + if(seaweed.lng){ + def item = [] + item << seaweed._id.toString() + item << cityCodeMap.get(seaweed.city) + item << regionCodeMap.get(seaweed.city + "-" + seaweed.region) + item << seaweed.name + def lng = com.fangjia.core.util.DataUtil.roundDouble(seaweed.lng/10000000000d, 6) + def lat = com.fangjia.core.util.DataUtil.roundDouble(seaweed.lat/10000000000d, 6) + item << lng + item << lat + item << seaweed.address + BasicDBObject location = new BasicDBObject() + BasicDBObject near = new BasicDBObject() + BasicDBObject geometry = new BasicDBObject("type", "Point") + geometry.append("coordinates", [lng, lat]) + near.append('$maxDistance', 1000) + near.append('$geometry', geometry) + location.append('$near', near) + BasicDBObject query = new BasicDBObject() + query.append("location", location) + query.append("attribute",new BasicDBObject('$in', ['省重点', '市重点', '区重点', '县重点', '省级示范'])) + query.append("category", new BasicDBObject('$in', ['中学'])) + BasicDBObject midSchool = school.findOne(query) +// for(def level in ['省重点', '市重点', '区重点', '县重点', '普通']){ +// query.append("location", location) +// query.append("attribute", level) +// midSchool = school.findOne(query) +// if(midSchool){ +// break +// } +// } +// if(!midSchool){ +// query.removeField("attribute") +// midSchool = school.findOne(query) +// } + BasicDBObject primarySchool=null + query.append("category", new BasicDBObject('$in', ['小学'])) + primarySchool = school.findOne(query) +// for(def level in ['省重点', '市重点', '区重点', '县重点', '普通']){ +// query.append("location", location) +// query.append("attribute", level) +// primarySchool = school.findOne(query) +// if(primarySchool){ +// break +// } +// } +// if(!primarySchool){ +// query.removeField("attribute") +// primarySchool = school.findOne(query) +// } + if(primarySchool){ + item << primarySchool.name + item << primarySchool.address + item << primarySchool.attribute + item << null + item << primarySchool.location[0] + item << primarySchool.location[1] + }else { + item << null + item << null + item << null + item << null + item << null + item << null + } + if(midSchool){ + item << midSchool.name + item << midSchool.address + item << midSchool.attribute + item << null + item << midSchool.location[0] + item << midSchool.location[1] + }else { + item << null + item << null + item << null + item << null + item << null + item << null + } + item << null + Date c_date = seaweed.c_date + Date m_date = seaweed.m_date + if(!c_date && !m_date){ + c_date = DateUtil.add(new Date(), Calendar.YEAR, -1) + } + if(!c_date){ + c_date = m_date + } + if(!m_date){ + m_date = c_date + } + item <