常州跑批优化

This commit is contained in:
2022-06-06 18:04:58 +08:00
parent d8af072e86
commit f63bfe70e1
@@ -11,6 +11,7 @@ import com.fangjia.script.util.OpenApiClient
import com.mongodb.BasicDBObject import com.mongodb.BasicDBObject
import com.mongodb.DBCollection import com.mongodb.DBCollection
import com.mongodb.DBObject import com.mongodb.DBObject
import com.rabbitmq.client.AMQP
import net.sf.json.JSONObject import net.sf.json.JSONObject
import org.apache.poi.hssf.usermodel.HSSFWorkbook import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.bson.types.ObjectId import org.bson.types.ObjectId
@@ -46,11 +47,17 @@ class CZDataBatch extends BaseBatch{
@Override @Override
void process(Object args) { void process(Object args) {
def citys = CommonDatautils.findAllCity(); def citys = CommonDatautils.findAllCity();
citys.remove("常州"); citys.remove("常州");
citys.add(0, "常州") citys.add(0, "常州")
for(def city : citys){ for(def city : citys){
def weekend = DateUtils.getFirstDayOfWeek(new Date())
def statMap = CommonDatautils.queryAllDistrictPriceByWeekend(city, weekend)
def commids = findAllJnBankDatas(city)
def districts = converList(CommonDatautils.findAllDistricts(city, "district", fields)); def districts = converList(CommonDatautils.findAllDistricts(city, "district", fields));
districtRun(districts); districtRun(districts, statMap, commids);
def shops = CommonDatautils.findAllDistricts(city, "shop", fields); def shops = CommonDatautils.findAllDistricts(city, "shop", fields);
shops = mergeShop(shops); shops = mergeShop(shops);
@@ -117,7 +124,7 @@ class CZDataBatch extends BaseBatch{
return rMap; return rMap;
} }
def districtRun(def districts){ def districtRun(def districts, def statMap, commids){
def total = districts.size(); def total = districts.size();
def totalCount = new AtomicLong() def totalCount = new AtomicLong()
final CountDownLatch latch = new CountDownLatch(total) final CountDownLatch latch = new CountDownLatch(total)
@@ -127,7 +134,7 @@ class CZDataBatch extends BaseBatch{
void run() { void run() {
try{ try{
totalCount.addAndGet(1) totalCount.addAndGet(1)
converDistrict(district); converDistrict(district, statMap, commids);
println totalCount.get()+"/"+total +" ["+district.city+"-"+district.region+"-"+district.name+"]"; println totalCount.get()+"/"+total +" ["+district.city+"-"+district.region+"-"+district.name+"]";
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace() e.printStackTrace()
@@ -158,7 +165,7 @@ class CZDataBatch extends BaseBatch{
// executorService.awaitTermination(30, TimeUnit.MINUTES) // executorService.awaitTermination(30, TimeUnit.MINUTES)
} }
def converDistrict(def dist){ def converDistrict(def dist, def statMap, def commids){
def map = [:] def map = [:]
//楼盘编号 //楼盘编号
/* def c_id = czIdMap.get(dist.city+"#"+dist.region+"#"+dist.name) /* def c_id = czIdMap.get(dist.city+"#"+dist.region+"#"+dist.name)
@@ -179,7 +186,11 @@ class CZDataBatch extends BaseBatch{
map.estate_type2 = dist.estate_type2 map.estate_type2 = dist.estate_type2
map.build_structure = dist.build_structure map.build_structure = dist.build_structure
// 楼盘均价 // 楼盘均价
map.avg_price = getDistrictPrice(dist.city, dist.region, dist.name, dist.address, dist.block); def priceObj = statMap.get(dist.region+"#"+dist.name)
if(priceObj && priceObj.avg_price){
map.avg_price = priceObj.avg_price
}
//map.avg_price = getDistrictPrice(dist.city, dist.region, dist.name, dist.address, dist.block);
// 省 市 区 // 省 市 区
if(dist.city == "常州"){ if(dist.city == "常州"){
map.province_code = regionMap.get("江苏"); map.province_code = regionMap.get("江苏");
@@ -190,23 +201,25 @@ class CZDataBatch extends BaseBatch{
map.city = dist.city; map.city = dist.city;
map.region = dist.region; map.region = dist.region;
if(!commids.contains(map.num_id)){
// 公共服务配套
map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2);
// 基础设施
map.facilities_code = "01";
// 居住社区成熟度
map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2);
// 交通条件
map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2);
// 泊车条件 /
map.stop_car_code = getStopCarCode(dist);
// /学区房类型
map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ;
}
// 地址 // 地址
map.address = dist.address map.address = dist.address
// 所属区域 // 所属区域
map.in_region_code = getRegionCode(dist.region); map.in_region_code = getRegionCode(dist.region);
// 公共服务配套
map.public_service_set_code = getPublicServiceSetCode(dist.city, dist.lat2, dist.lng2);
// 基础设施
map.facilities_code = "01";
// 居住社区成熟度
map.sophistication_code = getSophisticationCode(dist.city, dist.lat2, dist.lng2);
// 交通条件
map.traffic_code = getTrafficCode(dist.city, dist.lat2, dist.lng2);
// 泊车条件 /
map.stop_car_code = getStopCarCode(dist);
// /学区房类型
map.school_code = getSchoolCode(dist.city, dist.region, dist.lat2, dist.lng2) ;
//绿化率 //绿化率
map.virescence_percent = getVirescencePercent(dist.virescence_percent, map.build_date); map.virescence_percent = getVirescencePercent(dist.virescence_percent, map.build_date);
//容积率 //容积率
@@ -1102,4 +1115,18 @@ class CZDataBatch extends BaseBatch{
return list; return list;
} }
def findAllJnBankDatas(city){
def q = new BasicDBObject()
q.put("city", city)
def keys = new BasicDBObject()
keys.put("num_id", 1)
def dbcursor = DIST_COLL.find(q, keys)
def set = new HashSet()
for(def d : dbcursor){
set << d.num_id
}
return set;
}
} }