调整房价网界面

This commit is contained in:
王文艳
2026-03-24 08:42:44 +08:00
parent 020a9d9025
commit 012b508eca
68 changed files with 321 additions and 181 deletions
@@ -7,6 +7,8 @@ import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.DataUtil
import com.fangjia.script.util.DateUtil
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ElasticUtils
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
@@ -22,7 +24,7 @@ class HongXingMonthBatch extends BaseBatch{
static DBCollection SHOP_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "shop_sell_stat", "mongo.db.fangjia.com")
static DBCollection OFFICE_RENT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "office_rent_stat", "mongo.db.fangjia.com")
static DBCollection OFFICE_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "office_sell_stat", "mongo.db.fangjia.com")
static DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com")
static main(args) {
runBatch(new HongXingMonthBatch(), args);
}
@@ -33,17 +35,69 @@ class HongXingMonthBatch extends BaseBatch{
// createTestFile();
// mergeFile()
// mergeMatchId()
// def stat = [:]
// ExcelUtils.read("C:\\Users\\wenyan\\Desktop\\宏信2月价格监测核实(价格有偏差核查).xlsx").each{List item->
// if(item["U"]){
// stat.put(item["C"], item["U"])
// }
// }
// ExcelUtils.modify("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数.xlsx",{List item->
// if(stat.containsKey(item["C"])){
// item["O"] = stat[item["C"]].toString().toDouble().toInteger()
// }
// })
// def lastMonthStr = DateUtils.formatDateByPattern(DateUtils.parseFromTightYYYYMMDD(DateUtils.addMonth(new Date(), -1)),"yyyyMM");
// def count = findCurMonthPrice(lastMonthStr)
// if(count > 0){
// def datas = ExcelUtils.read("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数.xlsx")
// def newDatas = createDatas(datas, lastMonthStr)
//
// def curDateStr = DateUtils.formatDateByPattern(new Date(),"yyyyMMdd")
// ExcelUtils.write("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数1.xlsx", newDatas,"结果")
// }
ExcelUtils.multiThreadingModify("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数V3(mu).xlsx",{ List d->
if (!["商铺","办公楼"].contains(d['A'])){
def tihuanMap = [:]
def preTihuanMap = [:]
def dist = CommonDatautils.findDistrictById(d['AA'])
if(dist){
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["N"])
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["L"])
def resMap = getDistSortNumber(dist.city, dist.region, "202602", tihuanMap)
def preResMap = getDistSortNumber(dist.city, dist.region, "202601", preTihuanMap)
if(resMap){
d["V"] = resMap.num+"/"+resMap.total
}else{
d["V"] = null
}
if(preResMap){
d["U"] = preResMap.num+"/"+preResMap.total
}else{
d["U"] = null
}
if(resMap && preResMap){
d["W"] = resMap.num - preResMap.num
}else{
d["W"] = null
}
}
def lastMonthStr = DateUtils.formatDateByPattern(DateUtils.parseFromTightYYYYMMDD(DateUtils.addMonth(new Date(), -1)),"yyyyMM");
def count = findCurMonthPrice(lastMonthStr)
if(count > 0){
def datas = ExcelUtils.read("D:\\数据\\宏信息\\宏信楼盘监测20260302-价格修正.xlsx")
def newDatas = createDatas(datas, lastMonthStr)
def curDateStr = DateUtils.formatDateByPattern(new Date(),"yyyyMMdd")
ExcelUtils.write("D:\\数据\\宏信息\\宏信楼盘监测"+curDateStr+".xlsx", newDatas,"结果")
}
}
}, 1,"V3")
// ExcelUtils.modify("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数V3(mu).xlsx",{List item->
//// if(item["O"]){
//// item["N"] = item["O"].toString().toDouble().toInteger()
//// }
//// item["P"] = (item["I"] * item["N"]).toInteger()
//// if(item["N"] && item["L"]){
//// item["Q"] = new BigDecimal(DataUtil.getRound(2,(item["N"] - item["L"])*100/item["L"]).toString())
//// }
//// if(item["N"] && item["J"]){
//// item["S"] = new BigDecimal(DataUtil.getRound(2,(item["N"] - item["J"])*100/item["J"]).toString())
//// }
//
//
// }, 1,"V3")
// andAddSortNum()
}
@@ -52,44 +106,72 @@ class HongXingMonthBatch extends BaseBatch{
def createDatas(datas, lastMonthStr){
def rows = []
rows << ["物业类型","名称","地址","期房/现房","省份","城市","城市排名","面积","1月供数单价(元)","2月供数单价(元)","1月供数总价(元)","2月供数总价(元)","环比涨跌幅(%)","定基涨跌幅(相比首月波动)","3月区域均价","3月区域均价涨跌幅(%)","3月楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","匹配ID-新","报告负责人"]
rows << ["物业类型","名称","地址","期房/现房","处置状态","省份","城市","城市排名","面积","1月供数单价(元)","1月供数总价(元)","2月供数单价(元)","2月供数总价(元)","3月评估单价", "3月评估总价(元)"
,"环比涨跌幅(%)","计算方式","定基涨跌幅(相比首月波动)","3月区域均价","3月区域均价涨跌幅(%)","2月楼盘所在区域价格的排名(仅针对住宅)","3月楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","近3个月内成交量","近6个月成交量","3个月挂牌量","匹配ID-新","备注","报告负责人", "情况说明"]
def index = 1
for(def d : datas){
println d['B']
index++
// if(index < 12){
// continue
// }
def row = [:]
row << d['D']
if(d['E'] == "已处置"){
continue
}
def row = []
row << d['A']
row << d['B']
row << d['C']
row << d['D']
row << d['E']
row << d['F']
row << d['G']
row << d['H']
row << d['I']
row << d['J']
row << d['K']
row << d['L']
row << d['M']
if(!["商铺","办公楼"].contains(d['D'])){
def dist = CommonDatautils.findDistrictById(d['I'])
if(!["商铺","办公楼"].contains(d['A'])){
def dist = CommonDatautils.findDistrictById(d['Z'])
if(dist){
def priceObj = findDistrictMonthPrice(dist.city, dist.region, dist.name, lastMonthStr)
def tihuanMap = [:]
def preTihuanMap = [:]
if(priceObj){
def markup = priceObj.mom
def curPrice = d['U']
def newAvgPrice = curPrice * markup + curPrice
row << DataUtil.getRound(newAvgPrice)
row << getPriceWay(priceObj.value_type)
def totalPrice = newAvgPrice * d['H']
row << DataUtil.getRound(totalPrice)
row << markup*100
def djMarkup = (newAvgPrice - d['U'])*100/ d['U']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, newAvgPrice)
if(d["N"]){
def newAvgPrice = d["N"]
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
row << new BigDecimal(DataUtil.getRound(2,(newAvgPrice - d['L']) * 100/ d['L']).toString())
row << ""
def djMarkup = (newAvgPrice - d['J'])*100/ d['J']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, newAvgPrice)
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["L"])
}else{
def markup = priceObj.mom
def curPrice = d['L']
def newAvgPrice = curPrice * markup + curPrice
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
row << markup*100
row << getPriceWay(priceObj.value_type)
println(row)
def djMarkup = (newAvgPrice - d['J'])*100/ d['J']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, newAvgPrice)
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["L"])
}
}else{
row << ""
row << ""
row << ""
row << ""
row << ""
}
def regionPriceObj = findRegionPrice(dist.city, dist.region, lastMonthStr)
@@ -102,61 +184,82 @@ class HongXingMonthBatch extends BaseBatch{
}
def resMap = getDistSortNumber(dist.city, dist.region, lastMonthStr, tihuanMap)
def lastRank = null//getLastMonthSortNumer(d['AB'])
def preResMap = getDistSortNumber(dist.city, dist.region, "202601", preTihuanMap)
if(resMap){
row << resMap.num+"/"+resMap.total
if(lastRank){
row << lastRank - resMap.num
}else{
row << ""
}
}else{
row << ""
}
if(preResMap){
row << preResMap.num+"/"+preResMap.total
}else{
row << ""
}
if(resMap && preResMap){
row << resMap.num - preResMap.num
}
row << findTrades(dist, 3)
row << findTrades(dist, 6)
row << findHouse(dist)
}else{
println d['I'] +" 未找到该id的楼盘"
println d['AD'] +" 未找到该id的楼盘"
}
}else{
def dist = CommonDatautils.findDistrictById(d['I'])
def dist = CommonDatautils.findDistrictById(d['Z'])
def cityMarkupObj = null
def regionMarkupObj = null
if(dist){
if(d['D'] == "办公楼"){
if(d['A'] == "办公楼"){
cityMarkupObj = findRentOfficeMarkup(dist.city, null, lastMonthStr, "city")
regionMarkupObj = findSellOfficeMarkup(dist.city, dist.region, lastMonthStr, "district")
if(cityMarkupObj){
println cityMarkupObj
cityMarkupObj.mom = cityMarkupObj.mom / 100
}
if(regionMarkupObj){
println regionMarkupObj
regionMarkupObj.mom = regionMarkupObj.mom / 100
}
}else if(d['D'] == "商铺"){
}else if(d['A'] == "商铺"){
cityMarkupObj = findSellShopMarkup(dist.city, null, lastMonthStr, "city")
regionMarkupObj = findSellShopMarkup(dist.city, dist.region, lastMonthStr, "district")
}
if(cityMarkupObj){
def newAvgPrice = d['U'] * cityMarkupObj.mom + d['U']
row << DataUtil.getRound(newAvgPrice)
row << ""
def totalPrice = newAvgPrice * d['H']
row << DataUtil.getRound(totalPrice)
row << cityMarkupObj.mom * 100
def djMarkup = (newAvgPrice - d['U'])*100/ d['U']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
if(d["N"]){
def newAvgPrice = d["N"]
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
row << new BigDecimal(DataUtil.getRound(2, (newAvgPrice - d['L']) * 100/ d['L']).toString())
row << ""
def djMarkup = (newAvgPrice - d['J'])*100/ d['J']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
}else{
def newAvgPrice = d['L'] * cityMarkupObj.mom + d['L']
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
row << cityMarkupObj.mom * 100
row << ""
def djMarkup = (newAvgPrice - d['L'])*100/ d['L']
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
}
}else{
row << ""
row << ""
row << ""
row << ""
row << ""
row << ""
row << ""
row << ""
}
if(d['D'] == "办公楼"){
if(d['A'] == "办公楼"){
if(regionMarkupObj){
row << (int)regionMarkupObj.avg_price
row << regionMarkupObj.mom * 100
@@ -175,21 +278,58 @@ class HongXingMonthBatch extends BaseBatch{
}
row << ""
row << ""
row << ""
row << ""
row << ""
row << ""
}else{
println d['I'] +" 未找到该id的楼盘"
println d['AD'] +" 未找到该id的楼盘"
}
}
row << d['C']
row << d['E']
row << d['F']
row << d['G']
row << d['Z']
row << d['AA']
row << d['AB']
row << d['AC']
rows << row
}
return rows
}
def findTrades(BasicDBObject dist, int monthNum){
def alias = [dist.name]
if(dist.alias){
for(def a in dist.alias){
if(a && !alias.contains(a)){
alias.add(a)
}
}
}
def q = new BasicDBObject()
q.put("city", dist.city)
q.put("region", dist.region)
q.put("district_name", new BasicDBObject('$in', alias))
q.put("trade_date", new BasicDBObject('$gt', com.fangjia.core.util.DateUtil.add(new Date(),-monthNum * 30)))
return DEAL_PRICE_COLL.count(q)
}
def findHouse(BasicDBObject dist){
def alias = [dist.name]
if(dist.alias){
for(def a in dist.alias){
if(a && !alias.contains(a)){
alias.add(a)
}
}
}
def cnt =0
def sql = "select count(*) as count from \"seawater-2026\"s where city = '${dist.city}' and region = '${dist.region}' and cat = 'sell' and district_name in ('${alias.join("','")}')".toString()
ElasticUtils.executeSqlQuery(sql,{
cnt = it.count
})
return cnt
}
def andAddSortNum(){
ExcelUtils.modify("D:\\数据\\宏信息\\宏信楼盘监测20260302-修改总价.xlsx",{d->
if(!["商铺","办公楼"].contains(d['A'])){