Merge branch 'master' of http://gitlab.fangjia.com/dev0/main into script_gj
# Conflicts: # projects/fangjia-script/src/main/groovy/com/fangjia/script/Watcher.groovy
This commit is contained in:
@@ -530,6 +530,12 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.fangjia</groupId>-->
|
||||
<!-- <artifactId>fangjia-open</artifactId>-->
|
||||
<!-- <version>0.0.1-SNAPSHOT</version>-->
|
||||
<!-- <scope>compile</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
@@ -548,5 +554,5 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
package com.fangjia.script.majintao
|
||||
|
||||
import com.fangjia.core.RegionData
|
||||
|
||||
|
||||
import com.fangjia.core.ProvinceData
|
||||
import com.fangjia.core.util.MongoUtils
|
||||
import com.fangjia.datastore.driver.DSCollection
|
||||
import com.fangjia.datastore.driver.DataStore
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import org.bson.types.ObjectId
|
||||
|
||||
def map = [
|
||||
["学校", "高等院校", "中学", "小学", "幼儿园", "成人教育", "职业技术学校"]: "学校",
|
||||
["综合医院", "专科医院"] : "医院",
|
||||
["银行"] : "银行",
|
||||
["超级市场", "家电电子卖场", "便民商店/便利店"] : "超市",
|
||||
["商场"] : "商场",
|
||||
["美容美发店"] : "美容院",
|
||||
["健身中心"] : "健身中心",
|
||||
["公园广场", "公园"] : "公园/绿地",
|
||||
["公交车站"] : "公交",
|
||||
["飞机场"] : "机场",
|
||||
["火车站"] : "火车站",
|
||||
["快餐厅", "外国餐厅", "中餐厅"] : "餐馆",
|
||||
["宾馆酒店", "旅馆招待所"] : "酒店"
|
||||
] as HashMap<List<String>, String>
|
||||
|
||||
def type3In = ["学校", "高等院校", "中学", "小学", "幼儿园", "成人教育", "职业技术学校", "健身中心", "公园广场", "公园", "地铁站", "飞机场", "火车站"]
|
||||
// 输出 Map 的内容
|
||||
map.each { key, value ->
|
||||
println("$key: $value")
|
||||
}
|
||||
|
||||
def provinceList = []
|
||||
def provinceMap = ProvinceData.data
|
||||
provinceMap.each { pro ->
|
||||
provinceList.add(pro.getValue()[0])
|
||||
}
|
||||
def cityMap = ProvinceData.GOVERNMENT_CITY_LIST
|
||||
cityMap.each { city ->
|
||||
provinceList.add(city.getValue()[0])
|
||||
}
|
||||
def specialMap = ProvinceData.SPECIAL_ADMIN_REGION
|
||||
specialMap.each { spe ->
|
||||
provinceList.add(spe.getValue()[1])
|
||||
}
|
||||
|
||||
def pcmap = [:]
|
||||
provinceList.remove("广西省")
|
||||
provinceList.add("广西壮族自治区")
|
||||
|
||||
DSCollection seabird = new DataStore("192.168.0.43", 28017).getCollection("fangjia_base.baidu_place_poi2")
|
||||
DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "192.168.0.43", 28017)
|
||||
//def type3Not = ["学校内部设施", "进港", "出港", "候船室", "住宿服务相关"]
|
||||
//
|
||||
//def type2Not = ["学校", "专科医院", "综合医院", "诊所", "银行", "自动提款机", "便民商店/便利店", "家电电子卖场", "超级市场", "商场", "美容美发店", "地铁站", "港口码头", "住宿服务"]
|
||||
//def type2In = ["运动场馆", "公园广场", "公交车站", "机场相关", "火车站", "餐饮服务"]
|
||||
// 运动场馆 且为 健身中心
|
||||
|
||||
// 公园广场 公园广场
|
||||
//公园广场 公园
|
||||
// 公交车站 公交车站相关
|
||||
|
||||
// 机场相关 飞机场
|
||||
// 火车站 火车站
|
||||
// 餐饮服务 快餐厅 外国餐厅 中餐厅
|
||||
|
||||
println(provinceList)
|
||||
//provinceList = provinceList.subList(0,1)
|
||||
def c = 0
|
||||
def citys = []
|
||||
def citys2 = []
|
||||
|
||||
|
||||
for (p in provinceList) {
|
||||
println(p)
|
||||
def result = []
|
||||
ElasticUtils.executeSqlQuery("SELECT location,name,adname,cityname,m_date,id,address,type FROM amap_poi WHERE pname = '" + p + "'", { Map data ->
|
||||
// println(data["type"] + "-----")
|
||||
c = c+1
|
||||
if (c%10000==0){
|
||||
println("已处理$c 条")
|
||||
}
|
||||
def locationString = String.valueOf(data.get("location"))
|
||||
def typeString = String.valueOf(data.get("type"))
|
||||
def cityString = String.valueOf(data.get("cityname"))
|
||||
// citys2.add(cityS)
|
||||
// print(cityString)
|
||||
String city
|
||||
if ("台湾省".equals(cityString) | "香港特别行政区".equals(cityString) | "澳门特别行政区".equals(cityString)) {
|
||||
city = cityString
|
||||
} else {
|
||||
city = RegionData.formatCity(cityString)
|
||||
}
|
||||
def m_date = data["m_date"]
|
||||
def region = data["adname"]
|
||||
region = RegionData.formatRegion(city,region)
|
||||
def address = String.valueOf(data.get("address"))
|
||||
def uid = String.valueOf(data.get("id"))
|
||||
|
||||
def name = data.get("name")
|
||||
if (typeString.contains("|")) {
|
||||
typeString = typeString.split("'|'")[0]
|
||||
}
|
||||
// println(typeString)
|
||||
def secondType = typeString.split(";")[1]
|
||||
def smallType = typeString.split(";")[2]
|
||||
// println(smallType.getClass().getName())
|
||||
|
||||
|
||||
// 使用正则表达式匹配经度和纬度
|
||||
def matcher = locationString =~ /(-?\d+\.\d+)/
|
||||
def keyword = ""
|
||||
def flag = 0
|
||||
// 类型映射
|
||||
// 用三级分类判断
|
||||
if (smallType in type3In) {
|
||||
// 遍历Map的键集合,检查目标字符串是否存在于键集合中
|
||||
map.keySet().each { key ->
|
||||
if (key.contains(smallType)) {
|
||||
def value = map[key]
|
||||
// println("$smallType 存在于Map的键中,对应的值为: $value")
|
||||
keyword = value
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//用二级分类判断
|
||||
map.keySet().each { key ->
|
||||
if (key.contains(secondType)) {
|
||||
def value = map[key]
|
||||
// println("$secondType 存在于Map的键中,对应的值为: $value")
|
||||
keyword = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取匹配到的经度和纬度值
|
||||
def lng = matcher[0][0]
|
||||
lng = lng.toDouble()
|
||||
def lat = matcher[1][0]
|
||||
lat = lat.toDouble()
|
||||
|
||||
// println "纬度: $lng, 经度: $lat,"
|
||||
if (!"".equals(keyword)) {
|
||||
def dbo = new BasicDBObject()
|
||||
dbo["_id"] = new ObjectId()
|
||||
dbo["keyword"] = keyword
|
||||
dbo["lat"] = lat
|
||||
dbo["name"] = name
|
||||
dbo["city"] = city
|
||||
dbo["m_date"] = m_date
|
||||
dbo["lng"] = lng
|
||||
dbo["c_date"] = m_date
|
||||
dbo["address"] = address
|
||||
dbo["uid"] = uid
|
||||
dbo["status"] = 0
|
||||
dbo["source"] = "gaode"
|
||||
dbo["region"] = region
|
||||
result.add(dbo)
|
||||
}
|
||||
// print(result)
|
||||
// println("888")
|
||||
|
||||
})
|
||||
if (null != result && result.size() > 0) {
|
||||
m43.insert(result)
|
||||
}
|
||||
|
||||
println("已处理完$p 的数据")
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.fangjia.script.majintao
|
||||
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
|
||||
def count = 0
|
||||
//ElasticUtils.executeSqlQuery("SELECT * FROM seawater WHERE city = '重庆' and region = '渝北' and district_name = '棕榈泉国际花园四期'and p_date > 20230801 ",{Map doc->
|
||||
ElasticUtils.executeSqlQuery("SELECT * FROM seawater WHERE p_date > 20230801 order by p_date desc limit 100",{Map doc->
|
||||
def keys = ["c_date","_id","cat","city","region","name","address","block","district_name","total_price","area","height","floor","fitment","estate_type","hall","toilet","publish_date","url","direction","build_type","pay_type","line","rent_type","status","room"]
|
||||
// def dbo = new BasicDBObject()
|
||||
// for( String key in keys){
|
||||
// dbo[key] = doc[key]
|
||||
// }
|
||||
// println(doc['m_date'])
|
||||
// print(doc['name'])
|
||||
if (count==0)print(doc)
|
||||
count+=1
|
||||
|
||||
// DbUtils.seabird.save(dbo)
|
||||
})
|
||||
//DbUtils.seabird.find(new BasicDBObject("district_name","棕榈泉国际花园四期")).each {
|
||||
// println(it)
|
||||
//}
|
||||
print(count)
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import com.fangjia.core.ProvinceData
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.lowagie.text.Row
|
||||
import javafx.scene.control.Cell
|
||||
import jxl.Sheet
|
||||
import jxl.Workbook
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory
|
||||
|
||||
//String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表 - 副本.xlsx"
|
||||
//ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
//ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
//
|
||||
// province1 = items['A']
|
||||
// if (!province1.equals('黑龙江省') || !province1.equals('内蒙古自治区')) {
|
||||
// province = province1.substring(0, 2)
|
||||
// } else {
|
||||
// province = province1.substring(0, 3)
|
||||
// }
|
||||
//
|
||||
// println('province: ' + province)
|
||||
//
|
||||
// def citys = ProvinceData.getAllCity(province)
|
||||
// println(citys)
|
||||
//// if (citys.size() > 0) {
|
||||
//// ExcelUtils.writeToExcel(excelFilePath, citys, province)
|
||||
//// }
|
||||
//
|
||||
//})
|
||||
|
||||
|
||||
//
|
||||
//import com.fangjia.core.ProvinceData
|
||||
//
|
||||
//import com.fangjia.script.util.ExcelUtils
|
||||
//
|
||||
//
|
||||
//String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表.xlsx"
|
||||
//ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
//ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
//
|
||||
// def province1 = items['A']
|
||||
// def province
|
||||
//
|
||||
// if (!province1.equals('黑龙江省') && !province1.equals('内蒙古自治区')) {
|
||||
// province = province1.substring(0, 2)
|
||||
// } else {
|
||||
// province = province1.substring(0, 3)
|
||||
// }
|
||||
//
|
||||
// println('province: ' + province)
|
||||
//
|
||||
// def citys = ProvinceData.getAllCity(province)
|
||||
// println(citys)
|
||||
// items['D'] = citys.toString()
|
||||
//
|
||||
//})
|
||||
@@ -5,14 +5,15 @@ import com.fangjia.script.util.ExcelUtils
|
||||
import net.sf.json.JSONObject
|
||||
|
||||
|
||||
ExcelUtils.removeEmptyRow("F:\\估家\\文件\\北交所\\testcopy.xlsx")
|
||||
ExcelUtils.singleThreadingModify("F:\\估家\\文件\\北交所\\testcopy.xlsx", { List items ->
|
||||
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy.xlsx";
|
||||
String comprehensiveUrl = "http://192.168.10.15:9180/comprehensiveQuery/houseValueInformation";
|
||||
String communityUrl = "http://192.168.10.15:9180/addrSvc/avgPrice";
|
||||
String valueUrl = "http://192.168.10.15:9180/property/addressEvaluate";
|
||||
String caseUrl = "http://192.168.10.15:9180/house/case";
|
||||
String poiUrl = "http://192.168.10.15:9180/district/addrFacilitys";
|
||||
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy1.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
|
||||
String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
|
||||
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
|
||||
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
|
||||
String caseUrl = "http://open.fangjia.com/house/case";
|
||||
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.gj.village.ailiyun.SignatureUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
//def address = "江苏省徐州市贾汪区经济开发区大黄山镇孤山小区B3.801"
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
|
||||
count = count + 1
|
||||
if (count % 10 == 0) {
|
||||
println("已处理:" + count)
|
||||
}
|
||||
sleep(50)
|
||||
|
||||
def address = items['A']
|
||||
def map = SignatureUtils.getAliAddressStrc(address)
|
||||
//prov=河南省 city=信阳市 district=息县 town=孙庙乡 community=前赵楼村 road=前赵楼村 poi=爱婆店 roomno=012
|
||||
if ("prov" in map) {
|
||||
def province = map.get("prov")
|
||||
items['D'] = province
|
||||
}
|
||||
if ("city" in map) {
|
||||
def city = map.get("city")
|
||||
items['H'] = city
|
||||
}
|
||||
if ("district" in map) {
|
||||
def district = map.get("district")
|
||||
items['L'] = district
|
||||
}
|
||||
if ("town" in map) {
|
||||
def town = map.get("town")
|
||||
items['P'] = town
|
||||
}
|
||||
if ("community" in map) {
|
||||
def community = map.get("community")
|
||||
items['T'] = community
|
||||
|
||||
}
|
||||
// if ("road" in map) {
|
||||
// def road = map.get("road")
|
||||
// items['G'] = road
|
||||
//
|
||||
// }
|
||||
// if ("poi" in map) {
|
||||
//
|
||||
// def poi = map.get("poi")
|
||||
// items['H'] = poi
|
||||
//
|
||||
// }
|
||||
// if ("roomno" in map) {
|
||||
// def roomno = map.get("roomno")
|
||||
// items['I'] = roomno
|
||||
//
|
||||
// }
|
||||
// if ("devzone" in map) {
|
||||
// def devzone = map.get("devzone")
|
||||
// items['J'] = devzone
|
||||
//
|
||||
// }
|
||||
// if ("roadno" in map) {
|
||||
// def roadno = map.get("roadno")
|
||||
// items['K'] = roadno
|
||||
// }
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.gj.village.ailiyun.SignatureUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
//def address = "江苏省徐州市贾汪区经济开发区大黄山镇孤山小区B3.801"
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
|
||||
count = count + 1
|
||||
if (count % 10 == 0) {
|
||||
println("已处理:" + count)
|
||||
}
|
||||
sleep(50)
|
||||
|
||||
def address = items['A']
|
||||
def pro = items['D']
|
||||
if (pro == null) {
|
||||
|
||||
def map = SignatureUtils.getAliAddressStrc(address)
|
||||
//prov=河南省 city=信阳市 district=息县 town=孙庙乡 community=前赵楼村 road=前赵楼村 poi=爱婆店 roomno=012
|
||||
if ("prov" in map) {
|
||||
def province = map.get("prov")
|
||||
items['D'] = province
|
||||
}
|
||||
if ("city" in map) {
|
||||
def city = map.get("city")
|
||||
items['H'] = city
|
||||
}
|
||||
if ("district" in map) {
|
||||
def district = map.get("district")
|
||||
items['L'] = district
|
||||
}
|
||||
if ("town" in map) {
|
||||
def town = map.get("town")
|
||||
items['P'] = town
|
||||
}
|
||||
if ("community" in map) {
|
||||
def community = map.get("community")
|
||||
items['T'] = community
|
||||
|
||||
}
|
||||
// if ("road" in map) {
|
||||
// def road = map.get("road")
|
||||
// items['G'] = road
|
||||
//
|
||||
// }
|
||||
// if ("poi" in map) {
|
||||
//
|
||||
// def poi = map.get("poi")
|
||||
// items['H'] = poi
|
||||
//
|
||||
// }
|
||||
// if ("roomno" in map) {
|
||||
// def roomno = map.get("roomno")
|
||||
// items['I'] = roomno
|
||||
//
|
||||
// }
|
||||
// if ("devzone" in map) {
|
||||
// def devzone = map.get("devzone")
|
||||
// items['J'] = devzone
|
||||
//
|
||||
// }
|
||||
// if ("roadno" in map) {
|
||||
// def roadno = map.get("roadno")
|
||||
// items['K'] = roadno
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import net.sf.json.JSONObject
|
||||
|
||||
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\ÁÙʱÊý¾Ý\\2.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
|
||||
String url = "http://192.168.0.19:31080/FangJiaAddressService/v3/structure";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
String address = items['A']
|
||||
|
||||
def map = [:]
|
||||
map.put("address", address)
|
||||
map.put("complete", "true")
|
||||
map.put("addressAssessment", "true")
|
||||
|
||||
def content = httpRequest.getJsonContent(url, map, "UTF-8")
|
||||
def result = content.get("result")
|
||||
if ("province" in result) {
|
||||
items['B'] = result.get("province")
|
||||
}
|
||||
if ("provinceCode" in result) {
|
||||
items['C'] = result.get("provinceCode")
|
||||
}
|
||||
if ("city" in result){
|
||||
items['D'] = result.get("city")
|
||||
}
|
||||
if("cityCode" in result){
|
||||
items['E'] = result.get("cityCode")
|
||||
}
|
||||
if ("district" in result){
|
||||
|
||||
items['F'] = result.get("district")
|
||||
}
|
||||
if ("districtCode" in result){
|
||||
|
||||
items['G'] = result.get("districtCode")
|
||||
}
|
||||
if ("township" in result){
|
||||
|
||||
items['H'] = result.get("township")
|
||||
}
|
||||
if ("townshipCode" in result){
|
||||
|
||||
items['I'] = result.get("townshipCode")
|
||||
print(result.get("townshipCode"))
|
||||
}
|
||||
if ("address" in result){
|
||||
|
||||
items['J'] = result.get("address")
|
||||
}
|
||||
if ("formatAddress" in result){
|
||||
items['K'] = result.get("formatAddress")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.multiThreadingModify(excelFilePath, { List items ->
|
||||
count += 1
|
||||
if (count % 10 == 0) {
|
||||
println("已处理:" + count)
|
||||
}
|
||||
|
||||
|
||||
String address = items['A']
|
||||
String province = items['B']
|
||||
if (province == null) {
|
||||
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
|
||||
def map = [:]
|
||||
map.put("address", address)
|
||||
map.put("complete", "true")
|
||||
map.put("addressAssessment", "true")
|
||||
map.put("type", "1")
|
||||
|
||||
def content = httpRequest.getJsonContent(url, map, "UTF-8")
|
||||
def result = content.get("result")
|
||||
if (result != null) {
|
||||
if ("province" in result) {
|
||||
items['B'] = result.get("province")
|
||||
}
|
||||
if ("provinceCode" in result) {
|
||||
items['C'] = result.get("provinceCode")
|
||||
}
|
||||
if ("city" in result) {
|
||||
items['D'] = result.get("city")
|
||||
}
|
||||
if ("cityCode" in result) {
|
||||
items['E'] = result.get("cityCode")
|
||||
}
|
||||
if ("district" in result) {
|
||||
|
||||
items['F'] = result.get("district")
|
||||
}
|
||||
if ("districtCode" in result) {
|
||||
|
||||
items['G'] = result.get("districtCode")
|
||||
}
|
||||
if ("town" in result) {
|
||||
|
||||
items['H'] = result.get("town")
|
||||
}
|
||||
if ("townCode" in result) {
|
||||
|
||||
items['I'] = result.get("townCode")
|
||||
}
|
||||
|
||||
if ("committee" in result) {
|
||||
|
||||
items['J'] = result.get("committee")
|
||||
}
|
||||
if ("committeeCode" in result) {
|
||||
|
||||
items['K'] = result.get("committeeCode")
|
||||
}
|
||||
if ("typeCode" in result) {
|
||||
|
||||
items['L'] = result.get("typeCode")
|
||||
}
|
||||
if ("typeName") {
|
||||
items['M'] = result.get("typeName")
|
||||
}
|
||||
if ("verifyFlag") {
|
||||
items['N'] = result.get("verifyFlag")
|
||||
}
|
||||
if ("addrVerify") {
|
||||
items['O'] = result.get("addrVerify")
|
||||
}
|
||||
if ("countyLevelCity") {
|
||||
items['P'] = result.get("countyLevelCity")
|
||||
}
|
||||
if ("countyGov") {
|
||||
items['Q'] = result.get("countyGov")
|
||||
}
|
||||
if ("communitySource") {
|
||||
items['R'] = result.get("communitySource")
|
||||
}
|
||||
|
||||
if ("administrativeTowns" in result) {
|
||||
items['T'] = result.get("administrativeTowns")
|
||||
}
|
||||
if ("devDistrict" in result) {
|
||||
items['V'] = result.get("devDistrict")
|
||||
}
|
||||
if ("devDistrictName" in result) {
|
||||
items['W'] = result.get("devDistrictName")
|
||||
}
|
||||
if ("splitCommittee" in result) {
|
||||
items['X'] = result.get("splitCommittee")
|
||||
}
|
||||
if ("splitStreet" in result) {
|
||||
items['Y'] = result.get("splitStreet")
|
||||
}
|
||||
if ("poiName" in result) {
|
||||
items['Z'] = result.get("poiName")
|
||||
}
|
||||
if ("splitStreetNum" in result) {
|
||||
items['AA'] = result.get("splitStreetNum")
|
||||
}
|
||||
if ("dev" in result) {
|
||||
items['AB'] = result.get("dev")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\对公.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
count+=1
|
||||
if (count%10==0){
|
||||
println("已处理:"+count)
|
||||
}
|
||||
|
||||
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
String address = items['A']
|
||||
// print(address)
|
||||
|
||||
// province;
|
||||
// city;
|
||||
// district;
|
||||
// town;
|
||||
// committee;
|
||||
// type;
|
||||
// provinceCode;
|
||||
// cityCode;
|
||||
// districtCode;
|
||||
// townCode;
|
||||
// committeeCode;
|
||||
// typeCode;
|
||||
// typeName;
|
||||
// verifyFlag;//涉农标识
|
||||
// addrVerify;//地址是否有效信息
|
||||
// countyLevelCity;//是否为县级市
|
||||
// administrativeTowns;//是否市辖建制镇
|
||||
// countyGov;//是否为县政府
|
||||
// devDistrict;//是否为开发区
|
||||
// devDistrictName;//开发区
|
||||
// splitCommittee;
|
||||
// splitStreet;
|
||||
// poiName;
|
||||
// splitStreetNum;
|
||||
// dev;
|
||||
// communitySource;//居委来源
|
||||
|
||||
def map = [:]
|
||||
map.put("address", address)
|
||||
map.put("complete", "true")
|
||||
map.put("addressAssessment", "true")
|
||||
map.put("type", "2")
|
||||
|
||||
def content = httpRequest.getJsonContent(url, map, "UTF-8")
|
||||
def result = content.get("result")
|
||||
if ("province" in result) {
|
||||
items['B'] = result.get("province")
|
||||
}
|
||||
if ("provinceCode" in result) {
|
||||
items['C'] = result.get("provinceCode")
|
||||
}
|
||||
if ("city" in result){
|
||||
items['D'] = result.get("city")
|
||||
}
|
||||
if("cityCode" in result){
|
||||
items['E'] = result.get("cityCode")
|
||||
}
|
||||
if ("district" in result){
|
||||
|
||||
items['F'] = result.get("district")
|
||||
}
|
||||
if ("districtCode" in result){
|
||||
|
||||
items['G'] = result.get("districtCode")
|
||||
}
|
||||
if ("town" in result){
|
||||
|
||||
items['H'] = result.get("town")
|
||||
}
|
||||
if ("townCode" in result){
|
||||
|
||||
items['I'] = result.get("townCode")
|
||||
}
|
||||
|
||||
if ("committee" in result){
|
||||
|
||||
items['J'] = result.get("committee")
|
||||
}
|
||||
if ("committeeCode" in result){
|
||||
|
||||
items['K'] = result.get("committeeCode")
|
||||
}
|
||||
if ("typeCode" in result){
|
||||
|
||||
items['L'] = result.get("typeCode")
|
||||
}
|
||||
if ("typeName"){
|
||||
items['M'] = result.get("typeName")
|
||||
}
|
||||
if ("verifyFlag"){
|
||||
items['N'] = result.get("verifyFlag")
|
||||
}
|
||||
if ("addrVerify"){
|
||||
items['O'] = result.get("addrVerify")
|
||||
}
|
||||
if ("countyLevelCity"){
|
||||
items['P'] = result.get("countyLevelCity")
|
||||
}
|
||||
if ("countyGov"){
|
||||
items['Q'] = result.get("countyGov")
|
||||
}
|
||||
if ("communitySource"){
|
||||
items['R'] = result.get("communitySource")
|
||||
}
|
||||
|
||||
if ("administrativeTowns" in result){
|
||||
items['T'] = result.get("administrativeTowns")
|
||||
}
|
||||
if ("devDistrict" in result){
|
||||
items['V'] = result.get("devDistrict")
|
||||
}
|
||||
if ("devDistrictName" in result){
|
||||
items['W'] = result.get("devDistrictName")
|
||||
}
|
||||
if ("splitCommittee" in result){
|
||||
items['X'] = result.get("splitCommittee")
|
||||
}
|
||||
if ("splitStreet" in result){
|
||||
items['Y'] = result.get("splitStreet")
|
||||
}
|
||||
if ("poiName" in result){
|
||||
items['Z'] = result.get("poiName")
|
||||
}
|
||||
if ("splitStreetNum" in result){
|
||||
items['AA'] = result.get("splitStreetNum")
|
||||
}
|
||||
if ("dev" in result){
|
||||
items['AB'] = result.get("dev")
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据 - 副本.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
count += 1
|
||||
if (count % 10 == 0) {
|
||||
println("已处理:" + count)
|
||||
}
|
||||
|
||||
|
||||
String flag = items['X']
|
||||
String address = items['A']
|
||||
String tt = items['Y']
|
||||
if (flag == null&&"地址有效".equals(tt)) {
|
||||
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
|
||||
def map = [:]
|
||||
map.put("address", address)
|
||||
map.put("complete", "true")
|
||||
map.put("addressAssessment", "true")
|
||||
map.put("type", "1")
|
||||
|
||||
def content = httpRequest.getJsonContent(url, map, "UTF-8")
|
||||
def result = content.get("result")
|
||||
if (result != null) {
|
||||
if ("verifyFlag" in result) {
|
||||
items['X'] = result.get("verifyFlag")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
|
||||
|
||||
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\ÄϾ©ÒøÐвâÊÔ.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
def count = 0
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
count+=1
|
||||
if (count%10==0){
|
||||
println("ÒÑ´¦Àí£º"+count)
|
||||
}
|
||||
|
||||
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
String address = items['A']
|
||||
|
||||
def map = [:]
|
||||
map.put("address", address)
|
||||
map.put("complete", "true")
|
||||
map.put("addressAssessment", "true")
|
||||
map.put("type", "2")
|
||||
|
||||
def content = httpRequest.getJsonContent(url, map, "UTF-8")
|
||||
def result = content.get("result")
|
||||
if ("province" in result) {
|
||||
items['B'] = result.get("province")
|
||||
}
|
||||
if ("provinceCode" in result) {
|
||||
items['C'] = result.get("provinceCode")
|
||||
}
|
||||
if ("city" in result){
|
||||
items['D'] = result.get("city")
|
||||
}
|
||||
if("cityCode" in result){
|
||||
items['E'] = result.get("cityCode")
|
||||
}
|
||||
if ("district" in result){
|
||||
|
||||
items['F'] = result.get("district")
|
||||
}
|
||||
if ("districtCode" in result){
|
||||
|
||||
items['G'] = result.get("districtCode")
|
||||
}
|
||||
if ("town" in result){
|
||||
|
||||
items['H'] = result.get("town")
|
||||
}
|
||||
if ("townCode" in result){
|
||||
|
||||
items['I'] = result.get("townCode")
|
||||
}
|
||||
|
||||
if ("committee" in result){
|
||||
|
||||
items['J'] = result.get("committee")
|
||||
}
|
||||
if ("committeeCode" in result){
|
||||
|
||||
items['K'] = result.get("committeeCode")
|
||||
}
|
||||
if ("typeCode" in result){
|
||||
|
||||
items['L'] = result.get("typeCode")
|
||||
}
|
||||
if ("typeName"){
|
||||
items['M'] = result.get("typeName")
|
||||
}
|
||||
if ("verifyFlag"){
|
||||
items['N'] = result.get("verifyFlag")
|
||||
}
|
||||
if ("addrVerify"){
|
||||
items['O'] = result.get("addrVerify")
|
||||
}
|
||||
if ("countyLevelCity"){
|
||||
items['P'] = result.get("countyLevelCity")
|
||||
}
|
||||
if ("countyGov"){
|
||||
items['Q'] = result.get("countyGov")
|
||||
}
|
||||
// if ("communitySource"){
|
||||
// items['R'] = result.get("communitySource")
|
||||
// }
|
||||
//
|
||||
// if ("administrativeTowns" in result){
|
||||
// items['T'] = result.get("administrativeTowns")
|
||||
// }
|
||||
// if ("devDistrict" in result){
|
||||
// items['V'] = result.get("devDistrict")
|
||||
// }
|
||||
// if ("devDistrictName" in result){
|
||||
// items['W'] = result.get("devDistrictName")
|
||||
// }
|
||||
// if ("splitCommittee" in result){
|
||||
// items['X'] = result.get("splitCommittee")
|
||||
// }
|
||||
// if ("splitStreet" in result){
|
||||
// items['Y'] = result.get("splitStreet")
|
||||
// }
|
||||
// if ("poiName" in result){
|
||||
// items['Z'] = result.get("poiName")
|
||||
// }
|
||||
// if ("splitStreetNum" in result){
|
||||
// items['AA'] = result.get("splitStreetNum")
|
||||
// }
|
||||
// if ("dev" in result){
|
||||
// items['AB'] = result.get("dev")
|
||||
// }
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.fangjia.script.majintao.test
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import net.sf.json.JSONObject
|
||||
|
||||
|
||||
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy1.xlsx";
|
||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||
|
||||
String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
|
||||
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
|
||||
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
|
||||
String caseUrl = "http://open.fangjia.com/house/case";
|
||||
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
|
||||
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
map = new HashMap<String, String>()
|
||||
|
||||
String city = items['A']
|
||||
String address = items['B']
|
||||
double size = items['C']
|
||||
|
||||
System.out.println(city + "---" + address + "----" + size);
|
||||
|
||||
map.put("city", city)
|
||||
map.put("address", address)
|
||||
map.put("size", size.toString())
|
||||
map.put("strctureArea", size.toString())
|
||||
map.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB")
|
||||
|
||||
if (!address.contains("%")) {
|
||||
// 发送HTTP请求
|
||||
long start
|
||||
long end
|
||||
|
||||
// start = System.currentTimeMillis();
|
||||
// httpRequest.getJsonContent(communityUrl, map, "UTF-8")
|
||||
//
|
||||
//
|
||||
// end = System.currentTimeMillis();
|
||||
// items['D'] = String.valueOf(end - start);
|
||||
//
|
||||
// start = System.currentTimeMillis();
|
||||
// httpRequest.getJsonContent(valueUrl, map, "UTF-8")
|
||||
// end = System.currentTimeMillis();
|
||||
// items['E'] = String.valueOf(end - start);
|
||||
//
|
||||
// start = System.currentTimeMillis();
|
||||
// httpRequest.getJsonContent(caseUrl, map, "UTF-8")
|
||||
// end = System.currentTimeMillis();
|
||||
// items['F'] = String.valueOf(end - start);
|
||||
//
|
||||
// start = System.currentTimeMillis();
|
||||
// httpRequest.getJsonContent(poiUrl, map, "UTF-8")
|
||||
// end = System.currentTimeMillis();
|
||||
// items['G'] = String.valueOf(end - start);
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
|
||||
end = System.currentTimeMillis();
|
||||
items['H'] = String.valueOf(end - start);
|
||||
println content.get("msg")
|
||||
if(content.get("msg").contains("该地址不支持估价!")) {
|
||||
items['I'] = "该地址不支持估价!"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import org.bson.types.ObjectId
|
||||
|
||||
a = new ObjectId()
|
||||
print(a)
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import com.fangjia.datastore.driver.DSCollection
|
||||
import com.fangjia.datastore.driver.DataStore
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
|
||||
//@BatchOwner(Watcher.MaJinTao)
|
||||
class CommunityHouseSampleBatch extends BaseBatch {
|
||||
|
||||
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
|
||||
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
|
||||
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
|
||||
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
|
||||
|
||||
static void main(String[] args) {
|
||||
runBatch(new CommunityHouseSampleBatch(), args)
|
||||
}
|
||||
|
||||
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
|
||||
// 查本小区的房源
|
||||
def houseQuery = new BasicDBObject()
|
||||
houseQuery.put("cat", "sell")
|
||||
houseQuery.put("city", district_stat.city)
|
||||
houseQuery.put("region", district_stat.region)
|
||||
houseQuery.put("district_name", district_stat.district_name)
|
||||
def houseListAll = SEABIRD.find(houseQuery).toList()
|
||||
|
||||
// 将均价符合的房源放入结果集
|
||||
def houseList = houseListAll.findAll() { housecase ->
|
||||
def totalPrice = housecase.total_price
|
||||
def houseArea = housecase.area
|
||||
def houseAvgPrice = totalPrice / houseArea
|
||||
def avgPrice = district_stat.avg_price
|
||||
houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2
|
||||
}
|
||||
|
||||
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
|
||||
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
|
||||
for (def housecase : houseList) {
|
||||
if (housecase.area <= 200) {
|
||||
def area = housecase.area.toInteger()
|
||||
def key = "g" + (area / 10).toInteger() * 10
|
||||
def gList = houseMap.get(key)
|
||||
|
||||
if (gList == null || gList.size() == 0) {
|
||||
def gHouseCaseList = []
|
||||
gHouseCaseList.add(housecase)
|
||||
houseMap.put(key, gHouseCaseList)
|
||||
} else if (gList.size() < 10) {
|
||||
gList.add(housecase)
|
||||
houseMap.put(key, gList)
|
||||
}
|
||||
} else {
|
||||
def area = housecase.area.toInteger()
|
||||
def startPoint = 200
|
||||
def segmentSize = 30
|
||||
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
|
||||
def key = "g" + rangeStart
|
||||
def gList = houseMap.get(key)
|
||||
|
||||
if (gList == null || gList.size() == 0) {
|
||||
def gHouseCaseList = []
|
||||
gHouseCaseList.add(housecase)
|
||||
houseMap.put(key, gHouseCaseList)
|
||||
} else if (gList.size() < 10) {
|
||||
gList.add(housecase)
|
||||
houseMap.put(key, gList)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(Object args) {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(5)
|
||||
|
||||
try {
|
||||
def cityList = CommonUtils.findAllCity()
|
||||
// 测试
|
||||
cityList = cityList.subList(0, 5)
|
||||
cityList.each { city ->
|
||||
executorService.submit({
|
||||
def count = 0
|
||||
def documents = []
|
||||
def weekend = DateUtils.getFirstDayOfWeek(new Date())
|
||||
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
|
||||
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
|
||||
|
||||
// 测试
|
||||
districts = districts.subList(0, 10)
|
||||
|
||||
districts.each { district ->
|
||||
Map<String, List> houseMap = [:]
|
||||
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
|
||||
|
||||
if (district_stat != null) {
|
||||
findHouseCase(district_stat, houseMap)
|
||||
}
|
||||
if (houseMap == null || houseMap.size() == 0) {
|
||||
def aroundDistrictList = DbUtils.findAroundDistrictByRadius(district, 3000)
|
||||
// def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
|
||||
aroundDistrictList.each { aroundDistrict ->
|
||||
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
|
||||
if (aroundDistrict_stat != null) {
|
||||
findHouseCase(aroundDistrict_stat, houseMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def document = new BasicDBObject()
|
||||
document.put("city", district.city)
|
||||
document.put("region", district.region)
|
||||
document.put("district_name", district.name)
|
||||
document.put("house_case", houseMap)
|
||||
|
||||
documents.add(document)
|
||||
count++
|
||||
if (count % 10 == 0) {
|
||||
println(city + "已处理小区数----------------------------------------------------" + count)
|
||||
}
|
||||
}
|
||||
HOUSE_CASE.insert(documents)
|
||||
} as Runnable)
|
||||
}
|
||||
} finally {
|
||||
executorService.shutdown()
|
||||
executorService.awaitTermination(Long.MAX_VALUE, java.util.concurrent.TimeUnit.NANOSECONDS)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
package com.fangjia.script.sync
|
||||
|
||||
import com.fangjia.datastore.driver.DSCollection
|
||||
import com.fangjia.datastore.driver.DataStore
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
|
||||
|
||||
@BatchOwner(Watcher.MaJinTao)
|
||||
class CommunityHouseSampleBatch extends BaseBatch {
|
||||
|
||||
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
|
||||
|
||||
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
|
||||
|
||||
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
|
||||
|
||||
// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "192.168.0.43", 28017)
|
||||
|
||||
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
|
||||
|
||||
static void main(String[] args) {
|
||||
runBatch(new CommunityHouseSampleBatch(), args)
|
||||
}
|
||||
|
||||
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
|
||||
|
||||
// 查本小区的房源
|
||||
def houseQuery = new BasicDBObject()
|
||||
//houseQuery.put("city", "深圳")
|
||||
|
||||
//houseQuery.put("region", "福田")
|
||||
|
||||
//houseQuery.put("district_name", "中泰燕南名庭")
|
||||
|
||||
houseQuery.put("cat", "sell")
|
||||
|
||||
houseQuery.put("city", district_stat.city)
|
||||
|
||||
houseQuery.put("region", district_stat.region)
|
||||
|
||||
houseQuery.put("district_name", district_stat.district_name)
|
||||
|
||||
def houseListAll = SEABIRD.find(houseQuery).toList()
|
||||
|
||||
// 将均价符合的房源放入结果集
|
||||
def houseList = houseListAll.findAll() { housecase ->
|
||||
def totalPrice = housecase.total_price
|
||||
def houseArea = housecase.area
|
||||
def houseAvgPrice = totalPrice / houseArea
|
||||
def avgPrice = district_stat.avg_price
|
||||
if (houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
|
||||
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
|
||||
|
||||
for (def housecase : houseList) {
|
||||
if (housecase.area <= 200) {
|
||||
def area = housecase.area.toInteger()
|
||||
|
||||
def key = "g" + (area / 10).toInteger() * 10
|
||||
// println(key)
|
||||
// 获取该面积段的房源列表
|
||||
def gList = houseMap.get(key)
|
||||
|
||||
// 如果为空,说明该面积段没有房源,新建一个list,放入
|
||||
if (gList == null || gList.size() == 0) {
|
||||
def gHouseCaseList = []
|
||||
gHouseCaseList.add(housecase)
|
||||
houseMap.put(key, gHouseCaseList)
|
||||
} else {
|
||||
// 如果该面积段已经有10个房源,就不再放入
|
||||
if (gList.size() < 10) {
|
||||
// 如果不为空,说明该面积段已经有房源,直接放入
|
||||
gList.add(housecase)
|
||||
houseMap.put(key, gList)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
def area = housecase.area.toInteger()
|
||||
def startPoint = 200
|
||||
def segmentSize = 30
|
||||
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
|
||||
def key = "g" + rangeStart
|
||||
// println(key)
|
||||
// 获取该面积段的房源列表
|
||||
def gList = houseMap.get(key)
|
||||
|
||||
// 如果为空,说明该面积段没有房源,新建一个list,放入
|
||||
if (gList == null || gList.size() == 0) {
|
||||
def gHouseCaseList = []
|
||||
gHouseCaseList.add(housecase)
|
||||
houseMap.put(key, gHouseCaseList)
|
||||
} else {
|
||||
// 如果该面积段已经有10个房源,就不再放入
|
||||
if (gList.size() < 10) {
|
||||
gList.add(housecase)
|
||||
houseMap.put(key, gList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(Object args) {
|
||||
|
||||
|
||||
def count = 0
|
||||
|
||||
|
||||
def cityList = CommonUtils.findAllCity()
|
||||
|
||||
// 测试用,先只取一条
|
||||
// cityList = cityList.subList(0, 1)
|
||||
|
||||
print(cityList.size())
|
||||
print(cityList.toString())
|
||||
// cityList.each { city ->
|
||||
def city = cityList.get(0)
|
||||
print(city)
|
||||
def documents = []
|
||||
//查询该城市的所有小区
|
||||
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
|
||||
|
||||
//测试用,先只取5个小区
|
||||
// districts = districts.subList(0, 2)
|
||||
|
||||
// 查询所有的小区均价
|
||||
|
||||
def weekend = DateUtils.getFirstDayOfWeek(new Date());
|
||||
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
|
||||
for (def district : districts) {
|
||||
Map<String, List> houseMap = [:]
|
||||
|
||||
|
||||
|
||||
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
|
||||
// 拿到小区对应的均价之后,去查房源
|
||||
if (district_stat != null) {
|
||||
findHouseCase(district_stat, houseMap)
|
||||
|
||||
}
|
||||
// 没有拿到小区对应的均价,找小区周边的三十个小区
|
||||
|
||||
def aroundDistrictListAll = DbUtils.findAroundDistrictByRadius(district, 3000)
|
||||
def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
|
||||
|
||||
|
||||
// 遍历周边小区,找到均价符合的房源
|
||||
|
||||
aroundDistrictList.each { aroundDistrict ->
|
||||
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
|
||||
// 拿到小区对应的均价之后,去查房源
|
||||
if (aroundDistrict_stat != null) {
|
||||
findHouseCase(aroundDistrict_stat, houseMap)
|
||||
}
|
||||
}
|
||||
print(houseMap)
|
||||
|
||||
// 创建一个新的文档
|
||||
def document = new BasicDBObject()
|
||||
|
||||
// 将 houseMap 和 communityStr 放入文档
|
||||
document.put("city", district.city)
|
||||
document.put("region", district.region)
|
||||
document.put("district_name", district.name)
|
||||
document.put("house_case", houseMap)
|
||||
|
||||
// 将文档插入到 MongoDB 中
|
||||
// HOUSE_CASE.in(document)
|
||||
|
||||
documents.add(document)
|
||||
count++
|
||||
if (count % 10 == 0) {
|
||||
print("已处理小区数----------------------------------------------------" + count)
|
||||
}
|
||||
}
|
||||
HOUSE_CASE.insert(documents)
|
||||
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ public class ExcelUtils{
|
||||
|
||||
def data = ExcelUtils.read(fileName, srcSheetIndex, 0)
|
||||
def body = data.subList(1, data.size())
|
||||
def nThread = Runtime.getRuntime().availableProcessors() * 3
|
||||
def nThread = 10
|
||||
println nThread
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(3)
|
||||
final AtomicInteger counter = new AtomicInteger(0)
|
||||
|
||||
Reference in New Issue
Block a user