From 176923b86a246946ad12598dbd533c2d0025ff70 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Thu, 21 Oct 2021 15:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=9E=8D=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ronghe/BigdataCommunityGJRHBatch.groovy | 357 ++++++++++++++++++ 1 file changed, 357 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCommunityGJRHBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCommunityGJRHBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCommunityGJRHBatch.groovy new file mode 100644 index 000000000..3c39c1092 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCommunityGJRHBatch.groovy @@ -0,0 +1,357 @@ +package com.fangjia.script.ccbevaluation.ronghe + +import com.fangjia.core.util.DataUtil +import com.fangjia.core.util.GeoUtils +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.ccb.CcbCodeUtils +import com.fangjia.script.gj.ccb.FileUtils +import com.fangjia.script.jusfoun.JusfounCommon +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.OpenApiClient +import groovy.sql.Sql +import org.bson.types.ObjectId + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong +import java.util.regex.Pattern + + +/** + * 建行融合——小区表 + */ +@BatchOwner(Watcher.GaoJuan) +class BigdataCommunityGJRHBatch extends BaseBatch { + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(80) + + + def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.100:31521:orcl", + "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") + + public static def batchsize = 100 + static main(args) { + runBatch(new BigdataCommunityGJRHBatch(), args); + } + + @Override + public void process(Object args) { + def citys = CcbCommonUtils.citys; + citys.remove("厦门") + citys.remove("杭州") + def rows = [] + +// addBigdataDistrictFJW() + def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + for (def city : citys) { + def districts = CcbCommonUtils.findAllDistrictsByOracle(cityCodeDataMap.get(city)) + + for(def dist : districts){ + def obj = CommonDatautils.findDistrictFieldById(dist.commid,["build_structure","estate_type2","finish_building_date","alias","build_type","estate_charge","estate_type2"]) + if(obj){ + if(obj.alias && obj.alias.size()>0){ + dist.commalias = obj.alias.get(0) + }else{ + dist.commalias = "" + } + dist.buildstru = CcbCodeUtils.getBuildStructureCode(obj.build_structure) + dist.housetype = CcbCodeUtils.getDistHouseTypeCode(obj.estate_type2) + dist.buildyear = CcbCodeUtils.getBuildYear(obj.finish_building_date); + dist.houseuse = "11" + dist.buildtype = CcbCodeUtils.parseBuildType(dist.build_type) + dist.compid = new ObjectId() //物业公司id + dist.estatecharge = CcbCodeUtils.processEstateCharge(dist.city, obj.estate_charge, obj.estate_type2) + } + } + println city +" 小区加载完成 "+districts.size() + addBigdataCommunityGJRH(districts) + println city +" 1.小区表完成" + addBigdataCommbuildstruGJ(districts) + println city +" 2.小区建筑结构表" + addBigdataCommhousetypeGJ(districts) + println city +" 3.小区房屋类型表" + addBigdataCommbuildyearGj(districts) + println city +" 4.小区建筑年代表" + addBigdataCommfeeGj(districts) + println city +" 6.小区费用表" + addBigdataCommhouseuseGJ(districts) + println city +" 7.小区房屋用途表" + addBigdataPositionGJ(districts) + println city + " 8.地理位置表" + } + } + + def addBigdataCommunityGJRH(def districts){ + + sqlInstance.withBatch(batchsize) { stmt -> + for(def d : districts){ + def sql = "INSERT INTO BIGDATA_COMMUNITY_FJW (CITYID,DISTID,COMMID,COMMNAME,ADDRESS,LANDAREA,BUILDAREA,GREENINGRATE,PLOTRATIO,PARKINGCNT,UPDATETIME,COMMTYPE,COMMALIAS,STREET,STREETNO,IFNEW,INTRODUCTION,REMARK,CREATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.distid}','${d.commid}','${d.commname}',${converValue(d.address)},${d.landarea},${d.buildarea},${d.greeningrate},${d.plotratio},${d.parkingcnt}," + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.commtype}','${d.commalias}'," + }else{ + sql = sql + "null,'${d.commtype}','${d.commalias}'," + } + if(d.street && d.street!='null'){ + sql = sql +"'${d.street}'," + }else{ + sql = sql +"null," + } + if(d.streetno && d.streetno!='null'){ + sql = sql + "'${d.streetno}'," + }else{ + sql = sql +"null," + } + + sql = sql + "'${d.ifnew}',null,${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + + try{ + stmt.addBatch sql + }catch(Exception e){ + println d + println sql + } + + } + + } + } + + def converValue(def val){ + if(val && val!='null'){ + return "'"+val+"'"; + }else{ + return null + } + } + + def addBigdataCommbuildstruGJ(def districts){ + sqlInstance.withBatch(batchsize) { stmt -> + for(def d : districts){ + def sql = "INSERT INTO BIGDATA_COMMBUILDSTRU_FJW (CITYID,COMMID,BUILDSTRU,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.commid}','${d.buildstru}',${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + try{ + stmt.addBatch sql + }catch(Exception e){ + println d + println sql + } + } + } + } + + + def addBigdataCommhousetypeGJ(def districts){ + sqlInstance.withBatch(batchsize) { stmt -> + for(def d : districts){ + def sql = "INSERT INTO BIGDATA_COMMHOUSETYPE_FJW (CITYID,COMMID,HOUSETYPE,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.commid}','${d.housetype}',${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + try{ + stmt.addBatch sql + }catch(Exception e){ + println d + println sql + } + } + } + } + + def addBigdataCommbuildyearGj(districts){ + sqlInstance.withBatch(batchsize) { stmt -> + for(def d : districts){ + if(d.buildyear){ + def sql = "INSERT INTO BIGDATA_COMMBUILDYEAR_FJW (CITYID,COMMID,BUILDYEAR,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.commid}',${d.buildyear},${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + try{ + stmt.addBatch sql + }catch(Exception e){ + println d + println sql + } + } + } + } + } + + def addBigdataCommfeeGj(districts){ + + def sqls = [] + for(def d : districts){ + if(d.estatecharge){ + def sql = "INSERT INTO BIGDATA_COMMFEE_FJW (CITYID,COMMID,COMPID,FEE,HOUSEUSE,BUILDTYPE,FEETYPE,NOTE,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.commid}','${d.compid}',${d.estatecharge},'${d.houseuse}','${d.buildtype}','1',${d.note},${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + sqls << sql + + if (sqls.size() >= batchsize) { + try { + sqlInstance.withBatch(batchsize, { stmt -> + sqls.each { def s -> + println s + stmt.addBatch s + } + }) + + } catch (Exception e) { + e.printStackTrace() + } + sqls.clear() + } + + } + } + + if (sqls.size() > 0) { + sqlInstance.withBatch(100, { stmt -> + sqls.each { def s -> + stmt.addBatch s + } + }) + } + } + + def addBigdataCommhouseuseGJ(districts){ + def sqls = [] + for(def d : districts){ + def sql = "INSERT INTO BIGDATA_COMMHOUSEUSE_FJW (CITYID,COMMID,HOUSEUSE,HOUSECNT,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}', '${d.commid}','${d.houseuse}',${d.zts},${d.remark}," + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + sqls << sql + + if (sqls.size() >= batchsize) { + try { + sqlInstance.withBatch(batchsize, { stmt -> + sqls.each { def s -> + stmt.addBatch s + } + }) + + } catch (Exception e) { + e.printStackTrace() + } + sqls.clear() + } + + } + + if (sqls.size() > 0) { + sqlInstance.withBatch(100, { stmt -> + sqls.each { def s -> + stmt.addBatch s + } + }) + } + } + + def addBigdataPositionGJ(districts){ + def sqls = [] + def index = 1 + for(def d : districts){ + def sql = "INSERT INTO BIGDATA_POSITION_FJW (CITYID,OBJECTTYPE,OBJECTID,POSITIONTYPE,SEQNO,LONGITUDE,LATITUDE,ALTITUDE,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${d.cityid}','5', '${d.commid}','1',${index},${d.lng},${d.lat},null,${d.remark}," + index++ + if(d.createtime){ + sql = sql + "to_date('${d.createtime}','yyyy-mm-dd hh24:mi:ss')," + }else{ + sql = sql + "null," + } + if(d.updatetime){ + sql = sql + "to_date('${d.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${d.sourcecode}')" + }else{ + sql = sql + "null,'${d.sourcecode}')" + } + sqls << sql + + if (sqls.size() >= batchsize) { + try { + sqlInstance.withBatch(batchsize, { stmt -> + sqls.each { def s -> + stmt.addBatch s + } + }) + + } catch (Exception e) { + e.printStackTrace() + } + sqls.clear() + } + + } + + if (sqls.size() > 0) { + sqlInstance.withBatch(100, { stmt -> + sqls.each { def s -> + stmt.addBatch s + } + }) + } + } + + def addBigdataDistrictFJW(){ + def sql = "select DISTID,DISTNAME,DISTSPELL,CITYID,DISTCODE,SEQ,DISTTYPE,REMARK,to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE from bigdata_district_gj"; + def rows = [] + try{ + sqlInstance.eachRow(sql,{r-> + def insertSql = "INSERT INTO bigdata_district_fjw(DISTID,DISTNAME,DISTSPELL,CITYID,DISTCODE,SEQ,DISTTYPE,REMARK,CREATETIME,UPDATETIME,SOURCECODE) VALUES ('${r.distid}','${r.distname}','${r.distspell}','${r.cityid}','${r.distcode}','${r.seq}',${r.disttype},null,to_date('${r.createtime}','yyyy-mm-dd hh24:mi:ss'),to_date('${r.updatetime}','yyyy-mm-dd hh24:mi:ss'),'${r.sourcecode}')" + sqlInstance.withBatch(batchsize, { stmt -> + stmt.addBatch insertSql + }) + }); + }catch(Exception e){ + + } + } + +} \ No newline at end of file