update
This commit is contained in:
+63
-26
@@ -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,43 +401,73 @@ 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)
|
||||||
|
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
println set.toString()
|
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}"
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
latch.countDown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
latch.await()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def findThirdCount(sqlInstance236, sql){
|
def findThirdCount(sqlInstance236, sql){
|
||||||
def count = 0
|
def count = 0
|
||||||
sqlInstance236.eachRow(sql,{r->
|
sqlInstance236.eachRow(sql,{r->
|
||||||
|
|||||||
Reference in New Issue
Block a user