+36
-1
@@ -45,7 +45,7 @@ class CcbCommonUtils {
|
||||
|
||||
public static def sqlInstance = null
|
||||
|
||||
public static def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse",
|
||||
public static def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse",
|
||||
"postgres", "postgres", "org.postgresql.Driver")
|
||||
|
||||
|
||||
@@ -454,6 +454,41 @@ class CcbCommonUtils {
|
||||
return rets;
|
||||
}
|
||||
|
||||
|
||||
public static def findAllDistrictByCityAndRegion(def city, def region, def cat, def fields){
|
||||
|
||||
DBObject q = new BasicDBObject();
|
||||
q.put("visible",0)
|
||||
q.put("cat", cat);
|
||||
q.put("city", city);
|
||||
q.put("region", region)
|
||||
// q.put("name","鸣翠蓝湾")
|
||||
// q.put("name_cat", 0);
|
||||
// q.put("estate_type2", new BasicDBObject('$in', ["普通住宅","商住"]))
|
||||
|
||||
DBObject keys = new BasicDBObject();
|
||||
if(fields){
|
||||
for(def field : fields){
|
||||
keys.put(field, 1);
|
||||
}
|
||||
}
|
||||
// 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){
|
||||
if(d.name_cat == 0 && d.lng && ["普通住宅","商住"].contains(d.estate_type2) && !d.name.contains("洋房") && !d.name.contains("公房")){
|
||||
if(d.address){
|
||||
d.address = d.address.replaceAll("\r|\n|\\s", "");
|
||||
}
|
||||
rets << d
|
||||
}
|
||||
}
|
||||
println "小区量:"+rets.size()
|
||||
return rets;
|
||||
}
|
||||
|
||||
|
||||
public static def findDistrict(String city, String region, String name, String cat){
|
||||
|
||||
DBObject q = new BasicDBObject();
|
||||
|
||||
+32
-11
@@ -45,8 +45,8 @@ DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_craw
|
||||
def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017";
|
||||
def DBCollection youda_esfhouse_coll = MongoUtils.getCollectionByName2("business", "res_esfdealprice", offlineUrl)
|
||||
|
||||
def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse",
|
||||
"postgres", "postgres", "org.postgresql.Driver")
|
||||
//def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse",
|
||||
// "postgres", "postgres", "org.postgresql.Driver")
|
||||
|
||||
//def citys = ["山南","黄南州","甘南","克孜勒苏","嘉峪关","海北州","阿拉善盟","怒江州","和田","日喀则","昌都","海南州","玉树州","吐鲁番","阿勒泰","三沙","塔城","甘孜州","果洛州","林芝","那曲","阿坝州","神农架"]
|
||||
//def cityCodeDataMap = CcbCommonUtils.findCityCodeValue()
|
||||
@@ -1172,18 +1172,39 @@ def findThirdCommCount(cityid, sqlInstance){
|
||||
// return map
|
||||
//}
|
||||
|
||||
//
|
||||
//def fileName = "D:\\数据\\建行\\房产估值\\指导价\\无价格小区(3)2.23.xlsx"
|
||||
//ExcelUtils.multiThreadingModify(fileName, { d ->
|
||||
// def dist = CommonDatautils.findDistrictById(d['A'])
|
||||
// if(dist){
|
||||
// d['G'] = dist.city
|
||||
// d['H'] = dist.region
|
||||
// d['I'] = dist.name
|
||||
// }
|
||||
//})
|
||||
|
||||
def fileName = "D:\\数据\\建行\\房产估值\\指导价\\无价格小区(3)2.23.xlsx"
|
||||
ExcelUtils.multiThreadingModify(fileName, { d ->
|
||||
def dist = CommonDatautils.findDistrictById(d['A'])
|
||||
if(dist){
|
||||
d['G'] = dist.city
|
||||
d['H'] = dist.region
|
||||
d['I'] = dist.name
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
//def findAvgPrice(def commid, def pgsqlInstance, def cityid){
|
||||
// def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1"
|
||||
// def map = [:]
|
||||
// pgsqlInstance.eachRow(sql, { r ->
|
||||
// map.avg_price = r.gujia_bds_clc_avprc
|
||||
// map.type = r.gujia_bds_clmtd
|
||||
// map.month = r.gujiabds_clc_yrmo_val
|
||||
// if(r.gujia_bds_clmtd == 1){
|
||||
// map.calc_type = "人工估值"
|
||||
// }else if(r.gujia_bds_clmtd == 2){
|
||||
// map.calc_type = "样本计算"
|
||||
// }else if(r.gujia_bds_clmtd == 3){
|
||||
// map.calc_type = "神经网络"
|
||||
// }
|
||||
// })
|
||||
// return map
|
||||
//}
|
||||
|
||||
//def file = "C:\\Users\\gaojuan\\Desktop\\国信达小区.xlsx"
|
||||
//def cityCodeMap = CcbCommonUtils.findCityCodeValue()
|
||||
//ExcelUtils.multiThreadingModify(file, { d ->
|
||||
|
||||
+26
-25
@@ -178,9 +178,9 @@ class ExportPgsqlEvaluationResult {
|
||||
});
|
||||
}
|
||||
|
||||
def fileName = linux_prefix + "MODEL_000000_000000_CITY_PRICE_GJ_ALL_${curDate}_0001.dat"
|
||||
def fileName = linux_prefix + "MODEL_000000_000000_CITY_PRICE_GJ_ADD_${curDate}_0001.dat"
|
||||
if(CommonDatautils.isWindow()){
|
||||
fileName = win_prefix + "MODEL_000000_000000_CITY_PRICE_GJ_ALL_${curDate}_0001.dat"
|
||||
fileName = win_prefix + "MODEL_000000_000000_CITY_PRICE_GJ_ADD_${curDate}_0001.dat"
|
||||
}
|
||||
createFileToFtp("CITY_PRICE_GJ",allRows, fileName, curDate, false)
|
||||
}
|
||||
@@ -207,9 +207,9 @@ class ExportPgsqlEvaluationResult {
|
||||
allRows << data
|
||||
});
|
||||
}
|
||||
def fileName = linux_prefix + "MODEL_000000_000000_DISTRICT_PRICE_GJ_ALL_${curDate}_0001.dat"
|
||||
def fileName = linux_prefix + "MODEL_000000_000000_DISTRICT_PRICE_GJ_ADD_${curDate}_0001.dat"
|
||||
if(CommonDatautils.isWindow()){
|
||||
fileName = win_prefix + "MODEL_000000_000000_DISTRICT_PRICE_GJ_ALL_${curDate}_0001.dat"
|
||||
fileName = win_prefix + "MODEL_000000_000000_DISTRICT_PRICE_GJ_ADD_${curDate}_0001.dat"
|
||||
}
|
||||
|
||||
createFileToFtp("DISTRICT_PRICE_GJ",allRows, fileName, curDate, false)
|
||||
@@ -369,27 +369,28 @@ class ExportPgsqlEvaluationResult {
|
||||
if(CommonDatautils.isWindow()){
|
||||
fileName = win_prefix + "MODEL_000000_000000_COMM_CASE_DETAIL_GJ_ADD_${curDate}_0001.dat"
|
||||
}
|
||||
for(def city : citys){
|
||||
def cityCode = cityCodeMap.get(city)
|
||||
def sql = "select gujia_fsid, urbn_id, gujia_comm_id, gujia_case_id,gujia_bds_crterm,to_char(data_crt_tm,'yyyy-mm-dd') as data_crt_tm from "+database+"avm_comm_case_detail_gj_h where urbn_id='${cityCode}' and gujia_bds_crterm=${month}";
|
||||
def allRows = []
|
||||
pgsqlInstance.eachRow(sql,{r->
|
||||
def data = []
|
||||
data << r.gujia_fsid
|
||||
data << r.urbn_id
|
||||
data << r.gujia_comm_id
|
||||
data << r.gujia_case_id
|
||||
data << r.gujia_bds_crterm
|
||||
data << r.data_crt_tm
|
||||
allRows << data
|
||||
// if(allRows.size()%200000==0){
|
||||
// FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", true);
|
||||
// allRows.clear()
|
||||
// }
|
||||
});
|
||||
|
||||
FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", false);
|
||||
}
|
||||
// for(def city : citys){
|
||||
// def cityCode = cityCodeMap.get(city)
|
||||
// def sql = "select gujia_fsid, urbn_id, gujia_comm_id, gujia_case_id,gujia_bds_crterm,to_char(data_crt_tm,'yyyy-mm-dd') as data_crt_tm from "+database+"avm_comm_case_detail_gj_h where urbn_id='${cityCode}' and gujia_bds_crterm=${month}";
|
||||
// def allRows = []
|
||||
// pgsqlInstance.eachRow(sql,{r->
|
||||
// def data = []
|
||||
// data << r.gujia_fsid
|
||||
// data << r.urbn_id
|
||||
// data << r.gujia_comm_id
|
||||
// data << r.gujia_case_id
|
||||
// data << r.gujia_bds_crterm
|
||||
// data << r.data_crt_tm
|
||||
// allRows << data
|
||||
//// if(allRows.size()%200000==0){
|
||||
//// FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", true);
|
||||
//// allRows.clear()
|
||||
//// }
|
||||
// });
|
||||
//
|
||||
// FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", false);
|
||||
// }
|
||||
FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", false);
|
||||
CcbFtpTestUtils.ftpUpload(null, fileName, curDate)
|
||||
}
|
||||
|
||||
|
||||
+27
@@ -988,6 +988,33 @@ class CommonDatautils {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static def findDistrictByParams(String city, String region, String name, String cat, List fields){
|
||||
DBObject q = new BasicDBObject();
|
||||
q.put("city", city);
|
||||
q.put("cat", cat);
|
||||
q.put("region", region)
|
||||
q.put("name", name);
|
||||
q.put("status", 0)
|
||||
|
||||
DBObject keys = new BasicDBObject();
|
||||
if(fields){
|
||||
for(def field : fields){
|
||||
keys.put(field, 1);
|
||||
}
|
||||
}
|
||||
|
||||
DSCursor cursor = getDataStoreConnection().find(q, keys);
|
||||
def dataObj = null
|
||||
if(cursor){
|
||||
for(def obj : cursor){
|
||||
dataObj = obj
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return dataObj;
|
||||
}
|
||||
|
||||
public static def findAllStatusDistrict(String city, String region, String name, String cat, List fields){
|
||||
|
||||
DBObject q = new BasicDBObject();
|
||||
|
||||
+25
-1
@@ -1,8 +1,10 @@
|
||||
package com.fangjia.script.gj
|
||||
|
||||
import com.fangjia.core.RegionData
|
||||
import com.fangjia.script.ccbevaluation.CcbCommonUtils
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.common.DataHandleUtils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
@@ -24,8 +26,21 @@ class CityStatExport {
|
||||
|
||||
static main(args) {
|
||||
def task = new CityStatExport();
|
||||
task.run()
|
||||
// task.run()
|
||||
// task.run1()
|
||||
// task.regionStat()
|
||||
task.stat()
|
||||
}
|
||||
|
||||
def stat(){
|
||||
def fileName = "C:\\Users\\gaojuan\\Desktop\\江苏城市字段信息统计_交付.xlsx"
|
||||
ExcelUtils.multiThreadingModify(fileName, { d ->
|
||||
println d['A'] + " "+ d['B']
|
||||
def rets = CcbCommonUtils.findAllDistrictByCityAndRegion(d['A'], d['B'],"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","street","street_number"])
|
||||
if(rets){
|
||||
d['H'] = rets.size()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
def run(){
|
||||
@@ -80,6 +95,15 @@ class CityStatExport {
|
||||
|
||||
}
|
||||
|
||||
def regionStat(){
|
||||
def city = "无锡"
|
||||
def regions = CommonDatautils.getRegionListByCity(city)
|
||||
for(def r : regions){
|
||||
def districts = CommonDatautils.findDistricts(city, r, null)
|
||||
println r +" "+ districts.size()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def findHouseCount(def city, def startDate){
|
||||
def total = 0
|
||||
|
||||
+3
-751
@@ -32,9 +32,9 @@ import java.util.regex.Pattern
|
||||
@BatchOwner(Watcher.GaoJuan)
|
||||
class CZDataBatch extends BaseBatch{
|
||||
|
||||
def regionMap = ["江苏":"320000","常州":"320400","天宁":"320402","钟楼":"320404","戚墅堰":"320405","新北":"320411","武进":"320412","溧阳":"320481","金坛":"320482"];
|
||||
|
||||
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"]
|
||||
DBCollection DIST_COLL = MongoUtils.getCollectionByName("business", "jn_bank_district", "mongo.db.fangjia.com")
|
||||
|
||||
//final def czIdMap = readCZDistrict("d:\\常州数据结果\\原始数据\\常州江南银行住宅编号.xls");
|
||||
//final def czShopMap = readCZShop("d:\\常州数据结果\\原始数据\\常州江南银行商铺--更新ing(8).xls");
|
||||
|
||||
@@ -134,7 +134,7 @@ class CZDataBatch extends BaseBatch{
|
||||
void run() {
|
||||
try{
|
||||
totalCount.addAndGet(1)
|
||||
converDistrict(district, statMap, commids);
|
||||
FzDataUtils.converDistrict(district, statMap, commids);
|
||||
println totalCount.get()+"/"+total +" ["+district.city+"-"+district.region+"-"+district.name+"]";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace()
|
||||
@@ -165,92 +165,6 @@ class CZDataBatch extends BaseBatch{
|
||||
// executorService.awaitTermination(30, TimeUnit.MINUTES)
|
||||
}
|
||||
|
||||
def converDistrict(def dist, def statMap, def commids){
|
||||
def map = [:]
|
||||
//楼盘编号
|
||||
/* def c_id = czIdMap.get(dist.city+"#"+dist.region+"#"+dist.name)
|
||||
if(c_id){
|
||||
map.num_id = c_id;
|
||||
}else{
|
||||
map.num_id = dist.get("_id").toString();
|
||||
} */
|
||||
map.num_id = dist.get("_id").toString();
|
||||
map.cat = "district";
|
||||
// 楼盘名称
|
||||
map.name = dist.name
|
||||
map.alias = dist.alias
|
||||
map.build_date = getBuildDate(dist);
|
||||
//附属属性
|
||||
map.build_type = dist.build_type
|
||||
map.property_life = dist.property_life
|
||||
map.estate_type2 = dist.estate_type2
|
||||
map.build_structure = dist.build_structure
|
||||
// 楼盘均价
|
||||
def priceObj = statMap.get(dist.region+"#"+dist.name)
|
||||
if(priceObj && priceObj.avg_price){
|
||||
map.avg_price = priceObj.avg_price
|
||||
}
|
||||
//map.avg_price = getDistrictPrice(dist.city, dist.region, dist.name, dist.address, dist.block);
|
||||
// 省 市 区
|
||||
if(dist.city == "常州"){
|
||||
map.province_code = regionMap.get("江苏");
|
||||
map.city_code = regionMap.get(dist.city);
|
||||
map.region_code = regionMap.get(dist.region);
|
||||
map.province = "江苏";
|
||||
}
|
||||
map.city = dist.city;
|
||||
map.region = dist.region;
|
||||
|
||||
if(!commids.contains(map.num_id)){
|
||||
// 公共服务配套
|
||||
map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 基础设施
|
||||
map.facilities_code = "01";
|
||||
// 居住社区成熟度
|
||||
map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 交通条件
|
||||
map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 泊车条件 /
|
||||
map.stop_car_code = getStopCarCode(dist);
|
||||
// /学区房类型
|
||||
map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ;
|
||||
}
|
||||
// 地址
|
||||
map.address = dist.address
|
||||
// 所属区域
|
||||
map.in_region_code = getRegionCode(dist.region);
|
||||
|
||||
//绿化率
|
||||
map.virescence_percent = getVirescencePercent(dist.virescence_percent, map.build_date);
|
||||
//容积率
|
||||
map.cubage_percent = getCubagePercent(dist.cubage_percent, map.build_date);
|
||||
// 参考租金(1室) 参考租金(2室) 参考租金(3室) 参考租金(4室) 参考租金(5室) 参考租金(5室以上)
|
||||
map.rents = getRentPrice2(dist.city, dist.region, dist.name, dist.estate_type2, dist.lat2, dist.lng2, dist.cat);
|
||||
//物业公司
|
||||
map.estate_company = getEstateCompany(dist.estate_company);
|
||||
//物业费
|
||||
map.estate_charge = getEstateCharge(dist.estate_charge);
|
||||
|
||||
saveDistrict(map);
|
||||
}
|
||||
|
||||
|
||||
def saveDistrict(def m){
|
||||
DBObject q = new BasicDBObject();
|
||||
q.put("num_id",m.num_id)
|
||||
def dbo = DIST_COLL.findOne(q);
|
||||
|
||||
DBObject udata = new BasicDBObject();
|
||||
m.each {k,v->
|
||||
udata.put(k, v);
|
||||
}
|
||||
if(dbo){
|
||||
udata.removeField("num_id")
|
||||
DIST_COLL.update(q, new BasicDBObject('$set', udata), false, true);
|
||||
}else{
|
||||
DIST_COLL.save(udata);
|
||||
}
|
||||
}
|
||||
|
||||
def shopRun(shops){
|
||||
|
||||
@@ -444,668 +358,6 @@ class CZDataBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
|
||||
//1-主城区:天宁区、钟楼区 2-郊区:武进区、新北区、戚墅堰区 3-县级市:金坛市、溧阳市
|
||||
def getRegionCode(def region){
|
||||
if(region.indexOf("天宁")!=-1||region.indexOf("钟楼")!=-1){
|
||||
return "01";
|
||||
}else if(region.indexOf("武进")!=-1||region.indexOf("新北")!=-1||region.indexOf("戚墅堰")!=-1){
|
||||
return "02";
|
||||
}else if(region.indexOf("金坛")!=-1||region.indexOf("溧阳")!=-1){
|
||||
return "03";
|
||||
}else{
|
||||
return "99";
|
||||
}
|
||||
}
|
||||
|
||||
def getVirescencePercent(def virescence_percent, def buildDate){
|
||||
if(virescence_percent){
|
||||
virescence_percent = virescence_percent.replace("%","");
|
||||
}
|
||||
|
||||
if(virescence_percent){
|
||||
if(virescence_percent.toFloat()>50){
|
||||
virescence_percent = "";
|
||||
}
|
||||
}
|
||||
|
||||
if(!virescence_percent && buildDate){
|
||||
if(buildDate==1986){
|
||||
virescence_percent = 25;
|
||||
}else if(buildDate == 1987){
|
||||
virescence_percent = 30;
|
||||
}else if(buildDate>=1990 && buildDate<=2009){
|
||||
virescence_percent = 25;
|
||||
}else if(buildDate == 2010){
|
||||
virescence_percent = 30;
|
||||
}
|
||||
}
|
||||
|
||||
if(virescence_percent){
|
||||
virescence_percent = virescence_percent.toDouble()/100;
|
||||
return new DecimalFormat("######0.00").format(virescence_percent)
|
||||
}
|
||||
|
||||
return virescence_percent;
|
||||
}
|
||||
|
||||
|
||||
def getCubagePercent(def cubage_percent, def build_date){
|
||||
if(!cubage_percent && build_date){
|
||||
if(build_date >=1990 && build_date<=1999){
|
||||
return "1.49";
|
||||
}else if(build_date==2000){
|
||||
return "1.46";
|
||||
}
|
||||
}
|
||||
return cubage_percent;
|
||||
}
|
||||
|
||||
def getBuildDate(def dbo){
|
||||
def year = DataHandleUtils.findPattern(dbo.finish_building_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.live_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
if(!year){
|
||||
def date = DateUtils.formatToYYYYMMDD(dbo.open_date)
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dbo.build_date){
|
||||
year = DataHandleUtils.findPattern(dbo.build_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year && year>1900){
|
||||
return year;
|
||||
}
|
||||
}
|
||||
return year;
|
||||
}
|
||||
|
||||
def getEstateCompany(def company){
|
||||
if(company){
|
||||
company = company.replace("---","").replace("·","");
|
||||
return company;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
def getEstateCharge(def charge){
|
||||
if(charge){
|
||||
if(charge == "0.0"){
|
||||
return "";
|
||||
}else{
|
||||
Pattern pa=Pattern.compile("([\\d\\.]+)")
|
||||
Matcher ma=pa.matcher(charge)
|
||||
if(ma.find()){
|
||||
charge = ma.group(1)
|
||||
|
||||
if(charge.toFloat()>=40){
|
||||
return "";
|
||||
}else{
|
||||
if(charge.endsWith(".0")){
|
||||
return charge.substring(0, charge.indexOf(".0"))
|
||||
}else{
|
||||
return charge;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
def getRentPrice2(def city, def region, def name, def estate_type2, def lat2, def lng2, def cat){
|
||||
def month = CommonDatautils.getDistrictRentLastMonth(city, region, name)
|
||||
|
||||
def priceMap = [:];
|
||||
if(month){
|
||||
priceMap = CommonDatautils.getDistrictRentPrice(city, region, name, month);
|
||||
}
|
||||
|
||||
|
||||
if(!priceMap){
|
||||
priceMap = getRoundAvgRentPrice(city,region, name, estate_type2, lat2, lng2, cat);
|
||||
}
|
||||
|
||||
|
||||
if(priceMap && priceMap.size()>1){
|
||||
|
||||
def prices = []
|
||||
def rooms = [];
|
||||
for(int i=1;i<=6;i++){
|
||||
def price = priceMap.get(i);
|
||||
if(price){
|
||||
if(price>20000||price<300){
|
||||
priceMap.remove(i);
|
||||
}else{
|
||||
|
||||
if(i>3 && price<1000){
|
||||
priceMap.remove(i);
|
||||
}else{
|
||||
prices << price
|
||||
rooms << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//排序
|
||||
prices.sort();
|
||||
rooms.sort();
|
||||
if(prices.size()>1){
|
||||
priceMap = [:];
|
||||
def index = 0;
|
||||
for(def price : prices){
|
||||
index++;
|
||||
priceMap.put(rooms.get(index-1), price);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filterData(prices, rooms, priceMap);
|
||||
}
|
||||
|
||||
|
||||
if(priceMap && estate_type2.contains("别墅")){
|
||||
priceMap.remove(1);
|
||||
priceMap.remove(2);
|
||||
|
||||
if(priceMap.get(4)<2000){
|
||||
priceMap.remove(4);
|
||||
}
|
||||
|
||||
if(priceMap.get(3)<2000){
|
||||
priceMap.remove(3);
|
||||
}
|
||||
}
|
||||
|
||||
// if(!priceMap){
|
||||
// priceMap = findRegionRentPrice(priceMap, city, region, estate_type2)
|
||||
// }
|
||||
|
||||
//5室及以上价格小于2000去除
|
||||
if(priceMap){
|
||||
if(priceMap.get(5)<2000){
|
||||
priceMap.remove(5);
|
||||
}
|
||||
|
||||
if(priceMap.get(6)<3000){
|
||||
priceMap.remove(6);
|
||||
}
|
||||
}
|
||||
def newPriceMap = [:]
|
||||
if(priceMap){
|
||||
priceMap.each {k,v->
|
||||
newPriceMap.put(k.toString(),v)
|
||||
}
|
||||
}
|
||||
return newPriceMap;
|
||||
}
|
||||
|
||||
def findRegionRentPrice(def priceMap,def city, def region, def estate_type2){
|
||||
if(!priceMap){
|
||||
priceMap = [:]
|
||||
if(estate_type2=="别墅"){
|
||||
def room4 = CommonDatautils.getRegionRent(city, region, 4, "别墅");
|
||||
if(room4){
|
||||
def v = DataHandleUtils.random(-100, 500) + 100;
|
||||
priceMap.put(4, room4+v);
|
||||
|
||||
}
|
||||
}else{
|
||||
def room1 = CommonDatautils.getRegionRent(city, region, 1, "小区");
|
||||
def room2 = CommonDatautils.getRegionRent(city, region, 2, "小区");
|
||||
if(room1){
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
priceMap.put(1, room1+v);
|
||||
}
|
||||
|
||||
if(room2){
|
||||
def v = DataHandleUtils.random(-100, 600) + 100;
|
||||
priceMap.put(2, room2+v);
|
||||
}
|
||||
}
|
||||
}
|
||||
return priceMap;
|
||||
}
|
||||
|
||||
|
||||
def getRoundAvgRentPrice(city,region, name, estate_type2, lat2, lng2, cat ){
|
||||
if(lng2 && lat2){
|
||||
def lat = lat2/10000000000;
|
||||
def lng = lng2/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def ret = CommonDatautils.findDistrictsByLatLng(city, cat, map.maxLat*10000000000, map.minLat*10000000000, map.maxLng*10000000000, map.minLng*10000000000, estate_type2);
|
||||
if(ret){
|
||||
def room1_sum = 0;
|
||||
def room1_count = 0;
|
||||
def room2_sum = 0;
|
||||
def room2_count = 0;
|
||||
for(def obj : ret){
|
||||
def rentMap = CommonDatautils.getDistrictPrice(city, region, name, estate_type2)
|
||||
if(rentMap){
|
||||
if(rentMap.get(1)){
|
||||
room1_sum = room1_sum + rentMap.get(1);
|
||||
room1_count ++;
|
||||
}
|
||||
|
||||
if(rentMap.get(2)){
|
||||
room2_sum = room2_sum + rentMap.get(2);
|
||||
room2_count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
def result = [:];
|
||||
if(room1_count){
|
||||
def room1_avg_price = (room1_sum/room1_count).toInteger();
|
||||
if(room1_avg_price){
|
||||
result.put(1, room1_avg_price);
|
||||
}
|
||||
}
|
||||
if(room2_count){
|
||||
def room2_avg_price = (room2_sum/room2_count).toInteger();
|
||||
if(room2_avg_price){
|
||||
result.put(2, room2_avg_price);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
def static filterData(prices, rooms, priceMap){
|
||||
def mod = [];
|
||||
for(int j=1;j<prices.size();j++){
|
||||
def start = prices[j-1];
|
||||
def end = prices[j];
|
||||
def val = (end-start)/start;
|
||||
if(val>=1){
|
||||
def room = rooms.get(j);
|
||||
def price = prices.get(j)
|
||||
priceMap.remove(room);
|
||||
prices.remove(j);
|
||||
}
|
||||
mod << val;
|
||||
}
|
||||
println "mod:"+ mod;
|
||||
return priceMap;
|
||||
}
|
||||
|
||||
|
||||
//1-周边公交线路≥10条;2-周边公交线路<10条但≥5条;3-周边公交线路<5条但≥2条;4-周边公交线路<2条
|
||||
def getTrafficCode(def city, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def trafficMap = CommonDatautils.findBusLineCount(city, map.maxLat, map.minLat, map.maxLng, map.minLng);
|
||||
|
||||
def count = 0;
|
||||
if(trafficMap){
|
||||
count = trafficMap.bus.size()
|
||||
}
|
||||
|
||||
if(count>=10){
|
||||
return "01";
|
||||
}else if(count>=5){
|
||||
return "02";
|
||||
}else if(count>=2){
|
||||
return "03";
|
||||
}else if(count < 2){
|
||||
return "04";
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
|
||||
def getStopCarCode(def dbo){
|
||||
if(dbo.car_site){
|
||||
if(dbo.car_site=="<br />"||dbo.car_site=="待定"||dbo.car_site.indexOf("暂无")!=-1||dbo.car_site=="详询售楼处"){
|
||||
dbo.car_site ="";
|
||||
}
|
||||
|
||||
if(dbo.car_site){
|
||||
return "01";
|
||||
}
|
||||
}
|
||||
|
||||
if(!dbo.car_site){
|
||||
def year = DataHandleUtils.findPattern(dbo.build_date, "(\\d+)");
|
||||
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.finish_building_date, "(\\d+)");
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.live_date, "(\\d+)");
|
||||
if(!year){
|
||||
def date = DateUtils.formatToYYYYMMDD(dbo.open_date)
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
|
||||
if(year && year >= 1980){
|
||||
return "01";
|
||||
}else if(year && year>0 && year<1980){
|
||||
return "02";
|
||||
}else{
|
||||
if(dbo.name.endsWith("期")||dbo.name.indexOf("别墅")!=-1){
|
||||
return "01";
|
||||
}else{
|
||||
|
||||
if(dbo.build_type && dbo.build_type.indexOf("高层")!=-1){
|
||||
return "01";
|
||||
}else if(dbo.estate_type2 && dbo.estate_type2=="别墅"){
|
||||
return "01";
|
||||
}else{
|
||||
|
||||
def date = CommonDatautils.findHouseBuildDate(dbo.city, dbo.region, dbo.name, "sell")
|
||||
if(date){
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
if(year && year >= 1980){
|
||||
return "01";
|
||||
}else if(year && year>0 && year<1980){
|
||||
return "02";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "99"
|
||||
}
|
||||
|
||||
def endWithChar = ["村","宿舍","堂","弄"];
|
||||
for(def s : endWithChar){
|
||||
if(dbo.name.endsWith(s)){
|
||||
return "02";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "01";
|
||||
}
|
||||
|
||||
|
||||
def getSchoolCode(def city, def region, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def redius = 3000;
|
||||
if(city=="常州" && (region=="天宁"|| region=="钟楼")){
|
||||
redius = 1000;
|
||||
}
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, redius)
|
||||
def schools = CommonDatautils.findPomDetail(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def school_count = 0;
|
||||
if(schools){
|
||||
def names = [];
|
||||
for(def schoolName : schools){
|
||||
if(schoolName.contains("小学") && !names.contains(schoolName)){
|
||||
names << schoolName
|
||||
}
|
||||
}
|
||||
|
||||
school_count = names.size();
|
||||
}
|
||||
|
||||
if(school_count >= 1){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
def getSophisticationCode(def city, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
if(supermarket_count>=5){
|
||||
return "01";
|
||||
}else{
|
||||
map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 2000)
|
||||
supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
if(supermarket_count >= 5){
|
||||
return "02";
|
||||
}else{
|
||||
return "03";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
|
||||
def getPublicServiceSetCode(def city, def lat, def lng){
|
||||
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def hspt_count = CommonDatautils.findPomCount(city, "医院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def bank_count = CommonDatautils.findPomCount(city, "银行", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def school_count = CommonDatautils.findPomCount(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
def yl_count1 = CommonDatautils.findPomCount(city, "KTV", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count2 = CommonDatautils.findPomCount(city, "电影院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count3 = CommonDatautils.findPomCount(city, "网吧", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count4 = CommonDatautils.findPomCount(city, "健身中心", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
if(hspt_count>=1 && bank_count>=1 && school_count>=1 && supermarket_count>=1 && (yl_count1>=1 || yl_count2>=1 || yl_count3>=1||yl_count4>=1)){
|
||||
return "01";
|
||||
}else{
|
||||
map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 2000)
|
||||
hspt_count = CommonDatautils.findPomCount(city, "医院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
bank_count = CommonDatautils.findPomCount(city, "银行", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
school_count = CommonDatautils.findPomCount(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
yl_count1 = CommonDatautils.findPomCount(city, "KTV", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count2 = CommonDatautils.findPomCount(city, "电影院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count3 = CommonDatautils.findPomCount(city, "网吧", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count4 = CommonDatautils.findPomCount(city, "健身中心", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
if(hspt_count>=1 && bank_count>=1 && school_count>=1 && supermarket_count>=1 && (yl_count1>=1 || yl_count2>=1 || yl_count3>=1||yl_count4>=1)){
|
||||
return "02";
|
||||
}else{
|
||||
return "03";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
def getDistrictPrice(def city, def region, def name, def address, def block){
|
||||
|
||||
def price = CommonDatautils.findDistrictPrice(city, region, name);
|
||||
if(price){
|
||||
return price.avg_price;
|
||||
}else{
|
||||
// //样例估价
|
||||
// def s = OpenApiClient.evaluateDistrictPriceBySimilarHouse3(city, region, name, 100, false);
|
||||
// try{
|
||||
// JSONObject jsonObject = JSONObject.fromObject(s);
|
||||
// def map = DataHandleUtils.JsonToMap(jsonObject);
|
||||
// if(map.code==200){
|
||||
// if(map.result){
|
||||
// return map.result.avgPrice;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }catch(Exception e){
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
//分期找总期
|
||||
if(name.toString().endsWith("期")){
|
||||
def tempname = name.toString().substring(0, name.toString().indexOf("期")-1)
|
||||
def districtStat = CommonDatautils.findDistrictPrice(city, region, tempname);
|
||||
if(districtStat && districtStat.avg_price){
|
||||
return districtStat.avg_price+150;
|
||||
}
|
||||
}
|
||||
|
||||
if(name.toString().endsWith("区")){
|
||||
def tempname = name.toString().substring(0, name.toString().indexOf("区")-1)
|
||||
def districtStat = CommonDatautils.findDistrictPrice(city, region, tempname);
|
||||
if(districtStat && districtStat.avg_price){
|
||||
return districtStat.avg_price+100;
|
||||
}
|
||||
}
|
||||
|
||||
//周边均价
|
||||
// price = findAroundAvgPrice(city, address, 100);
|
||||
// if(price){
|
||||
// return price.toString()
|
||||
// }
|
||||
|
||||
//板块均价
|
||||
if(block){
|
||||
price = CommonDatautils.queryCityRegionPrice(city, region, block);
|
||||
if(price){
|
||||
return price.toInteger()
|
||||
}
|
||||
}
|
||||
|
||||
//区域均价
|
||||
if(!block||!price){
|
||||
price = CommonDatautils.queryCityRegionPrice(city, region, null);
|
||||
if(price){
|
||||
return price.toInteger()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
def getShopPrice(def priceString, def city, def region, def name){
|
||||
|
||||
if(priceString){
|
||||
def avgPrice = priceString.replace("元/㎡","").replace("房源价", "").replace("房源", "");
|
||||
if(avgPrice.indexOf("-")!=-1){
|
||||
def array = avgPrice.split("-")
|
||||
if(array.length>1){
|
||||
avgPrice = ((array[1].toInteger()+array[0].toInteger())/2).toInteger();
|
||||
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toInteger()+v;
|
||||
}
|
||||
}else{
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toDouble().toInteger()+v;
|
||||
}
|
||||
}else{
|
||||
def avgPrice = CommonDatautils.queryShopPrice(city, region, name);
|
||||
if(avgPrice){
|
||||
return avgPrice;
|
||||
}
|
||||
}
|
||||
|
||||
def avgPrice = CommonDatautils.queryRegionBusinessPrice(city, region);
|
||||
if(avgPrice){
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toInteger()+v;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
def getRentNumber(def rentPrice,def city, def region, def name){
|
||||
if(rentPrice){
|
||||
if(rentPrice.indexOf("元/㎡/天")!=-1){
|
||||
rentPrice = rentPrice.replace("元/㎡/天","");
|
||||
if(rentPrice){
|
||||
return rentPrice.toDouble();
|
||||
}
|
||||
}else if(rentPrice.indexOf("元/㎡/月")!=-1){
|
||||
def price = rentPrice.replace("元/㎡/月","").toString().trim();
|
||||
price = price.toFloat();
|
||||
price = price/30;
|
||||
return DataHandleUtils.getDoubleRound(2, price.toDouble());
|
||||
}else{
|
||||
if(rentPrice.contains("-")){
|
||||
rentPrice = rentPrice.substring(0, rentPrice.indexOf("-"));
|
||||
}
|
||||
return DataHandleUtils.getDoubleRound(2, rentPrice.toDouble());
|
||||
}
|
||||
}else{
|
||||
def day_avg_price = CommonDatautils.queryBusinessDayPrice(city, region, name, "商铺");
|
||||
if(day_avg_price){
|
||||
return day_avg_price;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
def getStreetCode(def val){
|
||||
if(val){
|
||||
if(val == "无交通管制"){
|
||||
return 1;
|
||||
}else if(val == "单行道"){
|
||||
return 2;
|
||||
}else if(val == "禁行"){
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
def getShopEstateTypeCode(def estateType){
|
||||
if(estateType){
|
||||
if(estateType.indexOf("商场商铺")!=-1){
|
||||
return 1;
|
||||
}else if(estateType.indexOf("专业市场")!=-1){
|
||||
return 2;
|
||||
}else if(estateType.indexOf("商业街")!=-1){
|
||||
return 3;
|
||||
}else if(estateType.indexOf("社区商铺")!=-1){
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return 99;
|
||||
}
|
||||
|
||||
def converList(def dbCursor){
|
||||
def list = []
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.fangjia.script.jiangnanblank
|
||||
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import org.bson.types.ObjectId
|
||||
|
||||
@BatchOwner(Watcher.GaoJuan)
|
||||
class DayUpdateDistRefreshBatch extends BaseBatch{
|
||||
|
||||
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"]
|
||||
|
||||
public static final DBCollection TASK_COLL = MongoUtils.getCollectionByName("fangjia", "district_update_task", "mongo.db.fangjia.com")
|
||||
|
||||
static main(args) {
|
||||
runBatch(new DayUpdateDistRefreshBatch(), args);
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(Object args) {
|
||||
def dists = findAllNeedRefreshDist()
|
||||
|
||||
if(dists){
|
||||
for(def d : dists){
|
||||
def distObj = CommonDatautils.findDistrictByParams(d.city, d.region, d.name, "district", fields)
|
||||
if(distObj._id){
|
||||
FzDataUtils.converDistrict(distObj, null, null);
|
||||
println new Date().toString()+" ¡¾´¦ÀíÍê³É¡¿ "+d.city +" "+d.region+" "+d.name
|
||||
updateTaskStatus(d.id, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
def updateTaskStatus(def id, def status){
|
||||
DBObject q = new BasicDBObject()
|
||||
q.put("_id", new ObjectId(id))
|
||||
|
||||
DBObject udata = new BasicDBObject()
|
||||
udata.put("status", status);
|
||||
udata.put("m_date", new Date());
|
||||
TASK_COLL.update(q, new BasicDBObject('$set', udata));
|
||||
}
|
||||
|
||||
def findAllNeedRefreshDist(){
|
||||
def rets = []
|
||||
def q = new BasicDBObject()
|
||||
q.put("status", 5);//δ´¦Àí
|
||||
TASK_COLL.find(q).each {d->
|
||||
rets << ["id":d._id.toString(),"city":d.city, "region":d.region, "name":d.name]
|
||||
}
|
||||
return rets;
|
||||
}
|
||||
|
||||
def converList(def dbCursor){
|
||||
def list = []
|
||||
for(def dbo : dbCursor){
|
||||
list << dbo
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+781
@@ -0,0 +1,781 @@
|
||||
package com.fangjia.script.jiangnanblank
|
||||
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.common.DataHandleUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
|
||||
import java.text.DecimalFormat
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class FzDataUtils {
|
||||
|
||||
static def regionMap = ["江苏":"320000","常州":"320400","天宁":"320402","钟楼":"320404","戚墅堰":"320405","新北":"320411","武进":"320412","溧阳":"320481","金坛":"320482"];
|
||||
|
||||
static DBCollection DIST_COLL = MongoUtils.getCollectionByName("business", "jn_bank_district", "mongo.db.fangjia.com")
|
||||
|
||||
static def converDistrict(def dist, def statMap, def commids){
|
||||
def map = [:]
|
||||
//楼盘编号
|
||||
/* def c_id = czIdMap.get(dist.city+"#"+dist.region+"#"+dist.name)
|
||||
if(c_id){
|
||||
map.num_id = c_id;
|
||||
}else{
|
||||
map.num_id = dist.get("_id").toString();
|
||||
} */
|
||||
map.num_id = dist.get("_id").toString();
|
||||
map.cat = "district";
|
||||
// 楼盘名称
|
||||
map.name = dist.name
|
||||
map.alias = dist.alias
|
||||
map.build_date = getBuildDate(dist);
|
||||
//附属属性
|
||||
map.build_type = dist.build_type
|
||||
map.property_life = dist.property_life
|
||||
map.estate_type2 = dist.estate_type2
|
||||
map.build_structure = dist.build_structure
|
||||
// 楼盘均价
|
||||
def priceObj = null
|
||||
if(statMap){
|
||||
priceObj = statMap.get(dist.region+"#"+dist.name)
|
||||
}
|
||||
if(priceObj && priceObj.avg_price){
|
||||
map.avg_price = priceObj.avg_price
|
||||
}else{
|
||||
priceObj = CommonDatautils.findDistrictPrice(dist.city, dist.region, dist.name);
|
||||
if(priceObj){
|
||||
map.avg_price = priceObj.avg_price
|
||||
}
|
||||
}
|
||||
|
||||
// 省 市 区
|
||||
if(dist.city == "常州"){
|
||||
map.province_code = regionMap.get("江苏");
|
||||
map.city_code = regionMap.get(dist.city);
|
||||
map.region_code = regionMap.get(dist.region);
|
||||
map.province = "江苏";
|
||||
}
|
||||
map.city = dist.city;
|
||||
map.region = dist.region;
|
||||
|
||||
if((commids && !commids.contains(map.num_id)) || !commids){
|
||||
// 公共服务配套
|
||||
map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 基础设施
|
||||
map.facilities_code = "01";
|
||||
// 居住社区成熟度
|
||||
map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 交通条件
|
||||
map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2);
|
||||
// 泊车条件 /
|
||||
map.stop_car_code = getStopCarCode(dist);
|
||||
// /学区房类型
|
||||
map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ;
|
||||
}
|
||||
// 地址
|
||||
map.address = dist.address
|
||||
// 所属区域
|
||||
map.in_region_code = getRegionCode(dist.region);
|
||||
|
||||
//绿化率
|
||||
map.virescence_percent = getVirescencePercent(dist.virescence_percent, map.build_date);
|
||||
//容积率
|
||||
map.cubage_percent = getCubagePercent(dist.cubage_percent, map.build_date);
|
||||
// 参考租金(1室) 参考租金(2室) 参考租金(3室) 参考租金(4室) 参考租金(5室) 参考租金(5室以上)
|
||||
map.rents = getRentPrice2(dist.city, dist.region, dist.name, dist.estate_type2, dist.lat2, dist.lng2, dist.cat);
|
||||
//物业公司
|
||||
map.estate_company = getEstateCompany(dist.estate_company);
|
||||
//物业费
|
||||
map.estate_charge = getEstateCharge(dist.estate_charge);
|
||||
|
||||
saveDistrict(map);
|
||||
}
|
||||
|
||||
|
||||
static def saveDistrict(def m){
|
||||
DBObject q = new BasicDBObject();
|
||||
q.put("num_id",m.num_id)
|
||||
def dbo = DIST_COLL.findOne(q);
|
||||
|
||||
DBObject udata = new BasicDBObject();
|
||||
m.each {k,v->
|
||||
udata.put(k, v);
|
||||
}
|
||||
if(dbo){
|
||||
udata.removeField("num_id")
|
||||
DIST_COLL.update(q, new BasicDBObject('$set', udata), false, true);
|
||||
}else{
|
||||
DIST_COLL.save(udata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//1-主城区:天宁区、钟楼区 2-郊区:武进区、新北区、戚墅堰区 3-县级市:金坛市、溧阳市
|
||||
static def getRegionCode(def region){
|
||||
if(region.indexOf("天宁")!=-1||region.indexOf("钟楼")!=-1){
|
||||
return "01";
|
||||
}else if(region.indexOf("武进")!=-1||region.indexOf("新北")!=-1||region.indexOf("戚墅堰")!=-1){
|
||||
return "02";
|
||||
}else if(region.indexOf("金坛")!=-1||region.indexOf("溧阳")!=-1){
|
||||
return "03";
|
||||
}else{
|
||||
return "99";
|
||||
}
|
||||
}
|
||||
|
||||
static def getVirescencePercent(def virescence_percent, def buildDate){
|
||||
if(virescence_percent){
|
||||
virescence_percent = virescence_percent.replace("%","");
|
||||
}
|
||||
|
||||
if(virescence_percent){
|
||||
if(virescence_percent.toFloat()>50){
|
||||
virescence_percent = "";
|
||||
}
|
||||
}
|
||||
|
||||
if(!virescence_percent && buildDate){
|
||||
if(buildDate==1986){
|
||||
virescence_percent = 25;
|
||||
}else if(buildDate == 1987){
|
||||
virescence_percent = 30;
|
||||
}else if(buildDate>=1990 && buildDate<=2009){
|
||||
virescence_percent = 25;
|
||||
}else if(buildDate == 2010){
|
||||
virescence_percent = 30;
|
||||
}
|
||||
}
|
||||
|
||||
if(virescence_percent){
|
||||
virescence_percent = virescence_percent.toDouble()/100;
|
||||
return new DecimalFormat("######0.00").format(virescence_percent)
|
||||
}
|
||||
|
||||
return virescence_percent;
|
||||
}
|
||||
|
||||
|
||||
static def getCubagePercent(def cubage_percent, def build_date){
|
||||
if(!cubage_percent && build_date){
|
||||
if(build_date >=1990 && build_date<=1999){
|
||||
return "1.49";
|
||||
}else if(build_date==2000){
|
||||
return "1.46";
|
||||
}
|
||||
}
|
||||
return cubage_percent;
|
||||
}
|
||||
|
||||
static def getBuildDate(def dbo){
|
||||
def year = DataHandleUtils.findPattern(dbo.finish_building_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.live_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
if(!year){
|
||||
def date = DateUtils.formatToYYYYMMDD(dbo.open_date)
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year<=1900){
|
||||
year = null;
|
||||
}else{
|
||||
return year;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dbo.build_date){
|
||||
year = DataHandleUtils.findPattern(dbo.build_date, "(\\d+)");
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
if(year && year>1900){
|
||||
return year;
|
||||
}
|
||||
}
|
||||
return year;
|
||||
}
|
||||
|
||||
static def getEstateCompany(def company){
|
||||
if(company){
|
||||
company = company.replace("---","").replace("·","");
|
||||
return company;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static def getEstateCharge(def charge){
|
||||
if(charge){
|
||||
if(charge == "0.0"){
|
||||
return "";
|
||||
}else{
|
||||
Pattern pa=Pattern.compile("([\\d\\.]+)")
|
||||
Matcher ma=pa.matcher(charge)
|
||||
if(ma.find()){
|
||||
charge = ma.group(1)
|
||||
|
||||
if(charge.toFloat()>=40){
|
||||
return "";
|
||||
}else{
|
||||
if(charge.endsWith(".0")){
|
||||
return charge.substring(0, charge.indexOf(".0"))
|
||||
}else{
|
||||
return charge;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static def getRentPrice2(def city, def region, def name, def estate_type2, def lat2, def lng2, def cat){
|
||||
def month = CommonDatautils.getDistrictRentLastMonth(city, region, name)
|
||||
|
||||
def priceMap = [:];
|
||||
if(month){
|
||||
priceMap = CommonDatautils.getDistrictRentPrice(city, region, name, month);
|
||||
}
|
||||
|
||||
|
||||
if(!priceMap){
|
||||
priceMap = getRoundAvgRentPrice(city,region, name, estate_type2, lat2, lng2, cat);
|
||||
}
|
||||
|
||||
|
||||
if(priceMap && priceMap.size()>1){
|
||||
|
||||
def prices = []
|
||||
def rooms = [];
|
||||
for(int i=1;i<=6;i++){
|
||||
def price = priceMap.get(i);
|
||||
if(price){
|
||||
if(price>20000||price<300){
|
||||
priceMap.remove(i);
|
||||
}else{
|
||||
|
||||
if(i>3 && price<1000){
|
||||
priceMap.remove(i);
|
||||
}else{
|
||||
prices << price
|
||||
rooms << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//排序
|
||||
prices.sort();
|
||||
rooms.sort();
|
||||
if(prices.size()>1){
|
||||
priceMap = [:];
|
||||
def index = 0;
|
||||
for(def price : prices){
|
||||
index++;
|
||||
priceMap.put(rooms.get(index-1), price);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filterData(prices, rooms, priceMap);
|
||||
}
|
||||
|
||||
|
||||
if(priceMap && estate_type2.contains("别墅")){
|
||||
priceMap.remove(1);
|
||||
priceMap.remove(2);
|
||||
|
||||
if(priceMap.get(4)<2000){
|
||||
priceMap.remove(4);
|
||||
}
|
||||
|
||||
if(priceMap.get(3)<2000){
|
||||
priceMap.remove(3);
|
||||
}
|
||||
}
|
||||
|
||||
// if(!priceMap){
|
||||
// priceMap = findRegionRentPrice(priceMap, city, region, estate_type2)
|
||||
// }
|
||||
|
||||
//5室及以上价格小于2000去除
|
||||
if(priceMap){
|
||||
if(priceMap.get(5)<2000){
|
||||
priceMap.remove(5);
|
||||
}
|
||||
|
||||
if(priceMap.get(6)<3000){
|
||||
priceMap.remove(6);
|
||||
}
|
||||
}
|
||||
def newPriceMap = [:]
|
||||
if(priceMap){
|
||||
priceMap.each {k,v->
|
||||
newPriceMap.put(k.toString(),v)
|
||||
}
|
||||
}
|
||||
return newPriceMap;
|
||||
}
|
||||
|
||||
static def findRegionRentPrice(def priceMap,def city, def region, def estate_type2){
|
||||
if(!priceMap){
|
||||
priceMap = [:]
|
||||
if(estate_type2=="别墅"){
|
||||
def room4 = CommonDatautils.getRegionRent(city, region, 4, "别墅");
|
||||
if(room4){
|
||||
def v = DataHandleUtils.random(-100, 500) + 100;
|
||||
priceMap.put(4, room4+v);
|
||||
|
||||
}
|
||||
}else{
|
||||
def room1 = CommonDatautils.getRegionRent(city, region, 1, "小区");
|
||||
def room2 = CommonDatautils.getRegionRent(city, region, 2, "小区");
|
||||
if(room1){
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
priceMap.put(1, room1+v);
|
||||
}
|
||||
|
||||
if(room2){
|
||||
def v = DataHandleUtils.random(-100, 600) + 100;
|
||||
priceMap.put(2, room2+v);
|
||||
}
|
||||
}
|
||||
}
|
||||
return priceMap;
|
||||
}
|
||||
|
||||
|
||||
static def getRoundAvgRentPrice(city,region, name, estate_type2, lat2, lng2, cat ){
|
||||
if(lng2 && lat2){
|
||||
def lat = lat2/10000000000;
|
||||
def lng = lng2/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def ret = CommonDatautils.findDistrictsByLatLng(city, cat, map.maxLat*10000000000, map.minLat*10000000000, map.maxLng*10000000000, map.minLng*10000000000, estate_type2);
|
||||
if(ret){
|
||||
def room1_sum = 0;
|
||||
def room1_count = 0;
|
||||
def room2_sum = 0;
|
||||
def room2_count = 0;
|
||||
for(def obj : ret){
|
||||
def rentMap = CommonDatautils.getDistrictPrice(city, region, name, estate_type2)
|
||||
if(rentMap){
|
||||
if(rentMap.get(1)){
|
||||
room1_sum = room1_sum + rentMap.get(1);
|
||||
room1_count ++;
|
||||
}
|
||||
|
||||
if(rentMap.get(2)){
|
||||
room2_sum = room2_sum + rentMap.get(2);
|
||||
room2_count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
def result = [:];
|
||||
if(room1_count){
|
||||
def room1_avg_price = (room1_sum/room1_count).toInteger();
|
||||
if(room1_avg_price){
|
||||
result.put(1, room1_avg_price);
|
||||
}
|
||||
}
|
||||
if(room2_count){
|
||||
def room2_avg_price = (room2_sum/room2_count).toInteger();
|
||||
if(room2_avg_price){
|
||||
result.put(2, room2_avg_price);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
def static filterData(prices, rooms, priceMap){
|
||||
def mod = [];
|
||||
for(int j=1;j<prices.size();j++){
|
||||
def start = prices[j-1];
|
||||
def end = prices[j];
|
||||
def val = (end-start)/start;
|
||||
if(val>=1){
|
||||
def room = rooms.get(j);
|
||||
def price = prices.get(j)
|
||||
priceMap.remove(room);
|
||||
prices.remove(j);
|
||||
}
|
||||
mod << val;
|
||||
}
|
||||
println "mod:"+ mod;
|
||||
return priceMap;
|
||||
}
|
||||
|
||||
|
||||
//1-周边公交线路≥10条;2-周边公交线路<10条但≥5条;3-周边公交线路<5条但≥2条;4-周边公交线路<2条
|
||||
static def getTrafficCode(def city, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def trafficMap = CommonDatautils.findBusLineCount(city, map.maxLat, map.minLat, map.maxLng, map.minLng);
|
||||
|
||||
def count = 0;
|
||||
if(trafficMap){
|
||||
count = trafficMap.bus.size()
|
||||
}
|
||||
|
||||
if(count>=10){
|
||||
return "01";
|
||||
}else if(count>=5){
|
||||
return "02";
|
||||
}else if(count>=2){
|
||||
return "03";
|
||||
}else if(count < 2){
|
||||
return "04";
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
|
||||
static def getStopCarCode(def dbo){
|
||||
if(dbo.car_site){
|
||||
if(dbo.car_site=="<br />"||dbo.car_site=="待定"||dbo.car_site.indexOf("暂无")!=-1||dbo.car_site=="详询售楼处"){
|
||||
dbo.car_site ="";
|
||||
}
|
||||
|
||||
if(dbo.car_site){
|
||||
return "01";
|
||||
}
|
||||
}
|
||||
|
||||
if(!dbo.car_site){
|
||||
def year = DataHandleUtils.findPattern(dbo.build_date, "(\\d+)");
|
||||
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.finish_building_date, "(\\d+)");
|
||||
if(!year){
|
||||
year = DataHandleUtils.findPattern(dbo.live_date, "(\\d+)");
|
||||
if(!year){
|
||||
def date = DateUtils.formatToYYYYMMDD(dbo.open_date)
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(year){
|
||||
year = Integer.parseInt(year);
|
||||
}
|
||||
|
||||
if(year && year >= 1980){
|
||||
return "01";
|
||||
}else if(year && year>0 && year<1980){
|
||||
return "02";
|
||||
}else{
|
||||
if(dbo.name.endsWith("期")||dbo.name.indexOf("别墅")!=-1){
|
||||
return "01";
|
||||
}else{
|
||||
|
||||
if(dbo.build_type && dbo.build_type.indexOf("高层")!=-1){
|
||||
return "01";
|
||||
}else if(dbo.estate_type2 && dbo.estate_type2=="别墅"){
|
||||
return "01";
|
||||
}else{
|
||||
|
||||
def date = CommonDatautils.findHouseBuildDate(dbo.city, dbo.region, dbo.name, "sell")
|
||||
if(date){
|
||||
year = DataHandleUtils.findPattern(date, "(\\d+)");
|
||||
if(year && year >= 1980){
|
||||
return "01";
|
||||
}else if(year && year>0 && year<1980){
|
||||
return "02";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "99"
|
||||
}
|
||||
|
||||
def endWithChar = ["村","宿舍","堂","弄"];
|
||||
for(def s : endWithChar){
|
||||
if(dbo.name.endsWith(s)){
|
||||
return "02";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "01";
|
||||
}
|
||||
|
||||
|
||||
static def getSchoolCode(def city, def region, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def redius = 3000;
|
||||
if(city=="常州" && (region=="天宁"|| region=="钟楼")){
|
||||
redius = 1000;
|
||||
}
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, redius)
|
||||
def schools = CommonDatautils.findPomDetail(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def school_count = 0;
|
||||
if(schools){
|
||||
def names = [];
|
||||
for(def schoolName : schools){
|
||||
if(schoolName.contains("小学") && !names.contains(schoolName)){
|
||||
names << schoolName
|
||||
}
|
||||
}
|
||||
|
||||
school_count = names.size();
|
||||
}
|
||||
|
||||
if(school_count >= 1){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static def getSophisticationCode(def city, def lat, def lng){
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
if(supermarket_count>=5){
|
||||
return "01";
|
||||
}else{
|
||||
map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 2000)
|
||||
supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
if(supermarket_count >= 5){
|
||||
return "02";
|
||||
}else{
|
||||
return "03";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
|
||||
static def getPublicServiceSetCode(def city, def lat, def lng){
|
||||
|
||||
if(lng && lat){
|
||||
lat = lat/10000000000;
|
||||
lng = lng/10000000000;
|
||||
def map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 1000)
|
||||
def hspt_count = CommonDatautils.findPomCount(city, "医院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def bank_count = CommonDatautils.findPomCount(city, "银行", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def school_count = CommonDatautils.findPomCount(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def supermarket_count = CommonDatautils.findPomCount(city, "超市", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
def yl_count1 = CommonDatautils.findPomCount(city, "KTV", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count2 = CommonDatautils.findPomCount(city, "电影院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count3 = CommonDatautils.findPomCount(city, "网吧", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
def yl_count4 = CommonDatautils.findPomCount(city, "健身中心", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
if(hspt_count>=1 && bank_count>=1 && school_count>=1 && supermarket_count>=1 && (yl_count1>=1 || yl_count2>=1 || yl_count3>=1||yl_count4>=1)){
|
||||
return "01";
|
||||
}else{
|
||||
map = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 2000)
|
||||
hspt_count = CommonDatautils.findPomCount(city, "医院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
bank_count = CommonDatautils.findPomCount(city, "银行", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
school_count = CommonDatautils.findPomCount(city, "学校", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
yl_count1 = CommonDatautils.findPomCount(city, "KTV", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count2 = CommonDatautils.findPomCount(city, "电影院", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count3 = CommonDatautils.findPomCount(city, "网吧", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
yl_count4 = CommonDatautils.findPomCount(city, "健身中心", map.minLat, map.maxLat, map.minLng, map.maxLng)
|
||||
|
||||
if(hspt_count>=1 && bank_count>=1 && school_count>=1 && supermarket_count>=1 && (yl_count1>=1 || yl_count2>=1 || yl_count3>=1||yl_count4>=1)){
|
||||
return "02";
|
||||
}else{
|
||||
return "03";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "99";
|
||||
}
|
||||
|
||||
static def getDistrictPrice(def city, def region, def name, def address, def block){
|
||||
|
||||
def price = CommonDatautils.findDistrictPrice(city, region, name);
|
||||
if(price){
|
||||
return price.avg_price;
|
||||
}else{
|
||||
// //样例估价
|
||||
// def s = OpenApiClient.evaluateDistrictPriceBySimilarHouse3(city, region, name, 100, false);
|
||||
// try{
|
||||
// JSONObject jsonObject = JSONObject.fromObject(s);
|
||||
// def map = DataHandleUtils.JsonToMap(jsonObject);
|
||||
// if(map.code==200){
|
||||
// if(map.result){
|
||||
// return map.result.avgPrice;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }catch(Exception e){
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
//分期找总期
|
||||
if(name.toString().endsWith("期")){
|
||||
def tempname = name.toString().substring(0, name.toString().indexOf("期")-1)
|
||||
def districtStat = CommonDatautils.findDistrictPrice(city, region, tempname);
|
||||
if(districtStat && districtStat.avg_price){
|
||||
return districtStat.avg_price+150;
|
||||
}
|
||||
}
|
||||
|
||||
if(name.toString().endsWith("区")){
|
||||
def tempname = name.toString().substring(0, name.toString().indexOf("区")-1)
|
||||
def districtStat = CommonDatautils.findDistrictPrice(city, region, tempname);
|
||||
if(districtStat && districtStat.avg_price){
|
||||
return districtStat.avg_price+100;
|
||||
}
|
||||
}
|
||||
|
||||
//周边均价
|
||||
// price = findAroundAvgPrice(city, address, 100);
|
||||
// if(price){
|
||||
// return price.toString()
|
||||
// }
|
||||
|
||||
//板块均价
|
||||
if(block){
|
||||
price = CommonDatautils.queryCityRegionPrice(city, region, block);
|
||||
if(price){
|
||||
return price.toInteger()
|
||||
}
|
||||
}
|
||||
|
||||
//区域均价
|
||||
if(!block||!price){
|
||||
price = CommonDatautils.queryCityRegionPrice(city, region, null);
|
||||
if(price){
|
||||
return price.toInteger()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
static def getShopPrice(def priceString, def city, def region, def name){
|
||||
|
||||
if(priceString){
|
||||
def avgPrice = priceString.replace("元/㎡","").replace("房源价", "").replace("房源", "");
|
||||
if(avgPrice.indexOf("-")!=-1){
|
||||
def array = avgPrice.split("-")
|
||||
if(array.length>1){
|
||||
avgPrice = ((array[1].toInteger()+array[0].toInteger())/2).toInteger();
|
||||
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toInteger()+v;
|
||||
}
|
||||
}else{
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toDouble().toInteger()+v;
|
||||
}
|
||||
}else{
|
||||
def avgPrice = CommonDatautils.queryShopPrice(city, region, name);
|
||||
if(avgPrice){
|
||||
return avgPrice;
|
||||
}
|
||||
}
|
||||
|
||||
def avgPrice = CommonDatautils.queryRegionBusinessPrice(city, region);
|
||||
if(avgPrice){
|
||||
def v = DataHandleUtils.random(-100, 300) + 100;
|
||||
return avgPrice.toInteger()+v;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static def getRentNumber(def rentPrice,def city, def region, def name){
|
||||
if(rentPrice){
|
||||
if(rentPrice.indexOf("元/㎡/天")!=-1){
|
||||
rentPrice = rentPrice.replace("元/㎡/天","");
|
||||
if(rentPrice){
|
||||
return rentPrice.toDouble();
|
||||
}
|
||||
}else if(rentPrice.indexOf("元/㎡/月")!=-1){
|
||||
def price = rentPrice.replace("元/㎡/月","").toString().trim();
|
||||
price = price.toFloat();
|
||||
price = price/30;
|
||||
return DataHandleUtils.getDoubleRound(2, price.toDouble());
|
||||
}else{
|
||||
if(rentPrice.contains("-")){
|
||||
rentPrice = rentPrice.substring(0, rentPrice.indexOf("-"));
|
||||
}
|
||||
return DataHandleUtils.getDoubleRound(2, rentPrice.toDouble());
|
||||
}
|
||||
}else{
|
||||
def day_avg_price = CommonDatautils.queryBusinessDayPrice(city, region, name, "商铺");
|
||||
if(day_avg_price){
|
||||
return day_avg_price;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static def getStreetCode(def val){
|
||||
if(val){
|
||||
if(val == "无交通管制"){
|
||||
return 1;
|
||||
}else if(val == "单行道"){
|
||||
return 2;
|
||||
}else if(val == "禁行"){
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static def getShopEstateTypeCode(def estateType){
|
||||
if(estateType){
|
||||
if(estateType.indexOf("商场商铺")!=-1){
|
||||
return 1;
|
||||
}else if(estateType.indexOf("专业市场")!=-1){
|
||||
return 2;
|
||||
}else if(estateType.indexOf("商业街")!=-1){
|
||||
return 3;
|
||||
}else if(estateType.indexOf("社区商铺")!=-1){
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return 99;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user