+64
@@ -5818,4 +5818,68 @@ class CommonDatautils {
|
|||||||
}
|
}
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static def findSeawater(city, lng, lat, distance, p_date, cat){
|
||||||
|
def header = [:]
|
||||||
|
header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString()
|
||||||
|
String seawaterUrl = "http://192.168.0.206:9200/seawater-*/_search"
|
||||||
|
def body = """
|
||||||
|
{
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must": [
|
||||||
|
{
|
||||||
|
"geo_distance": {
|
||||||
|
"distance": "1km",
|
||||||
|
"location": {
|
||||||
|
"lat": ${lat},
|
||||||
|
"lon": ${lng}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"term": {
|
||||||
|
"city": "${city}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"term": {
|
||||||
|
"cat": "${cat}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"range": {
|
||||||
|
"publish_date": {
|
||||||
|
"gte": "${p_date}",
|
||||||
|
"format": "yyyy-MM-dd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sort": [
|
||||||
|
{
|
||||||
|
"publish_date": {
|
||||||
|
"order": "desc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"size":30
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
HttpRequest request = new HttpRequest()
|
||||||
|
String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8")
|
||||||
|
def response = new JsonSlurper().parseText(res)
|
||||||
|
|
||||||
|
def esObj = null
|
||||||
|
if(response && response.hits){
|
||||||
|
esObj = response.hits.hits
|
||||||
|
}
|
||||||
|
return esObj
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-12
@@ -1,5 +1,6 @@
|
|||||||
package com.fangjia.script.jiangnanblank
|
package com.fangjia.script.jiangnanblank
|
||||||
|
|
||||||
|
import com.fangjia.core.util.DateUtil
|
||||||
import com.fangjia.script.BaseBatch
|
import com.fangjia.script.BaseBatch
|
||||||
import com.fangjia.script.BatchOwner
|
import com.fangjia.script.BatchOwner
|
||||||
import com.fangjia.script.Watcher
|
import com.fangjia.script.Watcher
|
||||||
@@ -7,24 +8,16 @@ import com.fangjia.script.commData.CommonDatautils
|
|||||||
import com.fangjia.script.common.DataHandleUtils
|
import com.fangjia.script.common.DataHandleUtils
|
||||||
import com.fangjia.script.util.DateUtils
|
import com.fangjia.script.util.DateUtils
|
||||||
import com.fangjia.script.util.MongoUtils
|
import com.fangjia.script.util.MongoUtils
|
||||||
import com.fangjia.script.util.OpenApiClient
|
|
||||||
import com.mongodb.BasicDBObject
|
import com.mongodb.BasicDBObject
|
||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
import com.mongodb.DBObject
|
import com.mongodb.DBObject
|
||||||
import com.rabbitmq.client.AMQP
|
|
||||||
import net.sf.json.JSONObject
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
||||||
import org.bson.types.ObjectId
|
import org.bson.types.ObjectId
|
||||||
|
|
||||||
import java.text.DecimalFormat
|
|
||||||
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.TimeUnit
|
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
import java.util.regex.Matcher
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by gaojuan on 2017/12/11.
|
* Created by gaojuan on 2017/12/11.
|
||||||
* 批量全国小区及商铺字段转换
|
* 批量全国小区及商铺字段转换
|
||||||
@@ -33,7 +26,7 @@ import java.util.regex.Pattern
|
|||||||
class CZDataBatch extends BaseBatch{
|
class CZDataBatch extends BaseBatch{
|
||||||
|
|
||||||
public static def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017";
|
public static def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017";
|
||||||
def fields = ["city","region","name", "address", "cat","lat2","lng2","alias","property_life","estate_type2","build_date","build_structure","build_type","finish_building_date","live_date","open_date","virescence_percent","cubage_percent","estate_company","estate_charge","car_site", "build_type"]
|
def fields = ["city","region","name", "address", "cat","lat2","lng2","lat","lng","alias","property_life","estate_type2","build_date","build_structure","build_type","finish_building_date","live_date","open_date","virescence_percent","cubage_percent","estate_company","estate_charge","car_site", "build_type"]
|
||||||
public static DBCollection DIST_COLL = MongoUtils.getCollectionByName2("business", "jn_bank_district", dbUrl)
|
public static DBCollection DIST_COLL = MongoUtils.getCollectionByName2("business", "jn_bank_district", dbUrl)
|
||||||
|
|
||||||
//final def czIdMap = readCZDistrict("d:\\常州数据结果\\原始数据\\常州江南银行住宅编号.xls");
|
//final def czIdMap = readCZDistrict("d:\\常州数据结果\\原始数据\\常州江南银行住宅编号.xls");
|
||||||
@@ -227,11 +220,14 @@ class CZDataBatch extends BaseBatch{
|
|||||||
map.build_structure = shop.build_structure
|
map.build_structure = shop.build_structure
|
||||||
// 楼盘均价
|
// 楼盘均价
|
||||||
map.avg_price = FzDataUtils.getShopPrice(priceString, shop.city, shop.region, shop.name);
|
map.avg_price = FzDataUtils.getShopPrice(priceString, shop.city, shop.region, shop.name);
|
||||||
|
if(!map.avg_price){
|
||||||
|
map.avg_price = getSellPrice(shop.city, shop.lng/10000000000.0, shop.lat/10000000000.0)
|
||||||
|
}
|
||||||
// 省 市 区
|
// 省 市 区
|
||||||
if(shop.city == "常州"){
|
if(shop.city == "常州"){
|
||||||
map.province_code = regionMap.get("江苏");
|
map.province_code = FzDataUtils.regionMap.get("江苏");
|
||||||
map.city_code = regionMap.get(shop.city);
|
map.city_code = FzDataUtils.regionMap.get(shop.city);
|
||||||
map.region_code = regionMap.get(shop.region);
|
map.region_code = FzDataUtils.regionMap.get(shop.region);
|
||||||
map.province = "江苏";
|
map.province = "江苏";
|
||||||
map.price_old_string = priceString;
|
map.price_old_string = priceString;
|
||||||
map.heights = heights;
|
map.heights = heights;
|
||||||
@@ -259,6 +255,9 @@ class CZDataBatch extends BaseBatch{
|
|||||||
map.street_code = FzDataUtils.getStreetCode(street);
|
map.street_code = FzDataUtils.getStreetCode(street);
|
||||||
// 租金
|
// 租金
|
||||||
map.shop_rent = FzDataUtils.getRentNumber(rentPrice, shop.city, shop.region, shop.name);
|
map.shop_rent = FzDataUtils.getRentNumber(rentPrice, shop.city, shop.region, shop.name);
|
||||||
|
if(!map.shop_rent){
|
||||||
|
map.shop_rent = getRentPrice(shop.city, shop.lng/10000000000.0, shop.lat/10000000000.0)
|
||||||
|
}
|
||||||
// 物业公司
|
// 物业公司
|
||||||
map.estate_company = FzDataUtils.getEstateCompany(shop.estate_company);
|
map.estate_company = FzDataUtils.getEstateCompany(shop.estate_company);
|
||||||
// 物业费(每月每平米)
|
// 物业费(每月每平米)
|
||||||
@@ -267,6 +266,38 @@ class CZDataBatch extends BaseBatch{
|
|||||||
saveShop(map);
|
saveShop(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getSellPrice(def city, def lng, def lat){
|
||||||
|
def p_date = DateUtils.formatDateByPattern(DateUtil.add(new Date(), -365),'yyyy-MM-dd')
|
||||||
|
def rets = CommonDatautils.findSeawater(city, lng, lat, "1km", p_date, "shop_sell")
|
||||||
|
if(rets){
|
||||||
|
def prices = []
|
||||||
|
for(def r : rets){
|
||||||
|
prices << r._source.avg_price
|
||||||
|
}
|
||||||
|
if(prices){
|
||||||
|
def price = (int)(prices.sum()/prices.size())
|
||||||
|
return price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
def getRentPrice(def city, def lng, def lat){
|
||||||
|
def p_date = DateUtils.formatDateByPattern(DateUtil.add(new Date(), -365),'yyyy-MM-dd')
|
||||||
|
def rets = CommonDatautils.findSeawater(city, lng, lat, "1km", p_date, "shop_rent")
|
||||||
|
if(rets){
|
||||||
|
def prices = []
|
||||||
|
for(def r : rets){
|
||||||
|
prices << r._source.avg_price
|
||||||
|
}
|
||||||
|
if(prices){
|
||||||
|
def day_price = (prices.sum()/prices.size())/30
|
||||||
|
return DataHandleUtils.getDoubleRound(2, day_price)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
def saveShop(def m){
|
def saveShop(def m){
|
||||||
DBObject q = new BasicDBObject();
|
DBObject q = new BasicDBObject();
|
||||||
q.put("city",m.city)
|
q.put("city",m.city)
|
||||||
|
|||||||
+1
@@ -809,4 +809,5 @@ class FzDataUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user