+93
-2
@@ -2656,12 +2656,12 @@ class CommonDatautils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static def queryDistrictPrices(city, region, name, estateType, startDate, endDate){
|
public static def queryDistrictPrices(city, region, name, startDate, endDate){
|
||||||
DBObject queryCondition = new BasicDBObject()
|
DBObject queryCondition = new BasicDBObject()
|
||||||
queryCondition.put("city", city);
|
queryCondition.put("city", city);
|
||||||
queryCondition.put("region", region);
|
queryCondition.put("region", region);
|
||||||
queryCondition.put("district_name", name);
|
queryCondition.put("district_name", name);
|
||||||
queryCondition.put("estate_type", estateType);
|
// queryCondition.put("estate_type", estateType);
|
||||||
queryCondition.put('weekend', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)).append('$lte', DateUtils.parseFromTightYYYYMMDD(endDate)));
|
queryCondition.put('weekend', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)).append('$lte', DateUtils.parseFromTightYYYYMMDD(endDate)));
|
||||||
DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
|
DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
|
||||||
def prices = [];
|
def prices = [];
|
||||||
@@ -4107,6 +4107,46 @@ class CommonDatautils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static def findHouseCountByDate(def city, def region, def name, def alias, def cat, def startDate){
|
||||||
|
|
||||||
|
QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(startDate).includeLower(true)
|
||||||
|
|
||||||
|
QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city))
|
||||||
|
.must(QueryBuilders.termQuery("region", region))
|
||||||
|
.must(QueryBuilders.termQuery("cat", cat)).must(date_range)
|
||||||
|
|
||||||
|
if(name || alias){
|
||||||
|
if(!alias){
|
||||||
|
alias = []
|
||||||
|
}
|
||||||
|
if(!alias.contains(name)){
|
||||||
|
alias.add(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(name.contains("弄小区")){
|
||||||
|
def newName = name.replace("弄小区","弄")
|
||||||
|
if(!alias.contains(newName)){
|
||||||
|
alias << newName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(alias && alias.size()>0){
|
||||||
|
BoolQueryBuilder inBuilder = QueryBuilders.boolQuery();
|
||||||
|
for(def s : alias){
|
||||||
|
inBuilder.should(QueryBuilders.matchQuery("district_name", s));
|
||||||
|
}
|
||||||
|
queryBuilder.must(inBuilder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"]
|
||||||
|
def index = new Random().nextInt(5);
|
||||||
|
def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder);
|
||||||
|
return houses.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是别墅
|
* 是否是别墅
|
||||||
* @return
|
* @return
|
||||||
@@ -5259,4 +5299,55 @@ class CommonDatautils {
|
|||||||
return STATS_INDEX_COLL.findOne(q)
|
return STATS_INDEX_COLL.findOne(q)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static def findAllThirdPrice(city, region, name, statDate){
|
||||||
|
def query = new BasicDBObject()
|
||||||
|
query.append("category", "district")
|
||||||
|
query.append("city", city)
|
||||||
|
query.append("region", region)
|
||||||
|
query.append("name", name)
|
||||||
|
query.append("s_date", new BasicDBObject(QueryOperators.GTE, statDate))
|
||||||
|
def dbCursor = thirdpartColl.find(query).sort(new BasicDBObject("s_date",-1))
|
||||||
|
def retMap = [:]
|
||||||
|
for(def d : dbCursor){
|
||||||
|
|
||||||
|
if(!retMap.get("xingfuli") && d.get("xingfuli_esf_price")){
|
||||||
|
retMap.put("xingfuli", d.get("xingfuli_esf_price"))
|
||||||
|
}
|
||||||
|
if(!retMap.get("anjuke") && d.get("anjuke_esf_price")){
|
||||||
|
retMap.put("anjuke", d.get("anjuke_esf_price"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!retMap.get("soufang") && d.get("soufang_esf_price")){
|
||||||
|
retMap.put("soufang", d.get("soufang_esf_price"))
|
||||||
|
}
|
||||||
|
if(!retMap.get("lianjia") && d.get("lianjia_esf_price")){
|
||||||
|
retMap.put("lianjia", d.get("lianjia_esf_price"))
|
||||||
|
}
|
||||||
|
if(!retMap.get("lianjia") && d.get("beike_esf_price")){
|
||||||
|
retMap.put("lianjia", d.get("beike_esf_price"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!retMap.get("cityhouse") && d.get("cityhouse_esf_price")){
|
||||||
|
retMap.put("cityhouse", d.get("cityhouse_esf_price"))
|
||||||
|
}
|
||||||
|
if(!retMap.get("jiwu") && d.get("jiwu_esf_price")){//使用吉屋替换房探 待抓取
|
||||||
|
retMap.put("jiwu", d.get("jiwu_esf_price"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!retMap.get("house365") && d.get("365house_esf_price")){//使用淘房365替换房多多
|
||||||
|
retMap.put("house365", d.get("365house_esf_price"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!retMap.get("maitian") && d.get("maitian_esf_price")){
|
||||||
|
retMap.put("maitian", d.get("maitian_esf_price"))
|
||||||
|
}
|
||||||
|
if(!retMap.get("tc_58") && d.get("58tc_esf_price")){
|
||||||
|
retMap.put("tc_58", d.get("58tc_esf_price"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-4
@@ -1,15 +1,14 @@
|
|||||||
package com.fangjia.script.gj.data_handle
|
package com.fangjia.script.gj.data_handle
|
||||||
|
|
||||||
import com.fangjia.core.RegionData
|
|
||||||
import com.fangjia.script.ccbevaluation.CcbCommonUtils
|
|
||||||
import com.fangjia.script.commData.CommonDatautils
|
import com.fangjia.script.commData.CommonDatautils
|
||||||
import com.fangjia.script.gj.district.SeaweedDataMatchProcess
|
|
||||||
import com.fangjia.script.util.ExcelUtils
|
import com.fangjia.script.util.ExcelUtils
|
||||||
|
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
class TempExportData {
|
class TempExportData {
|
||||||
|
|
||||||
@@ -17,7 +16,10 @@ class TempExportData {
|
|||||||
|
|
||||||
static main(args) {
|
static main(args) {
|
||||||
def task = new TempExportData()
|
def task = new TempExportData()
|
||||||
task.run()
|
// task.run()
|
||||||
|
def rets = task.fzHouseStat()
|
||||||
|
ExcelUtils.write("/home/goojia/gj/福州小区房源及第三方情况统计.xlsx", rets,"数据")
|
||||||
|
println "文件已生成"
|
||||||
}
|
}
|
||||||
|
|
||||||
def run() {
|
def run() {
|
||||||
@@ -75,4 +77,48 @@ class TempExportData {
|
|||||||
println(city +" "+rets.size())
|
println(city +" "+rets.size())
|
||||||
return rets;
|
return rets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def fzHouseStat(){
|
||||||
|
def districts = CommonDatautils.findAllDistricts("福州", "district", ["city", "region", "name", "alias","estate_type2"])
|
||||||
|
districts = districts[0..10]
|
||||||
|
def addCount = new AtomicLong()
|
||||||
|
final CountDownLatch latch = new CountDownLatch(districts.size())
|
||||||
|
def total = districts.size()
|
||||||
|
def rets = new CopyOnWriteArrayList()
|
||||||
|
rets << ["城市","区域","名称","上月价格","3年房源量","2年房源量", "2年第三方家数"]
|
||||||
|
for(def i=0;i<districts.size();i++){
|
||||||
|
final def o = districts[i]
|
||||||
|
// fixedThreadPool.execute(new Runnable() {
|
||||||
|
// void run() {
|
||||||
|
try{
|
||||||
|
addCount.addAndGet(1)
|
||||||
|
def prices = CommonDatautils.queryDistrictPrices(o.city, o.region, o.name, "2024-10-01", "2024-10-31")
|
||||||
|
def avg_price = 0
|
||||||
|
if(prices){
|
||||||
|
avg_price = prices[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
def count1 = CommonDatautils.findHouseCountByDate(o.city, o.region, o.name, o.alias, "sell", 20211115)
|
||||||
|
def count2 = CommonDatautils.findHouseCountByDate(o.city, o.region, o.name, o.alias, "sell", 20221115)
|
||||||
|
|
||||||
|
|
||||||
|
def thirdMap = CommonDatautils.findAllThirdPrice(o.city, o.region, o.name,202211)
|
||||||
|
def thirdCount = 0
|
||||||
|
if(thirdMap){
|
||||||
|
thirdCount = thirdMap.size()
|
||||||
|
}
|
||||||
|
rets << [o.city, o.region, o.name, avg_price, count1, count2, thirdCount]
|
||||||
|
println addCount.get() + " / "+ total
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
latch.countDown()
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
latch.await()
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user