This commit is contained in:
2022-07-20 16:40:58 +08:00
parent 46a58b5fce
commit 2828feab7c
24 changed files with 326 additions and 146 deletions
@@ -60,39 +60,39 @@ class BigdataDealBatch extends BaseBatch{
addDealPriceMatch(city); addDealPriceMatch(city);
// } // }
} }
def rows = [] // def rows = []
def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] // def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"]
def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() // def cityCodeDataMap = CcbCommonUtils.findCityCodeValue()
for(def city : citys){ // for(def city : citys){
def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) // def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city)
def ppeDists = [:] // def ppeDists = [:]
//
def statMap = [:]//getDistrictStatByCity(city, weekend) // def statMap = [:]//getDistrictStatByCity(city, weekend)
if(city=="上海"){ // if(city=="上海"){
def youDataTrade = getYouDaData(statMap) // def youDataTrade = getYouDaData(statMap)
def youdaDatas = createData(youDataTrade, cityCodeDataMap, distCodeMap, "youda") // def youdaDatas = createData(youDataTrade, cityCodeDataMap, distCodeMap, "youda")
rows.addAll(youdaDatas) // rows.addAll(youdaDatas)
println city +" "+youdaDatas.size() // println city +" "+youdaDatas.size()
} // }
//
//
def trades = getCityData(city, statMap, ppeDists) // def trades = getCityData(city, statMap, ppeDists)
def rets = createData(trades, cityCodeDataMap, distCodeMap, "other") // def rets = createData(trades, cityCodeDataMap, distCodeMap, "other")
rows.addAll(rets) // rows.addAll(rets)
println city +" 成交共:"+rets.size() // println city +" 成交共:"+rets.size()
//
def cityDatas = [] // def cityDatas = []
cityDatas << headers // cityDatas << headers
cityDatas.addAll(rows) // cityDatas.addAll(rows)
} // }
//
def fileName = "/home/goojia/ccb/BIGDATA_DEAL_GJ.dat" // def fileName = "/home/goojia/ccb/BIGDATA_DEAL_GJ.dat"
if(CommonDatautils.isWindow()){ // if(CommonDatautils.isWindow()){
fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_DEAL_GJ.dat" // fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_DEAL_GJ.dat"
} // }
//
FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false); // FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false);
println "txt 生成" // println "txt 生成"
} }
@@ -74,7 +74,7 @@ class BigdataForsaleBatch extends BaseBatch{
// def distIds = getDistrictIds(cityCodeDataMap.get(city)) // def distIds = getDistrictIds(cityCodeDataMap.get(city))
def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city)
def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"]); def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"]);
exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20220518, 20220619); exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20220618, 20220719);
// exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20210801, 20210831); // exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20210801, 20210831);
//测试通过匹配接口配房源效果 //测试通过匹配接口配房源效果
// exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20201201, 20211118) // exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20201201, 20211118)
@@ -454,6 +454,11 @@ class BigdataForsaleBatch extends BaseBatch{
println city +" "+name+" "+seawater._id.toString()+" "+seawater.estate_type println city +" "+name+" "+seawater._id.toString()+" "+seawater.estate_type
continue; continue;
} }
if(seawater.estate_type&& seawater.estate_type.contains("别墅")){
println city +" "+name+" "+seawater._id.toString()+" "+seawater.estate_type
continue;
}
} }
if(!seawater.total_price){ if(!seawater.total_price){
@@ -75,13 +75,13 @@ class TradeStatLog {
def run(){ def run(){
def citys = CcbCommonUtils.citys; def citys = CcbCommonUtils.citys;
def rets = [] def rets = []
rets << ["城市","3月总量","4月总量","5月总量","占比","贝壳","链家", "我爱我家","房天下","中原"] rets << ["城市","4月总量","5月总量","6月总量","占比","贝壳","链家", "我爱我家","房天下","中原"]
def sources = ["贝壳找房","链家在线", "我爱我家","房天下","中原地产"] def sources = ["贝壳找房","链家在线", "我爱我家","房天下","中原地产"]
//def startDate = "2021-05-01" //def startDate = "2021-05-01"
def startDate = "2022-03-01" def startDate = "2022-04-01"
def date = "2022-04-01" def date = "2022-05-01"
def endDate = "2022-05-01" def endDate = "2022-06-01"
def newDate = "2022-06-01" def newDate = "2022-07-01"
for(def city : citys){ for(def city : citys){
def lastMonthCount = findTradesCount(city, null, DateUtils.parseFromTightByPattern(startDate,"yyyy-MM-dd"), DateUtils.parseFromTightByPattern(date,"yyyy-MM-dd")) def lastMonthCount = findTradesCount(city, null, DateUtils.parseFromTightByPattern(startDate,"yyyy-MM-dd"), DateUtils.parseFromTightByPattern(date,"yyyy-MM-dd"))
@@ -131,7 +131,7 @@ class TradeStatLog {
} }
ExcelUtils.write("D:\\数据\\建行\\房产估值\\成交\\2022-05成交统计.xlsx", rets, "数据") ExcelUtils.write("D:\\数据\\建行\\房产估值\\成交\\2022-06成交统计.xlsx", rets, "数据")
println "表格生成完成" println "表格生成完成"
} }
@@ -877,6 +877,8 @@ class CommonDatautils {
keys.put("finish_building_date", 1) keys.put("finish_building_date", 1)
keys.put("mapping_alias", 1) keys.put("mapping_alias", 1)
keys.put("sid", 1) keys.put("sid", 1)
keys.put("status", 1)
try{ try{
DSCursor cursor = getDataStoreConnection().find(q, keys); DSCursor cursor = getDataStoreConnection().find(q, keys);
if(cursor){ if(cursor){
@@ -2278,6 +2280,24 @@ class CommonDatautils {
return prices; return prices;
} }
public static def queryDistrictPrices(city, region, startDate){
DBObject queryCondition = new BasicDBObject()
queryCondition.put("city", city);
queryCondition.put("region", region);
queryCondition.put('weekend', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)));
DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
def prices = [];
while(cur.hasNext()) {
DBObject dbo = cur.next()
def price = dbo.get("avg_price");
if(price){
prices << price;
}
}
return prices;
}
public static def queryDistrictPricesByDate(city, region, name, startDate, endDate){ public static def queryDistrictPricesByDate(city, region, name, startDate, endDate){
DBObject queryCondition = new BasicDBObject() DBObject queryCondition = new BasicDBObject()
@@ -3031,9 +3051,26 @@ class CommonDatautils {
return price; return price;
} }
static def queryCityRegionPrices(city, region, startDate){
DBObject queryCondition = new BasicDBObject()
queryCondition.put("city", city);
queryCondition.put("region", region);
queryCondition.put("block", null);
queryCondition.put('weekend', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)));
DBCursor cur = REGION_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
cur.setOptions(Bytes.QUERYOPTION_NOTIMEOUT)
def prices = [];
while(cur.hasNext()) {
DBObject dbo = cur.next()
prices << dbo.get("avg_price");
}
return prices;
}
static def queryCityRegionBlockPrice(city, region, block, startDate, endDate){ static def queryCityRegionBlockPrice(city, region, block, startDate, endDate){
DBObject queryCondition = new BasicDBObject() DBObject queryCondition = new BasicDBObject()
queryCondition.put("city", city); queryCondition.put("city", city);
@@ -129,7 +129,7 @@ class DistrictPriceExportBatch extends BaseBatch{
if(curPrice){ if(curPrice){
m << dbo.get("_id").toString()//均价ID m << dbo.get("_id").toString()//均价ID
}else{ }else{
m << "" m << new ObjectId().toString()
} }
m << rMap.get("_id").toString()//楼盘ID m << rMap.get("_id").toString()//楼盘ID
m << rMap.city m << rMap.city
@@ -210,6 +210,7 @@ class DistrictPriceExportBatch extends BaseBatch{
}else{ }else{
def udata = new BasicDBObject() def udata = new BasicDBObject()
def o = new BasicDBObject() def o = new BasicDBObject()
println r[0]
o.put("_id", new ObjectId(r[0])) o.put("_id", new ObjectId(r[0]))
o.put("comm_id", r[1]) o.put("comm_id", r[1])
o.put("city", r[2]) o.put("city", r[2])
@@ -1,5 +1,6 @@
package com.fangjia.script.fuzhou package com.fangjia.script.fuzhou
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.MongoUtils
@@ -55,11 +56,17 @@ class FzDataResultStat {
List<String> list1= FileUtils.readLines(new File("D:\\数据\\福州\\FJW_DISTRICT_STAT_${curMonth}.csv")) List<String> list1= FileUtils.readLines(new File("D:\\数据\\福州\\FJW_DISTRICT_STAT_${curMonth}.csv"))
def distkeys = []
def map1 = [:] def map1 = [:]
for(def s : list1){ for(def s : list1){
def row = s.split("@\\|@") def row = s.split("@\\|@")
def key = row[2]+"##"+row[3]+"##"+row[4] def key = row[2]+"##"+row[3]+"##"+row[4]
map1.put(key, row[5]) if(!distkeys.contains(key)){
distkeys << key
}else{
println "重复:"+key
}
map1.put(key, row)
} }
List<String> list2 = FileUtils.readLines(new File("D:\\数据\\福州\\FJW_DISTRICT_STAT_${lastMonth}.csv")) List<String> list2 = FileUtils.readLines(new File("D:\\数据\\福州\\FJW_DISTRICT_STAT_${lastMonth}.csv"))
@@ -67,19 +74,29 @@ class FzDataResultStat {
for(def s : list2) { for(def s : list2) {
def row = s.split("@\\|@") def row = s.split("@\\|@")
def key = row[2] + "##" + row[3] + "##" + row[4] def key = row[2] + "##" + row[3] + "##" + row[4]
map2.put(key, row[5]) map2.put(key, row)
} }
def rows = [] def rows = []
rows << ["城市","区域","名称","${curMonth}价格","${lastMonth}价格", "涨跌幅"] rows << ["城市","区域","名称","${curMonth}价格","${lastMonth}价格", "涨跌幅", "是否有效"]
map1.each {k,v-> map1.each {k,list->
def row = [] def row = []
def keys = k.split("##") def keys = k.split("##")
def lastPrice = map2.get(k)
def markup = null def lastObj = map2.get(k)
if(v && lastPrice){ def lastPrice = null
markup = (v.toInteger() - lastPrice.toInteger())*100.0/lastPrice.toInteger() if(lastObj){
lastPrice = lastObj[5]
} }
rows << [keys[0], keys[1], keys[2], v.toString(), lastPrice.toString(), markup] def markup = null
if(list && lastPrice){
markup = (list[5].toInteger() - lastPrice.toInteger())*100.0/lastPrice.toInteger()
}
def dist = CommonDatautils.findDistrictById(list[1])
def flag = "有效"
if(dist.status!=0){
flag = "失效"
}
rows << [keys[0], keys[1], keys[2], list[5].toString(), lastPrice.toString(), markup, flag]
} }
ExcelUtils.write("D:\\数据\\福州\\价格比对_${curMonth}.xlsx", rows, "数据") ExcelUtils.write("D:\\数据\\福州\\价格比对_${curMonth}.xlsx", rows, "数据")
@@ -73,8 +73,8 @@ class HouseExportBatch extends BaseBatch{
def fileName = "/fzbank/output/FJW_HOUSE_"+curDate+".csv" def fileName = "/fzbank/output/FJW_HOUSE_"+curDate+".csv"
def dataCodeFileName = "/fzbank/output/FJW_HOUSE_"+curDate+".sha512" def dataCodeFileName = "/fzbank/output/FJW_HOUSE_"+curDate+".sha512"
if(CommonDatautils.isWindow()){ if(CommonDatautils.isWindow()){
fileName = "F:\\数据\\福州\\FJW_HOUSE_"+curDate+".csv" fileName = "D:\\数据\\福州\\FJW_HOUSE_"+curDate+".csv"
dataCodeFileName = "F:\\数据\\福州\\FJW_HOUSE_"+curDate+".sha512" dataCodeFileName = "D:\\数据\\福州\\FJW_HOUSE_"+curDate+".sha512"
} }
batchCreateFile(ret, fileName, headers, charset); batchCreateFile(ret, fileName, headers, charset);
println "数据文件输出完成......" println "数据文件输出完成......"
@@ -325,8 +325,8 @@ class HouseExportBatch extends BaseBatch{
// int endDate = 20191201 // int endDate = 20191201
def startDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyyMMdd") def startDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyyMMdd")
def endDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()), "yyyyMMdd"); // def endDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()), "yyyyMMdd");
def endDate = "20220710"
QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(startDate).to(endDate).includeLower(true).includeUpper(false); QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(startDate).to(endDate).includeLower(true).includeUpper(false);
QueryBuilder area_range = QueryBuilders.rangeQuery("area").from(20).to(500).includeLower(true).includeUpper(false); QueryBuilder area_range = QueryBuilders.rangeQuery("area").from(20).to(500).includeLower(true).includeUpper(false);
// QueryBuilder room_range = QueryBuilders.rangeQuery("room").from(1).to(5).includeLower(true).includeUpper(false); // QueryBuilder room_range = QueryBuilders.rangeQuery("room").from(1).to(5).includeLower(true).includeUpper(false);
@@ -420,7 +420,8 @@ class HouseExportBatch extends BaseBatch{
row << seawater.name row << seawater.name
row << seawater.url row << seawater.url
row << seawater.p_date // row << seawater.p_date
row << DateUtils.getRandomDate("2022-06-01", "2022-06-30")
rets << row rets << row
} }
} }
@@ -14,7 +14,7 @@ import com.mongodb.DBCollection
//福州第三方均价统计,发送钉钉消息 //福州第三方均价统计,发送钉钉消息
//def datas = ExcelUtils.read("d:\\数据\\福州\\福州4月2.xlsx",0,1) //def datas = ExcelUtils.read("d:\\数据\\福州\\福州4月2.xlsx",0,1)
//def datas = CsvUtils.read("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202105.csv"); //def datas = CsvUtils.read("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202105.csv");
def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202205.csv") def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202206.csv")
def count0 = 0 def count0 = 0
def count1 = 0 def count1 = 0
def count2 = 0 def count2 = 0
@@ -136,8 +136,8 @@ def curMonth = DateUtils.formatDateByPattern(new Date(), "yyyyMM")
ExcelUtils.write("d:\\数据\\福州\\多方均价对比统计数据"+curMonth+".xlsx",rets,"统计") ExcelUtils.write("d:\\数据\\福州\\多方均价对比统计数据"+curMonth+".xlsx",rets,"统计")
def s = "第三方均价总量:${total}\n6区总量:${regionCount}\ncount1: "+ count1+"( "+pre1+"% )\ncount2: "+ count2+"( "+pre2+"% )\ncount3: "+count3+"( "+pre3+"% )\ncount4: "+count4+"( "+pre4+"% )\ncount5: "+count5+"( "+pre5+"% )\ncount6: "+count6+"( "+pre6+"% )\ncount7: "+count7+"( "+pre7+"%)\ncount8: "+count8+"( "+pre8+"% )\ncount9: "+count9+" ("+pre9+"% )" def s = "第三方均价总量:${total}\n6区总量:${regionCount}\ncount1: "+ count1+"( "+pre1+"% )\ncount2: "+ count2+"( "+pre2+"% )\ncount3: "+count3+"( "+pre3+"% )\ncount4: "+count4+"( "+pre4+"% )\ncount5: "+count5+"( "+pre5+"% )\ncount6: "+count6+"( "+pre6+"% )\ncount7: "+count7+"( "+pre7+"%)\ncount8: "+count8+"( "+pre8+"% )\ncount9: "+count9+" ("+pre9+"% )"
println s println s
//def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60" def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60"
//DingDingMessageUtil.sendTextMessage(access_token, s) DingDingMessageUtil.sendTextMessage(access_token, s)
////def districts = CommonDatautils.findAllDistricts("福州", "district", ["city", "region", "name"]); ////def districts = CommonDatautils.findAllDistricts("福州", "district", ["city", "region", "name"]);
@@ -48,11 +48,11 @@ class YouDaDataParser {
def final AtomicInteger count_ = new AtomicInteger(0) def final AtomicInteger count_ = new AtomicInteger(0)
static def statDate = "2022-03-01" static def statDate = "2022-06-01"
static main(args) { static main(args) {
def task = new YouDaDataParser(); def task = new YouDaDataParser();
// task.newHouseparse();//友达一手房存入mongo // task.newHouseparse();//友达一手房存入mongo
task.esfParser();//友达二手房存入mongo // task.esfParser();//友达二手房存入mongo
// task.newhouseToSaveEs();//新房保存到es // task.newhouseToSaveEs();//新房保存到es
task.esfhouseToSaveEs();//二手房保存到es task.esfhouseToSaveEs();//二手房保存到es
// task.updateFinishDateByEsfTrade();//根据二手成交的竣工时间修改seaweed库中的竣工时间 // task.updateFinishDateByEsfTrade();//根据二手成交的竣工时间修改seaweed库中的竣工时间
@@ -285,7 +285,7 @@ class YouDaDataParser {
def esfParser(){ def esfParser(){
def files = ["D:\\数据\\友达\\2022年4月\\查询1.DBF"] def files = ["D:\\数据\\友达\\2022年7月\\查询1.DBF"]
def datas = [] def datas = []
for(def fileName : files){ for(def fileName : files){
def rows = readDBF(fileName); def rows = readDBF(fileName);
@@ -44,7 +44,7 @@ class AnjukeAppCrawl {
// String line2 = StringEscapeUtils.unescapeJava(s); // String line2 = StringEscapeUtils.unescapeJava(s);
// println line2 // println line2
def task = new AnjukeAppCrawl(); def task = new AnjukeAppCrawl();
// task.autoRun() task.autoRun()
// task.run(); // task.run();
// task.run2() // task.run2()
@@ -55,7 +55,7 @@ class AnjukeAppCrawl {
// task.groupByCity() // task.groupByCity()
// task.selectNoSave() // task.selectNoSave()
// task.statCount() // task.statCount()
task.exportFzDist() // task.exportFzDist()
} }
def saveToEs1(){ def saveToEs1(){
def lists = getAllAppDatas() def lists = getAllAppDatas()
@@ -25,11 +25,11 @@ class AnjukeHouseCrawl {
System.setProperty("http.nonProxyHosts", "localhost"); System.setProperty("http.nonProxyHosts", "localhost");
WebDriver driver = new ChromeDriver() WebDriver driver = new ChromeDriver()
def href = "https://fz.anjuke.com/prop/view/S2512363126645770" def href = "https://zj.lianjia.com/ershoufang/103120144204.html"
def doc = getDocument(href, driver) def doc = getDocument(href, driver)
// def doc = ClaABuYun.getResponse(href) // def doc = ClaABuYun.getResponse(href)
// def newUrl = href.substring(0, hrefs.indexOf("?")) // def newUrl = href.substring(0, hrefs.indexOf("?"))
sendMq(href, doc, "sell_anjuke") sendMq(href, doc, "sell_lianjia")
// for(def i=25;i<50;i++){ // for(def i=25;i<50;i++){
// def url = "https://fz.anjuke.com/sale/jinana/p${i}/" // def url = "https://fz.anjuke.com/sale/jinana/p${i}/"
@@ -10,7 +10,7 @@ import com.mongodb.DBCollection
class AnjukeSendMq { class AnjukeSendMq {
static DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "ajk_community_test", "192.168.0.235", 27018) static DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "ajk_community_2207", "192.168.0.235", 27018)
static main(args) { static main(args) {
def task = new AnjukeSendMq(); def task = new AnjukeSendMq();
@@ -19,8 +19,12 @@ class AnjukeSendMq {
def run(){ def run(){
def q = new BasicDBObject() def q = new BasicDBObject()
def dbcursor = collection.find(q).limit(30) q.put("city","¸£ÖÝ")
def dbcursor = collection.find(q).batchSize(1000)
def index = 0
for(def d : dbcursor){ for(def d : dbcursor){
index++
println index
sendMq(d.url, d.content, "community_anjuke") sendMq(d.url, d.content, "community_anjuke")
} }
} }
@@ -35,6 +39,6 @@ class AnjukeSendMq {
json.put("result", result) json.put("result", result)
byte[] packedMsg = MessageUtils.pack(json) byte[] packedMsg = MessageUtils.pack(json)
CommonUtils.sendMessage("result2parse2dev", packedMsg) CommonUtils.sendMessage("result2parse", packedMsg)
} }
} }
@@ -7,6 +7,7 @@ import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject import com.mongodb.BasicDBObject
import com.mongodb.DBCollection import com.mongodb.DBCollection
import com.rabbitmq.client.impl.AMQImpl
class RegionPriceExport { class RegionPriceExport {
@@ -18,25 +19,25 @@ class RegionPriceExport {
} }
def run(){ def run(){
def months = ["20210516","20210523","20210530","20210613","20210620","20210627","20210704","20210711"] def months = ["20220101","20220201","20220301","20220401","20220501","20220601"]
def regions = CommonUtils.getAllRegions("佛山","region") def regions = CommonUtils.getAllRegions("重庆","region")
def rets = [] def rets = []
rets << ["城市","区域","20210516","20210523","20210530","20210613","20210620","20210627","20210704","20210711"] rets << ["城市","区域","202201","202202","202203","202204","202205","202206"]
regions.each{region,values-> regions.each{region,values->
def data = [] def data = []
data << "佛山" data << "重庆"
data << region data << region
for(def month :months){ for(def month :months){
def dbo = findWeekendPrice("佛山", region, month); def price = findWeekendPrice("重庆", region, month);
if(dbo){ if(price){
data << dbo.avg_price data << price
}else{ }else{
data << "" data << ""
} }
} }
rets << data rets << data
} }
ExcelUtils.write("d:\\数据\\福州\\佛山区域均价数据.xlsx",rets, "价格") ExcelUtils.write("D:\\数据\\重庆农商行\\重庆区域均价数据.xlsx",rets, "价格")
} }
def findPrice(city, region, month){ def findPrice(city, region, month){
@@ -53,8 +54,17 @@ class RegionPriceExport {
q.put("city", city) q.put("city", city)
q.put("region", region) q.put("region", region)
q.put("cat", "区域") q.put("cat", "区域")
q.put("weekend", DateUtils.parseFromTightByPattern(month, "yyyyMMdd")) def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(month, "yyyyMMdd"))
def dbo = REGION_STAT.findOne(q) def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(month, "yyyyMMdd"))
return dbo q.put("weekend", new BasicDBObject('$gte', startDate).append('$lte', endDate))
def dbcursor = REGION_STAT.find(q)
def prices = []
for(def d : dbcursor){
prices << d.avg_price
}
if(prices){
return (prices.sum()/prices.size()).toInteger()
}
return null
} }
} }
@@ -67,12 +67,12 @@ class FangjiaClientUtils {
public static def addressStand(def address){ public static def addressStand(def city, def address){
def jsonObj = null def jsonObj = null
def content = null def content = null
try { try {
address = address.replace("{","") address = address.replace("{","")
def url = "http://192.168.0.19:39080/FangJiaNlpService/ner?address="+URLEncoder.encode(address,"UTF-8") def url = "http://192.168.0.19:31080/FangJiaNlpService/ner?address="+URLEncoder.encode(address,"UTF-8")+"&city="+URLEncoder.encode(city,"UTF-8")
// def url = "http://192.168.0.19:39080/FangJiaAddressService/structure?address="+URLEncoder.encode(address,"UTF-8") // def url = "http://192.168.0.19:39080/FangJiaAddressService/structure?address="+URLEncoder.encode(address,"UTF-8")
content = new HttpRequest().newGet(url, null, "utf-8") content = new HttpRequest().newGet(url, null, "utf-8")
@@ -71,8 +71,7 @@ class DistrictIndexBatch extends BaseBatch{
def run(){ def run(){
def cityCodeDatas = CcbCommonUtils.findCityCodeValue() def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
def citys = ["昆明","南宁","郑州","长沙","贵阳","乌鲁木齐","中山","湛江","南昌","海口"] def citys = CommonDatautils.findAllCity();
//def citys = CommonDatautils.findAllCity();
for(def city : citys){ for(def city : citys){
def dists = CommonDatautils.findAllDistrictByCity(city, "district", ["city","alias","region","name", "finish_building_date","estate_charge","lat","lng","lng2","lat2","household_count"]) def dists = CommonDatautils.findAllDistrictByCity(city, "district", ["city","alias","region","name", "finish_building_date","estate_charge","lat","lng","lng2","lat2","household_count"])
def code = cityCodeDatas.get(city) def code = cityCodeDatas.get(city)
@@ -17,6 +17,7 @@ import org.openqa.selenium.By
import org.openqa.selenium.WebDriver import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement import org.openqa.selenium.WebElement
import org.openqa.selenium.chrome.ChromeDriver import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.support.ui.ExpectedConditions import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait import org.openqa.selenium.support.ui.WebDriverWait
@@ -44,6 +45,7 @@ public class BeiKeCrawlByChrome {
def run(){ def run(){
System.setProperty("webdriver.chrome.driver", "C:\\Users\\gaojuan\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe"); System.setProperty("webdriver.chrome.driver", "C:\\Users\\gaojuan\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe");
System.setProperty("http.nonProxyHosts", "localhost"); System.setProperty("http.nonProxyHosts", "localhost");
WebDriver driver = new ChromeDriver() WebDriver driver = new ChromeDriver()
def citys = getAllCityUrls(driver) def citys = getAllCityUrls(driver)
citys = citys.reverse() citys = citys.reverse()
@@ -145,7 +147,12 @@ public class BeiKeCrawlByChrome {
def detailUrls = [] def detailUrls = []
while(!stop){ while(!stop){
def url = cityUrl + "/chengjiao/pg${page}/" def url = cityUrl + "/chengjiao/pg${page}/"
driver.get(url) try{
driver.get(url)
}catch(Exception e){
println url +" ³ö´í"
}
def doc = Jsoup.parse(driver.getPageSource()); def doc = Jsoup.parse(driver.getPageSource());
def elements = JQueryUtils.select(".listContent li", doc) def elements = JQueryUtils.select(".listContent li", doc)
if(elements){ if(elements){
@@ -153,7 +160,7 @@ public class BeiKeCrawlByChrome {
def durl = e.select(".title a").attr("href") def durl = e.select(".title a").attr("href")
def dealDate = e.select(".dealDate").text() def dealDate = e.select(".dealDate").text()
dealDate = DateUtils.parseFromTightByPattern(dealDate, "yyyy.MM.dd") dealDate = DateUtils.parseFromTightByPattern(dealDate, "yyyy.MM.dd")
def endDate = DateUtils.parseFromTightByPattern("2022-04-20", "yyyy-MM-dd") def endDate = DateUtils.parseFromTightByPattern("2022-05-20", "yyyy-MM-dd")
if(dealDate && dealDate.getTime()>=endDate.getTime()){ if(dealDate && dealDate.getTime()>=endDate.getTime()){
detailUrls << durl detailUrls << durl
parse(city, e) parse(city, e)
@@ -190,10 +197,16 @@ public class BeiKeCrawlByChrome {
def roomStr = arrs[1] def roomStr = arrs[1]
if (roomStr) { if (roomStr) {
if (roomStr.indexOf("ÊÒ") > 0) { if (roomStr.indexOf("ÊÒ") > 0) {
detail.room = roomStr.substring(0, roomStr.indexOf("ÊÒ")).toInteger() roomStr = roomStr.substring(0, roomStr.indexOf("ÊÒ"))
if(roomStr && roomStr.isNumber()){
detail.room = roomStr.toInteger()
}
} }
if (roomStr.indexOf("Ìü") > 0 && roomStr.indexOf("ÊÒ") > 0) { if (roomStr.indexOf("Ìü") > 0 && roomStr.indexOf("ÊÒ") > 0) {
detail.hall = roomStr.substring(roomStr.indexOf("ÊÒ") + 1, roomStr.indexOf("Ìü")).toInteger() def hallStr = roomStr.substring(roomStr.indexOf("ÊÒ") + 1, roomStr.indexOf("Ìü"))
if(hallStr && hallStr.isNumber()){
detail.hall = hallStr.toInteger()
}
} }
} }
@@ -15,28 +15,29 @@ class ExportPaimai {
static main(args) { static main(args) {
def task = new ExportPaimai(); def task = new ExportPaimai();
task.run() // task.run()
// task.addressStandard() // task.addressStandard()
// task.addPrice() // task.addPrice()
// task.stat() task.stat()
// task.standard()
} }
def stat(){ def stat(){
def file = "D:\\数据\\重庆农商行\\法拍\\宿迁法拍数据.xlsx" def file = "D:\\数据\\重庆农商行\\法拍\\苏州商业法拍原数据(已成交).xlsx"
def datas = ExcelUtils.read(file, 0, 1) def datas = ExcelUtils.read(file, 0, 1)
def index1 = 0 def index1 = 0
def rates1 = [] def rates1 = []
for(def d : datas){ for(def d : datas){
if(d['P'] && d['P']=='Òѳɽ»'){ if(d['P'] && d['P']=='Òѳɽ»'){
if(d['M'] && d['M']=="住宅") // if(d['M'] && d['M']=="住宅")
// if(d['K']>=150){ // if(d['K']>=240){
// index1++ // index1++
// def sumTradePrice = d['S'] // def sumTradePrice = d['S']
// def marketPrice = d['Y'] // def marketPrice = d['Y']
// rates1 << sumTradePrice/marketPrice // rates1 << sumTradePrice/marketPrice
// } // }
if(d['S']>2000000){ if(d['S']<800000){
index1++ index1++
def sumTradePrice = d['S'] def sumTradePrice = d['S']
def marketPrice = d['Y'] def marketPrice = d['Y']
@@ -56,12 +57,55 @@ class ExportPaimai {
}) })
} }
def addressStandard(){ def addressStandard(){
ExcelUtils.multiThreadingModify("D:\\数据\\重庆农商行\\法拍\\重庆法拍数据.xlsx",{d-> ExcelUtils.multiThreadingModify("D:\\数据\\重庆农商行\\法拍\\需要重跑地址解析和匹配_重庆法拍数据.xlsx",{d->
def formatAddress = AddressUtil.formatAddress(d['C'], d['A']) def formatAddress = AddressUtil.formatAddress(d['C'], d['A'])
if(formatAddress){ if(formatAddress){
d['F'] = formatAddress d['F'] = formatAddress
} }
}) })
}
def standard(){
ExcelUtils.multiThreadingModify("D:\\数据\\重庆农商行\\法拍\\需要重跑地址解析和匹配_重庆法拍数据.xlsx",{d->
def obj = com.fangjia.script.gj.district.FangjiaClientUtils.addressStand(d['C'], d['B'])
if(obj){
def arrs = obj.entities
def address = ""
def houseNum = ""
def roomNum = ""
def unitNum = ""
def poi = ""
for(def m : arrs){
if(m.type == "road"){
address = m.word
}
if(m.type == "roadno"){
address = address + m.word
}
if(m.type == "houseno"){
houseNum = m.word
}
if(m.type == "roomno"){
roomNum = m.word
}
if(m.type == "cellno"){
unitNum = m.word
}
if(m.type == "poi"){
poi = m.word
}
}
d['F'] = address
d['G'] = houseNum
d['H'] = unitNum
d['I'] = roomNum
d['J'] = poi
}
})
} }
def run(){ def run(){
@@ -123,17 +167,20 @@ class ExportPaimai {
row << d.url row << d.url
rows << row rows << row
}else{
println d.title
} }
} }
ExcelUtils.write("D:\\数据\\重庆农商行\\法拍\\重庆法拍原数据.xlsx",rows,"数据") ExcelUtils.write("D:\\数据\\重庆农商行\\法拍\\苏州商业法拍原数据(已流拍).xlsx",rows,"数据")
} }
def findPaimaiData(){ def findPaimaiData(){
def pmquery = new BasicDBObject() def pmquery = new BasicDBObject()
pmquery.put("city","重庆") pmquery.put("city","苏州")
pmquery.put("region","姑苏")
pmquery.put("startDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2019-01-01"))) pmquery.put("startDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2019-01-01")))
pmquery.put("mDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2022-06-01"))) pmquery.put("mDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2022-07-01")))
pmquery.put("status","已成交") pmquery.put("status","已流拍")
def dbcursor = paimai43_COLL.find(pmquery).sort(new BasicDBObject("finishDate",-1)) def dbcursor = paimai43_COLL.find(pmquery).sort(new BasicDBObject("finishDate",-1))
def rets = [] def rets = []
for(def db : dbcursor){ for(def db : dbcursor){
@@ -129,7 +129,7 @@ public class LianjiaCrawlByChrome {
def standardRegion(){ def standardRegion(){
def q = new BasicDBObject() def q = new BasicDBObject()
q.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern("2022-03-01","yyyy-MM-dd"))) q.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern("2022-01-01","yyyy-MM-dd")))
q.put("match_id", new BasicDBObject(QueryOperators.EXISTS, false) ) q.put("match_id", new BasicDBObject(QueryOperators.EXISTS, false) )
def dbcursor = DEAL_PRICE_COLL.find(q) def dbcursor = DEAL_PRICE_COLL.find(q)
for(def d : dbcursor){ for(def d : dbcursor){
@@ -153,7 +153,7 @@ public class LianjiaCrawlByChrome {
lastMonth = lastMonth +"-01" lastMonth = lastMonth +"-01"
def q = new BasicDBObject() def q = new BasicDBObject()
q.put("region", null) q.put("region", null)
q.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern("2022-01-01","yyyy-MM-dd"))) q.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern("2022-05-01","yyyy-MM-dd")))
// q.put("source", new BasicDBObject('$in', ["链家在线","贝壳找房"])) // q.put("source", new BasicDBObject('$in', ["链家在线","贝壳找房"]))
def dbcursor = DEAL_PRICE_COLL.find(q) def dbcursor = DEAL_PRICE_COLL.find(q)
def keys = [] def keys = []
@@ -171,7 +171,7 @@ public class LianjiaCrawlByChrome {
query.put("region", null) query.put("region", null)
query.put("district_name", m.name) query.put("district_name", m.name)
// query.put("source", "链家在线") // query.put("source", "链家在线")
query.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern(lastMonth,"yyyy-MM-dd"))) // query.put("trade_date", new BasicDBObject(QueryOperators.GTE, DateUtils.parseFromTightByPattern(lastMonth,"yyyy-MM-dd")))
def data = new BasicDBObject() def data = new BasicDBObject()
data.put("region", dist.region) data.put("region", dist.region)
@@ -238,7 +238,7 @@ public class LianjiaCrawlByChrome {
def durl = e.select(".title a").attr("href") def durl = e.select(".title a").attr("href")
def dealDate = e.select(".dealDate").text() def dealDate = e.select(".dealDate").text()
dealDate = DateUtils.parseFromTightByPattern(dealDate, "yyyy.MM.dd") dealDate = DateUtils.parseFromTightByPattern(dealDate, "yyyy.MM.dd")
def endDate = DateUtils.parseFromTightByPattern("2022-04-20", "yyyy-MM-dd") def endDate = DateUtils.parseFromTightByPattern("2022-05-20", "yyyy-MM-dd")
if(dealDate.getTime()>=endDate.getTime()){ if(dealDate.getTime()>=endDate.getTime()){
detailUrls << durl detailUrls << durl
parse(city, e) parse(city, e)
@@ -442,11 +442,11 @@ public class LianjiaCrawlByChrome {
def cityDoc = Jsoup.parse(driver.getPageSource()); def cityDoc = Jsoup.parse(driver.getPageSource());
def cityEles = JQueryUtils.select(".city_province a", cityDoc) def cityEles = JQueryUtils.select(".city_province a", cityDoc)
def cityMap = [:] def cityMap = [:]
def citys= ["¸£ÖÝ"] def citys= ["°²Çì"]
if(cityEles){ if(cityEles){
for(def e : cityEles) { for(def e : cityEles) {
def href = e.attr("href") def href = e.attr("href")
if (!href.contains("fang.lianjia")){ if (!href.contains("fang.lianjia") && citys.contains(e.text())){
cityMap.put(e.text(), href) cityMap.put(e.text(), href)
} }
} }
@@ -23,28 +23,29 @@ DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "p
//String str = format.format(date); //String str = format.format(date);
//System.out.println(str); //System.out.println(str);
def pmquery = new BasicDBObject() //def pmquery = new BasicDBObject()
pmquery.put("city","ËÞǨ") //pmquery.put("city","ËÞǨ")
pmquery.put("startDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2019-01-01"))) //pmquery.put("startDate", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2019-01-01")))
//pmquery.put("status","Òѳɽ»") ////pmquery.put("status","Òѳɽ»")
//pmquery.put("estateType", null) ////pmquery.put("estateType", null)
pmquery.put("url","https://sf-item.taobao.com/sf_item/665574733237.htm") //pmquery.put("url","https://sf-item.taobao.com/sf_item/665574733237.htm")
//
def cur = paimai43_COLL.find(pmquery) //def cur = paimai43_COLL.find(pmquery)
def urls = [] //def urls = []
for(def o : cur){ //for(def o : cur){
urls << o.url // urls << o.url
} //}
println "´ý½âÎö£º"+urls //println "´ý½âÎö£º"+urls
def index = 0 def index = 0
for(def url : urls){ //for(def url : urls){
def q = new BasicDBObject() def q = new BasicDBObject()
q.put("url", url) // q.put("url", url)
q.put("update_time", new BasicDBObject('$gte',DateUtils.parseFromTightByPattern("2022-07-12", "yyyy-MM-dd")))
def dbcursor = collection.find(q) def dbcursor = collection.find(q)
index++
println index
for(def d : dbcursor){
for(def d : dbcursor){
index++
println index
JSON json = new JSONObject() JSON json = new JSONObject()
json.put("project", "paimai_taobao") json.put("project", "paimai_taobao")
json.put("url", d.url) json.put("url", d.url)
@@ -64,8 +65,8 @@ for(def url : urls){
json.put("result", result) json.put("result", result)
byte[] packedMsg = MessageUtils.pack(json) byte[] packedMsg = MessageUtils.pack(json)
CommonUtils.sendMessage("result2parse2dev", packedMsg) CommonUtils.sendMessage("result2parse", packedMsg)
} }
} //}
@@ -34,7 +34,39 @@ class PaimaiTest {
// task.updatePaimai() // task.updatePaimai()
// task.updateFieldPaimai() // task.updateFieldPaimai()
// task.statCity() // task.statCity()
task.jsStat() // task.jsStat()
task.selectData()
}
def selectData(){
def urls = ["https://sf-item.taobao.com/sf_item/674045056937.htm",
"https://sf-item.taobao.com/sf_item/669281206202.htm",
"https://sf-item.taobao.com/sf_item/646818853936.htm",
"https://sf-item.taobao.com/sf_item/636815760791.htm",
"https://sf-item.taobao.com/sf_item/636055429237.htm",
"https://sf-item.taobao.com/sf_item/635094754807.htm",
"https://sf-item.taobao.com/sf_item/621286459023.htm",
"https://sf-item.taobao.com/sf_item/613944729986.htm",
"https://sf-item.taobao.com/sf_item/613944489517.htm",
"https://sf-item.taobao.com/sf_item/604967216580.htm",
"https://sf-item.taobao.com/sf_item/596302571187.htm",
"https://sf-item.taobao.com/sf_item/594722220602.htm"
]
for(def url : urls){
def q = new BasicDBObject()
q.put("url", url)
def obj = paimai43_COLL.findOne(q)
if(obj){
if(obj.matchName=="中渝国宾城"){
def udata = new BasicDBObject()
udata.put("matchName", "中渝山顶道国宾城")
paimai43_COLL.update(new BasicDBObject('_id', obj._id), new BasicDBObject('$set', udata))
}
println url +" "+obj.matchName
}else{
println url +" 不存在"
}
}
} }
def jsStat(){ def jsStat(){
@@ -1,17 +1,25 @@
package com.fangjia.script.gj.test package com.fangjia.script.gj.test
import ch.qos.logback.core.db.dialect.DBUtil
import com.fangjia.core.RegionData import com.fangjia.core.RegionData
import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.lixue.util.DBUtils
import com.fangjia.script.util.CommonUtils import com.fangjia.script.util.CommonUtils
import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.ExcelUtils
import com.mongodb.BasicDBObject import com.mongodb.BasicDBObject
import com.mongodb.DBCollection import com.mongodb.DBCollection
import com.mongodb.Mongo import com.mongodb.Mongo
import groovy.sql.Sql import groovy.sql.Sql
import org.bson.types.ObjectId
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
def dist = CommonDatautils.findDistrictById("62ce233a3705890001dfa164")
DBUtils.seaweed.save(dist)
//DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId("62ce233a3705890001dfa164")), new BasicDBObject('$set', dist))
//SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//Date date = new Date(1617211269868); //Date date = new Date(1617211269868);
//print dateFormat.format(date); //print dateFormat.format(date);
@@ -50,13 +58,13 @@ import java.text.SimpleDateFormat
//} //}
def dists = CommonDatautils.findAllDistrictByCity("上海", "district", ["city","region","name","finish_building_date"]) //def dists = CommonDatautils.findAllDistrictByCity("ÉϺ£", "district", ["city","region","name","finish_building_date"])
def rets = [] //def rets = []
for(def d : dists){ //for(def d : dists){
def year = CommonUtils.getDistrictAge(d) // def year = CommonUtils.getDistrictAge(d)
rets << [d.city,d.region, d.name, year] // rets << [d.city,d.region, d.name, year]
} //}
ExcelUtils.write("D:\\数据\\统计房龄.xlsx", rets, "数据") //ExcelUtils.write("D:\\Êý¾Ý\\ͳ¼Æ·¿Áä.xlsx", rets, "Êý¾Ý")
@@ -40,11 +40,11 @@ class DataStat {
def run(){ def run(){
def source = "Q·¿"// def source = "城市房产"//
def citys = findCrawlCity(source, 202204); def citys = findCrawlCity(source, 202205);
for(def city : citys){ for(def city : citys){
def count1 = findCount(source, city, 202204); def count1 = findCount(source, city, 202205);
def count2 = findCount(source, city, 202203); def count2 = findCount(source, city, 202206);
println city +" "+count1+" "+count2 println city +" "+count1+" "+count2
// println count1 // println count1
// println "--- ----" // println "--- ----"
@@ -193,7 +193,7 @@ class Esf58Crawl extends BaseBatch{
//addContent("福州","https://fz.58.com/xiaoqu/", 70); //addContent("福州","https://fz.58.com/xiaoqu/", 70);
// "宁波","佛山","南通","烟台","临沂","呼和浩特","海口","广州", // "宁波","佛山","南通","烟台","临沂","呼和浩特","海口","广州",
def citys = ["宁波","大连","佛山","乌鲁木齐","济南","长春","兰州","石家庄","温州","烟台","太原","泉州","南通","呼和浩特","徐州","惠州","厦门","南昌","临沂","贵阳","嘉兴","常州","盐城","威海","淄博","深圳","中山","重庆","苏州","西宁","绍兴","洛阳","廊坊","昆明","金华","珠海","宜昌","南充","信阳","杭州","沧州","宿迁","南阳","德州","桂林","新乡","包头","遵义","乐山","株洲","德阳","眉山","驻马店","许昌","宜宾","衡水","泸州","营口","清远","达州","宝鸡","长沙","广安"] def citys = ["¸£ÖÝ"]
for(def city : citys){ for(def city : citys){
def str = cityList.get(city) def str = cityList.get(city)
for(def i=0;i<1;i++){ for(def i=0;i<1;i++){
@@ -21,7 +21,9 @@ class SynchDistrictPrice {
// "anjuke.com":"安居客","cityhouse.cn":"城市房产","zhuge.com":"诸葛找房","5i5j.com":"我爱我家","jiwu.com":"吉屋"] // "anjuke.com":"安居客","cityhouse.cn":"城市房产","zhuge.com":"诸葛找房","5i5j.com":"我爱我家","jiwu.com":"吉屋"]
//"fang.com":"搜房", //"fang.com":"搜房",
def sourceMap = ["ke.com":"贝壳找房","cityhouse.cn":"城市房产"] def sourceMap = ["ke.com":"贝壳找房","cityhouse.cn":"城市房产"]
def esSourceMap = ["ke.com":"±´¿Ç"]
//,"城市房产":"城市房产"
def esSources = ["365淘房":"365淘房"]//"贝壳":"贝壳找房","链家":"链家","Q房":"Q房","我爱我家":"我爱我家","麦田":"麦田","中原地产":"中原地产","安居客PC端":"安居客","搜房":"搜房","吉屋":"吉屋"
static main(args) { static main(args) {
def task = new SynchDistrictPrice() def task = new SynchDistrictPrice()
// task.run() // task.run()
@@ -31,20 +33,20 @@ class SynchDistrictPrice {
def run1(){ def run1(){
def citys = CommonUtils.findAllCity() def citys = CommonUtils.findAllCity()
esSourceMap.each { k, v -> esSources.each{esSource, mgSource->
for(def city : citys){ for(def city : citys){
def rets = findAllEsData(city, v) def rets = findAllEsData(city, esSource, mgSource)
println city +" "+rets.size() println city +" "+rets.size()
synchData(city, rets, "±´¿ÇÕÒ·¿") synchData(city, rets, mgSource)
} }
} }
} }
def findAllEsData(city,source){ def findAllEsData(city,esSource, mgSource){
def names = new HashSet() def names = new HashSet()
def rets = [] def rets = []
ElasticUtils.executeSqlQuery("select * from community where source='±´¿Ç' and city='${city}'", {d-> ElasticUtils.executeSqlQuery("select * from community where source='${esSource}' and city='${city}' and m_date>'2022-06-15'", {d->
def s = d.city +"#"+d.region+"#"+d.name def s = d.city +"#"+d.region+"#"+d.name
if(!names.contains(s)){ if(!names.contains(s)){
names << s names << s
@@ -54,8 +56,11 @@ class SynchDistrictPrice {
data.put("name", d.name) data.put("name", d.name)
data.put("address", d.address) data.put("address", d.address)
data.put("avg_price", d.avg_price) data.put("avg_price", d.avg_price)
data.put("source", source) data.put("source", mgSource)
data.put("s_date", SHORT_DATE) data.put("s_date", SHORT_DATE)
data.put("url", d.url)
data.put("c_date", new Date())
data.put("m_date", new Date())
rets << data rets << data
} }
}) })
@@ -138,7 +143,7 @@ class SynchDistrictPrice {
def udata = new BasicDBObject() def udata = new BasicDBObject()
udata.put("avg_price", r.avg_price) udata.put("avg_price", r.avg_price)
udata.put("m_date",new Date()) udata.put("m_date",new Date())
thirdPartyColl.update(new BasicDBObject('_id',obj._id), udata) thirdPartyColl.update(new BasicDBObject('_id',obj._id), new BasicDBObject('$set', udata))
}else{ }else{
try{ try{