update
This commit is contained in:
+41
-9
@@ -29,7 +29,7 @@ class PaimaiDataSend {
|
|||||||
def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017";
|
def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017";
|
||||||
DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl)
|
DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl)
|
||||||
|
|
||||||
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30)
|
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20)
|
||||||
|
|
||||||
static main(args) {
|
static main(args) {
|
||||||
def task = new PaimaiDataSend()
|
def task = new PaimaiDataSend()
|
||||||
@@ -198,9 +198,10 @@ class PaimaiDataSend {
|
|||||||
def index = 0
|
def index = 0
|
||||||
def q = new BasicDBObject()
|
def q = new BasicDBObject()
|
||||||
// q.put("city","宿迁")
|
// q.put("city","宿迁")
|
||||||
q.put("url","https://sf-item.taobao.com/sf_item/649014193736.htm")
|
q.put("url","https://sf-item.taobao.com/sf_item/665877683620.htm")
|
||||||
//https://sf-item.taobao.com/sf_item/657131607486.htm
|
//https://sf-item.taobao.com/sf_item/657131607486.htm
|
||||||
// q.put("parser_status", new BasicDBObject('$exists',false))
|
// q.put("parser_status", new BasicDBObject('$exists',false))
|
||||||
|
// q.put("finishDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2022-09-01")))
|
||||||
def dbcursor = ali_fp_coll.find(q).batchSize(2000)
|
def dbcursor = ali_fp_coll.find(q).batchSize(2000)
|
||||||
|
|
||||||
def rets = []
|
def rets = []
|
||||||
@@ -263,10 +264,11 @@ class PaimaiDataSend {
|
|||||||
def aliZcRun2(){
|
def aliZcRun2(){
|
||||||
def index = 0
|
def index = 0
|
||||||
def q = new BasicDBObject()
|
def q = new BasicDBObject()
|
||||||
// q.put("city","宿迁")
|
q.put("city","苏州")
|
||||||
// q.put("region","姑苏")
|
// q.put("region","姑苏")
|
||||||
q.put("url","https://zc-item.taobao.com/auction/672615219601.htm")
|
// q.put("url","https://zc-item.taobao.com/auction/636884262340.htm")
|
||||||
def dbcursor = ali_zc_coll.find(q).batchSize(1000)
|
def dbcursor = ali_zc_coll.find(q).batchSize(1000)
|
||||||
|
def rets = []
|
||||||
for(def d : dbcursor){
|
for(def d : dbcursor){
|
||||||
index++
|
index++
|
||||||
println "ali-zc: "+index
|
println "ali-zc: "+index
|
||||||
@@ -290,19 +292,40 @@ class PaimaiDataSend {
|
|||||||
result.put("region", d.region)
|
result.put("region", d.region)
|
||||||
json.put("result", result)
|
json.put("result", result)
|
||||||
|
|
||||||
byte[] packedMsg = MessageUtils.pack(json)
|
rets << result
|
||||||
CommonUtils.sendMessage("result2parse2dev", packedMsg)
|
}
|
||||||
|
println "共:"+rets.size()
|
||||||
|
|
||||||
|
def totalCount = new AtomicLong()
|
||||||
|
final CountDownLatch latch = new CountDownLatch(rets.size())
|
||||||
|
for(def i=0;i<rets.size();i++){
|
||||||
|
final def json = rets[i]
|
||||||
|
fixedThreadPool.execute(new Runnable() {
|
||||||
|
void run() {
|
||||||
|
try{
|
||||||
|
totalCount.addAndGet(1)
|
||||||
|
byte[] packedMsg = MessageUtils.pack(json)
|
||||||
|
CommonUtils.sendMessage("result2parse2dev", packedMsg)//result2parse2dev
|
||||||
|
|
||||||
def udata = new BasicDBObject()
|
def udata = new BasicDBObject()
|
||||||
udata.put("parser_status", 4)
|
udata.put("parser_status", 4)
|
||||||
udata.put("m_date", new Date())
|
udata.put("m_date", new Date())
|
||||||
ali_zc_coll.update(new BasicDBObject("_id", d.get("_id")), new BasicDBObject('$set', udata))
|
ali_zc_coll.update(new BasicDBObject("_id", json.get("_id")), new BasicDBObject('$set', udata))
|
||||||
|
println "send: "+totalCount.get()
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
latch.countDown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
latch.await()
|
||||||
|
}
|
||||||
|
|
||||||
def paimaiSendToEs(){
|
def paimaiSendToEs(){
|
||||||
def rets = getPaimaiDatas()
|
def rets = getPaimaiDatas()
|
||||||
|
println "共:"+rets.size()
|
||||||
def totalCount = new AtomicLong()
|
def totalCount = new AtomicLong()
|
||||||
final CountDownLatch latch = new CountDownLatch(rets.size())
|
final CountDownLatch latch = new CountDownLatch(rets.size())
|
||||||
for(def i=0;i<rets.size();i++){
|
for(def i=0;i<rets.size();i++){
|
||||||
@@ -312,7 +335,7 @@ class PaimaiDataSend {
|
|||||||
try{
|
try{
|
||||||
totalCount.addAndGet(1)
|
totalCount.addAndGet(1)
|
||||||
def flag = FangjiaClientUtils.saveToEsPaimai(m)
|
def flag = FangjiaClientUtils.saveToEsPaimai(m)
|
||||||
println totalCount.get()+" "+m.city +" "+m.name +" "+flag
|
println totalCount.get()+" "+m.city +" "+m.title +" "+flag
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
} finally {
|
} finally {
|
||||||
@@ -326,10 +349,11 @@ class PaimaiDataSend {
|
|||||||
|
|
||||||
def getPaimaiDatas(){
|
def getPaimaiDatas(){
|
||||||
def q = new BasicDBObject()
|
def q = new BasicDBObject()
|
||||||
q.put("mDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2022-08-01")))
|
q.put("mDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2022-07-01")))
|
||||||
def dbcursor = paimai43_COLL.find(q).batchSize(1000)
|
def dbcursor = paimai43_COLL.find(q).batchSize(1000)
|
||||||
def rets = []
|
def rets = []
|
||||||
for(def d : dbcursor){
|
for(def d : dbcursor){
|
||||||
|
if(d.city){
|
||||||
def o = [:]
|
def o = [:]
|
||||||
o.addPrice = d.addPrice
|
o.addPrice = d.addPrice
|
||||||
o.agencyName = d.agencyName
|
o.agencyName = d.agencyName
|
||||||
@@ -375,8 +399,16 @@ class PaimaiDataSend {
|
|||||||
o.type = d.type
|
o.type = d.type
|
||||||
o.unitNum = d.unitNum
|
o.unitNum = d.unitNum
|
||||||
o.url = d.url
|
o.url = d.url
|
||||||
|
if(d.url.contains("taobao.com")){
|
||||||
|
o.source = "淘宝"
|
||||||
|
}else if(d.url.contains("jd.com")){
|
||||||
|
o.source = "京东"
|
||||||
|
}else if(d.url.contains("rmfysszc.gov.cn")){
|
||||||
|
o.source = "人民法院讼诉网"
|
||||||
|
}
|
||||||
rets << o
|
rets << o
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return rets;
|
return rets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user