福州同步数据修改,新增3个小区
This commit is contained in:
+56
-1
@@ -11,6 +11,10 @@ import com.mongodb.BasicDBObject
|
|||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
import org.apache.commons.codec.digest.DigestUtils
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
|
|
||||||
|
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.Matcher
|
import java.util.regex.Matcher
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
@@ -26,7 +30,9 @@ class DistrictInfoExportBatch extends BaseBatch{
|
|||||||
|
|
||||||
public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017";
|
public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017";
|
||||||
public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl)
|
public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl)
|
||||||
|
public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName2("business", "fz_district", lineUrl)
|
||||||
|
|
||||||
|
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10)
|
||||||
|
|
||||||
static main(args) {
|
static main(args) {
|
||||||
runBatch(new DistrictInfoExportBatch(), args)
|
runBatch(new DistrictInfoExportBatch(), args)
|
||||||
@@ -87,7 +93,12 @@ class DistrictInfoExportBatch extends BaseBatch{
|
|||||||
def startDate = DateUtils.getFirstDayOfMonth(lastDate);
|
def startDate = DateUtils.getFirstDayOfMonth(lastDate);
|
||||||
|
|
||||||
def fzAddrMap = getFzAddress();
|
def fzAddrMap = getFzAddress();
|
||||||
for(def rMap : districts){
|
|
||||||
|
//因为福州个性化问题,又不想影响自家数据库数据,所以另存一个福州小区库,用于手动添加数据
|
||||||
|
saveOrUpdateFzDist(districts)
|
||||||
|
def fzDistricts = getFzDistricts(city)
|
||||||
|
|
||||||
|
for(def rMap : fzDistricts){
|
||||||
//价格没有也提供
|
//价格没有也提供
|
||||||
// def dbo = CommonDatautils.queryDistrictPriceByDate3(city, rMap.region, rMap.name, startDate, lastDate)
|
// def dbo = CommonDatautils.queryDistrictPriceByDate3(city, rMap.region, rMap.name, startDate, lastDate)
|
||||||
// if(dbo){
|
// if(dbo){
|
||||||
@@ -139,6 +150,50 @@ class DistrictInfoExportBatch extends BaseBatch{
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def saveOrUpdateFzDist(districts){
|
||||||
|
|
||||||
|
def totalCount = new AtomicLong()
|
||||||
|
final CountDownLatch latch = new CountDownLatch(districts.size())
|
||||||
|
for(def i=0;i<districts.size();i++){
|
||||||
|
final def d = districts[i]
|
||||||
|
fixedThreadPool.execute(new Runnable() {
|
||||||
|
void run() {
|
||||||
|
try{
|
||||||
|
totalCount.addAndGet(1)
|
||||||
|
def dbo = FZ_DIST_COLL.findOne(new BasicDBObject("_id", d.get('_id')))
|
||||||
|
if(dbo){
|
||||||
|
def udate = new BasicDBObject()
|
||||||
|
d.each {k,v->
|
||||||
|
udate.put(k,v)
|
||||||
|
}
|
||||||
|
udate.removeField("_id")
|
||||||
|
FZ_DIST_COLL.update(new BasicDBObject('_id',d.get('_id')), new BasicDBObject('$set', udate));
|
||||||
|
}else{
|
||||||
|
FZ_DIST_COLL.save(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
latch.countDown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
latch.await()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def getFzDistricts(def city){
|
||||||
|
def q = new BasicDBObject()
|
||||||
|
q.put("city", city)
|
||||||
|
def rets = []
|
||||||
|
FZ_DIST_COLL.find(q).each{it->
|
||||||
|
rets << it
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
def processAlias(alias, def addr_alias){
|
def processAlias(alias, def addr_alias){
|
||||||
def newAlias = []
|
def newAlias = []
|
||||||
if(alias){
|
if(alias){
|
||||||
|
|||||||
+23
-4
@@ -29,7 +29,9 @@ class DistrictPriceExportBatch extends BaseBatch{
|
|||||||
def charset = "GBK"
|
def charset = "GBK"
|
||||||
|
|
||||||
public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com")
|
public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com")
|
||||||
|
public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName("business", "fz_district", "mongo.db.fangjia.com")
|
||||||
|
|
||||||
|
def specialDistsPriceMap = ["津泰新村7号、9-17号":53620,"津泰新村14号":76230,"津泰新村1-6号、8号":32580]
|
||||||
static main(args) {
|
static main(args) {
|
||||||
runBatch(new DistrictPriceExportBatch(), args)
|
runBatch(new DistrictPriceExportBatch(), args)
|
||||||
}
|
}
|
||||||
@@ -86,10 +88,21 @@ class DistrictPriceExportBatch extends BaseBatch{
|
|||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getFzDistricts(def city){
|
||||||
|
def q = new BasicDBObject()
|
||||||
|
q.put("city", city)
|
||||||
|
def rets = []
|
||||||
|
FZ_DIST_COLL.find(q).each{it->
|
||||||
|
rets << it
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
def createDatas(def city){
|
def createDatas(def city){
|
||||||
def districts = CommonDatautils.findAllDistricts(city, "district", null);
|
// def districts = CommonDatautils.findAllDistricts(city, "district", null);
|
||||||
def removeDists = CommonDatautils.findRemoveDistricts(city, "district", null, "2022-01-01");
|
// def removeDists = CommonDatautils.findRemoveDistricts(city, "district", null, "2022-01-01");
|
||||||
districts.addAll(removeDists)
|
// districts.addAll(removeDists)
|
||||||
|
def districts = getFzDistricts(city)
|
||||||
|
|
||||||
def endDateStr = DateUtils.formatDateByPattern(new Date(), "yyyy-MM")+"-10"
|
def endDateStr = DateUtils.formatDateByPattern(new Date(), "yyyy-MM")+"-10"
|
||||||
def dataStr = DateUtils.add(endDateStr, -30)
|
def dataStr = DateUtils.add(endDateStr, -30)
|
||||||
@@ -124,9 +137,15 @@ class DistrictPriceExportBatch extends BaseBatch{
|
|||||||
curPrice = (int)(lastMonthPrice*markup/100 + lastMonthPrice)
|
curPrice = (int)(lastMonthPrice*markup/100 + lastMonthPrice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
curPrice = specialDistsPriceMap.get(rMap.name)
|
||||||
|
if(curPrice){
|
||||||
|
def randMarkup = nextDouble(0, 1)
|
||||||
|
curPrice = (int)(curPrice*randMarkup/100 + curPrice)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
def m = []
|
def m = []
|
||||||
if(curPrice){
|
if(curPrice && dbo){
|
||||||
m << dbo.get("_id").toString()//均价ID
|
m << dbo.get("_id").toString()//均价ID
|
||||||
}else{
|
}else{
|
||||||
m << new ObjectId().toString()
|
m << new ObjectId().toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user