From f63bfe70e13c87f65598e2288ebae530894fc3df Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 6 Jun 2022 18:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E5=B7=9E=E8=B7=91=E6=89=B9=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/jiangnanblank/CZDataBatch.groovy | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/CZDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/CZDataBatch.groovy index fe522570a..926581423 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/CZDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/CZDataBatch.groovy @@ -11,6 +11,7 @@ import com.fangjia.script.util.OpenApiClient import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject +import com.rabbitmq.client.AMQP import net.sf.json.JSONObject import org.apache.poi.hssf.usermodel.HSSFWorkbook import org.bson.types.ObjectId @@ -46,11 +47,17 @@ class CZDataBatch extends BaseBatch{ @Override void process(Object args) { def citys = CommonDatautils.findAllCity(); + citys.remove("常州"); citys.add(0, "常州") for(def city : citys){ + + def weekend = DateUtils.getFirstDayOfWeek(new Date()) + def statMap = CommonDatautils.queryAllDistrictPriceByWeekend(city, weekend) + def commids = findAllJnBankDatas(city) + def districts = converList(CommonDatautils.findAllDistricts(city, "district", fields)); - districtRun(districts); + districtRun(districts, statMap, commids); def shops = CommonDatautils.findAllDistricts(city, "shop", fields); shops = mergeShop(shops); @@ -117,7 +124,7 @@ class CZDataBatch extends BaseBatch{ return rMap; } - def districtRun(def districts){ + def districtRun(def districts, def statMap, commids){ def total = districts.size(); def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(total) @@ -127,7 +134,7 @@ class CZDataBatch extends BaseBatch{ void run() { try{ totalCount.addAndGet(1) - converDistrict(district); + converDistrict(district, statMap, commids); println totalCount.get()+"/"+total +" ["+district.city+"-"+district.region+"-"+district.name+"]"; } catch (Exception e) { e.printStackTrace() @@ -158,7 +165,7 @@ class CZDataBatch extends BaseBatch{ // executorService.awaitTermination(30, TimeUnit.MINUTES) } - def converDistrict(def dist){ + def converDistrict(def dist, def statMap, def commids){ def map = [:] //楼盘编号 /* def c_id = czIdMap.get(dist.city+"#"+dist.region+"#"+dist.name) @@ -179,7 +186,11 @@ class CZDataBatch extends BaseBatch{ map.estate_type2 = dist.estate_type2 map.build_structure = dist.build_structure // 楼盘均价 - map.avg_price = getDistrictPrice(dist.city, dist.region, dist.name, dist.address, dist.block); + def priceObj = statMap.get(dist.region+"#"+dist.name) + if(priceObj && priceObj.avg_price){ + map.avg_price = priceObj.avg_price + } + //map.avg_price = getDistrictPrice(dist.city, dist.region, dist.name, dist.address, dist.block); // 省 市 区 if(dist.city == "常州"){ map.province_code = regionMap.get("江苏"); @@ -190,23 +201,25 @@ class CZDataBatch extends BaseBatch{ map.city = dist.city; map.region = dist.region; - + if(!commids.contains(map.num_id)){ + // 公共服务配套 + map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2); + // 基础设施 + map.facilities_code = "01"; + // 居住社区成熟度 + map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2); + // 交通条件 + map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2); + // 泊车条件 / + map.stop_car_code = getStopCarCode(dist); + // /学区房类型 + map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ; + } // 地址 map.address = dist.address // 所属区域 map.in_region_code = getRegionCode(dist.region); - // 公共服务配套 - map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2); - // 基础设施 - map.facilities_code = "01"; - // 居住社区成熟度 - map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2); - // 交通条件 - map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2); - // 泊车条件 / - map.stop_car_code = getStopCarCode(dist); - // /学区房类型 - map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ; + //绿化率 map.virescence_percent = getVirescencePercent(dist.virescence_percent, map.build_date); //容积率 @@ -1102,4 +1115,18 @@ class CZDataBatch extends BaseBatch{ return list; } + def findAllJnBankDatas(city){ + def q = new BasicDBObject() + q.put("city", city) + + def keys = new BasicDBObject() + keys.put("num_id", 1) + def dbcursor = DIST_COLL.find(q, keys) + def set = new HashSet() + for(def d : dbcursor){ + set << d.num_id + } + return set; + } + }