From 839ed0f885b1bf05504baab6db8ff1942fa4d5f2 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 18 Mar 2026 09:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/district/FangjiaClientUtils.groovy | 2 +- .../gj/hongxing/HongXingMonthBatch.groovy | 251 +++++++++++++++++- 2 files changed, 245 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 271449eda..55eb288b1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -247,7 +247,7 @@ class FangjiaClientUtils { def url = null; try { // address = address.replace("{","").replace("\\","") - url = "http://192.168.0.93:8080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}" + url = "http://192.168.0.100:32080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}" // url = "http://192.168.20.242:5001/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}" // url = "http://192.168.0.19:31080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}" if(city){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/hongxing/HongXingMonthBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/hongxing/HongXingMonthBatch.groovy index cfc613f94..1b01437be 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/hongxing/HongXingMonthBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/hongxing/HongXingMonthBatch.groovy @@ -29,25 +29,30 @@ class HongXingMonthBatch extends BaseBatch{ @Override public void process(Object args) { + +// createTestFile(); +// mergeFile() +// mergeMatchId() + def lastMonthStr = DateUtils.formatDateByPattern(DateUtils.parseFromTightYYYYMMDD(DateUtils.addMonth(new Date(), -1)),"yyyyMM"); def count = findCurMonthPrice(lastMonthStr) if(count > 0){ - def fileName = "/home/goojia/hongxing/202602.xlsx" - if(CommonDatautils.isWindow()){ - fileName = "D:\\数据\\宏信息\\202602.xlsx" - } - def datas = ExcelUtils.read("D:\\数据\\宏信息\\最新0123核价结果(绿色价格)宏信估值详情(含总价).xlsx") + 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,"结果") } +// andAddSortNum() + } + + def createDatas(datas, lastMonthStr){ def rows = [] - rows << ["物业类型","名称","地址","面积","单价(元)","总价(元)","环比涨跌幅","定基涨跌幅(相比首月波动)","区域均价","区域均价涨跌幅","楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","期房/现房","省份","城市","城市排名"] + rows << ["物业类型","名称","地址","期房/现房","省份","城市","城市排名","面积","1月供数单价(元)","2月供数单价(元)","1月供数总价(元)","2月供数总价(元)","环比涨跌幅(%)","定基涨跌幅(相比首月波动)","3月区域均价","3月区域均价涨跌幅(%)","3月楼盘所在区域价格的排名(仅针对住宅)","楼盘所在区域排名变化(仅针对住宅)","匹配ID-新","报告负责人"] def index = 1 for(def d : datas){ println d['B'] @@ -55,7 +60,7 @@ class HongXingMonthBatch extends BaseBatch{ // if(index < 12){ // continue // } - def row = [] + def row = [:] row << d['D'] row << d['A'] row << d['B'] @@ -71,6 +76,7 @@ class HongXingMonthBatch extends BaseBatch{ 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 @@ -83,6 +89,7 @@ class HongXingMonthBatch extends BaseBatch{ row << "" row << "" row << "" + row << "" } def regionPriceObj = findRegionPrice(dist.city, dist.region, lastMonthStr) @@ -133,17 +140,20 @@ class HongXingMonthBatch extends BaseBatch{ 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() + }else{ row << "" row << "" row << "" row << "" + row << "" } if(d['D'] == "办公楼"){ @@ -163,6 +173,8 @@ class HongXingMonthBatch extends BaseBatch{ row << "" } } + row << "" + row << "" }else{ println d['I'] +" 未找到该id的楼盘" } @@ -178,6 +190,231 @@ class HongXingMonthBatch extends BaseBatch{ return rows } + def andAddSortNum(){ + ExcelUtils.modify("D:\\数据\\宏信息\\宏信楼盘监测20260302-修改总价.xlsx",{d-> + if(!["商铺","办公楼"].contains(d['A'])){ + if( d['B']=="中奥天赋"){ + def dist = CommonDatautils.findDistrictById(d['W']) + if(dist){ + def tihuanMap = [:] + tihuanMap.put(dist.city+"##"+dist.region+"##"+dist.name, d['I']) + def resMap = getDistSortNumber(dist.city, dist.region, "202512", tihuanMap) + if(resMap){ + def str = resMap.num+"/"+resMap.total + d['R'] = str + } + + def tihuanMap2 = [:] + tihuanMap2.put(dist.city+"##"+dist.region+"##"+dist.name, d['J']) + def resMap2 = getDistSortNumber(dist.city, dist.region, "202601", tihuanMap) + if(resMap2){ + def str = resMap2.num+"/"+resMap2.total + d['Q'] = str + } + } + } + + } + }) + } + + def mergeMatchId(){ + def datas = ExcelUtils.read("D:\\数据\\宏信息\\宏信楼盘监测20260302-价格修正.xlsx") + ExcelUtils.modify("D:\\数据\\宏信息\\宏信楼盘2月监测20260302交付.xlsx", { d -> + def addr = d['C'] + for (def row : datas) { + if (row['C'] && row['C'] == addr) { + d['T'] = row['W'] + d['U'] = row['X'] + break + } + } + }) + } + + + def mergeFile(){ + def datas = ExcelUtils.read("D:\\数据\\宏信息\\(人工已核实)宏信楼盘价格详情20260225.xlsx") + ExcelUtils.modify("D:\\数据\\宏信息\\宏信楼盘监测20260228.xlsx",{d-> + def addr = d['C'] + def result = null + for(def row : datas){ + if(row['B'] && row['B']==addr){ + result = row + break + } + } + if(result){ + d['R'] = result['J'] + if(result['L']){ + d['S'] = result['L'] + }else{ + d['S'] = result['K'] + } + def mom = (d['S']-d['R'])*100/d['R']; + mom = DataUtil.getRound(2, mom) + d['AA'] = new BigDecimal(mom.toString()) + d['T'] = result['AF'] + d['U'] = result['I'] + d['V'] = result['M'] + d['W'] = result['N'] + d['X'] = DateUtils.formatDateByPattern(result['O'], "yyyy/MM/dd") + d['Y'] = result['P'] + d['Z'] = result['Q'] + } + + }) + } + + + def getPriceWay(value_type){ + if(value_type == 1){ + return "指导价" + }else if(value_type == 2){ + return "自身样本" + }else if(value_type == 3){ + return "第三方" + }else if(value_type == 4){ + return "交易数据" + }else if(value_type == 5){ + return "周边楼盘" + }else if(value_type == 6){ + return "推导" + }else if(value_type == 7){ + return "周边推算" + }else if(value_type == 8){ + return "新模型" + }else if(value_type == 9){ + return "神经网络" + }else if(value_type == 10){ + return "无方式" + }else{ + return "" + } + return "" + } + def createTestFile(){ + def datas = ExcelUtils.read("D:\\数据\\宏信息\\最新0123核价结果(绿色价格)宏信估值详情(含总价).xlsx") + def rets = [] + def trade_date = "2025-11-01" + rets << ["小区名称","房产地址","期房/现房","类型","省份","城市","城市排名","面积","匹配ID-新","1月供数单价","2月供数单价","人工核实价格","报告负责人", + "抵房金额(元)","抵入协议签订时间","抵入年份","抵房单价","该楼盘的成交价中位价","该楼盘的成交均价","该楼盘的成交价最小价","该楼盘的成交价最大价","成交量","该楼盘的近3个月样本量","价格计算方式","周边1公里范围内同类型的成交价中位价","周边1公里范围内同类型的成交均价","周边1公里范围内同类型的成交价最小价","周边1公里范围内同类型的成交价最大价","周边1公里范围内同类型的成交样本量(近3个月)"] + def index = 1 + for(def d : datas){ + def ret = [] + println index + index++ + ret << d["A"] + ret << d["B"] + ret << d["C"] + ret << d["D"] + ret << d["E"] + ret << d["F"] + ret << d["G"] + ret << d["H"] + ret << d["I"] + ret << d['U'] + ret << ""//2月供数单价 + ret << ""//人工核实价格 + if(d["O"]=="1882266062917259264"){ + ret << "金水" + }else{ + ret << "曹" + } + ret << d['Q'] + ret << d['R'] + ret << d['S'] + ret << d['T'] + def dealAvgPrices = CommonDatautils.findTradeAvgPrices(d['I'], trade_date, null) + if(dealAvgPrices){ + def priceMap = getPriceValue(dealAvgPrices) + ret << priceMap.median + ret << priceMap.mean + ret << priceMap.min + ret << priceMap.max + ret << priceMap.count + }else{ + ret << "" + ret << "" + ret << "" + ret << "" + ret << "" + } + + def dist = CommonDatautils.findDistrictById(d['I']) + if(dist){ + def cat = "sell" + if(dist.cat == "office"){ + cat = "office_sell" + }else if(dist.cat == "shop"){ + cat = "shop_sell" + } + def count = CommonDatautils.findHouseCountByDate(dist.city, dist.region, dist.name, dist.alias, cat, 20251101) + ret << count + ret << "" + + def arrPriceMap = findArroundDealData(dist._id.toString(), dist.city, dist.lng/10000000000.0, dist.lat/10000000000.0, dist.estateType2, trade_date) + if(arrPriceMap){ + ret << arrPriceMap.median + ret << arrPriceMap.mean + ret << arrPriceMap.min + ret << arrPriceMap.max + ret << arrPriceMap.count + }else{ + ret << "" + ret << "" + ret << "" + ret << "" + ret << "" + } + }else{ + ret << "" + ret << "" + ret << "" + ret << "" + ret << "" + ret << "" + ret << "" + } + rets << ret + } + + def curDateStr = DateUtils.formatDateByPattern(new Date(),"yyyyMMdd") + ExcelUtils.write("D:\\数据\\宏信息\\宏信楼盘价格详情"+curDateStr+".xlsx", rets,"结果") + } + + def findArroundDealData(commid, city, lng, lat, estateType, trade_date){ + def districts = CommonDatautils.getDistrictArround(city, lng, lat) + if(districts){ + def prices = [] + for(def d : districts){ + if(d.estateType2 == estateType){ + def dealAvgPrices = CommonDatautils.findTradeAvgPrices(commid, trade_date, null) + prices.addAll(dealAvgPrices) + } + } + if(prices){ + return getPriceValue(prices) + } + } + return null + } + + def getPriceValue(prices){ + def sortedPrices = prices.sort() + def median = sortedPrices[sortedPrices.size().intdiv(2)] + def mean = prices.sum() / prices.size() + def max = prices.max() + def min = prices.min() + def map = [:] + map.put("median", median) + map.put("mean", (int)mean) + map.put("max", max) + map.put("min", min) + map.put("count", prices.size()) + return map; + } + def getLastMonthSortNumer(idNum, lastMonthStr){ def q = new BasicDBObject("fjw_num", idNum) def lastMonthObj = HONGXING_MONTH_STAT.findOne(q)