From cf41916ef3d0dcf1846a52c60f7d12684d09f137 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 12 Jan 2024 13:23:51 +0800 Subject: [PATCH 1/2] update --- .../ccbevaluation/GuiDingPriceBatch.groovy | 2 +- .../com/fangjia/script/gj/PoiLocation.groovy | 1 - .../fangjia/script/gj/abc/SuzouPocTest.groovy | 223 +++++++++++++++++- .../gj/district/FangjiaClientUtils.groovy | 7 +- .../gj/village/communityLocation.groovy | 25 ++ .../gj/xiamen/SuggestionDataSynch.groovy | 3 + 6 files changed, 254 insertions(+), 7 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy index 0c632d5cc..bdbbf0757 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy @@ -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) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PoiLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PoiLocation.groovy index 440d7495e..f0678d5b0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PoiLocation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PoiLocation.groovy @@ -158,7 +158,6 @@ class PoiLocation { gmap.lat = DataHandleUtils.getDoubleRound(6, gmap.lat) } return location; - } return null; } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abc/SuzouPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abc/SuzouPocTest.groovy index f1ca243e2..bc770b173 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abc/SuzouPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abc/SuzouPocTest.groovy @@ -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 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) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 797fff4eb..0f6684bdc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -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; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy new file mode 100644 index 000000000..bb7993201 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy @@ -0,0 +1,25 @@ +package com.fangjia.script.gj.village + +import com.fangjia.script.gj.OpenApiUtils +import com.fangjia.script.util.ExcelUtils + +filePath = "D:\\数据\\涉农\\2023居委相同包含.xlsx" +ExcelUtils.multiThreadingModify(filePath, {d-> + def poiName = d['N'] + def locstr = d['O'] + try{ + def name = poiName.substring(poiName.indexOf(" ")+4, poiName.indexOf("\n")) + def location = locstr.substring(locstr.indexOf("{"), locstr.indexOf("}")+1) + }catch(e){ + println "错误:"poiName + } + d["S"] = name + d['T'] = location +}) + + +//def codeMap = ["北京": "131", "天津": "332", "石家庄": "150", "唐山": "265", "秦皇岛": "148", "邯郸": "151", "邢台": "266", "保定": "307", "张家口": "264", "承德": "207", "沧州": "149", "廊坊": "191", "衡水": "208", "太原": "176", "大同": "355", "阳泉": "357", "长治": "356", "晋城": "290", "朔州": "237", "晋中": "238", "运城": "328", "忻州": "367", "临汾": "368", "吕梁": "327", "呼和浩特": "321", "包头": "229", "乌海": "123", "赤峰": "297", "通辽": "64", "鄂尔多斯": "283", "呼伦贝尔": "61", "巴彦淖尔": "169", "乌兰察布": "168", "兴安盟": "62", "锡林郭勒盟": "63", "阿拉善盟": "230", "沈阳": "58", "大连": "167", "鞍山": "320", "抚顺": "184", "本溪": "227", "丹东": "282", "锦州": "166", "营口": "281", "阜新": "59", "辽阳": "351", "盘锦": "228", "铁岭": "60", "朝阳": "280", "葫芦岛": "319", "长春": "53", "吉林市": "55", "四平": "56", "辽源": "183", "通化": "165", "白山": "57", "松原": "52", "白城": "51", "延边朝鲜族自治州": "54", "哈尔滨": "48", "齐齐哈尔": "41", "鸡西": "46", "鹤岗": "43", "双鸭山": "45", "大庆": "50", "伊春": "40", "佳木斯": "42", "七台河": "47", "牡丹江": "49", "黑河": "39", "绥化": "44", "大兴安岭地区": "38", "上海": "289", "南京": "315", "无锡": "317", "徐州": "316", "常州": "348", "苏州": "224", "南通": "161", "连云港": "347", "淮安": "162", "盐城": "223", "扬州": "346", "镇江": "160", "泰州": "276", "宿迁": "277", "杭州": "179", "宁波": "180", "温州": "178", "嘉兴": "334", "湖州": "294", "绍兴": "293", "金华": "333", "衢州": "243", "舟山": "245", "台州": "244", "丽水": "292", "合肥": "127", "芜湖": "129", "蚌埠": "126", "淮南": "250", "马鞍山": "358", "淮北": "253", "铜陵": "337", "安庆": "130", "黄山": "252", "滁州": "189", "阜阳": "128", "宿州": "370", "巢湖": "251", "六安": "298", "亳州": "188", "池州": "299", "宣城": "190", "福州": "300", "厦门": "194", "莆田": "195", "三明": "254", "泉州": "134", "漳州": "255", "南平": "133", "龙岩": "193", "宁德": "192", "南昌": "163", "景德镇": "225", "萍乡": "350", "九江": "349", "新余": "164", "鹰潭": "279", "赣州": "365", "吉安": "318", "宜春": "278", "抚州": "226", "上饶": "364", "济南": "288", "青岛": "236", "淄博": "354", "枣庄": "172", "东营": "174", "烟台": "326", "潍坊": "287", "济宁": "286", "泰安": "325", "威海": "175", "日照": "173", "莱芜": "124", "临沂": "234", "德州": "372", "聊城": "366", "滨州": "235", "菏泽": "353", "郑州": "268", "开封": "210", "洛阳": "153", "平顶山": "213", "安阳": "267", "鹤壁": "215", "新乡": "152", "焦作": "211", "濮阳": "209", "许昌": "155", "漯河": "344", "三门峡": "212", "南阳": "309", "商丘": "154", "信阳": "214", "周口": "308", "驻马店": "269", "武汉": "218", "黄石": "311", "十堰": "216", "宜昌": "270", "襄阳": "156", "鄂州": "122", "荆门": "217", "孝感": "310", "荆州": "157", "黄冈": "271", "咸宁": "362", "随州": "371", "恩施土家族苗族自治州": "373", "仙桃": "1713", "潜江": "1293", "天门": "2654", "神农架林区": "2734", "长沙": "158", "株洲": "222", "湘潭": "313", "衡阳": "159", "邵阳": "273", "岳阳": "220", "常德": "219", "张家界": "312", "益阳": "272", "郴州": "275", "永州": "314", "怀化": "363", "娄底": "221", "湘西土家族苗族自治州": "274", "广州": "257", "韶关": "137", "深圳": "340", "珠海": "140", "汕头": "303", "佛山": "138", "江门": "302", "湛江": "198", "茂名": "139", "肇庆": "338", "惠州": "301", "梅州": "141", "汕尾": "339", "河源": "200", "阳江": "199", "清远": "197", "东莞": "119", "中山": "187", "潮州": "201", "揭阳": "259", "云浮": "258", "南宁": "261", "柳州": "305", "桂林": "142", "梧州": "304", "北海": "295", "防城港": "204", "钦州": "145", "贵港": "341", "玉林": "361", "百色": "203", "贺州": "260", "河池": "143", "来宾": "202", "崇左": "144", "海口": "125", "三亚": "121", "五指山": "1644", "琼海": "2358", "儋州": "1215", "文昌": "2758", "万宁": "1216", "东方": "2634", "定安": "1214", "屯昌": "1641", "澄迈": "2757", "临高": "2033", "白沙黎族自治": "2359", "昌江黎族自治": "1642", "乐东黎族自治": "2032", "陵水黎族自治": "1643", "保亭黎族苗族自治": "1217", "琼中黎族苗族自治": "2031", "重庆": "132", "成都": "75", "自贡": "78", "攀枝花": "81", "泸州": "331", "德阳": "74", "绵阳": "240", "广元": "329", "遂宁": "330", "内江": "248", "乐山": "79", "南充": "291", "眉山": "77", "宜宾": "186", "广安": "241", "达州": "369", "雅安": "76", "巴中": "239", "资阳": "242", "阿坝藏族羌族自治州": "185", "甘孜藏族自治州": "73", "凉山彝族自治州": "80", "贵阳": "146", "六盘水": "147", "遵义": "262", "安顺": "263", "铜仁地区": "205", "黔西南布依族苗族自治州": "343", "毕节地区": "206", "黔东南苗族侗族自治州": "342", "黔南布依族苗族自治州": "306", "昆明": "104", "曲靖": "249", "玉溪": "106", "保山": "112", "昭通": "336", "丽江": "114", "临沧": "110", "楚雄彝族自治州": "105", "红河哈尼族彝族自治州": "107", "文山壮族苗族自治州": "177", "普洱": "108", "西双版纳傣族自治州": "109", "大理白族自治州": "111", "德宏傣族景颇族自治州": "116", "怒江傈僳族自治州": "113", "迪庆藏族自治州": "115", "拉萨": "100", "昌都地区": "99", "山南地区": "97", "日喀则地区": "102", "那曲地区": "101", "阿里地区": "103", "林芝地区": "98", "西安": "233", "铜川": "232", "宝鸡": "171", "咸阳": "323", "渭南": "170", "延安": "284", "汉中": "352", "榆林": "231", "安康": "324", "商洛": "285", "兰州": "36", "嘉峪关": "33", "金昌": "34", "白银": "35", "天水": "196", "武威": "118", "张掖": "117", "平凉": "359", "酒泉": "37", "庆阳": "135", "定西": "136", "陇南": "256", "临夏回族自治州": "182", "甘南藏族自治州": "247", "西宁": "66", "海东地区": "69", "海北藏族自治州": "67", "黄南藏族自治州": "70", "海南藏族自治州": "68", "果洛藏族自治州": "72", "玉树藏族自治州": "71", "海西蒙古族藏族自治州": "65", "银川": "360", "石嘴山": "335", "吴忠": "322", "固原": "246", "中卫": "181", "乌鲁木齐": "92", "克拉玛依": "95", "吐鲁番地区": "89", "哈密地区": "91", "昌吉回族自治州": "93", "博尔塔拉蒙古自治州": "88", "巴音郭楞蒙古自治州": "86", "阿克苏地区": "85", "克孜勒苏柯尔克孜自治州": "84", "喀什地区": "83", "和田地区": "82", "伊犁哈萨克自治州": "90", "塔城地区": "94", "阿勒泰地区": "96", "石河子": "770", "阿拉尔": "731", "图木舒克": "792", "五家渠": "789", "香港特别行政区": "2912", "澳门特别行政区": "2911"] +// +//def code = codeMap.get("北京"); +rets = OpenApiUtils.searchBaiDuMap("人定湖社区居委会", "东城区", code.toInteger()); +//println(rets) \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy index b9070a74a..e942ff1dc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy @@ -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") From e81564b9699037c8b4521c1b2d0a20d5d333f7aa Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 12 Jan 2024 13:44:07 +0800 Subject: [PATCH 2/2] update --- .../com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy index e942ff1dc..10a5f2cb9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy @@ -65,7 +65,7 @@ class SuggestionDataSynch extends BaseBatch{ for (def c : citys) { def allRets = [] if(["上海","北京","广州","深圳","成都","天津","西安"].contains(c)){ - break; + continue; } index++ // if(!["三明","宁德","泉州","厦门","福州","漳州","南平","龙岩","莆田","重庆"].contains(c)){