This commit is contained in:
2024-01-12 13:23:51 +08:00
parent 9e2278d113
commit cf41916ef3
6 changed files with 254 additions and 7 deletions
@@ -52,7 +52,7 @@ class GuiDingPriceBatch extends BaseBatch{
def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city)
//添加自己库中的人工指导价
def prices = CcbCommonUtils.findPersonPrice(city, "2023-11-26", "2023-12-27")
def prices = CcbCommonUtils.findPersonPrice(city, "2023-12-27", "2024-01-10")
// def prices = CcbCommonUtils.findPersonPrice(city, "2022-01-01", "2022-11-22")
if(prices){
def distMap = getDistrictMap(city)
@@ -158,7 +158,6 @@ class PoiLocation {
gmap.lat = DataHandleUtils.getDoubleRound(6, gmap.lat)
}
return location;
}
return null;
}
@@ -1,10 +1,17 @@
package com.fangjia.script.gj.abc
import com.fangjia.core.RegionData
import com.fangjia.script.ccbevaluation.CcbCommonUtils
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.gj.district.FangjiaClientUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.GeoHelper
import com.fangjia.script.util.OpenApiClient
import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBObject
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CountDownLatch
@@ -19,11 +26,223 @@ class SuzouPocTest {
static main(args) {
def task = new SuzouPocTest()
task.run()
// task.run()
task.newRun()
}
def newRun(){
println("start:"+new Date().toString())
def filePath = "D:\\数据\\江苏农行\\江苏农1500条-test.xlsx"
newMatch(filePath)
addEvalutePrice(filePath)
addLation(filePath)
addAroundPrice(filePath)
println("end:"+new Date().toString())
}
def newMatch(filePath){
ExcelUtils.multiThreadingModify(filePath, { d ->
if(d['G']){
def city = d['B']
def address = d['E']
def name = d['G']
def region = d['C']
if(region && name){
address = region + name
}
city = RegionData.formatCity(city)
if(region){
region = RegionData.formatRegion(city, region)
}
def obj = CommonDatautils.findDistrict(city, region, name.trim(), "district");
if(obj){
d['M'] = obj._id.toString()
d['N'] = obj.get("city")
d['O'] = obj.get("region")
d['P'] = obj.get("name")
if(obj.lng){
d['Q'] = obj.get("lng")/10000000000.0
d['R'] = obj.get("lat")/10000000000.0
}
d['S'] = "直接从库中查询"
}else{
//新的匹配算法
def jsonObject = FangjiaClientUtils.newMatch(city, address, "property", false)
if(!jsonObject && !jsonObject.containsKey("result")){
jsonObject = FangjiaClientUtils.newMatch(city, address, "property", true)
}
if(!jsonObject && !jsonObject.containsKey("result")){
def newAddr = d['E']
if(!d['E'].contains(d['C'])){
newAddr = d['C'] + d['E']
}
jsonObject = FangjiaClientUtils.newMatch(city, newAddr, "property", true)
}
if(!jsonObject){
//老匹配
jsonObject = OpenApiClient.addressMatch(city, address, null, false, region, name)
if(jsonObject && jsonObject.credit>0){
d['S'] = "老匹配"
}
}
if (jsonObject != null && !jsonObject.containsKey("result")) {
d['M'] = jsonObject.get("id")
d['N'] = jsonObject.get("city")
d['O'] = jsonObject.get("district")
d['P'] = jsonObject.get("name")
d['Q'] = jsonObject.get("lng")
d['R'] = jsonObject.get("lat")
}
}
}
});
}
def addEvalutePrice(filePath){
ExcelUtils.multiThreadingModify(filePath, { d ->
def city = d['N']
if(city && !d['J']){
def region = d['O']
def name = d['P']
def area = d['F']
def address = d['E']
def floor = null
if (d['H'] && d['H'].toString().isNumber()) {
floor = d['H'].toString().toDouble().toInteger().toString()
}
def height = null
if (d['J'] && d['J'].toString().isNumber()) {
height = d['J'].toString().toDouble().toInteger().toString()
}
def ret1 = OpenApiClient.addressEvaluation(city, region, name, name, area, floor, height)
if (ret1) {
d['J'] = ret1.totalPrice
d['K'] = ret1.avgPrice
}else{
def priceObj = CommonDatautils.findDistrictPrice(city, region, name)
if(priceObj){
d['K'] = priceObj.avg_price_2b
if(area && area.toString().isNumber() && !area.toString().contains("+")){
d['J'] = (int)(area.toString().toDouble()*priceObj.avg_price_2b)
}
}
}
}
})
}
def addLation(filePath){
ExcelUtils.multiThreadingModify(filePath, { d ->
def city = d['B']
if(city && !d['J']){
def address = d['E']
def map = parserByGaode(city, address)
if(map){
d['Q'] = map.lng
d['R'] = map.lat
d['T'] = "地址反解析经纬度"
}
}
})
}
def parserByGaode(def city, def address){
def json = GaoDeApiUtils.geo(city, address)
println json
if(json && json.status=="1"){
def ret = json.geocodes
if(ret){
def str = ret.get(0).location
def level = ret.get(0).level
if(str && ["门牌号","单元号","道路","道路交叉路口","热点商圈","村庄","兴趣点","门址","住宅区"].contains(level)){
def arrs = str.split(",")
return ["lng":arrs[0], "lat":arrs[1]]
}else{
println address +" "+level
return null
}
}
}
}
def addAroundPrice(path){
ExcelUtils.multiThreadingModify(path, { d ->
if(!d['J'] && d['Q']){
def city = RegionData.formatCity(d['B'])
def dist = new BasicDBObject()
dist.city = city
dist.lng = d['Q'].toString().toDouble()*10000000000L
dist.lat = d['R'].toString().toDouble()*10000000000L
dist.estateType = "普通住宅"//d['H']
if(dist.lat) {
List<DBObject> list = DbUtils.findAroundDistrictByRadius(dist, 1000)
if (list) {
list = sortByDistance(dist, list);
if (list && list.size() > 10) {
list = list[0..9]
}
if (list) {
def prices = []
for (def s : list) {
def priceObj = CommonDatautils.findDistrictPrice(s.city, s.region, s.name)
if (priceObj) {
prices << priceObj.avg_price
}
}
if (prices) {
def arround_price = (int) (prices.sum() / prices.size())
d['k'] = arround_price
def area = d["F"]
if(area && area.toString().isNumber() && !area.toString().contains("+")){
d['J'] = (int)(area.toString().toDouble()*arround_price)
}
}
}
}
}
}
});
}
def sortByDistance(d, list){
def newList = []
for(def nb : list){
def distance = GeoHelper.GetDistance(d.lat/10000000000.0, d.lng/10000000000.0, nb.lat/10000000000.0, nb.lng/10000000000.0)
nb.distance = distance
newList << nb
}
//排序
Collections.sort(newList, new Comparator() {
@Override
int compare(Object o1, Object o2) {
if(o1.distance > o2.distance)
return 1;//第二个元素(o1)比第一个元素(o2)大,返回-1
if(o1.distance == o2.distance)
return 0;
return -1;
}
})
return newList;
}
def run(){
def path = "D:\\数据\\江苏农行\\江苏农1062条(合).xlsx"
def path = "D:\\数据\\江苏农行\\江苏农1062条(总).xlsx"
addressEvalute(path)
// addFjwTobPrice(path)
// addThirdPrice(path)
@@ -225,10 +225,11 @@ class FangjiaClientUtils {
public static def newMatch(city,address, property, useMap){
def jsonObj = null
def content = null
def url = null;
try {
address = address.replace("{","").replace("\\","")
def url = "http://192.168.0.100:32080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}"
// def url = "http://192.168.0.19:31080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}"
// def url = "http://192.168.0.100:32080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}"
url = "http://192.168.0.19:31080/FangJiaNlpService/match?address="+URLEncoder.encode(address,"UTF-8")+"&useMap=${useMap}"
if(city){
url = url + "&city="+URLEncoder.encode(city,"UTF-8")
@@ -240,7 +241,7 @@ class FangjiaClientUtils {
content = new HttpRequest().newGet(url, null, "utf-8")
jsonObj = JSONObject.fromObject(content)
} catch (Exception e) {
println address +" "+content
println "报错地址:"+url
e.printStackTrace();
}
return jsonObj;
File diff suppressed because one or more lines are too long
@@ -64,6 +64,9 @@ class SuggestionDataSynch extends BaseBatch{
for (def c : citys) {
def allRets = []
if(["上海","北京","广州","深圳","成都","天津","西安"].contains(c)){
break;
}
index++
// if(!["三明","宁德","泉州","厦门","福州","漳州","南平","龙岩","莆田","重庆"].contains(c)){
def ret1 = updating(c, "district")