新增同步脚本
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
package com.fangjia.script.ccbevaluation
|
||||
|
||||
import com.fangjia.core.RegionData
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.gj.district.FangjiaClientUtils
|
||||
import com.fangjia.script.lixue.util.DBUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import groovy.sql.Sql
|
||||
import org.apache.lucene.queryparser.classic.QueryParser
|
||||
import org.apache.poi.ss.util.RegionUtil
|
||||
import org.bson.types.ObjectId
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder
|
||||
import org.elasticsearch.index.query.QueryBuilder
|
||||
import org.elasticsearch.index.query.QueryBuilders
|
||||
import org.elasticsearch.xpack.sql.jdbc.EsDataSource
|
||||
|
||||
import java.sql.ResultSet
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
/**
|
||||
* oralce中小区统计数据同步至85中
|
||||
*/
|
||||
class OracleDistrict2Mongo85 {
|
||||
|
||||
static def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl",
|
||||
"GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver")
|
||||
|
||||
static final DBCollection communityPoiConn = MongoUtils.getCollectionByName("fangjia_stat", "community_poi_gj", "192.168.0.85", 28017)
|
||||
|
||||
static main(args) {
|
||||
// 只写入重庆市数据
|
||||
def sql = "select distname, commid, commname, subway, traffic, bank, primary, junior, hospital, funeral from COMMUNITY_POI_GJ WHERE CITYID='500000'"
|
||||
def count = 0
|
||||
sqlInstance.eachRow(sql, { r ->
|
||||
def region = RegionData.formatRegion("重庆市", r['distname'])
|
||||
DBObject dbObject = new BasicDBObject("_id", r['commid'])
|
||||
DBObject updateObject = new BasicDBObject("city", "重庆").append("region", region)
|
||||
.append("name", r['commname'])
|
||||
.append('subway', Integer.parseInt(r['subway'].toString()))
|
||||
.append("traffic", Integer.parseInt(r['traffic'].toString()))
|
||||
.append("bank", Integer.parseInt(r['bank'].toString()))
|
||||
.append("primary", Integer.parseInt(r['primary'].toString()))
|
||||
.append("junior", Integer.parseInt(r['junior'].toString()))
|
||||
.append("hospital", Integer.parseInt(r['hospital'].toString()))
|
||||
.append("funeral", Integer.parseInt(r['funeral'].toString()))
|
||||
.append("c_date", new Date());
|
||||
communityPoiConn.update(dbObject, updateObject, true, false)
|
||||
count++;
|
||||
if (count % 500 == 0) {
|
||||
println "已写入" + count + "条小区数据"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user