增加样本过滤阀值
This commit is contained in:
+34
-40
@@ -50,7 +50,7 @@ class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
|
|||||||
void process(Object args) {
|
void process(Object args) {
|
||||||
String cityParam = System.getProperty("city");
|
String cityParam = System.getProperty("city");
|
||||||
String calcDate = System.getProperty("calcDate");
|
String calcDate = System.getProperty("calcDate");
|
||||||
def cities = new ArrayList()
|
def cities;
|
||||||
if(StringUtils.isNotBlank(cityParam)){
|
if(StringUtils.isNotBlank(cityParam)){
|
||||||
cities = new ArrayList()
|
cities = new ArrayList()
|
||||||
for(String c in cityParam.split(",")){
|
for(String c in cityParam.split(",")){
|
||||||
@@ -69,31 +69,22 @@ class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
|
|||||||
//开始时间
|
//开始时间
|
||||||
final Date startDate = new Date()
|
final Date startDate = new Date()
|
||||||
for (String city : cities) {
|
for (String city : cities) {
|
||||||
List<String> idList = getAllDistrictIds(city)
|
List<BasicDBObject> districts = getAllDistricts(city)
|
||||||
logInfo(city + ":" + idList.size())
|
logInfo(city + ":" + districts.size())
|
||||||
|
|
||||||
def buffer = []
|
def buffer = []
|
||||||
//生成计算小区队列
|
//生成计算小区队列
|
||||||
for (String id : idList) {
|
for (BasicDBObject district : districts) {
|
||||||
DBObject fields = new BasicDBObject()
|
String region = district.get('region')
|
||||||
fields.put("city", 1)
|
String name = district.get('name')
|
||||||
fields.put("region", 1)
|
String estateType = district.get('estate_type2')
|
||||||
fields.put("name", 1)
|
districtCount++
|
||||||
fields.put("estate_type2", 1)
|
String ip = WORKER_MACHINE_IPS[districtCount % WORKER_MACHINE_IPS.size()]
|
||||||
DBObject district = SEAWEED_COLL.findOne(new BasicDBObject("_id", new ObjectId(id)), fields)
|
BasicDBObject cmd = saveDistrictCalcCommand(city, region, name, estateType, weekend, ip)
|
||||||
if (district != null) {
|
logInfo("district:" + city + "-" + region + "-" + name + "-" + estateType + ",weekend:" + DateUtil.formatToYYYYMMDD(weekend) + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()))
|
||||||
String region = district.get('region')
|
buffer << cmd
|
||||||
String name = district.get('name')
|
if(buffer.size() == 1000){
|
||||||
String estateType = district.get('estate_type2')
|
COMMAND_COLL.insert(buffer)
|
||||||
districtCount++
|
buffer.clear()
|
||||||
String ip = WORKER_MACHINE_IPS[districtCount % WORKER_MACHINE_IPS.size()]
|
|
||||||
BasicDBObject cmd = saveDistrictCalcCommand(city, region, name, estateType, weekend, ip)
|
|
||||||
logInfo("district:" + city + "-" + region + "-" + name + "-" + estateType + ",weekend:" + DateUtil.formatToYYYYMMDD(weekend) + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()))
|
|
||||||
buffer << cmd
|
|
||||||
if(buffer.size() == 1000){
|
|
||||||
COMMAND_COLL.insert(buffer)
|
|
||||||
buffer.clear()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!buffer.isEmpty()){
|
if(!buffer.isEmpty()){
|
||||||
@@ -220,31 +211,34 @@ class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAllDistrictIds(String city) {
|
private List<BasicDBObject> getAllDistricts(String city) {
|
||||||
DBObject q = new BasicDBObject()
|
DBObject query = new BasicDBObject()
|
||||||
q.put("city", city)
|
query.put("city", city)
|
||||||
q.put("cat", "district")
|
query.put("cat", "district")
|
||||||
q.put("visible", 0)
|
query.put("visible", 0)
|
||||||
|
|
||||||
int trytimes = 5
|
DBObject fields = new BasicDBObject()
|
||||||
Set<String> uniqueIdList = new LinkedHashSet<String>()
|
fields.put("city", 1)
|
||||||
|
fields.put("region", 1)
|
||||||
|
fields.put("name", 1)
|
||||||
|
fields.put("estate_type2", 1)
|
||||||
|
fields.put("_id", 1)
|
||||||
|
|
||||||
for(int i=0; i<trytimes; i++) {
|
int tryTimes = 5
|
||||||
DSCursor cur = SEAWEED_COLL.find(q, new BasicDBObject("_id", 1)).batchSize(2000)
|
List<BasicDBObject> districts = new ArrayList<BasicDBObject>()
|
||||||
|
for(int i=0; i < tryTimes; i++) {
|
||||||
|
DSCursor cur = SEAWEED_COLL.find(query, fields).batchSize(5000)
|
||||||
int totalCount = cur.count()
|
int totalCount = cur.count()
|
||||||
Iterator<DBObject> iter = cur.iterator()
|
Iterator<DBObject> iter = cur.iterator()
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
DBObject dbo = iter.next()
|
BasicDBObject dbo = (BasicDBObject)iter.next()
|
||||||
String id = dbo.get('_id')
|
districts.add(dbo)
|
||||||
uniqueIdList.add(id)
|
|
||||||
}
|
}
|
||||||
|
if(districts.size() == totalCount) {
|
||||||
if(uniqueIdList.size() == totalCount) {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return districts
|
||||||
return new ArrayList<String>(uniqueIdList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DBObject> getRegions(String city) {
|
private List<DBObject> getRegions(String city) {
|
||||||
|
|||||||
Reference in New Issue
Block a user