From c99e51269918670804a275ef5aef86774e7ef798 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 17 Jun 2022 11:11:42 +0800 Subject: [PATCH 01/27] =?UTF-8?q?=E6=88=90=E4=BA=A4=E5=8F=8A=E6=8C=82?= =?UTF-8?q?=E7=89=8C=E4=BB=B7=E6=A0=BC10%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/DealPriceController.java | 4 ++-- .../com/fangjia/open/controllers/HouseController.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java index ab916308a..54c19713d 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java @@ -233,8 +233,8 @@ public class DealPriceController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } Date startDate = null; Date endDate = null; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index c75ec0da7..ff5708174 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -434,8 +434,8 @@ public class HouseController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } List names = new ArrayList(); names.add(district.getName()); @@ -487,8 +487,8 @@ public class HouseController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } List names = new ArrayList(); names.add(district.getName()); From 88f0d14121e5473ba1e33faac4d0ea0d8d72188e Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 20 Jun 2022 13:26:32 +0800 Subject: [PATCH 02/27] update --- .../java/com/fangjia/core/util/DataUtil.java | 1 + .../BigdataCommunityBatch.groovy | 4 +- .../ccbevaluation/BigdataDealBatch.groovy | 85 ++-- .../ccbevaluation/CcbCommonUtils.groovy | 4 +- .../fangjia/script/ccbevaluation/Test.groovy | 69 +-- .../ccbevaluation/data/CcbDistrictToDB.groovy | 162 ++++++- .../ccbevaluation/data/DistrictMarge.groovy | 12 +- .../ronghe/ExportDistrictRongHe.groovy | 174 +++---- .../fangjia/script/chongqing/GZIPUtils.groovy | 166 +++++++ .../script/chongqing/MeituanStat.groovy | 429 ++++++++++++++++++ .../script/commData/CommonDatautils.groovy | 8 + .../fangjiatong/FjtResponseTimeAnaly.groovy | 3 +- .../com/fangjia/script/fuzhou/Test1.groovy | 6 +- .../fuzhou/ThirdPriceExportBatch.groovy | 5 + .../com/fangjia/script/gj/OpenApiUtils.groovy | 2 +- .../fangjia/script/gj/OpenUserBatch.groovy | 22 +- .../script/gj/abuyun/AnjukeTest.groovy | 25 + .../gj/abuyun/ProxyAuthenticator.groovy | 23 + .../script/gj/crawl/AnjukeAbuyunCrawl.groovy | 91 ++++ .../script/gj/crawl/AnjukeAppCrawl.groovy | 371 ++++++++++++++- .../script/gj/crawl/AnjukeHouseCrawl.groovy | 50 +- .../script/gj/crawl/AnjukeSendMq.groovy | 40 ++ .../script/gj/crawl/ZhugeFangDistCrawl.groovy | 4 +- .../gj/district/FangjiaClientUtils.groovy | 6 + .../script/gj/district/NameProcess.groovy | 5 +- .../gj/location/DistrictMapMatch.groovy | 75 ++- .../gj/paimai/BeiKeCrawlByChrome.groovy | 20 +- .../gj/paimai/LianjiaCrawlByChrome.groovy | 20 +- .../thirdPriceCrawl/CrawalDBUtil.groovy | 6 + .../script/thirdPriceCrawl/DataStat.groovy | 4 +- .../script/thirdPriceCrawl/Esf58Crawl.groovy | 8 +- .../thirdPriceCrawl/SynchDistrictPrice.groovy | 43 +- .../TestCrawlTotalCount.groovy | 4 +- .../ThirdDataToGatherBatch.groovy | 4 +- .../fangjia/script/wenyan/temp/QinLin.groovy | 4 +- 35 files changed, 1719 insertions(+), 236 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/GZIPUtils.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeSendMq.groovy diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java index d4cc2d5da..e11cd2246 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java @@ -1341,6 +1341,7 @@ public class DataUtil { GZIPOutputStream outputStream = new GZIPOutputStream(bao); outputStream.write(content.getBytes("UTF-8")); outputStream.finish(); + System.out.println(bao.toString()); return bao.toByteArray(); } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index 6cd17549e..b54b97e70 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -44,9 +44,7 @@ class BigdataCommunityBatch extends BaseBatch{ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() for(def city : citys){ -// if(["苏州","北京","广州","杭州","合肥","深圳","石家庄","武汉","西安","重庆"].contains(city)){ -// continue -// } + def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat"]) println city +" 小区量:"+dists.size() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy index d34dedcc2..f606cd13f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy @@ -52,48 +52,51 @@ class BigdataDealBatch extends BaseBatch{ @Override public void process(Object args) { //def weekend = DateUtils.parseFromTightByPattern("2021-07-25","yyyy-MM-dd")//DateUtils.getFirstDayOfWeek(new Date()) - def citys = CcbCommonUtils.citys; + def citys = CommonDatautils.findAllCity()//CcbCommonUtils.citys; + def ccbCitys = CcbCommonUtils.citys; -// for(def city : citys){ -// addDealPriceMatch(city); -// } -// println citys.unique().size() - def rows = [] - def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] - def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() for(def city : citys){ - def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) - def ppeDists = [:] -// if(["贵阳","佛山","杭州","沈阳","天津","中山","徐州","绍兴","南通","哈尔滨","惠州","长沙","青岛","长春","烟台","温州","太原","台州","石家庄","宁波","常州","大连","嘉兴","金华","昆明"].contains(city)){ -// ppeDists = getPpeGTE15Datas(city) -// } - - def statMap = [:]//getDistrictStatByCity(city, weekend) - if(city=="上海"){ - def youDataTrade = getYouDaData(statMap) - def youdaDatas = createData(youDataTrade, cityCodeDataMap, distCodeMap, "youda") - rows.addAll(youdaDatas) - println city +" "+youdaDatas.size() + if(!ccbCitys.contains(city)){ + addDealPriceMatch(city); } - - - def trades = getCityData(city, statMap, ppeDists) - def rets = createData(trades, cityCodeDataMap, distCodeMap, "other") - rows.addAll(rets) - println city +" 成交共:"+rets.size() - - def cityDatas = [] - cityDatas << headers - cityDatas.addAll(rows) } - - def fileName = "/home/goojia/ccb/BIGDATA_DEAL_GJ.dat" - if(CommonDatautils.isWindow()){ - fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_DEAL_GJ.dat" - } - - FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false); - println "txt 生成" +//// println citys.unique().size() +// def rows = [] +// def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] +// def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() +// for(def city : citys){ +// def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) +// def ppeDists = [:] +//// if(["贵阳","佛山","杭州","沈阳","天津","中山","徐州","绍兴","南通","哈尔滨","惠州","长沙","青岛","长春","烟台","温州","太原","台州","石家庄","宁波","常州","大连","嘉兴","金华","昆明"].contains(city)){ +//// ppeDists = getPpeGTE15Datas(city) +//// } +// +// def statMap = [:]//getDistrictStatByCity(city, weekend) +// if(city=="上海"){ +// def youDataTrade = getYouDaData(statMap) +// def youdaDatas = createData(youDataTrade, cityCodeDataMap, distCodeMap, "youda") +// rows.addAll(youdaDatas) +// println city +" "+youdaDatas.size() +// } +// +// +// def trades = getCityData(city, statMap, ppeDists) +// def rets = createData(trades, cityCodeDataMap, distCodeMap, "other") +// rows.addAll(rets) +// println city +" 成交共:"+rets.size() +// +// def cityDatas = [] +// cityDatas << headers +// cityDatas.addAll(rows) +// } +// +// def fileName = "/home/goojia/ccb/BIGDATA_DEAL_GJ.dat" +// if(CommonDatautils.isWindow()){ +// fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_DEAL_GJ.dat" +// } +// +// FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false); +// println "txt 生成" } @@ -570,8 +573,10 @@ class BigdataDealBatch extends BaseBatch{ def addDealPriceMatch(city){ - def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) - def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) +// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) +// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) + def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20220101", "yyyyMMdd")) + def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20220601", "yyyyMMdd")) def trades = CcbCommonUtils.findTradesByMonth(city, startDate, endDate) final CountDownLatch latch = new CountDownLatch(trades.size()) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy index 98fbc2d09..db3beb6ef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy @@ -3,6 +3,7 @@ package com.fangjia.script.ccbevaluation import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DataStore +import com.fangjia.script.lixue.util.DBUtils import com.fangjia.script.util.DataUtil import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils @@ -377,7 +378,8 @@ class CcbCommonUtils { keys.put(field, 1); } } - def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) +// def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) + def dbsour = DBUtils.seaweed.find(q,keys).batchSize(2000) println "原始:"+dbsour.count() def rets = [] for(def d : dbsour){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy index 9af443b40..5648796e8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy @@ -30,11 +30,11 @@ import java.util.regex.*; //def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.100:31521:orcl", // "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") -def sqlInstance236 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +//def sqlInstance236 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") -def sqlInstance94 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.94:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +//def sqlInstance94 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.94:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") @@ -47,6 +47,16 @@ def DBCollection youda_esfhouse_coll = MongoUtils.getCollectionByName2("business +//def districts = CommonDatautils.findAllFiledDistrict("district", "南宁") +//for(def d : districts){ +// println d.name +//} + +//def dists = CommonDatautils.findAllDistrictByCity("南宁", "district", ["city","region","name"]) +//for(def d : dists){ +// def o = CommonDatautils.findDistrictById(d._id.toString()) +// println o._id.toString() + " "+o.name +//} //def citys = CcbCommonUtils.citys; //def rows = [] @@ -236,16 +246,16 @@ def youdaDeal(youda_esfhouse_coll, def city, def region, def name, def area, def // println d // } //},0) -def rows = findTradePpeData(sqlInstance236) -// rows.unique() -def map=findTradeDetail(sqlInstance236,null) -def datas=[] -map.each{key,row-> - if(!rows.contains(key)){ - datas< +// if(!rows.contains(key)){ +// datas< -// if(d['A']){ +ExcelUtils.modify("D:\\数据\\建行\\房产估值\\小区\\删除重复小区.xlsx",{d-> + if(d['A']){ // def region = d['B'] // def newRegion = RegionData.formatRegion(d['A'], region) // if(newRegion) { // def dist = CommonDatautils.findDistrict(d['A'], newRegion, d['C'], "district") -// if(dist){ -// def udata = new BasicDBObject() -// udata.put("name_cat", 11) -// udata.put("m_date",new Date()) -// -// def q = new BasicDBObject() -// q.put("_id", dist._id) -// DbUtils.seaweed.update(q, new BasicDBObject('$set', udata)) -// }else{ -// println d -// } + def dist = CommonDatautils.findDistrictById(d['A']) + if(dist){ + def udata = new BasicDBObject() + udata.put("name_cat", 11) + udata.put("m_date",new Date()) + + def q = new BasicDBObject() + q.put("_id", dist._id) + DbUtils.seaweed.update(q, new BasicDBObject('$set', udata)) + }else{ + println d + } // } -// } -//},0) + } +},0) //def citys = CcbCommonUtils.citys //def rets = [] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy index 98d755434..85e2c71b4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy @@ -16,6 +16,7 @@ import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.GeoHelper +import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import java.util.concurrent.CopyOnWriteArrayList @@ -27,9 +28,20 @@ class CcbDistrictToDB { // task.run() // task.run1() // task.meituanRun() - task.meituanSqrentRun() +// task.meituanSqrentRun() // task.updateDistrict() // task.updateDongguangRegion() +// task.houseDistToDB() + task.sendCalPrice() + } + + def sendCalPrice(){ + def dists = CommonDatautils.findAllDistrictByCity("东莞", "district", ["city","region","name","estate_type2"]) + def startDate = DateUtils.parseFromTightYYYYMMDD("2022-05-27") + def endDate = DateUtils.parseFromTightYYYYMMDD("2022-06-14") + for(def data : dists){ + addPrice(data, startDate, endDate) + } } def updateDongguangRegion(){ @@ -80,6 +92,123 @@ class CcbDistrictToDB { } } + + def houseDistToDB(){ + def index = 0 + def addIndex = 0 + def keys = new CopyOnWriteArrayList() + ExcelUtils.modify("D:\\数据\\建行\\二期\\新增小区_2739_0610.xlsx", { d -> + index++ + if(d['I']){ + def city = d['A'] + def mapInfo = getStreetInfo(d['P']+","+d['Q']) + def newRegion = null + if(mapInfo){ + if(d['A']=="东莞"){ + newRegion = mapInfo.township + }else{ + newRegion = mapInfo.district + } + } + + newRegion = RegionData.formatRegion(city, newRegion) + + if(newRegion && newRegion.contains(d['B'])){ + def name = nameFileter(d['I']) + def alias = [] + if(d['I']!=name){ + alias << d['I'] + } + if(d['C']!=d['I'] && !alias.contains(d['C'])){ + alias << d['C'] + } + + def estateType2 = "普通住宅" + if(name){ + if(name.contains("别墅")){ + estateType2 = "别墅" + }else if(name.contains("商住")){ + estateType2 = "商住" + }else{ + def type = d['O'] + if(type){ + if(type.contains("别墅")){ + estateType2 = "别墅" + }else if(type.contains("商住")){ + estateType2 = "商住" + } + } + } + } + def formatAddress = null + if (d['N']) { + formatAddress = AddressUtil.formatAddress(d['A'], d['N']) + } + + Long glat = null + Long glng = null + Long blat = null + Long blng = null + + if (d['P']) { + glat = d['P'].toString().toDouble() * 10000000000L + glng = d['Q'].toString().toDouble() * 10000000000L + def baidu = BaiDuApiUtils.geoconv(d['P'].toString().toDouble(), d['Q'].toString().toDouble(), 3) + blng = baidu.x * 10000000000L + blat = baidu.y * 10000000000L + } + + def key = city + "##" + newRegion + "##" + name + if (name && !keys.contains(key)) { + def dist = CommonDatautils.findDistrict(city, newRegion, name, "district") + if (!dist) { + addIndex++ + keys << key + def data = new BasicDBObject(); + data.put("name_cat", 0) + data.put("status", 0) + data.put("cat", "district") + data.put("c_date", new Date()) + data.put("m_date", new Date()) + data.put("city", city) + data.put("region", newRegion) + data.put("name", name) + data.put("estate_type2", estateType2) + data.put("address", formatAddress) + if (glat) { + data.put("lat", glat) + data.put("lng", glng) + data.put("lat2", blat) + data.put("lng2", blng) + } + def markMap = [:] + markMap.put("data_source", "机器入库") + data.put("mark_map", markMap) + index++ + DbUtils.seaweed.save(data); + println addIndex + " " + data +// def stop = false +// while (!stop) { +// if (data._id.toString()) { +// addPrice(data) +// stop = true; +// } +// } + }else{ + if(alias){ + def data = new BasicDBObject(); + data.put("alias", alias) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set',data)) + } + } + } + }else{ + println d['A']+" "+d['B']+" "+d['C'] +" 经纬度所在区:"+newRegion + } + } + }); + } + def meituanSqrentRun(){ def index = 0 ExcelUtils.modify("D:\\数据\\美团\\美团待入库.xlsx", { d -> @@ -228,11 +357,8 @@ class CcbDistrictToDB { } - def addPrice(dist){ - def startDate = DateUtils.parseFromTightYYYYMMDD("2022-05-01") - def endDate = DateUtils.parseFromTightYYYYMMDD("2022-05-24") + def addPrice(dist, startDate, endDate){ def weekends = DateUtils.getWeekendBetweenDates(startDate, endDate) - for(def weekend : weekends){ CommonUtils.recalculationAverage(dist.city, dist.region, dist.name, dist.estate_type2, weekend,false,0) } @@ -521,4 +647,30 @@ class CcbDistrictToDB { return null } + + def getLocationInfo(def city, def address){ + def gloJson = GaoDeApiUtils.geo(city, address) + if(gloJson) { + def glocation = null + if (gloJson && gloJson.get("geocodes")) { + def geocodes = gloJson.get("geocodes") + glocation = geocodes.get(0).location + } + return glocation + } + return null + } + + + def getStreetInfo(def glocation){ + def township = null + if(glocation){ + def jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { + def addressComponent = jsonObject.regeocode.addressComponent + return addressComponent; + } + } + return null; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy index afa2233b6..99e779ac6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy @@ -17,11 +17,11 @@ class DistrictMarge { //task.run() // task.repeatAddress() // task.removeDist() - task.updateAddress() -// task.addMappingAlias() +// task.updateAddress() + task.addMappingAlias() } def updateAddress(){ - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\更新小区地址.xlsx", { d -> + ExcelUtils.multiThreadingModify("D:\\数据\\建行\\更新小区地址_0608.xlsx", { d -> if (d['A']) { def region = d['B'].trim() def newRegion = RegionData.formatRegion(d['A'], region) @@ -41,7 +41,7 @@ class DistrictMarge { } def removeDist(){ - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\删除小区.xlsx", { d -> + ExcelUtils.modify("D:\\数据\\建行\\删除小区数据_245_0608.xlsx", { d -> if (d['A']) { def region = d['B'] def newRegion = RegionData.formatRegion(d['A'], region) @@ -52,6 +52,8 @@ class DistrictMarge { udata.put("status", 1) udata.put("m_date", new Date()) DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set', udata)) + }else{ + println d['A']+" "+d['C']+" 不存在" } }else{ println d['A'] + " 格式化失败 "+d['B'] @@ -62,7 +64,7 @@ class DistrictMarge { def addMappingAlias(){ def index = 0 - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\新增映射别名.xlsx", { d -> + ExcelUtils.multiThreadingModify("D:\\数据\\建行\\新增映射别名_0608.xlsx", { d -> index ++ if (d['A']) { def region = d['B'].trim() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy index d81974c8b..830424944 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy @@ -25,8 +25,9 @@ class ExportDistrictRongHe extends BaseBatch{ @Override void process(Object args) { def curDate = DateUtils.formatDateByPattern(new Date()+1, "yyyyMMdd") + def new_dists = ["350604","350605","410307","410308","450181"] //按天导(每天一个文件夹) - exportBigdataDealFJW2(curDate, DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()+1,-1), "yyyy-MM-dd")) + exportBigdataDealFJW2(curDate, DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()+1,-1), "yyyy-MM-dd"), new_dists) if(curDate.toString().endsWith("10")){ exportBigdataCommunityGJRH() @@ -459,7 +460,7 @@ class ExportDistrictRongHe extends BaseBatch{ } - def exportBigdataDealFJW2(curDate, dealdate){ + def exportBigdataDealFJW2(curDate, dealdate, new_dists){ def startDateStr = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") def endDateStr = DateUtils.formatDateByPattern(DateUtils.getLastDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") @@ -472,86 +473,107 @@ class ExportDistrictRongHe extends BaseBatch{ def allRows = [] if(curDate.toString().endsWith("28")){ - def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd')";//CITYID='${cityCode}' and - sqlInstance.eachRow(sql,{r-> - def data = [] - data << r.CITYID - data << r.DEALID - data << r.CITYNAME - data << r.DISTID - data << r.DISTNAME - data << r.STREET - data << r.STREETNO - data << r.COMMID - data << r.COMMNAME - data << r.BUILDID - data << r.BUILDNO - data << r.BUILDNAME - data << r.UNITID - data << r.UNITNO - data << r.UNITNAME - data << r.HOUSEID - data << r.ADDRESS - data << r.BUILDYEAR - data << r.PROPTYPE - data << r.PROPYEARS - data << r.PERIODNUM - data << r.FLOORNUM - data << r.FLOORTYPE - data << r.FLOORCNT - if(r.BUILDTYPE){ - def arrs = r.BUILDTYPE.replace("[","").replace("]","").split(",") - data << arrs[0].trim() - }else{ - data << '' - } - data << r.BUILDSTRU - data << r.BUILDAREA - data << r.LIVINGAREA - data << r.HOUSESTYLE - data << r.ROOMCNT - data << r.LIVINGROOMCNT - data << r.KITCHENCNT - data << r.BATHROOMCNT - data << r.HOUSEUSE - data << r.HOUSESTRU - data << r.HOUSEASPECT - data << r.FITMENT - data << r.EVALUATENO - data << r.DEALUNITPRICE - data << r.DEALTOTALPRICE - data << r.DECLAREPRICE - data << r.EVALUATEPRICE - data << r.CONTRACTNO - data << r.DEALDATE - data << r.DEALTYPE - data << r.PAYTYPE - data << r.DEALPERIOD - data << r.IFELEVATOR - data << r.COMPAREAGARDEN - data << r.COMPAREATERRACE - data << r.COMPAREABALCONY - data << r.COMPAREABAYWINDOW - data << r.COMPAREAATTIC - data << r.COMPAREAGARAGE - data << r.COMPAREABASEMENT - data << r.COMPAREAOTHER - data << r.DATASOURCE - data << r.AGENCYID - data << r.AGENCYNAME - data << r.REMARK - data << r.CREATETIME1 - data << r.UPDATETIME1 - data << r.SOURCECODE - data << r.WORKDATE - allRows << data - }); + if(new_dists){ + def newstr = "('"+new_dists.join("','")+"')" + def sql1 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ " + + "where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd') and" + + " distid not in ${newstr} ";//CITYID='${cityCode}' and + def rets1 = createDeal(sql1) + + def sql2 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ " + + " where distid in ${newstr}" + def rets2 = createDeal(sql2) + allRows.addAll(rets1) + allRows.addAll(rets2) + }else{ + def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd')";//CITYID='${cityCode}' and + allRows = createDeal(sql) + } } FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", false); CcbFtpUtils.ftpUpload("rh",fileName, curDate) println "BIGDATA_DEAL_FJW 上传Ftp完成......${endDateStr}" } + def createDeal(sql){ + def allRows = [] + sqlInstance.eachRow(sql,{r-> + def data = [] + data << r.CITYID + data << r.DEALID + data << r.CITYNAME + data << r.DISTID + data << r.DISTNAME + data << r.STREET + data << r.STREETNO + data << r.COMMID + data << r.COMMNAME + data << r.BUILDID + data << r.BUILDNO + data << r.BUILDNAME + data << r.UNITID + data << r.UNITNO + data << r.UNITNAME + data << r.HOUSEID + data << r.ADDRESS + data << r.BUILDYEAR + data << r.PROPTYPE + data << r.PROPYEARS + data << r.PERIODNUM + data << r.FLOORNUM + data << r.FLOORTYPE + data << r.FLOORCNT + if(r.BUILDTYPE){ + def arrs = r.BUILDTYPE.replace("[","").replace("]","").split(",") + data << arrs[0].trim() + }else{ + data << '' + } + data << r.BUILDSTRU + data << r.BUILDAREA + data << r.LIVINGAREA + data << r.HOUSESTYLE + data << r.ROOMCNT + data << r.LIVINGROOMCNT + data << r.KITCHENCNT + data << r.BATHROOMCNT + data << r.HOUSEUSE + data << r.HOUSESTRU + data << r.HOUSEASPECT + data << r.FITMENT + data << r.EVALUATENO + data << r.DEALUNITPRICE + data << r.DEALTOTALPRICE + data << r.DECLAREPRICE + data << r.EVALUATEPRICE + data << r.CONTRACTNO + data << r.DEALDATE + data << r.DEALTYPE + data << r.PAYTYPE + data << r.DEALPERIOD + data << r.IFELEVATOR + data << r.COMPAREAGARDEN + data << r.COMPAREATERRACE + data << r.COMPAREABALCONY + data << r.COMPAREABAYWINDOW + data << r.COMPAREAATTIC + data << r.COMPAREAGARAGE + data << r.COMPAREABASEMENT + data << r.COMPAREAOTHER + data << r.DATASOURCE + data << r.AGENCYID + data << r.AGENCYNAME + data << r.REMARK + data << r.CREATETIME1 + data << r.UPDATETIME1 + data << r.SOURCECODE + data << r.WORKDATE + allRows << data + }); + + return allRows; + } + def exportAllBigdataDealFJW(){ def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where DEALDATE= 0) { + + out.write(buffer, 0, n); + + } + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return out.toByteArray(); + + } + + public static String uncompressToString(byte[] bytes, String encoding) { + + if (bytes == null || bytes.length == 0) { + + return null; + + } + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + ByteArrayInputStream ins = new ByteArrayInputStream(bytes); + + try { + + GZIPInputStream ungzip = new GZIPInputStream(ins); + + byte[] buffer = new byte[256]; + + int n; + + while ((n = ungzip.read(buffer)) >= 0) { + + out.write(buffer, 0, n); + + } + + return out.toString(encoding); + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return null; + + } + + public static String uncompressToString(byte[] bytes) { + + return uncompressToString(bytes, GZIP_ENCODE_UTF_8); + + } + + /** + * 字符串转化成为16进制字符串 + * @param s + * @return + */ + public static String strTo16(String s) { + String str = ""; + for (int i = 0; i < s.length(); i++) { + int ch = (int) s.charAt(i); + String s4 = Integer.toHexString(ch); + str = str + s4; + } + return str; + } + + public static void main(String[] args) throws IOException { + + String s = "123"; + println "result: "+strTo16(s) + + System.out.println("字符串长度:"+s.length()); + + println compress(s) + + System.out.println("解压后:"+uncompress(compress(s)).length); + + System.out.println("解压字符串后::"+uncompressToString(compress(s)).length()); + + } + +} + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy new file mode 100644 index 000000000..aff0e94e9 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy @@ -0,0 +1,429 @@ +package com.fangjia.script.chongqing + +import com.fangjia.core.util.DataUtil +import com.fangjia.core.util.HttpRequest +import com.fangjia.httpclient.UserAgents +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.JacksonUtil +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.bytebuddy.description.type.TypeDescription +import org.apache.commons.lang.StringUtils + +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong +import java.util.zip.GZIPInputStream + + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + + +class MeituanStat { + + final static DBCollection CITY_INFO_CONN = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", MongoUtils.MongoDB_Domain_mongo); + + private static DBCollection on_line = MongoUtils.getCollectionByName("fangjia", "district_facilitys", MongoUtils.MongoDB_Domain_mongo) + + def arroundColl = CrawalDBUtil.getArroundTempCol(); + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) + + static main(args) { + def task = new MeituanStat() + task.run() +// task.run1() +// task.run2() + } + + def run(){ + def hexStr = "\\x1f\\x8b\\x08\\x00\\x17U\\xa4b\\x02\\xff342\\x06\\x00\\xd2cH\\x88\\x03\\x00\\x00\\x00" + println URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), StandardCharsets.UTF_8.name()) + + println URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), "utf-8"); +// def s = com.fangjia.core.util.DataUtil.zip("123") +// String str = new String(s, "utf-8"); +// def r = com.fangjia.core.util.DataUtil.unzips(s) +// println s +// println str +// println r +// def citys = ["北京","上海","保定","成都","广州","杭州","南京","深圳","天津","武汉","西安","重庆","吉林","常州","大连","东莞","佛山","福州","贵阳","哈尔滨","合肥","济南","昆明","南宁","宁波","青岛","厦门","沈阳","石家庄","苏州","太原","温州","无锡","长春","长沙","郑州","鞍山","包头","大庆","大同","海口","邯郸","衡阳","呼和浩特","湖州","淮安","惠州","济宁","嘉兴","江门","金华","荆州","兰州","连云港","临沂","柳州","洛阳","绵阳","南昌","南通","南阳","莆田","秦皇岛","泉州","三亚","汕头","绍兴","台州","泰州","唐山","威海","潍坊","乌鲁木齐","芜湖","襄阳","徐州","烟台","盐城","扬州","宜昌","银川","岳阳","湛江","镇江","中山","珠海","株洲","淄博"] +// def path = "D:\\数据\\美团\\美团88个城市统计.xlsx" +// def rets =[] +// rets << ["城市", "楼盘总量"] +// for(def c : citys){ +// def count = CommonDatautils.findAllDistrictCount("district", c) +// rets << [c, count] +// } +// ExcelUtils.write(path, rets, "总量") + } + + def run1(){ + def citys = ["北京","上海","保定","成都","广州","杭州","南京","深圳","天津","武汉","西安","重庆","吉林","常州","大连","东莞","佛山","福州","贵阳","哈尔滨","合肥","济南","昆明","南宁","宁波","青岛","厦门","沈阳","石家庄","苏州","太原","温州","无锡","长春","长沙","郑州","鞍山","包头","大庆","大同","海口","邯郸","衡阳","呼和浩特","湖州","淮安","惠州","济宁","嘉兴","江门","金华","荆州","兰州","连云港","临沂","柳州","洛阳","绵阳","南昌","南通","南阳","莆田","秦皇岛","泉州","三亚","汕头","绍兴","台州","泰州","唐山","威海","潍坊","乌鲁木齐","芜湖","襄阳","徐州","烟台","盐城","扬州","宜昌","银川","岳阳","湛江","镇江","中山","珠海","株洲","淄博"] + def path = "D:\\数据\\美团\\美团88个城市统计.xlsx" + def rets =[] + rets << ["城市","ID","区域","小区名","小区别名","地址","地址别名","物业类型","建筑类型","经度","纬度","板块","开发商","物业公司", + "环线","商圈","楼栋总数","户数","物业费","占地面积","建筑面积","容积率","绿化率","停车位","停车位(描述)","产权年限", + "产权性质","建成年代","开工时间","开盘时间","竣工时间","交房时间","装修情况","建筑结构","周边配套","交通状况","相关信息", + "描述","售楼地址","售楼电话","折扣信息","预售许可证","房产评级","房产均价","租金均价"] + for(def c : citys){ + def dists = CommonDatautils.findAllDistrictByCity(c, "district", ["lat","lng","loudong_count","mobile","car_site","fitment","relate_info","description","sell_address","discount","facilities","traffic","region","name"]) + def rMap = statFacilices(dists, c) + def obj = findFieldCov(c) + def rentCount = CommonDatautils.findSqmetreRents(c, DateUtils.parseFromTightByPattern("2022-05-31","yyyy-MM-dd")) + def block = obj.district_detail.block?obj.district_detail.block*100:'' + def alias = obj.district_detail.alias?obj.district_detail.alias*100:'' + def address= obj.district_detail.address?obj.district_detail.address*100:'' + def addrAlias = obj.district_detail.addrAlias?obj.district_detail.addrAlias*100:'' + def estateType2 = obj.district_detail.estateType2?obj.district_detail.estateType2*100:'' + def buildType = obj.district_detail.buildType?obj.district_detail.buildType*100:'' + def lng = obj.district_detail.lng?obj.district_detail.lng*100:'' + def developer = obj.district_detail.developer?obj.district_detail.developer*100:'' + def estateCompany = obj.district_detail.estateCompany?obj.district_detail.estateCompany*100:'' + def loopLineInfo = obj.district_detail.loopLineInfo?obj.district_detail.loopLineInfo*100:'' + def businessQuarter = obj.district_detail.businessQuarter?obj.district_detail.businessQuarter*100:'' + def loudong = '' + def loudongcount = getCount(dists,"loudong_count") + if(obj.existing_district_count && loudongcount){ + def pre = loudongcount*100/obj.existing_district_count + loudong = DataHandleUtils.getDoubleRound(2, pre) + } + + def householdCount = obj.district_detail.householdCount?obj.district_detail.householdCount*100:'' + def estateCharge = obj.district_detail.estateCharge?obj.district_detail.estateCharge*100:'' + def allArea = obj.district_detail.allArea?obj.district_detail.allArea*100:'' + def buildArea = obj.district_detail.buildArea?obj.district_detail.buildArea*100:'' + def cubagePercent = obj.district_detail.cubagePercent?obj.district_detail.cubagePercent*100:'' + def virescencePercent = obj.district_detail.virescencePercent?obj.district_detail.virescencePercent*100:'' + def carSite = obj.district_detail.carSite?obj.district_detail.carSite*100:'' + def carSiteStr = '' + def car_site_count = getCount(dists,"car_site") + if(obj.existing_district_count && car_site_count){ + def pre = car_site_count*100/obj.existing_district_count + carSiteStr = DataHandleUtils.getDoubleRound(2, pre) + } + def propertyLife = obj.district_detail.propertyLife?obj.district_detail.propertyLife*100:'' + def houseProperty = obj.district_detail.houseProperty?obj.district_detail.houseProperty*100:'' + def buildDate = obj.district_detail.buildDate?obj.district_detail.buildDate*100:'' + def startBuildingDate = obj.district_detail.startBuildingDate?obj.district_detail.startBuildingDate*100:'' + def openDate = obj.district_detail.openDate?obj.district_detail.openDate*100:'' + def finishBuildingDate = obj.district_detail.finishBuildingDate?obj.district_detail.finishBuildingDate*100:'' + def liveDate = obj.district_detail.liveDate?obj.district_detail.liveDate*100:'' + def fitment = '' + def fitment_count = getCount(dists,"fitment") + if(obj.existing_district_count && fitment_count){ + def pre = fitment_count*100/obj.existing_district_count + fitment = DataHandleUtils.getDoubleRound(2, pre) + } + def buildStructure = obj.district_detail.buildStructure?obj.district_detail.buildStructure*100:'' + def arround= '' + def facilities_count = getCount(dists,"facilities") + if(obj.existing_district_count && facilities_count){ + def pre = facilities_count*100/obj.existing_district_count + arround = DataHandleUtils.getDoubleRound(2, pre) + } + + def traffic = '' + def traffic_count = getCount(dists,"traffic") + if(obj.existing_district_count && traffic_count){ + def pre = traffic_count*100/obj.existing_district_count + traffic = DataHandleUtils.getDoubleRound(2, pre) + } + + def relateInfo = '' + def relate_info_count = getCount(dists,"relate_info") + if(obj.existing_district_count && relate_info_count){ + def pre = relate_info_count*100/obj.existing_district_count + relateInfo = DataHandleUtils.getDoubleRound(2, pre) + } + def description = '' + def description_count = getCount(dists,"description") + if(obj.existing_district_count && description_count){ + def pre = description_count*100/obj.existing_district_count + description = DataHandleUtils.getDoubleRound(2, pre) + } + def sellAddress = '' + def sell_address_count = getCount(dists,"sell_address") + if(obj.existing_district_count && sell_address_count){ + def pre = sell_address_count*100/obj.existing_district_count + sellAddress = DataHandleUtils.getDoubleRound(2, pre) + } + def mobile ='' + def mobile_count = getCount(dists,"mobile") + if(obj.existing_district_count && mobile_count){ + def pre = mobile_count*100/obj.existing_district_count + mobile = DataHandleUtils.getDoubleRound(2, pre) + } + def discount = '' + def dis_count = getCount(dists,"discount") + if(obj.existing_district_count && dis_count){ + def pre = dis_count*100/obj.existing_district_count + discount = DataHandleUtils.getDoubleRound(2, pre) + } + def licence = obj.district_detail.licence?obj.district_detail.licence*100:'' + def price = obj.price_coverage?obj.price_coverage*100:'' + def level = price + def rentPrie = '' + if(obj.existing_district_count && rentCount){ + def pre = rentCount*100/obj.existing_district_count + rentPrie = DataHandleUtils.getDoubleRound(2, pre) + } + + def db_fc = '' + def db_bus = '' + if(rMap){ + def count = obj.existing_district_count + if(rMap.bus){ + def pre = rMap.bus*100/count + db_bus = DataHandleUtils.getDoubleRound(2, pre) + } + if(rMap.fc){ + def pre = rMap.fc*100/count + db_fc = DataHandleUtils.getDoubleRound(2, pre) + } + } + rets << [c, 100,100,100,alias,address,addrAlias,estateType2,buildType,lng,lng,block,developer,estateCompany, + loopLineInfo,businessQuarter,loudong,householdCount,estateCharge,allArea,buildArea,cubagePercent,virescencePercent,carSite,carSiteStr,propertyLife, + houseProperty,buildDate,startBuildingDate,openDate,finishBuildingDate,liveDate,fitment,buildStructure,arround,traffic,relateInfo, + description,sellAddress,mobile,discount,licence,level,price,rentPrie, db_bus, db_fc] + println c +" 完成" + } + ExcelUtils.write(path, rets, "覆盖率") + } + + def run2(){ + ExcelUtils.modify("D:\\数据\\美团\\美团88个城市统计.xlsx",{d-> + def dists = CommonDatautils.findAllDistrictByCity(d['A'], "district", ["name","lat","lng"]) + def rMap = statFacilices(dists) + if(rMap){ + def count = dists.size() + if(rMap.bus){ + def pre = rMap.bus*100/count + d['AT'] = DataHandleUtils.getDoubleRound(2, pre) + } + if(rMap.fc){ + def pre = rMap.fc*100/count + d['AU'] = DataHandleUtils.getDoubleRound(2, pre) + } + } + }) + } + + def findFieldCov(c){ + def q = new BasicDBObject() + q.put("city", c) + q.put("weekend", DateUtils.parseFromTightByPattern("2022-06-05", "yyyy-MM-dd")) + def obj = CITY_INFO_CONN.findOne(q) + return obj + } + + def getCount(dists,field){ + def count = 0 + for(def d : dists){ + def val = d.get(field) + if(val && !val.toString().contains("暂无")){ + count++ + } + } + return count + } + + def statFacilices(dists){ +// def distMap = findArroundFaciltices(city) + def bus_count = 0 + def fc_count = 0 +// for(def d : dists){ +// def lng = d.lng/10000000000.0 +// def lat = d.lat/10000000000.0 +// def fcCount = findFacByEs(lng, lat, ["160100","060400","141200","141201","141202","141203","090100","160300"]) +// def busCount = findFacByEs(lng, lat, ["150700", "150500"]) +// println fcCount +// println busCount +// } + + def total = new AtomicLong() + def busCount = new AtomicLong() + def fcCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + for(def i=0;i0){ + busCount.addAndGet(1) + } + if(fc && fc>0){ + fcCount.addAndGet(1) + } + println total.get()+" "+ d.name + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + + def rMap = [:] + rMap.bus = busCount.get() + rMap.fc = fcCount.get() + return rMap + } + + def findFacByEs(lng, lat, codes){ + def must = [] + def term1 = ["terms":["typecode":codes]] + + must << term1 + def params = ["query":["bool":["must":must,"filter":["geo_distance": [ + "distance": "1km","location": ["lat": lat,"lon": lng]]]]]] + def s = httpSaveData(params, "http://192.168.0.206:9200/amap_poi/_search"); + def total = 0 + if(s){ + def doc = new groovy.json.JsonSlurper().parseText(s) + def hits = doc.hits + if(hits){ + total = hits.total.value + } + } + return total + } + + + + def findArroundFaciltices(city){ + def q = new BasicDBObject() + q.put("matched_city", city) + def dbcursor = arroundColl.find(q) + def distMap = [:] + for(def d : dbcursor){ + + def key = d.matched_region+"#"+d.matched_name + def dMap = distMap.get(key) + if(!dMap){ + dMap = [:] + distMap.put(d.region+"#"+d.district_name, dMap) + } + + def bus = 0 + def fc = 0 + if(d.type){ + if(d.type.contains("公交") || d.type.contains("地铁")){ + bus = 1 + fc = 1 + }else{ + fc = 1 + } + } +// if((d.bus && d.bus.size()>0) || (d.school && d.school.size()>0) || (d.bank && d.bank.size()>0) ||(d.supermarket && d.supermarket.size()>0) || (d.hospital && d.hospital.size()>0) || (d.atm && d.atm.size()>0)|| (d.university && d.university.size()>0)|| (d.middle_school && d.middle_school.size()>0) || (d.primary_school && d.primary_school.size()>0)|| (d.kindergarten && d.kindergarten.size()>0)){ +// fc = 1 +// } + dMap.bus = bus + dMap.fc = fc + } + return distMap + } + + def findAllFaciltices(city){ + def q = new BasicDBObject() + q.put("city", city) + def dbcursor = on_line.find(q) + def distMap = [:] + for(def d : dbcursor){ + def bus = 0 + def fc = 0 + if(d.bus && d.bus.size()>0){ + bus = 1 + } + if((d.bus && d.bus.size()>0) || (d.school && d.school.size()>0) || (d.bank && d.bank.size()>0) ||(d.supermarket && d.supermarket.size()>0) || (d.hospital && d.hospital.size()>0) || (d.atm && d.atm.size()>0)|| (d.university && d.university.size()>0)|| (d.middle_school && d.middle_school.size()>0) || (d.primary_school && d.primary_school.size()>0)|| (d.kindergarten && d.kindergarten.size()>0)){ + fc = 1 + } + def dMap = [:] + dMap.bus = bus + dMap.fc = 1 + distMap.put(d.region+"#"+d.district_name, dMap) + } + return distMap + } + + + + def httpSaveData(def params, def url){ + def header = [:] + header.put("Authorization","Basic ZGV2ZWxvcGVyOjVlOGVkZDg1MWQyZmRmYmQ3NDE1MjMyYzY3MzY3Y2Mz") + return doPost(url,header, params, true, "utf-8") + } + + + def doPost(def targetUrl, def headers, def params, def isJson, def charset){ + StringBuilder buffer = new StringBuilder(); + try{ + URL url = new URL(targetUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setUseCaches(false); + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + conn.setRequestProperty("User-Agent", UserAgents.get()); + String param = null; + BufferedWriter mWriter = null; + InputStreamReader inStream = null; + + + if (headers != null && headers.keySet().size() > 0) { + for (String head : headers.keySet()) { + conn.setRequestProperty(head, headers.get(head)); + } + } else { + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=" + CHARSET); + } + + if (isJson) { + conn.setRequestProperty("Content-Type", "application/json; charset=" + charset); + param = JacksonUtil.beanToJson(params) + } + + conn.connect(); + + //输出流 + if (StringUtils.isNotEmpty(param)) { + mWriter = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream(), charset)); + mWriter.write(param); + mWriter.flush(); + mWriter.close(); + } + if (conn.getHeaderField("Content-Encoding") != null + && conn.getHeaderField("Content-Encoding").equals("gzip")) { + inStream = new InputStreamReader(new GZIPInputStream(conn.getInputStream()), charset); + } else { + inStream = new InputStreamReader(conn.getInputStream(), charset); + } + char[] bf = new char[1024]; + int len; + while ((len = inStream.read(bf)) != -1) { + buffer.append(bf, 0, len); + } + } catch (Exception e) { + e.printStackTrace() + + } + return buffer.toString(); + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index b8e3cd5a1..5abaef7c1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -3200,6 +3200,14 @@ class CommonDatautils { return dbo; } + static def findSqmetreRents(def city, def weekend){ + def q = new BasicDBObject() + q.put("city", city) + q.put("weekend", weekend) + def count = SQMETRE_RENT_COLL.count(q) + return count; + } + static def findNewSqmetreRent(def city, def region, def name){ def q = new BasicDBObject() q.put("city", city) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy index f3f386be6..5c1e8c152 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy @@ -34,7 +34,8 @@ class FjtResponseTimeAnaly extends BaseBatch{ @Override public void process(Object args) { - run(); + //run(); + jms.sendMail("gaojuan@fangjia.com", "测试发邮件", "收到了?") } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy index 7e5074c7c..563e6ab47 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBCollection //福州第三方均价统计,发送钉钉消息 //def datas = ExcelUtils.read("d:\\数据\\福州\\福州4月2.xlsx",0,1) //def datas = CsvUtils.read("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202105.csv"); -def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202204.csv") +def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202205.csv") def count0 = 0 def count1 = 0 def count2 = 0 @@ -136,8 +136,8 @@ def curMonth = DateUtils.formatDateByPattern(new Date(), "yyyyMM") 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+"% )" println s -def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60" -DingDingMessageUtil.sendTextMessage(access_token, s) +//def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60" +//DingDingMessageUtil.sendTextMessage(access_token, s) ////def districts = CommonDatautils.findAllDistricts("福州", "district", ["city", "region", "name"]); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy index 7b357ab95..2cceebe1e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy @@ -143,9 +143,14 @@ class ThirdPriceExportBatch extends BaseBatch{ if(!retMap.zhugezhaofang_esf_price && d.zhugezhaofang_esf_price){ retMap.zhugezhaofang_esf_price = d.zhugezhaofang_esf_price } + if(!retMap.anjuke_esf_price && d.get("anjuke_esf_price")){ + retMap.anjuke_esf_price = d.get("anjuke_esf_price") + } + if(!retMap.anjuke_esf_price && d.get("58tc_esf_price")){ retMap.anjuke_esf_price = d.get("58tc_esf_price") } + if(!retMap.soufang_esf_price && d.soufang_esf_price){ retMap.soufang_esf_price = d.soufang_esf_price } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy index e4b621c99..5da258e86 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy @@ -165,7 +165,7 @@ class OpenApiUtils { return null; } address = address.trim().replace(" ","") - String url = "https://restapi.amap.com/v3/place/text?keywords=" + address + "&types=&city=" + city + "&output=json&offset=20&page=1&key=2af0b8533415a612b98d59bb93d664b9&extensions=all" + String url = "https://restapi.amap.com/v3/place/text?keywords=" + address + "&types=120000&city=" + city + "&output=json&offset=20&page=1&key=2af0b8533415a612b98d59bb93d664b9&extensions=all" List poiList = null; com.alibaba.fastjson.JSONObject result = null; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy index 45c2f60a5..42dd5ea08 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy @@ -12,7 +12,8 @@ class OpenUserBatch { def task = new OpenUserBatch(); // task.run(); // task.test(); - task.addShenZhenFjtUser(); +// task.addShenZhenFjtUser(); + task.addFujianFjtUser() } def test(){ @@ -63,4 +64,23 @@ class OpenUserBatch { } } + def addFujianFjtUser(){ + def datas = ExcelUtils.read("D:\\数据\\江苏农行\\福建省农行账号开通.xlsx",0,1) + def i = 0; + for(def data : datas){ + i++; + def id = 252738 + i; + String mobile = data['A'] + String pwd = '111111' + def sql = "insert into users(id, email, password, role, user_role, city, gold_total, come_from, date_created, last_updated, status, uid, access_token, house_report_token, open_day, fangdiao_apply_add, gujia_add, fangdiao_apply_count, gujia_down_count, fangdiao_add, fangdiao_down_count, yang_ben_down, mobile, pay_password, evaluation_count, close_date, manager, role_users, weixinId) VALUES ("+id+", '"+mobile+"', '"+pwd+"', '12', NULL, NULL, '0', 'fangjiatong', now(), now(), '0', NULL, NULL, '', '0', '2', '2', '2', '100', NULL, NULL, '0', NULL, NULL, '100', '2022-07-10 00:00:00', '0', '', NULL)"; + onLineSqlInstance.execute(sql); + + def sql2 = "INSERT INTO users_detail (id, p_id,name, org_name, phone, fax, email, address, role, company, user_valid_date, online_status, last_login_date, last_operat_date, date_created, last_updated, mobile, eva_guide, ip_list, sale_name) VALUES ('"+id+"', '0', '"+data['C']+"', '福建', '"+mobile+"', NULL, NULL, NULL, NULL, NULL, NULL, b'0', now(), now(), now(), now(), NULL, b'0', '', '蒋晓春')"; + onLineSqlInstance.execute(sql2) + + def sql3 = "INSERT INTO user_city (user_id, citys, credits) VALUES("+id+",'福州,厦门,泉州,莆田,宁德,三明,龙岩,南平,漳州','福州:,厦门:,泉州:,莆田:,宁德:,三明:,龙岩:,南平:,漳州:')" + onLineSqlInstance.execute(sql3) + } + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy new file mode 100644 index 000000000..e3ef4608c --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy @@ -0,0 +1,25 @@ +package com.fangjia.script.gj.abuyun + +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +class AnjukeTest { + + DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + + static main(args) { + def task = new AnjukeTest() + task.run() + } + + def run(){ + def q = new BasicDBObject() + def dbcursor = detail.find(q) + for(def d : dbcursor){ + def url = d.jumpAction + def s =ClaABuYun.getResponse(url) + println(s) + } + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy new file mode 100644 index 000000000..36115ae9c --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy @@ -0,0 +1,23 @@ +package com.fangjia.script.gj.abuyun + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.Proxy; +import java.net.URL; + +class ProxyAuthenticator extends Authenticator { + private String user, password; + + public ProxyAuthenticator(String user, String password) { + this.user = user; + this.password = password; + } + + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user, password.toCharArray()); + } +} \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy new file mode 100644 index 000000000..97dc61875 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy @@ -0,0 +1,91 @@ +package com.fangjia.script.gj.crawl + +import com.alibaba.fastjson.JSON +import com.alibaba.fastjson.JSONObject +import com.fangjia.script.crawl.JQueryUtils +import com.fangjia.script.gj.abuyun.ClaABuYun +import com.fangjia.script.temp.shenjian.util.MessageUtils +import com.fangjia.script.util.CommonUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.jsoup.Jsoup + + +class AnjukeAbuyunCrawl { + + DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + + static main(args) { + def task = new AnjukeAbuyunCrawl(); + task.run(); + } + def run(){ + def url = "https://fz.anjuke.com/sale/?from=navigation" + for(def i=2;i<50;i++){ + url ="https://fz.anjuke.com/sale/p${i}/?from=navigation" + def doc = getABuYunDocument(url); + def eles = JQueryUtils.select(".list-main .list-left .list .property a", doc) + println "页数:"+i+" 记录数:"+eles!=null?eles.size():0 + if(eles){ + parser(eles) + } + } + } + + def parser(eles){ + def index = 0 + for(def e : eles){ + index ++ + def href = e.attr("href") + def doc = getABuYunDocument(href); + def newUrl = href.substring(0, href.indexOf("?")) + sendMq(newUrl, doc) + println "[ "+index +"] "+ newUrl + } + } + + + + def getABuYunDocument(url){ + def stop = false + def error = 0 + def doc = null + while(!stop){ + try{ + def s = ClaABuYun.getResponse(url) + doc = Jsoup.parse(s); + def els = JQueryUtils.select(".list-main .list-left .list", doc) + if(!els){ + els = JQueryUtils.select(".props-main", doc) + } + if(els && els.size()>0){ + stop = true; + }else{ + error++ + println "[${error}] error: "+url + } + }catch(Exception e){ + error++ + } + if(error>=20){ + stop = true; + } + } + return doc + } + + def sendMq(href, doc){ + JSON json = new JSONObject() + json.put("project", "sell_anjuke") + json.put("url", href) + + JSON result = new JSONObject() + result.put("content", doc.toString()) + json.put("result", result) + + byte[] packedMsg = MessageUtils.pack(json) + CommonUtils.sendMessage("result2parse", packedMsg) + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy index d55350598..5354eafe8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy @@ -1,31 +1,239 @@ package com.fangjia.script.gj.crawl +import com.alibaba.fastjson.JSON +import com.fangjia.core.util.GeocodeUtils import com.fangjia.script.crawl.JQueryUtils +import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil import com.fangjia.script.thirdPriceCrawl.Utils import com.fangjia.script.util.ABuYunUtil +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl import net.sf.json.JSONObject +import org.apache.commons.lang.StringEscapeUtils import org.jsoup.Jsoup import org.openqa.selenium.WebDriver import org.openqa.selenium.chrome.ChromeDriver +import javax.script.Invocable +import javax.script.ScriptEngine +import javax.script.ScriptEngineManager +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + class AnjukeAppCrawl { + static def PREFIX_UNICODE = "\\u"; public static final SHORT_DATE = Utils.getLastMonth(); def static final DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); public static def SOURCE = "安居客"; DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) + static main(args) { + + + +// String line2 = StringEscapeUtils.unescapeJava(s); +// println line2 def task = new AnjukeAppCrawl(); +// task.autoRun() // task.run(); // task.run2() task.addThirdPrice() +// task.saveToEs() +// task.saveToEs1() + +// task.groupByCity() +// task.selectNoSave() +// task.statCount() + } + def saveToEs1(){ + def lists = getAllAppDatas() + anjukeToDB(lists) + } + + def statCount(){ + ExcelUtils.multiThreadingModify("D:\\数据\\anjuke\\cur_city_count.xlsx",{d-> + def city = d['B'] + if(!d['D']){ + def q = new BasicDBObject() + q.put("base.cityName",city) + def count = detail.count(q) + d['D'] = count + println city +" "+count + } + + }) + } + + def selectNoSave(){ + def esData = findAllEsData() + def q = new BasicDBObject() + def dbcursor = detail.find(q).batchSize(5000) + def index = 0 + for(def d : dbcursor){ + index++ + if(!esData.contains(d.jumpAction)){ + println "没保存 "+ d.jumpAction + } + if(index%100000==0){ + println index + } + + } + } + + def findAllEsData(){ + def urls = new HashSet() + ElasticUtils.executeSqlQuery("select url from community where source='安居客移动端'", { + urls << it.url + }) + return urls; + } + + def groupByCity(){ + def q = new BasicDBObject() + def dbcursor = detail.find(q).batchSize(5000) + def map = [:] + def index = 0 + for(def d : dbcursor){ + index++ + def city = d.base.cityName + def str = map.get(city) + if(!str){ + map.put(city, d.base.longCityListName) + } + println index + } + + map.each {k,v-> + println k + } + } + + def autoRun(){ + def rets = ExcelUtils.read("d:\\数据\\安居客城市区域编码.xlsx") + def total= rets.size() + def index =0 + for(def d : rets){ + index++ + println index+" "+ d['A']+" "+d['C'] + getDetailByRegion(d['A'], d['B'], d['D'], null) + } + + } + + def saveToEs(){ + def rets = ExcelUtils.read("d:\\数据\\安居客城市区域编码.xlsx",2,0) + def citys = ["福州"] + for(def d : rets){ + if(citys.contains(d['A'])){ + def lists = getAllAppDatas(d['A']) + anjukeToDB(lists) + citys << d['A'] + } + } + } + + def anjukeToDB(def lists){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(lists.size()) + for(def i=0;i + index++ + def regionDatas = getRegions(m.url+"community/?from=anjuke_home", driver) + println "[${index}] "+ch_city+" "+regionDatas.size() + regionDatas.each{k,v-> + + rets << [ch_city, m.city_id.toInteger(),v.info.name, v.info.value_str.toInteger()] + } + } + ExcelUtils.write("d:\\数据\\安居客城市区域编码.xlsx", rets, "数据") } def run2(){ @@ -46,6 +254,58 @@ class AnjukeAppCrawl { } } + def getRegions(url,driver){ + def doc = getDocument(url, driver) + def start = doc.toString().indexOf("") + if(start>0 && end>0 && end > start){ + def str = doc.toString().substring(start, end).replace(" + + + + + + + + + + +<#escape x as x?html> +
+
+ +
+
+ +
+
+
+
+

+

鎴戜滑寰堜箰鎰忎负鎮ㄦ彁渚涘府鍔�
+ √ 璇﹀敖鐨勪骇鍝佸姛鑳藉強鏈嶅姟浠嬬粛
+ √ 閽堝鎮ㄦ墍澶勭殑琛屼笟涓庝笟鍔″満鏅紝鎻愪緵涓撲笟鐨勬湇鍔℃柟妗�
+ √ 鏍规嵁鎮ㄧ殑涓氬姟瑙勬ā鍜岄渶姹傦紝鎻愪緵浼樻儬鐨勪环鏍兼柟妗�
+ 绱ф�ュ挩璇㈠彲鎷ㄦ墦400-188-3787
+ 棰勭害鐢宠璇风暀涓嬫偍鐨勮仈绯绘柟寮忥紝鎴戜滑浼氬敖蹇笌鎮ㄨ仈绯�
+
+

+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+ 鎻愪氦 +
+
+
+ + +<#include "/header/v5/_footer.ftl" /> +<#include "../citys.ftl"/> + + + + + + + + + + + + + + + + + + + diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl new file mode 100644 index 000000000..2009d5282 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl @@ -0,0 +1,87 @@ + + + + + +鍜ㄨ淇℃伅鎻愪氦鎴愬姛 - 鍦版暟 didata.ai + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+
+

鎮ㄧ殑淇℃伅宸叉彁浜ゆ垚鍔�

+ +

鑻ユ偍鏈変换浣曢棶棰橈紝娆㈣繋鎷ㄦ墦瀹㈡湇鐢佃瘽锛�400-188-3787

+
+
+
+
+ +<#include "/header/v5/_footer.ftl"/> + + + + + + + + diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java index 8daca61ed..6cb65c498 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java @@ -22,7 +22,8 @@ public enum SalesLeadEnum { DOWN_APPLY("1016", "下载申请"), FDANG_DIAO_BAO_GAO("1017", "房产专业调查评估报告"), BUSINESS_ASK("1018", "业务咨询"), - HOUSE_EVAL("1019", "房产评估"); + HOUSE_EVAL("1019", "房产评估"), + DIDATA("1020", "地数平台"); From 134a76cd767956c20cbb311e4ae18a49043dd3b2 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Wed, 22 Jun 2022 11:12:03 +0800 Subject: [PATCH 18/27] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E5=88=AB?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/saleLeads/didataApply.ftl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl index 78f147355..05f42d047 100644 --- a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl @@ -5,7 +5,7 @@ 鏃剁┖浠峰�兼寲鎺樺钩鍙� -鍦版暟 didata.ai - + <#include "../jsconstants.ftl" /> @@ -89,14 +89,12 @@

-

鎴戜滑寰堜箰鎰忎负鎮ㄦ彁渚涘府鍔�
- √ 璇﹀敖鐨勪骇鍝佸姛鑳藉強鏈嶅姟浠嬬粛
- √ 閽堝鎮ㄦ墍澶勭殑琛屼笟涓庝笟鍔″満鏅紝鎻愪緵涓撲笟鐨勬湇鍔℃柟妗�
- √ 鏍规嵁鎮ㄧ殑涓氬姟瑙勬ā鍜岄渶姹傦紝鎻愪緵浼樻儬鐨勪环鏍兼柟妗�
- 绱ф�ュ挩璇㈠彲鎷ㄦ墦400-188-3787
- 棰勭害鐢宠璇风暀涓嬫偍鐨勮仈绯绘柟寮忥紝鎴戜滑浼氬敖蹇笌鎮ㄨ仈绯�
-
-

+
鎴戜滑寰堜箰鎰忎负鎮ㄦ彁渚涘府鍔�
+
√ 璇﹀敖鐨勪骇鍝佸姛鑳藉強鏈嶅姟浠嬬粛
+
√ 閽堝鎮ㄦ墍澶勭殑琛屼笟涓庝笟鍔″満鏅紝鎻愪緵涓撲笟鐨勬湇鍔℃柟妗�
+
√ 鏍规嵁鎮ㄧ殑涓氬姟瑙勬ā鍜岄渶姹傦紝鎻愪緵浼樻儬鐨勪环鏍兼柟妗�
+
绱ф�ュ挩璇㈠彲鎷ㄦ墦400-188-3787
+
棰勭害鐢宠璇风暀涓嬫偍鐨勮仈绯绘柟寮忥紝鎴戜滑浼氬敖蹇笌鎮ㄨ仈绯�
@@ -131,7 +129,7 @@
- 鎻愪氦 + 鎻愪氦 From d57fa29702a4827abf72e4444b6e5c28509a547c Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Wed, 22 Jun 2022 13:29:26 +0800 Subject: [PATCH 19/27] =?UTF-8?q?=E5=89=94=E9=99=A4=E9=A1=B5=E8=84=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl | 1 - .../fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl | 1 - 2 files changed, 2 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl index 05f42d047..07a832de8 100644 --- a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl @@ -135,7 +135,6 @@ -<#include "/header/v5/_footer.ftl" /> <#include "../citys.ftl"/>