From 3bdf84df9dc4a1e2c7c5961f06321283c27b28a2 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Thu, 21 Jul 2022 13:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=97=B6=E9=97=B4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccbevaluation/ExportOracleData.groovy | 6 +-- .../ccbevaluation/GuiDingPriceBatch.groovy | 2 +- .../script/ccbevaluation/LoadGuide.groovy | 34 ++++++++------ .../script/ccbevaluation/UpdateData.groovy | 45 +++++++++++++++++++ 4 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateData.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy index eaf7586a5..08ab70333 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy @@ -23,7 +23,7 @@ class ExportOracleData { def run() { // def curMonth = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), 0, "yyyyMM")); def lastMonth = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - def new_dists = ["350604","350605","410307","410308","450181"] + def new_dists = [] //不会变 exportEvaluationRateData() exportBigdataPoiData() @@ -38,8 +38,8 @@ class ExportOracleData { exportCommunityBuileType() exportThirdPartyPrice2(lastMonth, new_dists) - exportBigdataForsale("2022-05-19", new_dists) - exportBigdataDeal("2022-05-01", new_dists) + exportBigdataForsale("2022-06-19", new_dists) + exportBigdataDeal("2022-06-01", new_dists) //计算结果相关 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy index 045cd0a82..08e507af9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy @@ -44,7 +44,7 @@ class GuiDingPriceBatch extends BaseBatch{ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) //添加自己库中的人工指导价 - def prices = CcbCommonUtils.findPersonPrice(city, "2022-05-1", "2022-06-1") + def prices = CcbCommonUtils.findPersonPrice(city, "2022-06-1", "2022-07-21") if(prices){ def distMap = getDistrictMap(city) def rets = createCityDatas(cityCodeDatas, distCodeMap, distMap, prices) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy index 9985dd73f..20e45bd1b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy @@ -24,7 +24,7 @@ class LoadGuide { def run(){ // addName("D:\\数据\\建行\\房产估值\\人工指导价更新.xlsx") - addPersonGuided("D:\\数据\\建行\\房产估值\\人工指导价更新.xlsx") + addPersonGuided("D:\\数据\\建行\\房产估值\\指导价\\7月人工指导价.xlsx") // match("D:\\数据\\建行\\房产估值\\指导价\\西安指导价2-103.xlsx") // saveDongGuangPrice("D:\\数据\\建行\\房产估值\\指导价\\东莞指导价218.xlsx") @@ -54,13 +54,13 @@ class LoadGuide { } def addPersonGuided(filename){ - ExcelUtils.modify(filename, { d -> - def city = d['B'] + ExcelUtils.modify(filename, { r -> + def city = r['B'] if(city){ def cityCodeDatas = CcbCommonUtils.findCityCodeValue() def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) - createSql( d, cityCodeDatas, distCodeMap) + createSql( r, cityCodeDatas, distCodeMap) } }) @@ -70,23 +70,31 @@ class LoadGuide { def id = new ObjectId() def commid = d['A'] def cityId = cityCodeDatas.get(d['B']) - def sampleRegion = d['C'].replace("街道","").replace("镇","") - def distRegion = distCodeMap.get(sampleRegion) + def cityName = d['B'] def distName = d['C'] def commName = d['D'] def price = d['E'].toDouble().toInteger() - def dist = CommonDatautils.findDistrict(cityName, sampleRegion, commName, "district") + //def dist = CommonDatautils.findDistrict(cityName, sampleRegion, commName, "district") + def dist = CommonDatautils.findDistrictById(commid) + if(dist){ - def createtime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") - def dealDate = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") + def sampleRegion = dist.region + def distRegion = distCodeMap.get(sampleRegion) + if(distRegion){ + def createtime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") + def dealDate = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") + + def sql = "insert into guided_price_gj(ID,COMMID,COMMNAME,CITYID,CITYNAME,DISTID,DISTNAME,DEALDATE,AVG_PRICE,GUIDING_PERSON,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES " + + "('${id.toString()}','${dist._id.toString()}', '${commName}','${cityId}','${cityName}','${distRegion.district_code}','${distName}',to_date('${dealDate}','yyyy-mm-dd'),${price},'房价网','',to_date('${createtime}','yyyy-mm-dd hh24:mi:ss'),to_date('${createtime}','yyyy-mm-dd hh24:mi:ss'),'FJW')" + println sql + sqlInstance.executeUpdate(sql) + }else{ + println "区域未标准化" + } - def sql = "insert into guided_price_gj(ID,COMMID,COMMNAME,CITYID,CITYNAME,DISTID,DISTNAME,DEALDATE,AVG_PRICE,GUIDING_PERSON,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES " + - "('${id.toString()}','${dist._id.toString()}', '${commName}','${cityId}','${cityName}','${distRegion.district_code}','${distName}',to_date('${dealDate}','yyyy-mm-dd'),${price},'房价网','',to_date('${createtime}','yyyy-mm-dd hh24:mi:ss'),to_date('${createtime}','yyyy-mm-dd hh24:mi:ss'),'FJW')" - println sql - sqlInstance.executeUpdate(sql) }else{ println " 没查到 "+commName } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateData.groovy new file mode 100644 index 000000000..024ad4123 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateData.groovy @@ -0,0 +1,45 @@ +package com.fangjia.script.ccbevaluation + +import com.fangjia.script.util.DbUtils +import com.mongodb.BasicDBObject +import groovy.sql.Sql + +class UpdateData { + + static def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", + "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") + + static main(args) { + def task = new UpdateData(); + task.run() + } + + def run(){ + def city = "东莞" + def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","quality"]) + println city +" 小区量:"+dists.size() + def commids = findOracleData(cityCodeDataMap.get(city)) + println "oracle 数量:"+commids.size() + def index = 0 + for(def dist : dists){ + if(!commids.contains(dist._id.toString()) && dist.quality){ + index ++ + + def udata = new BasicDBObject() + udata.put("name_cat", 11) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set', udata)) + } + } + println index + } + + def findOracleData(cityid){ + def sql = "select COMMID from bigdata_community_gj_test where cityId=${cityid} and status=0"; + def commIds = [] + sqlInstance.eachRow(sql,{r-> + commIds << r.COMMID + }); + return commIds + } +}