修改配置文件

This commit is contained in:
王文艳
2026-05-19 17:06:29 +08:00
parent a6d58b7745
commit 68c445b002
5 changed files with 151 additions and 42 deletions
@@ -4,7 +4,6 @@ import com.fangjia.core.Constants
import com.fangjia.core.util.DateUtil
import com.fangjia.core.util.DingDingMessageUtil
import com.fangjia.core.util.MongoUtils
import com.fangjia.datastore.driver.DSCursor
import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher
@@ -14,7 +13,7 @@ import com.fangjia.script.util.ServerAreaMap
import com.google.common.collect.MapDifference
import com.google.common.collect.Maps
import com.mongodb.*
import org.bson.types.ObjectId
/**
* 通知计算二手房均价
* @author duxiaoyu
@@ -25,7 +24,7 @@ class InsertMonitorCalcCommandBatch extends BaseBatch {
public static final DBCollection SEAWEED_COLL = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, 'fangjia', 'seaweed')
public final static DBCollection COMMAND_COLL = MongoUtils.getDbCollection(Constants.LOG_MONGO_URI, 'fangjia_log', 'calc_command')
public final static DBCollection COMMAND_COLL = MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI, 'fangjia_log', 'calc_command')
public final static DBCollection REGION_STAT_COLL = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_stat')
public final static DBCollection DISTRICT_STAT_COLL = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, 'fangjia_stat', 'district_stat')
public final static DBCollection REGION_COLL = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_block')
@@ -36,35 +36,44 @@ class HongXingMonthBatch extends BaseBatch{
// createTestFile();
// mergeFile()
// mergeMatchId()
def fileName = "C:\\Users\\wenyan\\Desktop\\宏信交付数据\\宏信楼盘4月监测20260420交付.xlsx"
def fileName = "C:\\Users\\wenyan\\Desktop\\宏信交付数据\\宏信楼盘5月监测20260520交付.xlsx"
def removeAddrFile = "C:\\Users\\wenyan\\Desktop\\宏信交付数据\\20260520宏信.xlsx"
def removeAddrs = []
ExcelUtils.read(removeAddrFile, 0).each {List item->
removeAddrs << item["C"]
}
ExcelUtils.modify(fileName,{List item->
if(item["E"] == null && removeAddrs.contains(item["C"])){
item["E"] = "已处置"
println("新增已处置房产:{item['C']}")
}
})
def fixPriceAddrs = [:]
ExcelUtils.read(removeAddrFile, 1).each {List item->
if(item["A"] && item["B"]){
fixPriceAddrs.put(item["A"],item["B"].toString().toDouble().toInteger())
}
removeAddrs << item["C"]
}
def stat = [:]
//获取上个月的交付价格
def lastMonthPriceRowId = "N" //上个月均价所在列号
def lastMonthPriceRowId = "P" //上个月均价所在列号
ExcelUtils.read(fileName).each{List item->
if(item[lastMonthPriceRowId]){
stat.put(item["C"], item[lastMonthPriceRowId])
}
}
// 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(fileName)
def newDatas = createDatas(datas, lastMonthStr)
def newDatas = createDatas(datas, lastMonthStr, fixPriceAddrs)
def curDateStr = DateUtils.formatDateByPattern(new Date(),"yyyyMMdd")
ExcelUtils.write(fileName, newDatas,"结果${curDateStr}")
}
// ExcelUtils.multiThreadingModify("C:\\Users\\wenyan\\Desktop\\宏信楼盘3月监测20260320交付跑数V3(mu).xlsx",{ List d->
// if (!["商铺","办公楼"].contains(d['A'])){
// def tihuanMap = [:]
@@ -112,10 +121,10 @@ class HongXingMonthBatch extends BaseBatch{
}
def createDatas(datas, lastMonthStr){
def createDatas(datas, lastMonthStr, Map fixPriceAddrs){
def rows = []
rows << ["物业类型","名称","地址","期房/现房","处置状态","省份","城市","城市排名","面积","1月评估单价(元)","1月评估总价(元)","2月评估单价(元)","2月评估总价(元)","3月评估单价", "3月评估总价(元)","4月评估单价", "4月评估总价(元)"
,"环比涨跌幅(%)","计算方式","定基涨跌幅(相比首月波动)","4月区域均价","4月区域均价涨跌幅(%)","3月楼盘所在区域价格的排名(仅针对住宅)","4月楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","近3个月内成交量","近6个月成交量","3个月挂牌量","匹配ID-新","备注","情况说明"]
rows << ["物业类型","名称","地址","期房/现房","处置状态","省份","城市","城市排名","面积","1月评估单价(元)","1月评估总价(元)","2月评估单价(元)","2月评估总价(元)","3月评估单价", "3月评估总价(元)","4月评估单价", "4月评估总价(元)","5月评估单价", "5月评估总价(元)"
,"环比涨跌幅(%)","计算方式","定基涨跌幅(相比首月波动)","5月区域均价","5月区域均价涨跌幅(%)","4月楼盘所在区域价格的排名(仅针对住宅)","5月楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","近3个月内成交量","近6个月成交量","3个月挂牌量","匹配ID-新","备注","情况说明"]
def index = 1
for(def d : datas){
println d['B']
@@ -136,25 +145,33 @@ class HongXingMonthBatch extends BaseBatch{
row << d['M']
row << d['N']
row << d['O']
row << d['P']
row << d['Q']
if(d['E'] == "已处置"){
rows << row
continue
}
def currMonthUnitPriceLabel = "R"
def preMonthUnitPriceLabel = "P"
def matchIdLabel = "AE"
if(!["商铺","办公楼"].contains(d['A'])){
def dist = CommonDatautils.findDistrictById(d['AD'])
def dist = CommonDatautils.findDistrictById(d[matchIdLabel])
if(dist){
def priceObj = findDistrictMonthPrice(dist.city, dist.region, dist.name, lastMonthStr)
def tihuanMap = [:]
def preTihuanMap = [:]
if(priceObj){
if(d["P"]){
def newAvgPrice = d["P"]
if(fixPriceAddrs.containsKey(d['C'])){
d[currMonthUnitPriceLabel] = fixPriceAddrs[d['c']]
}
if(d[currMonthUnitPriceLabel]){
def newAvgPrice = d[currMonthUnitPriceLabel]
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
if(d["N"]){
row << new BigDecimal(DataUtil.getRound(2,(newAvgPrice - d["N"]) * 100/ d["N"]).toString())
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["N"])
if(d[preMonthUnitPriceLabel]){
row << new BigDecimal(DataUtil.getRound(2,(newAvgPrice - d[preMonthUnitPriceLabel]) * 100/ d[preMonthUnitPriceLabel]).toString())
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d[preMonthUnitPriceLabel])
}else{
row << ""
}
@@ -169,7 +186,7 @@ class HongXingMonthBatch extends BaseBatch{
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, newAvgPrice)
}else{
def markup = priceObj.mom
def curPrice = d['N']
def curPrice = d[preMonthUnitPriceLabel]
def newAvgPrice = curPrice * markup + curPrice
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
@@ -184,7 +201,7 @@ class HongXingMonthBatch extends BaseBatch{
row << ""
}
tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, newAvgPrice)
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d["N"])
preTihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d[preMonthUnitPriceLabel])
}
}else{
row << ""
@@ -226,10 +243,10 @@ class HongXingMonthBatch extends BaseBatch{
row << findHouse(dist)
}else{
println d['AD'] +" 未找到该id的楼盘"
println d[matchIdLabel] +" 未找到该id的楼盘"
}
}else{
def dist = CommonDatautils.findDistrictById(d['AD'])
def dist = CommonDatautils.findDistrictById(d[matchIdLabel])
def cityMarkupObj = null
def regionMarkupObj = null
if(dist){
@@ -250,13 +267,13 @@ class HongXingMonthBatch extends BaseBatch{
regionMarkupObj = findSellShopMarkup(dist.city, dist.region, lastMonthStr, "district")
}
if(cityMarkupObj){
if(d["P"]){
def newAvgPrice = d["P"]
if(d[currMonthUnitPriceLabel]){
def newAvgPrice = d[currMonthUnitPriceLabel]
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
if(d['N']){
row << new BigDecimal(DataUtil.getRound(2, (newAvgPrice - d['N']) * 100/ d['N']).toString())
if(d[preMonthUnitPriceLabel]){
row << new BigDecimal(DataUtil.getRound(2, (newAvgPrice - d[preMonthUnitPriceLabel]) * 100/ d[preMonthUnitPriceLabel]).toString())
}else{
row << ""
}
@@ -270,14 +287,14 @@ class HongXingMonthBatch extends BaseBatch{
}
}else{
def newAvgPrice = d['N'] * cityMarkupObj.mom + d['N']
def newAvgPrice = d[preMonthUnitPriceLabel] * cityMarkupObj.mom + d[preMonthUnitPriceLabel]
row << DataUtil.getRound(newAvgPrice)
def totalPrice = newAvgPrice * d['I']
row << DataUtil.getRound(totalPrice)
row << cityMarkupObj.mom * 100
row << ""
if(d['N']){
def djMarkup = (newAvgPrice - d['N'])*100/ d['N']
if(d[preMonthUnitPriceLabel]){
def djMarkup = (newAvgPrice - d[preMonthUnitPriceLabel])*100/ d[preMonthUnitPriceLabel]
djMarkup = DataUtil.getRound(2, djMarkup)
row << djMarkup.toString()
}else{
@@ -326,12 +343,12 @@ class HongXingMonthBatch extends BaseBatch{
row << ""
row << ""
}else{
println d['AD'] +" 未找到该id的楼盘"
println d[matchIdLabel] +" 未找到该id的楼盘"
}
}
row << d['AD']
row << d['AB']
row << d['AC']
row << d[matchIdLabel]
row << d['AF']
row << d['AG']
rows << row
}