diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy index 12f5ce551..952218baa 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy @@ -7,6 +7,7 @@ import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils import com.mongodb.BasicDBObject import com.mongodb.DBObject import groovy.sql.Sql @@ -459,14 +460,19 @@ class BigdataCitypriceBatch extends BaseBatch{ def dealYoy = '' if(allLastMonthMap){ def dealMarkupMap = allLastMonthMap.get(dist._id.toString()) - if(dealMarkupMap && dealMarkupMap.deal_count && dealMarkupMap.deal_count>0){ - def markup = (dealCount-dealMarkupMap.deal_count)*100/dealMarkupMap.deal_count - dealMarkup = DataHandleUtils.getDoubleRound(2, markup) + try{ + if(dealCount && dealMarkupMap && dealMarkupMap.deal_count && dealMarkupMap.deal_count>0){ + def markup = (dealCount-dealMarkupMap.deal_count)*100/dealMarkupMap.deal_count + dealMarkup = DataHandleUtils.getDoubleRound(2, markup) + } + }catch(Exception e){ + e.printStackTrace() } + } if(allLastYearMap){ def dealYoyMap = allLastYearMap.get(dist._id.toString()) - if(dealYoyMap && dealYoyMap.deal_count && dealYoyMap.deal_count>0){ + if(dealCount && dealYoyMap && dealYoyMap.deal_count && dealYoyMap.deal_count>0){ def markup = (dealCount-dealYoyMap.deal_count)*100/dealYoyMap.deal_count dealYoy = DataHandleUtils.getDoubleRound(2, markup) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/UpdateCommPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/UpdateCommPrice.groovy new file mode 100644 index 000000000..a69e66d8f --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/UpdateCommPrice.groovy @@ -0,0 +1,74 @@ +package com.fangjia.script.ccbevaluation.ronghe + +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.DateUtils +import groovy.sql.Sql + +class UpdateCommPrice { + + def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified", + "postgres", "postgres", "org.postgresql.Driver") + + def oracleSqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", + "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") + + public static def cityCodeMap = CcbCommonUtils.findCityCodeValue() + + static main(args) { + def task = new UpdateCommPrice() + task.run(args) + } + + def run(Object args){ + def citys = CcbCommonUtils.citys_all + def curDate = new Date() + if(args){ + def dateStr = args[0] + curDate = DateUtils.parseFromTightByPattern(dateStr,"yyyy-MM-dd")//2022-03-01 + } + def curRunDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(curDate,-1), "yyyyMM").toInteger(); + def startDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(curDate,-1), "yyyyMMdd").toInteger(); + def dealStartDate = DateUtils.addMonth(DateUtils.parseFromTightByPattern(startDate.toString(), "yyyyMMdd"), -1) + + process(citys, dealStartDate, startDate, curRunDate) + + } + + def process(citys, dealStartDate, startDate, curRunDate){ + def rets = [] + def allDistricts = [] + def allDealCountMap = [:] + for(def city : citys) { + def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng", "estate_type2", "name_cat", "address", "alias"]); + allDistricts.addAll(districts) + + def cityCode = cityCodeMap.get(city) + def dealCountMap = findDealDatesByCity(cityCode, dealStartDate, startDate) + allDealCountMap = allDealCountMap + dealCountMap + } + + for(def i=0;i + rMap.put(r.gujia_comm_id, r.count) + }) + return rMap; + } +}