This commit is contained in:
2023-02-17 09:30:58 +08:00
parent ba9322e206
commit 0d9396305d
@@ -12,6 +12,7 @@ import com.fangjia.script.gj.district.FangjiaClientUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.OpenApiClient
import groovy.sql.Sql
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CountDownLatch
@@ -30,6 +31,9 @@ class BigdataCommunityBatch extends BaseBatch{
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10)
def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/postgres?stringtype=unspecified",
"postgres", "postgres", "org.postgresql.Driver")
static main(args) {
runBatch(new BigdataCommunityBatch(), args);
}
@@ -37,7 +41,7 @@ class BigdataCommunityBatch extends BaseBatch{
@Override
public void process(Object args) {
def citys = CcbCommonUtils.getRunningCitys(args)
// citys = ["文昌"]
def rows = []
def headers = []//["城市ID","行政区ID","小区ID","行政区名称","小区名称","详细地址","纬度","经度","占地总面积","建筑总面积","绿化率","容积率","车位数量","建筑年代","房屋用途",
@@ -71,7 +75,9 @@ class BigdataCommunityBatch extends BaseBatch{
allDatas << headers
allDatas.addAll(rows)
FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false);
println "txt 生成"
println "txt 生成->导Oracle"
saveToPgSql(rows)
// ExcelUtils.write("d:\\数据\\建行\\房产估值\\数据文件\\excel\\bigdata_community.xlsx", allDatas, "数据")
}
@@ -169,7 +175,7 @@ class BigdataCommunityBatch extends BaseBatch{
ret << CcbCodeUtils.parseBuildYear(dist.finish_building_date)
ret << CcbCodeUtils.parseHouseUse(dist.estate_type2)
ret << dist.household_count
ret << DateUtils.formatDateByPattern(new Date(),"yyyyMMdd")
ret << DateUtils.formatDateByPattern(new Date(),"yyyyMMdd").toInteger()
ret << dist.status
ret << DateUtils.formatDateByPattern(dist.m_date, "yyyy-MM-dd HH:mm:ss")
ret << "pa101"
@@ -222,4 +228,54 @@ class BigdataCommunityBatch extends BaseBatch{
}
return ret;
}
def saveToPgSql(rows){
for(def r : rows) {
for (def i = 0; i < r.size(); i++) {
if("" == r[i]){
r[i] = null
}
}
r << null
r << '2023-02-28'
r << null
r << '2999-12-31'
r << null
r << null
r << null
}
println "start: "+new Date()
def sql = "insert into warehouse.t0831_bigdata_community_gj_h values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
// def sql = "insert into base.t0831_bigdata_community_gj_h values "
def index = 0
sqlInstance.withBatch(20000, sql){ ps->
for(def r : rows) {
ps.addBatch(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15], r[16], r[17], r[18], r[19], r[20],
r[21], r[22], r[23], r[24], r[25], r[26], r[27], r[28], r[29], r[30], r[31], null, '2023-02-28', null, '2999-12-31', null, null, null)
ps.toString()
}
}
for(def r : rows){
index ++
if(index == 1){
sql = sql + "("+r[0].toString()+","+r[1].toString()+","+r[2].toString()+")"
}else{
sql = sql + ",("+")"
}
}
// sqlInstance.withBatch(50000, sql){ ps->
// def index = 0
// for(def r : rows){
// index++
// for(def i =0 ;i<r.size();i++){
// r[i] = r[i]?r[i]:null
// }
// ps.addBatch(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15],r[16],r[17],r[18],r[19],r[20],
// r[21],r[22],r[23],r[24],r[25],r[26],r[27],r[28],r[29],r[30],r[31],null,'2023-02-28',null,'2999-12-31',null,null,null)
// println index
// }
// }
println "end: "+new Date()
}
}