diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy index 023cc157d..d2c8a1f84 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy @@ -5,9 +5,14 @@ import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ExcelUtils +import com.mongodb.BasicDBObject import groovy.sql.Sql import org.bson.types.ObjectId +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + /** * 建行成交数据表优化 */ @@ -24,6 +29,8 @@ class DealPriceDataProcess { def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified", "postgres", "postgres", "org.postgresql.Driver") + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + static main(args) { def task = new DealPriceDataProcess() // task.process()//运当成交pe值不好时行,拉升成交价格及删除pe太大数据 @@ -394,43 +401,73 @@ class DealPriceDataProcess { def rows = [] def cityCodeDatas = CcbCommonUtils.findCityCodeValue() def set = new HashSet() + def index = 0 for(def city : citys) { + index ++ + if(index<145){ + continue + } + println index +" "+city def cityid = cityCodeDatas.get(city) def rets = findPeGteThirdParty2(cityid, DateUtils.formatDateByPattern(new Date(),"yyyyMM"))//当前月日期 println city +" "+rets.size() if(rets){ set.add(city) } - for(def m : rets){ - -// def sql = "delete from BIGDATA_THIRD_PARTY_PRICE_GJ where cityid='${cityId}' and commid='${m.commid}' and price_date=${month} and community_price=${m.price}" -// sqlInstance236.executeUpdate(sql) - def querySql = "select count(1) as count from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} and gujia_bds_comm_avprc=${m.price}" - def total = 0 - pgsqlInstance.eachRow(querySql, { r -> - total = r.count - }) - if(total>0){ - println city +" "+m.commid+" (按价格)删除:"+total - def sql = "delete from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} and gujia_bds_comm_avprc=${m.price}" - pgsqlInstance.executeUpdate(sql) - }else{ - - querySql = "select count(1) as count from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} " - pgsqlInstance.eachRow(querySql, { r -> - total = r.count - }) - if(total>0){ - println city +" "+m.commid+" (按小区)删除:"+total - def sql = "delete from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} " - pgsqlInstance.executeUpdate(sql) - } - } - } + processDetele(city, cityid, month, rets) } println set.toString() } + + def processDetele(city, cityid, month, rets){ + + final CountDownLatch latch = new CountDownLatch(rets.size()) + + for(def i=0;i + total = r.count + }) + if(total>0){ + println city +" "+m.commid+" (按价格)删除:"+total + def sql = "delete from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} and gujia_bds_comm_avprc=${m.price}" + pgsqlInstance.executeUpdate(sql) + }else{ + + querySql = "select count(1) as count from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} " + pgsqlInstance.eachRow(querySql, { r -> + total = r.count + }) + if(total>0){ + println city +" "+m.commid+" (按小区)删除:"+total + def sql = "delete from base.t0831_bigdata_third_party_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${m.commid}' and gujiabds_avprc_dt_val=${month} " + pgsqlInstance.executeUpdate(sql) + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + + latch.await() + } + + + + + def findThirdCount(sqlInstance236, sql){ def count = 0 sqlInstance236.eachRow(sql,{r->