diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BatchAddPersonGuiPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BatchAddPersonGuiPrice.groovy index a69810dab..ea0274d5f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BatchAddPersonGuiPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BatchAddPersonGuiPrice.groovy @@ -24,15 +24,16 @@ class BatchAddPersonGuiPrice { def run(){ - def path = "D:\\数据\\价格\\常南苏徐无人工指导价录入.xlsx" + def path = "D:\\数据\\福州\\价格比对_20240315 -价格入库.xlsx" def datas = ExcelUtils.read(path, 0, 1) for(def d : datas){ - def row = findGuidingPrice(d['B'], d['C'], d['D']) + def row = findGuidingPrice(d['B'], d['C'], d['C']) if(!row){ - def obj = CommonDatautils.findDistrictById(d['A']) - save(d['B'], d['C'], d['D'], d['M'], obj.estate_type2) +// def obj = CommonDatautils.findDistrictById(d['A']) + def obj = CommonDatautils.findDistrict(d['A'], d['B'], d['C'], "district") + save(d['A'], d['B'], d['C'], d['Q'], obj.estate_type2, d['P']) //发重算均价命令 - addPrice(d['B'], d['C'], d['D'], obj.estate_type2, DateUtils.parseFromTightByPattern('2023-01-01','yyyy-MM-dd'),new Date()) + addPrice(d['A'], d['B'], d['C'], obj.estate_type2, DateUtils.parseFromTightByPattern('2023-03-01','yyyy-MM-dd'),new Date()) } } } @@ -43,13 +44,13 @@ class BatchAddPersonGuiPrice { q.put("city", city) q.put("region", region) q.put("name", name) - q.put("guiding_person" , "付贵生") - q.put("guiding_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern("2022-11-01", "yyyy-MM-dd"))) +// q.put("guiding_person" , person) + q.put("guiding_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern("2024-03-20", "yyyy-MM-dd"))) def dbo = GUIDING_PRICE_COLL.findOne(q) return dbo } - def save(city, region, name, price, estate_type){ + def save(city, region, name, price, estate_type, person){ DBObject obj = new BasicDBObject(); obj.put("city", city); obj.put("region", region); @@ -62,7 +63,7 @@ class BatchAddPersonGuiPrice { obj.put("m_date", new Date()); obj.put("estate_type" , estate_type); obj.put("house_type" , 0) - obj.put("guiding_person" , "陈杰") + obj.put("guiding_person" , person) GUIDING_PRICE_COLL.save(obj); } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/PgsqlCommUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/PgsqlCommUtils.groovy index 2fd7e0c2f..cfbd78a2d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/PgsqlCommUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/PgsqlCommUtils.groovy @@ -27,4 +27,13 @@ class PgsqlCommUtils { }); return count } + + public static def findDistrictMap(){ + def sql = "select urbn_id,gujia_admndiv_id,gujia_admndiv_nm from base.t0831_bigdata_district_gj_h" + def map = [:] + sqlInstance.eachRow(sql,{r-> + map.put(r.urbn_id+"#"+r.gujia_admndiv_id, r.gujia_admndiv_nm) + }); + return map + } } 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 ad59e008c..1af08d6b3 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 @@ -1175,6 +1175,28 @@ class CommonDatautils { return null; } + + + public static def findAllStatusDistrict(String city,String region, String name, String cat){ + + DBObject q = new BasicDBObject(); + q.put("city", city); + q.put("region", region); + q.put("name", name); + q.put("cat", cat); + + def rets = [] + def cursor = SEAWEED_MONGO_COLL.find(q); + if(cursor){ + for(def obj : cursor){ + rets << obj; + } + + } + return rets; + } + + public static def findDistrictsByName(String city, String name, String cat){ DBObject q = new BasicDBObject(); @@ -1537,6 +1559,32 @@ class CommonDatautils { } + static def findAllStatusDistrictByAlias(def city, def region, def name, def cat){ + DBObject q = new BasicDBObject(); + if(region){ + q.put('region', region) + } + + q.put('city',city) + q.put('cat', cat) + + def names = []; + names << name; + BasicDBObject query = new BasicDBObject(); + query.putAt(QueryOperators.IN, names); + q.put("alias", query); + + + def dsCursor = getDataStoreConnection().find(q); + def ret = []; + for(def obj : dsCursor){ + ret << obj; + } + + return ret; + } + + static def findDistrictByAddress(def city, def region, def address, def cat){ DBObject q = new BasicDBObject(); if(region){ @@ -3919,6 +3967,29 @@ class CommonDatautils { return avg_price } + static def findMatchTrades(city, region, name, startDate, endDate){ + def q = new BasicDBObject() + q.put("city", city) + q.put("match_region", region) + q.put("match_name", name) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)).append('$lt',DateUtils.parseFromTightYYYYMMDD(endDate))) + def dbcorsor = DEAL_PRICE_COLL.find(q) + def avg_price = 0 + def total_price = 0 + def count = 0 + + for(def d : dbcorsor){ + if(d.avg_price){ + total_price = total_price + d.avg_price + count++ + } + } + if(count > 3){ + avg_price = total_price/count + } + return avg_price + } + /** @@ -3993,6 +4064,32 @@ class CommonDatautils { return total; } + + static def findLogs(user_id, requestUri, startDate, endDate){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("user_id", user_id)).must(QueryBuilders.termQuery("request_uri", requestUri)) + if(startDate){ + def startTime = DateUtils.parseFromTightYYYYMMDD(startDate) + def endTime = DateUtils.parseFromTightYYYYMMDD(endDate) + def date_range_cdate = QueryBuilders.rangeQuery("c_date").from(startTime.getTime()).to(endTime.getTime()).includeLower(true).includeUpper(false); + queryBuilder.must(date_range_cdate); + } + + def houses = ElasticUtils.executeSimpleQuery("192.168.0.206", "open_uri_log", queryBuilder); + if(houses){ + for (int k=0;k3000){ dataMap.put("beike_esf_price", db.beike_esf_price) } + if(!dataMap.containsKey("maitian_esf_price") && db.maitian_esf_price && db.maitian_esf_price>3000){ + dataMap.put("maitian_esf_price", db.maitian_esf_price) + } + } return map } @@ -4337,6 +4438,23 @@ class CommonDatautils { } + static def findHouseAvgPrice(city, region , start, end){ + def prices = [] + def sql = "select avg_price from latest_seawater where cat='sell' and city='${city}' and p_date > ${start} and p_date<${end} and (root='lianjia.com' or root='ke.com')" + if(region){ + sql = sql + " and region='${region}'" + } + ElasticUtils.executeSqlQuery(sql, { + prices << it.avg_price + }) + if(prices && prices.size()>3){ + def avg_price = (int)(prices.sum()/prices.size()) + println region + " "+ prices.size() +" "+avg_price +" "+start+" "+end + return avg_price + } + return null + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy index 0b6a136ec..beeafcb09 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy @@ -7,6 +7,7 @@ import com.fangjia.script.Watcher import com.fangjia.script.util.CommonUtils import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection @@ -74,7 +75,7 @@ class DistrictSellStatBatch extends BaseBatch { def day = new Date().getDate() - def startMDate = DateUtils.truncateDay(new Date()-1) + def startMDate = DateUtils.truncateDay(new Date()-7) def endMDate = DateUtils.truncateDay(new Date()) def index = 0 @@ -144,7 +145,8 @@ class DistrictSellStatBatch extends BaseBatch { void run() { try { totalCount.addAndGet(1) - def key = dist.region +"##" + dist.name + def type = dist.estate_type2=="别墅"?"别墅":"小区" + def key = dist.region +"##" + dist.name+"##"+ type def weekendPriceObj = weekendPriceMap.get(key) if(weekendPriceObj){ @@ -153,8 +155,13 @@ class DistrictSellStatBatch extends BaseBatch { def lastYearPriceObj = lastYearPriceMap.get(key) double mom = 0d - if(lastMonthPriceObj) { - mom = DataUtil.roundDouble(((weekendPriceObj.avg_price - lastMonthPriceObj.avg_price)/(double)lastMonthPriceObj.avg_price),4) + if(lastMonthPriceObj && lastMonthPriceObj.avg_price>0) { + try{ + mom = DataUtil.roundDouble(((weekendPriceObj.avg_price - lastMonthPriceObj.avg_price)/(double)lastMonthPriceObj.avg_price),4) + }catch(Exception e){ + println key+" 出错................." + } + } def curPrice = weekendPriceObj.avg_price @@ -192,7 +199,7 @@ class DistrictSellStatBatch extends BaseBatch { curPrice = 0 } if(curPriceObj){ - if(curPrice!=weekendPriceObj.avg_price){ + if(curPrice!=curPriceObj.avg_price){ def data = new BasicDBObject() data.put("m_date", new Date()) data.put("commid", dist._id.toString()) @@ -263,7 +270,7 @@ class DistrictSellStatBatch extends BaseBatch { } } if(!priceMap.containsKey(d.region +"##"+d.district_name)){ - priceMap.put(d.region +"##"+d.district_name, d) + priceMap.put(d.region +"##"+d.district_name+"##"+d.estate_type, d) } } return priceMap @@ -355,4 +362,5 @@ class DistrictSellStatBatch extends BaseBatch { // } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy index 02d267a37..893ad9876 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy @@ -9,6 +9,7 @@ import com.mongodb.Bytes import com.mongodb.DBCollection import com.mongodb.DBCursor import com.mongodb.DBObject +import com.rabbitmq.client.AMQP import com.rabbitmq.client.impl.AMQImpl import org.apache.commons.io.FileUtils import org.bson.types.ObjectId @@ -28,10 +29,11 @@ class FzDataResultStat { static main(args) { def task = new FzDataResultStat() - task.priceMarkupRun(); - task.regionPriceTrendRun() +// task.priceMarkupRun(); +// task.regionPriceTrendRun() //// task.margeExcel() // task.saveCsvData() + task.testNewPrice() } def margeExcel(){ @@ -163,7 +165,7 @@ class FzDataResultStat { def exportRegion(city, months){ - def regions = ["鼓楼","仓山","台江","晋安","马尾","长乐"]; + def regions = ["鼓楼","仓山","台江","晋安","马尾","长乐","福清","闽侯","连江","罗源","闽清","永泰","平潭"]; def datas =[] def header = ["城市", "区域"] for(def m : months){ @@ -206,8 +208,12 @@ class FzDataResultStat { DBObject dbo = cur.next() prices << dbo.get("avg_price"); } - def avg_price = (int)(prices.sum()/prices.size()) - return avg_price; + if(prices){ + def avg_price = (int)(prices.sum()/prices.size()) + return avg_price; + } + + return null; } @@ -293,4 +299,20 @@ class FzDataResultStat { } return rets } + + def testNewPrice(){ + ExcelUtils.modify("D:\\数据\\福州\\价格比对_20240315 -价格入库.xlsx",{d-> + if(d['A']){ + def q = new BasicDBObject() + q.put("city", d['A']) + q.put("region",d['B']) + q.put("name",d['C']) + q.put("month", 202402) + def obj = FZ_DISTRICT_STAT_COLL.findOne(q) + if(obj){ + d['S'] = obj.avg_price + } + } + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDistrictMatch.groovy index cae471308..baccfa579 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDistrictMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDistrictMatch.groovy @@ -19,7 +19,41 @@ class FzDistrictMatch { def task = new FzDistrictMatch() // task.run(); // task.addPrice() - task.addThirdPrice() +// task.addThirdPrice() + + task.addThirdPrice2("D:\\数据\\福州\\价格比对_20240315.xlsx") + } + + def addThirdPrice2(path){ + + ExcelUtils.multiThreadingModify(path, { row -> + def cityMap = CommonDatautils.findThirdPartyPrice(row['A'], row['B'], row['C'], 202312, 202402) + def priceMap = cityMap.get(row['A']+"##"+row['B']+"##"+row['C']) + if(priceMap){ + if(priceMap.containsKey("lianjia_esf_price")){ + row['J'] = priceMap.get("lianjia_esf_price") + } + + if(!row['J'] && priceMap.containsKey("beike_esf_price")){ + row['J'] = priceMap.get("beike_esf_price") + } + + if(priceMap.containsKey("maitian_esf_price")){ + row['K'] = priceMap.get("maitian_esf_price") + } + } + + def tradeAvgPrice = CommonDatautils.findMatchTrades(row['A'], row['B'], row['C'], "2023-08-01", "2024-01-31"); + if(tradeAvgPrice){ + row['L'] = (int)tradeAvgPrice + } + + def priceObj = CommonDatautils.findDistrictPrice(row['A'], row['B'], row['C']) + if(priceObj){ + row['M'] = priceObj.avg_price_2b + } + + }) } def addThirdPrice(){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/YouDaDataParser.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/YouDaDataParser.groovy index c40aca736..0db9c5bb7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/YouDaDataParser.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/YouDaDataParser.groovy @@ -52,7 +52,7 @@ class YouDaDataParser { static main(args) { def task = new YouDaDataParser(); // task.newHouseparse();//友达一手房存入mongo -// task.esfParser("D:\\数据\\友达\\2024年2月\\查询1.DBF");//友达二手房存入mongo + task.esfParser("D:\\数据\\友达\\2024年2月\\查询1.DBF");//友达二手房存入mongo // task.newhouseToSaveEs();//新房保存到es task.esfhouseToSaveEs();//二手房保存到es // task.updateFinishDateByEsfTrade();//根据二手成交的竣工时间修改seaweed库中的竣工时间 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy index 3289104fe..7ecf720df 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy @@ -31,7 +31,34 @@ class CityStatExport { // task.regionStat() // task.stat() // task.houseStat() - task.addFieldStat() +// task.addFieldStat() + + task.exportRegionAvgPrice() + } + + def exportRegionAvgPrice(){ + def regions = ["鼓楼","仓山","台江","晋安","马尾","长乐","福清","闽侯","连江","罗源","闽清","永泰","平潭"]; + def add = -9; + def months = [] + while(add<=0){ + months << DateUtils.addMonth(new Date(), add) + add++ + } + def rets = [] + rets << months + for(def region : regions){ + def row = [] + row << region + for(def i=0; i + if(!d['G']){ +// def name1 = d['E'].replace("街道","").replace("镇","").replace("乡","") +// def name2 = d['F'].replace("街道","").replace("镇","").replace("乡","") +// if(name1 == name2){ +// d['G'] = "不处理" +// } + + def lists1 = findCommunityTown(community_CONN, d['C'], d['D'], d['E']) + def lists2 = findCommunityTown(community_CONN, d['C'], d['D'], d['F']) + if(lists1 && lists2){ + d['G'] = "需删除" + } + } + }) + } + + + def findCommunityTown(community_CONN, city, region, town){ + def q = new BasicDBObject() + q.put("city_name", city) + q.put("area_name", region) + q.put("street_name", town) + def rets = community_CONN.find(q).toList() + return rets; + + } +} + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/GXDdistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/GXDdistrictMatch.groovy new file mode 100644 index 000000000..85b3a9a65 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/GXDdistrictMatch.groovy @@ -0,0 +1,138 @@ +package com.fangjia.script.gj.district + +import com.fangjia.core.RegionData +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.ccbevaluation.PgsqlCommUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.ExcelUtils + +class GXDdistrictMatch { + + static def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + static def regionCodeDataMap = PgsqlCommUtils.findDistrictMap() + + static main(args) { + def task = new GXDdistrictMatch(); + task.run() + } + + def run(){ + def fileName = "D:\\数据\\国信达\\国信达11城2.xlsx" + ExcelUtils.multiThreadingModify(fileName, { d -> + if(!d['V']){ + def city = getCityFromCityCode(d['A']) + def region = regionCodeDataMap.get(d['A'] + "#" + d['E']) + if (city && region) { + region = RegionData.formatRegion(city, region) + if (region) { + d = match(city, region, d) + } else { + println d['A'] + "#" + d['E'] + " 区域无法格式化" + } + } else { + println d['A'] + "#" + d['E'] + " 无法格式化" + } + } + }) + } + + + def match(city, region, d){ + d = matching(city, region, d, d['C'], d['D'], "") + if(!d['U']){ + if(d['C'].contains("小区")){ + d = matching(city, region, d, d['C'].replace("小区",""), d['D'], "(Update)") + }else{ + d = matching(city, region, d, d['C']+"小区", d['D'], "(Update)") + } + if(!d['U']){ + d = matching2(city, region, d, d['C'], d['D'], "") + } + + if(!d['U']){ + if(d['C'].contains("小区")){ + d = matching2(city, region, d, d['C'].replace("小区",""), d['D'], "(Update)") + }else{ + d = matching2(city, region, d, d['C']+"小区", d['D'], "(Update)") + } + } + + } + } + + + def matching(city, region, d, name, alias, str){ + //正常状态下有没有 + def rets = CommonDatautils.findDistrictList(city, region, name, "district") + if(rets){ + if(rets.size()==1){ + d = setRowValue(rets[0], d, "名称匹配"+str) + }else{ + d['U'] = "名称在多个小区中"+str + } + }else{ + rets = CommonDatautils.findDistrictByAlias(city, region, name, "district") + if(rets && rets.size()==1){ + d = setRowValue(rets[0], d, "名称在别名中"+str) + }else{ + if (d['D']) { + rets = CommonDatautils.findDistrictByAlias(city, region, alias, "district") + if (rets) { + if (rets.size() == 1) { + d = setRowValue(rets[0], d, "别名匹配"+str) + } else { + d['U'] = "别名在多个小区中"+str + } + } + } + } + } + + return d; + } + + def matching2(city, region, d, name, alias, str){ + def rets = CommonDatautils.findAllStatusDistrict(city, region, name, "district")//包含删除的 + if(rets){ + if (rets.size() == 1) { + d = setRowValue(rets[0], d, "名称匹配(非正常)"+str) + } + }else{ + + rets = CommonDatautils.findAllStatusDistrictByAlias(city, region, name, "district") + if (rets && rets.size() == 1) { + d = setRowValue(rets[0], d, "别名匹配(非正常)"+str) + }else{ + rets = CommonDatautils.findAllStatusDistrictByAlias(city, region, alias, "district") + if (rets.size() == 1) { + d = setRowValue(rets[0], d, "别名匹配(非正常)"+str) + } + } + } + return d; + } + + def setRowValue(dbo, d, remark){ + if (dbo) { + d['V'] = dbo.city + d['W'] = dbo.region + d['X'] = dbo.name + d['Y'] = dbo.estate_type2 + d['Z'] = dbo.status + d['AA'] = dbo.name_cat + d['U'] = remark + } + return d; + } + + def getCityFromCityCode(cityCode){ + def city = null + for(def m : cityCodeDataMap){ + if(m.value == cityCode){ + city = m.key + break; + } + } + return city; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsSelectTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsSelectTest.groovy index 6f2307343..d259d858b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsSelectTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsSelectTest.groovy @@ -1,6 +1,7 @@ package com.fangjia.script.gj.es import com.fangjia.core.util.DateUtil +import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.util.ElasticUtils import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders @@ -16,7 +17,13 @@ class EsSelectTest { static main(args) { def task = new EsSelectTest() - task.run() +// task.run() + task.test() + } + + + def test(){ + def ret = CommonDatautils.findLogs("1007703", "/property/evaluate", "2024-03-13", "2024-03-16") } def run(){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy new file mode 100644 index 000000000..c153747fc --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy @@ -0,0 +1,107 @@ +package com.fangjia.script.gj.village + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.temp.shenjian.util.HttpUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.yinjihaun.util.HttpClient +import net.sf.json.JSONObject + +class QiliangTest { + + static main(args) { + def task = new QiliangTest() + task.run() + } + + def run(){//地址测试-2024.3.4-结果.xlsx + ExcelUtils.modify("D:\\数据\\省联社\\对比.xlsx", { row -> + if(!row['N']){ + def address = null + if(row['B'] && row['C'] && !row['C'].toString().contains(row['B'])){ + address = row['B']+row['C'] + }else{ + address = row['C'] + } + if(address){ + def result = getHttpResult(address) + if(result && result.code==20000){ + def data = result.data + if(data){ + if(data.province && data.province!='null'){ + row['N'] = data.province + } + if(data.city && data.city!='null'){ + row['O'] = data.city + } + if(data.district && data.district!='null'){ + row['P'] = data.district + } + if(data.town && data.town!='null'){ + row['Q'] = data.town + } + if(data.village && data.village!='null'){ + row['R'] = data.village + } + + if(data.areaCode && data.areaCode!='null'){ + row['S'] = data.areaCode + } + + if(data.farmer == "0"){ + row['T'] = "非农" + }else{ + row['T'] = "农" + } + if(data.isGovt == "0"){ + row['U'] = "否" + }else{ + row['U'] = "是" + } + + def list = data.indusParkList + if(list && list!="null"){ + def s = "" + for(def r : list){ + s = s + r.indusParkName +"-"+r.indusParkLevel+"\n" + } + row['V'] = s + } + if(data.govtAddr && data.govtAddr!='null'){ + row['W'] = data.govtAddr?data.govtAddr:'' + } + + } + } + } + } + }) + } + + def getHttpResult(address){ + def data = new JSONObject() + data.put("address", address) + data.put("type","1") + + Map headers = new HashMap(); + headers.put("Accept", "application/json, text/plain, */*"); + headers.put("Accept-Encoding", "gzip, deflate"); + headers.put("Accept-Language","zh-CN,zh;q=0.9") + headers.put("Content-Type","application/json;charset=UTF-8") + headers.put("Host","146.56.217.44:9010") + headers.put("Origin","http://146.56.217.44:8088") + headers.put("Proxy-Connection","keep-alive") + headers.put("Referer","http://146.56.217.44:8088/") + headers.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36") + + HttpRequest request1 = new HttpRequest() + try{ + String res = request1.postWithBody("http://146.56.217.44:9010/uams/farmer/all/v3/sign", JSONObject.fromObject(data.toString()), headers, "UTF-8") + def response = JSONObject.fromObject(res) + println response + return response + }catch(Exception e){ + e.printStackTrace() + } + return null; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy index 49136a392..42972bc05 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy @@ -23,8 +23,8 @@ class DataStat { // for(def city :citys){ // println city // } -// task.run(); - task.stat() + task.run(); +// task.stat() // def citys = ["福州", "厦门", "泉州", "莆田", "宁德", "三明", "龙岩", "南平", "漳州"] // def rets = [] @@ -76,7 +76,7 @@ class DataStat { } def stat(){ - def dates = [202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202401] + def dates = [202303,202304,202305,202306,202307,202308,202309,202310,202311,202401,202402] def sources = ["时间","我爱我家","兔博士","吉屋","贝壳找房","乐有家","365淘房","诸葛找房","链家","Q房","麦田","中原地产","安居客","搜房","C21","城市房产","幸福里"] // crawlCount(dates,sources); matchCount(dates,sources); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestCrawlTotalCount.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestCrawlTotalCount.groovy index e396b2e96..a53d2d7c7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestCrawlTotalCount.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestCrawlTotalCount.groovy @@ -14,8 +14,8 @@ class TestCrawlTotalCount { def run(){ def sources = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集","链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","乐有家","乐有家(新)","房探","房多多","小资家","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋","幸福里"] for(def source :sources){ - def count1 = findTotalCount(source, 202307); - def count2 = findTotalCount(source, 202401); + def count1 = findTotalCount(source, 202401); + def count2 = findTotalCount(source, 202402); println source +" "+count1 +" "+count2 } }