指数脚本修改
This commit is contained in:
+25
-15
@@ -1,16 +1,14 @@
|
||||
package com.fangjia.script.trade
|
||||
|
||||
import com.fangjia.core.util.DataUtil
|
||||
import com.fangjia.core.util.DateUtil
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
|
||||
///导入价格指数
|
||||
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.common.DataHandleUtils
|
||||
import com.fangjia.script.gj.district.FangjiaClientUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
@@ -19,10 +17,8 @@ import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import org.apache.commons.lang.StringUtils
|
||||
import org.apache.commons.lang.math.RandomUtils
|
||||
import org.bson.types.ObjectId
|
||||
import org.elasticsearch.xpack.sql.jdbc.EsDataSource
|
||||
|
||||
import java.sql.ResultSet
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
@@ -74,13 +70,19 @@ class ImportIndexStats extends BaseBatch{
|
||||
|
||||
// updateDataType()
|
||||
// synch()
|
||||
// synchTjjIndex()//同步统计局抓取过来的指数
|
||||
// synchTjjIndex()//批量同步统计局抓取过来的指数
|
||||
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
def month= calendar.get(Calendar.MONTH);
|
||||
def year= calendar.get(Calendar.YEAR);
|
||||
def date = createDateString(year, month, 0, "");
|
||||
|
||||
def day = calendar.get(Calendar.DATE)
|
||||
if(day == 5){
|
||||
calculatePriceIndex(year, month, date);
|
||||
}
|
||||
|
||||
createTjjData(date)//同步单期统计局数据
|
||||
|
||||
// addLostIndex()
|
||||
// addHistoryIndex()
|
||||
@@ -199,7 +201,7 @@ class ImportIndexStats extends BaseBatch{
|
||||
runDates << map
|
||||
s = DateUtils.addMonth(date, 1, "yyyyMM")
|
||||
|
||||
if(year==2024 && month==8){
|
||||
if(year==2024 && month==10){
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +212,7 @@ class ImportIndexStats extends BaseBatch{
|
||||
|
||||
//计算统计局没有发布的城市的价格指数
|
||||
def calculatePriceIndex(def year, def month, def date){
|
||||
// def citys = ["五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中"]//
|
||||
// def citys = ["定安","五指山","琼海","儋州","文昌","万宁","东方","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中"]//
|
||||
def citys = CommonDatautils.findAllCity();
|
||||
// def date = createDateString(year, month, 0, "");
|
||||
def haveIndexCitys = findPriceIndexCitys(date.toInteger());
|
||||
@@ -233,14 +235,14 @@ class ImportIndexStats extends BaseBatch{
|
||||
if(id){//已计算
|
||||
continue;
|
||||
}
|
||||
if(date.toInteger()>=201601){
|
||||
dingjiYear = 2015
|
||||
}else if(date.toInteger()>=202101){
|
||||
dingjiYear = 2020
|
||||
if(date.toInteger()>=203101){
|
||||
dingjiYear = 2030
|
||||
}else if(date.toInteger()>=202601){
|
||||
dingjiYear = 2025
|
||||
}else if(date.toInteger()>=203101){
|
||||
dingjiYear = 2030
|
||||
}else if(date.toInteger()>=202101){
|
||||
dingjiYear = 2020
|
||||
}else if(date.toInteger()>=201601){
|
||||
dingjiYear = 2015
|
||||
}
|
||||
fixedThreadPool.execute(new Runnable() {
|
||||
void run() {
|
||||
@@ -259,6 +261,7 @@ class ImportIndexStats extends BaseBatch{
|
||||
});
|
||||
}
|
||||
latch.await(1, TimeUnit.MINUTES);
|
||||
// latch.await(1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
def calculating(city, year, month, date){
|
||||
@@ -826,6 +829,9 @@ class ImportIndexStats extends BaseBatch{
|
||||
}
|
||||
|
||||
def createTjjData(date){
|
||||
|
||||
def count = STATS_INDEX_COLL.count(new BasicDBObject("type","城市").append("source", 1).append("yearmonth", date.toInteger()))
|
||||
if(count == 0){
|
||||
def queryStartDate = DateUtils.parseFromTightByPattern(date+"01", "yyyyMMdd")
|
||||
def queryEndDate = DateUtils.parseFromTightByPattern(date+"05", "yyyyMMdd")
|
||||
def sellIndexMap = findTjjIndex(indices_price_house_sellColl, queryStartDate, queryEndDate)
|
||||
@@ -888,9 +894,13 @@ class ImportIndexStats extends BaseBatch{
|
||||
|
||||
rets << dbo
|
||||
}
|
||||
if(rets){
|
||||
STATS_INDEX_COLL.insert(rets)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
def findTjjIndex(coll, queryStartDate, queryEndDate){
|
||||
def q = new BasicDBObject()
|
||||
q.put("date", new BasicDBObject('$gte',queryStartDate).append('$lte', queryEndDate))
|
||||
|
||||
Reference in New Issue
Block a user