From 60ed1fc372f5f02b6a9261d74fa7c77eb6b91ee3 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Sep 2024 11:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=B9=E9=85=8D19=E6=8D=A293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_handle/ThirdPriceMappingBatch.groovy | 72 +++++++++++++++++-- .../gj/district/FangjiaClientUtils.groovy | 4 +- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy index dd8f3e1a6..2d7515aa7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy @@ -3,12 +3,15 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.util.CommonUtils import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import org.bson.types.ObjectId import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -28,6 +31,9 @@ class ThirdPriceMappingBatch extends BaseBatch{ final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) + + final DBCollection dataProcessColl = MongoUtils.getCollectionByName("fangjia_craw", "data_process", "192.168.0.235", 27018) + def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); static main(args) { @@ -36,10 +42,12 @@ class ThirdPriceMappingBatch extends BaseBatch{ @Override public void process(Object args) { - //将新增数据同步过来 - addNemCommunity() - //接口进行匹配 +// //将新增数据同步过来 +// addNemCommunity() +// //接口进行匹配 match() + +// addOldMatchResult() } def match(){ @@ -63,7 +71,11 @@ class ThirdPriceMappingBatch extends BaseBatch{ void run() { try{ addCount.addAndGet(1) - def address = nmd.city + nmd.district + nmd.name + def address = nmd.city + if(nmd.district){ + address = address + nmd.district + } + address = address + nmd.name def jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "property", true) if(jsonObject) { def udata = new BasicDBObject() @@ -147,4 +159,56 @@ class ThirdPriceMappingBatch extends BaseBatch{ latch.await() return addCount.get(); } + + def addOldMatchResult(){ + def citys = ["上海"]//CommonUtils.findAllCity() + def keys = new BasicDBObject() + keys.put("_id", 1) + + for(def c : citys){ + def datas = thirdSeaweedMappingColl.find(new BasicDBObject("city", c).append("old_match_id", new BasicDBObject('$exists', false)), keys).toList() + println c +" 待关联数据:"+datas.size() + findResultFromDB(c, datas) + println c + " 关联数据结束 "+DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd HH:mm:ss") + } + } + + def findResultFromDB(city, datas){ + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(datas.size()) + def total = datas.size() + for(def i=0;i