重庆农商行导出
This commit is contained in:
+42
-23
@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.district.Distance
|
||||
import com.fangjia.script.gj.ccb.FileUtils
|
||||
import com.fangjia.script.lixue.util.DBUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
@@ -45,28 +46,23 @@ class AroundExportByNewWay {
|
||||
def district_code = district.get(2)
|
||||
def name = district.get(3)
|
||||
List result = []
|
||||
if (district.get(20) != null && district.get(21) != null) {
|
||||
if (district.size() > 21 && district.get(20) != null && district.get(21) != null) {
|
||||
def lng = com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, district.get(20) / 10000000000d)
|
||||
def lat = com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, district.get(21) / 10000000000d)
|
||||
calcAroundInfo(lat, lng, result, id)
|
||||
|
||||
// 周围半径为3千米
|
||||
def mapLatLng = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 3000)
|
||||
DBObject q = new BasicDBObject()
|
||||
q.put('status', 0)
|
||||
q.put('lat', new BasicDBObject(QueryOperators.LTE, mapLatLng.maxLat).append(QueryOperators.GTE, mapLatLng.minLat));
|
||||
q.put('lng', new BasicDBObject(QueryOperators.LTE, mapLatLng.maxLng).append(QueryOperators.GTE, mapLatLng.minLng));
|
||||
poiConn.find(q, new BasicDBObject("name": 1, "distance": 1, "type": 1, "typecode": 1, "lat": 1, "lng": 1)).batchSize(500).each {obj ->
|
||||
double distance = Distance.GetDistance(lng, lat, obj.lng, obj.lat)
|
||||
if (distance <= 3000) {
|
||||
if (distance == 0) {
|
||||
distance = 50
|
||||
}
|
||||
def ret = []
|
||||
ret[0] = id
|
||||
ret[1] = obj.name
|
||||
ret[2] = formatType(obj.typecode)
|
||||
ret[3] = distance.toInteger()
|
||||
result << ret
|
||||
} else if (district.size() >24 &&district.get(22) != null && district.get(23) != null && district.get(24) != null) {
|
||||
DBObject query = new BasicDBObject()
|
||||
query.put("city", district.get(22))
|
||||
query.put("region", district.get(23))
|
||||
query.put("cat", "district")
|
||||
query.put("visible", 0)
|
||||
query.put("name", district.get(24))
|
||||
DBUtils.seaweed.find(query, new BasicDBObject("lng", 1).append("lat", 1)).limit(1).each {obj ->
|
||||
if (obj.lng && obj.lat) {
|
||||
def lng = com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, obj.lng/ 10000000000d)
|
||||
def lat = com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, obj.lat / 10000000000d)
|
||||
calcAroundInfo(lat, lng, result, id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -81,7 +77,7 @@ class AroundExportByNewWay {
|
||||
resultMap.put(district_code + name, result)
|
||||
println("当前处理" + count.incrementAndGet() )
|
||||
} catch (Exception ex) {
|
||||
|
||||
ex.printStackTrace()
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
@@ -113,14 +109,37 @@ class AroundExportByNewWay {
|
||||
map.put(key++, ret)
|
||||
//com.fangjia.script.util.ExcelUtils.write("F:\\数据\\重庆农商行\\周边配套.xlsx", ret, "周边配套");
|
||||
for (Integer k : map.keySet()) {
|
||||
FileUtils.batchCreateFile(map.get(k), "F:\\数据\\重庆农商行\\周边配套"+ k + ".dat", headArr, "utf-8")
|
||||
//EasyExcel.write("F:\\数据\\重庆农商行\\周边配套"+ + k + ".xlsx").head(head).sheet("周边配套").doWrite(map.get(k));
|
||||
//FileUtils.batchCreateFile(map.get(k), "F:\\数据\\重庆农商行\\周边配套"+ k + ".dat", headArr, "utf-8")
|
||||
EasyExcel.write("F:\\数据\\重庆农商行\\周边配套"+ + k + ".xlsx").head(head).sheet("周边配套").doWrite(map.get(k));
|
||||
}
|
||||
//printUnMatched(unMatchedMap)
|
||||
printUnMatched(unMatchedMap)
|
||||
executorService.shutdown()
|
||||
|
||||
}
|
||||
|
||||
static calcAroundInfo(def lat, def lng, def result, def id) {
|
||||
// 周围半径为3千米
|
||||
def mapLatLng = CommonDatautils.findMaxLatLngMinLatLng(lat, lng, 3000)
|
||||
DBObject q = new BasicDBObject()
|
||||
q.put('status', 0)
|
||||
q.put('lat', new BasicDBObject(QueryOperators.LTE, mapLatLng.maxLat).append(QueryOperators.GTE, mapLatLng.minLat));
|
||||
q.put('lng', new BasicDBObject(QueryOperators.LTE, mapLatLng.maxLng).append(QueryOperators.GTE, mapLatLng.minLng));
|
||||
poiConn.find(q, new BasicDBObject("name": 1, "distance": 1, "type": 1, "typecode": 1, "lat": 1, "lng": 1)).batchSize(500).each {obj ->
|
||||
double distance = Distance.GetDistance(lng, lat, obj.lng, obj.lat)
|
||||
if (distance <= 3000) {
|
||||
if (distance == 0) {
|
||||
distance = 50
|
||||
}
|
||||
def ret = []
|
||||
ret[0] = id
|
||||
ret[1] = obj.name
|
||||
ret[2] = formatType(obj.typecode)
|
||||
ret[3] = distance.toInteger()
|
||||
result << ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static printUnMatched(def unMatchedMap) {
|
||||
def ret = []
|
||||
ret << ['IDB','城市名称','区域编码','小区名称','楼栋号', '经度', '纬度']
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class POIRule {
|
||||
//db.getCollection('gaode_address_poi').update({'name': /[ABCD]+幢/, 'status': 0}, {$set: {'status': NumberInt(1), 'flag': '包含幢'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'name': /[ABCD]+馆/, 'typecode': {$in: ['060102', '060101']}, 'status': 0}, {$set: {'status': NumberInt(1), 'flag': '包含馆'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'name': /[ABCDE1234567890]+区/, 'typecode': {$nin: ['150700']}, 'status': 0}, {$set: {'status': NumberInt(1), 'flag': '包含区'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'name': /[ABCD]口/, 'typecode': {$nin: ['150700']}, 'status': 2}, {$set: {'status': NumberInt(1), 'flag': '包含入口'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'name': /[ABCDEFHG]口/, 'typecode': {$nin: ['150700']}, 'status': 2}, {$set: {'status': NumberInt(1), 'flag': '包含入口'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'name': /入口/, 'typecode': {$nin: ['150700']}, 'status': 0}, {$set: {'status': NumberInt(1), 'flag': '包含入口'}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'type': /医疗保健服务;专科医院;整形美容/}, {$set: {'status': NumberInt(1)}}, {multi:true,upsert:false});
|
||||
//db.getCollection('gaode_address_poi').update({'type': /科教文化服务;学校;职业技术学校/}, {$set: {'status': NumberInt(1)}}, {multi:true,upsert:false});
|
||||
|
||||
Reference in New Issue
Block a user