This commit is contained in:
2024-10-22 18:24:49 +08:00
parent e1fbc1ee6a
commit bda9cca523
@@ -5,9 +5,14 @@ import com.fangjia.script.common.DataHandleUtils
import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.gj.ccb.FileUtils
import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.ExcelUtils
import com.mongodb.BasicDBObject
import groovy.sql.Sql import groovy.sql.Sql
import org.bson.types.ObjectId 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", def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified",
"postgres", "postgres", "org.postgresql.Driver") "postgres", "postgres", "org.postgresql.Driver")
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20)
static main(args) { static main(args) {
def task = new DealPriceDataProcess() def task = new DealPriceDataProcess()
// task.process()//运当成交pe值不好时行,拉升成交价格及删除pe太大数据 // task.process()//运当成交pe值不好时行,拉升成交价格及删除pe太大数据
@@ -394,15 +401,34 @@ class DealPriceDataProcess {
def rows = [] def rows = []
def cityCodeDatas = CcbCommonUtils.findCityCodeValue() def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
def set = new HashSet() def set = new HashSet()
def index = 0
for(def city : citys) { for(def city : citys) {
index ++
if(index<145){
continue
}
println index +" "+city
def cityid = cityCodeDatas.get(city) def cityid = cityCodeDatas.get(city)
def rets = findPeGteThirdParty2(cityid, DateUtils.formatDateByPattern(new Date(),"yyyyMM"))//当前月日期 def rets = findPeGteThirdParty2(cityid, DateUtils.formatDateByPattern(new Date(),"yyyyMM"))//当前月日期
println city +" "+rets.size() println city +" "+rets.size()
if(rets){ if(rets){
set.add(city) set.add(city)
} }
for(def m : rets){ 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<rets.size();i++){
final def m = rets[i]
fixedThreadPool.execute(new Runnable() {
void run() {
try{
// 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}" // 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) // 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 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}"
@@ -426,11 +452,22 @@ class DealPriceDataProcess {
pgsqlInstance.executeUpdate(sql) pgsqlInstance.executeUpdate(sql)
} }
} }
} catch (Exception e) {
e.printStackTrace()
} finally {
latch.countDown()
} }
} }
println set.toString() });
} }
latch.await()
}
def findThirdCount(sqlInstance236, sql){ def findThirdCount(sqlInstance236, sql){
def count = 0 def count = 0
sqlInstance236.eachRow(sql,{r-> sqlInstance236.eachRow(sql,{r->