From f2cbbbece93d9f078f71e87981e42c14cb1bd04f Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 10 Jan 2022 15:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9F=E5=BA=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/level/DistrictIndexBatch.groovy | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/level/DistrictIndexBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/level/DistrictIndexBatch.groovy index aa68defee..44fe7b006 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/level/DistrictIndexBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/level/DistrictIndexBatch.groovy @@ -13,6 +13,7 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.GeoHelper import com.fangjia.script.util.JacksonUtil import com.mongodb.DBObject +import groovy.sql.Sql import net.sf.json.JSONObject import org.apache.commons.httpclient.util.DateUtil import org.apache.commons.lang.StringUtils @@ -46,6 +47,9 @@ class DistrictIndexBatch extends BaseBatch{ public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) + def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", + "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") + static main(args) { runBatch(new DistrictIndexBatch(), args); } @@ -112,10 +116,10 @@ class DistrictIndexBatch extends BaseBatch{ avg_cost_index = 67.0195871700 * (avg_cost - 73.04713255) / 31.3526959 avg_cost_index = DataHandleUtils.getDoubleRound(6, avg_cost_index) } - def potentiality = avg_cost_index + 4099.978248 + def potentiality = total_price_index + avg_charge_index + rank_index + avg_cost_index + 4099.978248 potentiality = DataHandleUtils.getDoubleRound(6, potentiality) def map = [:] - map.id = new ObjectId().toString() + map.id = d._id.toString() map.city = d.city map.region = d.region map.name = d.name @@ -130,7 +134,7 @@ class DistrictIndexBatch extends BaseBatch{ datas << [d.city, d.region, d.name, total_price_index, avg_charge_index, rank_index, avg_cost_index,potentiality] def newUrl = targetUrl +"/"+map.id - // httpSaveData(newUrl, map) + httpSaveData(newUrl, map) println "[${totalCount.get()}] " + d.name + " avg_cost: " + avg_cost + " avg_charge:" + avg_charge + " rank:" + rank + " total_price:" + total_price } catch (Exception e) { e.printStackTrace() @@ -154,7 +158,8 @@ class DistrictIndexBatch extends BaseBatch{ } def getHousePrice(d, dists, priceMap){ - def areas = findHouse(d, 20200101, 20220101) + //def areas = findHouse(d, 20200101, 20220101) + def areas = findHouseByOracle(d._id.toString()); def avg_area = null if(areas){ avg_area = areas.sum()/areas.size(); @@ -179,11 +184,18 @@ class DistrictIndexBatch extends BaseBatch{ } if(selectDists){ - def allAreas = [] + println d.region+" "+d.name+" 周边同建筑年代楼盘:"+selectDists.size() +// def allAreas = [] + def ids = [] for(def sd : selectDists){ - def areaDatas = findHouse(sd, 20190101, 20220101) - allAreas.addAll(areaDatas) +// //def areaDatas = findHouse(sd, 20190101, 20220101 +// def areaDatas = findHouseByOracle(sd._id.toString()); +// allAreas.addAll(areaDatas) + ids << sd._id.toString() } + + def idstr = ids.join("','") + def allAreas = findHouseByOracle2(idstr); if(allAreas){ avg_area = allAreas.sum()/allAreas.size(); } @@ -311,6 +323,27 @@ class DistrictIndexBatch extends BaseBatch{ } + + def findHouseByOracle(def distId){ + + def sql = "select BUILDAREA from bigdata_forsale_gj where CITYID='440100' AND COMMID='${distId}'"; + def allRows = [] + sqlInstance.eachRow(sql,{r-> + allRows << r.BUILDAREA + }) + return allRows + } + + def findHouseByOracle2(def idstr){ + + def sql = "select BUILDAREA from bigdata_forsale_gj where CITYID='440100' AND COMMID in ('${idstr}')"; + def allRows = [] + sqlInstance.eachRow(sql,{r-> + allRows << r.BUILDAREA + }) + return allRows + } + def findHouse(def dist, def startDate, def endDate){ def nameQuery = getAllName(dist); final StringBuffer sqlBuffer = new StringBuffer()