+87
-58
@@ -63,7 +63,7 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
def run(){
|
||||
def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
|
||||
def citys = CommonDatautils.findAllCity();
|
||||
citys = citys[22..(citys.size()-1)]
|
||||
// citys = citys[22..(citys.size()-1)]
|
||||
for(def city : citys){
|
||||
def dists = CommonDatautils.findAllDistrictByCity(city, "district", ["city","alias","region","name", "finish_building_date","estate_charge","lat","lng","lng2","lat2"])
|
||||
// dists = dists[0..20]
|
||||
@@ -157,75 +157,76 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
fileName = "D:\\数据\\评级\\${city}综合潜力.dat"
|
||||
}
|
||||
|
||||
FileUtils.batchCreateFile(datas, fileName, headers, "utf-8", true);
|
||||
FileUtils.batchCreateFile(datas, fileName, headers, "utf-8", false);
|
||||
// ExcelUtils.write("D:\\数据\\评级\\上海综合潜力.xlsx", datas, "数据")
|
||||
}
|
||||
|
||||
def getHousePrice(d, dists, priceMap, citycode){
|
||||
//def areas = findHouse(d, 20200101, 20220101)
|
||||
|
||||
def areas = []
|
||||
// def areas = []
|
||||
// if(citycode){
|
||||
// areas = findHouseByOracle(d._id.toString(), citycode);
|
||||
// }else{
|
||||
areas = findHouse(d, 20200101, DateUtils.formatDateByPattern(new Date(),"yyyyMMdd"))
|
||||
// areas = findHouse(d, 20200101, DateUtils.formatDateByPattern(new Date(),"yyyyMMdd"))
|
||||
// }
|
||||
def avg_area = null
|
||||
if(areas){
|
||||
avg_area = areas.sum()/areas.size();
|
||||
}else{
|
||||
if(d.finish_building_date){
|
||||
def year = CommonUtils.getBuildYear(d.finish_building_date)
|
||||
if(year){
|
||||
def startYear = (year.toString().substring(0,3)+"0").toInteger()
|
||||
def endYear = startYear + 10
|
||||
|
||||
def selectDists = []
|
||||
for(def ad : dists){
|
||||
if(d.region == ad.region){
|
||||
def adYear = CommonUtils.getBuildYear(ad.finish_building_date)
|
||||
if(adYear){
|
||||
adYear = adYear.toInteger()
|
||||
if(adYear>=startYear && adYear<=endYear){
|
||||
selectDists << ad
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(selectDists){
|
||||
println d.region+" "+d.name+" 周边同建筑年代楼盘:"+selectDists.size()
|
||||
def allAreas = []
|
||||
def ids = []
|
||||
if(citycode){
|
||||
for(def sd : selectDists){
|
||||
ids << sd._id.toString()
|
||||
}
|
||||
if(ids.size()>=901){
|
||||
ids = ids[0..900]
|
||||
}
|
||||
|
||||
def idstr = ids.join("','")
|
||||
allAreas = findHouseByOracle2(idstr,citycode);
|
||||
}else{
|
||||
for(def sd : selectDists){
|
||||
def areaDatas = findHouse(sd, 20190101, 20220101)
|
||||
allAreas.addAll(areaDatas)
|
||||
}
|
||||
}
|
||||
if(allAreas){
|
||||
avg_area = allAreas.sum()/allAreas.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
def avg_area = findHouse(d, 20200101, DateUtils.formatDateByPattern(new Date(),"yyyyMMdd"))
|
||||
if(!avg_area){
|
||||
avg_area = findHousByRegion(d.city, d.region, 20200101, DateUtils.formatDateByPattern(new Date(),"yyyyMMdd"))
|
||||
// if(d.finish_building_date){
|
||||
// def year = CommonUtils.getBuildYear(d.finish_building_date)
|
||||
// if(year){
|
||||
// def startYear = (year.toString().substring(0,3)+"0").toInteger()
|
||||
// def endYear = startYear + 10
|
||||
//
|
||||
// def selectDists = []
|
||||
// for(def ad : dists){
|
||||
// if(d.region == ad.region){
|
||||
// def adYear = CommonUtils.getBuildYear(ad.finish_building_date)
|
||||
// if(adYear){
|
||||
// adYear = adYear.toInteger()
|
||||
// if(adYear>=startYear && adYear<=endYear){
|
||||
// selectDists << ad
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(selectDists){
|
||||
// println d.region+" "+d.name+" 周边同建筑年代楼盘:"+selectDists.size()
|
||||
// def allAreas = []
|
||||
// def ids = []
|
||||
// if(citycode){
|
||||
// for(def sd : selectDists){
|
||||
// ids << sd._id.toString()
|
||||
// }
|
||||
// if(ids.size()>=901){
|
||||
// ids = ids[0..900]
|
||||
// }
|
||||
//
|
||||
// def idstr = ids.join("','")
|
||||
// allAreas = findHouseByOracle2(idstr,citycode);
|
||||
// }else{
|
||||
// for(def sd : selectDists){
|
||||
// def areaDatas = findHouse(sd, 20190101, 20220101)
|
||||
// allAreas.addAll(areaDatas)
|
||||
// }
|
||||
// }
|
||||
// if(allAreas){
|
||||
// avg_area = allAreas.sum()/allAreas.size();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
if(avg_area){
|
||||
def avg_price = priceMap.get(d.city+"##"+d.region+"##"+d.name)
|
||||
def total_price = (avg_price * avg_area)/10000.0
|
||||
def total = DataHandleUtils.getDoubleRound(2, total_price)
|
||||
return total
|
||||
if(avg_price){
|
||||
def total_price = (avg_price * avg_area)/10000.0
|
||||
def total = DataHandleUtils.getDoubleRound(2, total_price)
|
||||
return total
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -236,7 +237,7 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
for(def i=0;i<list.size();i++){
|
||||
def nb = list[i]
|
||||
def detail = CommonDatautils.findDistrictFieldById(nb._id.toString(), ["estate_charge"])
|
||||
if(detail && detail.estate_charge){
|
||||
if(detail && detail.estate_charge && detail.estate_charge.toString().isNumber()){
|
||||
rets << detail.estate_charge.toDouble()
|
||||
if(rets.size()>=3){
|
||||
break;
|
||||
@@ -287,7 +288,13 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
//排序
|
||||
Collections.sort(list, new Comparator() {
|
||||
@Override
|
||||
int compare(Object o1, Object o2) {return o1.distance-o2.distance;}
|
||||
int compare(Object o1, Object o2) {
|
||||
if(o1.distance > o2.distance)
|
||||
return 1;//第二个元素(o1)比第一个元素(o2)大,返回-1
|
||||
if(o1.distance == o2.distance)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
})
|
||||
return list;
|
||||
}
|
||||
@@ -379,6 +386,28 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
// areas << rs.getDouble("area")
|
||||
avg_area = rs.getDouble("avg_area")
|
||||
}
|
||||
if(avg_area){
|
||||
avg_area = DataHandleUtils.getDoubleRound(2, avg_area)
|
||||
}
|
||||
return avg_area;
|
||||
}
|
||||
|
||||
|
||||
def findHousByRegion(def city, def region, def startDate, def endDate){
|
||||
final StringBuffer sqlBuffer = new StringBuffer()
|
||||
sqlBuffer.append("SELECT avg(area) as avg_area FROM \"seawater-20*\" WHERE 1=1")
|
||||
sqlBuffer.append(" and city = '"+city+"'")
|
||||
sqlBuffer.append(" and region = '"+region+"'")
|
||||
sqlBuffer.append(" and cat = 'sell'")
|
||||
sqlBuffer.append(" and p_date >="+startDate).append(" and p_date <"+endDate);
|
||||
ResultSet rs = dataSource.connection.createStatement().executeQuery(sqlBuffer.toString())
|
||||
def avg_area = null
|
||||
while (rs.next()){
|
||||
avg_area = rs.getDouble("avg_area")
|
||||
}
|
||||
if(avg_area){
|
||||
avg_area = DataHandleUtils.getDoubleRound(2, avg_area)
|
||||
}
|
||||
return avg_area;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user