+107
-36
@@ -133,26 +133,27 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
def size = regionDatas.size()
|
||||
final CountDownLatch latch = new CountDownLatch(size)
|
||||
def totalCount = new AtomicLong()
|
||||
|
||||
for(def i = 0;i<regionDatas.size();i++){
|
||||
final def arr = regionDatas[i]
|
||||
fixedThreadPool.execute(new Runnable() {
|
||||
void run() {
|
||||
try {
|
||||
// fixedThreadPool.execute(new Runnable() {
|
||||
// void run() {
|
||||
// try {
|
||||
totalCount.addAndGet(1)
|
||||
println totalCount.get() +" /${size} "+arr[0] + " "+ arr[1]
|
||||
def row = createDatas(arr[0], arr[1], startDate, endDate, cityCodeDataMap, arr[2])
|
||||
if(row){
|
||||
rets << row
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
};
|
||||
})
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace()
|
||||
// } finally {
|
||||
// latch.countDown()
|
||||
// }
|
||||
// };
|
||||
// })
|
||||
}
|
||||
latch.await()
|
||||
// latch.await()
|
||||
|
||||
def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "10";
|
||||
def fileName = "/ccb/MODEL_000000_000000_BIGDATA_DISTPRICE.dat"
|
||||
@@ -206,12 +207,14 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
def allDistRegionPreMap = [:]
|
||||
def allLastMonthMap = [:]
|
||||
def allLastYearMap = [:]
|
||||
def allCcbPriceMap = [:]
|
||||
def allCcbPriceCaseCountMap = [:]
|
||||
for(def city : citys) {
|
||||
def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias"], null);
|
||||
allDistricts.addAll(districts)
|
||||
|
||||
def priceMap = CommonDatautils.queryDistrictStatByDate(city, startDate, endDate)
|
||||
allPriceMap = allPriceMap + priceMap
|
||||
// def priceMap = CommonDatautils.queryDistrictStatByDate(city, startDate, endDate)
|
||||
// allPriceMap = allPriceMap + priceMap
|
||||
|
||||
def rentMap = CommonDatautils.findSqmetreRentByCityAndDate(city, endDate)
|
||||
allRentMap = allRentMap + rentMap
|
||||
@@ -220,9 +223,15 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
def dealCountMap = findDealDatesByCity(cityCode, dealStartDate, startDate)
|
||||
allDealCountMap = allDealCountMap + dealCountMap
|
||||
|
||||
|
||||
def datas = findCommunityPriceByCity(cityCode, startDate.toString().substring(0,6))
|
||||
|
||||
def datasMap = findCommunityPriceByCityMap(cityCode, startDate.toString().substring(0,6))
|
||||
allCcbPriceMap = allCcbPriceMap + datasMap
|
||||
|
||||
|
||||
def caseCountMap = findCommunityPriceCountByCityMap(cityCode, startDate.toString().substring(0,6))
|
||||
allCcbPriceCaseCountMap = allCcbPriceCaseCountMap + caseCountMap
|
||||
|
||||
def cityRankMap = findCommunityCityRank(datas)
|
||||
allCityRankMap = allCityRankMap + cityRankMap
|
||||
|
||||
@@ -245,7 +254,7 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
allLastYearMap = allLastYearMap + lastYearMonthMap
|
||||
}
|
||||
|
||||
def cityLists = districtRunningByCity(allDistricts, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap, allDealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap)
|
||||
def cityLists = districtRunningByCity(allDistricts, startDate, endDate, cityCodeDataMap, allCcbPriceMap, allRentMap, allDealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap, allCcbPriceCaseCountMap)
|
||||
if(cityLists){
|
||||
rets.addAll(cityLists)
|
||||
}
|
||||
@@ -263,7 +272,7 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
|
||||
|
||||
|
||||
def districtRunningByCity(districts, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap){
|
||||
def districtRunningByCity(districts, startDate, endDate, cityCodeDataMap, allCcbPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap, allCcbPriceCaseCountMap){
|
||||
def totalCount = new AtomicLong()
|
||||
def distCount = districts.size()
|
||||
final CountDownLatch latch = new CountDownLatch(distCount)
|
||||
@@ -276,7 +285,7 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
void run() {
|
||||
try {
|
||||
totalCount.addAndGet(1)
|
||||
def row = createDistDate(dist, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap,allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap)
|
||||
def row = createDistDate(dist, startDate, endDate, cityCodeDataMap, allCcbPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap,allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap, allCcbPriceCaseCountMap)
|
||||
if(row){
|
||||
rets << row
|
||||
println totalCount.get() +"/"+distCount + dist.city+" "+dist.region+" "+dist.name+" "+row[4]+" "+row[6]
|
||||
@@ -323,37 +332,59 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
|
||||
def createDistDate(dist, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap){
|
||||
def createDistDate(dist, startDate, endDate, cityCodeDataMap, allCcbPriceMap, allRentMap, dealCountMap, allCityRankMap, allRegionRankMap, allDistCityPreMap, allDistRegionPreMap, allLastMonthMap, allLastYearMap, allCcbPriceCaseCountMap){
|
||||
def sellDataType = 1
|
||||
def rentDataType = 1
|
||||
def sellMap = findHouses(dist.city, dist.region, "sell", startDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
//房源查询是否按建行均价筛选房源
|
||||
def sellMap = null//findHouses(dist.city, dist.region, "sell", startDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
def sell_avg_price = null
|
||||
def sell_avg_area = null
|
||||
def sell_avg_total = null
|
||||
def sellStartDate = null
|
||||
def sell_count = 0
|
||||
if(!sellMap || (sellMap && sellMap.avg_price.size()<3)){
|
||||
sellDataType = 3
|
||||
sellStartDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -3), "yyyyMMdd").toInteger();
|
||||
sellMap = findHouses(dist.city, dist.region, "sell", sellStartDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
if(!sellMap || (sellMap && sellMap.avg_price.size()<3)){
|
||||
sellDataType = 6
|
||||
sellStartDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -6), "yyyyMMdd").toInteger();
|
||||
|
||||
|
||||
if(allCcbPriceMap.containsKey(dist._id.toString())){
|
||||
sell_avg_price = allCcbPriceMap.get(dist._id.toString())//avgValue(sellMap.avg_price)
|
||||
// sell_avg_area = avgValue(sellMap.area)
|
||||
// sell_avg_total = sell_avg_area*sell_avg_price//avgValue(sellMap.total_price)
|
||||
if(allCcbPriceCaseCountMap.containsKey(dist._id.toString())){
|
||||
sell_count = allCcbPriceCaseCountMap.get(dist._id.toString())
|
||||
}
|
||||
}
|
||||
if(sell_count){
|
||||
sellMap = findHouses(dist.city, dist.region, "sell", startDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
if(!sellMap || (sellMap && sellMap.avg_price.size()<1)){
|
||||
sellDataType = 3
|
||||
sellStartDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -3), "yyyyMMdd").toInteger();
|
||||
sellMap = findHouses(dist.city, dist.region, "sell", sellStartDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
if(!sellMap || (sellMap && sellMap.avg_price.size()<1)){
|
||||
sellDataType = 6
|
||||
sellStartDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -6), "yyyyMMdd").toInteger();
|
||||
sellMap = findHouses(dist.city, dist.region, "sell", sellStartDate, endDate, dist.name, dist.alias, dist.estate_type2)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sellMap){
|
||||
sell_count = sellMap.avg_price.size()
|
||||
if(sell_count>3){
|
||||
sell_avg_price = avgValue(sellMap.avg_price)
|
||||
if(sellMap){
|
||||
sell_avg_area = avgValue(sellMap.area)
|
||||
sell_avg_total = avgValue(sellMap.total_price)
|
||||
}else{
|
||||
sell_count = 0
|
||||
sellDataType = null
|
||||
sell_avg_total = sell_avg_area*sell_avg_price//avgValue(sellMap.total_price)
|
||||
// if(sell_count>3){
|
||||
// if(allCcbPriceMap.containsKey(dist._id.toString())){
|
||||
// sell_avg_price = allCcbPriceMap.get(dist._id.toString())//avgValue(sellMap.avg_price)
|
||||
// sell_avg_area = avgValue(sellMap.area)
|
||||
// sell_avg_total = sell_avg_area*sell_avg_price//avgValue(sellMap.total_price)
|
||||
// sell_count = allCcbPriceCaseCountMap.get(dist._id.toString())
|
||||
// }else{
|
||||
// sell_count = 0
|
||||
// sellDataType = null
|
||||
// }
|
||||
// }else{
|
||||
// sell_count = 0
|
||||
// sellDataType = null
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def rent_avg_price = null
|
||||
def rent_avg_area = null
|
||||
def rent_avg_total = null
|
||||
@@ -381,6 +412,8 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
rentDataType = null
|
||||
}
|
||||
}
|
||||
|
||||
//三个月,半年都没有数据时,用房价网价格,这块是否改为 建行价格
|
||||
if(!sell_avg_price){
|
||||
sell_avg_price = allPriceMap.get(dist.city +"##"+ dist.region +"##"+ dist.name)
|
||||
}
|
||||
@@ -620,6 +653,15 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
def sell_avg_area = null
|
||||
def sell_avg_total = null
|
||||
def sellStartDate = null
|
||||
|
||||
def avgPrice = null
|
||||
if(region){
|
||||
avgPrice = findCcbRegionPriceByRegion(cityCodeDataMap.get(city), regionCodeDataMap.district_code,startDate.toString().substring(0,6))
|
||||
}else{
|
||||
avgPrice = findCcbCityPrice(cityCodeDataMap.get(city), startDate.toString().substring(0,6))
|
||||
}
|
||||
|
||||
|
||||
if (sell_count < 10) {
|
||||
sellDataType = 3
|
||||
sellStartDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -3), "yyyyMMdd").toInteger();
|
||||
@@ -633,7 +675,7 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
sellStartDate = startDate
|
||||
}
|
||||
if (sell_count) {
|
||||
sell_avg_price = findHouseAvgByType(city, region, "sell", sellStartDate, endDate,"avg_price")
|
||||
sell_avg_price = avgPrice//findHouseAvgByType(city, region, "sell", sellStartDate, endDate,"avg_price")
|
||||
sell_avg_area = findHouseAvgByType(city, region, "sell", sellStartDate, endDate,"area")
|
||||
sell_avg_total = findHouseAvgByType(city, region, "sell", sellStartDate, endDate, "total_price")
|
||||
}
|
||||
@@ -1001,6 +1043,26 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
return datas;
|
||||
}
|
||||
|
||||
def findCommunityPriceByCityMap(cityCode, month){
|
||||
def sql = "select gujia_admndiv_nm,gujia_bds_id,gujia_bds_clc_avprc from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityCode}' and gujiabds_clc_yrmo_val=${month}";
|
||||
def dataMap = [:]
|
||||
pgsqlInstance.eachRow(sql, { r ->
|
||||
dataMap.put(r.gujia_bds_id, r.gujia_bds_clc_avprc)
|
||||
})
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
def findCommunityPriceCountByCityMap(cityCode, month){
|
||||
def sql = "SELECT gujia_comm_id,gujiabdsrt3mlgcasenum from t_app_p9pha_plda.avm_community_p_describe_gj_h WHERE urbn_id='${cityCode}' and gujia_bds_mo_val=${month}";
|
||||
def dataMap = [:]
|
||||
pgsqlInstance.eachRow(sql, { r ->
|
||||
if(r.gujiabdsrt3mlgcasenum){
|
||||
dataMap.put(r.gujia_comm_id, r.gujiabdsrt3mlgcasenum)
|
||||
}
|
||||
})
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
def findCcbCityPrice(cityCode, month){
|
||||
def sql = "SELECT gujia_bds_clc_avprc from t_app_p9pha_plda.avm_city_price_gj_h where urbn_id='${cityCode}' and gujiabds_clc_yrmo_val=${month}";
|
||||
def avgPrice = null
|
||||
@@ -1021,6 +1083,15 @@ class BigdataCitypriceBatch extends BaseBatch{
|
||||
return regionPriceMap;
|
||||
}
|
||||
|
||||
def findCcbRegionPriceByRegion(cityCode, regionCode, month){
|
||||
def sql = "SELECT gujia_bds_clc_avprc from t_app_p9pha_plda.avm_district_price_gj_h where gujiabds_clc_yrmo_val=${month} and gujia_admndiv_id='${regionCode}' and urbn_id='${cityCode}'";
|
||||
def price = null
|
||||
pgsqlInstance.eachRow(sql, { r ->
|
||||
price = r.gujia_bds_clc_avprc
|
||||
})
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
def districtCityPrictRate(cityPrice, datas){
|
||||
def distCityRateMap = [:]
|
||||
|
||||
Reference in New Issue
Block a user