update
This commit is contained in:
+39
-14
@@ -11,6 +11,7 @@ import com.fangjia.script.util.GeoHelper
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import groovy.sql.Sql
|
||||
|
||||
|
||||
@@ -454,22 +455,46 @@ def city = "
|
||||
// }
|
||||
//})
|
||||
|
||||
ExcelUtils.modify("D:\\数据\\小区\\评级小区.xls", { d ->
|
||||
//ExcelUtils.modify("D:\\数据\\小区\\评级小区.xls", { d ->
|
||||
// if(d['A']){
|
||||
// try{
|
||||
// def dist = CommonDatautils.findDistrictFieldById(d['A'],["city","region","name"])
|
||||
// if(dist){
|
||||
// d['B'] = dist.city
|
||||
// d['C'] = dist.region
|
||||
// d['D'] = dist.name
|
||||
//
|
||||
// def price = CommonDatautils.queryDistrictPrice(dist.city, dist.region, dist.name)
|
||||
// d['E'] = price
|
||||
// }
|
||||
// }catch(Exception e){
|
||||
// println d['A']
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//})
|
||||
|
||||
ExcelUtils.modify("D:\\数据\\建行\\房产估值\\小区\\删除映射别名数据的副本.xlsx", { d ->
|
||||
if(d['A']){
|
||||
try{
|
||||
def dist = CommonDatautils.findDistrictFieldById(d['A'],["city","region","name"])
|
||||
if(dist){
|
||||
d['B'] = dist.city
|
||||
d['C'] = dist.region
|
||||
d['D'] = dist.name
|
||||
|
||||
def price = CommonDatautils.queryDistrictPrice(dist.city, dist.region, dist.name)
|
||||
d['E'] = price
|
||||
def dist = CommonDatautils.findDistrictById(d['A'])
|
||||
if(dist){
|
||||
def mappingAlias = dist.mapping_alias
|
||||
if(mappingAlias){
|
||||
if(mappingAlias.contains(d['B'])){
|
||||
mappingAlias.remove(d['B'])
|
||||
DBObject udata = new BasicDBObject();
|
||||
udata.put("mapping_alias", mappingAlias);
|
||||
udata.put("m_date", new Date());
|
||||
DbUtils.seaweed.update(new BasicDBObject("_id", d['A']), new BasicDBObject('$set', udata))
|
||||
}else{
|
||||
println d['A']+"无映射别名"
|
||||
}
|
||||
}else{
|
||||
println d['A']+"映射别名为空"
|
||||
}
|
||||
}catch(Exception e){
|
||||
println d['A']
|
||||
}else{
|
||||
println d['A']+"没找到"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -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_202201.csv")
|
||||
def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202202.csv")
|
||||
def count0 = 0
|
||||
def count1 = 0
|
||||
def count2 = 0
|
||||
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
package com.fangjia.script.gj.chongqingblank
|
||||
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.DataUtil
|
||||
import com.fangjia.script.util.DateUtils
|
||||
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.mongodb.QueryOperators
|
||||
import com.fangjia.core.util.DataUtil
|
||||
import org.apache.commons.lang.math.RandomUtils
|
||||
|
||||
class DistrictSelectHouse {
|
||||
|
||||
DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com")
|
||||
static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43")
|
||||
|
||||
static main(args) {
|
||||
def task = new DistrictSelectHouse();
|
||||
// task.run()
|
||||
// task.run2()
|
||||
task.run3()
|
||||
}
|
||||
|
||||
def run3(){
|
||||
ExcelUtils.multiThreadingModify("D:\\数据\\重庆农商行\\重庆样本V1 -跑地址.xlsx",{d->
|
||||
if(d['A']) {
|
||||
def dist = CommonDatautils.findDistrict(d['A'],d['B'], d['C'], "district")
|
||||
if(dist){
|
||||
d['L'] = dist.address
|
||||
}
|
||||
}
|
||||
},0)
|
||||
}
|
||||
|
||||
def run2(){
|
||||
ExcelUtils.multiThreadingModify("D:\\数据\\重庆农商行\\重庆样本.xlsx",{d->
|
||||
if(d['N']){
|
||||
def floorInfo = d['J']
|
||||
def height = d['N']
|
||||
if(floorInfo && height){
|
||||
height = height.toInteger()
|
||||
def mod = (int)(height/3)
|
||||
def h_start = (height - mod).toInteger()
|
||||
def random_floor = null
|
||||
if(floorInfo.contains("低楼层")){
|
||||
random_floor = random(1, mod)
|
||||
}else if(floorInfo.contains("中楼层")){
|
||||
random_floor = random(mod+1, h_start-1)
|
||||
}else if(floorInfo.contains("高楼层")){
|
||||
random_floor = random(h_start, height)
|
||||
}
|
||||
d['M'] = random_floor
|
||||
}
|
||||
}
|
||||
},0)
|
||||
|
||||
}
|
||||
|
||||
|
||||
int random(int i1, int i2) {
|
||||
int max = Math.max(i1, i2);
|
||||
int min = Math.min(i1, i2);
|
||||
return min + RandomUtils.nextInt(max - min + 1);
|
||||
}
|
||||
|
||||
|
||||
def run(){
|
||||
def city = "重庆"
|
||||
def weekend = "2022-03-06"
|
||||
def thirdPriceMap = findNearThirdPartyPrice(city)
|
||||
def distStats = findCreditHightDistrict2(city, weekend, thirdPriceMap)
|
||||
findAllHouse(distStats);
|
||||
}
|
||||
|
||||
def findAllHouse(distStats){
|
||||
def houses = []
|
||||
distStats.each{k,v->
|
||||
def arrs = k.split("#")
|
||||
def list = findHouses(arrs[0],arrs[1], arrs[2], 20220201,20220401)
|
||||
if(list){
|
||||
houses.addAll(list)
|
||||
}
|
||||
}
|
||||
if(houses){
|
||||
def rets = []
|
||||
for(def h : houses){
|
||||
def row = []
|
||||
row << h.city
|
||||
row << h.region
|
||||
row << h.district_name
|
||||
row << h.area
|
||||
row << h.avg_price
|
||||
row << h.total_price
|
||||
row << h.direction
|
||||
row << h.estate_type
|
||||
row << h.fitment
|
||||
row << h.floor_info
|
||||
row << h.room
|
||||
row << h.hall
|
||||
row << h.floor
|
||||
row << h.height
|
||||
row << h.p_date
|
||||
rets << row
|
||||
}
|
||||
ExcelUtils.write("D:\\数据\\重庆农商行\\重庆样本.xlsx", rets, "数据")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def findHouses(def city, def region, def name, def startDate, def endDate){
|
||||
String sql = "select * from latest_seawater where cat='sell' and root='lianjia.com' and city='${city}' and region='${region}' and district_name='${name}' and p_date >= ${startDate} and p_date<${endDate}"
|
||||
def houses = []
|
||||
ElasticUtils.executeSqlQuery(sql,{ data->
|
||||
houses << data
|
||||
})
|
||||
if(houses.size()>10){
|
||||
houses = houses[0..9]
|
||||
}
|
||||
return houses
|
||||
}
|
||||
|
||||
|
||||
def findNearThirdPartyPrice(def city){
|
||||
def q = new BasicDBObject()
|
||||
q.put("city", city)
|
||||
q.put("s_date", new BasicDBObject('$gte', 202108))
|
||||
q.put("lianjia_esf_price", new BasicDBObject(QueryOperators.EXISTS, true))
|
||||
def dbcursor = AVERAGE_STATISTICS.find(q)
|
||||
def thirdPriceMap = [:]
|
||||
for(def d : dbcursor){
|
||||
def key = d.city+"#"+d.region+"#"+d.name
|
||||
if(!thirdPriceMap.containsKey(key)){
|
||||
thirdPriceMap.put(d.city+"#"+d.region+"#"+d.name, d.lianjia_esf_price)
|
||||
}
|
||||
}
|
||||
return thirdPriceMap
|
||||
}
|
||||
|
||||
|
||||
|
||||
def findCreditHightDistrict2(def city, def weekend, def thirdPriceMap){
|
||||
def q = new BasicDBObject()
|
||||
q.put("city", city)
|
||||
q.put("value_type", 2)
|
||||
q.put("weekend", DateUtils.parseFromTightByPattern(weekend, "yyyy-MM-dd"))
|
||||
def dbcursor = DIST_SELL_STAT.find(q).sort(new BasicDBObject("credit",-1))
|
||||
def retMaps = [:]
|
||||
for(def d : dbcursor){
|
||||
def thirdPrice = thirdPriceMap.get(d.city +"#"+d.region+"#"+d.district_name)
|
||||
if(thirdPrice) {
|
||||
def precent = (thirdPrice - d.avg_price) * 100 / d.avg_price
|
||||
if (Math.abs(precent) >= 0 && Math.abs(precent) <= 10) {
|
||||
retMaps.put(d.city +"#"+d.region+"#"+d.district_name, d.avg_price)
|
||||
}
|
||||
}
|
||||
}
|
||||
return retMaps
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user