From e20fef34559e814f9d750cafe6f3b680cda0e311 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sun, 9 Jun 2024 10:52:56 +0800 Subject: [PATCH 01/45] update --- .../ccbevaluation/CcbCommonUtils.groovy | 4 ++- .../FjwBigdataDealBatch.groovy | 9 +++--- .../FjwBigdataForsaleBatch.groovy | 3 +- .../FjwGuiDingPriceBatch.groovy | 15 +++++++-- .../fjwPriceBaseData/FjwPgsqlCommUtils.groovy | 13 ++++++++ .../FjwThirdPartyPriceBatch.groovy | 31 ++++++++++--------- 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy index 45327d072..f167832eb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets class CcbCommonUtils { - public static def citys_fjw_all = ["上海","长春","扬州","北京","重庆","天津","成都","深圳","沈阳","大连","安庆","西宁","日照","武汉","西安","乌鲁木齐","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台", "徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝","阿坝州","阿拉善盟","阿里","昌都","甘南","甘孜州","果洛州","海北州","海南州","黄南州","克孜勒苏","那曲","怒江州","三沙","山南","神农架","文山州","玉树州","白沙","北屯","昌江","澄迈","定安","东方","济源","可克达拉","昆玉","乐东","临高","琼海","琼中","石河子","双河","铁门关","图木舒克","屯昌","万宁","五家渠","五指山","阿拉尔"] + public static def citys_fjw_all = ["长春","上海","扬州","北京","重庆","天津","成都","深圳","沈阳","大连","安庆","西宁","日照","武汉","西安","乌鲁木齐","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台", "徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝","阿坝州","阿拉善盟","阿里","昌都","甘南","甘孜州","果洛州","海北州","海南州","黄南州","克孜勒苏","那曲","怒江州","三沙","山南","神农架","文山州","玉树州","白沙","北屯","昌江","澄迈","定安","东方","济源","可克达拉","昆玉","乐东","临高","琼海","琼中","石河子","双河","铁门关","图木舒克","屯昌","万宁","五家渠","五指山","阿拉尔"] public static def citys_all = ["乌鲁木齐","上海","长春","扬州","北京","重庆","天津","成都","沈阳","大连","安庆","西宁","日照","武汉","西安","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台","徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","深圳","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝"] public static def citys_92 = [ "上海","扬州","北京","重庆","天津","成都","沈阳","大连","安庆","西宁","日照","长春","武汉","西安","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台","徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","乌鲁木齐","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","深圳","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水"] @@ -691,6 +691,8 @@ class CcbCommonUtils { pgsqlInstance.executeUpdate(sql2) } + + public static def findGuiDingIdsByCity(){ // 创建布隆过滤器对象 BloomFilter filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy index 497adb4ec..3234ddbbd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy @@ -515,13 +515,12 @@ class FjwBigdataDealBatch extends BaseBatch{ def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(dists.size()) -// def citys = ["北京","广州","深圳","重庆","郑州","西安","成都","东莞","佛山","杭州","合肥","南京","长春","扬州","无锡","太原","台州","泉州","宁波","南通","南昌","贵阳","哈尔滨","惠州","济南","金华","昆明","遵义","镇江","肇庆","宜昌","芜湖","泰州","汕头","清远","秦皇岛","马鞍山","洛阳","连云港","九江","淮安","呼和浩特","沧州","保定","安庆"] -// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) -// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) + def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) + def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) - def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd")) - def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240701", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) +// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd")) +// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240701", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) for(def i=0;i filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001); + sqlInstance.eachRow("SELECT gujia_fsid FROM base.guided_price",{it-> + filter.put(it.gujia_fsid) + }); + return filter + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index a78586475..2d77f4142 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -50,20 +50,23 @@ class FjwThirdPartyPriceBatch extends BaseBatch { public void process(Object args) { def citys = CcbCommonUtils.getRunningCitys(args) - def stop = false - def month = -1 - while(!stop){ - if(sDate>202404 && sDate<202407){ - def weekend = DateUtils.getFirstDayOfWeek(DateUtils.parseFromTightByPattern(sDate+"15", "yyyyMMdd")) - println weekend.toString() +" "+sDate - runDatas(citys) - } - month = month -1 - sDate= Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), month, "yyyyMM")); - if(sDate == 201912){ - stop = true; - } - } + runDatas(citys) + + //同步历史数据 +// def stop = false +// def month = -1 +// while(!stop){ +// if(sDate>202404 && sDate<202407){ +// def weekend = DateUtils.getFirstDayOfWeek(DateUtils.parseFromTightByPattern(sDate+"15", "yyyyMMdd")) +// println weekend.toString() +" "+sDate +// runDatas(citys) +// } +// month = month -1 +// sDate= Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), month, "yyyyMM")); +// if(sDate == 201912){ +// stop = true; +// } +// } } def runDatas(citys){ From fb79e70a672b199a8223b5e623637c24a66610ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 1 Aug 2024 09:56:24 +0800 Subject: [PATCH 02/45] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/AddrSvcController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index f368e6055..d5e0ffc43 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -32,6 +32,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.DefaultProxyRoutePlanner; import org.apache.http.util.EntityUtils; +import org.sothis.core.util.CollectionUtils; import org.sothis.core.util.Pager; import sun.misc.BASE64Encoder; @@ -42,6 +43,7 @@ import java.net.PasswordAuthentication; import java.net.Proxy; import java.nio.charset.Charset; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -607,7 +609,8 @@ public class AddrSvcController { params.put("type", type); params.put("showFullValue", "2"); Pager pager = new Pager(1, 1); - VillageIdentify villageResult = villageIdentifyService.findAll(villageType, model.getCity(), model.getAddress(), pager).get(0); + List villageIdentifyList = villageIdentifyService.findAll(villageType, model.getCity(), model.getAddress(), pager); + VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { Map resultMap = new HashMap(); resultMap.put("province",villageResult.getProvince()); From 24a4fb2163330f85ea7759392284094f3f277942 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 1 Aug 2024 10:50:09 +0800 Subject: [PATCH 03/45] =?UTF-8?q?=E6=B6=89=E5=86=9C=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=BB=93=E6=9E=9C=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 2 +- .../mongo/fangjia/VillageIdentifyService.java | 1 + .../fangjia/VillageIdentifyServiceImpl.java | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index d5e0ffc43..b2aecb6a8 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -609,7 +609,7 @@ public class AddrSvcController { params.put("type", type); params.put("showFullValue", "2"); Pager pager = new Pager(1, 1); - List villageIdentifyList = villageIdentifyService.findAll(villageType, model.getCity(), model.getAddress(), pager); + List villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager); VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { Map resultMap = new HashMap(); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyService.java index a0f8f6348..068fd06c6 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyService.java @@ -17,5 +17,6 @@ public interface VillageIdentifyService { int count(String villageType,String city1,String address); List findAll(String villageType,String city1,String address,Pager pager); + List findByCityAndAddress(String villageType,String city1,String address,Pager pager); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyServiceImpl.java index 998576dd1..a2e66f603 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/VillageIdentifyServiceImpl.java @@ -62,6 +62,23 @@ public class VillageIdentifyServiceImpl implements VillageIdentifyService { return villageIdentifyDao.findAllByParams(queryParams, pager.getStartRow(), pager.getPageSize()); } + @Override + public List findByCityAndAddress(String villageType, String city1, String address, Pager pager) { + List queryParams = new ArrayList(); + if (StringUtils.isNotBlank(villageType)) { + queryParams.add(new QueryParam("villageType", villageType)); + }else { + queryParams.add(new QueryParam("villageType", "对公")); + } + if (StringUtils.isNotBlank(city1)) { + queryParams.add(new QueryParam("cityParam", city1)); + } + if (StringUtils.isNotBlank(address)) { + queryParams.add(new QueryParam("address", address)); + } + return villageIdentifyDao.findAllByParams(queryParams, pager.getStartRow(), pager.getPageSize()); + } + public void setVillageIdentifyDao(VillageIdentifyDao villageIdentifyDao) { this.villageIdentifyDao = villageIdentifyDao; } From c171b9a010ba15056e6bd48d1ef89969b1c02c3b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 1 Aug 2024 15:13:43 +0800 Subject: [PATCH 04/45] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A7=E6=AD=A3?= =?UTF-8?q?=E5=9C=B0=E5=9F=8E=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-bkoff/src/main/webapp/fjt/add.ftl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/fjt/add.ftl b/projects/fangjia-bkoff/src/main/webapp/fjt/add.ftl index 4a70b7978..84f44621a 100644 --- a/projects/fangjia-bkoff/src/main/webapp/fjt/add.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/fjt/add.ftl @@ -176,7 +176,7 @@ table{text-align: left;} } }) - if(role==12||role==17){ + if(role==12||role==17||role==18){ if(userStr.length>0){ console.log(userStr); $("input[name=roleUsers]").val(userStr); @@ -306,7 +306,7 @@ $("input[name=email]").blur(function(){ $("#role").change(function() { var role = $(this).val(); //鍙鍐滆鐢熸晥 - if (role == 12 || role == 17) { + if (role == 12 || role == 17 || role == 18) { $("#show_chk_all").removeAttr("style"); jQuery.ajax({ type: 'POST', @@ -340,7 +340,7 @@ $("input[name=email]").blur(function(){ } return false; } - <#if user?? && (user.role == 12 || user.role == 17)> + <#if user?? && (user.role == 12 || user.role == 17|| user.role == 18)> $("#show_chk_all").removeAttr("style"); jQuery.ajax({ type: 'POST', From 797378e163096ecae877428dd8bcf9daba3f9a82 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 2 Aug 2024 13:32:10 +0800 Subject: [PATCH 05/45] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A7=E6=AD=A3?= =?UTF-8?q?=E8=AF=84=E4=BC=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/bkoff/controllers/InquiryController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/InquiryController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/InquiryController.java index 6e8ae8ffc..c96fd1c20 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/InquiryController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/InquiryController.java @@ -74,6 +74,8 @@ public class InquiryController { role = fjtRoleService.findRolesByName("农行"); }else if(2 == bkoffUsers.getSupportInquiryTask().intValue()){ role = fjtRoleService.findRolesByName("深圳农行"); + }else if(3 == bkoffUsers.getSupportInquiryTask().intValue()){ + role = fjtRoleService.findRolesByName("大正评估"); } List zqUserIds = userCityService.findUserIdByCity("肇庆"); @@ -87,6 +89,8 @@ public class InquiryController { } }else if(vo2.getRole()==16){ userIds.add(vo2.getId()); + }else if(vo2.getRole()==18){ + userIds.add(vo2.getId()); } } From 564eb4a70112c4f7d401488cf1f07c6d72ad04c0 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 2 Aug 2024 15:37:01 +0800 Subject: [PATCH 06/45] css update --- .../fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css index 10311ed8f..9da6721f6 100644 --- a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css +++ b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css @@ -481,5 +481,7 @@ @media(max-device-width:375px){ .bg01{height: 1550px;} + .label_title01 {font-size: 1.2rem;} + .evaluationBox .evaluation_title {font-size: 1.2rem;} } From 8e7671483491bb960d1ccb99c9dce25af38c46c0 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 2 Aug 2024 15:54:32 +0800 Subject: [PATCH 07/45] css update --- .../src/main/webapp/style/fangjia/v6/mobile.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css index 9da6721f6..18ec9c747 100644 --- a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css +++ b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/mobile.css @@ -483,5 +483,10 @@ .bg01{height: 1550px;} .label_title01 {font-size: 1.2rem;} .evaluationBox .evaluation_title {font-size: 1.2rem;} + .sample_icon05 {background-size: 350px 200px;} +} + +@media(max-device-width:414px){ + .sample_icon05 {background-size: 400px 200px;} } From e7ae56c04cdf65b21f730c306eb9eb7b7b90a078 Mon Sep 17 00:00:00 2001 From: sjshenjian Date: Sat, 3 Aug 2024 17:48:48 +0800 Subject: [PATCH 08/45] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9F=9B=E7=9B=BE?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index b2aecb6a8..aa1183398 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -452,6 +452,12 @@ public class AddrSvcController { Map map = senRequest(address, qltype); // 涉农结果不一样 if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { + // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 + if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } //城市不一样 用我们 if (result.containsKey("city")) { if ((!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { @@ -544,6 +550,12 @@ public class AddrSvcController { Map map = senRequest(address, qltype); // 涉农结果不一样 if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { + // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 + if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } //城市不一样 用我们 if (result.containsKey("city")) { if ((!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { @@ -675,6 +687,12 @@ public class AddrSvcController { Map map = senRequest(address, qltype); // 涉农结果不一样 if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { + // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 + if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } //有市辖建制镇, 或者城市不一样 用我们 if (result.containsKey("city")) { if ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { From e318980b48aeb7bb8afd0d611420bce1c9eb83aa Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 8 Aug 2024 13:58:55 +0800 Subject: [PATCH 09/45] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=89=A9=E4=BD=99?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=AC=A1=E6=95=B0=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/UsersController.java | 270 +++++++++++------- .../fangjia/open/model/ApiMonitorInfo.java | 64 +++++ 2 files changed, 236 insertions(+), 98 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java index 2c5bbea24..69b48a5f8 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java @@ -1,24 +1,32 @@ package com.fangjia.open.controllers; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.BeanUtils; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.QueryParam; import com.fangjia.dal.mongo.model.SendSmsLog; +import com.fangjia.dal.mongo.open.model.ApiUserAuthority; +import com.fangjia.dal.mongo.open.model.OpenResource; +import com.fangjia.dal.mongo.tool.model.OpenUriAnaly; +import com.fangjia.open.HttpStatusCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.model.*; import com.fangjia.open.model.weixin.SendCodeJsonModel; import com.fangjia.open.model.weixin.SendCodeModel; +import com.fangjia.service.open.*; import net.sf.json.JSONObject; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.ActionInvocation; import org.sothis.web.mvc.annotation.Param; import com.fangjia.dal.sql.model.User; import com.fangjia.open.HttpCode; import com.fangjia.open.OpenHttpCodeEnum; -import com.fangjia.open.model.RestfulModelAndView; -import com.fangjia.open.model.UsersModel; import com.fangjia.service.mongo.mobile.UserInfoService; import com.fangjia.service.sql.UserService; import com.fangjia.service.util.UsersUtils; @@ -26,100 +34,166 @@ import com.fangjia.service.util.UsersUtils; import javax.servlet.http.HttpServletRequest; public class UsersController { - private UserService userService; - private UserInfoService userInfoService; + private UserService userService; + private UserInfoService userInfoService; - /** - * - * @param model - * @return 1 无此用户 2 非法请求 3 密码错误 0 正常登陆 - * @throws Exception - */ - public Object loginAction(UsersModel model) throws Exception { - Map infomain = new HashMap(); - if (StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getPwd())) { - infomain.put("flag", UsersUtils.LoginEnum.EINVAL.ordinal()); - } else { - User user = userService.findByUserName(model.getName()); - if (null == user) { - infomain.put("flag", UsersUtils.LoginEnum.NOUSER.ordinal()); - } else if (!user.getPassword().equals(DigestUtils.md5Hex(model.getPwd()))) { - infomain.put("flag", UsersUtils.LoginEnum.ERRPWD.ordinal()); - } else { - infomain.put("flag", UsersUtils.LoginEnum.SUCCESS.ordinal()); - infomain.put("displayname", user.getDisplayName()); - infomain.put("username", user.getUserName()); - infomain.put("id", user.getId()); - } - } - JSONObject json = JSONObject.fromObject(infomain); - return json.toString(); - } - - /** - * - * @param model - * @return 1 无此用户 2 非法请求 3 原始密码错误 0 修改成功 - * @throws Exception - */ - public Object modifyPwdAction(UsersModel model) throws Exception { - Map infomain = new HashMap(); - if (StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getPwd())) { - infomain.put("flag", UsersUtils.LoginEnum.EINVAL.ordinal()); - } else { - User user = userService.findByUserName(model.getName()); - if (null == user) { - infomain.put("flag", UsersUtils.LoginEnum.NOUSER.ordinal()); - } else if (!user.getPassword().equals(DigestUtils.md5Hex(model.getPwd()))) { - infomain.put("flag", UsersUtils.LoginEnum.ERRPWD.ordinal()); - } else { - user.setPassword(DigestUtils.md5Hex(model.getNewPwd())); - userService.updateUser(user); - infomain.put("flag", UsersUtils.LoginEnum.SUCCESS.ordinal()); - } - } - JSONObject json = JSONObject.fromObject(infomain); - return json.toString(); - } - - public Object saveAction(@Param(name = "ime") String ime, @Param(name = "name") String name, @Param(name = "description") String description, @Param(name = "image") String image, @Param(name = "type") String type) { - - if (ime == null || "".equals(ime.trim())) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "手机唯一标示缺失!")); - return mav; - } - if (name == null || "".equals(name.trim())) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "用户名缺失!")); - return mav; - } - if (type == null || "".equals(type.trim())) { - type = "default"; - } - - com.fangjia.dal.mongo.mobile.model.User userInfo = userInfoService.save(ime, name, description, image, type); - - Map infomain = new HashMap(); - infomain.put("uid", userInfo.getId()); - infomain.put("ime", userInfo.getIme()); - infomain.put("name", userInfo.getName()); - infomain.put("type", userInfo.getType()); - infomain.put("description", userInfo.getDescription()); - infomain.put("image", userInfo.getImage()); - JSONObject json = JSONObject.fromObject(infomain); - return json.toString(); - } - - public void setUserService(UserService userService) { - this.userService = userService; - } - - public void setUserInfoService(UserInfoService userInfoService) { - this.userInfoService = userInfoService; - } + private ApiVisitCountService apiVisitCountService; + private ApiUserAuthorityService apiUserAuthorityService; + private OpenResourceService openResourceService; + private OpenUriAnalyService openUriAnalyService; + /** + * @param model + * @return 1 无此用户 2 非法请求 3 密码错误 0 正常登陆 + * @throws Exception + */ + public Object loginAction(UsersModel model) throws Exception { + Map infomain = new HashMap(); + if (StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getPwd())) { + infomain.put("flag", UsersUtils.LoginEnum.EINVAL.ordinal()); + } else { + User user = userService.findByUserName(model.getName()); + if (null == user) { + infomain.put("flag", UsersUtils.LoginEnum.NOUSER.ordinal()); + } else if (!user.getPassword().equals(DigestUtils.md5Hex(model.getPwd()))) { + infomain.put("flag", UsersUtils.LoginEnum.ERRPWD.ordinal()); + } else { + infomain.put("flag", UsersUtils.LoginEnum.SUCCESS.ordinal()); + infomain.put("displayname", user.getDisplayName()); + infomain.put("username", user.getUserName()); + infomain.put("id", user.getId()); + } + } + JSONObject json = JSONObject.fromObject(infomain); + return json.toString(); + } + + /** + * @param model + * @return 1 无此用户 2 非法请求 3 原始密码错误 0 修改成功 + * @throws Exception + */ + public Object modifyPwdAction(UsersModel model) throws Exception { + Map infomain = new HashMap(); + if (StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getPwd())) { + infomain.put("flag", UsersUtils.LoginEnum.EINVAL.ordinal()); + } else { + User user = userService.findByUserName(model.getName()); + if (null == user) { + infomain.put("flag", UsersUtils.LoginEnum.NOUSER.ordinal()); + } else if (!user.getPassword().equals(DigestUtils.md5Hex(model.getPwd()))) { + infomain.put("flag", UsersUtils.LoginEnum.ERRPWD.ordinal()); + } else { + user.setPassword(DigestUtils.md5Hex(model.getNewPwd())); + userService.updateUser(user); + infomain.put("flag", UsersUtils.LoginEnum.SUCCESS.ordinal()); + } + } + JSONObject json = JSONObject.fromObject(infomain); + return json.toString(); + } + + public Object saveAction(@Param(name = "ime") String ime, @Param(name = "name") String name, @Param(name = "description") String description, @Param(name = "image") String image, @Param(name = "type") String type) { + + if (ime == null || "".equals(ime.trim())) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "手机唯一标示缺失!")); + return mav; + } + if (name == null || "".equals(name.trim())) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "用户名缺失!")); + return mav; + } + if (type == null || "".equals(type.trim())) { + type = "default"; + } + + com.fangjia.dal.mongo.mobile.model.User userInfo = userInfoService.save(ime, name, description, image, type); + + Map infomain = new HashMap(); + infomain.put("uid", userInfo.getId()); + infomain.put("ime", userInfo.getIme()); + infomain.put("name", userInfo.getName()); + infomain.put("type", userInfo.getType()); + infomain.put("description", userInfo.getDescription()); + infomain.put("image", userInfo.getImage()); + JSONObject json = JSONObject.fromObject(infomain); + return json.toString(); + } + + public Object surplusCallCountAction() throws IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + ActionContext context = ActionContext.getContext(); + HttpServletRequest request = context.getRequest(); + AuthenticationBean instance = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (null != instance) { + User user = instance.user; + List openResourceList = openResourceService.findAll(); + List list = new ArrayList(); + long id = user.getId(); + ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id); + if (null != authority) { + // 用户有的uri + List userResources = new ArrayList(); + for (OpenResource openResource : openResourceList) { + if (authority.getOpenResourseUris().contains(openResource.getUri())) { + userResources.add(openResource); + } + } + Map countMap = authority.getTotalCountMap(); + if (null != countMap) { + // 改成遍历用户有的uri + for (OpenResource openResource : userResources) { + String uri = openResource.getUri(); + if (null != countMap.get(uri) && countMap.get(uri) > 0) { + ApiMonitorInfo info = new ApiMonitorInfo(); + info.setApiUri(uri); + info.setApiName(openResource.getName()); + info.setUserId((int) id); + info.setUsername(user.getUserName()); + long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date())); + long total = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); + info.setSurplusCallCount(countMap.get(uri) - curVistedCount - total); + list.add(info); + } + + } + } + } + BasicModel basicModel = new BasicModel(200, "ok"); + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(new BasicModel(HttpStatusCodeEnum.BAD_REQUEST_ERROR_KEY)); + } + return mav; + } + + public void setUserService(UserService userService) { + this.userService = userService; + } + + public void setUserInfoService(UserInfoService userInfoService) { + this.userInfoService = userInfoService; + } + + public void setApiVisitCountService(ApiVisitCountService apiVisitCountService) { + this.apiVisitCountService = apiVisitCountService; + } + + public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) { + this.apiUserAuthorityService = apiUserAuthorityService; + } + + public void setOpenResourceService(OpenResourceService openResourceService) { + this.openResourceService = openResourceService; + } + + public void setOpenUriAnalyService(OpenUriAnalyService openUriAnalyService) { + this.openUriAnalyService = openUriAnalyService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java new file mode 100644 index 000000000..0fdb11e38 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java @@ -0,0 +1,64 @@ +package com.fangjia.open.model; + +import java.util.Date; + +public class ApiMonitorInfo { + private Integer userId; + private String username; + private Integer callCount; + private Date callTime; + private String apiUri; + private String apiName; + private Long surplusCallCount; + private Date endTime; + + public Long getSurplusCallCount() { + return surplusCallCount; + } + public void setSurplusCallCount(Long surplusCallCount) { + this.surplusCallCount = surplusCallCount; + } + public Date getEndTime() { + return endTime; + } + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public Integer getCallCount() { + return callCount; + } + public void setCallCount(Integer callCount) { + this.callCount = callCount; + } + public Date getCallTime() { + return callTime; + } + public void setCallTime(Date callTime) { + this.callTime = callTime; + } + public String getApiUri() { + return apiUri; + } + public void setApiUri(String apiUri) { + this.apiUri = apiUri; + } + public String getApiName() { + return apiName; + } + public void setApiName(String apiName) { + this.apiName = apiName; + } + +} From 52e1c4ecfb612257b409debe00c6ef1b67819ddd Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 15:56:05 +0800 Subject: [PATCH 10/45] update --- .../BigdataCommunityBatch.groovy | 15 ++--- .../script/commData/CommonDatautils.groovy | 63 ++++++++++++++++++- .../FjwBigdataDealBatch.groovy | 4 +- .../FjwThirdPartyPriceBatch.groovy | 2 +- 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index 47159ee0e..0ab948806 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -40,7 +40,7 @@ class BigdataCommunityBatch extends BaseBatch{ @Override public void process(Object args) { - def citys = CcbCommonUtils.getRunningCitys(args) + def citys = CcbCommonUtils.getRunningCitys(args) def rows = [] def headers = []//["城市ID","行政区ID","小区ID","行政区名称","小区名称","详细地址","纬度","经度","占地总面积","建筑总面积","绿化率","容积率","车位数量","建筑年代","房屋用途", @@ -50,6 +50,7 @@ class BigdataCommunityBatch extends BaseBatch{ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() def index = 0 def today = new Date().getDate() + def fangjiaDists = [] println "starting 。。。。。。。。。" for(def city : citys){ @@ -60,6 +61,9 @@ class BigdataCommunityBatch extends BaseBatch{ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","street","street_number"], null) + for(def d : dists){ + fangjiaDists << d._id.toString() + } def ccbMaps = null if(today<=10){ @@ -69,7 +73,7 @@ class BigdataCommunityBatch extends BaseBatch{ } def rets = createCityDatas(cityCodeDataMap, distCodeMap, dists) - rets = addDeleteDist(dists, ccbMaps, rets) + rets = addDeleteDist(dists, ccbMaps, rets, fangjiaDists) rows.addAll(rets) println "[${index}] "+city +" 小区量:"+dists.size()+" 总:"+rets.size() @@ -102,11 +106,8 @@ class BigdataCommunityBatch extends BaseBatch{ } - def addDeleteDist(dists, ccbMaps, rets){ - def fangjiaDists = [] - for(def d : dists){ - fangjiaDists << d._id.toString() - } + def addDeleteDist(dists, ccbMaps, rets, fangjiaDists){ + println "房价网小区:"+fangjiaDists.size()+" 建行小区:"+rets.size() def ccbDists = ccbMaps.keySet() for(def ccbId : ccbDists){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index 8446a9ef6..f197f974c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -4653,6 +4653,7 @@ class CommonDatautils { def q = new BasicDBObject() q.put("type","区域") q.put("district_diff",1) + q.put("city",new BasicDBObject('$in', ["中山","东莞","东方"])) def keys = new BasicDBObject() keys.put("province",1) @@ -4662,7 +4663,7 @@ class CommonDatautils { keys.put("mzb_district_name", 1) keys.put("shape", 1) keys.put("district_short",1) - def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(2000) + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(2000).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) def regionMap = [:] for(def d : dbcursor){ if(d.mzb_district_name){ @@ -4686,7 +4687,7 @@ class CommonDatautils { def q = new BasicDBObject() q.put("type","乡镇街道") // q.put("province",new BasicDBObject('$in', ['浙江省','江苏省','山东省'])) -// q.put("city","芜湖市") + q.put("city",new BasicDBObject('$in', ["中山市","东莞市","东方市"])) def keys = new BasicDBObject() keys.put("province",1) @@ -4712,10 +4713,42 @@ class CommonDatautils { } + + static def queryTownByCity(city){ + + def q = new BasicDBObject() + q.put("type","乡镇街道") + q.put("city",city) + + def keys = new BasicDBObject() + keys.put("province",1) + keys.put("city",1) + keys.put("district",1) + keys.put("street",1) + keys.put("shape",1) + keys.put("alias",1) + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + def townMap = [:] + for(def d : dbcursor){ + def key = d.district + def list = townMap.get(key) + if(!list){ + list = [] + } + list << d + townMap.put(key, list) + } + + println "乡镇街道 加载完成" + return townMap + } + + static def queryNewTownByCity(){ def q = new BasicDBObject() q.put("type","乡镇街道") + q.put("city",new BasicDBObject('$in', ["中山","东莞","东方"])) def keys = new BasicDBObject() keys.put("city",1) @@ -4833,6 +4866,9 @@ class CommonDatautils { def jsonObject = null def stop = false def count = 0 + def road = "" + def name = "" + def type = "" while(!stop){ if(glocation){ jsonObject = GaoDeApiUtils.geocode(glocation) @@ -4852,8 +4888,26 @@ class CommonDatautils { } - format_addr = jsonObject.regeocode.formatted_address + if(addressComponent.streetNumber){ + if(addressComponent.streetNumber.street){ + road = addressComponent.streetNumber.street + } + if(addressComponent.streetNumber.number){ + road = road + addressComponent.streetNumber.number + } + } + + if(addressComponent.building){ + if(addressComponent.building.name){ + name = addressComponent.building.name + } + if(addressComponent.building.type){ + type = addressComponent.building.type + } + } + + format_addr = jsonObject.regeocode.formatted_address } } } @@ -4871,6 +4925,9 @@ class CommonDatautils { map.district = district map.township = township map.format_addr = format_addr + map.road = road + map.type = type + map.name = name return map; } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy index 83e83e252..497adb4ec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy @@ -520,8 +520,8 @@ class FjwBigdataDealBatch extends BaseBatch{ // def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) // def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) - def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20200101", "yyyyMMdd")) - def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240601", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) + def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd")) + def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240701", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) for(def i=0;i202404 && sDate<202407){ def weekend = DateUtils.getFirstDayOfWeek(DateUtils.parseFromTightByPattern(sDate+"15", "yyyyMMdd")) println weekend.toString() +" "+sDate runDatas(citys) From d7dd53eb6832eff39f0f57dae296a4b60d75e3d0 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 16:05:24 +0800 Subject: [PATCH 11/45] update bug --- .../FjwBigdataCommunityBatch.groovy | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy index 4a0358411..575225b6b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy @@ -59,25 +59,27 @@ class FjwBigdataCommunityBatch extends BaseBatch{ index ++ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","street","street_number"], "all") + def fangjiaDists = [] + for(def d : dists){ + fangjiaDists << d._id.toString() + } + def ccbMaps = findPgCcbDistrict(cityCodeDataMap.get(city)) //估值导数时使用 def rets = createCityDatas(cityCodeDataMap, distCodeMap, dists) - rets = addDeleteDist(dists, ccbMaps, rets) + rets = addDeleteDist(dists, ccbMaps, rets, fangjiaDists) rows.addAll(rets) println "[${index}] "+city +" 小区量:"+dists.size()+" 总:"+rets.size() } - if(today > 10){ +// if(today > 10){ delPgData() saveToPgSql(rows) - } +// } } - def addDeleteDist(dists, ccbMaps, rets){ - def fangjiaDists = [] - for(def d : dists){ - fangjiaDists << d._id.toString() - } + def addDeleteDist(dists, ccbMaps, rets, fangjiaDists){ + println "房价网小区:"+fangjiaDists.size()+" 建行小区:"+rets.size() def ccbDists = ccbMaps.keySet() for(def ccbId : ccbDists){ From 27282f27814ce619ef7b5387584f57dbba90cf87 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 16:40:10 +0800 Subject: [PATCH 12/45] test --- .../script/ccbevaluation/BigdataCommunityBatch.groovy | 10 ++++++---- .../fjwPriceBaseData/FjwBigdataCommunityBatch.groovy | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index 0ab948806..28f4f850f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -34,6 +34,8 @@ class BigdataCommunityBatch extends BaseBatch{ def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified", "postgres", "postgres", "org.postgresql.Driver") + def fangjiaDists = new HashSet() + static main(args) { runBatch(new BigdataCommunityBatch(), args); } @@ -50,7 +52,6 @@ class BigdataCommunityBatch extends BaseBatch{ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() def index = 0 def today = new Date().getDate() - def fangjiaDists = [] println "starting 。。。。。。。。。" for(def city : citys){ @@ -64,6 +65,7 @@ class BigdataCommunityBatch extends BaseBatch{ for(def d : dists){ fangjiaDists << d._id.toString() } + println "加载建行小区量" def ccbMaps = null if(today<=10){ @@ -71,9 +73,9 @@ class BigdataCommunityBatch extends BaseBatch{ }else{ ccbMaps = CcbCommonUtils.findPgCcbDistrict(cityCodeDataMap.get(city)) //估值导数时使用 } - + println "组装新数据" def rets = createCityDatas(cityCodeDataMap, distCodeMap, dists) - rets = addDeleteDist(dists, ccbMaps, rets, fangjiaDists) + rets = addDeleteDist(dists, ccbMaps, rets) rows.addAll(rets) println "[${index}] "+city +" 小区量:"+dists.size()+" 总:"+rets.size() @@ -106,7 +108,7 @@ class BigdataCommunityBatch extends BaseBatch{ } - def addDeleteDist(dists, ccbMaps, rets, fangjiaDists){ + def addDeleteDist(dists, ccbMaps, rets){ println "房价网小区:"+fangjiaDists.size()+" 建行小区:"+rets.size() def ccbDists = ccbMaps.keySet() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy index 575225b6b..0291a1e8c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy @@ -53,13 +53,13 @@ class FjwBigdataCommunityBatch extends BaseBatch{ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() def index = 0 def today = new Date().getDate() - + def fangjiaDists = new HashSet() println "starting 。。。。。。。。。" for(def city : citys){ index ++ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","street","street_number"], "all") - def fangjiaDists = [] + for(def d : dists){ fangjiaDists << d._id.toString() } From 91fb2cf9c0b1b02e0f0426990131d84dca76060b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 17:17:26 +0800 Subject: [PATCH 13/45] update --- .../script/ccbevaluation/BigdataCommunityBatch.groovy | 10 +++++----- .../fangjia/script/ccbevaluation/CcbCommonUtils.groovy | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index 28f4f850f..eb995add5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -54,17 +54,17 @@ class BigdataCommunityBatch extends BaseBatch{ def today = new Date().getDate() println "starting 。。。。。。。。。" + + def allDists = CcbCommonUtils.findAllDistrictByCity(null, "district", ["city","region", "name"], null) + for(def d : allDists){ + fangjiaDists << d._id.toString() + } for(def city : citys){ index ++ - - def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","street","street_number"], null) - for(def d : dists){ - fangjiaDists << d._id.toString() - } println "加载建行小区量" def ccbMaps = null diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy index 775a4ecc1..12e0f264f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy @@ -442,9 +442,12 @@ class CcbCommonUtils { DBObject q = new BasicDBObject(); q.put("status",0) q.put("cat", cat); - q.put("city", city); + if(city){ + q.put("city", city); + } + // q.put("c_date", new BasicDBObject('$lt', DateUtils.parseFromTightYYYYMMDD("2023-05-01")))//因5月1日新增过多,所以暂且先去掉 此批数据改为name_cat=13 -// q.put("name","荣和怡景园") +// q.put("name","一米阳光一期") // q.put("name_cat", 0); // q.put("name", new BasicDBObject('$in', ["中信泰富又一城一期","中信泰富又一城"])) From cc87ebbb6f42dde093c0108d018b993c965cb96f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 17:37:57 +0800 Subject: [PATCH 14/45] update --- .../fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index eb995add5..d8e72d167 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -55,7 +55,7 @@ class BigdataCommunityBatch extends BaseBatch{ println "starting 。。。。。。。。。" - def allDists = CcbCommonUtils.findAllDistrictByCity(null, "district", ["city","region", "name"], null) + def allDists = CcbCommonUtils.findAllDistrictByCity(null, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat","street","street_number"], null) for(def d : allDists){ fangjiaDists << d._id.toString() } @@ -77,7 +77,7 @@ class BigdataCommunityBatch extends BaseBatch{ def rets = createCityDatas(cityCodeDataMap, distCodeMap, dists) rets = addDeleteDist(dists, ccbMaps, rets) rows.addAll(rets) - println "[${index}] "+city +" 小区量:"+dists.size()+" 总:"+rets.size() + println "[${index}] "+city +" 小区量:"+dists.size()+" 总:"+rets.size()+" 结果:"+rows.size() // FileUtils.batchCreateFile(rets, "d:\\数据\\建行\\房产估值\\数据文件\\txt\\bigdata_community_${city}.txt",headers, "utf-8", false); } From 7bfd107a84c55657629e26bbbe3e7de69941b0bb Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 8 Aug 2024 18:01:28 +0800 Subject: [PATCH 15/45] list>set --- .../com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy index 12e0f264f..45327d072 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy @@ -459,9 +459,9 @@ class CcbCommonUtils { } def dbsour = SEAWEED_MONGO_COLL.find(q,keys).batchSize(2000) println "[${city}] 原始:"+dbsour.count() - def rets = [] + def rets = new HashSet() + def ids = new HashSet() - def ids = [] for(def d : dbsour){ if(kind){ if(d.address){ From 29414e98b0ce2091e04c48e190e2c60160f8f3f9 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 9 Aug 2024 14:52:02 +0800 Subject: [PATCH 16/45] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_handle/ThardParthAnalyBatch.groovy | 101 +++++++++++++ .../FjwBigdataForsaleBatch.groovy | 2 +- .../FjwThirdPartyPriceBatch.groovy | 136 ------------------ 3 files changed, 102 insertions(+), 137 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy new file mode 100644 index 000000000..ef6476d48 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy @@ -0,0 +1,101 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +@BatchOwner(Watcher.GaoJuan) +class ThardParthAnalyBatch extends BaseBatch{ + + def thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); + static DBCollection THIRD_PARTY_STAT = MongoUtils.getCollectionByName("fangjia_stat", "third_party_stat", "mongo.db.fangjia.com") + + + static main(args) { + runBatch(new ThardParthAnalyBatch(), args) + } + +// static main(args) { +// def task = new ThardParthAnalyBatch() +// task.run() +// } + @Override + void process(Object args) { + run() + } + + def run(){ + def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -2), "yyyy-MM-dd") + def sDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM")); + println "统计月份:"+sDate+" 查询更新时间:"+mdate + + def crawlTotalCount = findAllEsDataCount(mdate) + println "抓取第三方小区量:"+crawlTotalCount + def synchTotalCount = findAllMongoDatasCount(sDate) + println "同步到第三方库小区量: "+synchTotalCount + def synchHavePriceTotalCount = findAllMongoDatasHavePricesCount(sDate) + println "同步到第三方库有价格数量:"+synchHavePriceTotalCount + def matchTotalCount = findMatchSuccessCount(sDate) + println "第三方小区匹配成功量:"+matchTotalCount + def noMatchTotalCount = findNoMatchCount(sDate) + println "第三方小区匹配还未匹配数量: "+noMatchTotalCount + + saveOrUpdateDatas(sDate, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, matchTotalCount, noMatchTotalCount); + + } + + + def findAllEsDataCount(mdate){ + def count = null + ElasticUtils.executeSqlQuery("select count(1) as count from community where m_date>='${mdate}'", { d-> + count = d.count + }) + return count; + } + + def findAllMongoDatasCount(s_date){ + def q = new BasicDBObject().append("s_date", s_date) + return thirdPartyColl.count(q) + } + + def findAllMongoDatasHavePricesCount(sDate){ + def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)) + return thirdPartyColl.count(q) + } + + def findMatchSuccessCount(sDate){ + def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)).append("status", 4) + return thirdPartyColl.count(q) + } + + def findNoMatchCount(sDate){ + def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)).append("status", new BasicDBObject('$exists', false)) + return thirdPartyColl.count(q) + } + + def saveOrUpdateDatas(sDate, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, matchTotalCount, noMatchTotalCount){ + def obj = THIRD_PARTY_STAT.findOne(new BasicDBObject("s_date", sDate)) + + def udata = new BasicDBObject() + udata.put("crawl_total", crawlTotalCount) + udata.put("synch_total", synchTotalCount) + udata.put("synch_have_price_total", synchHavePriceTotalCount) + udata.put("match_total", matchTotalCount) + udata.put("no_match_total", noMatchTotalCount) + udata.put("c_date", new Date()) + if(obj){ + udata.put("m_date", new Date()) + THIRD_PARTY_STAT.update(new BasicDBObject("_id",obj._id), new BasicDBObject('$set', udata)) + }else{ + udata.put("s_date", sDate) + THIRD_PARTY_STAT.save(udata) + } + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy index 1645e9131..f5da97fd8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy @@ -921,7 +921,7 @@ class FjwBigdataForsaleBatch extends BaseBatch{ def findAllHouseIdsByCity(){ // 创建布隆过滤器对象 - BloomFilter filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001); + BloomFilter filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 800000000, 0.000001); // def houseIds = new HashSet() pgsqlInstance.eachRow("SELECT gujia_sell_id FROM base.bigdata_forsale",{it-> filter.put(it.gujia_sell_id) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index 2d77f4142..daa08b17c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -35,9 +35,6 @@ class FjwThirdPartyPriceBatch extends BaseBatch { def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07","淘房365":"08","中原":"09","兔博士":"10","Q房":"11","房探":"12", "房多多":"13","我爱我家":"14","禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20"] - def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") - def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") @@ -392,139 +389,6 @@ class FjwThirdPartyPriceBatch extends BaseBatch { return rets; } - def createData3(cityid){ - def sql = "select COMMID, COMMNAME, CITYID, CITYNAME, DISTID, DISTNAME, YEAR_MONTH, ZHUGE_AVG_PRICE, ANJUKE_AVG_PRICE, FANG_AVG_PRICE, LIANJIA_AVG_PRICE, CITYHOUSE_AVG_PRICE, MAITIAN_AVG_PRICE, KE_AVG_PRICE, TAOFANG_AVG_PRICE, ZHONGYUAN_AVG_PRICE, TBS_AVG_PRICE, QFANG_AVG_PRICE, FANGTAN_AVG_PRICE, FANGDUODUO_AVG_PRICE, WIWJ_AVG_PRICE, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME from THIRD_PARTY_PRICE_GJ where CITYID='${cityid}' and YEAR_MONTH=${sDate}"; - def allRows = [] - sqlInstance.eachRow(sql,{r-> - def dataMap = [:] - - dataMap.COMMID = r.COMMID - dataMap.COMMNAME = r.COMMNAME - dataMap.CITYID = r.CITYID - dataMap.CITYNAME = r.CITYNAME - dataMap.DISTID = r.DISTID - dataMap.DISTNAME = r.DISTNAME - dataMap.YEAR_MONTH = r.YEAR_MONTH - def price_map = [:] - dataMap.price_map = price_map - if(r.ZHUGE_AVG_PRICE){ - price_map.zhuge_avg_price = r.ZHUGE_AVG_PRICE - } - - if(r.ANJUKE_AVG_PRICE){ - price_map.anjuke_avg_price = r.ANJUKE_AVG_PRICE - } - - if(r.FANG_AVG_PRICE){ - price_map.fang_avg_price = r.FANG_AVG_PRICE - } - - if(r.LIANJIA_AVG_PRICE){ - price_map.lianjia_avg_price = r.LIANJIA_AVG_PRICE - } - - if(r.CITYHOUSE_AVG_PRICE){ - price_map.cityhouse_avg_price = r.CITYHOUSE_AVG_PRICE - } - - if(r.MAITIAN_AVG_PRICE){ - price_map.maitian_avg_price = r.MAITIAN_AVG_PRICE - } - - if(r.KE_AVG_PRICE){ - price_map.ke_avg_price = r.KE_AVG_PRICE - } - - if(r.TAOFANG_AVG_PRICE){ - price_map.taofang_avg_price = r.TAOFANG_AVG_PRICE - } - - if(r.ZHONGYUAN_AVG_PRICE){ - price_map.zhongyuan_avg_price = r.ZHONGYUAN_AVG_PRICE - } - - if(r.TBS_AVG_PRICE){ - price_map.tbs_avg_price = r.TBS_AVG_PRICE - } - - if(r.QFANG_AVG_PRICE){ - price_map.qfang_avg_price = r.QFANG_AVG_PRICE - } - - if(r.FANGTAN_AVG_PRICE){ - price_map.fangtan_avg_price = r.FANGTAN_AVG_PRICE - } - - if(r.FANGDUODUO_AVG_PRICE){ - price_map.fangduoduo_avg_price = r.FANGDUODUO_AVG_PRICE - } - - if(r.WIWJ_AVG_PRICE){ - price_map.wiwj_avg_price = r.WIWJ_AVG_PRICE - } - dataMap.updatetime = r.UPDATETIME - - allRows << dataMap - }); - - - def results = [] - for(def m : allRows){ - def priceMap = m.price_map - priceMap.each{k,v-> - def ret = [] - ret << new ObjectId().toString() - ret << m.CITYID - ret << m.DISTID - ret << m.COMMID - ret << m.COMMNAME - - def web = "" - if(k=="zhuge_avg_price"){ - web = "诸葛找房" - }else if(k=="anjuke_avg_price"){ - web = "安居客" - }else if(k=="fang_avg_price"){ - web = "房天下" - }else if(k=="lianjia_avg_price"){ - web = "链家" - }else if(k=="cityhouse_avg_price"){ - web = "禧泰数据" - }else if(k=="maitian_avg_price"){ - web = "麦田" - }else if(k=="ke_avg_price"){ - web = "贝壳" - }else if(k=="taofang_avg_price"){ - web = "淘房365" - }else if(k=="zhongyuan_avg_price"){ - web = "中原" - }else if(k=="tbs_avg_price"){ - web = "兔博士" - }else if(k=="qfang_avg_price"){ - web = "Q房" - }else if(k=="fangtan_avg_price"){ - web = "房探" - }else if(k=="fangduoduo_avg_price"){ - web = "房多多" - }else if(k=="wiwj_avg_price"){ - web = "我爱我家" - } - - ret << sourceMap.get(web) - ret << web - ret << m.YEAR_MONTH - ret << v - ret << "" - ret << "" - ret << m.updatetime - results << ret - } - } - - return results - - } - def findThirdPartyPrice(def city, def statMap){ def q = new BasicDBObject() From 7ac29432191309084e3ae789dfc6273fd8eb9221 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 9 Aug 2024 15:13:42 +0800 Subject: [PATCH 17/45] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ronghe/ExportDistrictRongHe.groovy | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy index 846a244a8..c611aa10f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy @@ -146,7 +146,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataCommunityGJRH(){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMUNITY_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMUNITY_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMUNITY_FJW_ALL_${curDate}_0001.dat" } @@ -221,7 +221,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_PRICE_GJ_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_PRICE_GJ_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_COMMUNITY_PRICE_GJ_ALL_${curDate}_0001.dat" } @@ -253,7 +253,7 @@ class ExportDistrictRongHe extends BaseBatch{ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" // FJW_000000_000000_EVALUATE_RATE_CITY_FLW_ADD_ - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_CITY_FJW_HIS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_CITY_FJW_HIS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_EVALUATE_RATE_CITY_FJW_HIS_ADD_${curDate}_0001.dat" } @@ -295,7 +295,7 @@ class ExportDistrictRongHe extends BaseBatch{ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" // FJW_000000_000000_EVALUATE_RATE_COMM_FLW_ADD_ avm_evaluate_rate_comm_gj_h - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_COMM_FJW_HIS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_COMM_FJW_HIS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_EVALUATE_RATE_COMM_FJW_HIS_ADD_${curDate}_0001.dat" } @@ -327,7 +327,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMBUILDSTRU_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMBUILDSTRU_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMBUILDSTRU_FJW_ALL_${curDate}_0001.dat" } @@ -356,7 +356,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMHOUSETYPE_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMHOUSETYPE_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMHOUSETYPE_FJW_ALL_${curDate}_0001.dat" } @@ -384,7 +384,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMBUILDYEAR_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMBUILDYEAR_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMBUILDYEAR_FJW_ALL_${curDate}_0001.dat" } @@ -422,7 +422,7 @@ class ExportDistrictRongHe extends BaseBatch{ }); } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMFEE_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMFEE_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMFEE_FJW_ALL_${curDate}_0001.dat" } @@ -452,7 +452,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMHOUSEUSE_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMHOUSEUSE_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMHOUSEUSE_FJW_ALL_${curDate}_0001.dat" } @@ -485,7 +485,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_POSITION_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_POSITION_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_POSITION_FJW_ALL_${curDate}_0001.dat" } @@ -517,7 +517,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DISTRICT_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DISTRICT_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_DISTRICT_FJW_ALL_${curDate}_0001.dat" } @@ -552,7 +552,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_ADDRESS_ALIAS_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_ADDRESS_ALIAS_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_ADDRESS_ALIAS_FJW_ALL_${curDate}_0001.dat" } @@ -576,7 +576,7 @@ class ExportDistrictRongHe extends BaseBatch{ index++ def curStartStr = curStartDateStr - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curStartStr.replace("-","")}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curStartStr.replace("-","")}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curStartStr.replace("-","")}_0001.dat" } @@ -676,7 +676,7 @@ class ExportDistrictRongHe extends BaseBatch{ def endDateStr = DateUtils.formatDateByPattern(DateUtils.getLastDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") // def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMMdd") - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" } @@ -716,7 +716,7 @@ class ExportDistrictRongHe extends BaseBatch{ def endDateStr = DateUtils.formatDateByPattern(DateUtils.getLastDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" } @@ -987,7 +987,7 @@ class ExportDistrictRongHe extends BaseBatch{ allRows << data }); def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_DEAL_FJW_ADD_${curDate}_0001.dat" } @@ -998,7 +998,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataBuildingFJW(){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_BUILDING_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_BUILDING_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_BUILDING_FJW_ALL_${curDate}_0001.dat" } @@ -1072,7 +1072,7 @@ class ExportDistrictRongHe extends BaseBatch{ allRows << data }); def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_EVALUATE_RATE_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_EVALUATE_RATE_FJW_ALL_${curDate}_0001.dat" } @@ -1084,7 +1084,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportThirdPartyPrice2(price_date, new_dists) { def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "10"; - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" } @@ -1132,7 +1132,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgThirdPartyPrice2(price_date, new_dists){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28"; - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" } @@ -1215,7 +1215,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataBuildprojFjw(){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_BUILDPROJ_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_BUILDPROJ_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_BUILDPROJ_FJW_ALL_${curDate}_0001.dat" } @@ -1261,7 +1261,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_BASE_PRICE_GJNB_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_BASE_PRICE_GJNB_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_COMMUNITY_BASE_PRICE_GJNB_ADD_${curDate}_0001.dat" } @@ -1304,7 +1304,7 @@ class ExportDistrictRongHe extends BaseBatch{ } def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"28" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_COMM_BASE_PRICE_GJ_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_COMM_BASE_PRICE_GJ_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_COMM_BASE_PRICE_GJ_ADD_${curDate}_0001.dat" } @@ -1319,7 +1319,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportCommunityPdescribeGj(month){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_P_DESCRIBE_GJ_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_COMMUNITY_P_DESCRIBE_GJ_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_COMMUNITY_P_DESCRIBE_GJ_ADD_${curDate}_0001.dat" } @@ -1393,7 +1393,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgCommunityPdescribeGj(month){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"28" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_COMM_DESCRIBE_GJ_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_COMM_DESCRIBE_GJ_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_COMM_DESCRIBE_GJ_ADD_${curDate}_0001.dat" } @@ -1460,7 +1460,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportGuideStatistics(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" } @@ -1501,7 +1501,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgGuideStatistics(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"28" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_GUIDE_STATISTICS_ADD_${curDate}_0001.dat" } @@ -1537,7 +1537,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgBigdataSupplierStatistics(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"28" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" } @@ -1570,7 +1570,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataSupplierStatistics(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_SUPPLIER_STATISTICS_ADD_${curDate}_0001.dat" } @@ -1609,7 +1609,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataModelingBase(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" } @@ -1652,7 +1652,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgBigdataModelingBase(time){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"28" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_MODELING_BASE_ADD_${curDate}_0001.dat" } @@ -1689,7 +1689,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataCityPrice(queryDate){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_CITYPRICE_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_CITYPRICE_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_ronghe\\${curDate}\\FJW_000000_000000_BIGDATA_CITYPRICE_FJW_ADD_${curDate}_0001.dat" } @@ -1737,7 +1737,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataDistPrice(queryDate){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DISTPRICE_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_DISTPRICE_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_ronghe\\${curDate}\\FJW_000000_000000_BIGDATA_DISTPRICE_FJW_ADD_${curDate}_0001.dat" } @@ -1784,7 +1784,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataCommPrice(queryDate){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMPRICE_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMPRICE_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_ronghe\\${curDate}\\FJW_000000_000000_BIGDATA_COMMPRICE_FJW_ADD_${curDate}_0001.dat" } @@ -1845,7 +1845,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataCommlayoutpicFjw(){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMLAYOUTPIC_FJW_ALL_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_COMMLAYOUTPIC_FJW_ALL_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_COMMLAYOUTPIC_FJW_ALL_${curDate}_0001.dat" } @@ -1856,7 +1856,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportBigdataForsale(publishDate, new_dists){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" } @@ -1913,7 +1913,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportPgBigdataForsale(publishDate,endDate, new_dists){ def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM")+"10" - def fileName = "/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" + def fileName = "/home/ccb_rh/${curDate}/FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\FJW_000000_000000_BIGDATA_FORSALE_FJW_ADD_${curDate}_0001.dat" } @@ -2098,7 +2098,7 @@ class ExportDistrictRongHe extends BaseBatch{ def exportOk(curDate){ // def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMMdd") - def dataCodeFileName = "/ccb_rh/${curDate}/${curDate}.ok" + def dataCodeFileName = "/home/ccb_rh/${curDate}/${curDate}.ok" if(CommonDatautils.isWindow()){ dataCodeFileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\ccb_rh\\${curDate}\\${curDate}.ok" } From cb611af44f6583af1597f901bde736f1e38240e6 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 9 Aug 2024 15:14:30 +0800 Subject: [PATCH 18/45] update --- .../fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy index 0e5692cb7..04bdb7d77 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy @@ -61,7 +61,7 @@ class DataStandardBatch extends BaseBatch{ private static def districtMap = [:]; private static def limit = 5000; - def static final SHORT_DATE = Utils.getLastMonth() + def static final SHORT_DATE = Integer.parseInt(com.fangjia.script.util.DateUtils.addMonth(com.fangjia.script.util.DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); def static final statusMap = ["城市未匹配":1,"区域未匹配":2,"小区匹配失败":3,"小区匹配成功":4,"异常错误":5, "无价格":6, "无名称":7] def static final websites = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集", "链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋","幸福里"] @@ -922,7 +922,7 @@ class DataStandardBatch extends BaseBatch{ //查找出所有未进行匹配的数据 def findAllNoMatchData(){ DBObject qdata = new BasicDBObject(); - qdata.put("s_date", SHORT_DATE) + qdata.put("s_date", new BasicDBObject('$gte', SHORT_DATE)) // qdata.put("city","福州") // qdata.put("source","安居客") // qdata.put("name",Pattern.compile("龚家宅.*")) From d270779225c76a59b04c27afff3607d9220992fc Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 9 Aug 2024 15:45:53 +0800 Subject: [PATCH 19/45] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BD=91=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy | 2 +- .../fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy | 2 +- .../script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy index 04bdb7d77..f1df981ef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy @@ -64,7 +64,7 @@ class DataStandardBatch extends BaseBatch{ def static final SHORT_DATE = Integer.parseInt(com.fangjia.script.util.DateUtils.addMonth(com.fangjia.script.util.DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); def static final statusMap = ["城市未匹配":1,"区域未匹配":2,"小区匹配失败":3,"小区匹配成功":4,"异常错误":5, "无价格":6, "无名称":7] - def static final websites = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集", "链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋","幸福里"] + def static final websites = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集", "链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋","幸福里","中国房价行情","常州住房"] public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) static { thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy index 33e407462..4bb2aff5a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy @@ -27,7 +27,7 @@ class SynchDistrictPrice extends BaseBatch{ // "吉屋":"吉屋","365淘房":"365淘房","我爱我家":"我爱我家","诸葛找房APP":"诸葛找房","贝壳":"贝壳找房","链家":"链家","Q房":"Q房","麦田":"麦田", // "中原地产":"中原地产","安居客小程序":"安居客","搜房":"搜房","乐有家":"乐有家","C21":"C21","城市房产":"城市房产","兔博士PC端":"兔博士" // def esSources = ["搜房":"搜房"] - def esSources = ["我爱我家":"我爱我家","兔博士PC端":"兔博士","吉屋":"吉屋","贝壳找房":"贝壳找房","乐有家":"乐有家","365淘房":"365淘房","诸葛找房APP":"诸葛找房","链家":"链家","Q房":"Q房","麦田":"麦田","中原地产":"中原地产","安居客小程序":"安居客","搜房":"搜房","C21":"C21","城市房产小程序":"城市房产","幸福里APP":"幸福里"] + def esSources = ["我爱我家":"我爱我家","兔博士PC端":"兔博士","吉屋":"吉屋","贝壳找房":"贝壳找房","乐有家":"乐有家","365淘房":"365淘房","诸葛找房APP":"诸葛找房","链家":"链家","Q房":"Q房","麦田":"麦田","中原地产":"中原地产","安居客小程序":"安居客","搜房":"搜房","C21":"C21","城市房产小程序":"城市房产","幸福里APP":"幸福里", "中国房价行情":"中国房价行情","常州住房":"常州住房"] static main(args) { runBatch(new SynchDistrictPrice(), args); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy index ad821196e..aaf9d6380 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy @@ -32,7 +32,8 @@ class ThirdDataToGatherBatch extends BaseBatch{ "房估估":"fanggugu_esf","诸葛找房":"zhugezhaofang_esf","安居客":"anjuke_esf","搜房":"soufang_esf","中原地产":"zhongyuan_esf","赶集":"ganji_esf", "链家":"lianjia_esf","兔博士":"tuboshi_esf","城市房产":"cityhouse_esf","贝壳找房":"beike_esf","Q房":"qfang_esf","Q房(新)":"qfang_new","中原地产(新)":"zhongyuan_new", "乐有家":"leyoujia_esf","乐有家(新)":"leyoujia_new","房探":"fangtan_esf","房多多":"fangdoudou_esf","小资家":"xiaozijia_esf","我爱我家":"5i5j_esf","麦田":"maitian_esf", - "房途":"fangtoo_esf","C21":"c21_esf","乐居":"leju_esf","房产超市":"fccs_esf","58同城":"58tc_esf","365淘房":"365house_esf","吉屋":"jiwu_esf","幸福里":"xingfuli_esf" + "房途":"fangtoo_esf","C21":"c21_esf","乐居":"leju_esf","房产超市":"fccs_esf","58同城":"58tc_esf","365淘房":"365house_esf","吉屋":"jiwu_esf","幸福里":"xingfuli_esf", + "中国房价行情":"creprice_esf","常州住房":"zwfc_esf" ] public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2) From ece09656373f3449b067ed4e9997c2729e1bd03b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 12 Aug 2024 11:13:32 +0800 Subject: [PATCH 20/45] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=8F=E5=A4=AA?= =?UTF-8?q?=E5=A4=9A=E6=8C=89=E5=9F=8E=E5=B8=82=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/ccbevaluation/TestExport.groovy | 14 ++++ .../com/fangjia/script/gj/GreenBuild.groovy | 79 +++++++++++++++++++ .../FjwBigdataForsaleBatch.groovy | 7 +- 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TestExport.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/GreenBuild.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TestExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TestExport.groovy new file mode 100644 index 000000000..f84530d3d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TestExport.groovy @@ -0,0 +1,14 @@ +package com.fangjia.script.ccbevaluation + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.ExcelUtils + +ExcelUtils.modify("D:\\数据\\建行\\东莞202406.xlsx", { d -> + if(d['G'] && d['G'] instanceof String){ + + def obj = CommonDatautils.findDistrictById(d['G']) + if(obj){ + d['H'] = obj.name + } + } +}) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/GreenBuild.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/GreenBuild.groovy new file mode 100644 index 000000000..e66933e4d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/GreenBuild.groovy @@ -0,0 +1,79 @@ +package com.fangjia.script.gj + +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class GreenBuild { + + DBCollection GREEN_BUILD_COLL = MongoUtils.getCollectionByName("crawl", "green_build_project", "192.168.0.206",27020) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + + + static main(args) { + def task = new GreenBuild() + task.run() + } + + def run(){ + def datas = findAll() + def rets = match(datas) + ExcelUtils.write("D:\\数据\\绿色建筑\\绿色建筑匹配住宅.xlsx", rets, "匹配结果") + } + + def match(datas){ + + def rets = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(datas.size()) + + rets << ["ID", "城市","区域", "名称", "匹配ID", "匹配城市" , "匹配区域" ,"匹配名称"] + for(def i=0;i filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 800000000, 0.000001); // def houseIds = new HashSet() - pgsqlInstance.eachRow("SELECT gujia_sell_id FROM base.bigdata_forsale",{it-> + pgsqlInstance.eachRow("SELECT gujia_sell_id FROM base.bigdata_forsale where urbn_nm='${city}'",{it-> filter.put(it.gujia_sell_id) }); From 9958587d1205ab4a75b610411cdaa01968e141b9 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 12 Aug 2024 11:41:37 +0800 Subject: [PATCH 21/45] =?UTF-8?q?=E6=88=BF=E6=BA=90=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8C=89=E5=9F=8E=E5=B8=82id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy index 8a95c6476..c40ba1e41 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy @@ -98,7 +98,7 @@ class FjwBigdataForsaleBatch extends BaseBatch{ for(def city : citys){ index++ - houseIdsfilter = findAllHouseIdsByCity(city) + houseIdsfilter = findAllHouseIdsByCity(cityCodeDataMap.get(city)) def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"], "all"); exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, startDate.toInteger(), endDate.toInteger(), houseIdsfilter); @@ -920,11 +920,11 @@ class FjwBigdataForsaleBatch extends BaseBatch{ return houseIds; } - def findAllHouseIdsByCity(city){ + def findAllHouseIdsByCity(cityid){ // 创建布隆过滤器对象 - BloomFilter filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 800000000, 0.000001); + BloomFilter filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001); // def houseIds = new HashSet() - pgsqlInstance.eachRow("SELECT gujia_sell_id FROM base.bigdata_forsale where urbn_nm='${city}'",{it-> + pgsqlInstance.eachRow("SELECT gujia_sell_id FROM base.bigdata_forsale where urbn_id='${cityid}'",{it-> filter.put(it.gujia_sell_id) }); From f76253f9833297822d6af64e386060f53c90eb88 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 12 Aug 2024 11:50:45 +0800 Subject: [PATCH 22/45] =?UTF-8?q?=E6=88=BF=E4=BB=B7=E7=BD=91=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=9D=87=E4=BB=B7=E7=B3=BB=E7=BB=9F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9C=80=E8=BF=912=E4=B8=AA=E6=9C=88=E7=9A=84=E6=88=BF?= =?UTF-8?q?=E6=BA=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/ccbevaluation/AddSzDealData.groovy | 2 +- .../fangjia/script/ccbevaluation/Test.groovy | 71 ++++- .../script/ccbevaluation/TradeStatLog.groovy | 70 ++++- .../fangjia/script/gj/OpenUserBatch.groovy | 14 +- .../script/gj/data_handle/AddDistAddr.groovy | 247 ++++++++++++++++ .../script/gj/data_handle/DevProcess.groovy | 192 +++++++++++- .../gj/data_handle/DevUpdateTestBatch.groovy | 277 ++++++++++++++++++ .../data_handle/DistrictAliasProcess.groovy | 35 ++- .../gj/data_handle/GXDdistrictMatch.groovy | 10 +- .../script/gj/data_handle/PoiLocation.groovy | 92 +++++- .../gj/data_handle/TownMiddleProcess.groovy | 239 ++++++++++++++- .../data_handle/TownshipStrandUpdate.groovy | 254 +++++++++++++++- .../FjwBigdataForsaleBatch.groovy | 5 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 44 +-- .../script/gj/village/QiliangTest.groovy | 4 +- .../script/gj/xiamen/ElasticUtils89.groovy | 265 +++++++++++++++++ .../gj/xiamen/GaoDePoiDataProcess.groovy | 233 +++++++++++---- .../script/gj/xiamen/SeaweedDataSynch.groovy | 2 +- .../com/fangjia/script/util/DESUtil.groovy | 69 +++++ .../yinjihaun/amap/GaoDeApiUtils.groovy | 3 +- 20 files changed, 1995 insertions(+), 133 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistAddr.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/util/DESUtil.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy index ff77ef91f..449e1ad79 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\20240619--深圳成交数据.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年6月深圳二手房成交.xlsx", 0, 1) def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy index 6b7876324..13a46482e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy @@ -199,6 +199,16 @@ def findAllData(sqlInstance236, citycode){ } +//ExcelUtils.modify("D:\\数据\\建行\\保定202406.xlsx", { d -> +// if(d['G']){ +// def obj = CommonDatautils.findDistrictById(d['G']) +// if(obj){ +// d['H'] = obj.name +// } +// } +//}) + + ////def url = "https://sh.anjuke.com" ////def s = DataHandleUtils.findMatchPattern(name, "https://\\w+.anjuke.com") @@ -1289,7 +1299,7 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){ -def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240626人工指导价.xlsx" +def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240806--国信达价格录入.xlsx" ExcelUtils.multiThreadingModify(fileName, {d-> if(d['J']){ @@ -1308,9 +1318,9 @@ ExcelUtils.multiThreadingModify(fileName, {d-> d['A'] = dist.city d['B'] = dist.region d['C'] = dist.name -// d['K'] = dist.estate_type2 -// d['L'] = dist.status -// d['M'] = dist.name_cat + d['K'] = dist.estate_type2 + d['L'] = dist.status + d['M'] = dist.name_cat // d['H'] = dist.name } @@ -1352,24 +1362,57 @@ ExcelUtils.multiThreadingModify(fileName, {d-> // //}) - -//def filePath = "D:\\数据\\建行\\房产估值\\指导价\\大庆删除小区.xlsx" +// +//def filePath = "D:\\数据\\数据建设\\小区\\嘉峪关处理.xlsx" //ExcelUtils.modify(filePath, { d -> // if(d['A']){ -// -// def obj = CommonDatautils.findDistrictById(d['A']) -// if(obj){ -// -// def data = new BasicDBObject() -// data.put("status", 1) -// data.put("m_date", new Date()) -// DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])), new BasicDBObject('$set', data)) +//// def obj = CommonDatautils.findDistrictById(d['A']) +// def obj = CommonDatautils.findDistrict(d['A'], d['B'], d['C'], "district") +// def list = CommonDatautils.findDistrictList(d['A'], null, d['C'], "district") +// if(list){ +// if(list.size()==1){ +// def dbo = list[0] +// if(dbo){ +// def data = new BasicDBObject() +// data.put("region", d['B']) +// data.put("m_date", new Date()) +// DbUtils.seaweed.update(new BasicDBObject('_id',dbo._id), new BasicDBObject('$set', data)) +// } +// }else{ +// println d['C'] +" 有多个" +// } // } +//// if(obj){ +//// def lng = d['G'] +//// def lat =d['H'] +//// +//// // 高德转百度 +//// def baidu = BaiDuApiUtils.geoconv(d['G'].toString().toDouble(), d['H'].toString().toDouble(), 3) +//// def lng2 = baidu.x +//// def lat2 = baidu.y +//// +//// +//// def data = new BasicDBObject() +//// Long lng_new = d['G'].toString().toDouble() *10000000000L +//// Long lat_new = d['H'].toString().toDouble() *10000000000L +//// data.put("lng", lng_new) +//// data.put("lat", lat_new) +//// +//// Long dLat2 = lat2 * 10000000000L +//// Long dLng2 = lng2 * 10000000000L +//// data.put("lat2", dLat2) +//// data.put("lng2", dLng2) +//// +////// data.put("status", 1) +//// data.put("m_date", new Date()) +//// DbUtils.seaweed.update(new BasicDBObject('_id',obj._id), new BasicDBObject('$set', data)) +//// } // } // //}) + //def fileName = "D:\\数据\\建行\\房产估值\\指导价\\2024-04-08修改人工指导价.xlsx" //ExcelUtils.multiThreadingModify(fileName, { d -> // if(d['B'] && !d['D']){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy index 57bdfdbd9..9fc014cca 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy @@ -32,6 +32,10 @@ class TradeStatLog { def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") + + def pssqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified", + "postgres", "postgres", "org.postgresql.Driver") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) @@ -41,7 +45,9 @@ class TradeStatLog { static main(args) { def task = new TradeStatLog() // task.run()//统计最近3个月抓取的成交数据量 - task.exportTrade()//导出未入库成交 +// task.exportTrade()//导出未入库成交 + + task.exportTrade2()//导出未入库成交 // task.thirdPartyStat() // println Calendar.getInstance().get(Calendar.YEAR) // task.averageStat() @@ -584,6 +590,36 @@ class TradeStatLog { ExcelUtils.write("D:\\数据\\建行\\房产估值\\成交\\成交未入库记录(1月).xlsx", rets,"数据") } + + def exportTrade2(){ + +// def startDate = "2024-06-01" +// def endDate = "2024-07-01" + def ids = findAllDealIds(); + println ids.size() + ExcelUtils.multiThreadingModify("D:\\数据\\其它\\2024年6月成交数据.xlsx",{d-> + if(ids.contains(d['A'])){ + d['V'] = "供" + } + if(d['S'] && !d['W']){ + def dist = CommonDatautils.findDistrictById(d['S']) + if(!dist.name_cat && dist.name_cat!=0){ + d['W'] = "name_cat过滤" + } + if(dist.name_cat != 0 || !dist.lng || !["普通住宅","商住"].contains(dist.estate_type2) || dist.name.contains("洋房") || dist.name.contains("公房")){ + d['W'] = "小区过滤" + } + def key = d['B']+"##"+d['Q']+"##"+d['R']+"##"+d['D']+"##"+d['E'].toString().toDouble().toInteger()+"##"+d['J'].toString().substring(0,10) + def map = findDealByCommId(d['B'], d['S']) + def count = map.get(key) + if(count>=2){ + d['W'] = "重复" + } + } + println d['A'] + }) + } + def deleteDistrict(){ ExcelUtils.multiThreadingModify("D:\\数据\\建行\\房产估值\\要删除小区.xlsx",{d-> if(d['G']){ @@ -637,11 +673,39 @@ class TradeStatLog { return trades } + def findAllDealIds(){ + def sql = "select gujia_bds_mdl_id from base.t0831_bigdata_deal_gj_h where p9_start_date='2024-07-28'" + def ids = [] + pssqlInstance.eachRow(sql,{r-> + if(!ids.contains(r.gujia_bds_mdl_id)){ + ids << r.gujia_bds_mdl_id + } + }) + return ids + } + + def findDealByCommId(city, commid){ + def q = new BasicDBObject() + q.put("match_id", commid) + q.put("city", city) + q.put('trade_date', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2024-06-01")).append('$lt', DateUtils.parseFromTightYYYYMMDD("2024-07-01"))); + def dbcursor = DEAL_PRICE_COLL.find(q) + def map = [:] + for(def d : dbcursor){ + def key = d.city+"##"+d.match_region+"##"+d.match_name+"##"+d.area+"##"+d.avg_price+"##"+DateUtils.formatDateByPattern(d.trade_date,"yyyy-MM-dd") + def count = map.get(key) + if(!count){ + count = 0 + } + map.put(key, count+1) + } + return map + } + def findDealIds(city, startDate, endDate){ def sql = "select * from bigdata_deal_gj where dealdate>=to_date('${startDate}','yyyy-mm-dd') and dealdate + pssqlInstance.eachRow(sql,{r-> if(!ids.contains(r.dealid)){ ids << r.dealid diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy index 42dd5ea08..a87dbc4c2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy @@ -12,8 +12,8 @@ class OpenUserBatch { def task = new OpenUserBatch(); // task.run(); // task.test(); -// task.addShenZhenFjtUser(); - task.addFujianFjtUser() + task.addShenZhenFjtUser(); +// task.addFujianFjtUser() } def test(){ @@ -46,20 +46,20 @@ class OpenUserBatch { } def addShenZhenFjtUser(){ - def datas = ExcelUtils.read("D:\\数据\\渤海\\开通线上评估客户经理名单.xlsx",0,1) + def datas = ExcelUtils.read("D:\\数据\\黑龙江银行\\大正银行端新增账户模板中国银行.xls",0,1) def i = 0; for(def data : datas){ i++; - def id = 252608 + i; + def id = 252893 + i; BigDecimal bd = new BigDecimal(data[3].toString()); String mobile = bd.toPlainString(); - def sql = "insert into users(id, email, password, role, user_role, city, gold_total, come_from, date_created, last_updated, status, uid, access_token, house_report_token, open_day, fangdiao_apply_add, gujia_add, fangdiao_apply_count, gujia_down_count, fangdiao_add, fangdiao_down_count, yang_ben_down, mobile, pay_password, evaluation_count, close_date, manager, role_users, weixinId) VALUES ("+id+", '"+mobile+"', '666666', '17', NULL, NULL, '0', 'fangjiatong', now(), now(), '0', NULL, NULL, '', '0', '2', '2', '2', '500', NULL, NULL, '0', NULL, NULL, NULL, '2023-01-01 00:00:00', '0', '', NULL)"; + def sql = "insert into users(id, email, password, role, user_role, city, gold_total, come_from, date_created, last_updated, status, uid, access_token, house_report_token, open_day, fangdiao_apply_add, gujia_add, fangdiao_apply_count, gujia_down_count, fangdiao_add, fangdiao_down_count, yang_ben_down, mobile, pay_password, evaluation_count, close_date, manager, role_users, weixinId) VALUES ("+id+", '"+mobile+"', '666666', '18', NULL, NULL, '0', 'fangjiatong', now(), now(), '0', NULL, NULL, '', '0', '2', '2', '2', '500', NULL, NULL, '0', NULL, NULL, NULL, '2025-12-31 00:00:00', '0', '', NULL)"; onLineSqlInstance.execute(sql); - def sql2 = "INSERT INTO users_detail (id, p_id,name, org_name, phone, fax, email, address, role, company, user_valid_date, online_status, last_login_date, last_operat_date, date_created, last_updated, mobile, eva_guide, ip_list, sale_name) VALUES ('"+id+"', '0', '"+data[2]+"', '"+data[1]+"', '"+mobile+"', NULL, NULL, NULL, NULL, NULL, NULL, b'0', now(), now(), now(), now(), NULL, b'0', '', '姚静梦')"; + def sql2 = "INSERT INTO users_detail (id, p_id,name, org_name, phone, fax, email, address, role, company, user_valid_date, online_status, last_login_date, last_operat_date, date_created, last_updated, mobile, eva_guide, ip_list, sale_name) VALUES ('"+id+"', '0', '"+data[2]+"', '"+data[1]+"', '"+mobile+"', NULL, NULL, NULL, NULL, NULL, NULL, b'0', now(), now(), now(), now(), NULL, b'0', '', '王蕾')"; onLineSqlInstance.execute(sql2) - def sql3 = "INSERT INTO user_city (user_id, citys, credits) VALUES("+id+",'上海','上海:')" + def sql3 = "INSERT INTO user_city (user_id, citys, credits) VALUES("+id+",'哈尔滨,齐齐哈尔,大庆,牡丹江,佳木斯,绥化,鸡西,七台河,双鸭山,鹤岗,黑河,伊春,大兴安岭','哈尔滨:,齐齐哈尔:,大庆:,牡丹江:,佳木斯:,绥化:,鸡西:,七台河:,双鸭山:,鹤岗:,黑河:,伊春:,大兴安岭:')" onLineSqlInstance.execute(sql3) } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistAddr.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistAddr.groovy new file mode 100644 index 000000000..62d8f6b8a --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistAddr.groovy @@ -0,0 +1,247 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.OpenApiUtils +import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils +import com.mongodb.BasicDBObject +import org.bson.types.ObjectId + +class AddDistAddr { + 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","胡杨河市":"3370","新星市":"3384","昆玉市":"659009","三沙市":"3336","白沙黎族自治县":"2359","乐东黎族自治县":"2032","陵水黎族自治县":"1643","琼中黎族苗族自治县":"2031","毕节市":"206","济源市":"1277","昌江黎族自治县":"1642","吐鲁番市":"89","林芝市":"98"] + + static main(args) { + def task = new AddDistAddr() +// task.run() +// task.addAddr() +// task.addBaiduSearch() +// task.addCrawlDistAddr() +// task.addGaoDeDistAddr() + +// task.checkCalway() + task.updateAddr() + } + + def run(){ + def citys = CommonDatautils.findAllCity() + def noAddrs = [] + noAddrs << ["ID", "城市", "区域", "名称", "地址", "别名", "经度", "纬度"] + for(def c : citys){ + def dists = CommonDatautils.findAllDistricts(c, "district", ["city","region", "name", "address", "alias", "lng", "lat"]) + for(def d : dists){ + def addr = d.address + if(!addr){ + noAddrs << [d._id.toString(), d.city, d.region, d.name, d.address, d.alias?d.alias.join(","):'', d.lng?d.lng/10000000000.0:'', d.lat?d.lat/10000000000.0:''] + } + } + println c + " "+ dists.size()+" "+noAddrs.size() + } + ExcelUtils.write("D:\\数据\\数据建设\\小区\\小区无址址数据.xlsx",noAddrs, "小区") + } + + def addAddr(){ + ExcelUtils.modify("D:\\数据\\数据建设\\小区\\小区无址址数据.xlsx",{d-> + if(d['A']){ + def locMap = CommonDatautils.getTownshipInfo(d['G']+","+d['H']) + if(locMap){ + if(locMap.city && locMap.city!='[]'){ + d['I'] = locMap.city + } + + if(locMap.district && locMap.district!='[]'){ + d['J'] = locMap.district + } + + if(locMap.format_addr && locMap.format_addr!='[]'){ + d['K'] = locMap.format_addr + } + if(locMap.road && locMap.road!='[]'){ + d['L'] = locMap.road + } + + if(locMap.name && locMap.name!='[]'){ + d['M'] = locMap.road + } + + if(locMap.type && locMap.type!='[]'){ + d['N'] = locMap.type + } + + } + println d['D'] + } + }, 1) + } + + def addBaiduSearch(){ + + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\小区\\小区无址址数据.xlsx",{d-> + if(!d['P']){ + def code = codeMap.get(d['B']); + def rets = null + try{ + if(code){ + rets = OpenApiUtils.searchBaiDuMap(d['C'], null, d['B']+d['D'], code.toInteger()); + }else{ + rets = OpenApiUtils.searchBaiDuMap(d['C'], null, d['B']+d['D'], null); + } + }catch(Exception e){ + println "error.................................................................." + } + + if(rets){ + def o = null + if(rets.size()>1){ + for(def r : rets){ + if(r.region && r.region.contains(d['C'])){ + o = r + break + } + } + } + if(!o){ + o = rets[0] + } + d['Q'] = o.city + d['R'] = o.region + d['S'] = o.name + d['T'] = o.address + d['U'] = o.estateType + if(o.address){ + def formatAddress = AddressUtil.formatAddress(d['B'], o.address) + + if(!formatAddress){ + if(o.address.contains("交叉口")){ + if(o.address.contains(o.region)){ + formatAddress = o.address.substring(o.address.indexOf(o.region)+o.region.size(), o.address.toString().indexOf("交叉口")+3) + }else{ + formatAddress = o.address.substring(0, o.address.toString().indexOf("交叉口")+3) + } + + }else if(o.address.contains("交叉")){ + if(o.address.contains(o.region)){ + formatAddress = o.address.substring(o.address.indexOf(o.region)+o.region.size(), o.address.toString().indexOf("交叉")+2) + }else{ + formatAddress = o.address.substring(0, o.address.toString().indexOf("交叉")+2) + } + } + } + d['V'] = formatAddress + + } + } + } + }) + } + + + def findDatas(def city, def region, def name1){ + def sql = "select * from community where city='${city}' and region='${region}' and name='${name1}'" + def rets = [] + ElasticUtils.executeSqlQuery(sql, { d-> + rets << d + println d.property_type + }) + + if(rets){ + def obj = null + for(def r : rets){ + if(r.property_type && (r.property_type.contains("住宅") || r.property_type.contains("别墅") || r.property_type.contains("公寓"))){ + obj = r + break + } + } + if(obj){ + return obj; + }else{ + return rets[0]; + } + + } + return null; + } + + def addCrawlDistAddr(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\小区\\小区无址址数据.xlsx",{d-> + if(d['A']){ + def obj = findDatas(d['B'], d['C'], d['D']) + if(obj){ + d['AA'] = obj.city + d['AB'] = obj.region + d['AC'] = obj.name + d['AD'] = obj.address + } + } + }) + } + + def addGaoDeDistAddr(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\小区\\小区无址址数据1.xlsx",{d-> + if(d['A']){ + try{ + def list = OpenApiUtils.queryMaxSimilarAddress(d['B'], d['C']+d['D']) + if(list){ + def o = list[0] + d['J'] = o.cityname + d['K'] = o.adname + d['L'] = o.name + d['M'] = o.address + d['N'] = o.type + if(o.address){ + def formatAddress = AddressUtil.formatAddress(d['B'], o.address) + + if(!formatAddress){ + if(o.address.contains("交叉口")){ + if(o.address.contains(o.region)){ + formatAddress = o.address.substring(o.address.indexOf(o.region)+o.region.size(), o.address.toString().indexOf("交叉口")+3) + }else{ + formatAddress = o.address.substring(0, o.address.toString().indexOf("交叉口")+3) + } + + }else if(o.address.contains("交叉")){ + if(o.address.contains(o.region)){ + formatAddress = o.address.substring(o.address.indexOf(o.region)+o.region.size(), o.address.toString().indexOf("交叉")+2) + }else{ + formatAddress = o.address.substring(0, o.address.toString().indexOf("交叉")+2) + } + } + } + d['O'] = formatAddress + + } + + } + }catch(Exception e){ + println "error" + } + + } + }) + } + + def checkCalway(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\小区\\小区无址址数据1.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['A']) +// def priceObj = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) +// if(priceObj){ +// d['AE'] = priceObj.cal_type +// } + d['AF'] = dist.estate_type2 + d['AG'] = dist.name_cat + }) + } + + def updateAddr(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\小区\\小区无址址数据1.xlsx",{d-> + if(d['AA']){ + BasicDBObject q=new BasicDBObject('address',d['AA']) + q.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])),new BasicDBObject('$set',q)) + } + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 2084175da..f90ed42f6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -7,6 +7,7 @@ import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.gj.district.SeaweedDataMatchProcess import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils @@ -17,6 +18,8 @@ import net.sf.json.JSONObject import org.apache.poi.ss.util.RegionUtil import org.bson.types.ObjectId +import java.util.regex.Pattern + class DevProcess { def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; @@ -28,11 +31,13 @@ class DevProcess { DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + DBCollection kfq_COLL = MongoUtils.getCollectionByName("crawl", "kfq_investchn_com", "192.168.0.206",27020) + static main(args) { def task = new DevProcess(); // task.run() // task.parseCityAndDist() - task.devSplitRoad() +// task.devSplitRoad() // task.devNameSplitRoad() // task.addFlag() // task.matchDev() @@ -41,6 +46,7 @@ class DevProcess { // task.updateCityAndDist() // task.addDevAddres1() //按添加地址中包含开发区名称的地址 // task.addDevAddres2()//添加相差2公里范围内的地址 +// task.addDevAddres3() // task.matchDevAndAddAddress() // task.stat() @@ -56,6 +62,15 @@ class DevProcess { // task.matchDevTownship()//添加乡镇街道 // task.addDevStreet()//添加区域为等级开发区下的街道到开发区对应表中 + +// task.matchNewCrawlDev() + +// println DateUtils.add("2024-7-24", 7); + +// task.addKfc() +// task.devToPark() //开发区下辖园区 + task.checkTown() + } @@ -334,15 +349,22 @@ class DevProcess { } def matchDev(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\福建省.xlsx",{d-> - if(!d['Q'] && d['L']){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\省级开发区名单\\新疆开发区名单.xlsx",{d-> + if(!d['Q'] && d['A']){ def q = new BasicDBObject() - q.put("name", d['L']) - q.put("city",d['G']) +// q.put("name", d['A']) +// q.put("city",d['G']) +// q.put('alias', new BasicDBObject('$in',[d['A']])) + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+d['A']+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 def obj = development_zone_CONN.findOne(q) if(obj){ - d['Q'] = obj._id.toString() - d['R'] = obj.name + d['C'] = obj._id.toString() + d['D'] = obj.name + if(obj.name == d['A']){ + d['E'] = "相同" + }else{ + d['E'] = "包含" + } } } },0); @@ -509,6 +531,38 @@ class DevProcess { // ExcelUtils.write("D:\\数据\\数据建设\\待新增开发区.xlsx",rets, "新增") } + + def addDevAddres3(){ + def index = 0 + ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\新跑省份\\新疆省入库.xlsx",{d-> + if(d['A']){ + def obj = development_zone_CONN.findOne(new BasicDBObject("name", d['A'])) + if(obj){ + d['C'] = obj._id.toString() + + def q2 = new BasicDBObject() + q2.put("name", d['A']) + q2.put("address", d['B']) + q2.put("type","地址") + def sameObj = DEV_MAPPING_CONN.findOne(q2) + if(!sameObj){ + index++ + def udata = new BasicDBObject() + udata.put("province", obj.province) + udata.put("city", obj.city) + udata.put("district", obj.district) + udata.put("name",obj.name) + udata.put("type", "地址") + udata.put("address", d['B']) + DEV_MAPPING_CONN.save(udata) + } + } + } + },0) + println index +// ExcelUtils.write("D:\\数据\\数据建设\\待新增开发区.xlsx",rets, "新增") + } + def stat(){ def dbcursor = development_zone_CONN.find(new BasicDBObject()) def total = 0 @@ -777,4 +831,128 @@ class DevProcess { }) } + + def matchNewCrawlDev(){ + def query = new BasicDBObject() + query.put("match_id", new BasicDBObject('$exists', false)) + def list = kfq_COLL.find(query).toList() + for(def d : list){ + def q = new BasicDBObject() +// q.put("name", d.name) + q.put('alias', new BasicDBObject('$in',[d.name])) + def obj = development_zone_CONN.findOne(q) + if(obj){ + def udata = new BasicDBObject() + udata.put("match_id", obj._id.toString()) + udata.put("match_name", obj.name) + kfq_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) + } + } + } + + def addKfc(){ + ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\投促中国开发区(1).xlsx",{d-> + if(d['I']){ + if(d['I'] == "添加"){ + def udata = new BasicDBObject() + udata.put("create_time" , new Date()) + udata.put("industry",d['D']) + if(d['E'].contains("国家级")){ + udata.put("level" ,"国家级") + }else if(d['E'].contains("省级")){ + udata.put("level" ,"省级") + } + udata.put("name" ,d['F']) + udata.put("province" ,d['G']) + udata.put("type" ,d['H']) + udata.put("city" ,d['B']) + udata.put("district" ,d['J']) + development_zone_CONN.save(udata) + }else{ + def q = new BasicDBObject() + q.put("name", d['I']) + def obj = development_zone_CONN.findOne(q) + if(obj){ + def alias = [] + if(obj.alias){ + alias = obj.alias + } + if(!alias.contains(d['F'])){ + alias << d['F'] + } + if(alias && alias.size()!=obj.alias.size()){ + def updateData = new BasicDBObject() + updateData.put("alias", alias) + development_zone_CONN.update(new BasicDBObject("_id",obj._id), new BasicDBObject('$set',updateData)) + } + + } + } + } + }) + } + + def devToPark(){ + def datas = ExcelUtils.read("D:\\数据\\数据建设\\开发区\\开发区下辖街道-处理后表格.xlsx",0, 1) + def rets = [] + rets << ["开发区名称", "下辖街道", "城市", "区域"] + for(def d : datas){ + if(d['E']){ + def arrs = d['E'].split(",") + def q = new BasicDBObject().append("name", d['B']) + def obj = development_zone_CONN.findOne(q) + if(obj){ + for(def park : arrs){ + rets << [d['B'], park, obj.city, obj.district] + } + } + } + } + ExcelUtils.write("D:\\数据\\数据建设\\开发区\\开发区下辖园区.xlsx", rets, "下辖街道") + } + + + def checkTown(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\开发区下辖园区.xlsx",{d-> + + if(!d['E']){ + if(d['C'] && d['D']){ +// if(d['A']=="长春高新技术产业开发区"){ + def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['C'], d['D']+d['B']) + if(jsonObject1) { + if (jsonObject1.get("townCode") && jsonObject1.get("townCode")!='null' && jsonObject1.get("townCode")!='') { + def township = jsonObject1.get("township") + def district = jsonObject1.get("district") + d['E'] = "接口" + if(district && district!='null'){ + d['F'] = district + } + if(township && township!='null'){ + d['G'] = township + } + + d['H'] = jsonObject1.get("townCode") + if(jsonObject1.get("provinceCode") && jsonObject1.get("provinceCode")!='null'){ + d['I'] = jsonObject1.get("provinceCode") + } + } +// } + } + +// def q = new BasicDBObject() +// q.put("city", d['C']) +//// q.put("district", d['D']) +// q.put("mzb_district_name", d['D']) +// q.put("type", "乡镇街道") +// q.put("street", d['B']) +// def obj = ADMINISTRATIVE_MAPPING_COLL.findOne(q) +// if(obj){ +// d['E'] = "可入库2" +// d['F'] = obj.district +// } + } + } + + },1) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy new file mode 100644 index 000000000..405fdbde8 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy @@ -0,0 +1,277 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import com.rabbitmq.client.AMQP +import net.sf.json.JSONObject +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +class DevUpdateTestBatch { + + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection development_zone_100_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL) + DBCollection DEV_MAPPING_100_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + + + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + + static main(args) { + def task = new DevUpdateTestBatch() + def path = "D:\\数据\\数据建设\\开发区\\文心一言获取开发区下辖园区及街道.xlsx"//开发区-园区.xlsx +// task.addDev(path) + task.addDevAddress(path) + +// task.updateHasGov("新疆维吾尔自治区","喀什地区","麦盖提县", "麦盖提镇", "是") + } + + def addDev(path){ + ExcelUtils.modify(path,{ d-> + if(!d['I'] && d['A']){ + def obj = development_zone_100_CONN.findOne(new BasicDBObject("name", d['A'])) + if(!obj){ + def o = new BasicDBObject() + o.put("province", d['B']) + o.put("city", d['C']) + o.put("district", d['D']) + o.put("name", d['A']) + o.put("level", d['E']) + o.put("type", d['F']) + + if(d['G']){ + o.put("township", d['G']) + } + if(d['H']){ + def arr = d['H'].split(",") + if(arr){ + o.put("alias", arr) + } + } + def id = addMongoDB(o) + o.remove("_id") + o.id = id.toString() + o.remove("create_time") + addEs(o, "192.168.0.89", "development_zone") + addEs(o, "192.168.0.52", "development_zone") + d['I'] = "已完成" + }else{ + println d['A'] +" 已存在" + } + } + }) + } + + def addMongoDB(o){ + o.put("create_time", new Date()) + development_zone_100_CONN.save(o) + DEVELOPMENT_ZONE_43_COLL.save(o) + return o._id + } + + def addEs(map, host, indexName){ + BulkRequest request = new BulkRequest(); + int processedCount = 0; + def client = null + if(host && host == "192.168.0.89"){ + client = ElasticUtils89.getClient(host) + }else if(host && host == "192.168.0.52"){ + client = ElasticUtils.getClient(host) + } + + request.add(new IndexRequest(indexName, "_doc", map.id).source(map, XContentType.JSON)); + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + } + + def addDevAddress(path){ + ExcelUtils.modify(path,{ d-> + if(!d['D'] && d['A']){ + def obj = development_zone_100_CONN.findOne(new BasicDBObject("name", d['A'])) + if(obj){ + def q = new BasicDBObject("name", d['A']).append("type",d['B']) + if(d['B'] == "乡镇街道"){ + q.put("township", d['C']) + }else if(d['B'] == "地址"){ + q.put("address", d['C']) + }else if(d['B'] == "园区"){ + q.put("park", d['C']) + } + def mappingObj = DEV_MAPPING_100_CONN.findOne(q) + if(!mappingObj){ + def o = new BasicDBObject() + o.put("province", obj.province) + o.put("city", obj.city) + o.put("district", obj.district) + o.put("name", obj.name) + o.put("type", d['B']) + if(d['B'] == "乡镇街道"){ + o.put("township", d['C']) + }else if(d['B'] == "地址"){ + o.put("address", d['C']) + }else if(d['B'] == "园区"){ + o.put("park", d['C']) + } + def date = new Date() + o.put("c_date", date) + o.put("version", date.getTime()) + DEV_MAPPING_100_CONN.save(o) + + + o.id = o._id.toString() + o.remove("_id") + o.remove("c_date") + addEs(o, "192.168.0.89", "dev_mapping") + try{ + addEs(o, "192.168.0.52", "dev_mapping") + }catch(Exception e){ + println "52 es error: "+e.printStackTrace() + } + + d['D'] = "已完成" + }else{ + d['D'] = "存在" + println d['A'] +" "+ d['C']+" 重复" + } + }else{ + println d['A'] +" 不存在" + } + } + },2) + } + + + def updateHasGov(province, city, district, street, hasGov){ + + def q = new BasicDBObject() + q.put("province", province) + q.put("city", city) + q.put("district", district) + q.put("street", street) + def obj = ADMINISTRATIVE_MAPPING_COLL.findOne(q) + if(obj){ + //修改43 +// ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",obj._id), new BasicDBObject('$set',new BasicDBObject('has_gov',hasGov))) + + //修改89 administrative_mapping + update89EsAdministrativeMapping(province, city, district, street, hasGov) + //修改89 administrative_mapping + update52EsAdministrativeMapping(province, city, district, street, hasGov) + }else{ + println province+" "+city+" "+district+" "+street+" 没找到" + } + //修改100 community + //修改89 community + //修改52 community + + } + + + def update89EsAdministrativeMapping(province, city, district, street, hasGov){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/administrative_mapping/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.has_gov='${hasGov}'", + "lang": "painless" + }, + "query": { + "bool": { + "must": [ + { + "match": { + "province_name": "${province}" + } + }, + { + "match": { + "city_name":"${city}" + } + }, + { + "match": { + "area_name":"${district}" + } + }, + { + "match": { + "street_name":"${street}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") +// def response = JSONObject.fromObject(res) + println(res) + } + + + def update52EsAdministrativeMapping(province, city, district, street, hasGov){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.52:9200/administrative_mapping/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.has_gov='${hasGov}'", + "lang": "painless" + }, + "query": { + "bool": { + "must": [ + { + "match": { + "province_name": "${province}" + } + }, + { + "match": { + "city_name":"${city}" + } + }, + { + "match": { + "area_name":"${district}" + } + }, + { + "match": { + "street_name":"${street}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") +// def response = JSONObject.fromObject(res) + println(res) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DistrictAliasProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DistrictAliasProcess.groovy index c987e3b7c..5b80f7877 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DistrictAliasProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DistrictAliasProcess.groovy @@ -10,7 +10,8 @@ class DistrictAliasProcess { static main(args) { def task = new DistrictAliasProcess(); - task.run() +// task.run() + task.fenQiProcess() } def run(){ @@ -42,4 +43,36 @@ class DistrictAliasProcess { } }) } + + def fenQiProcess(){ + def q = new BasicDBObject() + q.put("cat","district") + q.put("status", 0) + q.put("master_district_name", 'master') + def dbcursor = DbUtils.seaweed.find(q) + def rets = [] + for(def d : dbcursor){ + rets << ["_id":d._id.toString(),"city":d.city, "region":d.region, "name":d.name] + } + + for(def r : rets){ + def mainName1 = r.name.toString().replaceAll("([一二三四五六七八九十百千\\d]+)期\$", "") + def mainName2 = r.name.toString().replaceAll("(\\w|东|南|北|中|西|甲|乙|丙|丁|一|二|三|四|五|六|七|八|九|十)区\$", "") + def lastObj = null + for(def j : rets){ + if((j.name==mainName1 || mainName2==j.name) && r._id!=j._id && r.region==j.region && r.city==j.city){ + lastObj = j; + break + } + } + if(lastObj){ + println r + def udata = new BasicDBObject() + udata.put("master_district_name","") + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(r._id)), new BasicDBObject('$set', udata)) + } + + } + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy index b11210d3e..f814cceb2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy @@ -28,23 +28,23 @@ class GXDdistrictMatch { static main(args) { def task = new GXDdistrictMatch(); // task.run() -// task.addOldMatch() + task.addOldMatch() // task.runDb() // task.updateDistStatus()//恢复name_cat不正常数据 // task.saveToDB() //保存新增小区 // task.restoreDist()//恢复小区status=0 - task.runMatch() +// task.runMatch() } def addOldMatch(){ //老匹配 - def fileName = "D:\\数据\\国信达\\非正常数据.xlsx"//11城重新匹配.xlsx + def fileName = "D:\\数据\\建行\\房产估值\\20240616-20240715系统业务反馈.xlsx"//11城重新匹配.xlsx ExcelUtils.multiThreadingModify(fileName, { d -> println d['C'] - if(!d['AJ']){ - def jsonObject = OpenApiClient.addressMatch(d['AD'], d['H'], null, false, d['AE'], d['C']) + if(!d['AJ'] && d['I']){ + def jsonObject = OpenApiClient.addressMatch(d['C'], d['I'], "district", false,null, d['D']) if (jsonObject != null && !jsonObject.containsKey("result")) { d['AJ'] = jsonObject.get("id") d['AK'] = jsonObject.get("city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiLocation.groovy index 69fb2feef..0ae99adbe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiLocation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiLocation.groovy @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicLong class PoiLocation { def MAP_POI_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; - DBCollection MAPPOI_CONN = MongoUtils.getCollectionByName2("fangjia", "map_poi", MAP_POI_URL) + DBCollection MAPPOI_CONN = MongoUtils.getCollectionByName2("fangjia", "didata_map_poi_single", MAP_POI_URL) public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) def regionMap = com.fangjia.script.commData.CommonDatautils.queryDistNameByCity() @@ -35,21 +35,52 @@ class PoiLocation { static main(args) { def task = new PoiLocation(); - task.run(); +// task.run(); + task.regionAndStreetProcess() } + + + def run(){ - def citys = ["芜湖市","重庆市","杭州市","泉州市","东莞市","福州市","厦门市","佛山市","天津市","武汉市","宁波市","郑州市","长沙市","青岛市","上海市","西安市","温州市","无锡市","南京市","湖州市","合肥市","临沂市","石家庄市","昆明市","金华市","保定市","成都市","济南市","北京市","沈阳市","潍坊市","广州市","惠州市","嘉兴市","赣州市","苏州市","南通市","南宁市","台州市","南阳市","徐州市","长春市","深圳市","哈尔滨市","漳州市","中山市","常州市","烟台市","大连市","邯郸市","济宁市","盐城市","绍兴市","唐山市","洛阳市","阜阳市","菏泽市","贵阳市","沧州市","遵义市","莆田市","南昌市","商丘市","周口市","邢台市","江门市","衡阳市","邵阳市","信阳市","廊坊市","扬州市","泰州市","新乡市","太原市","德州市","淄博市","宁德市","绵阳市","汕头市","聊城市","淮安市","驻马店市","黄冈市","宿迁市","三明市","六安市","龙岩市","桂林市","岳阳市","南平市","揭阳市","上饶市","九江市","南充市","连云港市","襄阳市","泰安市","常德市","郴州市","安阳市","安庆市","湛江市","永州市","茂名市","曲靖市","宜宾市","肇庆市","宿州市","兰州市","运城市","镇江市","滁州市","威海市","梅州市","宜春市","清远市","亳州市","怀化市","荆州市","平顶山市","开封市","玉林市","咸阳市","宜昌市","株洲市","乌鲁木齐市","滨州市","渭南市","临汾市","榆林市","银川市","衡水市","毕节市","枣庄市","吉安市","张家口市","柳州市","许昌市","泸州市","呼和浩特市","达州市","德阳市","赤峰市","珠海市","孝感市","益阳市","娄底市","乐山市","恩施土家族苗族自治州","焦作市","湘潭市","海口市","红河哈尼族彝族自治州","黔南布依族苗族自治州","河源市","汉中市","日照市","大理白族自治州","濮阳市","黔东南苗族侗族自治州","秦皇岛市","晋中市","宝鸡市","吉林市","包头市","蚌埠市","东营市","宣城市","韶关市","衢州市","十堰市","承德市","丽水市","眉山市","鞍山市","昭通市","凉山彝族自治州","长治市","抚州市","鄂尔多斯市","吕梁市","百色市","齐齐哈尔市","贵港市","潮州市","黔西南布依族苗族自治州","广安市","淮南市","河池市","大同市","铜仁市","阳江市","咸宁市","营口市","绥化市","马鞍山市","安康市","荆门市","忻州市","广元市","内江市","遂宁市","西宁市","大庆市","汕尾市","文山壮族苗族自治州","锦州市","延安市","巴中市","呼伦贝尔市","楚雄彝族自治州","黄石市","玉溪市","六盘水市","通辽市","钦州市","云浮市","梧州市","漯河市","晋城市","庆阳市","安顺市","丹东市","自贡市","朝阳市","葫芦岛市","天水市","三门峡市","湘西土家族苗族自治州","北海市","陇南市","普洱市","延边朝鲜族自治州","保山市","定西市","随州市","喀什地区","黄山市","佳木斯市","巴彦淖尔市","牡丹江市","舟山市","资阳市","商洛市","松原市","锡林郭勒盟","伊犁哈萨克自治州","萍乡市","铁岭市","乌兰察布市","丽江市","景德镇市","张家界市","抚顺市","通化市","淮北市","来宾市","临沧市","阿克苏地区","贺州市","盘锦市","昌吉回族自治州","池州市","雅安市","三亚市","平凉市","四平市","酒泉市","西双版纳傣族自治州","鹤壁市","辽阳市","白城市","吴忠市","崇左市","阜新市","朔州市","白银市","拉萨市","巴音郭楞蒙古自治州","张掖市","铜陵市","武威市","临夏回族自治州","德宏傣族景颇族自治州","新余市","甘孜藏族自治州","兴安盟","本溪市","鄂州市","黑河市","阿坝藏族羌族自治州","阳泉市","防城港市","鸡西市","仙桃市","鹰潭市","固原市","白山市","中卫市","双鸭山市","攀枝花市","石嘴山市","和田地区","海东市","塔城地区","日喀则市","济源市","伊春市","天门市","辽源市","潜江市","那曲市","铜川市","海西蒙古族藏族自治州","鹤岗市","昌都市","阿拉善盟","乌海市","儋州市","哈密市","克拉玛依市","七台河市","金昌市","甘南藏族自治州","琼海市","迪庆藏族自治州","石河子市","阿勒泰地区","文昌市","玉树藏族自治州","嘉峪关市","万宁市","怒江傈僳族自治州","林芝市","海南藏族自治州","吐鲁番市","澄迈县","陵水黎族自治县","博尔塔拉蒙古自治州","山南市","阿里地区","大兴安岭地区","海北藏族自治州","东方市","乐东黎族自治县","克孜勒苏柯尔克孜自治州","果洛藏族自治州","临高县","阿拉尔市","黄南藏族自治州","神农架林区","屯昌县","定安县","昌江黎族自治县","五家渠市","保亭黎族苗族自治县","琼中黎族苗族自治县","五指山市","白沙黎族自治县","北屯市","图木舒克市","可克达拉市","双河市","铁门关市","毕节地区","昆玉市","铜仁地区","海东地区","三沙市","吐鲁番地区","哈密地区","日喀则地区","林芝地区","昌都地区","山南地区","那曲地区"] + def citys = [""] citys = citys.reverse() for(def city : citys){ findPois(city) } } + def regionAndStreetProcess(){ + def citys = ['南平市','泉州市', '厦门市', '福州市', '龙岩市', '漳州市', '宁德市', '三明市', '莆田市'] + for(def city : citys){ + def datas = findAllPoisByCity(city) + process(datas) + } + + } + + def findAllPoisByCity(city){ + def q = new BasicDBObject() + q.put("city", city) + def keys = new BasicDBObject() + keys.put("_id", 1) + keys.put("province", 1) + keys.put("city", 1) + keys.put("district", 1) + keys.put("township", 1) + keys.put("location", 1) + def dbcursor = MAPPOI_CONN.find(q).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + def rets = [] + for(def d : dbcursor){ + rets << d + } + return rets; + } + def findPois(city){ def q = new BasicDBObject() q.put("city", city) - q.put("run_status", new BasicDBObject('$ne', 1)) +// q.put("run_status", new BasicDBObject('$ne', 1)) def keys = new BasicDBObject() keys.put("_id", 1) @@ -87,6 +118,32 @@ class PoiLocation { return rets; } + + def process(datas){ + def totalCount = new AtomicLong() + def rets = new CopyOnWriteArrayList() + final CountDownLatch latch = new CountDownLatch(datas.size()) + for(def i=0;i= 2000) { - ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) println datas.size() datas.clear(); } } if (datas.size() >= 0) { - ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) datas.clear(); } } @@ -929,4 +946,222 @@ class TownMiddleProcess { ADMINISTRATIVE_MAPPING_COLL.update(upquery, new BasicDBObject('$set',udata), false, true) } } + + def addAliasFromExcel(){ + ExcelUtils.modify("D:\\数据\\数据建设\\乡镇街道\\乡镇街道合并或者变更20240627.xlsx",{ row-> + def q = new BasicDBObject("type", "乡镇街道") + q.put("city", row['A']) + q.put("street", row['D']) + if(row['B']){ + q.put("district", row['B']) + } + def obj = ADMINISTRATIVE_MAPPING_COLL.findOne(q) + if(obj){ + row['F'] = '是' + def alias = obj.alias + if(!alias){ + alias = [] + } + if(!alias.contains(row['C'])){ + alias << row['C'] + } + + if(alias){ + def udata = new BasicDBObject() + udata.put("alias", alias) + + def updateQuery = new BasicDBObject("_id", obj._id) + ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata)) + } + + } + }) + } + + def addSimpleName(){ + def q = new BasicDBObject() + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + for(def d : dbcursor){ + + def prov = ProvinceData.getSimpleProvince(d.province) + if(prov){ + def udata = new BasicDBObject() + udata.put("province_short", prov) + + def updateQuery = new BasicDBObject("_id", d._id) + ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata)) + } +// def city = d.city.replace("市","").replace("区","").replace("县","") +// def udata = new BasicDBObject() +// udata.put("city_short", city) +// if(d.district && d.district.size()>=3){ +// def region= d.district.replace("区","").replace("镇","").replace("乡","") +// udata.put("district_short", region) +// } +// def updateQuery = new BasicDBObject("_id", d._id) +// ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata)) +// def city = RegionData.formatCity(d.city) +// if(city && d.mzb_district_name){ +// def region = RegionData.formatRegion(city, d.mzb_district_name) +// if(region){ +// def udata = new BasicDBObject() +// udata.put("city_short", city) +// udata.put("district_short", region) +// +// def updateQuery = new BasicDBObject("_id", d._id) +// ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata)) +// } +// } + + } + } + + def mzbDistrictUpate(){ + ExcelUtils.modify("D:\\数据\\数据建设\\乡镇街道\\民政部\\2014-2022年.xlsx",{ row-> + if(!row['I']){ + def updateType = row['E'] + def prov = row['B'] + def newStreet = row['G'] + + if(["新设街道","新设镇","新增街道","新建街道","新建乡镇","新设乡","新增乡","新增建制"].contains(updateType)){ + def dbo = findStreets(prov, newStreet, row['F'].toString().toDouble().toInteger().toString()) + if(dbo){ + row['I'] = dbo.city + row['J'] = dbo.district + row['K'] = "存在" + row['L'] = dbo.tjj_street_code + row['M'] = dbo.pid + } + }else if(["撤乡设镇","撤乡建镇","撤乡设乡","撤乡、镇设镇","撤销设街道","撤销建街道","撤销街道建镇","撤镇设镇、街道","撤销镇新设镇","乡镇合并","整建制划归","撤镇建新镇","区划变更","撤镇、街道设镇","撤街道建镇","撤销乡、镇新设镇","撤镇、街道设街道","撤乡、街道设街道","撤乡设街道","撤乡建街道","撤镇设街道","撤镇建街道","名称变更","撤街道设镇","撤乡、镇设街道","撤街道、镇、乡","并入其他建制",'撤镇设镇',"合并","合并建镇","更名","撤销合并","合并建制","合并镇","合并街道","名称变更","合并调整","合并建街道","撤镇设街道、镇","撤乡、镇设乡","撤镇乡设街道","区划调整","合并乡","撤镇设市","区划代码调整","区划代码变更","撤销乡、镇设街道"].contains(updateType)){ + if(row['F']){ + def dbo = null + def code = row['F'].toString() + if(!code.contains(" ")){ + dbo = findStreets(prov, newStreet, code.toDouble().toInteger().toString()) + } + if(dbo){ + row['I'] = dbo.city + row['J'] = dbo.district + row['L'] = dbo.tjj_street_code + row['M'] = dbo.pid + def alias = dbo.alias + if(!dbo.alias){ + alias = [] + } + if(row['D']){ + if(!alias.contains(row['D'])){ + row['K'] = "存在(加别名)" + alias << row['D'] + addAlias(dbo._id, alias) + }else{ + row['K'] = "存在" + } + }else{ + row['K'] = "存在" + } + + } + } + + }else if(updateType == "撤街道设街道"){ + row['K'] = "人工处理" + }else if(updateType == "隶属关系变更"){ + row['K'] = "人工处理" + }else if(["撤销镇","撤乡","撤销街道","撤销","撤街道设社区工作站","撤销建制"].contains(updateType)){ + row['K'] = "人工处理" + }else if(updateType =='撤销乡'){ + if(!row['F']){ + row['K'] = "人工处理" + } + } + + if(prov && newStreet && (!row['K'] || (row['K'] && !row['K'].contains("存在")) )){ + def dbo = findStreets(prov, newStreet, null) + if(dbo){ + row['I'] = dbo.city + row['J'] = dbo.district + row['K'] = "存在-编码不同" + row['L'] = dbo.tjj_street_code + row['M'] = dbo.pid + def alias = dbo.alias + if(!dbo.alias){ + alias = [] + } + if(row['D']){ + if(!alias.contains(row['D'])){ + row['K'] = "存在(加别名)" + alias << row['D'] +// addAlias(dbo._id, alias) + }else{ + row['K'] = "存在" + } + }else{ + row['K'] = "存在" + } + } + } + + } + }) + } + + def addCity(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\乡镇街道\\民政部\\2014-2022年.xlsx",{ row-> + def citycode = null + if(row['F']){ + citycode = row['F'].toString().substring(0, 4) + }else if(row['C']){ + citycode = row['C'].toString().substring(0, 4) + } + + if(citycode){ + def q = new BasicDBObject() + q.put("mzb_city_code", citycode+"00") + q.put("type", "城市") + def dbo = ADMINISTRATIVE_MAPPING_COLL.findOne(q) + if(dbo){ + row['O'] = dbo.city + } + } + + }) + } + + def findStreets(prov, newStreet, streetCode){ + def q = new BasicDBObject() + Pattern provPattern = Pattern.compile(prov+'.*$', Pattern.CASE_INSENSITIVE); + q.put("province", new BasicDBObject('$regex', provPattern)) + q.put("street", newStreet) + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + def list = [] + def dbo = null + for(def d : dbcursor){ + list << d + } + if(list && list.size()==1){ + dbo = list[0] + }else if(list && list.size()>1){ + if(streetCode){ + for(def d : list){ + if(d.tjj_street_code && d.tjj_street_code.contains(streetCode)){ + dbo = d + break; + }else if(streetCode.contains(d.pid)){ + dbo = d + break; + } + } + } + } + return dbo + } + + def addAlias(id, alias){ + def udata = new BasicDBObject() + udata.put("alias", alias) + udata.put("operator","高娟-批量") + + def updateQuery = new BasicDBObject("_id", id) + ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata)) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy index c4816c69c..2a6c1d7a3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.RegionData import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.CosineSimilarAlgorithm @@ -9,12 +10,14 @@ import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import com.rabbitmq.client.impl.AMQImpl import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong +import java.util.regex.Pattern class TownshipStrandUpdate { @@ -26,13 +29,26 @@ class TownshipStrandUpdate { def polylineMap = null def newAdvMappingMap = null public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + public static final DBCollection REGION_BLOCK_COLL = MongoUtils.getCollectionByName("fangjia", "region_block", "mongo.db.fangjia.com") + + + + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection dev_MAPPING_COLL_100 = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) static main(args) { def task = new TownshipStrandUpdate() // task.process() - task.updateTown() +// task.updateTown() // task.stat() +// task.updateDiffRegionTown() +// task.cleanTown() +// task.checkTownFromMongo() +// task.updateTownMapping() +// task.updateDevMapping() + println new Date().getTime() +// task.updateSpecCityTown() } @@ -43,21 +59,21 @@ class TownshipStrandUpdate { polylineMap = CommonDatautils.findAllTownRanges() newAdvMappingMap = CommonDatautils.queryNewTownByCity() // def citys = ["唐山","邯郸","石家庄","保定","秦皇岛","廊坊","沧州","张家口","衡水","邢台","承德"]//CommonDatautils.findAllCity() - def citys = CommonDatautils.findAllCity() + def citys = ["澄迈","临高"]//CommonDatautils.findAllCity(),"东方","澄迈","临高" citys = citys.reverse() for(def city : citys){ // - if(["中山","东莞"].contains(city)){ - continue - } - def fileName = "D:\\数据\\数据建设\\乡镇街道\\商铺\\商铺乡镇街道格式化-${city}.xlsx" +// if(["中山","东莞"].contains(city)){ +// continue +// } + def fileName = "D:\\数据\\数据建设\\乡镇街道\\写字楼\\写字楼乡镇街道格式化-${city}.xlsx" File file=new File(fileName); - if(!file.exists()){ - def dists = CommonDatautils.findAllDistrictsFromMg(city, "shop", ["city","region","name","address","cat","estate_type2","status","township","lng","lat"]) +// if(!file.exists()){ + def dists = CommonDatautils.findAllDistrictsFromMg(city, "office", ["city","region","name","address","cat","estate_type2","status","township","lng","lat"]) dists = checkData(dists) def datas = createDatas(dists) ExcelUtils.write(fileName, datas, "${city}") - } +// } } } @@ -162,6 +178,10 @@ class TownshipStrandUpdate { def running(d){ def fullCity = fullCityMap.get(d.city) def regions = getFullRegion(fullCity, d) + if(!regions && ["中山市","东莞市","济源市","仙桃市","潜江市","天门市","神农架市","五指山市","琼海市","文昌市","万宁市","东方市","定安市","屯昌市","澄迈市","临高市","白沙市","昌江市","乐东市","陵水市","保亭市","琼中市","阿拉尔市","图木舒克市","五家渠市","北屯市","铁门关市","双河市","可克达拉市"].contains(fullCity.city)){ + regions = [] + regions << fullCity.city + } def gaodeMap = null def town = null def mapTown = null @@ -217,6 +237,10 @@ class TownshipStrandUpdate { } if( gaodeMap.district && gaodeMap.district!='[]'){ mapRegion = gaodeMap.district + }else{ + if(mapCity && ["中山市","东莞市","济源市","仙桃市","潜江市","天门市","神农架市","五指山市","琼海市","文昌市","万宁市","东方市","定安市","屯昌市","澄迈市","临高市","白沙市","昌江市","乐东市","陵水市","保亭市","琼中市","阿拉尔市","图木舒克市","五家渠市","北屯市","铁门关市","双河市","可克达拉市"].contains(mapCity)){ + mapRegion = mapCity + } } if(gaodeMap.township && gaodeMap.township!='[]'){ mapTownship = gaodeMap.township @@ -331,7 +355,7 @@ class TownshipStrandUpdate { def names = [] if(regions){ for(def r : regions){ - if(r.mzb_district_name.contains(d.region)){ + if(r.mzb_district_name.contains(d.region) || r.district_short.contains(d.region)){ names << r.district } } @@ -381,7 +405,7 @@ class TownshipStrandUpdate { } } } - if(district || count>10){ + if(township || district || count>10){ stop = true }else{ count ++ @@ -397,4 +421,212 @@ class TownshipStrandUpdate { map.format_addr = format_addr return map; } + + def updateDiffRegionTown(){ + def fileName = "D:\\数据\\数据建设\\乡镇街道\\shop-不同区域.xlsx" + ExcelUtils.multiThreadingModify(fileName,{d-> + def lists = CommonDatautils.findDistrictList(d['B'], null, d['D'], "shop") + d['AA'] = lists.size() + //只处理库中只有一个的 + if(lists && lists.size()==1 && d['Z']=="包含" && !d['AB']){ + def newRegion = RegionData.formatRegion(d['B'], d['M']) + if(newRegion){ + if(d['X'] && d['X'].toString().contains(d['M']+" "+d['N'])){ //地图街道在中间表中 + def dbo = lists[0] + def arrs = d['X'].split(" ") + def udata = new BasicDBObject() + udata.put("region", newRegion) + udata.put("m_date", new Date()) + udata.put("township", arrs[1]) + + DbUtils.seaweed.update(new BasicDBObject('_id',dbo._id), new BasicDBObject('$set', udata)) + CommonDatautils.saveOptLog(dbo.city, dbo.region, dbo.name, "shop", "update","高娟") + d['AB'] = "已处理" + } + } + } + }) + } + + def cleanTown(){ + def fileName = "D:\\数据\\数据建设\\乡镇街道\\district-不同区域.xlsx" + ExcelUtils.modify(fileName,{d-> + if(d['AC']){ + def dbo = CommonDatautils.findDistrict(d['B'], d['C'], d['D'], "district") + if(dbo && dbo.township){ + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("township", "") + + DbUtils.seaweed.update(new BasicDBObject('_id',dbo._id), new BasicDBObject('$set', udata)) + CommonDatautils.saveOptLog(dbo.city, dbo.region, dbo.name, "office", "update-town","高娟") + } + } + }) + } + + def checkTownFromMongo(){ + def citys = CommonDatautils.findAllCity() + fullCityMap = CommonDatautils.queryFullNameByCity() + regionMap = CommonDatautils.queryDistNameByCity() + commMap = CommonDatautils.queryCommunityByCity() + citys = citys.reverse() + def index = 0 + for(def city : citys) { + index++ + if (["中山", "东莞"].contains(city)) { + continue + } + + def dists = CommonDatautils.findAllDistrictsFromMg(city, "office", ["city", "region", "name", "address", "cat", "estate_type2", "status", "township", "lng", "lat"]) + for (def d : dists) { + if (d.township) { + def fullCity = fullCityMap.get(d.city) + def regions = getFullRegion(fullCity, d) + def town = getSimilarTown(regions, fullCity, d.township) + if (!town) { + town = findStreet(d.city, d.city, d.township) + if (!town) { + + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("township", "") + + DbUtils.seaweed.update(new BasicDBObject('_id',d._id), new BasicDBObject('$set', udata)) + CommonDatautils.saveOptLog(d.city, d.region, d.name, "office", "update-town","高娟") + + println d.city + " " + d.region + " " + d.township + " " + d.name + } + } + } + } + println index + " " + city + " 完成" + } + } + + def findStreet(city, district, street){ + def q = new BasicDBObject() + Pattern provPattern = Pattern.compile(city+'.*$', Pattern.CASE_INSENSITIVE); + q.put("city", new BasicDBObject('$regex', provPattern)) + q.put("district", new BasicDBObject('$regex', Pattern.compile(district+'.*$', Pattern.CASE_INSENSITIVE))) + q.put("street", new BasicDBObject('$regex', Pattern.compile(street+'.*$', Pattern.CASE_INSENSITIVE))) + def list = ADMINISTRATIVE_MAPPING_COLL.find(q).toList() + if(list){ + if(list.size()==1){ + return list[0] + }else{ + println city+ " "+district+" "+street+" 有多个" + } + } + return null + } + + def updateTownMapping(){ + def fileName = "D:\\数据\\数据建设\\乡镇街道\\双方区域对比.xlsx" + ExcelUtils.modify(fileName,{d-> + if(d['F']){ +// def udata = new BasicDBObject() +// udata.put("mzb_district_name", d['F']) +// +// def updateQuery = new BasicDBObject() +// updateQuery.put("city", d['C']) +// updateQuery.put("district", d['D']) +// ADMINISTRATIVE_MAPPING_COLL.update(updateQuery, new BasicDBObject('$set',udata), false, true) + + def city = RegionData.formatCity(d['C']) + if(city){ + def region = RegionData.formatRegion(city, d['D']) + if(region){ + def updateQuery = new BasicDBObject() + updateQuery.put("category", "region") + updateQuery.put("city", city) + updateQuery.put("name", region) + + def list = REGION_BLOCK_COLL.find(updateQuery).toList() + if(list && list.size()==1){ + def dbo = list[0] + def query = new BasicDBObject() + query.put("_id", dbo._id) + +// def pattern = dbo.pattern +// if(pattern.contains(d['F'])){ +// pattern.remove(d['F']) +// } + def udata = new BasicDBObject() + udata.put("org_name", d['F']) +// udata.put("pattern",pattern) + REGION_BLOCK_COLL.update(query, new BasicDBObject('$set',udata), false, true) + }else{ + println city +" "+region+" "+list.size() + } + } + } + + + } + }) + } + + def updateDevMapping(){ + def fileName = "D:\\数据\\数据建设\\开发区\\开发区映射表重复数据.xlsx" + ExcelUtils.modify(fileName,{d-> + def q = new BasicDBObject() + q.put("city", d['A']) + q.put("district", d['B']) + q.put("name",d['C']) + q.put("type", "乡镇街道") + q.put("township", d['D']) + def list = dev_MAPPING_COLL_100.find(q).toList() + if(list && list.size()==2){ + def obj = list[0] + def removeQuery = new BasicDBObject() + removeQuery.put("_id", obj._id) + dev_MAPPING_COLL_100.remove(removeQuery) + }else{ + println q + } + }) + } + + def updateSpecCityTown(){ + def citys = ["中山","东莞","潜江","天门","神农架","五指山","琼海","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","阿拉尔","图木舒克","五家渠","北屯","铁门关","双河","可克达拉"] + +// def citys = ["中山"] + for(def city : citys){ + def fileName = "D:\\数据\\数据建设\\乡镇街道\\商铺\\商铺乡镇街道格式化-${city}.xlsx" + ExcelUtils.modify(fileName,{d-> + def list = CommonDatautils.findDistrictList(d['A'], null , d['C'], "office") + if(list.size()>1){ + println d['A'] +" "+d['C'] + " 有多个" + }else if(list.size()==1){ + def dbo = list[0] + def town = null +// if(d['X']){ +// town = d['X'] +// }else + if(d['R']){ + town = d['R'] + } + if(!town && d['M']){ + town = d['M'] + } + def region = RegionData.formatRegion(d['A'], town) + if(region){ + def q = new BasicDBObject() + q.put("region", region) + + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("township", town) + udata.put("region", region) + DbUtils.seaweed.update(new BasicDBObject('_id',dbo._id), new BasicDBObject('$set', udata)) + }else{ + println d['A']+" "+d['C']+" "+d['X'] +" 无法格式化" + } + } + + }) + } + + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy index c40ba1e41..afcedfa60 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy @@ -86,7 +86,6 @@ class FjwBigdataForsaleBatch extends BaseBatch{ //目前查询库中是否已存在,用的是Oracle def index = 0 def citys = CcbCommonUtils.getRunningCitys(args) - citys = ["三沙","临高","乐东","五指山","北屯","双河","可克达拉","定安","屯昌","昆玉","昌江","果洛州","海南州","玉树州","琼中","甘南","白沙","铁门关","阿里","黄南州"] def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() @@ -494,8 +493,8 @@ class FjwBigdataForsaleBatch extends BaseBatch{ def findHousesByMdate(def city, def region, def cat, def startDate, def endDate, def name, def alias, def estate_type2, rets1){ def date = "20200101"//DateUtils.addMonth(endDate.toString(), -3, "yyyyMMdd") - def startMdate = DateUtils.parseFromTightByPattern("20200101","yyyyMMdd")//DateUtils.parseFromTightByPattern(date,"yyyyMMdd") - def endMdate = DateUtils.parseFromTightByPattern("20240518", "yyyyMMdd")//DateUtils.parseFromTightByPattern(endDate.toString(), "yyyyMMdd") + def startMdate = DateUtils.parseFromTightByPattern("20240519","yyyyMMdd")//DateUtils.parseFromTightByPattern(date,"yyyyMMdd") + def endMdate = DateUtils.parseFromTightByPattern("20240718", "yyyyMMdd")//DateUtils.parseFromTightByPattern(endDate.toString(), "yyyyMMdd") QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(date.toInteger()).to(endDate).includeLower(false).includeUpper(false); QueryBuilder area_range = QueryBuilders.rangeQuery("area").from(20).to(500).includeLower(true).includeUpper(false); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy index 17555562d..2dd8a91a7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy @@ -33,7 +33,7 @@ class AddPriceTest { task.run(); } def run(){ - def filePath = "D:\\数据\\建行\\分期小区对比结果.xlsx" + def filePath = "D:\\数据\\建行\\房产估值\\20240616-20240715系统业务反馈.xlsx" // addGXDPrice(filePath) // addCcbPrice(filePath) // addThirdPrice(filePath) @@ -167,14 +167,14 @@ class AddPriceTest { } def addCcbPrice(filepath){ -// def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() ExcelUtils.multiThreadingModify(filepath,{ d-> - if(d['A']){ -// def cityId = cityCodeDataMap.get(d['N']) - def map = findAvgPrice(d['G'], d['A'].toString().toDouble().toInteger()) + if(d['AJ']){ + def cityId = cityCodeDataMap.get(d['AK']) + def map = findAvgPrice(d['AJ'], cityId) if(map){ -// d['AK'] = map.avg_price - d['P'] = map.calc_type + d['F'] = map.avg_price +// d['P'] = map.calc_type // d['AM'] = map.credit_value } } @@ -183,7 +183,7 @@ class AddPriceTest { def findAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202406 order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -272,23 +272,23 @@ class AddPriceTest { ExcelUtils.multiThreadingModify(path,{d-> // if(!d['L']){ // if(d['J'] instanceof String){ - def dist = CommonDatautils.findDistrictById(d['J']) + def dist = CommonDatautils.findDistrictById(d['AJ']) if(dist){ - d['A'] = dist.city - d['B'] = dist.region - d['C'] = dist.name - d['D'] = dist.status - d['E'] = dist.name_cat - d['F'] = dist.estate_type2 - d['G'] = DateUtils.formatDateByPattern(dist.m_date,'yyyy-MM-dd') - d['H'] = dist.master_district_name +// d['A'] = dist.city +// d['B'] = dist.region + d['E'] = dist.name +// d['D'] = dist.status +// d['E'] = dist.name_cat +// d['F'] = dist.estate_type2 +// d['G'] = DateUtils.formatDateByPattern(dist.m_date,'yyyy-MM-dd') +// d['H'] = dist.master_district_name // d['N'] = dist.region -// def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) -// if(dbo){ -// d['D'] = dbo.avg_price -//// d['X'] = dbo.cal_type + def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) + if(dbo){ + d['G'] = dbo.avg_price +// d['X'] = dbo.cal_type // d['E'] = dbo.avg_price_2b -// } + } } // } // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy index 70de3fab2..b6fea9896 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy @@ -27,8 +27,8 @@ class QiliangTest { // task.run() def data = [ - 'address': '宁德市福安市中兴西路16号', - 'type': '2' //1:对公 0:对私 + 'address': '江阴市澄杨路77号', + 'type': '1' //1:对公 0:对私 ] def s = task.getProxyResult(data); print(s); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy new file mode 100644 index 000000000..2d2f76f24 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy @@ -0,0 +1,265 @@ +package com.fangjia.script.gj.xiamen + +import org.apache.http.HttpHost +import org.apache.http.auth.AuthScope +import org.apache.http.auth.UsernamePasswordCredentials +import org.apache.http.client.CredentialsProvider +import org.apache.http.client.config.RequestConfig +import org.apache.http.impl.client.BasicCredentialsProvider +import org.apache.http.impl.nio.client.HttpAsyncClientBuilder +import org.elasticsearch.action.ActionListener +import org.elasticsearch.action.bulk.BackoffPolicy +import org.elasticsearch.action.bulk.BulkProcessor +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.search.ClearScrollRequest +import org.elasticsearch.action.search.SearchRequest +import org.elasticsearch.action.search.SearchResponse +import org.elasticsearch.action.search.SearchScrollRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.client.RestClient +import org.elasticsearch.client.RestClientBuilder +import org.elasticsearch.client.RestHighLevelClient +import org.elasticsearch.common.unit.TimeValue +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.search.Scroll +import org.elasticsearch.search.SearchHit +import org.elasticsearch.search.builder.SearchSourceBuilder +import org.elasticsearch.xpack.sql.jdbc.EsDataSource + +import java.sql.Connection +import java.sql.ResultSet +import java.sql.Statement +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.function.BiConsumer + +/** + * 功能说明:Elasticsearch工具类 + */ +class ElasticUtils89 { + + + static getEsDataSource(String host){ + EsDataSource dataSource = new EsDataSource (); + dataSource.setUrl("jdbc:es://${host}:9200?timezone=UTC&page.size=240&connect.timeout=240000&network.timeout=60000&page.timeout=240000&query.timeout=90000"); + Properties connectionProperties = new Properties(); +// connectionProperties.setProperty("user","developer"); +// connectionProperties.setProperty("password","5e8edd851d2fdfbd7415232c67367cc3"); + + connectionProperties.setProperty("user","elastic"); + connectionProperties.setProperty("password","elasticsearch");//elasticsearch + dataSource.setProperties(connectionProperties); + return dataSource; + } + + static executeSqlQuery(String sql, Closure closure, String host = "192.168.0.89"){ + EsDataSource dataSource = getEsDataSource(host) + Connection connection = dataSource.getConnection() + Statement statement = connection.createStatement() + ResultSet rs = statement.executeQuery(sql) + def columns = [] + for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++){ + columns << rs.getMetaData().getColumnName(i) + } + rs.getMetaData().getColumnCount() + while(rs.next()){ + def row = [:] + for (String col : columns){ + row[col] = rs.getObject(col) + } + closure.call(row) + } + rs.close() + connection.close() + } + + static RestHighLevelClient getClient(String host) { + RestClientBuilder builder = RestClient.builder(new HttpHost(host, 9200, "http")); + builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { + @Override + RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) { + requestConfigBuilder.setConnectionRequestTimeout(1000 * 60); + requestConfigBuilder.setSocketTimeout(1000 * 180); + return requestConfigBuilder; + } + }) + builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { + @Override + HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) { + httpAsyncClientBuilder.disableAuthCaching(); + CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "elasticsearch"));//goojia123456 + httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + return httpAsyncClientBuilder; + } + }) + return new RestHighLevelClient(builder) + } + + + static RestHighLevelClient getClient89(String host) { + RestClientBuilder builder = RestClient.builder(new HttpHost(host, 9200, "http")); + builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { + @Override + RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) { + requestConfigBuilder.setConnectionRequestTimeout(1000 * 60); + requestConfigBuilder.setSocketTimeout(1000 * 180); + return requestConfigBuilder; + } + }) + builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { + @Override + HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) { + httpAsyncClientBuilder.disableAuthCaching(); + CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "elasticsearch"));//goojia123456 + httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + return httpAsyncClientBuilder; + } + }) + return new RestHighLevelClient(builder) + } + + + /** + * 创建一个ES批处理器 + * @param host + * @return + */ + static createBulkProcessor(String host, RestHighLevelClient client = null) { + + BulkProcessor.Listener listener = new BulkProcessor.Listener() { + @Override + void beforeBulk(long executionId, BulkRequest request) { + } + + @Override + void afterBulk(long executionId, BulkRequest request, + BulkResponse response) { + } + + @Override + void afterBulk(long executionId, BulkRequest request, + Throwable failure) { + } + }; + if(!client){ + client = getClient(host); + } + return BulkProcessor.builder(new BiConsumer>() { + @Override + void accept(BulkRequest bulkRequest, ActionListener bulkResponseActionListener) { + client.bulkAsync(bulkRequest, RequestOptions.DEFAULT, bulkResponseActionListener) + } + }, listener).setBulkActions(10000) + .setConcurrentRequests(20) + .setBackoffPolicy(BackoffPolicy.constantBackoff(TimeValue.timeValueSeconds(1L), 3)) + .setFlushInterval(TimeValue.timeValueSeconds(10L)).build(); + } + + /** + * 关闭一个ES批处理器 + * @param + * @return + */ + static closeBulkProcessor(BulkProcessor bulkProcessor) { + bulkProcessor.awaitClose(10, TimeUnit.DAYS) + bulkProcessor.flush() + bulkProcessor.close() + } + + + static executeQuery(String host, String indexName, QueryBuilder qb, Closure closure){ + + RestHighLevelClient client = getClient(host) + BulkProcessor bulkProcessor = createBulkProcessor(host, client) + final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(60L)) + SearchRequest searchRequest = new SearchRequest(indexName); + searchRequest.scroll(scroll); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(qb); + searchRequest.source(searchSourceBuilder); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); + String scrollId = searchResponse.getScrollId(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + def nThread = Runtime.getRuntime().availableProcessors() * 5 + ExecutorService executorService = Executors.newFixedThreadPool(nThread) + while (searchHits != null && searchHits.length > 0) { + for (int k=0; k < searchHits.size(); k++) { + final SearchHit hit = searchHits[k]; + executorService.submit(new Runnable() { + @Override + void run() { + try{ + if(closure.getMaximumNumberOfParameters() == 1){ + def update = closure.call(hit.getSourceAsMap()) + if(update){ + bulkProcessor.add(new IndexRequest(indexName).id(hit.getId()).source(hit.getSourceAsMap())) + } + }else if(closure.getMaximumNumberOfParameters() == 2){ + def update = closure.call(hit.getId(), hit.getSourceAsMap()) + if(update){ + bulkProcessor.add(new IndexRequest(indexName).id(hit.getId()).source(hit.getSourceAsMap())) + } + } + }catch (Exception e){ + e.printStackTrace() + } + } + }) + } + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); + scrollRequest.scroll(scroll); + searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); + scrollId = searchResponse.getScrollId(); + searchHits = searchResponse.getHits().getHits(); + } + ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); + clearScrollRequest.addScrollId(scrollId); + client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); + executorService.shutdown() + executorService.awaitTermination(1, TimeUnit.DAYS) + bulkProcessor.close() + bulkProcessor.awaitClose(1, TimeUnit.DAYS) + client.close() + } + + + static def executeSimpleQuery(String host, String indexName, QueryBuilder qb){ + + final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(60L)) + RestHighLevelClient client = getClient(host) + SearchRequest searchRequest = new SearchRequest(indexName); + searchRequest.scroll(scroll); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(qb); + searchRequest.source(searchSourceBuilder); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); + String scrollId = searchResponse.getScrollId(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + def results = [] + while (searchHits != null && searchHits.length > 0) { + for (int k=0; k < searchHits.size(); k++) { + SearchHit searchHit = searchHits[k] + searchHit.getSourceAsMap().put("id", searchHit.getId()); + results << searchHit.getSourceAsMap() + } + if(results.size()%100000==0){ + println "."+ new Date() + } + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); + scrollRequest.scroll(scroll); + searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); + scrollId = searchResponse.getScrollId(); + searchHits = searchResponse.getHits().getHits(); + } + ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); + clearScrollRequest.addScrollId(scrollId); + client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); + client.close() + return results; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy index 63996e918..024a20faf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy @@ -10,7 +10,6 @@ import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.looplineinfo.InsidePolygon -import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils @@ -27,6 +26,8 @@ import org.elasticsearch.action.index.IndexRequest import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -48,6 +49,9 @@ class GaoDePoiDataProcess extends BaseBatch{ public static def TAGS = ["加油站","其它能源站","加气站","洗车场","充电站","餐饮相关场所","休闲餐饮场所","购物相关场所","商场","超级市场","家电电子卖场","花鸟鱼虫市场","家居建材市场","综合市场","特色商业街","生活服务场所","邮局","事务所","人才市场","洗浴推拿场所","体育休闲服务场所","运动场馆","娱乐场所","度假疗养场所","休闲场所","医疗保健服务场所","综合医院","专科医院","诊所","急救中心","疾病预防机构","住宿服务相关","宾馆酒店","旅馆招待所","风景名胜相关","公园广场","风景名胜","产业园区","政府及社会团体相关","政府机关","外国机构","社会团体","公检法机构","交通车辆管理","工商税务机构","科教文化场所","博物馆","展览馆","会展中心","美术馆","图书馆","科技馆","天文馆","文化宫","档案馆","文艺团体","传媒机构","学校","科研机构","培训机构","驾校","机场相关","银行","银行相关","保险公司","证券公司","财务公司","公司企业","知名企业","公司","工厂","农林牧渔基地","收费站","服务区","标志性建筑物","地名地址信息","热点地名","紧急避难场所"] + public static def TYPES = ["出入口;门","美食","交通设施;停车场","交通设施;路侧停车位","生活服务;彩票销售点","生活服务;公用事业","出入口;停车场出入口","出入口","生活服务;殡葬服务","交通设施;充电站","出入口;其他","丽人;美体","丽人;美甲","金融;atm","汽车服务;汽车检测场","道路;路口","生活服务;公共厕所","交通设施;加油加气站","生活服务;售票处","出入口;高速公路出口","交通设施;港口","交通设施;普通停车位","生活服务;步骑行专用道驿站","交通设施;收费站","交通设施;桥","交通设施;火车站","交通设施;高速公路停车区","出入口;车站入口","医疗;核酸检测点","地名地址信息;交通地名;路口名","地名地址信息;交通地名;道路名","交通设施服务;公交车站;公交车站相关","生活服务;共享设备;充电宝","交通设施服务;停车场;公共停车场","地名地址信息;自然地名;山","交通设施服务;停车场;停车场出入口","公共设施;公共厕所;公共厕所","通行设施;临街院门;临街院正门","室内设施;室内设施;室内设施","交通设施服务;停车场;路边停车场","交通设施服务;停车场;停车场相关","地名地址信息;交通地名;桥","地名地址信息;自然地名;河流","交通设施服务;停车场;专用停车场","体育休闲服务;娱乐场所;KTV","通行设施;建筑物门;建筑物门","交通设施服务;停车场;停车场入口","生活服务;丧葬设施;丧葬设施","金融保险服务;自动提款机;农村商业银行ATM","交通设施服务;停车场;停车场出口","政府机构及社会团体;交通车辆管理;交通管理机构","通行设施;建筑物门;建筑物正门","地名地址信息;普通地名;乡镇级地名","地名地址信息;自然地名;湖泊","公司企业;公司;广告装饰|生活服务","金融保险服务;自动提款机;自动提款机","金融保险服务;自动提款机;中国邮政储蓄银行ATM","金融保险服务;自动提款机;中国农业银行ATM","购物服务;家居建材市场;建材五金市场|公司企业","地名地址信息;交通地名;高速路出口","地名地址信息;交通地名;高速路入口","金融保险服务;自动提款机;中国工商银行ATM","交通设施服务;交通服务相关;交通服务相关","金融保险服务;自动提款机;中国建设银行ATM","购物服务;超级市场;超市|购物服务","交通设施服务;地铁站;出入口","购物服务;家电电子卖场;手机销售|生活服务","公司企业;公司;公司|购物服务","公司企业;公司;公司|生活服务","地名地址信息;交通地名;隧道","政府机构及社会团体;交通车辆管理;验车场","购物服务;家居建材市场;建材五金市场|生活服务","地名地址信息;交通地名;立交桥","金融保险服务;自动提款机;中国银行ATM","购物服务;便民商店/便利店;便民商店/便利店|购物服务","汽车销售;汽车销售;汽车销售|汽车维修","交通设施服务;长途汽车站;长途汽车站","地名地址信息;交通地名;铁路","道路附属设施;服务区;高速服务区","政府机构及社会团体;交通车辆管理;交通执法站","生活服务;美容美发店;美容美发店|购物服务","地名地址信息;普通地名;街道级地名","交通设施服务;地铁站;地铁站","公司企业;工厂;工厂|公司企业","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|生活服务","公共设施;公共厕所;女洗手间","政府机构及社会团体;交通车辆管理;车辆管理机构","住宿服务;住宿服务相关;住宿服务相关|体育休闲服务","公共设施;公共厕所;男洗手间","汽车服务;汽车养护/装饰;汽车养护|汽车服务","地名地址信息;自然地名;岛屿","交通设施服务;港口码头;港口码头","住宿服务;宾馆酒店;宾馆酒店|住宿服务","生活服务;电讯营业厅;中国移动营业厅|购物服务","购物服务;专卖店;专营店|生活服务","地名地址信息;交通地名;城市快速路出口","地名地址信息;交通地名;城市快速路入口","购物服务;专卖店;专营店|公司企业","生活服务;丧葬设施;公墓","公司企业;公司;公司|公司企业","交通设施服务;火车站;火车站","汽车服务;汽车养护/装饰;汽车养护|汽车维修","购物服务;购物相关场所;购物相关场所|生活服务","购物服务;专卖店;烟酒专卖店|购物服务","购物服务;专卖店;自行车专卖店|生活服务","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|生活服务","金融保险服务;自动提款机;交通银行ATM","生活服务;生活服务场所;生活服务场所|购物服务","购物服务;个人用品/化妆品店;其它个人用品店|生活服务","购物服务;综合市场;农副产品市场|购物服务","住宿服务;旅馆招待所;旅馆招待所|住宿服务","购物服务;专卖店;专营店|汽车服务","公司企业;公司;广告装饰|购物服务","住宿服务;宾馆酒店;宾馆酒店|餐饮服务","公共设施;公共厕所;残障洗手间/无障碍洗手间","购物服务;专卖店;专营店|餐饮服务","购物服务;家居建材市场;建材五金市场|购物服务","购物服务;综合市场;农副产品市场|餐饮服务","购物服务;家电电子卖场;数码电子|公司企业","医疗保健服务;核酸检测;核酸检测","购物服务;家电电子卖场;数码电子|生活服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|公司企业","汽车服务;汽车配件销售;汽车配件销售|汽车维修","购物服务;家居建材市场;布艺市场|公司企业","生活服务;丧葬设施;陵园","金融保险服务;银行;交通银行","餐饮服务;中餐厅;中餐厅|住宿服务","政府机构及社会团体;交通车辆管理;交通车辆管理相关","汽车维修;汽车维修;汽车维修|汽车服务","政府机构及社会团体;政府机关;区县级政府及事业单位|政府机构及社会团体","交通设施服务;公交车站;快速公交站","住宿服务;旅馆招待所;旅馆招待所|商务住宅","交通设施服务;火车站;进站口/检票口","地名地址信息;普通地名;区县级地名","政府机构及社会团体;政府机关;乡镇级政府及事业单位|政府机构及社会团体","购物服务;家电电子卖场;家电电子卖场|生活服务","生活服务;电讯营业厅;中国电信营业厅|购物服务","汽车维修;汽车综合维修;汽车综合维修|汽车服务","医疗保健服务;专科医院;口腔医院|医疗保健服务","金融保险服务;自动提款机;招商银行ATM","汽车服务;汽车服务相关;汽车服务相关|汽车维修","公司企业;公司;公司|汽车服务","政府机构及社会团体;社会团体;社会团体相关|公司企业","政府机构及社会团体;公检法机构;社会治安机构|政府机构及社会团体","商务住宅;住宅区;住宅小区|商务住宅","政府机构及社会团体;政府机关;乡镇级政府及事业单位|生活服务","购物服务;商场;普通商场|购物服务","公司企业;公司;机械电子|购物服务","商务住宅;住宅区;住宅小区|住宿服务","公司企业;公司;冶金化工|公司企业","公共设施;公共厕所;婴儿换洗间/哺乳室/母婴室","科教文化服务;培训机构;培训机构|购物服务","公司企业;公司;商业贸易|购物服务","餐饮服务;餐饮相关场所;餐饮相关|购物服务","生活服务;丧葬设施;殡仪馆","金融保险服务;自动提款机;中国民生银行ATM","购物服务;专卖店;自行车专卖店|摩托车服务","交通设施服务;火车站;货运火车站","购物服务;专卖店;儿童用品店|生活服务","体育休闲服务;休闲场所;休闲场所|餐饮服务","地名地址信息;自然地名;海湾海峡","政府机构及社会团体;社会团体;少先队","公司企业;公司;公司|金融保险服务","购物服务;专卖店;烟酒专卖店|公司企业","餐饮服务;中餐厅;中餐厅|餐饮服务","生活服务;维修站点;维修站点|购物服务","金融保险服务;自动提款机;兴业银行ATM","交通设施服务;长途汽车站;进站","购物服务;综合市场;农副产品市场|公司企业","住宿服务;宾馆酒店;四星级宾馆|餐饮服务","购物服务;家居建材市场;家具城|公司企业","科教文化服务;培训机构;培训机构|生活服务","公司企业;公司;广告装饰|生活服务;生活服务场所;生活服务场所","餐饮服务;冷饮店;冷饮店|餐饮服务","金融保险服务;自动提款机;上海浦东发展银行ATM","公司企业;公司;机械电子|公司企业","交通设施服务;火车站;出站口","购物服务;专卖店;专营店|购物服务","餐饮服务;茶艺馆;茶艺馆|购物服务","餐饮服务;中餐厅;特色/地方风味餐厅|餐饮服务","购物服务;花鸟鱼虫市场;花卉市场|生活服务","购物服务;便民商店/便利店;便民商店/便利店|生活服务","汽车服务;洗车场;洗车场|汽车服务","交通设施服务;停车场;公共停车场|交通设施服务","餐饮服务;糕饼店;糕饼店|购物服务","餐饮服务;中餐厅;火锅店|餐饮服务","公司企业;工厂;工厂|生活服务","餐饮服务;冷饮店;冷饮店|购物服务","医疗保健服务;综合医院;卫生院|医疗保健服务","金融保险服务;自动提款机;中信银行ATM","金融保险服务;自动提款机;中国光大银行ATM","公共设施;公用电话;公用电话","购物服务;购物相关场所;购物相关场所|餐饮服务","科教文化服务;驾校;驾校|生活服务","购物服务;综合市场;果品市场|购物服务","商务住宅;楼宇;商务写字楼|商务住宅","生活服务;美容美发店;美容美发店|生活服务","汽车销售;长安汽车销售;长安汽车销售|汽车维修","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|政府机构及社会团体","餐饮服务;糕饼店;糕饼店|餐饮服务","购物服务;综合市场;果品市场|餐饮服务","餐饮服务;中餐厅;中餐厅|体育休闲服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|餐饮服务","出入口;门","生活服务;生活服务场所;生活服务场所|公司企业","购物服务;便民商店/便利店;便民商店/便利店|餐饮服务","生活服务;电讯营业厅;中国联通营业厅|购物服务","汽车服务;汽车配件销售;汽车配件销售|汽车服务","政府机构及社会团体;政府机关;地市级政府及事业单位|政府机构及社会团体","购物服务;专卖店;专营店|科教文化服务","购物服务;超级市场;超市|购物服务;便民商店/便利店;便民商店/便利店","购物服务;专卖店;儿童用品店|购物服务","生活服务;洗浴推拿场所;洗浴推拿场所|生活服务","汽车服务;汽车配件销售;汽车配件销售|购物服务","餐饮服务;中餐厅;综合酒楼|住宿服务","体育休闲服务;娱乐场所;酒吧|餐饮服务","购物服务;家居建材市场;布艺市场|生活服务","公司企业;公司;电信公司|生活服务","公司企业;公司;公司|科教文化服务","公司企业;工厂;工厂|购物服务","购物服务;家电电子卖场;手机销售|公司企业","医疗保健服务;专科医院;专科医院|医疗保健服务","餐饮服务;中餐厅;清真菜馆|餐饮服务","汽车销售;汽车销售;汽车销售|汽车服务","生活服务;维修站点;维修站点|摩托车服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|购物服务","金融保险服务;自动提款机;华夏银行ATM","公司企业;公司企业;公司企业|生活服务","公司企业;公司;公司|餐饮服务","购物服务;商场;购物中心|购物服务","商务住宅;住宅区;住宅小区|生活服务","商务住宅;住宅区;住宅小区|地名地址信息","政府机构及社会团体;交通车辆管理;交通管理机构|政府机构及社会团体","购物服务;家居建材市场;家居建材市场|生活服务","商务住宅;住宅区;住宅小区|购物服务","政府机构及社会团体;公检法机构;公安警察|政府机构及社会团体","购物服务;家居建材市场;厨卫市场|购物服务","商务住宅;住宅区;住宅小区|餐饮服务","政府机构及社会团体;政府机关;区县级政府及事业单位|生活服务","餐饮服务;中餐厅;中餐厅|生活服务","汽车服务;汽车服务相关;汽车服务相关|购物服务","购物服务;家居建材市场;厨卫市场|公司企业","购物服务;家居建材市场;建材五金市场|公司企业;公司;公司","生活服务;维修站点;维修站点|汽车维修","生活服务;中介机构;中介机构|公司企业","生活服务;电讯营业厅;中国电信营业厅|公司企业","购物服务;购物相关场所;购物相关场所|汽车服务","摩托车服务;摩托车维修;摩托车维修|生活服务","汽车服务;汽车服务相关;汽车服务相关|汽车销售","生活服务;物流速递;物流速递|公司企业","购物服务;综合市场;农副产品市场|生活服务","汽车销售;大众特约销售;上海大众销售|汽车维修","汽车销售;吉利特约销售;吉利销售|汽车维修","生活服务;洗浴推拿场所;洗浴推拿场所|购物服务","购物服务;综合市场;蔬菜市场|购物服务","金融保险服务;自动提款机;广发银行ATM","购物服务;购物相关场所;购物相关场所|公司企业","政府机构及社会团体;政府机关;区县级政府及事业单位|公司企业","生活服务;洗浴推拿场所;洗浴推拿场所|住宿服务","生活服务;丧葬设施;丧葬设施|购物服务","购物服务;家居建材市场;布艺市场|购物服务","购物服务;专卖店;珠宝首饰工艺品|生活服务","购物服务;家电电子卖场;家电电子卖场|公司企业","汽车销售;大众特约销售;一汽-大众销售|汽车维修","购物服务;专卖店;自行车专卖店|汽车服务","购物服务;家居建材市场;建材五金市场|汽车服务","政府机构及社会团体;政府机关;政府机关相关|公司企业","政府机构及社会团体;政府机关;政府机关相关|生活服务","科教文化服务;学校;职业技术学校|科教文化服务","购物服务;家居建材市场;家具城|购物服务","金融保险服务;自动提款机;平安银行ATM","汽车服务;汽车服务相关;汽车服务相关|生活服务","汽车维修;汽车维修;汽车维修|汽车销售","购物服务;花鸟鱼虫市场;花卉市场|公司企业","购物服务;专卖店;古玩字画店|科教文化服务","住宿服务;宾馆酒店;五星级宾馆|餐饮服务","汽车销售;长城汽车销售;长城汽车销售|汽车维修","公司企业;公司;公司|生活服务;生活服务场所;生活服务场所","住宿服务;宾馆酒店;宾馆酒店|生活服务","餐饮服务;甜品店;甜品店|餐饮服务","商务住宅;楼宇;商住两用楼宇|商务住宅","公司企业;公司企业;公司企业|购物服务","餐饮服务;茶艺馆;茶艺馆|餐饮服务","汽车销售;日产特约销售;东风日产销售|汽车维修","科教文化服务;学校;幼儿园|科教文化服务","生活服务;摄影冲印店;摄影冲印|购物服务","道路附属设施;服务区;高速停车区","生活服务;生活服务场所;生活服务场所|汽车服务","科教文化服务;科教文化场所;科教文化场所|生活服务","政府机构及社会团体;社会团体;社会团体相关|购物服务","购物服务;家居建材市场;家居建材市场|公司企业","公司企业;公司;公司|汽车销售","汽车销售;东风特约销售;东风销售|汽车维修","购物服务;便民商店/便利店;便民商店/便利店|公司企业","交通设施服务;公交车站;电车站","购物服务;家电电子卖场;手机销售|生活服务;电讯营业厅;中国移动营业厅","地名地址信息;普通地名;村庄级地名|商务住宅","购物服务;家居建材市场;灯具瓷器市场|公司企业","餐饮服务;中餐厅;中餐厅|公司企业","生活服务;洗浴推拿场所;洗浴推拿场所|体育休闲服务","购物服务;专卖店;烟酒专卖店|餐饮服务","交通设施服务;停车场;路边停车场|交通设施服务","金融保险服务;自动提款机;北京银行ATM","公司企业;公司;公司|商务住宅","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|商务住宅","汽车销售;丰田特约销售;一汽丰田销售|汽车维修","生活服务;物流速递;物流速递|购物服务","交通设施服务;机场相关;飞机场","体育休闲服务;休闲场所;休闲场所|住宿服务","生活服务;丧葬设施;陵园|风景名胜","购物服务;便民商店/便利店;便民商店/便利店|购物服务;超级市场;超市","餐饮服务;中餐厅;四川菜(川菜)|餐饮服务","生活服务;美容美发店;美容美发店|餐饮服务","购物服务;文化用品店;文化用品店|生活服务","公司企业;公司;冶金化工|购物服务","交通设施服务;火车站;候车室","金融保险服务;银行;农村商业银行|金融保险服务","科教文化服务;学校;中学|科教文化服务","购物服务;家电电子卖场;数码电子|购物服务","餐饮服务;中餐厅;海鲜酒楼|餐饮服务","汽车销售;通用特约销售;别克销售|汽车维修","交通设施服务;机场相关;机场出发/到达","公司企业;公司;公司|政府机构及社会团体","汽车服务;二手车交易;二手车交易|汽车销售","餐饮服务;休闲餐饮场所;休闲餐饮场所|餐饮服务","餐饮服务;咖啡厅;咖啡厅|餐饮服务","汽车销售;汽车销售;汽车销售|汽车维修;汽车维修;汽车维修","汽车销售;梅赛德斯-奔驰特约销售;梅赛德斯-奔驰销售|汽车维修","购物服务;家电电子卖场;手机销售|购物服务","购物服务;专卖店;自行车专卖店|汽车销售","科教文化服务;培训机构;培训机构|体育休闲服务","生活服务;洗浴推拿场所;洗浴推拿场所|餐饮服务","生活服务;生活服务场所;生活服务场所|科教文化服务","科教文化服务;培训机构;培训机构|科教文化服务","体育休闲服务;娱乐场所;棋牌室|餐饮服务","地名地址信息;普通地名;村庄级地名|购物服务","地名地址信息;自然地名;山|地名地址信息","公司企业;公司;网络科技|购物服务","餐饮服务;中餐厅;综合酒楼|餐饮服务","生活服务;中介机构;中介机构|购物服务","汽车销售;福特特约销售;福特销售|汽车维修","公司企业;公司;公司|购物服务;购物相关场所;购物相关场所","体育休闲服务;娱乐场所;KTV|购物服务","医疗保健服务;综合医院;综合医院|医疗保健服务","商务住宅;产业园区;产业园区|公司企业","交通设施服务;港口码头;人渡口","汽车销售;奥迪特约销售;一汽-大众奥迪销售|汽车维修","科教文化服务;学校;小学|科教文化服务","生活服务;生活服务场所;生活服务场所|商务住宅","交通设施服务;港口码头;货运港口码头","科教文化服务;学校;高等院校|科教文化服务","生活服务;物流速递;物流仓储场地|公司企业","购物服务;超级市场;超市|生活服务","体育休闲服务;娱乐场所;KTV|生活服务","购物服务;专卖店;烟酒专卖店|生活服务","购物服务;专卖店;儿童用品店|科教文化服务","购物服务;家居建材市场;厨卫市场|生活服务","购物服务;商场;普通商场|商务住宅","汽车销售;现代特约销售;北京现代销售|汽车维修","生活服务;电讯营业厅;中国移动营业厅|公司企业","购物服务;家居建材市场;家居建材市场|购物服务","餐饮服务;外国餐厅;西餐厅(综合风味)|餐饮服务","体育休闲服务;娱乐场所;KTV|餐饮服务","科教文化服务;传媒机构;传媒机构|生活服务","地名地址信息;交通地名;道路名|购物服务","公司企业;公司;广告装饰|科教文化服务","公司企业;农林牧渔基地;其它农林牧渔基地|公司企业","购物服务;专卖店;书店|科教文化服务","购物服务;专卖店;珠宝首饰工艺品|公司企业","汽车销售;本田特约销售;东风本田销售|汽车维修","商务住宅;楼宇;商务写字楼|购物服务","汽车销售;丰田特约销售;广汽丰田销售|汽车维修","汽车销售;本田特约销售;广汽本田销售|汽车维修","购物服务;专卖店;古玩字画店|生活服务","医疗保健服务;诊所;诊所|医疗保健服务","汽车销售;北京汽车销售;北京汽车销售|汽车维修","购物服务;家居建材市场;灯具瓷器市场|购物服务","摩托车服务;摩托车销售;摩托车销售|购物服务","购物服务;专卖店;礼品饰品店|购物服务","交通设施服务;火车站;站台","政府机构及社会团体;社会团体;社会团体相关|生活服务","科教文化服务;培训机构;培训机构|公司企业","住宿服务;住宿服务相关;住宿服务相关|餐饮服务","购物服务;专卖店;儿童用品店|餐饮服务","公司企业;公司;电信公司|购物服务","住宿服务;旅馆招待所;旅馆招待所|餐饮服务","汽车销售;奇瑞特约销售;奇瑞销售|汽车维修","金融保险服务;自动提款机;北京农商银行ATM","生活服务;维修站点;维修站点|汽车服务","政府机构及社会团体;政府机关;乡镇级政府及事业单位|科教文化服务","医疗保健服务;医药保健销售店;药房|医疗保健服务","科教文化服务;展览馆;室内展位","体育休闲服务;娱乐场所;酒吧|购物服务","商务住宅;楼宇;商务写字楼|公司企业","金融保险服务;自动提款机;广州农商银行ATM","交通设施服务;火车站;售票","体育休闲服务;度假疗养场所;疗养院|生活服务","住宿服务;旅馆招待所;旅馆招待所|生活服务","汽车服务;汽车配件销售;汽车配件销售|公司企业","科教文化服务;传媒机构;传媒机构|公司企业","公司企业;工厂;工厂|公司企业;公司;公司","生活服务;电力营业厅;电力营业厅|公司企业","地名地址信息;普通地名;村庄级地名|地名地址信息","科教文化服务;科研机构;科研机构|公司企业","汽车销售;广汽传祺销售;广汽传祺销售|汽车维修","体育休闲服务;娱乐场所;KTV|体育休闲服务","购物服务;专卖店;儿童用品店|公司企业","汽车销售;荣威销售;荣威销售|汽车维修","政府机构及社会团体;社会团体;社会团体相关|科教文化服务","汽车销售;宝马特约销售;宝马销售|汽车维修","餐饮服务;中餐厅;中餐厅|商务住宅","住宿服务;宾馆酒店;宾馆酒店|体育休闲服务","生活服务;人才市场;人才市场|公司企业","餐饮服务;快餐厅;快餐厅|餐饮服务","交通设施;停车场","政府机构及社会团体;公检法机构;公证鉴定机构|政府机构及社会团体","生活服务;生活服务场所;生活服务场所|汽车维修","体育休闲服务;休闲场所;休闲场所|生活服务","交通设施服务;长途汽车站;出站","汽车服务;汽车养护/装饰;汽车养护|购物服务","生活服务;摄影冲印店;摄影冲印|公司企业","汽车销售;通用特约销售;雪佛兰销售|汽车维修","汽车维修;汽车维修;汽车维修|生活服务","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|地名地址信息","生活服务;电讯营业厅;中国移动营业厅|购物服务;家电电子卖场;手机销售","汽车销售;起亚特约销售;东风悦达起亚销售|汽车维修","生活服务;物流速递;物流仓储场地|商务住宅","政府机构及社会团体;公检法机构;公证鉴定机构|公司企业","地名地址信息;市中心;城市中心","政府机构及社会团体;政府机关;地市级政府及事业单位|生活服务","金融保险服务;自动提款机;深圳农村商业银行ATM","交通设施服务;轮渡站;轮渡站","购物服务;综合市场;水产海鲜市场|餐饮服务","金融保险服务;自动提款机;上海银行ATM","汽车销售;汽车销售;汽车销售|购物服务","生活服务;婴儿服务场所;婴儿游泳馆|购物服务","购物服务;服装鞋帽皮具店;品牌服装店|购物服务","餐饮服务;快餐厅;茶餐厅|餐饮服务","交通设施服务;停车场;专用停车场|交通设施服务","政府机构及社会团体;政府机关;区县级政府及事业单位|科教文化服务","购物服务;专卖店;珠宝首饰工艺品|购物服务","地名地址信息;普通地名;地市级地名","政府机构及社会团体;政府机关;地市级政府及事业单位|公司企业","餐饮服务;餐饮相关场所;餐饮相关|生活服务","住宿服务;宾馆酒店;宾馆酒店|住宿服务;旅馆招待所;旅馆招待所","住宿服务;宾馆酒店;宾馆酒店|公司企业","交通设施服务;班车站;班车站","交通设施服务;长途汽车站;候车室","医疗保健服务;综合医院;三级甲等医院|医疗保健服务","购物服务;家居建材市场;家具城|生活服务","购物服务;综合市场;果品市场|公司企业","生活服务;中介机构;中介机构|生活服务","汽车服务;汽车养护/装饰;汽车养护|汽车销售","生活服务;生活服务场所;生活服务场所|餐饮服务","购物服务;专卖店;礼品饰品店|生活服务","商务住宅;商务住宅相关;商务住宅相关|生活服务","住宿服务;住宿服务相关;住宿服务相关|商务住宅","汽车服务;汽车养护/装饰;汽车养护|生活服务","风景名胜;公园广场;公园|风景名胜","商务住宅;住宅区;住宅小区|体育休闲服务","购物服务;家电电子卖场;手机销售|生活服务;电讯营业厅;中国电信营业厅","住宿服务;住宿服务相关;住宿服务相关|体育休闲服务;休闲场所;休闲场所","商务住宅;住宅区;社区中心|生活服务","汽车服务;汽车养护/装饰;汽车养护|汽车维修;汽车维修;汽车维修","商务住宅;住宅区;住宅小区|公司企业","金融保险服务;自动提款机;上海农商银行ATM","医疗保健服务;医药保健销售店;医疗保健用品|医疗保健服务","商务住宅;楼宇;商务写字楼|政府机构及社会团体","政府机构及社会团体;社会团体;社会团体相关|金融保险服务","生活服务;事务所;会计师事务所|公司企业","住宿服务;宾馆酒店;宾馆酒店|商务住宅","公司企业;农林牧渔基地;其它农林牧渔基地|购物服务","住宿服务;宾馆酒店;宾馆酒店|购物服务","汽车销售;大众特约销售;斯柯达销售|汽车维修","政府机构及社会团体;政府机关;省直辖市级政府及事业单位|政府机构及社会团体","购物服务;个人用品/化妆品店;其它个人用品店|购物服务","汽车维修;长城汽车维修;长城汽车维修|汽车销售","餐饮服务;咖啡厅;咖啡厅|购物服务","商务住宅;住宅区;宿舍|商务住宅","生活服务;电讯营业厅;中国联通营业厅|公司企业","体育休闲服务;运动场馆;健身中心|生活服务","购物服务;专卖店;书店|公司企业","汽车维修;汽车综合维修;汽车综合维修|汽车销售","生活服务;美容美发店;美容美发店|购物服务;购物相关场所;购物相关场所","体育休闲服务;休闲场所;采摘园|公司企业","购物服务;服装鞋帽皮具店;品牌服装店|生活服务","交通设施服务;火车站;票务相关","摩托车服务;摩托车销售;摩托车销售|摩托车服务","公司企业;公司;网络科技|生活服务","医疗保健服务;医疗保健服务场所;医疗保健服务场所|生活服务","汽车销售;名爵销售;名爵销售|汽车维修","政府机构及社会团体;政府机关;政府机关相关|科教文化服务","汽车销售;通用特约销售;凯迪拉克销售|汽车维修","住宿服务;宾馆酒店;经济型连锁酒店|住宿服务","购物服务;家居建材市场;家具建材综合市场|购物服务","汽车销售;福特特约销售;马自达销售|汽车维修","购物服务;专卖店;自行车专卖店|公司企业","住宿服务;旅馆招待所;旅馆招待所|体育休闲服务","购物服务;花鸟鱼虫市场;花卉市场|购物服务","政府机构及社会团体;交通车辆管理;验车场|公司企业","购物服务;专卖店;儿童用品店|体育休闲服务","公司企业;公司;广告装饰|公司企业","政府机构及社会团体;政府机关;乡镇级政府及事业单位|公司企业","体育休闲服务;运动场馆;跆拳道场馆|科教文化服务","购物服务;家居建材市场;建材五金市场|餐饮服务","购物服务;综合市场;水产海鲜市场|购物服务","汽车服务;洗车场;洗车场|汽车维修","汽车维修;货车维修;货车维修|汽车服务","商务住宅;住宅区;住宅小区|政府机构及社会团体","医疗保健服务;专科医院;骨科医院|医疗保健服务","政府机构及社会团体;政府及社会团体相关;政府及社会团体相关|生活服务","医疗保健服务;专科医院;妇科医院|医疗保健服务","购物服务;专卖店;专营店|公司企业;公司;公司","体育休闲服务;休闲场所;休闲场所|体育休闲服务","公司企业;公司;公司|汽车维修","商务住宅;住宅区;社区中心|科教文化服务","生活服务;美容美发店;美容美发店|公司企业","购物服务;花鸟鱼虫市场;花卉市场|餐饮服务","汽车销售;红旗销售;红旗销售|汽车维修","汽车销售;长城汽车销售;魏派汽车销售|汽车维修","购物服务;专卖店;自行车专卖店|生活服务;维修站点;维修站点","地名地址信息;自然地名;湖泊|地名地址信息","购物服务;综合市场;果品市场|生活服务","购物服务;超级市场;超市|餐饮服务","住宿服务;旅馆招待所;旅馆招待所|购物服务","公司企业;公司;机械电子|生活服务","商务住宅;产业园区;产业园区|生活服务","购物服务;专卖店;宠物用品店|生活服务","汽车销售;标致雪铁龙特约销售;东风雪铁龙销售|汽车维修","购物服务;专卖店;烟酒专卖店|体育休闲服务","购物服务;综合市场;水产海鲜市场|公司企业","购物服务;专卖店;专营店|生活服务;生活服务场所;生活服务场所","商务住宅;住宅区;社区中心|体育休闲服务","汽车销售;三菱特约销售;广汽三菱销售|汽车维修","摩托车服务;摩托车维修;摩托车维修|摩托车服务","购物服务;家电电子卖场;家电电子卖场|购物服务","金融保险服务;银行;中国邮政储蓄银行|生活服务","科教文化服务;学校;成人教育|科教文化服务","购物服务;购物相关场所;购物相关场所|汽车销售","汽车销售;标致雪铁龙特约销售;东风标致销售|汽车维修","地名地址信息;自然地名;沙漠","购物服务;专卖店;专营店|汽车维修","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|公司企业;公司;公司","政府机构及社会团体;交通车辆管理;交通执法站|政府机构及社会团体","购物服务;超级市场;超市|公司企业","公司企业;公司;建筑公司|公司企业","生活服务;维修站点;维修站点|公司企业","公司企业;公司;机械电子|汽车服务","商务住宅;楼宇;商务写字楼|生活服务","政府机构及社会团体;政府机关;省直辖市级政府及事业单位|科教文化服务","住宿服务;旅馆招待所;旅馆招待所|住宿服务;宾馆酒店;宾馆酒店","体育休闲服务;娱乐场所;棋牌室|购物服务","汽车销售;货车销售;货车销售|汽车维修","购物服务;综合市场;综合市场|购物服务","体育休闲服务;运动场馆;运动场所|科教文化服务","生活服务;美容美发店;美容美发店|商务住宅","体育休闲服务;运动场馆;健身中心|体育休闲服务","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|科教文化服务","汽车维修;东风特约维修;东风维修|汽车销售","生活服务;生活服务场所;生活服务场所|政府机构及社会团体","购物服务;综合市场;旧货市场|生活服务","金融保险服务;金融保险服务机构;金融保险机构|生活服务","公司企业;公司;建筑公司|生活服务","体育休闲服务;运动场馆;健身中心|科教文化服务","公司企业;公司;公司|住宿服务","政府机构及社会团体;公检法机构;社会治安机构|公司企业","购物服务;家居建材市场;建材五金市场|公司企业;工厂;工厂","生活服务;美容美发店;美容美发店|科教文化服务","科教文化服务;培训机构;培训机构|餐饮服务","购物服务;文化用品店;文化用品店|公司企业","公司企业;公司;公司|购物服务;专卖店;专营店","政府机构及社会团体;政府机关;政府机关相关|政府机构及社会团体","生活服务;洗衣店;洗衣店|购物服务","通行设施;虚拟门;虚拟门","汽车服务;汽车服务相关;汽车服务相关|公司企业","地名地址信息;普通地名;村庄级地名|餐饮服务","地名地址信息;交通地名;桥|地名地址信息","体育休闲服务;娱乐场所;网吧|购物服务","体育休闲服务;运动场馆;台球厅|体育休闲服务","体育休闲服务;度假疗养场所;度假村|体育休闲服务","公司企业;公司;公司|公司企业;工厂;工厂","交通设施服务;上下客区;出租车","政府机构及社会团体;政府机关;地市级政府及事业单位|科教文化服务","交通设施服务;机场相关;机场相关","体育休闲服务;娱乐场所;娱乐场所|生活服务","生活服务;邮局;邮政速递|生活服务","购物服务;专卖店;专营店|餐饮服务;茶艺馆;茶艺馆","商务住宅;住宅区;住宅区|生活服务","生活服务;生活服务场所;生活服务场所|金融保险服务","餐饮服务;茶艺馆;茶艺馆|体育休闲服务","购物服务;专卖店;钟表店|生活服务","购物服务;家电电子卖场;家电电子卖场|汽车服务","购物服务;购物相关场所;购物相关场所|商务住宅","汽车维修;大众特约维修;上海大众维修|汽车销售","体育休闲服务;休闲场所;游乐场|体育休闲服务","生活服务;摄影冲印店;摄影冲印|生活服务","金融保险服务;自动提款机;农村商业银行ATM|金融保险服务","体育休闲服务;娱乐场所;棋牌室|生活服务","汽车服务;汽车配件销售;汽车配件销售|生活服务","公司企业;农林牧渔基地;其它农林牧渔基地|体育休闲服务","政府机构及社会团体;工商税务机构;工商部门|政府机构及社会团体","购物服务;家居建材市场;建材五金市场|商务住宅","体育休闲服务;娱乐场所;酒吧|体育休闲服务","购物服务;专卖店;专营店|汽车服务;汽车服务相关;汽车服务相关","公司企业;公司;商业贸易|汽车服务","政府机构及社会团体;公检法机构;消防机关|生活服务","政府机构及社会团体;政府机关;乡镇级政府及事业单位|购物服务","商务住宅;商务住宅相关;商务住宅相关|购物服务","交通设施服务;机场相关;候机室","交通设施服务;港口码头;车渡口","生活服务;邮局;邮局|公司企业","购物服务;家电电子卖场;综合家电商场|购物服务","体育休闲服务;运动场馆;游泳馆|体育休闲服务","生活服务;旅行社;旅行社|公司企业","购物服务;文化用品店;文化用品店|购物服务","购物服务;特色商业街;步行街|地名地址信息","科教文化服务;学校;幼儿园|生活服务","购物服务;综合市场;蔬菜市场|生活服务","体育休闲服务;休闲场所;游乐场|购物服务","汽车销售;汽车销售;汽车销售|公司企业","购物服务;综合市场;农副产品市场|购物服务;超级市场;超市","购物服务;花鸟鱼虫市场;花卉市场|商务住宅","住宿服务;旅馆招待所;旅馆招待所|商务住宅;商务住宅相关;商务住宅相关","公司企业;公司;网络科技|公司企业","政府机构及社会团体;政府机关;政府机关相关|公司企业;公司企业;公司企业","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|商务住宅","政府机构及社会团体;交通车辆管理;车辆管理机构|政府机构及社会团体","餐饮服务;快餐厅;麦当劳|餐饮服务","体育休闲服务;休闲场所;休闲场所|科教文化服务","医疗保健服务;专科医院;口腔医院|医疗保健服务;诊所;诊所","汽车销售;江淮销售;江淮销售|汽车维修","餐饮服务;外国餐厅;牛扒店(扒房)|餐饮服务","购物服务;专卖店;书店|购物服务","政府机构及社会团体;社会团体;行业协会|政府机构及社会团体","商务住宅;住宅区;住宅区|住宿服务","购物服务;专卖店;专营店|体育休闲服务","餐饮服务;快餐厅;肯德基|餐饮服务","汽车维修;汽车维修;汽车维修|汽车服务;汽车服务相关;汽车服务相关","餐饮服务;中餐厅;海鲜酒楼|住宿服务","体育休闲服务;度假疗养场所;度假村|住宿服务","购物服务;专卖店;眼镜店|公司企业","体育休闲服务;娱乐场所;网吧|体育休闲服务","购物服务;商场;商场|购物服务","购物服务;商场;普通商场|生活服务","公司企业;公司;公司|体育休闲服务","住宿服务;宾馆酒店;三星级宾馆|餐饮服务","地名地址信息;交通地名;环岛名","购物服务;家居建材市场;建材五金市场|公司企业;公司企业;公司企业","购物服务;综合市场;蔬菜市场|餐饮服务","地名地址信息;普通地名;村组级地名|地名地址信息","购物服务;家电电子卖场;数码电子|汽车服务","购物服务;综合市场;农副产品市场|餐饮服务;餐饮相关场所;餐饮相关","餐饮服务;中餐厅;东北菜|餐饮服务","政府机构及社会团体;政府机关;政府机关相关|商务住宅","汽车维修;汽车维修;汽车维修|购物服务","汽车销售;货车销售;货车销售|汽车服务","生活服务;电讯营业厅;中国电信营业厅|购物服务;家电电子卖场;手机销售","购物服务;家居建材市场;灯具瓷器市场|生活服务","住宿服务;宾馆酒店;四星级宾馆|餐饮服务;餐饮相关场所;餐饮相关","生活服务;人才市场;人才市场|生活服务","科教文化服务;学校;学校|科教文化服务","体育休闲服务;娱乐场所;棋牌室|体育休闲服务","政府机构及社会团体;社会团体;社会团体相关|政府机构及社会团体","汽车维修;日产特约维修;东风日产维修|汽车销售","购物服务;购物相关场所;购物相关场所|汽车维修","餐饮服务;中餐厅;湖南菜(湘菜)|餐饮服务","公司企业;公司;商业贸易|公司企业","购物服务;专卖店;珠宝首饰工艺品|餐饮服务","购物服务;商场;普通商场|公司企业","购物服务;花鸟鱼虫市场;宠物市场|购物服务","地名地址信息;自然地名;山脉","生活服务;洗浴推拿场所;洗浴推拿场所|商务住宅","医疗保健服务;疾病预防机构;疾病预防|医疗保健服务","地名地址信息;交通地名;立交桥|地名地址信息","风景名胜;风景名胜;红色景区|风景名胜","生活服务;物流速递;物流速递|汽车服务","购物服务;专卖店;专营店|摩托车服务","金融保险服务;银行;中国农业银行|金融保险服务","公司企业;公司;公司|购物服务;服装鞋帽皮具店;服装鞋帽皮具店","公司企业;公司;建筑公司|购物服务","餐饮服务;中餐厅;云贵菜|餐饮服务","商务住宅;住宅区;住宅小区|住宿服务;旅馆招待所;旅馆招待所","汽车维修;现代特约维修;北京现代维修|汽车销售","餐饮服务;快餐厅;快餐厅|生活服务","公司企业;公司;商业贸易|生活服务","汽车销售;丰田特约销售;雷克萨斯销售|汽车维修","科教文化服务;学校;幼儿园|购物服务","购物服务;专卖店;珠宝首饰工艺品|科教文化服务","汽车服务;汽车服务相关;汽车服务相关|汽车维修;汽车维修;汽车维修","餐饮服务;茶艺馆;茶艺馆|购物服务;专卖店;专营店","商务住宅;商务住宅相关;商务住宅相关|住宿服务","政府机构及社会团体;公检法机构;社会治安机构|生活服务","生活服务;事务所;律师事务所|政府机构及社会团体","体育休闲服务;娱乐场所;娱乐场所|购物服务","汽车服务;二手车交易;二手车交易|汽车服务","风景名胜;公园广场;城市广场|购物服务","政府机构及社会团体;政府机关;政府机关相关|金融保险服务","政府机构及社会团体;社会团体;社会团体相关|公司企业;公司企业;公司企业","购物服务;体育用品店;体育用品店|购物服务","金融保险服务;银行;中国邮政储蓄银行|金融保险服务","商务住宅;住宅区;别墅|商务住宅","汽车维修;长安汽车维修;长安汽车维修|汽车销售","餐饮服务;餐饮相关场所;餐饮相关|体育休闲服务","体育休闲服务;休闲场所;休闲场所|公司企业","体育休闲服务;娱乐场所;网吧|公司企业","汽车服务;汽车配件销售;汽车配件销售|汽车销售","汽车维修;福特特约维修;福特维修|汽车销售","购物服务;便民商店/便利店;便民商店/便利店|住宿服务","住宿服务;宾馆酒店;经济型连锁酒店|购物服务","商务住宅;住宅区;住宅区|购物服务","政府机构及社会团体;公检法机构;消防机关|政府机构及社会团体","生活服务;美容美发店;美容美发店|体育休闲服务","购物服务;家电电子卖场;数码电子|生活服务;维修站点;维修站点","金融保险服务;银行;中国工商银行|金融保险服务","餐饮服务;糕饼店;糕饼店|公司企业","科教文化服务;美术馆;美术馆|科教文化服务","购物服务;综合市场;小商品市场|购物服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|餐饮服务","体育休闲服务;娱乐场所;娱乐场所|体育休闲服务","金融保险服务;金融保险服务机构;金融保险机构|汽车服务","餐饮服务;中餐厅;广东菜(粤菜)|餐饮服务","汽车服务;二手车交易;二手车交易|购物服务","生活服务;物流速递;物流速递|汽车销售","购物服务;专卖店;自行车专卖店|摩托车服务;摩托车销售;摩托车销售","购物服务;专卖店;自行车专卖店|购物服务","体育休闲服务;休闲场所;休闲场所|风景名胜","生活服务;生活服务场所;生活服务场所|体育休闲服务","体育休闲服务;度假疗养场所;度假村|风景名胜","生活服务;邮局;邮政速递|公司企业","体育休闲服务;度假疗养场所;疗养院|政府机构及社会团体","体育休闲服务;运动场馆;健身中心|购物服务","公司企业;公司;广告装饰|购物服务;家居建材市场;建材五金市场","生活服务;电讯营业厅;中国移动营业厅|生活服务","金融保险服务;银行;中国银行|金融保险服务","体育休闲服务;休闲场所;休闲场所|购物服务","汽车服务;汽车租赁;汽车租赁|生活服务","汽车服务;汽车配件销售;汽车配件销售|汽车维修;汽车维修;汽车维修","汽车销售;斯巴鲁特约销售;斯巴鲁销售|汽车维修","餐饮服务;茶艺馆;茶艺馆|生活服务","购物服务;家电电子卖场;数码电子|公司企业;公司;公司","购物服务;家电电子卖场;综合家电商场|生活服务","商务住宅;楼宇;商务写字楼|住宿服务","政府机构及社会团体;社会团体;残联|生活服务","购物服务;商场;购物中心|商务住宅","体育休闲服务;体育休闲服务场所;体育休闲服务场所|购物服务","公司企业;公司企业;公司企业|金融保险服务","摩托车服务;摩托车服务相关;摩托车服务相关|购物服务","汽车维修;汽车综合维修;汽车综合维修|生活服务","汽车维修;货车维修;货车维修|汽车维修","购物服务;家电电子卖场;手机销售|生活服务;维修站点;维修站点","购物服务;服装鞋帽皮具店;品牌鞋店|购物服务","购物服务;综合市场;旧货市场|购物服务","住宿服务;宾馆酒店;宾馆酒店|餐饮服务;中餐厅;中餐厅","汽车销售;吉利特约销售;沃尔沃销售|汽车维修","生活服务;婴儿服务场所;婴儿游泳馆|体育休闲服务","购物服务;特色商业街;特色商业街|餐饮服务","餐饮服务;甜品店;甜品店|购物服务","交通设施服务;港口码头;客运港","体育休闲服务;娱乐场所;网吧|餐饮服务","公司企业;农林牧渔基地;其它农林牧渔基地|政府机构及社会团体","生活服务;洗浴推拿场所;洗浴推拿场所|公司企业","购物服务;专卖店;烟酒专卖店|购物服务;便民商店/便利店;便民商店/便利店","购物服务;体育用品店;体育用品店|公司企业","购物服务;便民商店/便利店;便民商店/便利店|汽车服务","购物服务;家居建材市场;建材五金市场|购物服务;专卖店;专营店","购物服务;专卖店;古玩字画店|购物服务","体育休闲服务;休闲场所;游乐场|科教文化服务","公司企业;公司;公司|金融保险服务;金融保险服务机构;金融保险机构","政府机构及社会团体;社会团体;慈善机构|生活服务","汽车销售;保时捷特约销售;保时捷销售|汽车维修","购物服务;体育用品店;户外用品|购物服务","金融保险服务;银行;银行|金融保险服务","餐饮服务;中餐厅;综合酒楼|体育休闲服务","餐饮服务;餐饮相关场所;餐饮相关|住宿服务","体育休闲服务;娱乐场所;娱乐场所|餐饮服务","体育休闲服务;娱乐场所;网吧|生活服务","购物服务;专卖店;专营店|餐饮服务;餐饮相关场所;餐饮相关","住宿服务;宾馆酒店;四星级宾馆|住宿服务","医疗保健服务;专科医院;整形美容|医疗保健服务","地名地址信息;交通地名;道路名|商务住宅","地名地址信息;自然地名;山|地名地址信息;普通地名;村庄级地名","风景名胜;公园广场;城市广场|商务住宅","购物服务;家电电子卖场;手机销售|生活服务;电讯营业厅;中国联通营业厅","金融保险服务;金融保险服务机构;金融保险机构|公司企业","生活服务;事务所;评估事务所|公司企业","生活服务;电讯营业厅;中国电信营业厅|生活服务","购物服务;购物相关场所;购物相关场所|体育休闲服务","公司企业;公司企业;公司企业|汽车服务","生活服务;中介机构;中介机构|商务住宅","科教文化服务;学校;高等院校|生活服务","购物服务;家电电子卖场;家电电子卖场|生活服务;维修站点;维修站点","餐饮服务;餐饮相关场所;餐饮相关|购物服务;购物相关场所;购物相关场所","公司企业;公司;冶金化工|生活服务","商务住宅;产业园区;产业园区|科教文化服务","商务住宅;住宅区;住宅小区|风景名胜","商务住宅;住宅区;社区中心|政府机构及社会团体","科教文化服务;培训机构;培训机构|商务住宅","购物服务;家电电子卖场;家电电子卖场|餐饮服务","地名地址信息;自然地名;河流|地名地址信息","汽车服务;汽车服务相关;汽车服务相关|金融保险服务","科教文化服务;驾校;驾校|生活服务;生活服务场所;生活服务场所","购物服务;个人用品/化妆品店;其它个人用品店|公司企业","公司企业;工厂;工厂|生活服务;生活服务场所;生活服务场所","生活服务;美容美发店;美容美发店|生活服务;洗浴推拿场所;洗浴推拿场所","科教文化服务;展览馆;展览馆|科教文化服务","购物服务;购物相关场所;购物相关场所|餐饮服务;餐饮相关场所;餐饮相关","医疗保健服务;专科医院;眼科医院|医疗保健服务","商务住宅;住宅区;住宅小区|科教文化服务","购物服务;文化用品店;文化用品店|科教文化服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|生活服务","汽车维修;起亚特约维修;东风悦达起亚维修|汽车销售","购物服务;家居建材市场;建材五金市场|汽车维修","汽车服务;汽车养护/装饰;汽车养护|公司企业","生活服务;中介机构;中介机构|购物服务;购物相关场所;购物相关场所","生活服务;中介机构;中介机构|金融保险服务","餐饮服务;糕饼店;糕饼店|生活服务","汽车销售;大众特约销售;进口大众销售|汽车维修","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|体育休闲服务","风景名胜;公园广场;水族馆|购物服务","体育休闲服务;娱乐场所;KTV|商务住宅","摩托车服务;摩托车维修;摩托车维修|购物服务","体育休闲服务;休闲场所;休闲场所|餐饮服务;中餐厅;中餐厅","商务住宅;楼宇;商住两用楼宇|购物服务","政府机构及社会团体;公检法机构;公证鉴定机构|科教文化服务","汽车维修;北京汽车维修;北京汽车维修|汽车销售","汽车销售;克莱斯勒特约销售;吉普销售|汽车维修","生活服务;物流速递;物流速递|商务住宅","生活服务;自来水营业厅;自来水营业厅|公司企业","购物服务;超级市场;华润|购物服务","餐饮服务;中餐厅;中餐厅|科教文化服务","餐饮服务;中餐厅;综合酒楼|商务住宅","商务住宅;楼宇;商务写字楼|科教文化服务","地名地址信息;普通地名;村庄级地名|生活服务","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|公司企业","生活服务;摄影冲印店;摄影冲印|餐饮服务","交通设施服务;上下客区;上下客区","汽车维修;汽车综合维修;汽车综合维修|汽车维修","购物服务;专卖店;自行车专卖店|汽车维修","购物服务;综合市场;水产海鲜市场|生活服务","餐饮服务;休闲餐饮场所;休闲餐饮场所|购物服务","商务住宅;住宅区;宿舍|住宿服务","政府机构及社会团体;政府机关;省直辖市级政府及事业单位|公司企业","购物服务;家电电子卖场;手机销售|生活服务;生活服务场所;生活服务场所","购物服务;综合市场;农副产品市场|生活服务;生活服务场所;生活服务场所","汽车维修;货车维修;货车维修|汽车销售","购物服务;专卖店;专营店|汽车销售","购物服务;专卖店;书店|生活服务","风景名胜;公园广场;城市广场|体育休闲服务","出入口;停车场出入口","汽车维修;本田特约维修;东风本田维修|汽车销售","生活服务;中介机构;中介机构|餐饮服务","住宿服务;宾馆酒店;三星级宾馆|住宿服务","地名地址信息;普通地名;村庄级地名|风景名胜","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|科教文化服务","购物服务;特色商业街;特色商业街|生活服务","风景名胜;风景名胜;风景名胜|体育休闲服务","交通设施服务;过境口岸;过境口岸","地名地址信息;普通地名;村庄级地名|政府机构及社会团体","汽车维修;通用特约维修;别克维修|汽车销售","科教文化服务;文化宫;文化宫|科教文化服务","餐饮服务;中餐厅;中餐厅|风景名胜","公司企业;公司;公司|汽车服务;汽车服务相关;汽车服务相关","商务住宅;住宅区;住宅区|餐饮服务","汽车维修;广汽传祺维修;广汽传祺维修|汽车销售","汽车销售;吉利特约销售;沃尔沃汽车销售|汽车维修","生活服务;物流速递;物流速递|生活服务","购物服务;综合市场;蔬菜市场|公司企业","住宿服务;住宿服务相关;住宿服务相关|生活服务","体育休闲服务;度假疗养场所;疗养院|体育休闲服务","购物服务;专卖店;烟酒专卖店|住宿服务","体育休闲服务;运动场馆;游泳馆|生活服务","政府机构及社会团体;社会团体;行业协会|公司企业","金融保险服务;保险公司;保险公司|公司企业","金融保险服务;银行;农村商业银行|购物服务","餐饮服务;外国餐厅;日本料理|餐饮服务","生活服务;电讯营业厅;中国电信营业厅|公司企业;公司;电信公司","购物服务;专卖店;古玩字画店|餐饮服务","金融保险服务;银行;农村商业银行|生活服务","交通设施服务;停车场;公共停车场|交通设施服务;停车场;路边停车场","住宿服务;住宿服务相关;住宿服务相关|体育休闲服务;度假疗养场所;度假村","体育休闲服务;休闲场所;游乐场|风景名胜","生活服务;电讯营业厅;中国联通营业厅|购物服务;家电电子卖场;手机销售","生活服务;摄影冲印店;摄影冲印|科教文化服务","科教文化服务;文化宫;文化宫|体育休闲服务","餐饮服务;中餐厅;海鲜酒楼|体育休闲服务","汽车销售;汽车销售;汽车销售|汽车服务;汽车服务相关;汽车服务相关","购物服务;家电电子卖场;数码电子|科教文化服务","购物服务;购物相关场所;购物相关场所|金融保险服务","公司企业;公司;医药公司|公司企业","地名地址信息;普通地名;村庄级地名|地名地址信息;自然地名;山","政府机构及社会团体;交通车辆管理;验车场|政府机构及社会团体","政府机构及社会团体;政府机关;省直辖市级政府及事业单位|生活服务","购物服务;家居建材市场;建材五金市场|地名地址信息","风景名胜;风景名胜;红色景区|生活服务","地名地址信息;交通地名;道路名|餐饮服务","汽车销售;福特特约销售;林肯销售|汽车维修","金融保险服务;银行;中国建设银行|金融保险服务","风景名胜;公园广场;公园|体育休闲服务","政府机构及社会团体;公检法机构;公安警察|生活服务","政府机构及社会团体;社会团体;慈善机构|购物服务","金融保险服务;自动提款机;中国农业银行ATM|金融保险服务","公司企业;公司企业;公司企业|汽车销售","政府机构及社会团体;政府机关;区县级政府及事业单位|金融保险服务","汽车服务;汽车租赁;汽车租赁|公司企业","购物服务;综合市场;综合市场|生活服务","体育休闲服务;娱乐场所;夜总会|体育休闲服务","商务住宅;产业园区;产业园区|购物服务","汽车维修;通用特约维修;雪佛兰维修|汽车销售","生活服务;物流速递;物流仓储场地|购物服务","购物服务;专卖店;书店|餐饮服务","购物服务;专卖店;土特产专卖店|购物服务","政府机构及社会团体;交通车辆管理;交通管理机构|公司企业","汽车服务;二手车交易;二手车交易|汽车维修","汽车服务;汽车服务相关;汽车服务相关|汽车销售;汽车销售;汽车销售","生活服务;洗浴推拿场所;洗浴推拿场所|生活服务;美容美发店;美容美发店","生活服务;生活服务场所;生活服务场所|公司企业;公司企业;公司企业","医疗保健服务;专科医院;专科医院|医疗保健服务;诊所;诊所","地名地址信息;自然地名;山|风景名胜","汽车服务;加油站;加油站|汽车服务","购物服务;购物相关场所;购物相关场所|科教文化服务","汽车维修;吉利特约维修;吉利维修|汽车销售","汽车维修;大众特约维修;斯柯达维修|汽车销售","科教文化服务;科研机构;科研机构|生活服务","购物服务;专卖店;专营店|科教文化服务;培训机构;培训机构","购物服务;专卖店;土特产专卖店|餐饮服务","购物服务;专卖店;宠物用品店|购物服务","购物服务;专卖店;宠物用品店|餐饮服务","购物服务;专卖店;珠宝首饰工艺品|生活服务;生活服务场所;生活服务场所","购物服务;家居建材市场;布艺市场|公司企业;公司;公司","政府机构及社会团体;公检法机构;消防机关|购物服务","汽车维修;本田特约维修;广汽本田维修|汽车销售","购物服务;家居建材市场;家居建材市场|汽车服务","购物服务;家居建材市场;建材五金市场|公司企业;公司;广告装饰","购物服务;服装鞋帽皮具店;品牌服装店|餐饮服务","公司企业;工厂;工厂|餐饮服务","政府机构及社会团体;公检法机构;公证鉴定机构|生活服务","购物服务;专卖店;烟酒专卖店|公司企业;公司;公司","购物服务;综合市场;农副产品市场|政府机构及社会团体","公司企业;公司;公司|摩托车服务","公司企业;公司;商业贸易|汽车销售","地名地址信息;交通地名;交通地名","政府机构及社会团体;社会团体;行业协会|生活服务","生活服务;美容美发店;美容美发店|汽车服务","购物服务;家居建材市场;厨卫市场|餐饮服务","购物服务;家居建材市场;布艺市场|生活服务;生活服务场所;生活服务场所","购物服务;特色商业街;特色商业街|购物服务","餐饮服务;休闲餐饮场所;休闲餐饮场所|体育休闲服务","交通设施服务;火车站;公安制证","住宿服务;宾馆酒店;五星级宾馆|餐饮服务;餐饮相关场所;餐饮相关","体育休闲服务;娱乐场所;KTV|住宿服务","汽车维修;大众特约维修;一汽-大众维修|汽车销售","购物服务;个人用品/化妆品店;其它个人用品店|餐饮服务","购物服务;花鸟鱼虫市场;宠物市场|风景名胜","金融保险服务;金融保险服务机构;金融保险机构|购物服务","商务住宅;住宅区;宿舍|科教文化服务","商务住宅;楼宇;商务写字楼|商务住宅;楼宇;商住两用楼宇","政府机构及社会团体;交通车辆管理;交通管理机构|生活服务","购物服务;专卖店;礼品饰品店|公司企业","购物服务;综合市场;农副产品市场|公司企业;公司;公司","金融保险服务;保险公司;保险公司|汽车服务","风景名胜;风景名胜;纪念馆|科教文化服务","餐饮服务;中餐厅;特色/地方风味餐厅|公司企业","体育休闲服务;影剧院;电影院|生活服务","体育休闲服务;运动场馆;台球厅|购物服务","地名地址信息;普通地名;乡镇级地名|地名地址信息","生活服务;售票处;飞机票代售点|生活服务","生活服务;维修站点;维修站点|生活服务","科教文化服务;培训机构;培训机构|购物服务;专卖店;专营店","购物服务;专卖店;珠宝首饰工艺品|商务住宅","餐饮服务;中餐厅;中餐厅|餐饮服务;茶艺馆;茶艺馆","医疗保健服务;动物医疗场所;宠物诊所|医疗保健服务","地名地址信息;交通地名;交通地名|购物服务","政府机构及社会团体;政府机关;区县级政府及事业单位|购物服务","汽车销售;日产特约销售;英菲尼迪销售|汽车维修","科教文化服务;驾校;驾校|科教文化服务","公司企业;公司;建筑公司|科教文化服务","汽车销售;日产特约销售;郑州日产销售|汽车维修","购物服务;服装鞋帽皮具店;品牌服装店|公司企业","购物服务;购物相关场所;购物相关场所|摩托车服务","金融保险服务;自动提款机;中国建设银行ATM|金融保险服务","金融保险服务;自动提款机;汇丰银行ATM","风景名胜;风景名胜相关;旅游景点|体育休闲服务","公司企业;公司;冶金化工|公司企业;工厂;工厂","公司企业;工厂;工厂|汽车服务","政府机构及社会团体;政府机关;乡镇级政府及事业单位|体育休闲服务","汽车维修;标致雪铁龙特约维修;东风雪铁龙维修|汽车销售","公司企业;公司;机械电子|购物服务;专卖店;专营店","公司企业;公司;网络科技|科教文化服务","商务住宅;住宅区;社区中心|商务住宅","政府机构及社会团体;政府机关;政府机关相关|风景名胜","汽车服务;加气站;加气站|生活服务","汽车服务;汽车俱乐部;汽车俱乐部|汽车服务","购物服务;专卖店;眼镜店|生活服务","购物服务;商场;免税品店|购物服务","餐饮服务;中餐厅;中餐厅|住宿服务;宾馆酒店;宾馆酒店","餐饮服务;中餐厅;综合酒楼|生活服务","体育休闲服务;娱乐场所;游戏厅|体育休闲服务","公司企业;公司;公司|交通设施服务","医疗保健服务;专科医院;整形美容|生活服务","政府机构及社会团体;政府机关;地市级政府及事业单位|金融保险服务","生活服务;维修站点;维修站点|汽车维修;汽车维修;汽车维修","购物服务;花鸟鱼虫市场;花卉市场|生活服务;生活服务场所;生活服务场所","金融保险服务;自动提款机;中国工商银行ATM|金融保险服务","公司企业;公司;广告装饰|生活服务;摄影冲印店;摄影冲印","医疗保健服务;综合医院;卫生院|医疗保健服务;诊所;诊所","商务住宅;楼宇;商务写字楼|餐饮服务","汽车维修;汽车综合维修;汽车综合维修|公司企业","汽车维修;荣威维修;荣威维修|汽车销售","购物服务;专卖店;专营店|公司企业;公司企业;公司企业","购物服务;体育用品店;体育用品店|体育休闲服务","餐饮服务;中餐厅;综合酒楼|公司企业","体育休闲服务;度假疗养场所;度假村|餐饮服务","体育休闲服务;度假疗养场所;疗养院|商务住宅","公司企业;农林牧渔基地;其它农林牧渔基地|生活服务","医疗保健服务;专科医院;肿瘤医院|医疗保健服务","汽车服务;汽车养护/装饰;汽车养护|汽车服务;洗车场;洗车场","生活服务;中介机构;中介机构|住宿服务","购物服务;家电电子卖场;数码电子|体育休闲服务","餐饮服务;中餐厅;中餐厅|生活服务;生活服务场所;生活服务场所","交通设施服务;交通服务相关;交通服务相关|生活服务","体育休闲服务;影剧院;电影院|餐饮服务","汽车销售;宝马特约销售;宝马MINI销售|汽车维修","科教文化服务;博物馆;博物馆|风景名胜","购物服务;专卖店;钟表店|购物服务","购物服务;家居建材市场;家具城|公司企业;公司;公司","购物服务;家居建材市场;建材五金市场|科教文化服务","购物服务;家电电子卖场;家电电子卖场|汽车维修","风景名胜;风景名胜;教堂|政府机构及社会团体","餐饮服务;冷饮店;冷饮店|生活服务","体育休闲服务;运动场馆;运动场所|购物服务","公司企业;公司;医药公司|生活服务","生活服务;生活服务场所;生活服务场所|汽车销售","生活服务;维修站点;维修站点|摩托车服务;摩托车维修;摩托车维修","购物服务;专卖店;礼品饰品店|餐饮服务","购物服务;家居建材市场;家具城|餐饮服务","餐饮服务;中餐厅;火锅店|公司企业","交通设施服务;火车站;改签","住宿服务;宾馆酒店;经济型连锁酒店|餐饮服务","政府机构及社会团体;社会团体;教会|风景名胜","政府机构及社会团体;社会团体;残联|政府机构及社会团体","汽车服务;二手车交易;二手车交易|生活服务","汽车服务;汽车养护/装饰;汽车养护|汽车服务;汽车配件销售;汽车配件销售","生活服务;电讯营业厅;中国联通营业厅|生活服务","科教文化服务;培训机构;培训机构|生活服务;生活服务场所;生活服务场所","餐饮服务;中餐厅;中餐厅|体育休闲服务;休闲场所;休闲场所","餐饮服务;糕饼店;糕饼店|购物服务;购物相关场所;购物相关场所","餐饮服务;餐饮相关场所;餐饮相关|公司企业","住宿服务;旅馆招待所;青年旅舍|住宿服务","体育休闲服务;运动场馆;乒乓球馆|科教文化服务","科教文化服务;学校;幼儿园|体育休闲服务","科教文化服务;展览馆;展览馆|风景名胜","购物服务;家居建材市场;厨卫市场|公司企业;公司;公司","购物服务;文化用品店;文化用品店|餐饮服务","购物服务;综合市场;果品市场|餐饮服务;餐饮相关场所;餐饮相关","风景名胜;风景名胜相关;旅游景点|购物服务","餐饮服务;中餐厅;潮州菜|餐饮服务","餐饮服务;中餐厅;西北菜|餐饮服务","生活服务;中介机构;中介机构|汽车服务","科教文化服务;科教文化场所;科教文化场所|公司企业","购物服务;专卖店;烟酒专卖店|公司企业;公司企业;公司企业","金融保险服务;保险公司;中国人寿保险公司|公司企业","风景名胜;公园广场;城市广场|风景名胜","公司企业;公司企业;公司企业|生活服务;生活服务场所;生活服务场所","政府机构及社会团体;社会团体;行业协会|科教文化服务","生活服务;物流速递;物流速递|餐饮服务","科教文化服务;驾校;驾校|公司企业","购物服务;商场;普通商场|风景名胜","购物服务;综合市场;果品市场|体育休闲服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|住宿服务","公司企业;公司;机械电子|公司企业;工厂;工厂","公司企业;公司;电信公司|生活服务;电讯营业厅;中国电信营业厅","医疗保健服务;医药保健销售店;医疗保健用品|生活服务","地名地址信息;普通地名;乡镇级地名|政府机构及社会团体","摩托车服务;摩托车销售;摩托车销售|汽车销售","汽车服务;洗车场;洗车场|生活服务","生活服务;婴儿服务场所;婴儿游泳馆|科教文化服务","餐饮服务;中餐厅;火锅店|餐饮服务;中餐厅;特色/地方风味餐厅","体育休闲服务;娱乐场所;酒吧|生活服务","公司企业;公司;商业贸易|餐饮服务","公司企业;公司;矿产公司|公司企业","汽车维修;标致雪铁龙特约维修;东风标致维修|汽车销售","汽车销售;货车销售;货车销售|汽车销售","生活服务;生活服务场所;生活服务场所|住宿服务","科教文化服务;科教文化场所;科教文化场所|购物服务","购物服务;专卖店;古玩字画店|公司企业","政府机构及社会团体;社会团体;慈善机构|政府机构及社会团体","生活服务;事务所;评估事务所|生活服务","生活服务;售票处;火车票代售点|生活服务","生活服务;物流速递;物流速递|公司企业;公司;公司","科教文化服务;科研机构;科研机构|科教文化服务","购物服务;便民商店/便利店;便民商店/便利店|商务住宅","购物服务;家电电子卖场;手机销售|公司企业;公司;电信公司","购物服务;特殊买卖场所;典当行|公司企业","金融保险服务;保险公司;中国人民保险公司|公司企业","交通设施服务;火车站;退票","体育休闲服务;休闲场所;休闲场所|商务住宅","体育休闲服务;娱乐场所;棋牌室|科教文化服务","商务住宅;楼宇;商务写字楼|商务住宅;住宅区;住宅小区","摩托车服务;摩托车维修;摩托车维修|汽车维修","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|体育休闲服务","汽车服务;二手车交易;二手车交易|汽车销售;汽车销售;汽车销售","生活服务;彩票彩券销售点;彩票彩券销售点|购物服务","科教文化服务;传媒机构;电视台|生活服务","购物服务;家居建材市场;建材五金市场|生活服务;维修站点;维修站点","购物服务;综合市场;综合市场|公司企业","餐饮服务;中餐厅;火锅店|生活服务","住宿服务;旅馆招待所;青年旅舍|商务住宅","体育休闲服务;运动场馆;综合体育馆|体育休闲服务","政府机构及社会团体;社会团体;社会团体相关|风景名胜","汽车销售;汽车销售;汽车销售|生活服务","生活服务;洗衣店;洗衣店|公司企业","购物服务;专卖店;音像店|购物服务","购物服务;家居建材市场;家具城|商务住宅","购物服务;家居建材市场;建材五金市场|政府机构及社会团体","购物服务;服装鞋帽皮具店;品牌鞋店|生活服务","体育休闲服务;影剧院;电影院|购物服务","汽车维修;奇瑞特约维修;奇瑞维修|汽车销售","生活服务;丧葬设施;公墓|风景名胜","购物服务;家电电子卖场;数码电子|生活服务;生活服务场所;生活服务场所","购物服务;特殊买卖场所;特殊买卖场所|生活服务","餐饮服务;中餐厅;中餐厅|餐饮服务;糕饼店;糕饼店","餐饮服务;外国餐厅;韩国料理|餐饮服务","体育休闲服务;娱乐场所;游戏厅|购物服务","商务住宅;住宅区;住宅小区|商务住宅;楼宇;商务写字楼","政府机构及社会团体;政府机关;乡镇以下级政府及事业单位|购物服务","汽车服务;汽车租赁;汽车租赁|汽车服务","汽车服务;汽车租赁;汽车租赁|汽车销售","汽车维修;梅赛德斯-奔驰特约维修;梅赛德斯-奔驰维修|汽车销售","汽车销售;长城汽车销售;长城汽车销售|购物服务","生活服务;事务所;会计师事务所|生活服务","生活服务;物流速递;物流速递|住宿服务","购物服务;专卖店;专营店|商务住宅","购物服务;专卖店;专营店|风景名胜","购物服务;家居建材市场;布艺市场|餐饮服务","风景名胜;风景名胜;风景名胜|购物服务","餐饮服务;中餐厅;特色/地方风味餐厅|体育休闲服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|公司企业","体育休闲服务;影剧院;电影院|体育休闲服务","公司企业;公司;网络科技|体育休闲服务","医疗保健服务;专科医院;精神病医院|医疗保健服务","商务住宅;住宅区;社区中心|地名地址信息","商务住宅;楼宇;商务写字楼|金融保险服务","汽车销售;海马汽车销售;海马汽车销售|汽车维修","汽车销售;现代特约销售;现代销售|汽车维修","生活服务;事务所;会计师事务所|金融保险服务","生活服务;旅行社;旅行社|住宿服务","生活服务;维修站点;维修站点|购物服务;家电电子卖场;家电电子卖场","科教文化服务;传媒机构;传媒机构|购物服务","科教文化服务;文艺团体;文艺团体|科教文化服务","购物服务;专卖店;烟酒专卖店|公司企业;工厂;工厂","购物服务;家居建材市场;建材五金市场|公司企业;公司;商业贸易","餐饮服务;中餐厅;火锅店|商务住宅","餐饮服务;咖啡厅;咖啡厅|体育休闲服务","餐饮服务;外国餐厅;西餐厅(综合风味)|体育休闲服务","交通设施服务;停车场;停车场出入口|交通设施服务","公司企业;公司;公司|汽车销售;汽车销售;汽车销售","公司企业;公司;商业贸易|购物服务;购物相关场所;购物相关场所","公司企业;公司;广告装饰|餐饮服务","汽车服务;汽车配件销售;汽车配件销售|汽车服务;汽车养护/装饰;汽车养护","生活服务;丧葬设施;公墓|生活服务","生活服务;中介机构;中介机构|公司企业;公司;公司","科教文化服务;传媒机构;传媒机构|科教文化服务","科教文化服务;学校;小学|政府机构及社会团体","购物服务;专卖店;儿童用品店|购物服务;服装鞋帽皮具店;服装鞋帽皮具店","购物服务;便民商店/便利店;便民商店/便利店|金融保险服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|购物服务;专卖店;专营店","风景名胜;风景名胜;风景名胜|科教文化服务","体育休闲服务;娱乐场所;迪厅|体育休闲服务","公司企业;公司;医药公司|购物服务","公司企业;农林牧渔基地;其它农林牧渔基地|风景名胜","政府机构及社会团体;社会团体;社会团体相关|体育休闲服务","购物服务;便民商店/便利店;便民商店/便利店|政府机构及社会团体","餐饮服务;冷饮店;冷饮店|购物服务;购物相关场所;购物相关场所","餐饮服务;快餐厅;快餐厅|公司企业","体育休闲服务;体育休闲服务场所;体育休闲服务场所|风景名胜","体育休闲服务;娱乐场所;酒吧|餐饮服务;中餐厅;中餐厅","体育休闲服务;影剧院;剧场|科教文化服务","医疗保健服务;动物医疗场所;兽医站|医疗保健服务","政府机构及社会团体;政府机关;政府机关相关|购物服务","汽车维修;汽车维修;汽车维修|汽车销售;汽车销售;汽车销售","汽车维修;汽车综合维修;汽车综合维修|购物服务","科教文化服务;传媒机构;报社|公司企业","科教文化服务;传媒机构;电视台|科教文化服务","科教文化服务;学校;职业技术学校|生活服务","科教文化服务;学校;高等院校|商务住宅","购物服务;专卖店;儿童用品店|生活服务;婴儿服务场所;婴儿游泳馆","购物服务;专卖店;烟酒专卖店|政府机构及社会团体","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|汽车服务","餐饮服务;中餐厅;安徽菜(徽菜)|餐饮服务","餐饮服务;中餐厅;海鲜酒楼|公司企业","餐饮服务;咖啡厅;咖啡厅|生活服务","餐饮服务;茶艺馆;茶艺馆|餐饮服务;中餐厅;中餐厅","公司企业;公司;公司|生活服务;物流速递;物流速递","商务住宅;产业园区;产业园区|商务住宅","汽车维修;名爵维修;名爵维修|汽车销售","汽车维修;江淮维修;江淮维修|汽车销售","汽车销售;吉利特约销售;吉利销售|汽车维修;吉利特约维修;吉利维修","汽车销售;福特特约销售;福特销售|汽车维修;福特特约维修;福特维修","汽车销售;路虎特约销售;路虎销售|汽车维修","生活服务;事务所;律师事务所|公司企业","生活服务;售票处;飞机票代售点|公司企业","生活服务;洗衣店;洗衣店|生活服务","科教文化服务;学校;幼儿园|商务住宅","科教文化服务;学校;幼儿园|政府机构及社会团体","购物服务;专卖店;专营店|政府机构及社会团体","购物服务;家电电子卖场;综合家电商场|公司企业","购物服务;特殊买卖场所;典当行|生活服务","购物服务;特色商业街;特色商业街|地名地址信息","购物服务;综合市场;农副产品市场|地名地址信息","餐饮服务;中餐厅;北京菜|餐饮服务","餐饮服务;茶艺馆;茶艺馆|商务住宅","交通设施服务;上下客区;自驾车","住宿服务;住宿服务相关;住宿服务相关|购物服务","公司企业;公司;商业贸易|金融保险服务","商务住宅;住宅区;住宅小区|商务住宅;楼宇;楼宇相关","政府机构及社会团体;公检法机构;社会治安机构|科教文化服务","政府机构及社会团体;政府机关;区县级政府及事业单位|公司企业;公司;公司","汽车服务;其它能源站;其它能源站|汽车服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|住宿服务","购物服务;特殊买卖场所;拍卖行|公司企业","金融保险服务;银行;农村商业银行|公司企业","金融保险服务;银行;银行|生活服务","政府机构及社会团体;公检法机构;法院|政府机构及社会团体","政府机构及社会团体;政府机关;乡镇级政府及事业单位|地名地址信息","汽车服务;汽车配件销售;汽车配件销售|摩托车服务","汽车维修;三菱特约维修;广汽三菱维修|汽车销售","汽车销售;雷诺特约销售;雷诺销售|汽车维修","科教文化服务;展览馆;展览馆|购物服务","科教文化服务;科研机构;科研机构|政府机构及社会团体","购物服务;专卖店;摄影器材店|生活服务","购物服务;商场;购物中心|购物服务;商场;普通商场","购物服务;购物相关场所;购物相关场所|政府机构及社会团体","风景名胜;风景名胜相关;旅游景点|生活服务","餐饮服务;中餐厅;浙江菜|餐饮服务","餐饮服务;中餐厅;特色/地方风味餐厅|生活服务","餐饮服务;冷饮店;冷饮店|餐饮服务;中餐厅;中餐厅","地名地址信息;普通地名;村庄级地名|体育休闲服务","摩托车服务;摩托车销售;摩托车销售|公司企业","政府机构及社会团体;交通车辆管理;车辆管理机构|汽车服务","政府机构及社会团体;交通车辆管理;验车场|汽车服务","政府机构及社会团体;社会团体;社会团体相关|汽车服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|地名地址信息","购物服务;购物相关场所;购物相关场所|公司企业;公司企业;公司企业","餐饮服务;中餐厅;综合酒楼|住宿服务;宾馆酒店;宾馆酒店","餐饮服务;茶艺馆;茶艺馆|住宿服务","公司企业;公司;公司|餐饮服务;中餐厅;中餐厅","公司企业;公司;商业贸易|购物服务;家居建材市场;建材五金市场","公司企业;公司企业;公司企业|体育休闲服务","公司企业;公司企业;公司企业|科教文化服务","商务住宅;楼宇;商务写字楼|风景名胜","生活服务;事务所;会计师事务所|科教文化服务","科教文化服务;培训机构;培训机构|购物服务;购物相关场所;购物相关场所","购物服务;综合市场;农副产品市场|商务住宅","餐饮服务;外国餐厅;意式菜品餐厅|餐饮服务","体育休闲服务;娱乐场所;KTV|科教文化服务","体育休闲服务;度假疗养场所;疗养院|生活服务;生活服务场所;生活服务场所","公司企业;公司;建筑公司|政府机构及社会团体","医疗保健服务;专科医院;耳鼻喉医院|医疗保健服务","地名地址信息;交通地名;道路名|地名地址信息","室内设施;室内设施;室内设施|生活服务","摩托车服务;摩托车维修;摩托车维修|生活服务;维修站点;维修站点","政府机构及社会团体;政府机关;外地政府办|政府机构及社会团体","生活服务;信息咨询中心;信息咨询中心|公司企业","生活服务;旅行社;旅行社|购物服务","购物服务;家居建材市场;家具建材综合市场|公司企业","金融保险服务;自动提款机;中国邮政储蓄银行ATM|金融保险服务","金融保险服务;自动提款机;自动提款机|金融保险服务","餐饮服务;中餐厅;火锅店|住宿服务","餐饮服务;茶艺馆;茶艺馆|购物服务;购物相关场所;购物相关场所","住宿服务;宾馆酒店;五星级宾馆|住宿服务","体育休闲服务;休闲场所;水上活动中心|风景名胜","体育休闲服务;休闲场所;采摘园|餐饮服务","体育休闲服务;娱乐场所;娱乐场所|住宿服务","体育休闲服务;度假疗养场所;疗养院|公司企业","公司企业;公司;公司|生活服务;中介机构;中介机构","公司企业;公司企业;公司企业|购物服务;购物相关场所;购物相关场所","商务住宅;住宅区;住宅小区|生活服务;生活服务场所;生活服务场所","地名地址信息;自然地名;峡谷","政府机构及社会团体;政府机关;乡镇级政府及事业单位|商务住宅","汽车服务;洗车场;洗车场|汽车服务;汽车养护/装饰;汽车养护","汽车销售;东风特约销售;东风销售|汽车维修;东风特约维修;东风维修","生活服务;丧葬设施;丧葬设施|购物服务;购物相关场所;购物相关场所","生活服务;信息咨询中心;信息咨询中心|生活服务","科教文化服务;培训机构;培训机构|政府机构及社会团体","购物服务;专卖店;眼镜店|购物服务","购物服务;专卖店;自行车专卖店|摩托车服务;摩托车维修;摩托车维修","购物服务;家居建材市场;家居建材市场|餐饮服务","餐饮服务;中餐厅;火锅店|体育休闲服务","体育休闲服务;休闲场所;游乐场|餐饮服务","体育休闲服务;休闲场所;采摘园|购物服务","商务住宅;住宅区;住宅小区|商务住宅;楼宇;商住两用楼宇","汽车服务;汽车养护/装饰;汽车养护|餐饮服务","汽车服务;汽车救援;汽车救援|汽车服务","生活服务;丧葬设施;陵园|生活服务","生活服务;事务所;事务所|公司企业","生活服务;婴儿服务场所;婴儿游泳馆|生活服务","生活服务;生活服务场所;生活服务场所|风景名胜","购物服务;专卖店;自行车专卖店|汽车销售;汽车销售;汽车销售","购物服务;商场;普通商场|餐饮服务","金融保险服务;财务公司;财务公司|公司企业","风景名胜;公园广场;城市广场|科教文化服务","风景名胜;风景名胜;国家级景点|风景名胜","餐饮服务;中餐厅;中餐厅|地名地址信息","餐饮服务;中餐厅;中餐厅|汽车服务","餐饮服务;中餐厅;山东菜(鲁菜)|餐饮服务","餐饮服务;冷饮店;冷饮店|餐饮服务;快餐厅;快餐厅","体育休闲服务;娱乐场所;娱乐场所|科教文化服务","公司企业;公司;矿产公司|购物服务","商务住宅;楼宇;商住两用楼宇|住宿服务","政府机构及社会团体;政府机关;区县级政府及事业单位|商务住宅","生活服务;生活服务场所;生活服务场所|交通设施服务","科教文化服务;传媒机构;出版社|公司企业","科教文化服务;学校;幼儿园|公司企业","购物服务;专卖店;珠宝首饰工艺品|体育休闲服务","购物服务;便民商店/便利店;便民商店/便利店|购物服务;专卖店;专营店","金融保险服务;自动提款机;中国银行ATM|金融保险服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|科教文化服务","公司企业;公司;公司|风景名胜","公司企业;农林牧渔基地;其它农林牧渔基地|餐饮服务","医疗保健服务;急救中心;急救中心|医疗保健服务","商务住宅;楼宇;楼宇相关|餐饮服务","摩托车服务;摩托车销售;摩托车销售|摩托车服务;摩托车维修;摩托车维修","汽车服务;汽车养护/装饰;汽车养护|汽车销售;汽车销售;汽车销售","汽车维修;汽车综合维修;汽车综合维修|汽车服务;汽车养护/装饰;汽车养护","汽车销售;捷豹特约销售;捷豹销售|汽车维修","生活服务;售票处;公园景点售票处|生活服务","生活服务;邮局;邮局|购物服务","购物服务;专卖店;土特产专卖店|公司企业","购物服务;家居建材市场;家具城|公司企业;工厂;工厂","购物服务;特色商业街;特色商业街|商务住宅","购物服务;综合市场;农副产品市场|购物服务;专卖店;专营店","购物服务;购物相关场所;购物相关场所|风景名胜","金融保险服务;银行;农村商业银行|政府机构及社会团体","餐饮服务;中餐厅;特色/地方风味餐厅|住宿服务","交通设施服务;公交车站;普通公交站","公司企业;公司企业;公司企业|商务住宅","公司企业;公司企业;公司企业|政府机构及社会团体","公司企业;公司企业;公司企业|餐饮服务","商务住宅;商务住宅相关;商务住宅相关|餐饮服务","地名地址信息;交通地名;立交桥|地名地址信息;交通地名;桥","政府机构及社会团体;政府及社会团体相关;政府及社会团体相关|公司企业","生活服务;事务所;律师事务所|商务住宅","科教文化服务;学校;高等院校|体育休闲服务","购物服务;专卖店;专营店|生活服务;丧葬设施;丧葬设施","购物服务;体育用品店;户外用品|体育休闲服务","购物服务;家居建材市场;家居建材市场|商务住宅","购物服务;家居建材市场;布艺市场|汽车服务","购物服务;家居建材市场;建材五金市场|体育休闲服务","金融保险服务;保险公司;中国太平洋保险|公司企业","金融保险服务;银行相关;银行相关|政府机构及社会团体","风景名胜;风景名胜;寺庙道观|风景名胜","体育休闲服务;影剧院;剧场|体育休闲服务","公共设施;公共厕所;公共厕所|生活服务","公司企业;知名企业;知名企业|公司企业","商务住宅;住宅区;住宅小区|餐饮服务;中餐厅;中餐厅","地名地址信息;交通地名;桥|地名地址信息;交通地名;立交桥","汽车维修;货车维修;货车维修|生活服务","汽车销售;一汽解放销售;一汽解放销售|汽车维修","科教文化服务;学校;小学|地名地址信息","购物服务;便民商店/便利店;便民商店/便利店|体育休闲服务","购物服务;便民商店/便利店;便民商店/便利店|科教文化服务","购物服务;特色商业街;特色商业街|风景名胜","金融保险服务;自动提款机;东亚银行ATM","风景名胜;风景名胜;纪念馆|风景名胜","餐饮服务;中餐厅;清真菜馆|体育休闲服务","公司企业;公司;广告装饰|购物服务;家居建材市场;家居建材市场","公司企业;公司;机械电子|科教文化服务","医疗保健服务;专科医院;传染病医院|医疗保健服务","商务住宅;产业园区;产业园区|政府机构及社会团体","商务住宅;住宅区;别墅|住宿服务","地名地址信息;普通地名;街道级地名|地名地址信息","摩托车服务;摩托车销售;摩托车销售|生活服务","汽车服务;汽车救援;汽车救援|汽车维修","生活服务;旅行社;旅行社|生活服务","科教文化服务;图书馆;图书馆|科教文化服务","科教文化服务;学校;高等院校|政府机构及社会团体","购物服务;专卖店;专营店|汽车服务;汽车配件销售;汽车配件销售","购物服务;专卖店;儿童用品店|生活服务;生活服务场所;生活服务场所","购物服务;专卖店;自行车专卖店|体育休闲服务","购物服务;服装鞋帽皮具店;品牌鞋店|公司企业","金融保险服务;保险公司;中国平安保险公司|公司企业","风景名胜;公园广场;公园|商务住宅","餐饮服务;中餐厅;四川菜(川菜)|生活服务","公司企业;公司;公司|科教文化服务;科研机构;科研机构","公司企业;农林牧渔基地;其它农林牧渔基地|商务住宅","摩托车服务;摩托车维修;摩托车维修|汽车服务","汽车服务;加油站;加油站|公司企业","汽车销售;克莱斯勒特约销售;道奇销售|汽车维修","生活服务;丧葬设施;丧葬设施|公司企业","生活服务;物流速递;物流速递|政府机构及社会团体","生活服务;生活服务场所;生活服务场所|室内设施","生活服务;生活服务场所;生活服务场所|摩托车服务","生活服务;维修站点;维修站点|购物服务;购物相关场所;购物相关场所","科教文化服务;传媒机构;传媒机构|生活服务;生活服务场所;生活服务场所","购物服务;便民商店/便利店;便民商店/便利店|公司企业;公司;公司","购物服务;商场;普通商场|购物服务;商场;购物中心","购物服务;服装鞋帽皮具店;品牌皮具店|购物服务","购物服务;特色商业街;步行街|购物服务","购物服务;花鸟鱼虫市场;花卉市场|体育休闲服务","购物服务;花鸟鱼虫市场;花卉市场|风景名胜","金融保险服务;保险公司;中国人寿保险公司|金融保险服务","金融保险服务;银行;中国人民银行|金融保险服务","风景名胜;风景名胜;红色景区|科教文化服务","风景名胜;风景名胜;风景名胜|生活服务","风景名胜;风景名胜相关;旅游景点|商务住宅","餐饮服务;中餐厅;中餐厅|餐饮服务;休闲餐饮场所;休闲餐饮场所","餐饮服务;中餐厅;中餐厅|餐饮服务;冷饮店;冷饮店","住宿服务;宾馆酒店;宾馆酒店|科教文化服务","体育休闲服务;休闲场所;游乐场|生活服务","体育休闲服务;娱乐场所;KTV|公司企业","体育休闲服务;娱乐场所;网吧|住宿服务","体育休闲服务;度假疗养场所;度假村|生活服务","体育休闲服务;运动场馆;台球厅|餐饮服务","体育休闲服务;运动场馆;游泳馆|科教文化服务","商务住宅;住宅区;住宅小区|购物服务;购物相关场所;购物相关场所","商务住宅;楼宇;商住两用楼宇|商务住宅;楼宇;商务写字楼","商务住宅;楼宇;楼宇相关|商务住宅","地名地址信息;普通地名;村庄级地名|公司企业","政府机构及社会团体;交通车辆管理;货车相关检查站","政府机构及社会团体;公检法机构;公检法机关|政府机构及社会团体","汽车服务;汽车养护/装饰;汽车养护|汽车维修;汽车综合维修;汽车综合维修","生活服务;事务所;律师事务所|生活服务","购物服务;专卖店;宠物用品店|公司企业","购物服务;专卖店;烟酒专卖店|餐饮服务;餐饮相关场所;餐饮相关","购物服务;专卖店;自行车专卖店|汽车服务;汽车服务相关;汽车服务相关","购物服务;家居建材市场;家具城|科教文化服务","购物服务;家居建材市场;布艺市场|商务住宅","购物服务;家居建材市场;建材五金市场|公司企业;公司;机械电子","购物服务;家电电子卖场;苏宁|生活服务","购物服务;花鸟鱼虫市场;花卉市场|科教文化服务","风景名胜;风景名胜;寺庙道观|地名地址信息","餐饮服务;糕饼店;糕饼店|餐饮服务;中餐厅;中餐厅","餐饮服务;餐饮相关场所;餐饮相关|商务住宅","交通设施服务;停车场;停车场入口|交通设施服务","体育休闲服务;休闲场所;采摘园|风景名胜","体育休闲服务;运动场馆;健身中心|公司企业","商务住宅;楼宇;商务写字楼|公司企业;公司;公司","地名地址信息;普通地名;省级地名","地名地址信息;自然地名;海湾海峡|地名地址信息","地名地址信息;自然地名;盆地","政府机构及社会团体;交通车辆管理;验车场|生活服务","政府机构及社会团体;政府及社会团体相关;政府及社会团体相关|购物服务","汽车服务;加气站;加气站|汽车服务","汽车销售;中国重汽销售;中国重汽销售|汽车服务","汽车销售;法拉利特约销售;玛莎拉蒂销售|汽车维修","生活服务;事务所;专利事务所|公司企业","生活服务;邮局;邮局|生活服务","科教文化服务;传媒机构;报社|生活服务","购物服务;专卖店;专营店|生活服务;美容美发店;美容美发店","购物服务;专卖店;儿童用品店|商务住宅","购物服务;体育用品店;户外用品|生活服务","购物服务;商场;普通商场|购物服务;超级市场;超市","购物服务;家居建材市场;家居建材市场|公司企业;公司;公司","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|汽车销售","购物服务;购物相关场所;购物相关场所|住宿服务","餐饮服务;中餐厅;上海菜|餐饮服务","餐饮服务;外国餐厅;泰国/越南菜品餐厅|餐饮服务","交通设施服务;上下客区;网约车","体育休闲服务;休闲场所;垂钓园|购物服务","体育休闲服务;运动场馆;篮球场馆|科教文化服务","公司企业;公司;商业贸易|购物服务;专卖店;专营店","商务住宅;住宅区;住宅小区|地名地址信息;普通地名;村庄级地名","摩托车服务;摩托车服务相关;摩托车服务相关|生活服务","摩托车服务;摩托车销售;摩托车销售|汽车服务","政府机构及社会团体;社会团体;行业协会|购物服务","汽车服务;二手车交易;二手车交易|公司企业","汽车服务;洗车场;洗车场|购物服务","生活服务;丧葬设施;丧葬设施|风景名胜","生活服务;物流速递;物流速递|汽车维修","生活服务;电讯营业厅;中国铁通营业厅|公司企业","生活服务;美容美发店;美容美发店|餐饮服务;餐饮相关场所;餐饮相关","科教文化服务;科研机构;科研机构|购物服务","购物服务;专卖店;烟酒专卖店|商务住宅","购物服务;体育用品店;户外用品|公司企业","购物服务;超级市场;超市|生活服务;生活服务场所;生活服务场所","风景名胜;公园广场;水族馆|体育休闲服务","餐饮服务;中餐厅;中餐厅|公司企业;公司;公司","体育休闲服务;运动场馆;台球厅|生活服务","体育休闲服务;运动场馆;运动场所|生活服务","公司企业;工厂;工厂|购物服务;购物相关场所;购物相关场所","摩托车服务;摩托车维修;摩托车维修|摩托车服务;摩托车销售;摩托车销售","政府机构及社会团体;社会团体;社会团体相关|商务住宅","汽车服务;汽车俱乐部;汽车俱乐部|汽车维修","汽车维修;克莱斯勒特约维修;吉普维修|汽车销售","汽车维修;汽车维修;汽车维修|公司企业","汽车维修;海马汽车维修;海马汽车维修|汽车销售","汽车维修;福特特约维修;马自达维修|汽车销售","汽车销售;大众特约销售;上海大众销售|汽车销售","汽车销售;日产特约销售;东风日产销售|汽车销售","汽车销售;本田特约销售;本田讴歌销售|汽车维修","生活服务;彩票彩券销售点;彩票彩券销售点|政府机构及社会团体","生活服务;电讯营业厅;中国移动营业厅|公司企业;公司;电信公司","科教文化服务;科教文化场所;科教文化场所|体育休闲服务","购物服务;专卖店;烟酒专卖店|地名地址信息","购物服务;专卖店;烟酒专卖店|汽车服务","购物服务;家电电子卖场;数码电子|公司企业;公司;网络科技","购物服务;综合市场;果品市场|政府机构及社会团体","购物服务;花鸟鱼虫市场;宠物市场|公司企业","餐饮服务;中餐厅;中餐厅|住宿服务;住宿服务相关;住宿服务相关","餐饮服务;中餐厅;清真菜馆|住宿服务","餐饮服务;糕饼店;糕饼店|餐饮服务;甜品店;甜品店","交通设施服务;停车场;公共停车场|生活服务","体育休闲服务;体育休闲服务场所;体育休闲服务场所|商务住宅","体育休闲服务;运动场馆;运动场所|体育休闲服务","公司企业;公司;广告装饰|购物服务;购物相关场所;购物相关场所","公司企业;公司;建筑公司|金融保险服务","公司企业;公司;电信公司|政府机构及社会团体","公司企业;公司;电信公司|购物服务;家电电子卖场;手机销售","商务住宅;产业园区;产业园区|风景名胜","商务住宅;住宅区;住宅区|公司企业","政府机构及社会团体;社会团体;行业协会|体育休闲服务","汽车维修;丰田特约维修;一汽丰田维修|汽车销售","汽车维修;奥迪特约维修;一汽-大众奥迪维修|汽车销售","汽车维修;斯巴鲁特约维修;斯巴鲁维修|汽车销售","汽车销售;东风货车销售;东风货车销售|汽车维修","汽车销售;大众特约销售;大众销售|汽车维修","生活服务;洗浴推拿场所;洗浴推拿场所|科教文化服务","生活服务;洗浴推拿场所;洗浴推拿场所|风景名胜","生活服务;物流速递;物流速递|交通设施服务","生活服务;生活服务场所;生活服务场所|餐饮服务;餐饮相关场所;餐饮相关","生活服务;维修站点;维修站点|汽车销售","科教文化服务;学校;学校|生活服务","科教文化服务;文艺团体;文艺团体|生活服务","购物服务;体育用品店;体育用品店|生活服务","购物服务;商场;普通商场|体育休闲服务","购物服务;家电电子卖场;家电电子卖场|公司企业;公司;公司","购物服务;综合市场;水产海鲜市场|餐饮服务;餐饮相关场所;餐饮相关","购物服务;超级市场;超市|汽车服务","风景名胜;风景名胜;风景名胜|餐饮服务","餐饮服务;茶艺馆;茶艺馆|科教文化服务","交通设施服务;出租车;出租车","体育休闲服务;休闲场所;水上活动中心|体育休闲服务","体育休闲服务;娱乐场所;棋牌室|餐饮服务;茶艺馆;茶艺馆","体育休闲服务;运动场馆;健身中心|餐饮服务","公司企业;公司;广告装饰|商务住宅","商务住宅;商务住宅相关;商务住宅相关|风景名胜","商务住宅;楼宇;楼宇相关|购物服务","地名地址信息;交通地名;道路名|生活服务","政府机构及社会团体;交通车辆管理;交通车辆管理相关|生活服务","政府机构及社会团体;政府及社会团体相关;政府及社会团体相关|科教文化服务","生活服务;信息咨询中心;服务中心|生活服务","生活服务;电力营业厅;电力营业厅|生活服务","生活服务;美容美发店;美容美发店|购物服务;专卖店;专营店","科教文化服务;学校;成人教育|政府机构及社会团体","科教文化服务;学校;职业技术学校|科教文化服务;培训机构;培训机构","科教文化服务;科教文化场所;科教文化场所|商务住宅","购物服务;专卖店;古玩字画店|商务住宅","购物服务;商场;购物中心|生活服务","餐饮服务;中餐厅;清真菜馆|公司企业","餐饮服务;中餐厅;清真菜馆|商务住宅","餐饮服务;冷饮店;冷饮店|餐饮服务;糕饼店;糕饼店","餐饮服务;糕饼店;糕饼店|商务住宅","交通设施服务;港口码头;港口码头|风景名胜","体育休闲服务;休闲场所;休闲场所|住宿服务;住宿服务相关;住宿服务相关","公司企业;公司;机械电子|购物服务;家居建材市场;建材五金市场","商务住宅;楼宇;楼宇相关|住宿服务","地名地址信息;交通地名;桥|风景名胜","政府机构及社会团体;交通车辆管理;车辆管理机构|生活服务","政府机构及社会团体;公检法机构;检察院|政府机构及社会团体","政府机构及社会团体;工商税务机构;工商税务机构|政府机构及社会团体","政府机构及社会团体;社会团体;消费者协会|政府机构及社会团体","汽车服务;汽车服务相关;汽车服务相关|摩托车服务","汽车维修;长城汽车维修;魏派汽车维修|汽车销售","汽车销售;货车销售;货车销售|公司企业","汽车销售;货车销售;货车销售|购物服务","汽车销售;通用特约销售;别克销售|汽车维修;通用特约维修;别克维修","生活服务;物流速递;物流速递|购物服务;购物相关场所;购物相关场所","科教文化服务;文化宫;文化宫|生活服务","购物服务;专卖店;专营店|住宿服务","购物服务;专卖店;专营店|购物服务;便民商店/便利店;便民商店/便利店","购物服务;专卖店;儿童用品店|生活服务;美容美发店;美容美发店","购物服务;专卖店;烟酒专卖店|科教文化服务","购物服务;便民商店/便利店;便民商店/便利店|风景名胜","购物服务;商场;普通商场|购物服务;便民商店/便利店;便民商店/便利店","购物服务;家居建材市场;家具建材综合市场|生活服务","购物服务;家电电子卖场;数码电子|商务住宅","购物服务;文化用品店;文化用品店|生活服务;生活服务场所;生活服务场所","购物服务;综合市场;综合市场|餐饮服务","购物服务;超级市场;上海华联|购物服务","金融保险服务;保险公司;保险公司|生活服务","金融保险服务;银行;农村商业银行|金融保险服务;银行相关;银行相关","金融保险服务;银行相关;银行相关|金融保险服务","风景名胜;公园广场;植物园|风景名胜","风景名胜;风景名胜;寺庙道观|购物服务","风景名胜;风景名胜;风景名胜|政府机构及社会团体","风景名胜;风景名胜相关;旅游景点|科教文化服务","餐饮服务;中餐厅;浙江菜|住宿服务","餐饮服务;冷饮店;冷饮店|公司企业","餐饮服务;茶艺馆;茶艺馆|公司企业","交通设施服务;机场相关;直升机场","住宿服务;宾馆酒店;宾馆酒店|餐饮服务;餐饮相关场所;餐饮相关","体育休闲服务;娱乐场所;KTV|购物服务;购物相关场所;购物相关场所","体育休闲服务;娱乐场所;棋牌室|商务住宅","体育休闲服务;度假疗养场所;疗养院|住宿服务","公司企业;公司;公司|公司企业;农林牧渔基地;其它农林牧渔基地","公司企业;公司;公司|餐饮服务;餐饮相关场所;餐饮相关","公司企业;公司;冶金化工|科教文化服务","公司企业;公司;网络科技|商务住宅","公司企业;工厂;工厂|汽车维修","商务住宅;楼宇;商住两用楼宇|生活服务","政府机构及社会团体;工商税务机构;工商税务机构|生活服务","汽车服务;加气站;加气站|公司企业","汽车服务;汽车租赁;汽车租赁|购物服务","汽车维修;奥迪特约维修;上汽-大众奥迪维修|汽车销售","汽车销售;丰田特约销售;丰田销售|汽车维修","生活服务;洗浴推拿场所;洗浴推拿场所|汽车服务","科教文化服务;传媒机构;电视台|公司企业","科教文化服务;学校;小学|公司企业","科教文化服务;科教文化场所;科教文化场所|政府机构及社会团体","购物服务;专卖店;书店|体育休闲服务","购物服务;专卖店;珠宝首饰工艺品|公司企业;公司;公司","购物服务;专卖店;音像店|生活服务","购物服务;商场;免税品店|生活服务","购物服务;商场;商场|商务住宅","购物服务;商场;购物中心|公司企业","购物服务;家居建材市场;家具城|生活服务;生活服务场所;生活服务场所","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|风景名胜","购物服务;超级市场;超市|住宿服务","风景名胜;风景名胜;寺庙道观|生活服务","餐饮服务;中餐厅;海鲜酒楼|生活服务","交通设施服务;停车场;专用停车场|交通设施服务;停车场;路边停车场","体育休闲服务;休闲场所;露营地|住宿服务","体育休闲服务;运动场馆;综合体育馆|购物服务","公司企业;公司;公司|汽车服务;汽车配件销售;汽车配件销售","公司企业;公司;机械电子|汽车服务;汽车服务相关;汽车服务相关","公司企业;农林牧渔基地;花卉苗圃基地|购物服务","公司企业;工厂;工厂|购物服务;专卖店;专营店","商务住宅;楼宇;工业大厦建筑物|商务住宅","地名地址信息;普通地名;村庄级地名|科教文化服务","摩托车服务;摩托车销售;摩托车销售|购物服务;购物相关场所;购物相关场所","政府机构及社会团体;公检法机构;社会治安机构|购物服务","政府机构及社会团体;政府机关;区县级政府及事业单位|体育休闲服务","汽车服务;汽车配件销售;汽车配件销售|购物服务;专卖店;专营店","汽车销售;奇瑞特约销售;奇瑞销售|汽车维修;奇瑞特约维修;奇瑞维修","汽车销售;汽车销售;汽车销售|购物服务;购物相关场所;购物相关场所","生活服务;人才市场;人才市场|购物服务","生活服务;物流速递;物流仓储场地|公司企业;公司;公司","生活服务;维修站点;维修站点|餐饮服务","科教文化服务;博物馆;博物馆|科教文化服务","科教文化服务;培训机构;培训机构|风景名胜","科教文化服务;学校;幼儿园|科教文化服务;培训机构;培训机构","购物服务;专卖店;古玩字画店|生活服务;生活服务场所;生活服务场所","购物服务;专卖店;古玩字画店|科教文化服务;培训机构;培训机构","购物服务;专卖店;珠宝首饰工艺品|风景名胜","购物服务;专卖店;礼品饰品店|体育休闲服务","购物服务;个人用品/化妆品店;莎莎|生活服务","购物服务;家居建材市场;建材五金市场|摩托车服务","购物服务;家居建材市场;灯具瓷器市场|公司企业;公司;公司","购物服务;家电电子卖场;手机销售|购物服务;家电电子卖场;数码电子","购物服务;家电电子卖场;手机销售|餐饮服务","购物服务;家电电子卖场;数码电子|餐饮服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|公司企业;公司企业;公司企业","购物服务;综合市场;农副产品市场|体育休闲服务","购物服务;花鸟鱼虫市场;花卉市场|政府机构及社会团体","餐饮服务;中餐厅;江苏菜|餐饮服务","餐饮服务;外国餐厅;西餐厅(综合风味)|生活服务","住宿服务;宾馆酒店;三星级宾馆|生活服务","住宿服务;旅馆招待所;旅馆招待所|公司企业","体育休闲服务;娱乐场所;酒吧|餐饮服务;餐饮相关场所;餐饮相关","公司企业;公司;公司|购物服务;便民商店/便利店;便民商店/便利店","公司企业;公司;冶金化工|汽车服务","公司企业;公司;机械电子|购物服务;购物相关场所;购物相关场所","公司企业;公司;电信公司|公司企业","商务住宅;商务住宅相关;商务住宅相关|公司企业","商务住宅;楼宇;楼宇相关|风景名胜","汽车服务;充电站;充电站|生活服务","汽车服务;汽车养护/装饰;汽车养护|购物服务;购物相关场所;购物相关场所","汽车维修;吉利特约维修;沃尔沃汽车维修|汽车销售","汽车销售;东风货车销售;东风货车销售|汽车销售","汽车销售;捷豹特约销售;捷豹销售|汽车销售","生活服务;婴儿服务场所;婴儿游泳馆|购物服务;专卖店;儿童用品店","生活服务;洗浴推拿场所;洗浴推拿场所|餐饮服务;餐饮相关场所;餐饮相关","生活服务;电讯营业厅;电讯营业厅|生活服务","科教文化服务;传媒机构;电台|科教文化服务","科教文化服务;学校;职业技术学校|公司企业","科教文化服务;展览馆;展览馆|生活服务","科教文化服务;美术馆;美术馆|生活服务","购物服务;专卖店;专营店|公司企业;工厂;工厂","购物服务;专卖店;儿童用品店|公司企业;公司;公司","购物服务;专卖店;儿童用品店|餐饮服务;餐饮相关场所;餐饮相关","购物服务;专卖店;宠物用品店|体育休闲服务","购物服务;个人用品/化妆品店;其它个人用品店|汽车服务","购物服务;体育用品店;体育用品店|科教文化服务","购物服务;体育用品店;耐克专卖店|购物服务","购物服务;便民商店/便利店;便民商店/便利店|摩托车服务","购物服务;商场;商场|生活服务","购物服务;家居建材市场;厨卫市场|生活服务;生活服务场所;生活服务场所","购物服务;家居建材市场;建材五金市场|风景名胜","购物服务;综合市场;果品市场|餐饮服务;冷饮店;冷饮店","购物服务;综合市场;蔬菜市场|政府机构及社会团体","购物服务;花鸟鱼虫市场;花卉市场|住宿服务","金融保险服务;自动提款机;农村商业银行ATM|生活服务","金融保险服务;银行;中国建设银行|生活服务","风景名胜;风景名胜;风景名胜|公司企业","餐饮服务;中餐厅;中餐厅|商务住宅;商务住宅相关;商务住宅相关","餐饮服务;中餐厅;台湾菜|餐饮服务","餐饮服务;中餐厅;湖北菜(鄂菜)|餐饮服务","餐饮服务;休闲餐饮场所;休闲餐饮场所|餐饮服务;中餐厅;中餐厅","餐饮服务;外国餐厅;韩国料理|生活服务","交通设施服务;港口码头;出港","交通设施服务;索道站;索道站","住宿服务;宾馆酒店;四星级宾馆|商务住宅","体育休闲服务;运动场馆;溜冰场|购物服务","体育休闲服务;运动场馆;综合体育馆|科教文化服务","公司企业;公司;广告装饰|科教文化服务;传媒机构;传媒机构","公司企业;公司;网络科技|购物服务;家电电子卖场;数码电子","公司企业;公司;网络科技|金融保险服务","公司企业;公司;网络科技|餐饮服务","公司企业;农林牧渔基地;其它农林牧渔基地|公司企业;公司;公司","医疗保健服务;诊所;诊所|医疗保健服务;专科医院;专科医院","商务住宅;住宅区;住宅区|体育休闲服务","政府机构及社会团体;公检法机构;公检法机关|生活服务","汽车维修;汽车维修;汽车维修|生活服务;生活服务场所;生活服务场所","汽车维修;通用特约维修;凯迪拉克维修|汽车销售","汽车销售;东风特约销售;东风销售|购物服务","汽车销售;奥迪特约销售;上汽-大众奥迪销售|汽车维修","汽车销售;标致雪铁龙特约销售;东风雪铁龙销售|汽车销售","汽车销售;江淮货车销售;江淮货车销售|汽车维修","汽车销售;观致销售;观致销售|汽车维修","生活服务;丧葬设施;陵园|风景名胜;风景名胜;风景名胜","生活服务;中介机构;中介机构|科教文化服务","生活服务;售票处;售票处|生活服务","生活服务;美容美发店;美容美发店|住宿服务","科教文化服务;传媒机构;传媒机构|公司企业;公司;公司","科教文化服务;传媒机构;电视台|政府机构及社会团体","科教文化服务;学校;中学|公司企业","购物服务;专卖店;烟酒专卖店|风景名胜","购物服务;家电电子卖场;手机销售|生活服务;电讯营业厅;电讯营业厅","购物服务;服装鞋帽皮具店;品牌皮具店|生活服务","购物服务;综合市场;旧货市场|汽车服务","购物服务;超级市场;屈臣氏|购物服务","金融保险服务;银行;中国工商银行|生活服务","餐饮服务;中餐厅;特色/地方风味餐厅|地名地址信息","餐饮服务;茶艺馆;茶艺馆|风景名胜","住宿服务;宾馆酒店;四星级宾馆|体育休闲服务","体育休闲服务;休闲场所;水上活动中心|生活服务","体育休闲服务;运动场馆;羽毛球场|体育休闲服务","公司企业;公司;公司|购物服务;家居建材市场;家居建材市场","公司企业;公司;商业贸易|商务住宅","公司企业;公司企业;公司企业|汽车维修","公司企业;农林牧渔基地;其它农林牧渔基地|科教文化服务","医疗保健服务;综合医院;综合医院|医疗保健服务;诊所;诊所","商务住宅;住宅区;宿舍|政府机构及社会团体","商务住宅;楼宇;商务写字楼|体育休闲服务","政府机构及社会团体;公检法机构;消防机关|公司企业","政府机构及社会团体;政府机关;国家级机关及事业单位|政府机构及社会团体","汽车服务;汽车配件销售;汽车配件销售|公司企业;公司;公司","汽车销售;宝马特约销售;宝马销售|汽车维修;宝马特约维修;宝马维修","科教文化服务;学校;中学|政府机构及社会团体","购物服务;专卖店;古玩字画店|科教文化服务;科教文化场所;科教文化场所","购物服务;家居建材市场;建材五金市场|金融保险服务","购物服务;家电电子卖场;手机销售|政府机构及社会团体","购物服务;家电电子卖场;苏宁|购物服务","购物服务;综合市场;农副产品市场|汽车服务","购物服务;综合市场;果品市场|商务住宅","购物服务;花鸟鱼虫市场;宠物市场|生活服务","金融保险服务;保险公司;保险公司|购物服务","风景名胜;风景名胜;风景名胜|商务住宅","餐饮服务;中餐厅;中式素菜馆|餐饮服务","餐饮服务;中餐厅;四川菜(川菜)|住宿服务","餐饮服务;中餐厅;广东菜(粤菜)|体育休闲服务","餐饮服务;中餐厅;湖南菜(湘菜)|住宿服务","餐饮服务;中餐厅;特色/地方风味餐厅|餐饮服务;中餐厅;海鲜酒楼","餐饮服务;中餐厅;综合酒楼|餐饮服务;茶艺馆;茶艺馆","餐饮服务;外国餐厅;外国餐厅|餐饮服务","餐饮服务;外国餐厅;西餐厅(综合风味)|餐饮服务;外国餐厅;牛扒店(扒房)","住宿服务;宾馆酒店;三星级宾馆|商务住宅","体育休闲服务;休闲场所;休闲场所|餐饮服务;餐饮相关场所;餐饮相关","体育休闲服务;娱乐场所;娱乐场所|公司企业","体育休闲服务;娱乐场所;娱乐场所|商务住宅","体育休闲服务;娱乐场所;棋牌室|住宿服务","体育休闲服务;运动场馆;游泳馆|购物服务","公司企业;公司;公司|商务住宅;产业园区;产业园区","公司企业;公司;公司|科教文化服务;传媒机构;传媒机构","公司企业;公司;公司|购物服务;体育用品店;体育用品店","商务住宅;住宅区;宿舍|生活服务","商务住宅;楼宇;商务写字楼|商务住宅;产业园区;产业园区","政府机构及社会团体;交通车辆管理;交通管理机构|汽车服务","政府机构及社会团体;交通车辆管理;验车场|摩托车服务","政府机构及社会团体;政府机关;乡镇级政府及事业单位|金融保险服务","政府机构及社会团体;社会团体;慈善机构|体育休闲服务","汽车服务;汽车服务相关;汽车服务相关|餐饮服务","汽车服务;洗车场;洗车场|汽车销售","汽车维修;宝马特约维修;宝马维修|汽车销售","汽车维修;雷诺特约维修;雷诺维修|汽车销售","生活服务;洗浴推拿场所;洗浴推拿场所|住宿服务;宾馆酒店;宾馆酒店","生活服务;生活服务场所;生活服务场所|汽车维修;汽车维修;汽车维修","生活服务;电讯营业厅;电讯营业厅|公司企业","生活服务;邮局;邮局|政府机构及社会团体","科教文化服务;会展中心;会展中心|科教文化服务","科教文化服务;学校;小学|购物服务","购物服务;体育用品店;体育用品店|公司企业;公司;公司","购物服务;商场;免税品店|公司企业","购物服务;家电电子卖场;数码电子|生活服务;摄影冲印店;摄影冲印","购物服务;家电电子卖场;数码电子|金融保险服务","购物服务;特色商业街;特色商业街|公司企业","购物服务;综合市场;水产海鲜市场|公司企业;公司;公司","购物服务;超级市场;超市|政府机构及社会团体","金融保险服务;自动提款机;自动提款机|生活服务","金融保险服务;金融保险服务机构;金融保险机构|商务住宅","金融保险服务;银行;中国民生银行|金融保险服务","餐饮服务;中餐厅;四川菜(川菜)|体育休闲服务","餐饮服务;中餐厅;江苏菜|住宿服务","餐饮服务;冷饮店;冷饮店|餐饮服务;甜品店;甜品店","餐饮服务;咖啡厅;咖啡厅|公司企业","餐饮服务;快餐厅;快餐厅|住宿服务","餐饮服务;甜品店;甜品店|餐饮服务;糕饼店;糕饼店","交通设施服务;机场相关;机场货运处","住宿服务;住宿服务相关;住宿服务相关|风景名胜","住宿服务;宾馆酒店;三星级宾馆|体育休闲服务","公司企业;公司;医药公司|科教文化服务","商务住宅;商务住宅相关;商务住宅相关|科教文化服务","政府机构及社会团体;交通车辆管理;车辆通行证办理处","政府机构及社会团体;公检法机构;法院|生活服务","政府机构及社会团体;工商税务机构;国税机关|政府机构及社会团体","政府机构及社会团体;工商税务机构;地税机关|政府机构及社会团体","汽车销售;东风特约销售;东风销售|汽车销售","汽车销售;中国重汽销售;中国重汽销售|汽车维修","汽车销售;大众特约销售;一汽-大众销售|汽车销售","汽车销售;起亚特约销售;起亚销售|汽车维修","生活服务;摄影冲印店;摄影冲印|商务住宅","生活服务;美容美发店;美容美发店|汽车维修","科教文化服务;学校;学校|商务住宅","科教文化服务;学校;成人教育|生活服务","购物服务;专卖店;儿童用品店|科教文化服务;培训机构;培训机构","购物服务;专卖店;儿童用品店|购物服务;体育用品店;体育用品店","购物服务;专卖店;钟表店|公司企业","购物服务;家居建材市场;建材五金市场|购物服务;家居建材市场;厨卫市场","购物服务;家电电子卖场;手机销售|汽车服务","购物服务;服装鞋帽皮具店;品牌鞋店|餐饮服务","购物服务;服装鞋帽皮具店;服装鞋帽皮具店|餐饮服务;糕饼店;糕饼店","购物服务;花鸟鱼虫市场;花卉市场|公司企业;公司;公司","金融保险服务;自动提款机;南洋商业银行ATM","金融保险服务;银行相关;银行相关|生活服务","餐饮服务;中餐厅;中餐厅|住宿服务;旅馆招待所;旅馆招待所","餐饮服务;中餐厅;中餐厅|金融保险服务","餐饮服务;外国餐厅;日本料理|生活服务","餐饮服务;餐饮相关场所;餐饮相关|生活服务;生活服务场所;生活服务场所","交通设施服务;停车场;路边停车场|交通设施服务;停车场;公共停车场","交通设施服务;火车站;售票|生活服务","体育休闲服务;娱乐场所;酒吧|公司企业","体育休闲服务;影剧院;剧场|公司企业","体育休闲服务;运动场馆;跆拳道场馆|科教文化服务;培训机构;培训机构","体育休闲服务;运动场馆;运动场所|地名地址信息","公司企业;公司;建筑公司|餐饮服务","医疗保健服务;专科医院;胸科医院|医疗保健服务","商务住宅;住宅区;住宅区|商务住宅","商务住宅;住宅区;住宅小区|公司企业;公司;公司","摩托车服务;摩托车维修;摩托车维修|生活服务;生活服务场所;生活服务场所","政府机构及社会团体;政府机关;国家级机关及事业单位|公司企业","政府机构及社会团体;政府机关;政府机关相关|体育休闲服务","政府机构及社会团体;社会团体;共青团|政府机构及社会团体","汽车服务;二手车交易;二手车交易|摩托车服务","汽车服务;汽车俱乐部;汽车俱乐部|汽车销售","汽车服务;汽车租赁;汽车租赁|汽车维修","汽车服务;汽车配件销售;汽车配件销售|餐饮服务","汽车维修;一汽解放维修;一汽解放维修|汽车服务","汽车维修;东风特约维修;东风维修|汽车维修","汽车销售;一汽解放销售;一汽解放销售|汽车服务","汽车销售;东风特约销售;东风销售|汽车服务","汽车销售;江淮销售;江淮销售|汽车销售","汽车销售;荣威销售;荣威销售|汽车维修;荣威维修;荣威维修","生活服务;丧葬设施;丧葬设施|餐饮服务","生活服务;事务所;会计师事务所|政府机构及社会团体","生活服务;人才市场;人才市场|公司企业;公司;公司","科教文化服务;培训机构;培训机构|住宿服务","科教文化服务;科研机构;科研机构|商务住宅","购物服务;专卖店;珠宝首饰工艺品|金融保险服务","购物服务;便民商店/便利店;便民商店/便利店|汽车销售","购物服务;家电电子卖场;家电电子卖场|摩托车服务","购物服务;服装鞋帽皮具店;品牌箱包店|购物服务","购物服务;综合市场;旧货市场|公司企业","餐饮服务;中餐厅;湖南菜(湘菜)|生活服务","餐饮服务;中餐厅;老字号|餐饮服务","餐饮服务;冷饮店;冷饮店|体育休闲服务","餐饮服务;冷饮店;冷饮店|餐饮服务;休闲餐饮场所;休闲餐饮场所","餐饮服务;快餐厅;茶餐厅|体育休闲服务","住宿服务;旅馆招待所;旅馆招待所|风景名胜","体育休闲服务;休闲场所;垂钓园|餐饮服务","体育休闲服务;度假疗养场所;度假村|体育休闲服务;休闲场所;休闲场所","体育休闲服务;运动场馆;健身中心|科教文化服务;培训机构;培训机构","体育休闲服务;运动场馆;篮球场馆|体育休闲服务","体育休闲服务;高尔夫相关;高尔夫练习场|体育休闲服务","公司企业;公司;公司|商务住宅;商务住宅相关;商务住宅相关","公司企业;公司;机械电子|餐饮服务","医疗保健服务;动物医疗场所;动物医疗场所|医疗保健服务","商务住宅;产业园区;产业园区|体育休闲服务","商务住宅;产业园区;产业园区|汽车销售","商务住宅;楼宇;商务写字楼|政府机构及社会团体;政府机关;政府机关相关","地名地址信息;交通地名;道路名|购物服务;特色商业街;特色商业街","地名地址信息;自然地名;湖泊|风景名胜","政府机构及社会团体;交通车辆管理;交通管理机构|交通设施服务","政府机构及社会团体;公检法机构;公证鉴定机构|公司企业;公司;公司","汽车服务;汽车俱乐部;汽车俱乐部|体育休闲服务","汽车维修;大众特约维修;进口大众维修|汽车销售","汽车销售;货车销售;货车销售|生活服务","生活服务;丧葬设施;丧葬设施|购物服务;专卖店;专营店","生活服务;信息咨询中心;信息咨询中心|金融保险服务","生活服务;洗衣店;洗衣店|汽车服务","生活服务;物流速递;物流速递|金融保险服务","生活服务;电讯营业厅;中国联通营业厅|公司企业;公司;电信公司","科教文化服务;培训机构;培训机构|公司企业;公司;公司","科教文化服务;美术馆;美术馆|购物服务","购物服务;专卖店;自行车专卖店|汽车服务;二手车交易;二手车交易","购物服务;家居建材市场;灯具瓷器市场|汽车服务","购物服务;特殊买卖场所;典当行|金融保险服务","购物服务;特殊买卖场所;特殊买卖场所|公司企业","购物服务;特色商业街;步行街|地名地址信息;交通地名;道路名","金融保险服务;自动提款机;招商银行ATM|金融保险服务","金融保险服务;银行;中国光大银行|金融保险服务","金融保险服务;银行;交通银行|金融保险服务","风景名胜;公园广场;公园|科教文化服务","风景名胜;公园广场;公园|风景名胜;风景名胜;风景名胜","餐饮服务;中餐厅;四川菜(川菜)|餐饮服务;中餐厅;特色/地方风味餐厅","餐饮服务;中餐厅;山东菜(鲁菜)|住宿服务","餐饮服务;中餐厅;海鲜酒楼|商务住宅","餐饮服务;中餐厅;海鲜酒楼|餐饮服务;中餐厅;综合酒楼","餐饮服务;休闲餐饮场所;休闲餐饮场所|生活服务","餐饮服务;快餐厅;快餐厅|体育休闲服务","餐饮服务;甜品店;甜品店|餐饮服务;冷饮店;冷饮店","餐饮服务;糕饼店;糕饼店|购物服务;专卖店;专营店","交通设施服务;过境口岸;旅检楼","住宿服务;宾馆酒店;宾馆酒店|商务住宅;商务住宅相关;商务住宅相关","住宿服务;宾馆酒店;经济型连锁酒店|生活服务","体育休闲服务;休闲场所;休闲场所|体育休闲服务;娱乐场所;娱乐场所","体育休闲服务;娱乐场所;KTV|生活服务;洗浴推拿场所;洗浴推拿场所","体育休闲服务;度假疗养场所;疗养院|购物服务","公司企业;农林牧渔基地;农场|体育休闲服务","商务住宅;住宅区;别墅|体育休闲服务","商务住宅;住宅区;社区中心|生活服务;生活服务场所;生活服务场所","商务住宅;楼宇;商住两用楼宇|餐饮服务","地名地址信息;自然地名;湖泊|地名地址信息;自然地名;河流","政府机构及社会团体;交通车辆管理;交通管理机构|科教文化服务","汽车服务;汽车租赁;汽车租赁还车|生活服务","汽车维修;汽车综合维修;汽车综合维修|汽车销售;汽车销售;汽车销售","汽车销售;中国重汽销售;中国重汽销售|汽车销售","生活服务;彩票彩券销售点;彩票彩券销售点|生活服务","生活服务;摄影冲印店;摄影冲印|住宿服务","生活服务;摄影冲印店;摄影冲印|购物服务;购物相关场所;购物相关场所","生活服务;生活服务场所;生活服务场所|公共设施","科教文化服务;传媒机构;报社|科教文化服务","科教文化服务;学校;学校|政府机构及社会团体","购物服务;专卖店;专营店|汽车维修;汽车维修;汽车维修","购物服务;专卖店;专营店|购物服务;服装鞋帽皮具店;服装鞋帽皮具店","购物服务;专卖店;专营店|金融保险服务","购物服务;专卖店;宠物用品店|科教文化服务","购物服务;体育用品店;户外用品|摩托车服务","购物服务;商场;商场|公司企业","购物服务;商场;普通商场|科教文化服务","购物服务;商场;普通商场|购物服务;服装鞋帽皮具店;服装鞋帽皮具店","购物服务;家居建材市场;厨卫市场|购物服务;家电电子卖场;家电电子卖场","购物服务;家居建材市场;家居建材市场|汽车维修","购物服务;家居建材市场;家居建材市场|购物服务;专卖店;专营店","购物服务;家居建材市场;建材五金市场|住宿服务","购物服务;家居建材市场;建材五金市场|汽车销售","购物服务;特殊买卖场所;特殊买卖场所|汽车服务","购物服务;特色商业街;步行街|生活服务","金融保险服务;银行;中国农业银行|生活服务","风景名胜;公园广场;水族馆|风景名胜","风景名胜;风景名胜;国家级景点|体育休闲服务","风景名胜;风景名胜;纪念馆|生活服务","风景名胜;风景名胜;风景名胜|风景名胜","餐饮服务;中餐厅;中餐厅|交通设施服务","餐饮服务;中餐厅;中餐厅|汽车维修","餐饮服务;中餐厅;安徽菜(徽菜)|住宿服务","餐饮服务;中餐厅;火锅店|餐饮服务;中餐厅;海鲜酒楼","餐饮服务;中餐厅;特色/地方风味餐厅|商务住宅","餐饮服务;中餐厅;特色/地方风味餐厅|餐饮服务;中餐厅;四川菜(川菜)","餐饮服务;外国餐厅;牛扒店(扒房)|餐饮服务;外国餐厅;西餐厅(综合风味)"] + + public final static DBCollection COMPANY_206_COLL = MongoUtils.getCollectionByName("business", "company_huzhou", "192.168.0.206",27020) @@ -60,7 +64,7 @@ class GaoDePoiDataProcess extends BaseBatch{ def fullCityMap = null - DBCollection CHUN_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) DBCollection ADMINISTRATIVE_MAPPING_COLL_100 = MongoUtils.getCollectionByName2("fangjia", "administrative_mapping", MAP_POI_URL) @@ -80,9 +84,9 @@ class GaoDePoiDataProcess extends BaseBatch{ // synchNetwork() // println DateUtils.parseFromTightByPattern("2023-11-30","yyyy-MM-dd").getTime() // sysnchPoi() -// sysnchVillage() + sysnchVillage() - addTownship() +// addTownship() } def addTownship(){ @@ -119,13 +123,53 @@ class GaoDePoiDataProcess extends BaseBatch{ } def sysnchVillage(){ - def buducitys = ["乌兰察布市","巴彦淖尔市","渭南市","宝鸡市","枣庄市","日照市","东营市","威海市","太原市","文山壮族苗族自治州","中卫市","临夏回族自治州","辽源市","抚顺市","阿坝藏族羌族自治州","宜宾市","中山市","亳州市","滁州市","宣城市","廊坊市","宁德市","龙岩市","厦门市","莆田市","天水市","清远市","湛江市","阳江市","河源市","潮州市","来宾市","百色市","防城港市","铜仁地区","毕节地区","承德市","衡水市","濮阳市","开封市","焦作市","三门峡市","平顶山市","信阳市","鹤壁市","十堰市","荆门市","武汉市","常德市","岳阳市","娄底市","株洲市","盐城市","苏州市","景德镇市","抚州市","本溪市","盘锦市","包头市","阿拉善盟","榆林市","铜川市","西安市","临沂市","滨州市","青岛市","朔州市","晋中市","巴中市","绵阳市","广安市","资阳市","固原市","甘南藏族自治州","内江市","曲靖市","淮南市","巢湖市","黄山市","淮北市","三明市","漳州市","陇南市","广州市","云浮市","揭阳市","贺州市","南宁市","遵义市","安顺市","张家口市","唐山市","邢台市","安阳市","郑州市","驻马店市","宜昌市","黄冈市","益阳市","邵阳市","湘西土家族苗族自治州","郴州市","泰州市","宿迁市","宜春市","鹰潭市","朝阳市","营口市","丹东市","鄂尔多斯市","延安市","商洛市","济宁市","潍坊市","济南市","上海市","晋城市","南充市","北海市","赤峰市","六安市","池州市","福州市","惠州市","江门市","汕头市","梧州市","柳州市","黔南布依族苗族自治州","保定市","周口市","南阳市","孝感市","黄石市","张家界市","湘潭市","永州市","南京市","徐州市","无锡市","吉安市","葫芦岛市","鞍山市","呼和浩特市","吴忠市","咸阳市","安康市","泰安市","烟台市","吕梁市","运城市","广元市","遂宁市","泸州市","天津市","石嘴山市","昭通市","铜陵市","肇庆市","汕尾市","深圳市","贵港市","黔东南苗族侗族自治州","黔西南布依族苗族自治州","漯河市","扬州市","连云港市","常州市","九江市","萍乡市","辽阳市","汉中市","菏泽市","淄博市","大同市","长治市","阳泉市","马鞍山市","平凉市","银川市","玉林市","咸宁市","怀化市","上饶市","赣州市","聊城市","忻州市","临汾市","达州市","宿州市","随州市","德州市","恩施土家族苗族自治州","阿拉尔市","石河子市","五家渠市","图木舒克市","定安县","儋州市","万宁市","保亭黎族苗族自治县","西沙群岛","济源市","潜江市","中沙群岛","南沙群岛","屯昌县","昌江黎族自治县","陵水黎族自治县","五指山市","仙桃市","琼中黎族苗族自治县","乐东黎族自治县","临高县","琼海市","白沙黎族自治县","东方市","天门市","神农架林区","澄迈县","文昌市","澳门特别行政区","香港特别行政区","桃园市","台北市","南投县","嘉义市","彰化县","新竹县","澎湖县","台东县","宜兰县","新北市","基隆市","屏东县","嘉义县","云林县","花莲县","台南市","台中市","新竹市","高雄市","苗栗县"] + def buducitys = [ '七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市', + '东营市', '中卫市', '中山市', '临夏回族自治州', '临汾市', '临沂市', '临沧市', '临高县', '丹东市', + '丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市', + '云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市', + '佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州', + '克拉玛依市', '六安市', '六盘水市', '兰州市', '兴安盟', '内江市', '包头市', '北京市', '北海市', + '十堰市', '南京市', '南充市', '南宁市', '南平市', '南昌市', '南通市', '南阳市', + '博尔塔拉蒙古自治州', '厦门市', '双鸭山市', '台州市', '合肥市', '吉安市', '吉林市', '吐鲁番地区', + '吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市', + '哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市', + '固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市', + '天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市', + '安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市', + '宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市', + '巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市', + '广州市', '庆阳市', '廊坊市', '延安市', '延边朝鲜族自治州', '开封市', '张家口市', '张家界市', + '张掖市', '徐州市', '德州市', '德阳市', '忻州市', '怀化市', '恩施土家族苗族自治州', '惠州市', + '成都市', '扬州市', '承德市', '抚州市', '抚顺市', '拉萨市', '揭阳市', '攀枝花市', '文昌市', + '新乡市', '新余市', '无锡市', '日喀则地区', '日照市', '昆明市', '昌吉回族自治州', '昌江黎族自治县', + '昌都地区', '昭通市', '晋中市', '晋城市', '普洱市', '景德镇市', '曲靖市', '朔州市', '朝阳市', + '本溪市', '来宾市', '杭州市', '松原市', '林芝地区', '枣庄市', '柳州市', '株洲市', '桂林市', + '梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市', + '汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市', + '泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市', + '淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市', + '湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市', + '潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市', + '珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县', + '白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市', + '神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市', + '肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市', + '菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市', + '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市', + '辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', + '邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市', + '重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市', + '锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市', + '阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市', + '陵水黎族自治县', '随州市', '雅安市', '青岛市', '鞍山市', '韶关市', '马鞍山市', '驻马店市', + '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', + '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] for(def city : buducitys){ def pois = findAllVillagePoiMap(city) def rows = createVillageData(city, pois) save(city, rows) - saveToMG(city, rows) +// saveToMG(city, rows) println city +" "+pois.size()+" add:"+rows.size() } @@ -133,29 +177,36 @@ class GaoDePoiDataProcess extends BaseBatch{ def createVillageData(city, pois){ def rets = new CopyOnWriteArrayList() + def keyRets = new CopyOnWriteArrayList() def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(pois.size()) - def townMap = findTownRange(city) +// def townMap = findTownRange(city) + def townMap = CommonDatautils.queryTownByCity(city) + def poiKeys = findEsPoiByCity(city) for(def i=0;i +// +// }) + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) + def rets = new HashSet() + ElasticUtils89.executeQuery("192.168.0.89", "didata_map_poi_single", queryBuilder, { String id, Map d-> + rets << d.city +"##"+d.district+"##"+d.name + }) + return rets + } + + def queryMapPoi(city){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/didata_map_poi_single/_search" + def body = """ + { + "query": { + "term": { + "city" : { + "value": "上海市" + } + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + def obj = null + if(response && response.hits){ + def hits = response.hits.hits + if(hits){ + obj = hits[0] + } + } + println(response) + return obj + } + + def isTown( city, region, name){ // ElasticUtils.executeSqlQuery("select * from administrative_town where province = '${prov}' and city='${city}' and district='${region}' and town='${town}'", { // obj = it @@ -213,14 +308,59 @@ class GaoDePoiDataProcess extends BaseBatch{ retMap.city = map.city retMap.district = map.district retMap.name = map.name - retMap.type = "地名地址信息" - retMap.secondary_type = "普通地名" - retMap.small_type = "村庄级地名" - retMap.cat = "地名地址信息;普通地名;村庄级地名" + +// retMap.type = "地名地址信息" +// retMap.secondary_type = "普通地名" +// retMap.small_type = "村庄级地名" + retMap.cat = map.std_tag - retMap.location = ["lon": map.gcj02_x,"lat":map.gcj02_y] - retMap.township = InsidePolygon.isInArea2(retMap.location.lon, retMap.location.lat, townMap) + def nameArr = map.std_tag.split(";|:") + if(nameArr.size()>=1){ + retMap.type = nameArr[0] + } + if (nameArr.size()>=2){ + retMap.secondary_type = nameArr[1] + }else{ + if(retMap.type){ + retMap.secondary_type = retMap.type + } + } + + if (nameArr.size()>=3){ + def small = nameArr[2] + if (small.find("|")>-1){ + def smallArr = small.split("|") + if(smallArr.size()>=1){ + retMap.small_type = smallArr[0] + }else{ + retMap.small_type = small + } + } + }else{ + if(retMap.secondary_type){ + retMap.small_type = retMap.secondary_type + } + } + + if(map.gcj02_x){ + def lng = DataHandleUtils.getDoubleRound(6, map.gcj02_x) + def lat = DataHandleUtils.getDoubleRound(6, map.gcj02_y) + retMap.location = ["lon": lng,"lat":lat] + } + def towns = townMap.get(retMap.district) + if(towns){ + for(def town : towns){ + if(town.shape){ + def flag = InsidePolygon.isInArea(retMap.location.lon, retMap.location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) + if(flag){ + retMap.township = town.street + break; + } + } + } + } +// retMap.township = InsidePolygon.isInArea2(retMap.location.lon, retMap.location.lat, townMap) //高德转百度 def baiduMap = GeoUtils.gcj02ToBd09(retMap.location.lat, retMap.location.lon) if(baiduMap){ @@ -239,36 +379,30 @@ class GaoDePoiDataProcess extends BaseBatch{ retMap.gps_location = gpslocation } - if(!retMap.township){ - - def gaodeMap = getTownshipInfo(retMap.location.lon+","+retMap.location.lat) - if(gaodeMap && gaodeMap.township){ - retMap.township = gaodeMap.township - } - -// if(!fjw_region){ -// if(gaodeMap && gaodeMap.district){ -// fjw_region = RegionData.formatRegion(fjw_city, gaodeMap.district) -// } -// } -// -// if(!fjw_region){ -// println fjw_city+" "+retMap.region+" 无法格式化 "+retMap.location + " "+gaodeMap + //现在企业帐号被封无法大批量调用 +// if(!retMap.township){ +// def gaodeMap = getTownshipInfo(retMap.location.lon+","+retMap.location.lat) +// if(gaodeMap && gaodeMap.township){ +// retMap.township = gaodeMap.township // } +// } -// retMap.fjw_district = fjw_region - } -// retMap.fjw_district = fjw_region retMap.spell_name = com.fangjia.core.util.DataUtil.hanyuQuanpin(retMap.name, " ") retMap.version = version retMap.data_source = "百度地图" retMap.data_id = map._id.toString() retMap.id = map._id.toString() - if(retMap.secondary_type && TAGS.contains(retMap.secondary_type)){ - retMap.status = 0 +// if(retMap.secondary_type && TAGS.contains(retMap.secondary_type)){ +// retMap.status = 0 +// }else{ +// retMap.status = 1 +// } + + if(!retMap.cat || (retMap.cat && TYPES.contains(retMap.cat))){ + retMap.status = 1 //不输出 }else{ - retMap.status = 1 + retMap.status = 0 //输出 } return retMap } @@ -281,7 +415,8 @@ class GaoDePoiDataProcess extends BaseBatch{ keys.put("addr", 1) keys.put("gcj02_x", 1) keys.put("gcj02_y", 1) - def list = CHUN_POI_COLL.find(new BasicDBObject("std_tag","行政地标;村庄").append("city", city), keys).toList() + keys.put("std_tag", 1) + def list = BAIDU_POI_COLL.find(new BasicDBObject("city", city), keys).toList() return list; } @@ -552,7 +687,7 @@ class GaoDePoiDataProcess extends BaseBatch{ BulkRequest request = new BulkRequest(); int batchSize = 1000; int processedCount = 0; - def client = ElasticUtils.getClient("192.168.0.89") + def client = ElasticUtils89.getClient("192.168.0.89") for (int i = 0; i < rows.size(); i++) { def map = rows[i] request.add(new IndexRequest("didata_map_poi_single", "_doc", map.id).source(map, XContentType.JSON)); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy index 081770d5b..480a0c151 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy @@ -129,7 +129,7 @@ class SeaweedDataSynch extends BaseBatch{ def run(){ fullCityMap = CommonDatautils.queryFullNameCity() - mcaDistMap = CommonDatautils.queryDistNameCity() + mcaDistMap = CommonDatautils.queryDistNameCityByMapping() // priceMap = findAllDistrictSellPrice() def citys = CommonDatautils.findAllCity().reverse() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/DESUtil.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/DESUtil.groovy new file mode 100644 index 000000000..a9c2c6311 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/DESUtil.groovy @@ -0,0 +1,69 @@ +package com.fangjia.script.util + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; + +public class DESUtil { + + private static final String ALGORITHM = "DES"; + + // 生成密钥 + public static SecretKey generateKey() throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance(ALGORITHM); + keyGenerator.init(56); // DES密钥长度为56位 + return keyGenerator.generateKey(); + } + + // 将密钥转换为字符串 + public static String keyToString(SecretKey secretKey) { + return Base64.getEncoder().encodeToString(secretKey.getEncoded()); + } + + // 将字符串转换为密钥 + public static SecretKey stringToKey(String keyStr) { + byte[] decodedKey = Base64.getDecoder().decode(keyStr); + return new SecretKeySpec(decodedKey, 0, decodedKey.length, ALGORITHM); + } + + // DES加密 + public static String encrypt(String data, SecretKey secretKey) throws Exception { + Cipher cipher = Cipher.getInstance(ALGORITHM); + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + byte[] encryptedData = cipher.doFinal(data.getBytes()); + return Base64.getEncoder().encodeToString(encryptedData); + } + + // DES解密 + public static String decrypt(String encryptedData, SecretKey secretKey) throws Exception { + Cipher cipher = Cipher.getInstance(ALGORITHM); + cipher.init(Cipher.DECRYPT_MODE, secretKey); + byte[] decodedData = Base64.getDecoder().decode(encryptedData); + byte[] decryptedData = cipher.doFinal(decodedData); + return new String(decryptedData); + } + + public static void main(String[] args) { + try { + // 生成密钥 +// SecretKey secretKey = generateKey(); +// String keyStr = keyToString(secretKey); +// System.out.println("密钥: " + keyStr); +// +//// // 加密数据 +// String data = "高娟"; +// String encryptedData = encrypt(data, secretKey); +// System.out.println("加密后的数据: " + encryptedData); + + // 解密数据 + SecretKey newSecretKey = stringToKey("tnb12345"); + String decryptedData = decrypt("5E55C890CED08EFB7E3A05A0BAECB7B100D71965E4AD0FE2", newSecretKey); + System.out.println("解密后的数据: " + decryptedData); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index b3b119384..4ec1957bd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,7 +12,8 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "dfc2245bac8a7b2d5b62e060e59d4eca" //15021384995 + def static GAO_DE_AK = "c6fcd4bfbc40d73ee762b8115dca3390" //宝剑 + //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca /** * 经纬度转地址
From 156e09d4df3f306746597a9f31c416b436bc0f50 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 12 Aug 2024 15:17:51 +0800 Subject: [PATCH 23/45] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=89=A9=E4=BD=99?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=AC=A1=E6=95=B0=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=E6=80=BB=E6=AC=A1=E6=95=B0=E5=92=8C?= =?UTF-8?q?=E5=B7=B2=E7=94=A8=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/UsersController.java | 20 +++++++++++-------- .../fangjia/open/model/ApiMonitorInfo.java | 19 +++++++++++++++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java index 69b48a5f8..951c354b3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java @@ -149,17 +149,21 @@ public class UsersController { // 改成遍历用户有的uri for (OpenResource openResource : userResources) { String uri = openResource.getUri(); + ApiMonitorInfo info = new ApiMonitorInfo(); + info.setApiUri(uri); + info.setApiName(openResource.getName()); + info.setUserId((int) id); + info.setUsername(user.getUserName()); if (null != countMap.get(uri) && countMap.get(uri) > 0) { - ApiMonitorInfo info = new ApiMonitorInfo(); - info.setApiUri(uri); - info.setApiName(openResource.getName()); - info.setUserId((int) id); - info.setUsername(user.getUserName()); long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date())); - long total = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); - info.setSurplusCallCount(countMap.get(uri) - curVistedCount - total); - list.add(info); + long historyCount = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); + Integer totalCount = countMap.get(uri); + info.setTotalCallCount(Long.valueOf(totalCount)); + long usedCount = curVistedCount + historyCount; + info.setSurplusCallCount(totalCount - usedCount); + info.setUsedCallCount(usedCount); } + list.add(info); } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java index 0fdb11e38..481c6bf62 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiMonitorInfo.java @@ -10,6 +10,8 @@ public class ApiMonitorInfo { private String apiUri; private String apiName; private Long surplusCallCount; + private Long totalCallCount; + private Long usedCallCount; private Date endTime; public Long getSurplusCallCount() { @@ -60,5 +62,20 @@ public class ApiMonitorInfo { public void setApiName(String apiName) { this.apiName = apiName; } - + + public Long getTotalCallCount() { + return totalCallCount; + } + + public void setTotalCallCount(Long totalCallCount) { + this.totalCallCount = totalCallCount; + } + + public Long getUsedCallCount() { + return usedCallCount; + } + + public void setUsedCallCount(Long usedCallCount) { + this.usedCallCount = usedCallCount; + } } From d23244e83929d6caa8c31b7903d1e895cd9aedee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 13 Aug 2024 18:23:36 +0800 Subject: [PATCH 24/45] =?UTF-8?q?=E5=AF=B9=E7=A7=81=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E9=BD=90=E6=A2=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/AddrSvcController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index aa1183398..392a896a4 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -441,6 +441,8 @@ public class AddrSvcController { if (result.containsKey("devDistrictName")) { basicModel.setResult(result); + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 @@ -538,7 +540,8 @@ public class AddrSvcController { //我们省级及以上有开发区,直接用我们的结果 if (result.containsKey("devDistrictName")) { basicModel.setResult(result); - + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 @@ -674,7 +677,8 @@ public class AddrSvcController { //我们省级及以上有开发区,直接用我们的结果 if (result.containsKey("devDistrictName")) { basicModel.setResult(result); - + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 From e52540856f03f7dcae5137a0cf81bc8ec886a7f0 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 14 Aug 2024 14:14:25 +0800 Subject: [PATCH 25/45] update --- .../script/commData/CommonDatautils.groovy | 6 ++ .../script/gj/data_handle/DevProcess.groovy | 39 ++++++----- .../data_handle/ThardParthAnalyBatch.groovy | 68 +++++++++++++++++-- 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index f197f974c..d36b853dc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -1209,6 +1209,12 @@ class CommonDatautils { return rets; } + public static def findAllCount(String cat){ + DBObject q = new BasicDBObject(); + q.put("cat", cat); + return SEAWEED_MONGO_COLL.count(q) + } + public static def findDistrictsByName(String city, String name, String cat){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index f90ed42f6..772bbaf62 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -37,7 +37,7 @@ class DevProcess { def task = new DevProcess(); // task.run() // task.parseCityAndDist() -// task.devSplitRoad() + task.devSplitRoad() // task.devNameSplitRoad() // task.addFlag() // task.matchDev() @@ -69,7 +69,7 @@ class DevProcess { // task.addKfc() // task.devToPark() //开发区下辖园区 - task.checkTown() +// task.checkTown() } @@ -349,22 +349,27 @@ class DevProcess { } def matchDev(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\省级开发区名单\\新疆开发区名单.xlsx",{d-> - if(!d['Q'] && d['A']){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\前瞻网开发区对应园区.xlsx",{d-> + if(!d['I'] && d['J']){ def q = new BasicDBObject() -// q.put("name", d['A']) +// q.put("name", d['J']) // q.put("city",d['G']) -// q.put('alias', new BasicDBObject('$in',[d['A']])) - q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+d['A']+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 +// q.put('alias', new BasicDBObject('$in',[d['J']])) + def name = d['J'].replace('经济技术开发区','经济开发区') + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 def obj = development_zone_CONN.findOne(q) if(obj){ - d['C'] = obj._id.toString() - d['D'] = obj.name - if(obj.name == d['A']){ - d['E'] = "相同" - }else{ - d['E'] = "包含" - } + d['I'] = "库中有开发区-相似2" + d['K'] = obj.name +// d['C'] = obj._id.toString() +// d['D'] = obj.name +// if(obj.name == d['A']){ +// d['E'] = "相同" +// }else{ +// d['E'] = "包含" +// } +// d['E'] = "别名" +// d['F'] = obj.name } } },0); @@ -913,12 +918,12 @@ class DevProcess { def checkTown(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\开发区下辖园区.xlsx",{d-> + ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\前瞻网开发区对应园区.xlsx",{d-> if(!d['E']){ - if(d['C'] && d['D']){ + if(d['A']){ // if(d['A']=="长春高新技术产业开发区"){ - def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['C'], d['D']+d['B']) + def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['A']) if(jsonObject1) { if (jsonObject1.get("townCode") && jsonObject1.get("townCode")!='null' && jsonObject1.get("townCode")!='') { def township = jsonObject1.get("township") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy index ef6476d48..ee60d55b2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy @@ -1,14 +1,19 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.datastore.driver.FacetResult 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.common.DataHandleUtils import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.MongoUtils +import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import com.mongodb.DBObject @BatchOwner(Watcher.GaoJuan) class ThardParthAnalyBatch extends BaseBatch{ @@ -31,22 +36,36 @@ class ThardParthAnalyBatch extends BaseBatch{ } def run(){ + def fjwTotalCount = CommonDatautils.findAllCount("district") def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -2), "yyyy-MM-dd") def sDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM")); println "统计月份:"+sDate+" 查询更新时间:"+mdate def crawlTotalCount = findAllEsDataCount(mdate) - println "抓取第三方小区量:"+crawlTotalCount + println "抓取第三方小区总量:"+crawlTotalCount def synchTotalCount = findAllMongoDatasCount(sDate) - println "同步到第三方库小区量: "+synchTotalCount + println "同步到第三方库小区总量: "+synchTotalCount + def synchHavePriceTotalCount = findAllMongoDatasHavePricesCount(sDate) println "同步到第三方库有价格数量:"+synchHavePriceTotalCount + + def synchDistCount = findAllMongoDistrictCount(sDate) + println "同步到第三方库有价格小区量: "+synchDistCount + def matchTotalCount = findMatchSuccessCount(sDate) - println "第三方小区匹配成功量:"+matchTotalCount + println "第三方匹配成功总量:"+matchTotalCount + + def matchDistTotalCount = findMatchSuccessDistCount(sDate) + println "第三方匹配成功小区量:"+matchDistTotalCount + + def precent = matchDistTotalCount*100.0/fjwTotalCount + precent = DataHandleUtils.getDoubleRound(2, precent) + println "匹配成功占比:"+precent+"%" + def noMatchTotalCount = findNoMatchCount(sDate) println "第三方小区匹配还未匹配数量: "+noMatchTotalCount - saveOrUpdateDatas(sDate, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, matchTotalCount, noMatchTotalCount); + saveOrUpdateDatas(sDate, fjwTotalCount, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, synchDistCount, matchTotalCount,matchDistTotalCount, precent,noMatchTotalCount); } @@ -59,11 +78,36 @@ class ThardParthAnalyBatch extends BaseBatch{ return count; } + def findAllEsDistDataCount(mdate){ + def count = null + ElasticUtils.executeSqlQuery("select city,region,name as count from community where m_date>='${mdate}'", { d-> + count = d.count + }) + return count; + } + def findAllMongoDatasCount(s_date){ def q = new BasicDBObject().append("s_date", s_date) return thirdPartyColl.count(q) } + def findAllMongoDistrictCount(s_date){ + + def q = new BasicDBObject().append("s_date", s_date) + q.put("avg_price", new BasicDBObject('$gt', 0)) + def keys = new BasicDBObject() + keys.put("city",1) + keys.put("region",1) + keys.put("name",1) + def dbcursor = thirdPartyColl.find(q,keys) + + def set = new HashSet() + for (def d : dbcursor) { + set << d.city+"##"+d.region+"##"+d.name + } + return set.size() + } + def findAllMongoDatasHavePricesCount(sDate){ def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)) return thirdPartyColl.count(q) @@ -74,19 +118,33 @@ class ThardParthAnalyBatch extends BaseBatch{ return thirdPartyColl.count(q) } + def findMatchSuccessDistCount(sDate){ + def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)).append("status", 4) + def dbcursor = thirdPartyColl.count(q) + def set = new HashSet() + for (def d : dbcursor) { + set << d.city+"##"+d.region+"##"+d.name + } + return set.size() + } + def findNoMatchCount(sDate){ def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)).append("status", new BasicDBObject('$exists', false)) return thirdPartyColl.count(q) } - def saveOrUpdateDatas(sDate, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, matchTotalCount, noMatchTotalCount){ + def saveOrUpdateDatas(sDate, fjwTotalCount, crawlTotalCount, synchTotalCount, synchHavePriceTotalCount, synchDistCount, matchTotalCount, matchDistTotalCount, precent, noMatchTotalCount){ def obj = THIRD_PARTY_STAT.findOne(new BasicDBObject("s_date", sDate)) def udata = new BasicDBObject() + udata.put("fjw_dist_total", fjwTotalCount) udata.put("crawl_total", crawlTotalCount) udata.put("synch_total", synchTotalCount) udata.put("synch_have_price_total", synchHavePriceTotalCount) + udata.put("synch_have_price_district_total", synchDistCount) udata.put("match_total", matchTotalCount) + udata.put("match_dist_total", matchDistTotalCount) + udata.put("match_dist_rate", precent) udata.put("no_match_total", noMatchTotalCount) udata.put("c_date", new Date()) if(obj){ From 6872caffc108afc0c09ee16e1f05886ebb3acafd Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 14 Aug 2024 14:24:13 +0800 Subject: [PATCH 26/45] update --- .../fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy index ee60d55b2..7453c70a7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy @@ -120,7 +120,7 @@ class ThardParthAnalyBatch extends BaseBatch{ def findMatchSuccessDistCount(sDate){ def q = new BasicDBObject().append("s_date", sDate).append("avg_price", new BasicDBObject('$gt', 0)).append("status", 4) - def dbcursor = thirdPartyColl.count(q) + def dbcursor = thirdPartyColl.find(q) def set = new HashSet() for (def d : dbcursor) { set << d.city+"##"+d.region+"##"+d.name From 6ed32bce1d6652666a7d04b09eb49b0eea8d20ce Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 14 Aug 2024 14:45:51 +0800 Subject: [PATCH 27/45] update --- .../fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy index 7453c70a7..855403723 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy @@ -37,7 +37,7 @@ class ThardParthAnalyBatch extends BaseBatch{ def run(){ def fjwTotalCount = CommonDatautils.findAllCount("district") - def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -2), "yyyy-MM-dd") + def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyy-MM-dd") def sDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM")); println "统计月份:"+sDate+" 查询更新时间:"+mdate From 022b26f67034462bca8c09514f3596df03a0b2d7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 15 Aug 2024 09:59:04 +0800 Subject: [PATCH 28/45] =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy index 855403723..6a2ee9eec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThardParthAnalyBatch.groovy @@ -38,7 +38,7 @@ class ThardParthAnalyBatch extends BaseBatch{ def run(){ def fjwTotalCount = CommonDatautils.findAllCount("district") def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyy-MM-dd") - def sDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM")); + def sDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); println "统计月份:"+sDate+" 查询更新时间:"+mdate def crawlTotalCount = findAllEsDataCount(mdate) From 877ee4f977fcc60133384292ce1644c3fa9ff395 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 15 Aug 2024 17:20:17 +0800 Subject: [PATCH 29/45] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B9=B3=E7=B1=B3?= =?UTF-8?q?=E7=A7=9F=E9=87=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/mongo/model/SqmetreRent.java | 16 +- .../open/controllers/PropertyController.java | 11286 ++++++++-------- .../open/controllers/RentController.java | 2 +- .../open/model/AvgPriceQueryModel.java | 9 + .../datastore/EvaluationServiceImpl.java | 2 +- .../district/HouseReportServiceImpl.java | 6 +- .../district/SqmetreRentServiceImpl.java | 7 + 7 files changed, 5699 insertions(+), 5629 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SqmetreRent.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SqmetreRent.java index 839d829bc..284449824 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SqmetreRent.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SqmetreRent.java @@ -15,15 +15,15 @@ import com.fangjia.dal.MongoEntity; public class SqmetreRent implements MongoEntity { /** - * + * */ private static final long serialVersionUID = -5525712882803653336L; private String id; private String city; private String region; private String districtName; - private Integer avgPrice; - private Integer calcAvgPrice; + private Number avgPrice; + private Number calcAvgPrice; private Double markup; private Date weekend; private String cat; @@ -74,20 +74,20 @@ public class SqmetreRent implements MongoEntity { } @Column(name = "avg_price") - public Integer getAvgPrice() { + public Number getAvgPrice() { return avgPrice; } - public void setAvgPrice(Integer avgPrice) { + public void setAvgPrice(Number avgPrice) { this.avgPrice = avgPrice; } @Column(name = "calc_avg_price") - public Integer getCalcAvgPrice() { + public Number getCalcAvgPrice() { return calcAvgPrice; } - public void setCalcAvgPrice(Integer calcAvgPrice) { + public void setCalcAvgPrice(Number calcAvgPrice) { this.calcAvgPrice = calcAvgPrice; } @@ -163,7 +163,5 @@ public class SqmetreRent implements MongoEntity { public void setCat(String cat) { this.cat = cat; } - - } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index b5efca725..10e92ff24 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -14,6 +14,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.persistence.Id; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @@ -130,5323 +131,5378 @@ import com.mongodb.DBObject; @Authority(role = Role.USER) public class PropertyController { - private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); - private DistrictService districtService; - private AddressParser addressParser; - private DistrictStatService districtStatService; - private DealPriceService dealPriceService; - private HouseService houseService; - private ApiUserService apiUserService; - private NoHouseDistrictService noHouseDistrictService; - private UserService userService; - private HouseLoudongService houseLoudongService; - private LoudongService loudongService; - private EvaluationService evaluationService; - private FjtEvaluationService fjtEvaluationService; - private FieldFilterService fieldFilterService; - private OpenLogService openLogService; - private DistrictStatRentService districtStatRentService; - private BatchEvaluateService batchEvaluateService; - private DistrictAttentionRankService districtAttentionRankService; - private DistrictHotService districtHotService; - private CityHotService cityHotService; - private BizShopService bizShopService; - private BusStationService busStationService; - private BaiduApiService baiduApiService; - private DistrictHouseResourceStatService districtHouseResourceStatService; - private DistrictSellStatService districtSellStatService; - private DistrictAnalyDataService districtAnalyDataService; - private AddressMatchProxyService addressMatchProxyService; - private AddressParserService addressParserService; - private ApiUserAuthorityService apiUserAuthorityService; - private AverageStatisticsService averageStatisticsService; - private NetworkPriceService networkPriceService; - private AverageAnalyService averageAnalyService; - private ServerAreaService serverAreaService; - private HouseAuctionService houseAuctionService; - private ApiUserCfgService apiUserCfgService; - private OpenApiLogService openApiLogService; - private FangjiaOfficialAreaService fangjiaOfficialAreaService; - private RegionAnaDataService regionAnaDataService; - private SeawaterDao seawaterDao; - private SeawaterService seawaterService; - private SqmetreRentService sqmetreRentService; - private CommunityPoiService communityPoiService; - private CommunityBasePriceService communityBasePriceService; - private EvaluateFactorService evaluateFactorService; + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + private DistrictService districtService; + private AddressParser addressParser; + private DistrictStatService districtStatService; + private DealPriceService dealPriceService; + private HouseService houseService; + private ApiUserService apiUserService; + private NoHouseDistrictService noHouseDistrictService; + private UserService userService; + private HouseLoudongService houseLoudongService; + private LoudongService loudongService; + private EvaluationService evaluationService; + private FjtEvaluationService fjtEvaluationService; + private FieldFilterService fieldFilterService; + private OpenLogService openLogService; + private DistrictStatRentService districtStatRentService; + private BatchEvaluateService batchEvaluateService; + private DistrictAttentionRankService districtAttentionRankService; + private DistrictHotService districtHotService; + private CityHotService cityHotService; + private BizShopService bizShopService; + private BusStationService busStationService; + private BaiduApiService baiduApiService; + private DistrictHouseResourceStatService districtHouseResourceStatService; + private DistrictSellStatService districtSellStatService; + private DistrictAnalyDataService districtAnalyDataService; + private AddressMatchProxyService addressMatchProxyService; + private AddressParserService addressParserService; + private ApiUserAuthorityService apiUserAuthorityService; + private AverageStatisticsService averageStatisticsService; + private NetworkPriceService networkPriceService; + private AverageAnalyService averageAnalyService; + private ServerAreaService serverAreaService; + private HouseAuctionService houseAuctionService; + private ApiUserCfgService apiUserCfgService; + private OpenApiLogService openApiLogService; + private FangjiaOfficialAreaService fangjiaOfficialAreaService; + private RegionAnaDataService regionAnaDataService; + private SeawaterDao seawaterDao; + private SeawaterService seawaterService; + private SqmetreRentService sqmetreRentService; + private CommunityPoiService communityPoiService; + private CommunityBasePriceService communityBasePriceService; + private EvaluateFactorService evaluateFactorService; - private FileDao fileDao = FileDao.getInstance(); - private static final int DEFAULT_PAGE_SIZE = 20; - private static final String[] PROPERTY_SEARCH_API_FIELDS = { "address", "city", "region", "name", "lat2", "lng2","lat", "lng", "block", "estateType2", "addrAlias", "alias" }; - static final int BAI_DU_GEO = 1;// 百度系坐标 - static final int GAO_DE_GEO = 2;// 高德系坐标 + private FileDao fileDao = FileDao.getInstance(); + private static final int DEFAULT_PAGE_SIZE = 20; + private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "lat2", "lng2", "lat", "lng", "block", "estateType2", "addrAlias", "alias"}; + static final int BAI_DU_GEO = 1;// 百度系坐标 + static final int GAO_DE_GEO = 2;// 高德系坐标 - private AutoCompleteService autoCompleteService; + private AutoCompleteService autoCompleteService; - private DistrictRoomSqmetreRentService districtRoomSqmetreRentService; - private RentDealPriceService rentDealPriceService; - private EvaluateRatioService evaluateRatioService; - private AliasFangService aliasFangService; + private DistrictRoomSqmetreRentService districtRoomSqmetreRentService; + private RentDealPriceService rentDealPriceService; + private EvaluateRatioService evaluateRatioService; + private AliasFangService aliasFangService; - private static final int EVALUATE_SHOW_DETAIL = 1; - private static final Map PROPERTY_TYPES = new HashMap() { - { - put(null, "普通住宅"); - put("0", "普通住宅"); - put("1", "别墅"); - put("2", "商住"); - } - }; + private static final int EVALUATE_SHOW_DETAIL = 1; + private static final Map PROPERTY_TYPES = new HashMap() { + { + put(null, "普通住宅"); + put("0", "普通住宅"); + put("1", "别墅"); + put("2", "商住"); + } + }; - private static final Map DIRECTION = new HashMap() { - { - put(null, "南"); - put("1", "西南"); - put("2", "东南"); - put("3", "南"); - put("4", "西北"); - put("5", "东北"); - put("6", "东"); - put("7", "西"); - put("8", "北"); - put("9", "东西"); - put("10", "南北"); - } - }; + private static final Map DIRECTION = new HashMap() { + { + put(null, "南"); + put("1", "西南"); + put("2", "东南"); + put("3", "南"); + put("4", "西北"); + put("5", "东北"); + put("6", "东"); + put("7", "西"); + put("8", "北"); + put("9", "东西"); + put("10", "南北"); + } + }; - private static final Map FITMENT = new HashMap() { - { - put(null, "简装"); - put("1", "毛坯"); - put("2", "简装"); - put("3", "精装"); - put("4", "豪装"); - } - }; + private static final Map FITMENT = new HashMap() { + { + put(null, "简装"); + put("1", "毛坯"); + put("2", "简装"); + put("3", "精装"); + put("4", "豪装"); + } + }; - private static final Map EVALUATION_MODEL_FITMENT = new HashMap() { - { - put(null, "简单装修"); - put("简装", "简单装修"); - put("毛坯", "毛坯"); - put("精装", "精装修"); - put("豪装", "豪华装修"); - } - }; + private static final Map EVALUATION_MODEL_FITMENT = new HashMap() { + { + put(null, "简单装修"); + put("简装", "简单装修"); + put("毛坯", "毛坯"); + put("精装", "精装修"); + put("豪装", "豪华装修"); + } + }; - private static final Map FITMENT_MAP = new HashMap() { - { - put("1", "毛坯"); - put("2", "简装"); - put("3", "精装"); - put("4", "豪装"); - } - }; + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "毛坯"); + put("2", "简装"); + put("3", "精装"); + put("4", "豪装"); + } + }; - private static final Map SIGHT = new HashMap() { - { - put(null, "一般"); - put("1", "景观房"); - put("2", "侧景观房"); - put("3", "一般"); - put("4", "差"); - } - }; + private static final Map SIGHT = new HashMap() { + { + put(null, "一般"); + put("1", "景观房"); + put("2", "侧景观房"); + put("3", "一般"); + put("4", "差"); + } + }; - private static final Map NOISE = new HashMap() { - { - put(null, "无噪音"); - put("0", "无噪音"); - put("1", "噪音较小"); - put("2", "噪音大"); - } - }; + private static final Map NOISE = new HashMap() { + { + put(null, "无噪音"); + put("0", "无噪音"); + put("1", "噪音较小"); + put("2", "噪音大"); + } + }; - private static final Map WORRY_FACTOR = new HashMap() { - { - put("0", "变电站"); - put("1", "垃圾场"); - put("2", "高架噪音"); - put("3", "轨交噪音"); - put("4", "发射塔"); - } - }; + private static final Map WORRY_FACTOR = new HashMap() { + { + put("0", "变电站"); + put("1", "垃圾场"); + put("2", "高架噪音"); + put("3", "轨交噪音"); + put("4", "发射塔"); + } + }; - private static final Map FACILITIES = new HashMap() { - { - put("0", "健身房"); - put("1", "游泳池"); - put("2", "会所"); - put("3", "网球场"); - put("4", "球场"); - put("5", "棋牌室"); - put("6", "停车场"); - put("7", "图书馆"); - put("8", "活动中心"); - } - }; + private static final Map FACILITIES = new HashMap() { + { + put("0", "健身房"); + put("1", "游泳池"); + put("2", "会所"); + put("3", "网球场"); + put("4", "球场"); + put("5", "棋牌室"); + put("6", "停车场"); + put("7", "图书馆"); + put("8", "活动中心"); + } + }; - private static final Map FJT_DIRECTION = new HashMap() { - { - put("1", "西南"); - put("2", "东南"); - put("3", "南"); - put("4", "西北"); - put("5", "东北"); - put("6", "东"); - put("7", "西"); - put("8", "北"); - put("9", "东西"); - put("10", "南北"); - } - }; - private static final Map FJT_FITMENT = new HashMap() { - { - put("0", "毛坯"); - put("1", "毛坯"); - put("2", "简装"); - put("4", "精装"); - put("5", "豪华装修"); - } - }; - private static final Map NEGATIVE_FACTOR = new HashMap() { - { - put(null, "无"); - put("1", "很近"); - put("2", "较近"); - put("3", "无"); - } - }; - private static final Map AROUND_KEYWORD_FACTOR = new HashMap() { - { - put("KTV", "KTV"); - put("医院", "hospital"); - put("学校", "school"); - put("银行", "bank"); - put("ATM", "ATM"); - put("写字楼", "office"); - put("超市", "superMarket"); - put("公园", "park"); - put("停车场", "parking"); - put("机场", "airport"); - put("网吧", "netbar"); - put("电影院", "cinema"); - put("美容院", "beautySalon"); - put("健身中心", "fitnessCenter"); - put("商场", "shoppingMall"); - put("星级酒店", "hotel"); - put("高尔夫球场", "golf"); - put("咖啡厅", "cafe"); - } - }; + private static final Map FJT_DIRECTION = new HashMap() { + { + put("1", "西南"); + put("2", "东南"); + put("3", "南"); + put("4", "西北"); + put("5", "东北"); + put("6", "东"); + put("7", "西"); + put("8", "北"); + put("9", "东西"); + put("10", "南北"); + } + }; + private static final Map FJT_FITMENT = new HashMap() { + { + put("0", "毛坯"); + put("1", "毛坯"); + put("2", "简装"); + put("4", "精装"); + put("5", "豪华装修"); + } + }; + private static final Map NEGATIVE_FACTOR = new HashMap() { + { + put(null, "无"); + put("1", "很近"); + put("2", "较近"); + put("3", "无"); + } + }; + private static final Map AROUND_KEYWORD_FACTOR = new HashMap() { + { + put("KTV", "KTV"); + put("医院", "hospital"); + put("学校", "school"); + put("银行", "bank"); + put("ATM", "ATM"); + put("写字楼", "office"); + put("超市", "superMarket"); + put("公园", "park"); + put("停车场", "parking"); + put("机场", "airport"); + put("网吧", "netbar"); + put("电影院", "cinema"); + put("美容院", "beautySalon"); + put("健身中心", "fitnessCenter"); + put("商场", "shoppingMall"); + put("星级酒店", "hotel"); + put("高尔夫球场", "golf"); + put("咖啡厅", "cafe"); + } + }; - private static final Map AROUND_KEYWORD_FACTOR_NEW = new HashMap() { - { - put("学校", "school"); - put("医院", "hospital"); - put("银行", "bank"); - put("超市", "supermarket"); - put("商场", "market"); - put("美容院", "beautySalon"); - put("健身中心", "gym"); - put("公园/绿地", "park"); - put("地铁", "metro"); - put("公交", "bus"); - put("码头", "dock"); - put("机场", "airport"); - put("火车站", "trainStation"); - put("餐馆", "restaurant"); - put("酒店", "hotel"); - } - }; + private static final Map AROUND_KEYWORD_FACTOR_NEW = new HashMap() { + { + put("学校", "school"); + put("医院", "hospital"); + put("银行", "bank"); + put("超市", "supermarket"); + put("商场", "market"); + put("美容院", "beautySalon"); + put("健身中心", "gym"); + put("公园/绿地", "park"); + put("地铁", "metro"); + put("公交", "bus"); + put("码头", "dock"); + put("机场", "airport"); + put("火车站", "trainStation"); + put("餐馆", "restaurant"); + put("酒店", "hotel"); + } + }; - Map listKeyMap = new HashMap() { - { - put("school", "schools"); - put("hospital", "hospitals"); - put("bank", "banks"); - put("supermarket", "supermarkets"); - put("market", "markets"); - put("beautySalon", "beautySalons"); - put("gym", "gyms"); - put("park", "parks"); - put("bus", "buses"); - put("metro", "metros"); - put("dock", "docks"); - put("airport", "airports"); - put("trainStation", "trainStations"); - put("restaurant", "restaurants"); - put("hotel", "hotels"); - } - }; + Map listKeyMap = new HashMap() { + { + put("school", "schools"); + put("hospital", "hospitals"); + put("bank", "banks"); + put("supermarket", "supermarkets"); + put("market", "markets"); + put("beautySalon", "beautySalons"); + put("gym", "gyms"); + put("park", "parks"); + put("bus", "buses"); + put("metro", "metros"); + put("dock", "docks"); + put("airport", "airports"); + put("trainStation", "trainStations"); + put("restaurant", "restaurants"); + put("hotel", "hotels"); + } + }; - private static final Map CITYLEVEL_MAP = new HashMap() { - { - put("1000", "one");// 一线 - put("1500", "newOne");// 新一线 - put("2000", "two");// 二线 - put("3000", "three");// 三线 - put("4000", "four");// 四线 - put("5000", "five");// 五线 - } - }; - /** - * 第三方均价映射 - */ - private static final Map OTHER_PRICE_MAP = new HashMap() { - { - put("zhuge_price", "诸葛找房"); - put("anjuke_price", "安居客"); - put("fang_price", "房天下"); - put("lianjia_price", "链家"); - put("cityhouse_price", "禧泰数据"); - put("maitian_price", "麦田"); - put("ke_price", "贝壳"); - put("taofang_price", "淘房365"); - put("zhongyuan_price", "中原"); - put("tbs_price", "兔博士"); - put("qfang_price", "Q房"); - put("fangtan_price", "房探"); - put("fangduoduo_price", "房多多"); - put("wiwj_price", "我爱我家"); - } - }; + private static final Map CITYLEVEL_MAP = new HashMap() { + { + put("1000", "one");// 一线 + put("1500", "newOne");// 新一线 + put("2000", "two");// 二线 + put("3000", "three");// 三线 + put("4000", "four");// 四线 + put("5000", "five");// 五线 + } + }; + /** + * 第三方均价映射 + */ + private static final Map OTHER_PRICE_MAP = new HashMap() { + { + put("zhuge_price", "诸葛找房"); + put("anjuke_price", "安居客"); + put("fang_price", "房天下"); + put("lianjia_price", "链家"); + put("cityhouse_price", "禧泰数据"); + put("maitian_price", "麦田"); + put("ke_price", "贝壳"); + put("taofang_price", "淘房365"); + put("zhongyuan_price", "中原"); + put("tbs_price", "兔博士"); + put("qfang_price", "Q房"); + put("fangtan_price", "房探"); + put("fangduoduo_price", "房多多"); + put("wiwj_price", "我爱我家"); + } + }; - /** - * 利用百度API把GPS转换成Google经纬度 - * - * @param lng - * @param lat - * @return - */ - private CoordPoint convertWGSToGoogleByAPI(double lng, double lat) { - Map lnglatMap = null; - try { - lnglatMap = LatitudeAndLongitudeUtil.geoGpsToBaidu(lng, lat); - } catch (Exception e) { - return null; - } + /** + * 利用百度API把GPS转换成Google经纬度 + * + * @param lng + * @param lat + * @return + */ + private CoordPoint convertWGSToGoogleByAPI(double lng, double lat) { + Map lnglatMap = null; + try { + lnglatMap = LatitudeAndLongitudeUtil.geoGpsToBaidu(lng, lat); + } catch (Exception e) { + return null; + } - if (lnglatMap != null) { - lnglatMap = GeocodeUtils.geoconvBaiduToGoogle(lnglatMap.get("lng"), lnglatMap.get("lat")); - return new CoordPoint(lnglatMap.get("lng"), lnglatMap.get("lat")); - } - return null; - } + if (lnglatMap != null) { + lnglatMap = GeocodeUtils.geoconvBaiduToGoogle(lnglatMap.get("lng"), lnglatMap.get("lat")); + return new CoordPoint(lnglatMap.get("lng"), lnglatMap.get("lat")); + } + return null; + } - /** - * 利用算法模板把GPS转换成Google经纬度 - * - * @param lng - * @param lat - * @return - */ - private CoordPoint convertWGSToGoogleByMode(double lng, double lat) { - return CoordinateConversion.wgs_gcj_encrypts(lat, lng); - } + /** + * 利用算法模板把GPS转换成Google经纬度 + * + * @param lng + * @param lat + * @return + */ + private CoordPoint convertWGSToGoogleByMode(double lng, double lat) { + return CoordinateConversion.wgs_gcj_encrypts(lat, lng); + } - public Object searchAction(PropertySearchModel model) { + public Object searchAction(PropertySearchModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); - return mav; - } - if (!RegionData.isCity(model.getCity())) { - String city = RegionData.formatCity(model.getCity()); - if (null == city) { - mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); - return mav; - } else { - model.setCity(city); - } - } - if (StringUtils.isNotBlank(model.getDistrict())) { - model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); - } + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); + return mav; + } + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } + if (StringUtils.isNotBlank(model.getDistrict())) { + model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); + } - /** 设置默认坐标系 */ - if (model.getFrom() == 0) { - model.setFrom(BAI_DU_GEO); - } - if (StringUtils.isBlank(model.getKeyword()) && !isRadiusSearch(model)) { - ServerArea cityData = ServerAreaData.getServerAreaByCity(model.getCity()); - if (cityData == null) { - mav.setModel(BasicModel.buildBadRequestModel("城市:" + model.getCity() + "暂不支持")); - return mav; - } - if (cityData.getLng2() <= 0 || cityData.getLat2() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("关键字(keyword)和经纬度信息(lat,lng,radius)不能同时为空")); - return mav; - } - if (model.getFrom() == BAI_DU_GEO) { - model.setLat(DataUtil.roundDouble(cityData.getLat2(), 6)); - model.setLng(DataUtil.roundDouble(cityData.getLng2(), 6)); - } else if (model.getFrom() == GAO_DE_GEO) { - model.setLat(DataUtil.roundDouble(cityData.getLat(), 6)); - model.setLng(DataUtil.roundDouble(cityData.getLng(), 6)); - } - } - if (isRadiusSearch(model)) { - if (model.getRadius() == null || model.getRadius() <= 0 || model.getRadius() >= 5000) { - model.setRadius(1000); - } - if (model.getFrom() == 0) { - model.setFrom(BAI_DU_GEO); - } - } + /** 设置默认坐标系 */ + if (model.getFrom() == 0) { + model.setFrom(BAI_DU_GEO); + } + if (StringUtils.isBlank(model.getKeyword()) && !isRadiusSearch(model)) { + ServerArea cityData = ServerAreaData.getServerAreaByCity(model.getCity()); + if (cityData == null) { + mav.setModel(BasicModel.buildBadRequestModel("城市:" + model.getCity() + "暂不支持")); + return mav; + } + if (cityData.getLng2() <= 0 || cityData.getLat2() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("关键字(keyword)和经纬度信息(lat,lng,radius)不能同时为空")); + return mav; + } + if (model.getFrom() == BAI_DU_GEO) { + model.setLat(DataUtil.roundDouble(cityData.getLat2(), 6)); + model.setLng(DataUtil.roundDouble(cityData.getLng2(), 6)); + } else if (model.getFrom() == GAO_DE_GEO) { + model.setLat(DataUtil.roundDouble(cityData.getLat(), 6)); + model.setLng(DataUtil.roundDouble(cityData.getLng(), 6)); + } + } + if (isRadiusSearch(model)) { + if (model.getRadius() == null || model.getRadius() <= 0 || model.getRadius() >= 5000) { + model.setRadius(1000); + } + if (model.getFrom() == 0) { + model.setFrom(BAI_DU_GEO); + } + } - if (model.getMax() == null) { - model.setMax(DEFAULT_PAGE_SIZE); - } else if (model.getMax().intValue() > 100) { - model.setMax(100); - } else if (model.getMax().intValue() < 1) { - model.setMax(DEFAULT_PAGE_SIZE); - } + if (model.getMax() == null) { + model.setMax(DEFAULT_PAGE_SIZE); + } else if (model.getMax().intValue() > 100) { + model.setMax(100); + } else if (model.getMax().intValue() < 1) { + model.setMax(DEFAULT_PAGE_SIZE); + } - SdQuery sdQuery = null; - CoordPoint point = null; + SdQuery sdQuery = null; + CoordPoint point = null; - if (isRadiusSearch(model)) { - if (model.getLat() < 0 || model.getLat() > 90) { - mav.setModel(BasicModel.buildBadRequestModel("lat(维度)的取值范围是0~90")); - return mav; - } - if (model.getLng() < 0 || model.getLng() > 180) { - mav.setModel(BasicModel.buildBadRequestModel("lng(经度)的取值范围是0~180")); - return mav; - } - // from=0为默认值,表示输入值为GPS的经纬度 - // from>0,表示为输入的是baidu经纬度 - if (model.getFrom() == BAI_DU_GEO) { - Map geo = GeocodeUtils.geoconvBaiduToGoogle(model.getLng(), model.getLat()); - point = new CoordPoint(geo.get("lng"), geo.get("lat")); + if (isRadiusSearch(model)) { + if (model.getLat() < 0 || model.getLat() > 90) { + mav.setModel(BasicModel.buildBadRequestModel("lat(维度)的取值范围是0~90")); + return mav; + } + if (model.getLng() < 0 || model.getLng() > 180) { + mav.setModel(BasicModel.buildBadRequestModel("lng(经度)的取值范围是0~180")); + return mav; + } + // from=0为默认值,表示输入值为GPS的经纬度 + // from>0,表示为输入的是baidu经纬度 + if (model.getFrom() == BAI_DU_GEO) { + Map geo = GeocodeUtils.geoconvBaiduToGoogle(model.getLng(), model.getLat()); + point = new CoordPoint(geo.get("lng"), geo.get("lat")); - } else if (model.getFrom() == GAO_DE_GEO) { - point = new CoordPoint(model.getLng(), model.getLat()); - } - if (point != null) { - sdQuery = new SdQuery(); - sdQuery.setPoint(point.getLat() + "," + point.getLng()); - sdQuery.setField("lat_lng"); - sdQuery.setDistance(String.valueOf(model.getRadius() / 1000.0)); - } - } + } else if (model.getFrom() == GAO_DE_GEO) { + point = new CoordPoint(model.getLng(), model.getLat()); + } + if (point != null) { + sdQuery = new SdQuery(); + sdQuery.setPoint(point.getLat() + "," + point.getLng()); + sdQuery.setField("lat_lng"); + sdQuery.setDistance(String.valueOf(model.getRadius() / 1000.0)); + } + } - List result = districtService.searchByKeyword(model.getCity(), model.getDistrict(), - model.getKeyword(), "district", sdQuery, PROPERTY_SEARCH_API_FIELDS, model.getMax()); - if (result.isEmpty() && StringUtils.isNotBlank(model.getKeyword())) { - District matchDistrict = matchDistrict(model.getCity(), model.getKeyword(), model.getDistrict(), null); - if (matchDistrict != null) { - if (isRadiusSearch(model)) {// 如果搜索中包涵经纬度信息,计算匹配出来的小区是否在指定半径内 - double distance; - if (hasGeoPoint(matchDistrict)) { - distance = GeoUtils.calculateDistance(point.getLng(), point.getLat(), - matchDistrict.getLng() / 10000000000d, matchDistrict.getLat() / 10000000000d); - if (distance < model.getRadius()) { - result.add(matchDistrict); - } - } + List result = districtService.searchByKeyword(model.getCity(), model.getDistrict(), + model.getKeyword(), "district", sdQuery, PROPERTY_SEARCH_API_FIELDS, model.getMax()); + if (result.isEmpty() && StringUtils.isNotBlank(model.getKeyword())) { + District matchDistrict = matchDistrict(model.getCity(), model.getKeyword(), model.getDistrict(), null); + if (matchDistrict != null) { + if (isRadiusSearch(model)) {// 如果搜索中包涵经纬度信息,计算匹配出来的小区是否在指定半径内 + double distance; + if (hasGeoPoint(matchDistrict)) { + distance = GeoUtils.calculateDistance(point.getLng(), point.getLat(), + matchDistrict.getLng() / 10000000000d, matchDistrict.getLat() / 10000000000d); + if (distance < model.getRadius()) { + result.add(matchDistrict); + } + } - } else { - result.add(matchDistrict); - } - } - } - String inputAddress = null; - if (StringUtils.isNotBlank(model.getKeyword())) { - com.fangjia.service.address.mode.Address address = addressParserService.standardize(model.getCity(), - model.getKeyword()); - if (StringUtils.isNotBlank(address.getStreet())) { - inputAddress = address.getStreet(); - } - if (StringUtils.isNotBlank(address.getStreetNumber())) { - inputAddress = inputAddress + address.getStreetNumber(); - } - } + } else { + result.add(matchDistrict); + } + } + } + String inputAddress = null; + if (StringUtils.isNotBlank(model.getKeyword())) { + com.fangjia.service.address.mode.Address address = addressParserService.standardize(model.getCity(), + model.getKeyword()); + if (StringUtils.isNotBlank(address.getStreet())) { + inputAddress = address.getStreet(); + } + if (StringUtils.isNotBlank(address.getStreetNumber())) { + inputAddress = inputAddress + address.getStreetNumber(); + } + } - List list = new ArrayList(); - for (District district : result) { - PropertyDto dto = new PropertyDto(); - dto.setId(district.getId()); - if (inputAddress == null) { - dto.setAddress(district.getAddress()); - } else { - dto.setAddress(findMostSimilarAddress(inputAddress, district)); - } - dto.setCity(district.getCity()); - dto.setDistrict(district.getRegion()); - if (model.getFrom() == BAI_DU_GEO) { - if (district.getLat2() != null && district.getLng2() != null) { - dto.setLat(Double.toString(district.getLat2() / 10000000000D)); - dto.setLng(Double.toString(district.getLng2() / 10000000000D)); - } - } else if (model.getFrom() == GAO_DE_GEO) { - if (district.getLat() != null && district.getLng() != null) { - dto.setLat(Double.toString(district.getLat() / 10000000000D)); - dto.setLng(Double.toString(district.getLng() / 10000000000D)); - } - } - if (isRadiusSearch(model) && district.getLng() != null && district.getLat() != null && point != null) { - dto.setDistance(String.valueOf((long) GeoUtils.calculateDistance(district.getLng() / 10000000000D, - district.getLat() / 10000000000D, point.getLng(), point.getLat()))); - } + List list = new ArrayList(); + for (District district : result) { + PropertyDto dto = new PropertyDto(); + dto.setId(district.getId()); + if (inputAddress == null) { + dto.setAddress(district.getAddress()); + } else { + dto.setAddress(findMostSimilarAddress(inputAddress, district)); + } + dto.setCity(district.getCity()); + dto.setDistrict(district.getRegion()); + if (model.getFrom() == BAI_DU_GEO) { + if (district.getLat2() != null && district.getLng2() != null) { + dto.setLat(Double.toString(district.getLat2() / 10000000000D)); + dto.setLng(Double.toString(district.getLng2() / 10000000000D)); + } + } else if (model.getFrom() == GAO_DE_GEO) { + if (district.getLat() != null && district.getLng() != null) { + dto.setLat(Double.toString(district.getLat() / 10000000000D)); + dto.setLng(Double.toString(district.getLng() / 10000000000D)); + } + } + if (isRadiusSearch(model) && district.getLng() != null && district.getLat() != null && point != null) { + dto.setDistance(String.valueOf((long) GeoUtils.calculateDistance(district.getLng() / 10000000000D, + district.getLat() / 10000000000D, point.getLng(), point.getLat()))); + } - dto.setName(district.getName()); - if (district.getBlock() == null) { - dto.setBlock(""); - } else { - dto.setBlock(district.getBlock()); - } - dto.setPropertyType(district.getEstateType2()); - if (CollectionUtils.isNotEmpty(district.getAlias())) { - // 将最相近的别名输出给用户 - String alias = null; - double similarity = 0; - if (StringUtils.isNotBlank(model.getKeyword())) { - for (String mappingAlias : district.getAlias()) { - double curr = AddressParserUtil.getSimilarityRatio(mappingAlias, model.getKeyword()); - if (curr > similarity ) { - similarity = curr; - alias = mappingAlias; - } - } - } - if (StringUtils.isNotBlank(alias)) { - dto.setAlias(alias); - } else { - dto.setAlias(district.getAlias().get(0)); - } - } - list.add(dto); - } + dto.setName(district.getName()); + if (district.getBlock() == null) { + dto.setBlock(""); + } else { + dto.setBlock(district.getBlock()); + } + dto.setPropertyType(district.getEstateType2()); + if (CollectionUtils.isNotEmpty(district.getAlias())) { + // 将最相近的别名输出给用户 + String alias = null; + double similarity = 0; + if (StringUtils.isNotBlank(model.getKeyword())) { + for (String mappingAlias : district.getAlias()) { + double curr = AddressParserUtil.getSimilarityRatio(mappingAlias, model.getKeyword()); + if (curr > similarity) { + similarity = curr; + alias = mappingAlias; + } + } + } + if (StringUtils.isNotBlank(alias)) { + dto.setAlias(alias); + } else { + dto.setAlias(district.getAlias().get(0)); + } + } + list.add(dto); + } - mav.setModel(BasicModel.buildOKModel().setResult(list)); - return mav; - } + mav.setModel(BasicModel.buildOKModel().setResult(list)); + return mav; + } - private String findMostSimilarAddress(String inputAddress, District district) { + private String findMostSimilarAddress(String inputAddress, District district) { - if (StringUtils.isBlank(inputAddress)) { - return district.getAddress(); - } - if (StringUtils.isNotBlank(district.getKeyword()) && district.getAddress().contains(inputAddress)) { - return district.getAddress(); - } - if (district.getAddrAlias() == null) { - return district.getAddress(); - } - for (String addr : district.getAddrAlias()) { - if (addr.contains(inputAddress)) { - return addr; - } - } - return district.getAddress(); - } + if (StringUtils.isBlank(inputAddress)) { + return district.getAddress(); + } + if (StringUtils.isNotBlank(district.getKeyword()) && district.getAddress().contains(inputAddress)) { + return district.getAddress(); + } + if (district.getAddrAlias() == null) { + return district.getAddress(); + } + for (String addr : district.getAddrAlias()) { + if (addr.contains(inputAddress)) { + return addr; + } + } + return district.getAddress(); + } - /** - * 判断小区是否有经纬度 - * - * @param district - * @return - */ - private boolean hasGeoPoint(District district) { - return district.getLat() != null && district.getLng() != null && district.getLat() != 0 - && district.getLng() != 0; - } + /** + * 判断小区是否有经纬度 + * + * @param district + * @return + */ + private boolean hasGeoPoint(District district) { + return district.getLat() != null && district.getLng() != null && district.getLat() != 0 + && district.getLng() != 0; + } - /** - * 调用匹配接口匹配小区 - * - * @param city - * @param address - * @param region - * @param name - * @return - */ - private District matchDistrict(String city, String address, String region, String name) { + /** + * 调用匹配接口匹配小区 + * + * @param city + * @param address + * @param region + * @param name + * @return + */ + private District matchDistrict(String city, String address, String region, String name) { - Map params = new HashMap(); - params.put("city", city); - params.put("token", APIConstant.SUPER_USER_TOKEN); - params.put("address", address); - params.put("category", "property"); - if (StringUtils.isNotBlank(region)) { - params.put("suggestDistrict", region); - } - if(StringUtils.isNotBlank(name)){ - params.put("suggestName", name); - } - String content = addressMatchProxyService.parser(params); - if (StringUtils.isBlank(content)) { - return null; - } - JSONObject json = JSONObject.fromObject(content); - if (json.getInt("code") != 200) { - return null; - } - JSONObject result = json.getJSONObject("result"); - if (result.getDouble("credit") > 0.5) { - return districtService.findById(result.getString("id")); - } - return null; - } + Map params = new HashMap(); + params.put("city", city); + params.put("token", APIConstant.SUPER_USER_TOKEN); + params.put("address", address); + params.put("category", "property"); + if (StringUtils.isNotBlank(region)) { + params.put("suggestDistrict", region); + } + if (StringUtils.isNotBlank(name)) { + params.put("suggestName", name); + } + String content = addressMatchProxyService.parser(params); + if (StringUtils.isBlank(content)) { + return null; + } + JSONObject json = JSONObject.fromObject(content); + if (json.getInt("code") != 200) { + return null; + } + JSONObject result = json.getJSONObject("result"); + if (result.getDouble("credit") > 0.5) { + return districtService.findById(result.getString("id")); + } + return null; + } - public Object detailAction(PropertySearchModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getId()) - && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) - || StringUtils.isBlank(model.getName())) - && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) - || StringUtils.isBlank(model.getAddress()))) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:请输入正确的参数组合")); - return mav; - } - String userId = FangjiaApiUtil.parseUserId(model.getToken()); + public Object detailAction(PropertySearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId()) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getName())) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getAddress()))) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:请输入正确的参数组合")); + return mav; + } + String userId = FangjiaApiUtil.parseUserId(model.getToken()); - District district = null; - if (StringUtils.isNotBlank(model.getId())){ - if(ObjectId.isValid(model.getId())){ - district = districtService.findById(model.getId()); - }else{ - mav.setModel(BasicModel.buildBadRequestModel("非法的住宅ID")); - return mav; - } - } + District district = null; + if (StringUtils.isNotBlank(model.getId())) { + if (ObjectId.isValid(model.getId())) { + district = districtService.findById(model.getId()); + } else { + mav.setModel(BasicModel.buildBadRequestModel("非法的住宅ID")); + return mav; + } + } - if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) - && StringUtils.isNotBlank(model.getName())) { - district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district != null) { - district = districtService.findById(district.getId()); - } - } + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getName())) { + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district != null) { + district = districtService.findById(district.getId()); + } + } - if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) - && StringUtils.isNotBlank(model.getAddress())) { - Map result = addressParser.parse2(model.getCity(), model.getAddress(), "district", false); - saveAddressMatchLog(result, model.getAddress(), model.getCity(), model.getToken()); - Integer status = (Integer) result.get("status"); - Integer precise = (Integer) result.get("precise"); - if (status != null && status == 0 && precise == 0) { - String id = (String) result.get("id"); - district = districtService.findById(id); - } - } + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getAddress())) { + Map result = addressParser.parse2(model.getCity(), model.getAddress(), "district", false); + saveAddressMatchLog(result, model.getAddress(), model.getCity(), model.getToken()); + Integer status = (Integer) result.get("status"); + Integer precise = (Integer) result.get("precise"); + if (status != null && status == 0 && precise == 0) { + String id = (String) result.get("id"); + district = districtService.findById(id); + } + } - if (district != null) { - fieldFilterService.filterWithProcessNUll(district); - DistrictInfoDto districtInfoDto = new DistrictInfoDto(); - if (model.getDetailLevel() == null || model.getDetailLevel() >= 0) { - districtInfoDto.setId(district.getId()); - districtInfoDto.setCity(district.getCity()); - districtInfoDto.setDistrict(district.getRegion()); - districtInfoDto.setName(district.getName()); - districtInfoDto.setAddress(district.getAddress()); - int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); - if (avgPrice != 0) { - districtInfoDto.setAvgPrice(avgPrice); - } - districtInfoDto.setPropertyType(district.getEstateType2()); - if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null - && district.getLng2() != 0) { - districtInfoDto.setLat(district.getLat2() / 10000000000D); - districtInfoDto.setLng(district.getLng2() / 10000000000D); - } - } + if (district != null) { + fieldFilterService.filterWithProcessNUll(district); + DistrictInfoDto districtInfoDto = new DistrictInfoDto(); + if (model.getDetailLevel() == null || model.getDetailLevel() >= 0) { + districtInfoDto.setId(district.getId()); + districtInfoDto.setCity(district.getCity()); + districtInfoDto.setDistrict(district.getRegion()); + districtInfoDto.setName(district.getName()); + districtInfoDto.setAddress(district.getAddress()); + int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + if (avgPrice != 0) { + districtInfoDto.setAvgPrice(avgPrice); + } + districtInfoDto.setPropertyType(district.getEstateType2()); + if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null + && district.getLng2() != 0) { + districtInfoDto.setLat(district.getLat2() / 10000000000D); + districtInfoDto.setLng(district.getLng2() / 10000000000D); + } + } - districtInfoDto.setBlock(district.getBlock()); - districtInfoDto.setLoopLine(district.getLoopLineInfo()); - if (HouseValidator.validateBuildingType(district.getBuildType())) { - districtInfoDto.setBuildingType(district.getBuildType()); - } else { - districtInfoDto.setBuildingType(""); - } - districtInfoDto.setAlias(district.getMappingAlias()); - districtInfoDto.setAddressAlias(district.getAddrAlias()); - districtInfoDto.setCommunity(district.getStreetCommunity()); - districtInfoDto.setCommercialArea(district.getBusinessQuarter()); - if (district.getHouseholdCount() != null) { - districtInfoDto.setTotalUnitCount(SeaweedUtils.formatHouseholdCount(district.getHouseholdCount().toString())); - } else { - districtInfoDto.setTotalUnitCount(""); - } - districtInfoDto.setManagementFee(district.getEstateCharge()); - if (district.getCarSiteCount() != null) { - districtInfoDto.setParking(SeaweedUtils.formatCarSiteCount(district.getCarSiteCount().toString())); - } else { - districtInfoDto.setParking(""); - } - districtInfoDto.setParkingDescription(district.getCarSite()); - districtInfoDto.setOwnershipPeriod(district.getPropertyLife()); - districtInfoDto.setOwnershipType(district.getHouseProperty()); - districtInfoDto.setStartBuildTime(district.getStartBuildingDate()); - if (district.getOpenDate() != null) { - Date minDate = DateUtil.parseDate("1900-01-01", "yyyy-MM-dd"); - Date maxDate = DateUtil.parseDate("2025-01-01", "yyyy-MM-dd"); - if (district.getOpenDate().after(minDate) && district.getOpenDate().before(maxDate)) { - districtInfoDto - .setStartSellingTime(DateUtil.formatByPattern(district.getOpenDate(), "yyyy-MM-dd")); - } - } else { - districtInfoDto.setStartSellingTime(""); - } + districtInfoDto.setBlock(district.getBlock()); + districtInfoDto.setLoopLine(district.getLoopLineInfo()); + if (HouseValidator.validateBuildingType(district.getBuildType())) { + districtInfoDto.setBuildingType(district.getBuildType()); + } else { + districtInfoDto.setBuildingType(""); + } + districtInfoDto.setAlias(district.getMappingAlias()); + districtInfoDto.setAddressAlias(district.getAddrAlias()); + districtInfoDto.setCommunity(district.getStreetCommunity()); + districtInfoDto.setCommercialArea(district.getBusinessQuarter()); + if (district.getHouseholdCount() != null) { + districtInfoDto.setTotalUnitCount(SeaweedUtils.formatHouseholdCount(district.getHouseholdCount().toString())); + } else { + districtInfoDto.setTotalUnitCount(""); + } + districtInfoDto.setManagementFee(district.getEstateCharge()); + if (district.getCarSiteCount() != null) { + districtInfoDto.setParking(SeaweedUtils.formatCarSiteCount(district.getCarSiteCount().toString())); + } else { + districtInfoDto.setParking(""); + } + districtInfoDto.setParkingDescription(district.getCarSite()); + districtInfoDto.setOwnershipPeriod(district.getPropertyLife()); + districtInfoDto.setOwnershipType(district.getHouseProperty()); + districtInfoDto.setStartBuildTime(district.getStartBuildingDate()); + if (district.getOpenDate() != null) { + Date minDate = DateUtil.parseDate("1900-01-01", "yyyy-MM-dd"); + Date maxDate = DateUtil.parseDate("2025-01-01", "yyyy-MM-dd"); + if (district.getOpenDate().after(minDate) && district.getOpenDate().before(maxDate)) { + districtInfoDto + .setStartSellingTime(DateUtil.formatByPattern(district.getOpenDate(), "yyyy-MM-dd")); + } + } else { + districtInfoDto.setStartSellingTime(""); + } - districtInfoDto.setFinishBuildTime(district.getFinishBuildingDate()); - districtInfoDto.setMoveinTime(district.getLiveDate()); - districtInfoDto.setFloorSpace(SeaweedUtils.formatAllArea(district.getAllArea())); - districtInfoDto.setConstructionSpace(district.getBuildArea()); - districtInfoDto.setPlotRatio(SeaweedUtils.formatCubagePercent(district.getCubagePercent())); - districtInfoDto.setGreenPercentage(SeaweedUtils.formatVirescencePercent(district.getVirescencePercent())); - districtInfoDto.setPreSalePermit(district.getLicence()); - districtInfoDto.setDeveloper(district.getDeveloper()); - districtInfoDto.setDiscount(district.getDiscount()); - districtInfoDto.setPropertyManagement(district.getEstateCompany()); - if (HouseValidator.fetchFitmentInfo(district.getFitment()) == null) { - districtInfoDto.setDecorationStandard(""); - } else { - districtInfoDto.setDecorationStandard(HouseValidator.fetchFitmentInfo(district.getFitment())); - } - districtInfoDto.setBuildingStructure(district.getBuildStructure()); - districtInfoDto.setSupportingFacilities(district.getFacilities()); - districtInfoDto.setTransportation(district.getTraffic()); - districtInfoDto.setRelatedInfo(district.getRelateInfo()); - districtInfoDto.setDescription(district.getDescription()); - districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); - districtInfoDto.setSalesPhoneNumber(district.getMobile()); - districtInfoDto.setTownship(district.getTownship()); - if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { - districtInfoDto.setBuildingCount(district.getLoudongCount()); - } + districtInfoDto.setFinishBuildTime(district.getFinishBuildingDate()); + districtInfoDto.setMoveinTime(district.getLiveDate()); + districtInfoDto.setFloorSpace(SeaweedUtils.formatAllArea(district.getAllArea())); + districtInfoDto.setConstructionSpace(district.getBuildArea()); + districtInfoDto.setPlotRatio(SeaweedUtils.formatCubagePercent(district.getCubagePercent())); + districtInfoDto.setGreenPercentage(SeaweedUtils.formatVirescencePercent(district.getVirescencePercent())); + districtInfoDto.setPreSalePermit(district.getLicence()); + districtInfoDto.setDeveloper(district.getDeveloper()); + districtInfoDto.setDiscount(district.getDiscount()); + districtInfoDto.setPropertyManagement(district.getEstateCompany()); + if (HouseValidator.fetchFitmentInfo(district.getFitment()) == null) { + districtInfoDto.setDecorationStandard(""); + } else { + districtInfoDto.setDecorationStandard(HouseValidator.fetchFitmentInfo(district.getFitment())); + } + districtInfoDto.setBuildingStructure(district.getBuildStructure()); + districtInfoDto.setSupportingFacilities(district.getFacilities()); + districtInfoDto.setTransportation(district.getTraffic()); + districtInfoDto.setRelatedInfo(district.getRelateInfo()); + districtInfoDto.setDescription(district.getDescription()); + districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); + districtInfoDto.setSalesPhoneNumber(district.getMobile()); + districtInfoDto.setTownship(district.getTownship()); + if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { + districtInfoDto.setBuildingCount(district.getLoudongCount()); + } // Integer finishYear = districtService.getBuildYear(district); - Integer finishYear = districtService.getCreateYear(district); - if (finishYear != null) { - districtInfoDto.setFinishYear(finishYear); - } - - mav.setModel(BasicModel.buildOKModel().setResult(districtInfoDto)); - return mav; - } - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - - - public Object detail2Action(PropertySearchModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getId()) - && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) - || StringUtils.isBlank(model.getName())) - && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) - || StringUtils.isBlank(model.getAddress()))) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:请输入正确的参数组合")); - return mav; - } - - District district = null; - if (StringUtils.isNotBlank(model.getId())){ - if(ObjectId.isValid(model.getId())){ - district = districtService.findById(model.getId()); - }else{ - mav.setModel(BasicModel.buildBadRequestModel("非法的住宅ID")); - return mav; - } - } - - if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) - && StringUtils.isNotBlank(model.getName())) { - district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district != null) { - district = districtService.findById(district.getId()); - } - } - - if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) - && StringUtils.isNotBlank(model.getAddress())) { - Map result = addressParser.parse2(model.getCity(), model.getAddress(), "district", false); - saveAddressMatchLog(result, model.getAddress(), model.getCity(), model.getToken()); - Integer status = (Integer) result.get("status"); - Integer precise = (Integer) result.get("precise"); - if (status != null && status == 0 && precise == 0) { - String id = (String) result.get("id"); - district = districtService.findById(id); - } - } - - if (district != null) { - fieldFilterService.filterWithProcessNUll(district); - DistrictInfoDto districtInfoDto = new DistrictInfoDto(); - districtInfoDto.setId(district.getId()); - districtInfoDto.setCity(district.getCity()); - districtInfoDto.setDistrict(district.getRegion()); - districtInfoDto.setName(district.getName()); - districtInfoDto.setAlias(district.getMappingAlias()); - districtInfoDto.setAddress(district.getAddress()); - districtInfoDto.setAddressAlias(district.getAddrAlias()); - if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null - && district.getLng2() != 0) { - districtInfoDto.setLat2(district.getLat2() / 10000000000D); - districtInfoDto.setLng2(district.getLng2() / 10000000000D); - } - if (district.getLat() != null && district.getLat() != 0 && district.getLng() != null - && district.getLng() != 0) { - districtInfoDto.setLat(district.getLat() / 10000000000D); - districtInfoDto.setLng(district.getLng() / 10000000000D); - } - districtInfoDto.setPropertyType(district.getEstateType2()); - if (HouseValidator.validateBuildingType(district.getBuildType())) { - districtInfoDto.setBuildingType(district.getBuildType()); - } else { - districtInfoDto.setBuildingType(""); - } - districtInfoDto.setBlock(district.getBlock()); - districtInfoDto.setTownship(district.getTownship()); - if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { - districtInfoDto.setBuildingCount(district.getLoudongCount()); - } - - if (district.getHouseholdCount() != null) { - districtInfoDto.setTotalUnitCount(SeaweedUtils.formatHouseholdCount(district.getHouseholdCount().toString())); - } else { - districtInfoDto.setTotalUnitCount(""); - } - districtInfoDto.setManagementFee(district.getEstateCharge()); - if (district.getCarSiteCount() != null) { - districtInfoDto.setParking(SeaweedUtils.formatCarSiteCount(district.getCarSiteCount().toString())); - } else { - districtInfoDto.setParking(""); - } - districtInfoDto.setOwnershipPeriod(district.getPropertyLife()); - districtInfoDto.setOwnershipType(district.getHouseProperty()); - districtInfoDto.setBuildingStructure(district.getBuildStructure()); - districtInfoDto.setLandProperty(district.getLandProperty()); - districtInfoDto.setFloorSpace(SeaweedUtils.formatAllArea(district.getAllArea())); - districtInfoDto.setConstructionSpace(district.getBuildArea()); - districtInfoDto.setPlotRatio(SeaweedUtils.formatCubagePercent(district.getCubagePercent())); - districtInfoDto.setGreenPercentage(SeaweedUtils.formatVirescencePercent(district.getVirescencePercent())); - districtInfoDto.setDeveloper(district.getDeveloper()); - districtInfoDto.setPropertyManagement(district.getEstateCompany()); - - Integer finishYear = districtService.getCreateYear(district); - if (finishYear != null) { - districtInfoDto.setFinishYear(finishYear); - } - - mav.setModel(BasicModel.buildOKModel().setResult(districtInfoDto)); - return mav; - } - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - - private void saveAddressMatchLog(Map resMap, String keywords, String city, String token) { - Map tokenMap = FangjiaApiUtil.parseToken(token); - String userName = null; - // token验证后,拿取出的字段再去数据库验证一遍 - if (tokenMap != null && StringUtils.isNotBlank(tokenMap.get("userid")) - && !"null".equals(tokenMap.get("userid"))) { - User user = userService.findById(Long.parseLong(tokenMap.get("userid"))); - if (user != null) { - userName = user.getUserName(); - } - } - // 记录用户搜索词open匹配结果 - HttpServletRequest request = ActionContext.getContext().getRequest(); - AddressMatchLog addressMatchLog = new AddressMatchLog(); - addressMatchLog.setCity(city); - addressMatchLog.setInput(keywords); - addressMatchLog.setIp(AnalyticsUtil.getIpAddress(request)); - addressMatchLog.setSource("API"); - addressMatchLog.setUserName(userName); - addressMatchLog.setCreationDate(new Date()); - addressMatchLog.setModificationDate(new Date()); - if (MapUtils.isNotEmpty(resMap)) { - if (resMap.containsKey("status") && (Integer) resMap.get("status") == 0) { - List> result = new ArrayList>(); - Map map = new HashMap(); - map.put("city", (String) resMap.get("city")); - map.put("region", (String) resMap.get("region")); - map.put("name", (String) resMap.get("name")); - result.add(map); - addressMatchLog.setResult(result); - } else { - addressMatchLog.setStatus(1); - } - } else { - addressMatchLog.setStatus(1); - } - addressMatchLogService.addAddressMatchLog(addressMatchLog); - } - - @Authority(role = Role.NONE) - public Object sampleEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - EvaluationBo evaluationBo = evaluationService.doApply(buildEvaluation(model, request), true, false, true); - if (evaluationBo != null && evaluationBo.getSampleModeValue() > 0) { - UniversalDto dto = UniversalDto.newDto(); - dto.put("city", district.getCity()); - dto.put("district", district.getRegion()); - dto.put("name", district.getName()); - dto.put("totalPrice", evaluationBo.getSampleModeValue()); - dto.put("avgPrice", evaluationBo.getSampleModeValue() / model.getSize()); - mav.setModel(BasicModel.buildOKModel().setResult(dto)); - return mav; - } - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - - public Object evaluateAction(PropertyEvaluationModel model, HttpServletRequest request) - throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { - - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - if(model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())){ - district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "district"); - } - if(district == null){ - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - } - model.setName(district.getName()); - - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - if(model.getFloor() == null){ - JSONObject structureOb = addressMatchProxyService.addressStructure(district.getCity(), model.getAddress()); - if(structureOb != null){ - if(structureOb.containsKey("buildingNumber")){ - model.setBuildingNumber(structureOb.getString("buildingNumber")); - } - - if(structureOb.containsKey("roomNumber")){ - String roomNumber = structureOb.getString("roomNumber"); - model.setFloor(getFloor(roomNumber)); - } - - } - } - - if(model.getMaxFloor() == null && model.getFloor() != null &&StringUtils.isNotBlank(model.getBuildingNumber())){ - Loudong loudong = loudongService.findForEvaluate(district.getId(), model.getBuildingNumber(), model.getUnitNumber()); - if(loudong != null && loudong.getFloors() >= model.getFloor()){ - model.setMaxFloor(loudong.getFloors()); - } - } - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - - - Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), - model.getCalDate()); - Double cityPriceCredit = null; - if (StringUtils.isNotBlank(evaluation.getFromUserId())) { - try { - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority.getCityCreditMap() != null - && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { - cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); - if (cityPriceCredit > 1 || cityPriceCredit < 0) { - cityPriceCredit = null; - } - } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - this.adjustPriceByRatio(district, evaluation); - } - - // 调整面积不同面积价格 - try { - DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district)); - int orgAvgPrice = 0; - if (districtStatBo != null) { - if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) { - orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); - } else if (districtStatBo.getDistrictStat() != null) { - orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); - } - } - if (evaluation != null && evaluation.getAvgPrice() != null && evaluation.getAvgPrice() > 0) { - int factorPrice = evaluation.getAvgPrice(); - int avgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), evaluation.getArea(), factorPrice, orgAvgPrice); - Integer minPrice = (int)(evaluation.getAvgPrice() * 0.95); - Integer maxPrice = (int)(evaluation.getAvgPrice() * 1.05); - // 偏离度超过5%不进行调整 - if (minPrice <= avgPrice && avgPrice <= maxPrice) { - evaluation.setAvgPrice(avgPrice); - evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea())); - } - } - } catch (Exception ex) { - LOGGER.error("调整面积不同面积价格异常{}", ex.getMessage()); - } - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 - && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - - // 根据城市等 级设置D级可信度 - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() - && apiUserAuthority.getCreditLevelStatus() == 1) { - double dCredit = 0.61; - if (null != apiUserAuthority.getPriceRatingMap()) { - ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); - Map rateMap = apiUserAuthority.getPriceRatingMap(); - if (null != rateMap) { - dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); - } - } - Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - if (null != rMap) { - if (rMap.containsKey("level")) { - districtPriceMap.put("level", rMap.get("level")); - } - if (rMap.containsKey("other_price")) { - districtPriceMap.put("other_price", rMap.get("other_price")); - } - } - } - - Long lastPrice = (Long) rMap.get("lastPrice"); - - if (null != lastPrice) { - districtPriceMap.put("totalPrice", lastPrice); - if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { - districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); - } - } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - - } else { - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - } - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); - districtPriceMap.put("credit", evaluation.getCredit()); - districtPriceMap.put("id", evaluation.getId()); - } - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - try{ - if(StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")){ - openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/property/evaluate"); - } - - }catch(Exception e){ - e.printStackTrace(); - } - - return mav; - } else { - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - } - - /** - * 系数下调 - * - * @param district - * @param evaluation - */ - private void adjustPriceByRatio(District district, Evaluation evaluation) { - - try { - ApiUserCfg apiUserCfg_pt = apiUserCfgService.findByUserId(Long.valueOf(evaluation.getFromUserId()), ApiUserCfg.ApiUserCfgKey.PRICE_TYPE); - if (apiUserCfg_pt != null && apiUserCfg_pt.getCfgValue() != null) { - String priceType = apiUserCfg_pt.getCfgValue().toString(); - // 评估价则系数调整 - if (StringUtils.isNotBlank(priceType) && "evaluate".equals(priceType)) { - EvaluateRatio evaluateRatio = null; - if (StringUtils.isNotBlank(district.getRegion())) { - evaluateRatio = evaluateRatioService.findByCityAndRegion(district.getCity(), district.getRegion()); - } - if (evaluateRatio == null) { - evaluateRatio = evaluateRatioService.findByCity(district.getCity()); - } - if (evaluateRatio != null) { - // 系数添加 - long totalPrice = evaluation.getBigTotalPrice(); - totalPrice = (long) (totalPrice * (1 + evaluateRatio.getRatio())); - evaluation.setBigTotalPrice(totalPrice); - evaluation.setAvgPrice((int) (totalPrice / evaluation.getArea())); - } - } - } - } catch (Exception ex) { - LOGGER.error("系数下调异常{}", ex.getMessage()); - } - } - - static final Map CITY_CORRECTION_FACTOR = new HashMap(); - static { - CITY_CORRECTION_FACTOR.put("上海", 0.02); - CITY_CORRECTION_FACTOR.put("杭州", 0.1); - CITY_CORRECTION_FACTOR.put("大连", 0.09); - CITY_CORRECTION_FACTOR.put("广州", 0.09); - CITY_CORRECTION_FACTOR.put("深圳", 0.02); - CITY_CORRECTION_FACTOR.put("重庆", 0.1); - CITY_CORRECTION_FACTOR.put("苏州", 0.08); - CITY_CORRECTION_FACTOR.put("成都", 0.07); - CITY_CORRECTION_FACTOR.put("北京", 0.04); - CITY_CORRECTION_FACTOR.put("厦门", 0.1); - } - - public Object evaluateForTestAction(PropertyEvaluationModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("城市为必填项")); - return mav; - } - if (model.getSize() <= 0){ - mav.setModel(BasicModel.buildBadRequestModel("面积为必填项")); - return mav; - } - if(StringUtils.isBlank(model.getAddress()) && StringUtils.isBlank(model.getName())){ - mav.setModel(BasicModel.buildBadRequestModel("地址和小区名至少填一个")); - return mav; - } - if(StringUtils.isNotBlank(model.getName()) && StringUtils.isBlank(model.getAddress())){ - model.setAddress(model.getName()); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = DateUtil.parseDate(request.getParameter("calDate"), "yyyy-MM-dd"); - model.setCalDate(calDate); - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findDistrict(new DistrictKey(model.getCity(), model.getDistrict(), model.getName()), "district");//matchDistrict(model.getCity(), model.getAddress(), model.getDistrict(), model.getName()); - if(district == null){ - //防止地址模糊,名称详细的情况 - district = matchDistrict(model.getCity(), model.getName(), model.getDistrict(), model.getAddress()); - if(district == null){ - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - } - model.setName(district.getName()); - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); - if(!"self".equalsIgnoreCase(evaluation.getEvaluateWay())){ - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - - this.adjustPriceByRatio(district, evaluation); - - // 调整面积不同面积价格 - try { - DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district)); - int orgAvgPrice = 0; - if (districtStatBo != null) { - if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) { - orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); - } else if (districtStatBo.getDistrictStat() != null) { - orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); - } - } - if (evaluation != null && evaluation.getAvgPrice() != null && evaluation.getAvgPrice() > 0) { - int factorPrice = evaluation.getAvgPrice(); - int avgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), evaluation.getArea(), factorPrice, orgAvgPrice); - Integer minPrice = (int)(evaluation.getAvgPrice() * 0.95); - Integer maxPrice = (int)(evaluation.getAvgPrice() * 1.05); - // 偏离度超过5%不进行调整 - if (minPrice <= avgPrice && avgPrice <= maxPrice) { - evaluation.setAvgPrice(avgPrice); - evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea())); - } - } - } catch (Exception ex) { - - } - Map districtPriceMap = new LinkedHashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - districtPriceMap.put("unitPrice", evaluation.getAvgPrice()); - // 新增置信度 - CommunityBasePrice communityBasePrice = communityBasePriceService.getById(district.getId()); - if (communityBasePrice != null) { - districtPriceMap.put("credit", communityBasePrice.getCredit()); - } else { - districtPriceMap.put("credit", evaluation.getCredit()); - } - List names = new ArrayList(); - names.add(district.getName()); - if(district.getAlias() != null){ - for(String alia : district.getAlias()){ - if(StringUtils.isNotBlank(alia) && !names.contains(alia)){ - names.add(alia); - } - } - } - Integer minPrice = (int)(evaluation.getAvgPrice() * 0.8); - Integer maxPrice = (int)(evaluation.getAvgPrice() * 1.2); - Integer min10Price = (int)(evaluation.getAvgPrice() * 0.9); - Integer max10Price = (int)(evaluation.getAvgPrice() * 1.1); - // 新增第三方均价 - try { - double dCredit = 0.61; - Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); - if (null != rMap) { - if (rMap.containsKey("other_price")) { - Map otherPriceMap = (Map) rMap.get("other_price"); - Map priceResultMap = new HashMap(); - for (String key : otherPriceMap.keySet()) { - Integer price = otherPriceMap.get(key); - // 剔除偏差大于10的 - if (min10Price <= price && max10Price >= price) { - if (OTHER_PRICE_MAP.containsKey(key)) { - priceResultMap.put(OTHER_PRICE_MAP.get(key), price); - } - } - } - districtPriceMap.put("otherPrice", priceResultMap); - } - } - } catch (Exception ex) { - - } - List houses = seawaterDao.findHouses(district.getCity(), district.getRegion(), names,minPrice, maxPrice, 20); - if(houses.size() > 3){ - districtPriceMap.put("calcType", 1); - List houseDtos = new ArrayList(); - for(Seawater seawater: houses){ - UniversalDto houseDto = new UniversalDto(); - houseDto.append("city", seawater.getCity()); - houseDto.append("district", seawater.getRegion()); - houseDto.append("name", seawater.getDistrictName()); - houseDto.append("title", seawater.getName()); - houseDto.append("size", seawater.getArea()); - houseDto.append("unitPrice", seawater.getAvgPrice()); - houseDto.append("totalPrice", seawater.getTotalPrice()); - houseDto.append("room", seawater.getRoom()); - houseDto.append("hall", seawater.getHall()); - houseDto.append("toilet", seawater.getToilet()); - houseDto.append("direction", HouseValidator.fetchDirectionInfo(seawater.getDirection())); - houseDto.append("decoration", HouseValidator.fetchFitmentInfo(seawater.getFitment())); - houseDto.append("publishDate", seawater.getpDate()); - if(seawater.getHeight() != null && seawater.getHeight() > 0){ - houseDto.append("maxFloor", seawater.getHeight()); - } - houseDtos.add(houseDto); - } - districtPriceMap.put("houses", houseDtos); - }else if(district.getLng() != null && district.getLng() > 0){ - double lng = DataUtil.roundDouble(district.getLng() / 10000000000.0,6); - double lat = DataUtil.roundDouble(district.getLat() / 10000000000.0, 6); - List districts = districtService.findNearestDistrict(district.getEstateType2(), lng, lat, 1000 * 3 , 6, null); - if(districts.size() < 2){ - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - UniversalDto modelFeaturesFto = UniversalDto.newDto(); - districtPriceMap.put("calcType", 2); - modelFeaturesFto.append("propertyType", district.getEstateType2()); - modelFeaturesFto.append("lng", lng); - modelFeaturesFto.append("lat", lat); - DistrictAnalyData districtAnalyData = districtAnalyDataService.findByDistrictKey(new DistrictKey(district)); - if(districtAnalyData != null && districtAnalyData.getHalfYearMarkup() != null){ - modelFeaturesFto.append("halfYearMarkup", DataUtil.roundDouble(districtAnalyData.getHalfYearMarkup() * 100 ,2)); - } - RegionAnaData regionAnaData = regionAnaDataService.findRegionAnaData(district.getCity(), district.getRegion()); - if(regionAnaData != null){ - modelFeaturesFto.append("region20PercentPrice", regionAnaData.getRegion20PercentPrice()); - modelFeaturesFto.append("region80PercentPrice", regionAnaData.getRegion80PercentPrice()); - } - List nearCommunityDtos = new ArrayList(); - for(District d : districts){ - if(d.getId().equals(district.getId())){ - continue; - } - UniversalDto districtDto = UniversalDto.newDto(); - districtDto.append("city", d.getCity()); - districtDto.append("region", d.getRegion()); - districtDto.append("name", d.getName()); - districtDto.append("lng", DataUtil.roundDouble(d.getLng()/10000000000.0 ,6)); - districtDto.append("lat", DataUtil.roundDouble(d.getLat()/10000000000.0, 6)); - districtDto.append("distance", GeoUtils.calculateDistance(lng, lat, d.getLng()/10000000000.0, d.getLat()/10000000000.0)); - districtDto.append("propertyType", d.getEstateType2()); - Integer buildYear = districtService.getBuildYear(d); - if(buildYear != null){ - districtDto.append("buildYear", String.valueOf(buildYear)); - } - districtAnalyData = districtAnalyDataService.findByDistrictKey(new DistrictKey(d)); - if(districtAnalyData != null){ - if (districtAnalyData.getHalfYearMarkup() != null) { - districtDto.append("halfYearMarkup", DataUtil.roundDouble(districtAnalyData.getHalfYearMarkup() * 100, 2)); - } - if (districtAnalyData.getAvgPrice() != null && minPrice <= districtAnalyData.getAvgPrice() && maxPrice >= districtAnalyData.getAvgPrice()) { - districtDto.append("avgPrice", districtAnalyData.getAvgPrice()); - } - } - - nearCommunityDtos.add(districtDto); - } - Integer buildYear = districtService.getBuildYear(district); - if(buildYear != null){ - modelFeaturesFto.put("buildYear", String.valueOf(buildYear)); - } - modelFeaturesFto.append("nearCommunity", nearCommunityDtos); - - // 模型特征新增周边数量 - CommunityPoi communityPoi = communityPoiService.getById(district.getId()); - if (communityPoi != null) { - modelFeaturesFto.put("subway", communityPoi.getSubway()); - modelFeaturesFto.put("traffic", communityPoi.getTraffic()); - modelFeaturesFto.put("bank", communityPoi.getBank()); - modelFeaturesFto.put("primary", communityPoi.getPrimary()); - modelFeaturesFto.put("hospital", communityPoi.getHospital()); - modelFeaturesFto.put("junior", communityPoi.getJunior()); - modelFeaturesFto.put("funeral", communityPoi.getFuneral()); - } - districtPriceMap.put("modelFeatures", modelFeaturesFto); - } - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } - /** - * 地址估值 - * @param model 参数 - * @param request - * @return - */ - public Object addressEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) throws IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项")); - return mav; - } - if(model.getDistrict()!=null){ - //区域编码转房价网区域 - FangjiaOfficialAreaMap fangjiaOfficialAreaMap = fangjiaOfficialAreaService.convertOfficialCodeToFangjia(model.getDistrict()); - if(fangjiaOfficialAreaMap != null){ - model.setDistrict(fangjiaOfficialAreaMap.getFangjiaDistrict()); - } - } - - boolean villaFlag = DataUtil.isVilla(model.getSize(), model.getName(), model.getHeight(), model.getRoom()); - - District district = null; - Map params = new HashMap(); - params.put("city", model.getCity()); - if(StringUtils.isNotBlank(model.getDistrict())){ - params.put("suggestDistrict", model.getDistrict()); - } - params.put("address", model.getAddress()); - if(StringUtils.isNotBlank(model.getName())){ - params.put("suggestName", model.getName()); - } - params.put("category", "district"); - String result = addressMatchProxyService.parser(params); - if (result != null) { - JSONObject json = JSONObject.fromObject(result); - if(json.getInt("code")==200){ - Map map = (Map) json.get("result"); - if((Integer)map.get("precise")>=0){ - String propertyType = (String) map.get("propertyType"); - if(villaFlag && StringUtils.isNotBlank(propertyType) && !propertyType.equals("别墅")){ - district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name")+"别墅", "district"); - } - if(null == district){ - district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name"), "district"); - } - - } - } - } - - if(district == null){ - mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); - return mav; - } - model.setDistrict(district.getRegion()); - model.setName(district.getName()); - return this.evaluateAction(model,request); - } - - public Object evaluate2Action(PropertyEvaluationModel model, HttpServletRequest request) - throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { - - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); - Double cityPriceCredit = null; - if (StringUtils.isNotBlank(evaluation.getFromUserId())) { - try { - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority.getCityCreditMap() != null - && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { - cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); - if (cityPriceCredit > 1 || cityPriceCredit < 0) { - cityPriceCredit = null; - } - } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 - && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { - - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - - // 根据城市等 级设置D级可信度 - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() - && apiUserAuthority.getCreditLevelStatus() == 1) { - double dCredit = 0.61; - if (null != apiUserAuthority.getPriceRatingMap()) { - ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); - Map rateMap = apiUserAuthority.getPriceRatingMap(); - if (null != rateMap) { - dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); - } - } - Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - if (null != rMap) { - if (rMap.containsKey("level")) { - districtPriceMap.put("level", rMap.get("level")); - } - if (rMap.containsKey("other_price")) { - districtPriceMap.put("other_price", rMap.get("other_price")); - } - } - } - - Long lastPrice = (Long) rMap.get("lastPrice"); - if (null != lastPrice) { - districtPriceMap.put("totalPrice", lastPrice); - if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { - districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); - } - } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - - } else { - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - } - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); - districtPriceMap.put("credit", evaluation.getCredit()); - districtPriceMap.put("id", evaluation.getId()); - } - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - } - - /** - * 四川锦程 定制接口 多建筑年代 - * @param model - * @param request - * @return - * @throws NumberFormatException - * @throws IllegalAccessException - */ - public Object evaluate3Action(PropertyEvaluationModel model, HttpServletRequest request) - throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { - - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); - Double cityPriceCredit = null; - if (StringUtils.isNotBlank(evaluation.getFromUserId())) { - try { - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority.getCityCreditMap() != null - && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { - cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); - if (cityPriceCredit > 1 || cityPriceCredit < 0) { - cityPriceCredit = null; - } - } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 - && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { - - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - if(StringUtils.isNotBlank(district.getFinishBuildingDate())){ - Pattern pat3 = Pattern.compile("\\d{4}"); - Matcher matcher3 = pat3.matcher(district.getFinishBuildingDate()); - if (matcher3.find()) { - districtPriceMap.put("buildYear", matcher3.group()); - } - } - - - // 根据城市等 级设置D级可信度 - ApiUserAuthority apiUserAuthority = apiUserAuthorityService - .findByUserId(Long.valueOf(evaluation.getFromUserId())); - if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() - && apiUserAuthority.getCreditLevelStatus() == 1) { - double dCredit = 0.61; - if (null != apiUserAuthority.getPriceRatingMap()) { - ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); - Map rateMap = apiUserAuthority.getPriceRatingMap(); - if (null != rateMap) { - dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); - } - } - Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - if (null != rMap) { - if (rMap.containsKey("level")) { - districtPriceMap.put("level", rMap.get("level")); - } - if (rMap.containsKey("other_price")) { - districtPriceMap.put("other_price", rMap.get("other_price")); - } - } - } - - Long lastPrice = (Long) rMap.get("lastPrice"); - if (null != lastPrice) { - districtPriceMap.put("totalPrice", lastPrice); - if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { - districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); - } - } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - - } else { - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - } - - if (model.getScope() == EVALUATE_SHOW_DETAIL) { - districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); - districtPriceMap.put("credit", evaluation.getCredit()); - districtPriceMap.put("id", evaluation.getId()); - } - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); - return mav; - } - } - - @Authority(role = Role.USER) - public Object addBatchEvaluateTaskAction(BatchEvaluateModel model) throws IOException { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (model.getFile() == null || model.getFile().isEmpty()) { - mav.setModel(BasicModel.buildBadRequestModel("请上传包含待评估数据的数据文件")); - return mav; - } - MultipartFile file = model.getFile(); - - if (StringUtils.isNotBlank(model.getCharset()) && Charset.isSupported(model.getCharset())) { - mav.setModel(BasicModel.buildBadRequestModel("字符编码不支持")); - return mav; - } else { - model.setCharset("GBK"); - } - Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); - String userId = tokenMap.get("userid"); - DBObject dbFile = fileDao.save(file.getBytes(), file.getContentType()); - String fileId = (String) dbFile.get("_id"); - BatchEvaluateTask task = new BatchEvaluateTask(); - task.setDateCreated(new Date()); - task.setStatus(BatchEvaluateTask.StatusEnum.INIT.getStatus()); - task.setDataFileId(fileId); - task.setUserId(userId); - task.setFileName(file.getOriginalFilename()); - task.setCharset(model.getCharset()); - batchEvaluateService.saveBatchEvaluateTask(task); - Map data = new HashMap(); - data.put("taskId", task.getId()); - mav.setModel(BasicModel.buildOKModel().setResult(data)); - return mav; - } - - @Authority(role = Role.USER) - public Object batchEvaluateTaskStatusAction(BatchEvaluateModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getId()) || !ObjectId.isValid(model.getId())) { - mav.setModel(BasicModel.buildBadRequestModel("任务id非法")); - return mav; - } - Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); - String userId = tokenMap.get("userid"); - BatchEvaluateTask task = batchEvaluateService.findBatchEvaluateTaskById(model.getId()); - if (task == null || !task.getUserId().equals(userId)) { - mav.setModel(BasicModel.buildBadRequestModel("任务不存在")); - return mav; - } - Map data = new HashMap(); - data.put("status", task.getStatus()); - if (BatchEvaluateTask.StatusEnum.INIT.getStatus() == task.getStatus()) { - data.put("msg", "待处理"); - } else if (BatchEvaluateTask.StatusEnum.DOING.getStatus() == task.getStatus()) { - data.put("msg", "处理中"); - } else if (BatchEvaluateTask.StatusEnum.SUC.getStatus() == task.getStatus()) { - data.put("msg", "已完成"); - data.put("downLink", "http://open.fangjia.com/property/downEvaluateResult?id=" + task.getId() + "&token=" - + model.getToken()); - } else if (BatchEvaluateTask.StatusEnum.ERROR.getStatus() == task.getStatus()) { - data.put("msg", "处理失败"); - data.put("subMsg", task.getMsg()); - } - mav.setModel(BasicModel.buildOKModel().setResult(data)); - return mav; - } - - @Authority(role = Role.USER) - public Object downEvaluateResultAction(BatchEvaluateModel model, HttpServletResponse response) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getId()) || !ObjectId.isValid(model.getId())) { - mav.setModel(BasicModel.buildBadRequestModel("任务id非法")); - return mav; - } - Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); - - String userId = tokenMap.get("userid"); - BatchEvaluateTask task = batchEvaluateService.findBatchEvaluateTaskById(model.getId()); - if (task == null || !task.getUserId().equals(userId)) { - mav.setModel(BasicModel.buildBadRequestModel("任务不存在")); - return mav; - } - - DBObject file = fileDao.findById(task.getDataFileId()); - byte[] data = (byte[]) file.get("data"); - OutputStream os = null; - try { - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/x-gzip"); - String fileName = DateUtil.formatToYYYYMMDDhhmmss(new Date()) + ".csv.gz"; - response.setHeader("Content-Disposition", "attachment;filename=" + fileName); - os = response.getOutputStream();// 取得输出流 - os.write(data); - os.flush(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (os != null) { - os.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - ModelAndViewSupport mv = new ModelAndViewSupport(); - mv.setViewType("stream"); - return mv; - } - - @Authority(role = Role.NONE) - public Object batchEvaluateTemplateAction(BatchEvaluateModel model, HttpServletResponse response, - HttpServletRequest request) { - OutputStream os = null; - FileInputStream fis = null; - try { - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/csv"); - response.setHeader("Content-Disposition", "attachment;filename=batchEvaluateTemplate.csv"); - os = response.getOutputStream();// 取得输出流 - String path = request.getSession().getServletContext().getRealPath("") + File.separator + "WEB-INF" - + File.separator + "classes" + File.separator + "batchEvaluateTemplate.csv"; - File template = new File(path); - fis = new FileInputStream(template); - byte[] data = new byte[fis.available()]; - fis.read(data); - os.write(data); - os.flush(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (os != null) { - os.close(); - } - if (fis != null) { - fis.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - ModelAndViewSupport mv = new ModelAndViewSupport(); - mv.setViewType("stream"); - return mv; - } - - public Object evaluateShopAction(PropertyEvaluationModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "shop"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - if (model.getCalDate() != null) { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - Evaluation evaluation = evaluationService.evaluateWithPadding(buildEvaluation(model, request), - model.getCalDate()); - if (null != evaluation && evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - evaluationService.remove(evaluation.getId()); - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价")); - return mav; - } - } - - public Object filterAction(PropertySearchModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - District district = districtService.findById(model.getId()); - fieldFilterService.refresh(); - fieldFilterService.filterWithProcessNUll(district); - mav.setModel(BasicModel.buildOKModel().setResult(district)); - return mav; - } - - public Object houseRentAction(PropertyEvaluationModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getHouseType() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,房型(houseType)为必填项")); - return mav; - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - List evaluations = evaluationService.histroyRent(district, buildEvaluation(model, request), 1, - model.getHouseType()); - if (evaluations.isEmpty()) { - mav.setModel(BasicModel.buildOKModel().setMsg("暂无租金")); - } else { - Evaluation evaluation = evaluations.get(0); - JSONObject item = new JSONObject(); - item.put("city", district.getCity()); - item.put("district", district.getRegion()); - item.put("name", district.getName()); - item.put("rent", evaluation.getAvgPrice()); - item.put("changePercent", evaluation.getMarkup() / 100d); - mav.setModel(BasicModel.buildOKModel().setResult(item)); - } - return mav; - } - - public Object historyRentAction(PropertyEvaluationModel model, HttpServletRequest request) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getHouseType() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,房型(houseType)为必填项")); - return mav; - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - if (model.getPeriodCount() == null) { - model.setPeriodCount(1); - } - if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); - return mav; - } - - List evaluations = evaluationService.histroyRent(district, buildEvaluation(model, request), - model.getPeriodCount(), model.getHouseType()); - List historyEvaluations = new ArrayList(); - for (Evaluation evaluation : evaluations) { - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - JSONObject item = new JSONObject(); - item.put("city", district.getCity()); - item.put("district", district.getRegion()); - item.put("name", district.getName()); - item.put("rent", evaluation.getAvgPrice()); - item.put("changePercent", evaluation.getMarkup() / 100d); - item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM")); - historyEvaluations.add(item); - } - } - if (historyEvaluations.size() > model.getPeriodCount()) { - historyEvaluations = historyEvaluations.subList(historyEvaluations.size() - model.getPeriodCount(), - historyEvaluations.size()); - } - mav.setModel(BasicModel.buildOKModel().setResult(historyEvaluations)); - return mav; - - } - - public Object historyEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { - mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); - return mav; - } - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - if (model.getPeriodCount() == null) { - model.setPeriodCount(1); - } - if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); - return mav; - } - if (StringUtils.isBlank(model.getPeriodType())) { - model.setPeriodType("weekly"); - } else { - if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { - mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); - return mav; - } - } - Calendar calendar = Calendar.getInstance(); - if ("weekly".equals(model.getPeriodType())) { - calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); - } else { - calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); - - } - List evaluations = evaluationService.histroyEvaluate(district, buildEvaluation(model, request), - calendar.getTime(), model.getPeriodType()); - List historyEvaluations = new ArrayList(); - for (Evaluation evaluation : evaluations) { - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - JSONObject item = new JSONObject(); - item.put("city", district.getCity()); - item.put("district", district.getRegion()); - item.put("name", district.getName()); - item.put("totalPrice", evaluation.getBigTotalPrice()); - item.put("avgPrice", evaluation.getAvgPrice()); - item.put("changePercent", evaluation.getMarkup() / 100d); - if ("weekly".equals(model.getPeriodType())) { - item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM-dd")); - } else { - item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM")); - } - historyEvaluations.add(item); - } - } - if (historyEvaluations.size() > model.getPeriodCount()) { - historyEvaluations = historyEvaluations.subList(historyEvaluations.size() - model.getPeriodCount(), - historyEvaluations.size()); - } - mav.setModel(BasicModel.buildOKModel().setResult(historyEvaluations)); - return mav; - } - - public Object avgPriceAction(AvgPriceQueryModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - if (model.getPeriodCount() == null) { - model.setPeriodCount(1); - } - if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); - return mav; - } - if (StringUtils.isBlank(model.getPeriodType())) { - model.setPeriodType("weekly"); - } else { - if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { - mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); - return mav; - } - } - Calendar calendar = Calendar.getInstance(); - if ("weekly".equals(model.getPeriodType())) { - calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); - } else { - calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); - } - - List districtStats = districtStatService.findAllDistrictStatByNameWithPadding(district.getCity(), - district.getRegion(), district.getName(), district.getEstateType2(), calendar.getTime(), new Date(), - model.getPeriodType()); - if (districtStats.size() > model.getPeriodCount()) { - districtStats = districtStats.subList(districtStats.size() - model.getPeriodCount(), districtStats.size()); - } - List> result = new ArrayList>(model.getPeriodCount()); - for (DistrictStat districtStat : districtStats) { - Map item = new LinkedHashMap(); - item.put("city", districtStat.getCity()); - item.put("district", districtStat.getRegion()); - item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvgPrice()); - if ("monthly".equals(model.getPeriodType())) { - item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); - } else { - item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM-dd")); - } - item.put("changePercent", districtStat.getMarkup() / 100d); - result.add(item); - } - mav.setModel(BasicModel.buildOKModel().setResult(result)); - return mav; - } - - /** - * 小区租金查询接口 - * - * @param model - * @return - */ - public Object rentAction(AvgPriceQueryModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (model.getPeriodCount() == null) { - model.setPeriodCount(1); - } - if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); - return mav; - } - if (model.getHouseType() == null || model.getHouseType() < 1) { - mav.setModel(BasicModel.buildBadRequestModel("房屋类型不合法")); - return mav; - } - String estateType2 = "小区"; - if (district.getEstateType2().contains("别墅")) { - estateType2 = "别墅"; - } - List rents = districtStatRentService.findAllByDistrictKeyAndHouseType( - new DistrictKey(district), model.getHouseType(), estateType2, model.getPeriodCount()); - if (rents.isEmpty() && estateType2.equals("别墅")) { - estateType2 = "小区"; - rents = districtStatRentService.findAllByDistrictKeyAndHouseType(new DistrictKey(district), - model.getHouseType(), estateType2, model.getPeriodCount()); - } - List> result = new ArrayList>(model.getPeriodCount()); - for (DistrictStatRent districtStat : rents) { - Map item = new LinkedHashMap(); - item.put("city", districtStat.getCity()); - item.put("district", districtStat.getRegion()); - item.put("name", districtStat.getDistrictName()); - item.put("rent", districtStat.getAvgPrice()); - item.put("date", DateUtil.formatByPattern(districtStat.getEndMonthDate(), "yyyy-MM")); - item.put("houseType", districtStat.getHouseType()); - item.put("changePercent", districtStat.getMarkup() / 100d); - result.add(item); - } - mav.setModel(BasicModel.buildOKModel().setResult(result)); - return mav; - } - - public Object rankAction(final DealPriceModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - model.setCity(RegionData.formatCity(model.getCity())); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); - if (StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getName())) { - mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); - return mav; - } - DistrictAnalyData districtAnalyData = districtAnalyDataService - .findByDistrictKey(new DistrictKey(model.getCity(), model.getDistrict(), model.getName())); - if (null != districtAnalyData && StringUtils.isNotBlank(districtAnalyData.getRank())) { - String[] rankDesc = districtAnalyData.getRank().split("/"); - int rank = Integer.valueOf(rankDesc[0]); - int total = Integer.valueOf(rankDesc[1]); - UniversalDto dto = new UniversalDto(); - dto.append("relativeRank", DataUtil.roundDouble(((total - rank) / (double) total) * 100, 2)); - - if(null != districtAnalyData.getRegionRank()){ - dto.append("regionRelativeRank", DataUtil.roundDouble(((districtAnalyData.getRegionRankTotal() - districtAnalyData.getRegionRank()) / (double) districtAnalyData.getRegionRankTotal()) * 100, 2)); - } - mav.setModel(BasicModel.buildOKModel().setResult(dto)); - } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂无该小区排名信息")); - } - return mav; - - } - - - - /** - * 小区成交记录查询 - * - * @param model - * @return - */ - public Object dealAction(final DealPriceModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getName())) { - mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - - if (model.getMax() == null || model.getMax() < 1) { - model.setMax(DEFAULT_PAGE_SIZE); - } else if (model.getMax() > 100) { - model.setMax(100); - } - - Set districtNames = new HashSet(); - if (null == district) { - districtNames.add(model.getName()); - } else { - districtNames.add(district.getName()); - if (district.getAlias() != null) { - districtNames.addAll(district.getAlias()); - } - final String masterDistrictName = district.getMasterDistrictName(); - if (StringUtils.isNotBlank(masterDistrictName)) { - List districts; - if ("master".equals(masterDistrictName)) { - // 所有的分期数据 - districts = districtService.findSlaves(model.getCity(), model.getDistrict(), model.getName()); - } else { - // 根据主小区名查询所有名称 - districts = districtService.findSlaves(model.getCity(), model.getDistrict(), masterDistrictName); - } - if (CollectionUtils.isNotEmpty(districts)) { - for (District districtTemp : districts) { - districtNames.add(districtTemp.getName()); - } - } - - // districtNames 不包含 主小区名,加进去 - if (!districtNames.contains(masterDistrictName)){ - districtNames.add(masterDistrictName); - } - - } - } - // 将搜房中的别名与名称加入查询集合 - try { - List aliasFangs = aliasFangService.findFangByNameAndAlias(model.getCity(), model.getDistrict(), districtNames); - Set aliasSet = new HashSet(); - for (AliasFang aliasFang : aliasFangs) { - if (StringUtils.isNotBlank(aliasFang.getName())) { - aliasSet.add(aliasFang.getName()); - } - if (StringUtils.isNotBlank(aliasFang.getAlias())) { - aliasSet.add(aliasFang.getAlias()); - } - } - districtNames.addAll(aliasSet); - } catch (Exception ex) { - ex.printStackTrace(); - } + Integer finishYear = districtService.getCreateYear(district); + if (finishYear != null) { + districtInfoDto.setFinishYear(finishYear); + } + + mav.setModel(BasicModel.buildOKModel().setResult(districtInfoDto)); + return mav; + } + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + + + public Object detail2Action(PropertySearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId()) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getName())) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getAddress()))) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:请输入正确的参数组合")); + return mav; + } + + District district = null; + if (StringUtils.isNotBlank(model.getId())) { + if (ObjectId.isValid(model.getId())) { + district = districtService.findById(model.getId()); + } else { + mav.setModel(BasicModel.buildBadRequestModel("非法的住宅ID")); + return mav; + } + } + + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getName())) { + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district != null) { + district = districtService.findById(district.getId()); + } + } + + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getAddress())) { + Map result = addressParser.parse2(model.getCity(), model.getAddress(), "district", false); + saveAddressMatchLog(result, model.getAddress(), model.getCity(), model.getToken()); + Integer status = (Integer) result.get("status"); + Integer precise = (Integer) result.get("precise"); + if (status != null && status == 0 && precise == 0) { + String id = (String) result.get("id"); + district = districtService.findById(id); + } + } + + if (district != null) { + fieldFilterService.filterWithProcessNUll(district); + DistrictInfoDto districtInfoDto = new DistrictInfoDto(); + districtInfoDto.setId(district.getId()); + districtInfoDto.setCity(district.getCity()); + districtInfoDto.setDistrict(district.getRegion()); + districtInfoDto.setName(district.getName()); + districtInfoDto.setAlias(district.getMappingAlias()); + districtInfoDto.setAddress(district.getAddress()); + districtInfoDto.setAddressAlias(district.getAddrAlias()); + if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null + && district.getLng2() != 0) { + districtInfoDto.setLat2(district.getLat2() / 10000000000D); + districtInfoDto.setLng2(district.getLng2() / 10000000000D); + } + if (district.getLat() != null && district.getLat() != 0 && district.getLng() != null + && district.getLng() != 0) { + districtInfoDto.setLat(district.getLat() / 10000000000D); + districtInfoDto.setLng(district.getLng() / 10000000000D); + } + districtInfoDto.setPropertyType(district.getEstateType2()); + if (HouseValidator.validateBuildingType(district.getBuildType())) { + districtInfoDto.setBuildingType(district.getBuildType()); + } else { + districtInfoDto.setBuildingType(""); + } + districtInfoDto.setBlock(district.getBlock()); + districtInfoDto.setTownship(district.getTownship()); + if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { + districtInfoDto.setBuildingCount(district.getLoudongCount()); + } + + if (district.getHouseholdCount() != null) { + districtInfoDto.setTotalUnitCount(SeaweedUtils.formatHouseholdCount(district.getHouseholdCount().toString())); + } else { + districtInfoDto.setTotalUnitCount(""); + } + districtInfoDto.setManagementFee(district.getEstateCharge()); + if (district.getCarSiteCount() != null) { + districtInfoDto.setParking(SeaweedUtils.formatCarSiteCount(district.getCarSiteCount().toString())); + } else { + districtInfoDto.setParking(""); + } + districtInfoDto.setOwnershipPeriod(district.getPropertyLife()); + districtInfoDto.setOwnershipType(district.getHouseProperty()); + districtInfoDto.setBuildingStructure(district.getBuildStructure()); + districtInfoDto.setLandProperty(district.getLandProperty()); + districtInfoDto.setFloorSpace(SeaweedUtils.formatAllArea(district.getAllArea())); + districtInfoDto.setConstructionSpace(district.getBuildArea()); + districtInfoDto.setPlotRatio(SeaweedUtils.formatCubagePercent(district.getCubagePercent())); + districtInfoDto.setGreenPercentage(SeaweedUtils.formatVirescencePercent(district.getVirescencePercent())); + districtInfoDto.setDeveloper(district.getDeveloper()); + districtInfoDto.setPropertyManagement(district.getEstateCompany()); + + Integer finishYear = districtService.getCreateYear(district); + if (finishYear != null) { + districtInfoDto.setFinishYear(finishYear); + } + + mav.setModel(BasicModel.buildOKModel().setResult(districtInfoDto)); + return mav; + } + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + + private void saveAddressMatchLog(Map resMap, String keywords, String city, String token) { + Map tokenMap = FangjiaApiUtil.parseToken(token); + String userName = null; + // token验证后,拿取出的字段再去数据库验证一遍 + if (tokenMap != null && StringUtils.isNotBlank(tokenMap.get("userid")) + && !"null".equals(tokenMap.get("userid"))) { + User user = userService.findById(Long.parseLong(tokenMap.get("userid"))); + if (user != null) { + userName = user.getUserName(); + } + } + // 记录用户搜索词open匹配结果 + HttpServletRequest request = ActionContext.getContext().getRequest(); + AddressMatchLog addressMatchLog = new AddressMatchLog(); + addressMatchLog.setCity(city); + addressMatchLog.setInput(keywords); + addressMatchLog.setIp(AnalyticsUtil.getIpAddress(request)); + addressMatchLog.setSource("API"); + addressMatchLog.setUserName(userName); + addressMatchLog.setCreationDate(new Date()); + addressMatchLog.setModificationDate(new Date()); + if (MapUtils.isNotEmpty(resMap)) { + if (resMap.containsKey("status") && (Integer) resMap.get("status") == 0) { + List> result = new ArrayList>(); + Map map = new HashMap(); + map.put("city", (String) resMap.get("city")); + map.put("region", (String) resMap.get("region")); + map.put("name", (String) resMap.get("name")); + result.add(map); + addressMatchLog.setResult(result); + } else { + addressMatchLog.setStatus(1); + } + } else { + addressMatchLog.setStatus(1); + } + addressMatchLogService.addAddressMatchLog(addressMatchLog); + } + + @Authority(role = Role.NONE) + public Object sampleEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + EvaluationBo evaluationBo = evaluationService.doApply(buildEvaluation(model, request), true, false, true); + if (evaluationBo != null && evaluationBo.getSampleModeValue() > 0) { + UniversalDto dto = UniversalDto.newDto(); + dto.put("city", district.getCity()); + dto.put("district", district.getRegion()); + dto.put("name", district.getName()); + dto.put("totalPrice", evaluationBo.getSampleModeValue()); + dto.put("avgPrice", evaluationBo.getSampleModeValue() / model.getSize()); + mav.setModel(BasicModel.buildOKModel().setResult(dto)); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + + public Object evaluateAction(PropertyEvaluationModel model, HttpServletRequest request) + throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"}); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) { + district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "district"); + } + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + } + model.setName(district.getName()); + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + if (model.getFloor() == null) { + JSONObject structureOb = addressMatchProxyService.addressStructure(district.getCity(), model.getAddress()); + if (structureOb != null) { + if (structureOb.containsKey("buildingNumber")) { + model.setBuildingNumber(structureOb.getString("buildingNumber")); + } + + if (structureOb.containsKey("roomNumber")) { + String roomNumber = structureOb.getString("roomNumber"); + model.setFloor(getFloor(roomNumber)); + } + + } + } + + if (model.getMaxFloor() == null && model.getFloor() != null && StringUtils.isNotBlank(model.getBuildingNumber())) { + Loudong loudong = loudongService.findForEvaluate(district.getId(), model.getBuildingNumber(), model.getUnitNumber()); + if (loudong != null && loudong.getFloors() >= model.getFloor()) { + model.setMaxFloor(loudong.getFloors()); + } + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + + + Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), + model.getCalDate()); + Double cityPriceCredit = null; + if (StringUtils.isNotBlank(evaluation.getFromUserId())) { + try { + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority.getCityCreditMap() != null + && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { + cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); + if (cityPriceCredit > 1 || cityPriceCredit < 0) { + cityPriceCredit = null; + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + this.adjustPriceByRatio(district, evaluation); + } + + // 调整面积不同面积价格 + try { + DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district)); + int orgAvgPrice = 0; + if (districtStatBo != null) { + if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) { + orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); + } else if (districtStatBo.getDistrictStat() != null) { + orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); + } + } + if (evaluation != null && evaluation.getAvgPrice() != null && evaluation.getAvgPrice() > 0) { + int factorPrice = evaluation.getAvgPrice(); + int avgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), evaluation.getArea(), factorPrice, orgAvgPrice); + Integer minPrice = (int) (evaluation.getAvgPrice() * 0.95); + Integer maxPrice = (int) (evaluation.getAvgPrice() * 1.05); + // 偏离度超过5%不进行调整 + if (minPrice <= avgPrice && avgPrice <= maxPrice) { + evaluation.setAvgPrice(avgPrice); + evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea())); + } + } + } catch (Exception ex) { + LOGGER.error("调整面积不同面积价格异常{}", ex.getMessage()); + } + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 + && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); + + // 根据城市等 级设置D级可信度 + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() + && apiUserAuthority.getCreditLevelStatus() == 1) { + double dCredit = 0.61; + if (null != apiUserAuthority.getPriceRatingMap()) { + ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); + Map rateMap = apiUserAuthority.getPriceRatingMap(); + if (null != rateMap) { + dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); + } + } + Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + if (null != rMap) { + if (rMap.containsKey("level")) { + districtPriceMap.put("level", rMap.get("level")); + } + if (rMap.containsKey("other_price")) { + districtPriceMap.put("other_price", rMap.get("other_price")); + } + } + } + + Long lastPrice = (Long) rMap.get("lastPrice"); + + if (null != lastPrice) { + districtPriceMap.put("totalPrice", lastPrice); + if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { + districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); + } + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + + } else { + districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + } + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); + districtPriceMap.put("credit", evaluation.getCredit()); + districtPriceMap.put("id", evaluation.getId()); + } + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/property/evaluate"); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + } + + /** + * 系数下调 + * + * @param district + * @param evaluation + */ + private void adjustPriceByRatio(District district, Evaluation evaluation) { + + try { + ApiUserCfg apiUserCfg_pt = apiUserCfgService.findByUserId(Long.valueOf(evaluation.getFromUserId()), ApiUserCfg.ApiUserCfgKey.PRICE_TYPE); + if (apiUserCfg_pt != null && apiUserCfg_pt.getCfgValue() != null) { + String priceType = apiUserCfg_pt.getCfgValue().toString(); + // 评估价则系数调整 + if (StringUtils.isNotBlank(priceType) && "evaluate".equals(priceType)) { + EvaluateRatio evaluateRatio = null; + if (StringUtils.isNotBlank(district.getRegion())) { + evaluateRatio = evaluateRatioService.findByCityAndRegion(district.getCity(), district.getRegion()); + } + if (evaluateRatio == null) { + evaluateRatio = evaluateRatioService.findByCity(district.getCity()); + } + if (evaluateRatio != null) { + // 系数添加 + long totalPrice = evaluation.getBigTotalPrice(); + totalPrice = (long) (totalPrice * (1 + evaluateRatio.getRatio())); + evaluation.setBigTotalPrice(totalPrice); + evaluation.setAvgPrice((int) (totalPrice / evaluation.getArea())); + } + } + } + } catch (Exception ex) { + LOGGER.error("系数下调异常{}", ex.getMessage()); + } + } + + static final Map CITY_CORRECTION_FACTOR = new HashMap(); + + static { + CITY_CORRECTION_FACTOR.put("上海", 0.02); + CITY_CORRECTION_FACTOR.put("杭州", 0.1); + CITY_CORRECTION_FACTOR.put("大连", 0.09); + CITY_CORRECTION_FACTOR.put("广州", 0.09); + CITY_CORRECTION_FACTOR.put("深圳", 0.02); + CITY_CORRECTION_FACTOR.put("重庆", 0.1); + CITY_CORRECTION_FACTOR.put("苏州", 0.08); + CITY_CORRECTION_FACTOR.put("成都", 0.07); + CITY_CORRECTION_FACTOR.put("北京", 0.04); + CITY_CORRECTION_FACTOR.put("厦门", 0.1); + } + + public Object evaluateForTestAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("城市为必填项")); + return mav; + } + if (model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("面积为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getAddress()) && StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("地址和小区名至少填一个")); + return mav; + } + if (StringUtils.isNotBlank(model.getName()) && StringUtils.isBlank(model.getAddress())) { + model.setAddress(model.getName()); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = DateUtil.parseDate(request.getParameter("calDate"), "yyyy-MM-dd"); + model.setCalDate(calDate); + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findDistrict(new DistrictKey(model.getCity(), model.getDistrict(), model.getName()), "district");//matchDistrict(model.getCity(), model.getAddress(), model.getDistrict(), model.getName()); + if (district == null) { + //防止地址模糊,名称详细的情况 + district = matchDistrict(model.getCity(), model.getName(), model.getDistrict(), model.getAddress()); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + } + model.setName(district.getName()); + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); + if (!"self".equalsIgnoreCase(evaluation.getEvaluateWay())) { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + + this.adjustPriceByRatio(district, evaluation); + + // 调整面积不同面积价格 + try { + DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district)); + int orgAvgPrice = 0; + if (districtStatBo != null) { + if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) { + orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); + } else if (districtStatBo.getDistrictStat() != null) { + orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); + } + } + if (evaluation != null && evaluation.getAvgPrice() != null && evaluation.getAvgPrice() > 0) { + int factorPrice = evaluation.getAvgPrice(); + int avgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), evaluation.getArea(), factorPrice, orgAvgPrice); + Integer minPrice = (int) (evaluation.getAvgPrice() * 0.95); + Integer maxPrice = (int) (evaluation.getAvgPrice() * 1.05); + // 偏离度超过5%不进行调整 + if (minPrice <= avgPrice && avgPrice <= maxPrice) { + evaluation.setAvgPrice(avgPrice); + evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea())); + } + } + } catch (Exception ex) { + + } + Map districtPriceMap = new LinkedHashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + + districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + districtPriceMap.put("unitPrice", evaluation.getAvgPrice()); + // 新增置信度 + CommunityBasePrice communityBasePrice = communityBasePriceService.getById(district.getId()); + if (communityBasePrice != null) { + districtPriceMap.put("credit", communityBasePrice.getCredit()); + } else { + districtPriceMap.put("credit", evaluation.getCredit()); + } + List names = new ArrayList(); + names.add(district.getName()); + if (district.getAlias() != null) { + for (String alia : district.getAlias()) { + if (StringUtils.isNotBlank(alia) && !names.contains(alia)) { + names.add(alia); + } + } + } + Integer minPrice = (int) (evaluation.getAvgPrice() * 0.8); + Integer maxPrice = (int) (evaluation.getAvgPrice() * 1.2); + Integer min10Price = (int) (evaluation.getAvgPrice() * 0.9); + Integer max10Price = (int) (evaluation.getAvgPrice() * 1.1); + // 新增第三方均价 + try { + double dCredit = 0.61; + Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); + if (null != rMap) { + if (rMap.containsKey("other_price")) { + Map otherPriceMap = (Map) rMap.get("other_price"); + Map priceResultMap = new HashMap(); + for (String key : otherPriceMap.keySet()) { + Integer price = otherPriceMap.get(key); + // 剔除偏差大于10的 + if (min10Price <= price && max10Price >= price) { + if (OTHER_PRICE_MAP.containsKey(key)) { + priceResultMap.put(OTHER_PRICE_MAP.get(key), price); + } + } + } + districtPriceMap.put("otherPrice", priceResultMap); + } + } + } catch (Exception ex) { + + } + List houses = seawaterDao.findHouses(district.getCity(), district.getRegion(), names, minPrice, maxPrice, 20); + if (houses.size() > 3) { + districtPriceMap.put("calcType", 1); + List houseDtos = new ArrayList(); + for (Seawater seawater : houses) { + UniversalDto houseDto = new UniversalDto(); + houseDto.append("city", seawater.getCity()); + houseDto.append("district", seawater.getRegion()); + houseDto.append("name", seawater.getDistrictName()); + houseDto.append("title", seawater.getName()); + houseDto.append("size", seawater.getArea()); + houseDto.append("unitPrice", seawater.getAvgPrice()); + houseDto.append("totalPrice", seawater.getTotalPrice()); + houseDto.append("room", seawater.getRoom()); + houseDto.append("hall", seawater.getHall()); + houseDto.append("toilet", seawater.getToilet()); + houseDto.append("direction", HouseValidator.fetchDirectionInfo(seawater.getDirection())); + houseDto.append("decoration", HouseValidator.fetchFitmentInfo(seawater.getFitment())); + houseDto.append("publishDate", seawater.getpDate()); + if (seawater.getHeight() != null && seawater.getHeight() > 0) { + houseDto.append("maxFloor", seawater.getHeight()); + } + houseDtos.add(houseDto); + } + districtPriceMap.put("houses", houseDtos); + } else if (district.getLng() != null && district.getLng() > 0) { + double lng = DataUtil.roundDouble(district.getLng() / 10000000000.0, 6); + double lat = DataUtil.roundDouble(district.getLat() / 10000000000.0, 6); + List districts = districtService.findNearestDistrict(district.getEstateType2(), lng, lat, 1000 * 3, 6, null); + if (districts.size() < 2) { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + UniversalDto modelFeaturesFto = UniversalDto.newDto(); + districtPriceMap.put("calcType", 2); + modelFeaturesFto.append("propertyType", district.getEstateType2()); + modelFeaturesFto.append("lng", lng); + modelFeaturesFto.append("lat", lat); + DistrictAnalyData districtAnalyData = districtAnalyDataService.findByDistrictKey(new DistrictKey(district)); + if (districtAnalyData != null && districtAnalyData.getHalfYearMarkup() != null) { + modelFeaturesFto.append("halfYearMarkup", DataUtil.roundDouble(districtAnalyData.getHalfYearMarkup() * 100, 2)); + } + RegionAnaData regionAnaData = regionAnaDataService.findRegionAnaData(district.getCity(), district.getRegion()); + if (regionAnaData != null) { + modelFeaturesFto.append("region20PercentPrice", regionAnaData.getRegion20PercentPrice()); + modelFeaturesFto.append("region80PercentPrice", regionAnaData.getRegion80PercentPrice()); + } + List nearCommunityDtos = new ArrayList(); + for (District d : districts) { + if (d.getId().equals(district.getId())) { + continue; + } + UniversalDto districtDto = UniversalDto.newDto(); + districtDto.append("city", d.getCity()); + districtDto.append("region", d.getRegion()); + districtDto.append("name", d.getName()); + districtDto.append("lng", DataUtil.roundDouble(d.getLng() / 10000000000.0, 6)); + districtDto.append("lat", DataUtil.roundDouble(d.getLat() / 10000000000.0, 6)); + districtDto.append("distance", GeoUtils.calculateDistance(lng, lat, d.getLng() / 10000000000.0, d.getLat() / 10000000000.0)); + districtDto.append("propertyType", d.getEstateType2()); + Integer buildYear = districtService.getBuildYear(d); + if (buildYear != null) { + districtDto.append("buildYear", String.valueOf(buildYear)); + } + districtAnalyData = districtAnalyDataService.findByDistrictKey(new DistrictKey(d)); + if (districtAnalyData != null) { + if (districtAnalyData.getHalfYearMarkup() != null) { + districtDto.append("halfYearMarkup", DataUtil.roundDouble(districtAnalyData.getHalfYearMarkup() * 100, 2)); + } + if (districtAnalyData.getAvgPrice() != null && minPrice <= districtAnalyData.getAvgPrice() && maxPrice >= districtAnalyData.getAvgPrice()) { + districtDto.append("avgPrice", districtAnalyData.getAvgPrice()); + } + } + + nearCommunityDtos.add(districtDto); + } + Integer buildYear = districtService.getBuildYear(district); + if (buildYear != null) { + modelFeaturesFto.put("buildYear", String.valueOf(buildYear)); + } + modelFeaturesFto.append("nearCommunity", nearCommunityDtos); + + // 模型特征新增周边数量 + CommunityPoi communityPoi = communityPoiService.getById(district.getId()); + if (communityPoi != null) { + modelFeaturesFto.put("subway", communityPoi.getSubway()); + modelFeaturesFto.put("traffic", communityPoi.getTraffic()); + modelFeaturesFto.put("bank", communityPoi.getBank()); + modelFeaturesFto.put("primary", communityPoi.getPrimary()); + modelFeaturesFto.put("hospital", communityPoi.getHospital()); + modelFeaturesFto.put("junior", communityPoi.getJunior()); + modelFeaturesFto.put("funeral", communityPoi.getFuneral()); + } + districtPriceMap.put("modelFeatures", modelFeaturesFto); + } + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } + + /** + * 地址估值 + * + * @param model 参数 + * @param request + * @return + */ + public Object addressEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) throws IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项")); + return mav; + } + if (model.getDistrict() != null) { + //区域编码转房价网区域 + FangjiaOfficialAreaMap fangjiaOfficialAreaMap = fangjiaOfficialAreaService.convertOfficialCodeToFangjia(model.getDistrict()); + if (fangjiaOfficialAreaMap != null) { + model.setDistrict(fangjiaOfficialAreaMap.getFangjiaDistrict()); + } + } + + boolean villaFlag = DataUtil.isVilla(model.getSize(), model.getName(), model.getHeight(), model.getRoom()); + + District district = null; + Map params = new HashMap(); + params.put("city", model.getCity()); + if (StringUtils.isNotBlank(model.getDistrict())) { + params.put("suggestDistrict", model.getDistrict()); + } + params.put("address", model.getAddress()); + if (StringUtils.isNotBlank(model.getName())) { + params.put("suggestName", model.getName()); + } + params.put("category", "district"); + String result = addressMatchProxyService.parser(params); + if (result != null) { + JSONObject json = JSONObject.fromObject(result); + if (json.getInt("code") == 200) { + Map map = (Map) json.get("result"); + if ((Integer) map.get("precise") >= 0) { + String propertyType = (String) map.get("propertyType"); + if (villaFlag && StringUtils.isNotBlank(propertyType) && !propertyType.equals("别墅")) { + district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name") + "别墅", "district"); + } + if (null == district) { + district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name"), "district"); + } + + } + } + } + + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); + return mav; + } + model.setDistrict(district.getRegion()); + model.setName(district.getName()); + return this.evaluateAction(model, request); + } + + public Object evaluate2Action(PropertyEvaluationModel model, HttpServletRequest request) + throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"}); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); + Double cityPriceCredit = null; + if (StringUtils.isNotBlank(evaluation.getFromUserId())) { + try { + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority.getCityCreditMap() != null + && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { + cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); + if (cityPriceCredit > 1 || cityPriceCredit < 0) { + cityPriceCredit = null; + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 + && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { + + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); + + // 根据城市等 级设置D级可信度 + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() + && apiUserAuthority.getCreditLevelStatus() == 1) { + double dCredit = 0.61; + if (null != apiUserAuthority.getPriceRatingMap()) { + ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); + Map rateMap = apiUserAuthority.getPriceRatingMap(); + if (null != rateMap) { + dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); + } + } + Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + if (null != rMap) { + if (rMap.containsKey("level")) { + districtPriceMap.put("level", rMap.get("level")); + } + if (rMap.containsKey("other_price")) { + districtPriceMap.put("other_price", rMap.get("other_price")); + } + } + } + + Long lastPrice = (Long) rMap.get("lastPrice"); + if (null != lastPrice) { + districtPriceMap.put("totalPrice", lastPrice); + if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { + districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); + } + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + + } else { + districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + } + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); + districtPriceMap.put("credit", evaluation.getCredit()); + districtPriceMap.put("id", evaluation.getId()); + } + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + } + + /** + * 四川锦程 定制接口 多建筑年代 + * + * @param model + * @param request + * @return + * @throws NumberFormatException + * @throws IllegalAccessException + */ + public Object evaluate3Action(PropertyEvaluationModel model, HttpServletRequest request) + throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"}); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request), model.getCalDate()); + Double cityPriceCredit = null; + if (StringUtils.isNotBlank(evaluation.getFromUserId())) { + try { + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority.getCityCreditMap() != null + && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) { + cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity()); + if (cityPriceCredit > 1 || cityPriceCredit < 0) { + cityPriceCredit = null; + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0 + && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) { + + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); + if (StringUtils.isNotBlank(district.getFinishBuildingDate())) { + Pattern pat3 = Pattern.compile("\\d{4}"); + Matcher matcher3 = pat3.matcher(district.getFinishBuildingDate()); + if (matcher3.find()) { + districtPriceMap.put("buildYear", matcher3.group()); + } + } + + + // 根据城市等 级设置D级可信度 + ApiUserAuthority apiUserAuthority = apiUserAuthorityService + .findByUserId(Long.valueOf(evaluation.getFromUserId())); + if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus() + && apiUserAuthority.getCreditLevelStatus() == 1) { + double dCredit = 0.61; + if (null != apiUserAuthority.getPriceRatingMap()) { + ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity()); + Map rateMap = apiUserAuthority.getPriceRatingMap(); + if (null != rateMap) { + dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString())); + } + } + Map rMap = getLastEvaluationPrice(district, evaluation, dCredit); + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + if (null != rMap) { + if (rMap.containsKey("level")) { + districtPriceMap.put("level", rMap.get("level")); + } + if (rMap.containsKey("other_price")) { + districtPriceMap.put("other_price", rMap.get("other_price")); + } + } + } + + Long lastPrice = (Long) rMap.get("lastPrice"); + if (null != lastPrice) { + districtPriceMap.put("totalPrice", lastPrice); + if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) { + districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea())); + } + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + + } else { + districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + } + + if (model.getScope() == EVALUATE_SHOW_DETAIL) { + districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); + districtPriceMap.put("credit", evaluation.getCredit()); + districtPriceMap.put("id", evaluation.getId()); + } + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData()); + return mav; + } + } + + @Authority(role = Role.USER) + public Object addBatchEvaluateTaskAction(BatchEvaluateModel model) throws IOException { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getFile() == null || model.getFile().isEmpty()) { + mav.setModel(BasicModel.buildBadRequestModel("请上传包含待评估数据的数据文件")); + return mav; + } + MultipartFile file = model.getFile(); + + if (StringUtils.isNotBlank(model.getCharset()) && Charset.isSupported(model.getCharset())) { + mav.setModel(BasicModel.buildBadRequestModel("字符编码不支持")); + return mav; + } else { + model.setCharset("GBK"); + } + Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); + String userId = tokenMap.get("userid"); + DBObject dbFile = fileDao.save(file.getBytes(), file.getContentType()); + String fileId = (String) dbFile.get("_id"); + BatchEvaluateTask task = new BatchEvaluateTask(); + task.setDateCreated(new Date()); + task.setStatus(BatchEvaluateTask.StatusEnum.INIT.getStatus()); + task.setDataFileId(fileId); + task.setUserId(userId); + task.setFileName(file.getOriginalFilename()); + task.setCharset(model.getCharset()); + batchEvaluateService.saveBatchEvaluateTask(task); + Map data = new HashMap(); + data.put("taskId", task.getId()); + mav.setModel(BasicModel.buildOKModel().setResult(data)); + return mav; + } + + @Authority(role = Role.USER) + public Object batchEvaluateTaskStatusAction(BatchEvaluateModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId()) || !ObjectId.isValid(model.getId())) { + mav.setModel(BasicModel.buildBadRequestModel("任务id非法")); + return mav; + } + Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); + String userId = tokenMap.get("userid"); + BatchEvaluateTask task = batchEvaluateService.findBatchEvaluateTaskById(model.getId()); + if (task == null || !task.getUserId().equals(userId)) { + mav.setModel(BasicModel.buildBadRequestModel("任务不存在")); + return mav; + } + Map data = new HashMap(); + data.put("status", task.getStatus()); + if (BatchEvaluateTask.StatusEnum.INIT.getStatus() == task.getStatus()) { + data.put("msg", "待处理"); + } else if (BatchEvaluateTask.StatusEnum.DOING.getStatus() == task.getStatus()) { + data.put("msg", "处理中"); + } else if (BatchEvaluateTask.StatusEnum.SUC.getStatus() == task.getStatus()) { + data.put("msg", "已完成"); + data.put("downLink", "http://open.fangjia.com/property/downEvaluateResult?id=" + task.getId() + "&token=" + + model.getToken()); + } else if (BatchEvaluateTask.StatusEnum.ERROR.getStatus() == task.getStatus()) { + data.put("msg", "处理失败"); + data.put("subMsg", task.getMsg()); + } + mav.setModel(BasicModel.buildOKModel().setResult(data)); + return mav; + } + + @Authority(role = Role.USER) + public Object downEvaluateResultAction(BatchEvaluateModel model, HttpServletResponse response) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId()) || !ObjectId.isValid(model.getId())) { + mav.setModel(BasicModel.buildBadRequestModel("任务id非法")); + return mav; + } + Map tokenMap = FangjiaApiUtil.parseToken(model.getToken()); + + String userId = tokenMap.get("userid"); + BatchEvaluateTask task = batchEvaluateService.findBatchEvaluateTaskById(model.getId()); + if (task == null || !task.getUserId().equals(userId)) { + mav.setModel(BasicModel.buildBadRequestModel("任务不存在")); + return mav; + } + + DBObject file = fileDao.findById(task.getDataFileId()); + byte[] data = (byte[]) file.get("data"); + OutputStream os = null; + try { + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/x-gzip"); + String fileName = DateUtil.formatToYYYYMMDDhhmmss(new Date()) + ".csv.gz"; + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + os = response.getOutputStream();// 取得输出流 + os.write(data); + os.flush(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (os != null) { + os.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + ModelAndViewSupport mv = new ModelAndViewSupport(); + mv.setViewType("stream"); + return mv; + } + + @Authority(role = Role.NONE) + public Object batchEvaluateTemplateAction(BatchEvaluateModel model, HttpServletResponse response, + HttpServletRequest request) { + OutputStream os = null; + FileInputStream fis = null; + try { + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/csv"); + response.setHeader("Content-Disposition", "attachment;filename=batchEvaluateTemplate.csv"); + os = response.getOutputStream();// 取得输出流 + String path = request.getSession().getServletContext().getRealPath("") + File.separator + "WEB-INF" + + File.separator + "classes" + File.separator + "batchEvaluateTemplate.csv"; + File template = new File(path); + fis = new FileInputStream(template); + byte[] data = new byte[fis.available()]; + fis.read(data); + os.write(data); + os.flush(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (os != null) { + os.close(); + } + if (fis != null) { + fis.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + ModelAndViewSupport mv = new ModelAndViewSupport(); + mv.setViewType("stream"); + return mv; + } + + public Object evaluateShopAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "shop"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + if (model.getCalDate() != null) { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + Evaluation evaluation = evaluationService.evaluateWithPadding(buildEvaluation(model, request), + model.getCalDate()); + if (null != evaluation && evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + evaluationService.remove(evaluation.getId()); + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价")); + return mav; + } + } + + public Object filterAction(PropertySearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + District district = districtService.findById(model.getId()); + fieldFilterService.refresh(); + fieldFilterService.filterWithProcessNUll(district); + mav.setModel(BasicModel.buildOKModel().setResult(district)); + return mav; + } + + public Object houseRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getHouseType() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,房型(houseType)为必填项")); + return mav; + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + List evaluations = evaluationService.histroyRent(district, buildEvaluation(model, request), 1, + model.getHouseType()); + if (evaluations.isEmpty()) { + mav.setModel(BasicModel.buildOKModel().setMsg("暂无租金")); + } else { + Evaluation evaluation = evaluations.get(0); + JSONObject item = new JSONObject(); + item.put("city", district.getCity()); + item.put("district", district.getRegion()); + item.put("name", district.getName()); + item.put("rent", evaluation.getAvgPrice()); + item.put("changePercent", evaluation.getMarkup() / 100d); + mav.setModel(BasicModel.buildOKModel().setResult(item)); + } + return mav; + } + + public Object historyRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getHouseType() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,房型(houseType)为必填项")); + return mav; + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + return mav; + } + + List evaluations = evaluationService.histroyRent(district, buildEvaluation(model, request), + model.getPeriodCount(), model.getHouseType()); + List historyEvaluations = new ArrayList(); + for (Evaluation evaluation : evaluations) { + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + JSONObject item = new JSONObject(); + item.put("city", district.getCity()); + item.put("district", district.getRegion()); + item.put("name", district.getName()); + item.put("rent", evaluation.getAvgPrice()); + item.put("changePercent", evaluation.getMarkup() / 100d); + item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM")); + historyEvaluations.add(item); + } + } + if (historyEvaluations.size() > model.getPeriodCount()) { + historyEvaluations = historyEvaluations.subList(historyEvaluations.size() - model.getPeriodCount(), + historyEvaluations.size()); + } + mav.setModel(BasicModel.buildOKModel().setResult(historyEvaluations)); + return mav; + + } + + public Object historyEvaluateAction(PropertyEvaluationModel model, HttpServletRequest request) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + return mav; + } + if (StringUtils.isBlank(model.getPeriodType())) { + model.setPeriodType("weekly"); + } else { + if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { + mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); + return mav; + } + } + Calendar calendar = Calendar.getInstance(); + if ("weekly".equals(model.getPeriodType())) { + calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); + } else { + calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); + + } + List evaluations = evaluationService.histroyEvaluate(district, buildEvaluation(model, request), + calendar.getTime(), model.getPeriodType()); + List historyEvaluations = new ArrayList(); + for (Evaluation evaluation : evaluations) { + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + JSONObject item = new JSONObject(); + item.put("city", district.getCity()); + item.put("district", district.getRegion()); + item.put("name", district.getName()); + item.put("totalPrice", evaluation.getBigTotalPrice()); + item.put("avgPrice", evaluation.getAvgPrice()); + item.put("changePercent", evaluation.getMarkup() / 100d); + if ("weekly".equals(model.getPeriodType())) { + item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM-dd")); + } else { + item.put("date", DateUtil.formatByPattern(evaluation.getCreationDate(), "yyyy-MM")); + } + historyEvaluations.add(item); + } + } + if (historyEvaluations.size() > model.getPeriodCount()) { + historyEvaluations = historyEvaluations.subList(historyEvaluations.size() - model.getPeriodCount(), + historyEvaluations.size()); + } + mav.setModel(BasicModel.buildOKModel().setResult(historyEvaluations)); + return mav; + } + + public Object avgPriceAction(AvgPriceQueryModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + return mav; + } + if (StringUtils.isBlank(model.getPeriodType())) { + model.setPeriodType("weekly"); + } else { + if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { + mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); + return mav; + } + } + Calendar calendar = Calendar.getInstance(); + if ("weekly".equals(model.getPeriodType())) { + calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); + } else { + calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); + } + + List districtStats = districtStatService.findAllDistrictStatByNameWithPadding(district.getCity(), + district.getRegion(), district.getName(), district.getEstateType2(), calendar.getTime(), new Date(), + model.getPeriodType()); + if (districtStats.size() > model.getPeriodCount()) { + districtStats = districtStats.subList(districtStats.size() - model.getPeriodCount(), districtStats.size()); + } + List> result = new ArrayList>(model.getPeriodCount()); + for (DistrictStat districtStat : districtStats) { + Map item = new LinkedHashMap(); + item.put("city", districtStat.getCity()); + item.put("district", districtStat.getRegion()); + item.put("name", districtStat.getDistrictName()); + item.put("avgPrice", districtStat.getAvgPrice()); + if ("monthly".equals(model.getPeriodType())) { + item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); + } else { + item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM-dd")); + } + item.put("changePercent", districtStat.getMarkup() / 100d); + result.add(item); + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); + return mav; + } + + /** + * 小区租金查询接口 + * + * @param model + * @return + */ + public Object rentAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + return mav; + } + if (model.getHouseType() == null || model.getHouseType() < 1) { + mav.setModel(BasicModel.buildBadRequestModel("房屋类型不合法")); + return mav; + } + String estateType2 = "小区"; + if (district.getEstateType2().contains("别墅")) { + estateType2 = "别墅"; + } + List rents = districtStatRentService.findAllByDistrictKeyAndHouseType( + new DistrictKey(district), model.getHouseType(), estateType2, model.getPeriodCount()); + if (rents.isEmpty() && estateType2.equals("别墅")) { + estateType2 = "小区"; + rents = districtStatRentService.findAllByDistrictKeyAndHouseType(new DistrictKey(district), + model.getHouseType(), estateType2, model.getPeriodCount()); + } + List> result = new ArrayList>(model.getPeriodCount()); + for (DistrictStatRent districtStat : rents) { + Map item = new LinkedHashMap(); + item.put("city", districtStat.getCity()); + item.put("district", districtStat.getRegion()); + item.put("name", districtStat.getDistrictName()); + item.put("rent", districtStat.getAvgPrice()); + item.put("date", DateUtil.formatByPattern(districtStat.getEndMonthDate(), "yyyy-MM")); + item.put("houseType", districtStat.getHouseType()); + item.put("changePercent", districtStat.getMarkup() / 100d); + result.add(item); + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); + return mav; + } + + /** + * 平米租金 + * cat 表示租金类型 + * city:城市 , region : 区域 ,district :小区 + * + * @param model + * @return + */ + + public Object sqmeterRentAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCat())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:cat(租金类型)是必须参数")); + return mav; + } + if ("city".equals(model.getCity()) && StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("城市平米租金,city(城市)是必须参数")); + return mav; + } + if ("region".equals(model.getCity()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()))) { + mav.setModel(BasicModel.buildBadRequestModel("区域平米租金,city(城市),district(区域)是必须参数")); + return mav; + } + if ("district".equals(model.getCity()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName()))) { + mav.setModel(BasicModel.buildBadRequestModel("小区平米租金,city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + if ("district".equals(model.getCat())) { + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + } + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + return mav; + } + Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -model.getPeriodCount()); + + List sqmetreRents = sqmetreRentService.findSqmetreRents(model.getCity(), model.getDistrict(), model.getName(), model.getCat(), startDate, null); + List> result = new ArrayList>(model.getPeriodCount()); + + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + item.put("district", sqmetreRent.getRegion()); + item.put("name", sqmetreRent.getDistrictName()); + item.put("rent", sqmetreRent.getAvgPrice().intValue()); + item.put("date", DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM")); + result.add(item); + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); + return mav; + } + + public Object rankAction(final DealPriceModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + model.setCity(RegionData.formatCity(model.getCity())); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); + return mav; + } + DistrictAnalyData districtAnalyData = districtAnalyDataService + .findByDistrictKey(new DistrictKey(model.getCity(), model.getDistrict(), model.getName())); + if (null != districtAnalyData && StringUtils.isNotBlank(districtAnalyData.getRank())) { + String[] rankDesc = districtAnalyData.getRank().split("/"); + int rank = Integer.valueOf(rankDesc[0]); + int total = Integer.valueOf(rankDesc[1]); + UniversalDto dto = new UniversalDto(); + dto.append("relativeRank", DataUtil.roundDouble(((total - rank) / (double) total) * 100, 2)); + + if (null != districtAnalyData.getRegionRank()) { + dto.append("regionRelativeRank", DataUtil.roundDouble(((districtAnalyData.getRegionRankTotal() - districtAnalyData.getRegionRank()) / (double) districtAnalyData.getRegionRankTotal()) * 100, 2)); + } + mav.setModel(BasicModel.buildOKModel().setResult(dto)); + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂无该小区排名信息")); + } + return mav; + + } + + + /** + * 小区成交记录查询 + * + * @param model + * @return + */ + public Object dealAction(final DealPriceModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + + if (model.getMax() == null || model.getMax() < 1) { + model.setMax(DEFAULT_PAGE_SIZE); + } else if (model.getMax() > 100) { + model.setMax(100); + } + + Set districtNames = new HashSet(); + if (null == district) { + districtNames.add(model.getName()); + } else { + districtNames.add(district.getName()); + if (district.getAlias() != null) { + districtNames.addAll(district.getAlias()); + } + final String masterDistrictName = district.getMasterDistrictName(); + if (StringUtils.isNotBlank(masterDistrictName)) { + List districts; + if ("master".equals(masterDistrictName)) { + // 所有的分期数据 + districts = districtService.findSlaves(model.getCity(), model.getDistrict(), model.getName()); + } else { + // 根据主小区名查询所有名称 + districts = districtService.findSlaves(model.getCity(), model.getDistrict(), masterDistrictName); + } + if (CollectionUtils.isNotEmpty(districts)) { + for (District districtTemp : districts) { + districtNames.add(districtTemp.getName()); + } + } + + // districtNames 不包含 主小区名,加进去 + if (!districtNames.contains(masterDistrictName)) { + districtNames.add(masterDistrictName); + } + + } + } + // 将搜房中的别名与名称加入查询集合 + try { + List aliasFangs = aliasFangService.findFangByNameAndAlias(model.getCity(), model.getDistrict(), districtNames); + Set aliasSet = new HashSet(); + for (AliasFang aliasFang : aliasFangs) { + if (StringUtils.isNotBlank(aliasFang.getName())) { + aliasSet.add(aliasFang.getName()); + } + if (StringUtils.isNotBlank(aliasFang.getAlias())) { + aliasSet.add(aliasFang.getAlias()); + } + } + districtNames.addAll(aliasSet); + } catch (Exception ex) { + ex.printStackTrace(); + } // List dealPrices = new ArrayList(); - // 将主名与映射别名查得成交加入 存在不能查出最新成交问题 + // 将主名与映射别名查得成交加入 存在不能查出最新成交问题 // for (String name : districtNames) { // List dealPricesTempList = findDealPricesByName(model.getCity(), model.getDistrict(), name, model.getMax() * 5, model); // if (CollectionUtils.isNotEmpty(dealPricesTempList)) { // dealPrices.addAll(dealPricesTempList); // } // } - List dealPrices = findDealPricesByNames(model.getCity(), model.getDistrict(), new ArrayList(districtNames), model.getMax() * 5, model); - if (model.getSize() != null) { - Collections.sort(dealPrices, new Comparator() { - @Override - public int compare(DealPrice o1, DealPrice o2) { - Double a1 = Math.abs(model.getSize() - o1.getArea()); - Double a2 = Math.abs(model.getSize() - o2.getArea()); - if (a1.compareTo(a2) == 0) { - return -o1.getTradeDate().compareTo(o2.getTradeDate()); - } - return a1.compareTo(a2); - } - }); - } else if (StringUtils.isNotBlank(model.getFloor())) { - final int floor = Integer.valueOf(model.getFloor()); - Collections.sort(dealPrices, new Comparator() { - @Override - public int compare(DealPrice o1, DealPrice o2) { - if (o1.getFloor() == null) { - return 1; - } - if (o1.getFloor() == o2.getFloor() && o1.getFloor() == null) { - return 0; - } - if (o2.getFloor() == null) { - return -1; - } + List dealPrices = findDealPricesByNames(model.getCity(), model.getDistrict(), new ArrayList(districtNames), model.getMax() * 5, model); + if (model.getSize() != null) { + Collections.sort(dealPrices, new Comparator() { + @Override + public int compare(DealPrice o1, DealPrice o2) { + Double a1 = Math.abs(model.getSize() - o1.getArea()); + Double a2 = Math.abs(model.getSize() - o2.getArea()); + if (a1.compareTo(a2) == 0) { + return -o1.getTradeDate().compareTo(o2.getTradeDate()); + } + return a1.compareTo(a2); + } + }); + } else if (StringUtils.isNotBlank(model.getFloor())) { + final int floor = Integer.valueOf(model.getFloor()); + Collections.sort(dealPrices, new Comparator() { + @Override + public int compare(DealPrice o1, DealPrice o2) { + if (o1.getFloor() == null) { + return 1; + } + if (o1.getFloor() == o2.getFloor() && o1.getFloor() == null) { + return 0; + } + if (o2.getFloor() == null) { + return -1; + } - Integer a1 = Math.abs(floor - o1.getFloor()); - Integer a2 = Math.abs(floor - o2.getFloor()); - if (a1.compareTo(a2) == 0) { - return -o1.getTradeDate().compareTo(o2.getTradeDate()); - } - return a1.compareTo(a2); - } - }); - } - if (dealPrices.size() > model.getMax()) { - dealPrices = dealPrices.subList(0, model.getMax()); - } + Integer a1 = Math.abs(floor - o1.getFloor()); + Integer a2 = Math.abs(floor - o2.getFloor()); + if (a1.compareTo(a2) == 0) { + return -o1.getTradeDate().compareTo(o2.getTradeDate()); + } + return a1.compareTo(a2); + } + }); + } + if (dealPrices.size() > model.getMax()) { + dealPrices = dealPrices.subList(0, model.getMax()); + } - List> formateDealPrices = new ArrayList>(); - Map deal; - for (DealPrice dealPrice : dealPrices) { - if (model.isConvert()) { - fieldFilterService.filterWithProcessNUll(dealPrice); - } - deal = new LinkedHashMap(); - dealPrice.setId(null); - deal.put("city", dealPrice.getCity()); - deal.put("district", dealPrice.getRegion()); - deal.put("name", dealPrice.getDistrictName()); - if (dealPrice.getArea() == null) { - deal.put("size", ""); - } else { - deal.put("size", dealPrice.getArea()); - } - deal.put("avgPrice", dealPrice.getAvgPrice()); - deal.put("totalPrice", dealPrice.getTotalPrice()); - deal.put("tradeDate", DateUtil.formatByPattern(dealPrice.getTradeDate(), "yyyy-MM-dd")); - if (dealPrice.getFloor() == null || dealPrice.getFloor() < 1) { - deal.put("floor", ""); - } else { - deal.put("floor", dealPrice.getFloor().toString()); - } - if (dealPrice.getHeight() == null || dealPrice.getHeight() < 1) { - deal.put("maxFloor", ""); - } else { - deal.put("maxFloor", dealPrice.getHeight().toString()); - } + List> formateDealPrices = new ArrayList>(); + Map deal; + for (DealPrice dealPrice : dealPrices) { + if (model.isConvert()) { + fieldFilterService.filterWithProcessNUll(dealPrice); + } + deal = new LinkedHashMap(); + dealPrice.setId(null); + deal.put("city", dealPrice.getCity()); + deal.put("district", dealPrice.getRegion()); + deal.put("name", dealPrice.getDistrictName()); + if (dealPrice.getArea() == null) { + deal.put("size", ""); + } else { + deal.put("size", dealPrice.getArea()); + } + deal.put("avgPrice", dealPrice.getAvgPrice()); + deal.put("totalPrice", dealPrice.getTotalPrice()); + deal.put("tradeDate", DateUtil.formatByPattern(dealPrice.getTradeDate(), "yyyy-MM-dd")); + if (dealPrice.getFloor() == null || dealPrice.getFloor() < 1) { + deal.put("floor", ""); + } else { + deal.put("floor", dealPrice.getFloor().toString()); + } + if (dealPrice.getHeight() == null || dealPrice.getHeight() < 1) { + deal.put("maxFloor", ""); + } else { + deal.put("maxFloor", dealPrice.getHeight().toString()); + } - if (dealPrice.getRoom() == null || dealPrice.getRoom() < 1) { - deal.put("room", ""); - } else { - deal.put("room", dealPrice.getRoom().toString()); - } - if (dealPrice.getHall() == null || dealPrice.getHall() < 1) { - deal.put("hall", ""); - } else { - deal.put("hall", dealPrice.getHall().toString()); - } - if (dealPrice.getToilet() == null || dealPrice.getToilet() < 1) { - deal.put("toilet", ""); - } else { - deal.put("toilet", dealPrice.getToilet().toString()); - } - String fitment = HouseValidator.fetchFitmentInfo(dealPrice.getFitment()); - if (fitment == null) { - deal.put("decoration", ""); - } else { - deal.put("decoration", fitment); - } - String direction = HouseValidator.fetchDirectionInfo(dealPrice.getDirection()); - if (direction == null) { - deal.put("direction", ""); - } else { - deal.put("direction", direction); - } - formateDealPrices.add(deal); - } - mav.setModel(BasicModel.buildOKModel().setResult(formateDealPrices)); - return mav; - } + if (dealPrice.getRoom() == null || dealPrice.getRoom() < 1) { + deal.put("room", ""); + } else { + deal.put("room", dealPrice.getRoom().toString()); + } + if (dealPrice.getHall() == null || dealPrice.getHall() < 1) { + deal.put("hall", ""); + } else { + deal.put("hall", dealPrice.getHall().toString()); + } + if (dealPrice.getToilet() == null || dealPrice.getToilet() < 1) { + deal.put("toilet", ""); + } else { + deal.put("toilet", dealPrice.getToilet().toString()); + } + String fitment = HouseValidator.fetchFitmentInfo(dealPrice.getFitment()); + if (fitment == null) { + deal.put("decoration", ""); + } else { + deal.put("decoration", fitment); + } + String direction = HouseValidator.fetchDirectionInfo(dealPrice.getDirection()); + if (direction == null) { + deal.put("direction", ""); + } else { + deal.put("direction", direction); + } + formateDealPrices.add(deal); + } + mav.setModel(BasicModel.buildOKModel().setResult(formateDealPrices)); + return mav; + } - public Object houseAction(DealPriceModel model) { + public Object houseAction(DealPriceModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getName())) { - mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); - return mav; - } - if (null == model.getSize()) { - mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName().replace(" ",""), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - if (model.getMax() == null || model.getMax() < 1) { - model.setMax(DEFAULT_PAGE_SIZE); - } else if (model.getMax() > 100) { - model.setMax(100); - } - FacetQueryResult houseList = findDistrictHouses(district, model.getMax() * 5); - if (houseList == null || houseList.isEmpty()) {// 通知API没有找到房源 - String cat = "sell"; - String source = ""; - ApiUser apiUser = checkNewAuthorized(model.getToken()); - if (apiUser != null) { - User user = userService.findById(apiUser.getId()); - if (user != null) { - source = user.getUserName(); - } + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); + return mav; + } + if (null == model.getSize()) { + mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName().replace(" ", ""), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + if (model.getMax() == null || model.getMax() < 1) { + model.setMax(DEFAULT_PAGE_SIZE); + } else if (model.getMax() > 100) { + model.setMax(100); + } + FacetQueryResult houseList = findDistrictHouses(district, model.getMax() * 5); + if (houseList == null || houseList.isEmpty()) {// 通知API没有找到房源 + String cat = "sell"; + String source = ""; + ApiUser apiUser = checkNewAuthorized(model.getToken()); + if (apiUser != null) { + User user = userService.findById(apiUser.getId()); + if (user != null) { + source = user.getUserName(); + } - } else { - source = "api调用"; - } + } else { + source = "api调用"; + } - NoHouseDistrict noHouseDistrict = noHouseDistrictService.findNoHouseDistrictByParams(district.getCity(), - district.getRegion(), district.getName(), cat, source); - if (noHouseDistrict == null) { - noHouseDistrict = new NoHouseDistrict(); - noHouseDistrict.setCity(district.getCity()); - noHouseDistrict.setRegion(district.getRegion()); - noHouseDistrict.setName(district.getName()); - noHouseDistrict.setCategory(cat); - noHouseDistrict.setCreationDate(new Date()); - noHouseDistrict.setModificationDate(new Date()); - noHouseDistrict.setLevel(10); - noHouseDistrict.setCrawlCount(0); - noHouseDistrict.setSource(source); - noHouseDistrictService.save(noHouseDistrict); - } - } - List houseBoList = fillDistrictInfoForHouse(houseList, district, model.isConvert()); - orderHouseList(houseBoList, model); - if (houseBoList.size() > model.getMax()) { - houseBoList = new FacetQueryResult(houseBoList.subList(0, model.getMax())); - } - mav.setModel(BasicModel.buildOKModel().setResult(houseBoList)); - return mav; + NoHouseDistrict noHouseDistrict = noHouseDistrictService.findNoHouseDistrictByParams(district.getCity(), + district.getRegion(), district.getName(), cat, source); + if (noHouseDistrict == null) { + noHouseDistrict = new NoHouseDistrict(); + noHouseDistrict.setCity(district.getCity()); + noHouseDistrict.setRegion(district.getRegion()); + noHouseDistrict.setName(district.getName()); + noHouseDistrict.setCategory(cat); + noHouseDistrict.setCreationDate(new Date()); + noHouseDistrict.setModificationDate(new Date()); + noHouseDistrict.setLevel(10); + noHouseDistrict.setCrawlCount(0); + noHouseDistrict.setSource(source); + noHouseDistrictService.save(noHouseDistrict); + } + } + List houseBoList = fillDistrictInfoForHouse(houseList, district, model.isConvert()); + orderHouseList(houseBoList, model); + if (houseBoList.size() > model.getMax()) { + houseBoList = new FacetQueryResult(houseBoList.subList(0, model.getMax())); + } + mav.setModel(BasicModel.buildOKModel().setResult(houseBoList)); + return mav; - } + } - private boolean isRadiusSearch(PropertySearchModel model) { - return model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; - } + private boolean isRadiusSearch(PropertySearchModel model) { + return model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; + } - private String transformPicsToFangJia(String url) { + private String transformPicsToFangJia(String url) { - return "http://static.fangjia.com/stc/fs/" + encodePicUrl(url, "o", "district"); + return "http://static.fangjia.com/stc/fs/" + encodePicUrl(url, "o", "district"); - } + } - public String encodePicUrl(String u, String s, String t) { - try { - return SecurityUtil.encode("u=" + URLEncoder.encode(u, "UTF-8") + "&s=" + s + "&t=" + t); - } catch (Exception e) { - return SecurityUtil.encode("u=" + u + "&s=" + s + "&t=" + t); - } + public String encodePicUrl(String u, String s, String t) { + try { + return SecurityUtil.encode("u=" + URLEncoder.encode(u, "UTF-8") + "&s=" + s + "&t=" + t); + } catch (Exception e) { + return SecurityUtil.encode("u=" + u + "&s=" + s + "&t=" + t); + } - } + } - /** - * 通过EvaluationModel组装Evaluation实体 - * - * @param model - * @param request - * @return - */ - private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { - Evaluation evaluation = new Evaluation(); - evaluation.setCity(model.getCity()); - evaluation.setRegion(model.getRegion()); - evaluation.setDistrictName(model.getName()); - evaluation.setDirection(DIRECTION.get(model.getDirection())); - evaluation.setFitment(EVALUATION_MODEL_FITMENT.get(FITMENT.get(StringUtils.isNotBlank(model.getDecoration()) ? - model.getDecoration() : model.getFitment()))); - evaluation.setNoise(NOISE.get(model.getNoise())); - evaluation.setEstateType(PROPERTY_TYPES.get(model.getPropertyType())); - evaluation.setSight(SIGHT.get(model.getView())); - evaluation.setAtticArea(model.getAtticSize()); - evaluation.setTerraceArea(model.getOuterSize()); - evaluation.setBasementArea(model.getBasementSize()); - evaluation.setGardenArea(model.getGardenSize()); - String worryFacility = model.getNegativeFactor(); - evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility)); - evaluation.setCreationDate(new Date()); - evaluation.setModificationDate(new Date()); - evaluation.setClientNo(model.getClientNo()); - if (0 != model.getAge()) { - evaluation.setAge(model.getAge()); - } - evaluation.setArea(model.getSize()); - if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { - evaluation.setBuildQuality(convertToString(model.getBuildQuality())); - } - if (StringUtils.isNotBlank(model.getBuildType())) { - evaluation.setBuildType(model.getBuildType()); - } - if (StringUtils.isNotBlank(model.getCarport())) { - evaluation.setCarport(model.getCarport()); - } - if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) { - evaluation.setFitmentAge(model.getDecorationAge()); - } - evaluation.setCarportPrice(model.getCarportPrice()); - evaluation.setCity(model.getCity()); - evaluation.setDistrictName(model.getName()); - if (model.getDecorationCost() != null && model.getDecorationCost() > 0) { - evaluation.setFitmentCharge(model.getDecorationCost()); - } - if (0 != model.getHall()) { - evaluation.setHall(model.getHall()); - } - if (null != model.getFloor()) { - evaluation.setFloor(model.getFloor()); - } - if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) { - evaluation.setHeight(model.getMaxFloor()); - } - if (StringUtils.isNotBlank(model.getBuildingNumber())) { - evaluation.setHouseNum(model.getBuildingNumber()); - } - if (StringUtils.isNotBlank(model.getHouseProperty())) { - evaluation.setHouseProperty(model.getHouseProperty()); - } - if (StringUtils.isNotBlank(model.getInsidepos())) { - evaluation.setInsidepos(model.getInsidepos()); - } - if (StringUtils.isNotBlank(model.getLightingVentilation())) { - evaluation.setLightingVentilation(model.getLightingVentilation()); - } + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setDirection(DIRECTION.get(model.getDirection())); + evaluation.setFitment(EVALUATION_MODEL_FITMENT.get(FITMENT.get(StringUtils.isNotBlank(model.getDecoration()) ? + model.getDecoration() : model.getFitment()))); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setEstateType(PROPERTY_TYPES.get(model.getPropertyType())); + evaluation.setSight(SIGHT.get(model.getView())); + evaluation.setAtticArea(model.getAtticSize()); + evaluation.setTerraceArea(model.getOuterSize()); + evaluation.setBasementArea(model.getBasementSize()); + evaluation.setGardenArea(model.getGardenSize()); + String worryFacility = model.getNegativeFactor(); + evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility)); + evaluation.setCreationDate(new Date()); + evaluation.setModificationDate(new Date()); + evaluation.setClientNo(model.getClientNo()); + if (0 != model.getAge()) { + evaluation.setAge(model.getAge()); + } + evaluation.setArea(model.getSize()); + if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { + evaluation.setBuildQuality(convertToString(model.getBuildQuality())); + } + if (StringUtils.isNotBlank(model.getBuildType())) { + evaluation.setBuildType(model.getBuildType()); + } + if (StringUtils.isNotBlank(model.getCarport())) { + evaluation.setCarport(model.getCarport()); + } + if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) { + evaluation.setFitmentAge(model.getDecorationAge()); + } + evaluation.setCarportPrice(model.getCarportPrice()); + evaluation.setCity(model.getCity()); + evaluation.setDistrictName(model.getName()); + if (model.getDecorationCost() != null && model.getDecorationCost() > 0) { + evaluation.setFitmentCharge(model.getDecorationCost()); + } + if (0 != model.getHall()) { + evaluation.setHall(model.getHall()); + } + if (null != model.getFloor()) { + evaluation.setFloor(model.getFloor()); + } + if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) { + evaluation.setHeight(model.getMaxFloor()); + } + if (StringUtils.isNotBlank(model.getBuildingNumber())) { + evaluation.setHouseNum(model.getBuildingNumber()); + } + if (StringUtils.isNotBlank(model.getHouseProperty())) { + evaluation.setHouseProperty(model.getHouseProperty()); + } + if (StringUtils.isNotBlank(model.getInsidepos())) { + evaluation.setInsidepos(model.getInsidepos()); + } + if (StringUtils.isNotBlank(model.getLightingVentilation())) { + evaluation.setLightingVentilation(model.getLightingVentilation()); + } - if (StringUtils.isNotBlank(model.getOtherFactor())) { - evaluation.setOtherFactor(model.getOtherFactor()); - } - evaluation.setRegion(model.getDistrict()); - if (null != model.getRoom()) { - evaluation.setRoom(model.getRoom()); - } - if (StringUtils.isNotBlank(model.getRoomNumber())) { - evaluation.setRoomNum(model.getRoomNumber()); - } - if (StringUtils.isNotBlank(model.getSideset())) { - evaluation.setSideset(model.getSideset()); - } - if (0 != model.getToilet()) { - evaluation.setToilet(model.getToilet()); - } - if (model.getFacilities() != null) { - String facilities = model.getFacilities(); - String[] fs = facilities.split(","); - for (int i = 0; i < fs.length; i++) { - fs[i] = FACILITIES.get(fs[i]); - } - evaluation.setFacilities(convertToString(fs)); - } + if (StringUtils.isNotBlank(model.getOtherFactor())) { + evaluation.setOtherFactor(model.getOtherFactor()); + } + evaluation.setRegion(model.getDistrict()); + if (null != model.getRoom()) { + evaluation.setRoom(model.getRoom()); + } + if (StringUtils.isNotBlank(model.getRoomNumber())) { + evaluation.setRoomNum(model.getRoomNumber()); + } + if (StringUtils.isNotBlank(model.getSideset())) { + evaluation.setSideset(model.getSideset()); + } + if (0 != model.getToilet()) { + evaluation.setToilet(model.getToilet()); + } + if (model.getFacilities() != null) { + String facilities = model.getFacilities(); + String[] fs = facilities.split(","); + for (int i = 0; i < fs.length; i++) { + fs[i] = FACILITIES.get(fs[i]); + } + evaluation.setFacilities(convertToString(fs)); + } - if (StringUtils.isNotBlank(model.getFacade())) { - evaluation.setFacade(model.getFacade()); - } - if (StringUtils.isNotBlank(model.getTraffice())) { - evaluation.setTraffice(model.getTraffice()); - } - if (StringUtils.isNotBlank(model.getShape())) { - evaluation.setShape(model.getShape()); - } - if (StringUtils.isNotBlank(model.getObstacle())) { - evaluation.setObstacle(model.getObstacle()); - } - if (StringUtils.isNotBlank(model.getIndustry())) { - evaluation.setIndustry(model.getIndustry()); - } - if (StringUtils.isNotBlank(model.getSupportDevice())) { - evaluation.setSupportDevice(model.getSupportDevice()); - } - if (StringUtils.isNotBlank(model.getLeftPosition())) { - evaluation.setLeftPosition(model.getLeftPosition()); - } - if (StringUtils.isNotBlank(model.getShopType())) { - evaluation.setShopType(model.getShopType()); - } - if (StringUtils.isNotBlank(model.getShopUnique())) { - evaluation.setShopUnique(model.getShopUnique()); - } - if (StringUtils.isNotBlank(model.getLocation())) { - evaluation.setLocation(model.getLocation()); - } - if (model.isNewDistrict()) { - evaluation.setNewDistrict(model.isNewDistrict()); - } - String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest()); - evaluation.setIp(ip); - AuthenticationBean authenticationBean = (AuthenticationBean) request - .getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); - if (authenticationBean != null && authenticationBean.apiUser != null) { - evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId())); - } - evaluation.setSource("api_property_evaluation"); - return evaluation; - } + if (StringUtils.isNotBlank(model.getFacade())) { + evaluation.setFacade(model.getFacade()); + } + if (StringUtils.isNotBlank(model.getTraffice())) { + evaluation.setTraffice(model.getTraffice()); + } + if (StringUtils.isNotBlank(model.getShape())) { + evaluation.setShape(model.getShape()); + } + if (StringUtils.isNotBlank(model.getObstacle())) { + evaluation.setObstacle(model.getObstacle()); + } + if (StringUtils.isNotBlank(model.getIndustry())) { + evaluation.setIndustry(model.getIndustry()); + } + if (StringUtils.isNotBlank(model.getSupportDevice())) { + evaluation.setSupportDevice(model.getSupportDevice()); + } + if (StringUtils.isNotBlank(model.getLeftPosition())) { + evaluation.setLeftPosition(model.getLeftPosition()); + } + if (StringUtils.isNotBlank(model.getShopType())) { + evaluation.setShopType(model.getShopType()); + } + if (StringUtils.isNotBlank(model.getShopUnique())) { + evaluation.setShopUnique(model.getShopUnique()); + } + if (StringUtils.isNotBlank(model.getLocation())) { + evaluation.setLocation(model.getLocation()); + } + if (model.isNewDistrict()) { + evaluation.setNewDistrict(model.isNewDistrict()); + } + String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest()); + evaluation.setIp(ip); + AuthenticationBean authenticationBean = (AuthenticationBean) request + .getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (authenticationBean != null && authenticationBean.apiUser != null) { + evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId())); + } + evaluation.setSource("api_property_evaluation"); + return evaluation; + } - /** - * 批量获取小区的均价,均价走势数据 - * - * @param request - * @return - */ - public Object priceAction(HttpServletRequest request) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); + /** + * 批量获取小区的均价,均价走势数据 + * + * @param request + * @return + */ + public Object priceAction(HttpServletRequest request) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); - JSONObject jo = getJsonParam(request); - if (jo == null || !jo.containsKey("property") || jo.getJSONArray("property").size() == 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); - return mav; - } - JSONArray ja = jo.getJSONArray("property"); - if (ja.size() > 12) { - mav.setModel(BasicModel.buildBadRequestModel("批量查询小区数超过上限")); - return mav; - } + JSONObject jo = getJsonParam(request); + if (jo == null || !jo.containsKey("property") || jo.getJSONArray("property").size() == 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); + return mav; + } + JSONArray ja = jo.getJSONArray("property"); + if (ja.size() > 12) { + mav.setModel(BasicModel.buildBadRequestModel("批量查询小区数超过上限")); + return mav; + } - JSONArray jsonArray = new JSONArray();// 结果集 - boolean hasData = false; - for (Object o : ja) { - JSONObject subJo = (JSONObject) o; - String id = subJo.containsKey("id") ? subJo.getString("id") : null; - String city = subJo.containsKey("city") ? subJo.getString("city") : null; - String region = subJo.containsKey("district") ? subJo.getString("district") : null; - String name = subJo.containsKey("name") ? subJo.getString("name") : null; - Date updatedDate = DateUtil.getLastWeekendOfLastMonth(new Date()); + JSONArray jsonArray = new JSONArray();// 结果集 + boolean hasData = false; + for (Object o : ja) { + JSONObject subJo = (JSONObject) o; + String id = subJo.containsKey("id") ? subJo.getString("id") : null; + String city = subJo.containsKey("city") ? subJo.getString("city") : null; + String region = subJo.containsKey("district") ? subJo.getString("district") : null; + String name = subJo.containsKey("name") ? subJo.getString("name") : null; + Date updatedDate = DateUtil.getLastWeekendOfLastMonth(new Date()); - JSONObject resultJo = new JSONObject(); - District district; - if (StringUtils.isNotBlank(id)) { - district = districtService.findById(id); - } else { - if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); - return mav; - } - district = districtService.findByNameAndAlias(city, region, name, "district"); - } - if (district == null) { - jsonArray.add(resultJo); - continue; - } - hasData = true; - resultJo.put("id", district.getId()); - resultJo.put("city", district.getCity()); - resultJo.put("district", district.getRegion()); - resultJo.put("name", district.getName()); + JSONObject resultJo = new JSONObject(); + District district; + if (StringUtils.isNotBlank(id)) { + district = districtService.findById(id); + } else { + if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); + return mav; + } + district = districtService.findByNameAndAlias(city, region, name, "district"); + } + if (district == null) { + jsonArray.add(resultJo); + continue; + } + hasData = true; + resultJo.put("id", district.getId()); + resultJo.put("city", district.getCity()); + resultJo.put("district", district.getRegion()); + resultJo.put("name", district.getName()); - int monthCountOfYear = 12;// 一年12个月 - List districtSellStats = districtSellStatService.getAllWithMonths(district.getCity(), - district.getRegion(), district.getName(), monthCountOfYear); - if (CollectionUtils.isNotEmpty(districtSellStats)) { - DistrictSellStat districtSellStat = districtSellStats.get(0); + int monthCountOfYear = 12;// 一年12个月 + List districtSellStats = districtSellStatService.getAllWithMonths(district.getCity(), + district.getRegion(), district.getName(), monthCountOfYear); + if (CollectionUtils.isNotEmpty(districtSellStats)) { + DistrictSellStat districtSellStat = districtSellStats.get(0); - Integer avgPrice = districtSellStat.getAvgPrice(); - Double mom = districtSellStat.getMom(); - Double yoy = districtSellStat.getYoy(); - Integer riseOnMonth = null; - Integer riseOnYear = null; - if (districtSellStats.size() > 1) { - if (districtSellStats.get(1).getDate() + 1 == districtSellStat.getDate()) { - riseOnMonth = avgPrice - districtSellStats.get(1).getAvgPrice(); - } - if (districtSellStats.size() == monthCountOfYear) { - riseOnYear = avgPrice - districtSellStats.get(monthCountOfYear - 1).getAvgPrice(); - } - } + Integer avgPrice = districtSellStat.getAvgPrice(); + Double mom = districtSellStat.getMom(); + Double yoy = districtSellStat.getYoy(); + Integer riseOnMonth = null; + Integer riseOnYear = null; + if (districtSellStats.size() > 1) { + if (districtSellStats.get(1).getDate() + 1 == districtSellStat.getDate()) { + riseOnMonth = avgPrice - districtSellStats.get(1).getAvgPrice(); + } + if (districtSellStats.size() == monthCountOfYear) { + riseOnYear = avgPrice - districtSellStats.get(monthCountOfYear - 1).getAvgPrice(); + } + } - JSONArray trendJa = new JSONArray(); - for (DistrictSellStat jsa : districtSellStats) { - String date = new StringBuffer(jsa.getDate() + "").insert(4, "-").toString(); + JSONArray trendJa = new JSONArray(); + for (DistrictSellStat jsa : districtSellStats) { + String date = new StringBuffer(jsa.getDate() + "").insert(4, "-").toString(); - JSONObject trendJo = new JSONObject(); - trendJo.put("avgPrice", jsa.getAvgPrice()); - trendJo.put("mom", jsa.getMom()); - trendJo.put("date", date); - trendJa.add(trendJo); - } - resultJo.put("avgPrice", avgPrice); - resultJo.put("riseOnMonth", riseOnMonth); - resultJo.put("mom", mom); - resultJo.put("riseOnYear", riseOnYear); - resultJo.put("yoy", yoy); - resultJo.put("updatedDate", sdf.format(updatedDate)); - resultJo.put("avgPriceTrend", trendJa); - } - jsonArray.add(resultJo); - } - if (!hasData) { - BasicModel.markNoDataRequest(); - } - mav.setModel(BasicModel.buildOKModel().setResult(jsonArray)); - return mav; - } + JSONObject trendJo = new JSONObject(); + trendJo.put("avgPrice", jsa.getAvgPrice()); + trendJo.put("mom", jsa.getMom()); + trendJo.put("date", date); + trendJa.add(trendJo); + } + resultJo.put("avgPrice", avgPrice); + resultJo.put("riseOnMonth", riseOnMonth); + resultJo.put("mom", mom); + resultJo.put("riseOnYear", riseOnYear); + resultJo.put("yoy", yoy); + resultJo.put("updatedDate", sdf.format(updatedDate)); + resultJo.put("avgPriceTrend", trendJa); + } + jsonArray.add(resultJo); + } + if (!hasData) { + BasicModel.markNoDataRequest(); + } + mav.setModel(BasicModel.buildOKModel().setResult(jsonArray)); + return mav; + } - public Object floorPlanAction(@Valid FloorPlanModel model) { + public Object floorPlanAction(@Valid FloorPlanModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - District district = districtService.findById(model.getId()); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("未找到该小区")); - return mav; - } - List srcFloorPlanPics = district.getSrcFloorplanPics(); - List floorPlanDtos = new ArrayList(); - for (Object obj : srcFloorPlanPics) { - if (obj != null && obj instanceof Map) { - Map src = (Map) obj; - if (src.containsKey("url") && src.containsKey("main_type") && src.containsKey("main_type_area")) { - FloorPlanDto dto = new FloorPlanDto(); - dto.setUrl(src.get("url")); - dto.setMainHouseType(src.get("main_type")); - dto.setMainHouseTypeArea(src.get("main_type_area")); - dto.setTitle(src.get("description")); - floorPlanDtos.add(dto); - } - } - } - if (floorPlanDtos.isEmpty()) { - for (Object obj : srcFloorPlanPics) { - if (obj != null && obj instanceof Map) { - Map src = (Map) obj; - if (src.containsKey("url") && src.containsKey("description")) { - FloorPlanDto dto = new FloorPlanDto(); - dto.setUrl(src.get("url")); - dto.setTitle(src.get("description")); - floorPlanDtos.add(dto); - } - } - } - } + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + District district = districtService.findById(model.getId()); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("未找到该小区")); + return mav; + } + List srcFloorPlanPics = district.getSrcFloorplanPics(); + List floorPlanDtos = new ArrayList(); + for (Object obj : srcFloorPlanPics) { + if (obj != null && obj instanceof Map) { + Map src = (Map) obj; + if (src.containsKey("url") && src.containsKey("main_type") && src.containsKey("main_type_area")) { + FloorPlanDto dto = new FloorPlanDto(); + dto.setUrl(src.get("url")); + dto.setMainHouseType(src.get("main_type")); + dto.setMainHouseTypeArea(src.get("main_type_area")); + dto.setTitle(src.get("description")); + floorPlanDtos.add(dto); + } + } + } + if (floorPlanDtos.isEmpty()) { + for (Object obj : srcFloorPlanPics) { + if (obj != null && obj instanceof Map) { + Map src = (Map) obj; + if (src.containsKey("url") && src.containsKey("description")) { + FloorPlanDto dto = new FloorPlanDto(); + dto.setUrl(src.get("url")); + dto.setTitle(src.get("description")); + floorPlanDtos.add(dto); + } + } + } + } - mav.setModel(BasicModel.buildOKModel().setResult(floorPlanDtos)); - return mav; - } + mav.setModel(BasicModel.buildOKModel().setResult(floorPlanDtos)); + return mav; + } - /** - * 批量获取小区的配套数据,最多12个小区 - * - * @param request - * @return - */ - public Object facilitiesAction(HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); + /** + * 批量获取小区的配套数据,最多12个小区 + * + * @param request + * @return + */ + public Object facilitiesAction(HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); - JSONObject jo = getJsonParam(request); - if (jo == null || !jo.containsKey("property") || jo.getJSONArray("property").size() == 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); - return mav; - } - // 查询半径 ,默认1000米,最大5000米 - Double radius = getRadius(jo); - if (radius == null) { - mav.setModel(BasicModel.buildBadRequestModel("查询半径(radius)非法")); - return mav; - } - Integer maxNum = getNum(jo); - if (maxNum == null) { - mav.setModel(BasicModel.buildBadRequestModel("最大记录数(num)非法")); - return mav; - } - JSONArray ja = jo.getJSONArray("property"); - if (ja.size() > 12) { - mav.setModel(BasicModel.buildBadRequestModel("批量查询小区数超过上限")); - return mav; - } + JSONObject jo = getJsonParam(request); + if (jo == null || !jo.containsKey("property") || jo.getJSONArray("property").size() == 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); + return mav; + } + // 查询半径 ,默认1000米,最大5000米 + Double radius = getRadius(jo); + if (radius == null) { + mav.setModel(BasicModel.buildBadRequestModel("查询半径(radius)非法")); + return mav; + } + Integer maxNum = getNum(jo); + if (maxNum == null) { + mav.setModel(BasicModel.buildBadRequestModel("最大记录数(num)非法")); + return mav; + } + JSONArray ja = jo.getJSONArray("property"); + if (ja.size() > 12) { + mav.setModel(BasicModel.buildBadRequestModel("批量查询小区数超过上限")); + return mav; + } - JSONArray jsonArray = new JSONArray();// 结果集 - boolean hasData = false; - for (Object o : ja) { - JSONObject subJo = (JSONObject) o; - String id = subJo.containsKey("id") ? subJo.getString("id") : null; - String city = subJo.containsKey("city") ? subJo.getString("city") : null; - String region = subJo.containsKey("district") ? subJo.getString("district") : null; - String name = subJo.containsKey("name") ? subJo.getString("name") : null; + JSONArray jsonArray = new JSONArray();// 结果集 + boolean hasData = false; + for (Object o : ja) { + JSONObject subJo = (JSONObject) o; + String id = subJo.containsKey("id") ? subJo.getString("id") : null; + String city = subJo.containsKey("city") ? subJo.getString("city") : null; + String region = subJo.containsKey("district") ? subJo.getString("district") : null; + String name = subJo.containsKey("name") ? subJo.getString("name") : null; - District district = null; - if (StringUtils.isNotBlank(id)) { - district = districtService.findById(id); - } else { - if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); - return mav; - } - district = districtService.findByNameAndAlias(city, region, name, "district"); - } - JSONObject aroundJo = new JSONObject(); - if (null == district || district.getLat2() == null || district.getLat2() == 0) { - jsonArray.add(aroundJo); - continue; - } - hasData = true; - aroundJo.put("id", district.getId()); - aroundJo.put("city", district.getCity()); - aroundJo.put("district", district.getRegion()); - aroundJo.put("name", district.getName()); + District district = null; + if (StringUtils.isNotBlank(id)) { + district = districtService.findById(id); + } else { + if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("参数格式错误")); + return mav; + } + district = districtService.findByNameAndAlias(city, region, name, "district"); + } + JSONObject aroundJo = new JSONObject(); + if (null == district || district.getLat2() == null || district.getLat2() == 0) { + jsonArray.add(aroundJo); + continue; + } + hasData = true; + aroundJo.put("id", district.getId()); + aroundJo.put("city", district.getCity()); + aroundJo.put("district", district.getRegion()); + aroundJo.put("name", district.getName()); - double lat = district.getLat2() / 10000000000d; - double lng = district.getLng2() / 10000000000d; + double lat = district.getLat2() / 10000000000d; + double lng = district.getLng2() / 10000000000d; - // 查询小区周边(所有类型) - List arrs = baiduApiService.searchNearbyLocalDatabase(district, radius); - Map> districtAroundMap = Maps.newHashMap(); - Map districtAroundCountMap = Maps.newHashMap(); + // 查询小区周边(所有类型) + List arrs = baiduApiService.searchNearbyLocalDatabase(district, radius); + Map> districtAroundMap = Maps.newHashMap(); + Map districtAroundCountMap = Maps.newHashMap(); - for (String key : AROUND_KEYWORD_FACTOR_NEW.keySet()) { - districtAroundMap.put(AROUND_KEYWORD_FACTOR_NEW.get(key), new ArrayList());// 把key的英文put到map并把value设置为一个List引用 - } - for (int i = 0; i < arrs.size(); i++) { - BaiduPlacePoi poiObj = arrs.get(i); - String _name = poiObj.getName(); - String keyword = poiObj.getKeyword(); - double latjs = poiObj.getLat(); - double lngjs = poiObj.getLng(); - String key = AROUND_KEYWORD_FACTOR_NEW.get(keyword); - if (StringUtils.isBlank(key)) { - continue; - } + for (String key : AROUND_KEYWORD_FACTOR_NEW.keySet()) { + districtAroundMap.put(AROUND_KEYWORD_FACTOR_NEW.get(key), new ArrayList());// 把key的英文put到map并把value设置为一个List引用 + } + for (int i = 0; i < arrs.size(); i++) { + BaiduPlacePoi poiObj = arrs.get(i); + String _name = poiObj.getName(); + String keyword = poiObj.getKeyword(); + double latjs = poiObj.getLat(); + double lngjs = poiObj.getLng(); + String key = AROUND_KEYWORD_FACTOR_NEW.get(keyword); + if (StringUtils.isBlank(key)) { + continue; + } - AroundDto dto = new AroundDto(); - dto.setName(_name); - dto.setLat(latjs); - dto.setLng(lngjs); - dto.setDistance((int) GeoUtils.calculateDistance(lng, lat, lngjs, latjs)); - if (districtAroundMap.get(key) != null) { - districtAroundMap.get(key).add(dto);// 按key值取出list add 周边名称已经经纬度 - } - } + AroundDto dto = new AroundDto(); + dto.setName(_name); + dto.setLat(latjs); + dto.setLng(lngjs); + dto.setDistance((int) GeoUtils.calculateDistance(lng, lat, lngjs, latjs)); + if (districtAroundMap.get(key) != null) { + districtAroundMap.get(key).add(dto);// 按key值取出list add 周边名称已经经纬度 + } + } - // 周边公交、地铁 - Map> stationMap = busStationService.getNearByStations(district.getCity(), lat, lng, - radius); - addToDistrictAroundMap(districtAroundMap, stationMap, district, "公交"); - addToDistrictAroundMap(districtAroundMap, stationMap, district, "地铁"); + // 周边公交、地铁 + Map> stationMap = busStationService.getNearByStations(district.getCity(), lat, lng, + radius); + addToDistrictAroundMap(districtAroundMap, stationMap, district, "公交"); + addToDistrictAroundMap(districtAroundMap, stationMap, district, "地铁"); - // 根据maxNum参数过滤返回值数量,并由近及远排序 - filterAndSortResult(districtAroundMap, districtAroundCountMap, maxNum); + // 根据maxNum参数过滤返回值数量,并由近及远排序 + filterAndSortResult(districtAroundMap, districtAroundCountMap, maxNum); - // 封装成需要的返回格式 - for (Map.Entry> entry : districtAroundMap.entrySet()) { - String key = entry.getKey(); - List listVal = entry.getValue(); - if (CollectionUtils.isEmpty(listVal)) { - continue; - } - JSONObject jsonObject = new JSONObject(); - jsonObject.put("count", districtAroundCountMap.get(key)); - jsonObject.put(listKeyMap.get(key), listVal); - aroundJo.put(key, jsonObject); - } + // 封装成需要的返回格式 + for (Map.Entry> entry : districtAroundMap.entrySet()) { + String key = entry.getKey(); + List listVal = entry.getValue(); + if (CollectionUtils.isEmpty(listVal)) { + continue; + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("count", districtAroundCountMap.get(key)); + jsonObject.put(listKeyMap.get(key), listVal); + aroundJo.put(key, jsonObject); + } - jsonArray.add(aroundJo); - } - if (!hasData) { - BasicModel.markNoDataRequest(); - } - mav.setModel(BasicModel.buildOKModel().setResult(jsonArray)); - return mav; - } + jsonArray.add(aroundJo); + } + if (!hasData) { + BasicModel.markNoDataRequest(); + } + mav.setModel(BasicModel.buildOKModel().setResult(jsonArray)); + return mav; + } - private void filterAndSortResult(Map> districtAroundMap, - Map districtAroundCountMap, int maxNum) { - for (Map.Entry> entry : districtAroundMap.entrySet()) { - List dtos = entry.getValue(); - districtAroundCountMap.put(entry.getKey(), CollectionUtils.isEmpty(dtos) ? 0 : dtos.size()); - if (dtos != null && dtos.size() > 1) { - Collections.sort(dtos, new Comparator() { - @Override - public int compare(AroundDto o1, AroundDto o2) { - return o1.getDistance() - o2.getDistance(); - } - }); - } - if (maxNum < Integer.MAX_VALUE) { - dtos = dtos.subList(0, Math.min(dtos.size(), maxNum)); - } - districtAroundMap.put(entry.getKey(), dtos); - } - } + private void filterAndSortResult(Map> districtAroundMap, + Map districtAroundCountMap, int maxNum) { + for (Map.Entry> entry : districtAroundMap.entrySet()) { + List dtos = entry.getValue(); + districtAroundCountMap.put(entry.getKey(), CollectionUtils.isEmpty(dtos) ? 0 : dtos.size()); + if (dtos != null && dtos.size() > 1) { + Collections.sort(dtos, new Comparator() { + @Override + public int compare(AroundDto o1, AroundDto o2) { + return o1.getDistance() - o2.getDistance(); + } + }); + } + if (maxNum < Integer.MAX_VALUE) { + dtos = dtos.subList(0, Math.min(dtos.size(), maxNum)); + } + districtAroundMap.put(entry.getKey(), dtos); + } + } - /** - * 获取JSON参数中的num参数值 - * - * @param jo - * @return - */ - private Integer getNum(JSONObject jo) { - Integer num = Integer.MAX_VALUE; - if (jo.containsKey("num")) { - try { - if (!jo.getString("num").matches("\\d+")) { - num = null; - } else { - num = jo.getInt("num"); - if (num <= 0) { - num = null; - } - } - } catch (Exception e) { - num = null; - } - } - return num; - } + /** + * 获取JSON参数中的num参数值 + * + * @param jo + * @return + */ + private Integer getNum(JSONObject jo) { + Integer num = Integer.MAX_VALUE; + if (jo.containsKey("num")) { + try { + if (!jo.getString("num").matches("\\d+")) { + num = null; + } else { + num = jo.getInt("num"); + if (num <= 0) { + num = null; + } + } + } catch (Exception e) { + num = null; + } + } + return num; + } - /** - * 获取JSON参数中的radius值 - * - * @param jo - * @return - */ - private Double getRadius(JSONObject jo) { - Double radius = 1000d; - if (jo.containsKey("radius")) { - try { - radius = jo.getDouble("radius"); - if (radius <= 0 || radius > 5000) { - radius = null; - } - } catch (Exception e) { - radius = null; - } - } - return radius; - } + /** + * 获取JSON参数中的radius值 + * + * @param jo + * @return + */ + private Double getRadius(JSONObject jo) { + Double radius = 1000d; + if (jo.containsKey("radius")) { + try { + radius = jo.getDouble("radius"); + if (radius <= 0 || radius > 5000) { + radius = null; + } + } catch (Exception e) { + radius = null; + } + } + return radius; + } - private void addToDistrictAroundMap(Map> districtAroundMap, - Map> stationMap, District district, String type) { - List busList = stationMap.get(type); - Set stationCache = Sets.newHashSet();// 记录是否有重复站点 - List aroundDtos = Lists.newArrayList(); - double lat = district.getLat2() / 10000000000d; - double lng = district.getLng2() / 10000000000d; - if (CollectionUtils.isNotEmpty(busList)) { - for (BusStation bs : busList) { - if (stationCache.add(bs.getStation())) { - AroundDto aroundDto = new AroundDto(); - aroundDto.setLat(bs.getLat()); - aroundDto.setLng(bs.getLng()); - aroundDto.setName(bs.getStation()); - aroundDto.setDistance((int) GeoUtils.calculateDistance(lng, lat, bs.getLng(), bs.getLat())); - aroundDtos.add(aroundDto); - } - } - String key = AROUND_KEYWORD_FACTOR_NEW.get(type); - districtAroundMap.put(key, aroundDtos); - } - } + private void addToDistrictAroundMap(Map> districtAroundMap, + Map> stationMap, District district, String type) { + List busList = stationMap.get(type); + Set stationCache = Sets.newHashSet();// 记录是否有重复站点 + List aroundDtos = Lists.newArrayList(); + double lat = district.getLat2() / 10000000000d; + double lng = district.getLng2() / 10000000000d; + if (CollectionUtils.isNotEmpty(busList)) { + for (BusStation bs : busList) { + if (stationCache.add(bs.getStation())) { + AroundDto aroundDto = new AroundDto(); + aroundDto.setLat(bs.getLat()); + aroundDto.setLng(bs.getLng()); + aroundDto.setName(bs.getStation()); + aroundDto.setDistance((int) GeoUtils.calculateDistance(lng, lat, bs.getLng(), bs.getLat())); + aroundDtos.add(aroundDto); + } + } + String key = AROUND_KEYWORD_FACTOR_NEW.get(type); + districtAroundMap.put(key, aroundDtos); + } + } - public Object searchRoomAction(PropertyEvaluationModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getKeyword())) { - mav.setModel(BasicModel.buildBadRequestModel("keyword(关键词)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getUnitNumber())) { - mav.setModel(BasicModel.buildBadRequestModel("unitNumber(室号)不能为空")); - return mav; - } + public Object searchRoomAction(PropertyEvaluationModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getKeyword())) { + mav.setModel(BasicModel.buildBadRequestModel("keyword(关键词)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getUnitNumber())) { + mav.setModel(BasicModel.buildBadRequestModel("unitNumber(室号)不能为空")); + return mav; + } - District district = null; - // if(StringUtils.isNotBlank(model.getDistrict())){ - district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getKeyword(), - "district"); - // } - if (district == null) { - Map result = addressParser.parse2(model.getCity(), model.getKeyword(), "district", false); - saveAddressMatchLog(result, model.getKeyword(), model.getCity(), model.getToken()); - Integer status = (Integer) result.get("status"); - Integer precise = (Integer) result.get("precise"); - if (status != null && status == 0 && precise == 0) { - String id = (String) result.get("id"); - District matchDistrict = districtService.findById(id); - if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().equals(matchDistrict.getRegion())) { - district = matchDistrict; - } - } else { - saveAddressMatchLog(result, model.getKeyword(), model.getCity(), model.getToken()); - } - } - if (district == null) { - mav.setModel(BasicModel.buildOKModel()); - return mav; - } - HouseLoudong loudong = houseLoudongService.findHouseLoudong(district.getCity(), district.getRegion(), - district.getName(), model.getBuildingNumber(), "1", model.getUnitNumber()); - if (loudong != null) { - mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(loudong, district, model.isConvert()))); - return mav; - } - FjtEvaluation fjtEvaluation = fjtEvaluationService.findFjtEvaluationByConditions(district.getCity(), - district.getRegion(), district.getName(), model.getBuildingNumber(), model.getUnitNumber()); - if (fjtEvaluation != null) { - mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(fjtEvaluation, district, model.isConvert()))); - return mav; - } + District district = null; + // if(StringUtils.isNotBlank(model.getDistrict())){ + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getKeyword(), + "district"); + // } + if (district == null) { + Map result = addressParser.parse2(model.getCity(), model.getKeyword(), "district", false); + saveAddressMatchLog(result, model.getKeyword(), model.getCity(), model.getToken()); + Integer status = (Integer) result.get("status"); + Integer precise = (Integer) result.get("precise"); + if (status != null && status == 0 && precise == 0) { + String id = (String) result.get("id"); + District matchDistrict = districtService.findById(id); + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().equals(matchDistrict.getRegion())) { + district = matchDistrict; + } + } else { + saveAddressMatchLog(result, model.getKeyword(), model.getCity(), model.getToken()); + } + } + if (district == null) { + mav.setModel(BasicModel.buildOKModel()); + return mav; + } + HouseLoudong loudong = houseLoudongService.findHouseLoudong(district.getCity(), district.getRegion(), + district.getName(), model.getBuildingNumber(), "1", model.getUnitNumber()); + if (loudong != null) { + mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(loudong, district, model.isConvert()))); + return mav; + } + FjtEvaluation fjtEvaluation = fjtEvaluationService.findFjtEvaluationByConditions(district.getCity(), + district.getRegion(), district.getName(), model.getBuildingNumber(), model.getUnitNumber()); + if (fjtEvaluation != null) { + mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(fjtEvaluation, district, model.isConvert()))); + return mav; + } - Evaluation evaluation = evaluationService.findEvaluationByNum(district.getCity(), district.getRegion(), - district.getName(), model.getBuildingNumber(), model.getUnitNumber()); - if (evaluation != null) { - mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(evaluation, district, model.isConvert()))); - return mav; - } - mav.setModel(BasicModel.buildOKModel()); - return mav; + Evaluation evaluation = evaluationService.findEvaluationByNum(district.getCity(), district.getRegion(), + district.getName(), model.getBuildingNumber(), model.getUnitNumber()); + if (evaluation != null) { + mav.setModel(BasicModel.buildOKModel().setResult(convertToRoomInfo(evaluation, district, model.isConvert()))); + return mav; + } + mav.setModel(BasicModel.buildOKModel()); + return mav; - } + } - /** - * 把房价通估价,房价网估价以及房子信息转成房子信息 - * - * @param in - * @param district - * @param convert - * @return - */ - private Map convertToRoomInfo(Object in, District district, boolean convert) { - LinkedHashMap result = new LinkedHashMap(); - if (in instanceof HouseLoudong) { - HouseLoudong loudong = (HouseLoudong) in; - result.put("city", district.getCity()); - result.put("district", district.getRegion()); - result.put("name", district.getName()); - result.put("address", district.getAddress()); - result.put("propertyType", district.getEstateType2()); - if (loudong.getHouseNum() == null) { - result.put("buildingNumber", ""); - } else { - result.put("buildingNumber", loudong.getHouseNum()); - } - if (null == loudong.getRoomNum()) { - result.put("unitNumber", ""); - } else { - result.put("unitNumber", loudong.getRoomNum()); - } - if (loudong.getHouseArea() > 0) { - result.put("size", DataUtil.roundDouble(loudong.getHouseArea(), 2) + ""); - } else { - result.put("size", ""); - } + /** + * 把房价通估价,房价网估价以及房子信息转成房子信息 + * + * @param in + * @param district + * @param convert + * @return + */ + private Map convertToRoomInfo(Object in, District district, boolean convert) { + LinkedHashMap result = new LinkedHashMap(); + if (in instanceof HouseLoudong) { + HouseLoudong loudong = (HouseLoudong) in; + result.put("city", district.getCity()); + result.put("district", district.getRegion()); + result.put("name", district.getName()); + result.put("address", district.getAddress()); + result.put("propertyType", district.getEstateType2()); + if (loudong.getHouseNum() == null) { + result.put("buildingNumber", ""); + } else { + result.put("buildingNumber", loudong.getHouseNum()); + } + if (null == loudong.getRoomNum()) { + result.put("unitNumber", ""); + } else { + result.put("unitNumber", loudong.getRoomNum()); + } + if (loudong.getHouseArea() > 0) { + result.put("size", DataUtil.roundDouble(loudong.getHouseArea(), 2) + ""); + } else { + result.put("size", ""); + } - if (loudong.getHouseFloor() > 0) { - result.put("floor", loudong.getHouseFloor() + ""); - } else { - result.put("floor", ""); - } - if (loudong.getHouseHeight() > 0) { - result.put("maxFloor", loudong.getHouseHeight() + ""); - } else { - result.put("maxFloor", ""); - } - if (loudong.getRoom() > 0) { - result.put("room", loudong.getRoom() + ""); - } else { - result.put("room", ""); - } - if (loudong.getHall() > 0) { - result.put("hall", loudong.getHall() + ""); - } else { - result.put("hall", ""); - } - if (loudong.getToilet() > 0) { - result.put("toilet", loudong.getToilet() + ""); - } else { - result.put("toilet", ""); - } - if (null == loudong.getDirection()) { - result.put("direction", ""); - } else { - result.put("direction", loudong.getDirection()); - } - if (null == loudong.getFitmentRank()) { - result.put("decoration", ""); - } else { - result.put("decoration", HouseValidator.fetchFitmentInfo(loudong.getFitmentRank())); - } - } else if (in instanceof FjtEvaluation) { - FjtEvaluation fjtEvaluation = (FjtEvaluation) in; - result.put("city", district.getCity()); - result.put("district", district.getRegion()); - result.put("name", district.getName()); - result.put("address", district.getAddress()); - result.put("propertyType", district.getEstateType2()); - if (null == fjtEvaluation.getHouseNum()) { - result.put("buildingNumber", ""); - } else { - result.put("buildingNumber", fjtEvaluation.getHouseNum()); - } - if (null == fjtEvaluation.getHouseNum()) { - result.put("unitNumber", ""); - } else { - result.put("unitNumber", fjtEvaluation.getRoomNum()); - } + if (loudong.getHouseFloor() > 0) { + result.put("floor", loudong.getHouseFloor() + ""); + } else { + result.put("floor", ""); + } + if (loudong.getHouseHeight() > 0) { + result.put("maxFloor", loudong.getHouseHeight() + ""); + } else { + result.put("maxFloor", ""); + } + if (loudong.getRoom() > 0) { + result.put("room", loudong.getRoom() + ""); + } else { + result.put("room", ""); + } + if (loudong.getHall() > 0) { + result.put("hall", loudong.getHall() + ""); + } else { + result.put("hall", ""); + } + if (loudong.getToilet() > 0) { + result.put("toilet", loudong.getToilet() + ""); + } else { + result.put("toilet", ""); + } + if (null == loudong.getDirection()) { + result.put("direction", ""); + } else { + result.put("direction", loudong.getDirection()); + } + if (null == loudong.getFitmentRank()) { + result.put("decoration", ""); + } else { + result.put("decoration", HouseValidator.fetchFitmentInfo(loudong.getFitmentRank())); + } + } else if (in instanceof FjtEvaluation) { + FjtEvaluation fjtEvaluation = (FjtEvaluation) in; + result.put("city", district.getCity()); + result.put("district", district.getRegion()); + result.put("name", district.getName()); + result.put("address", district.getAddress()); + result.put("propertyType", district.getEstateType2()); + if (null == fjtEvaluation.getHouseNum()) { + result.put("buildingNumber", ""); + } else { + result.put("buildingNumber", fjtEvaluation.getHouseNum()); + } + if (null == fjtEvaluation.getHouseNum()) { + result.put("unitNumber", ""); + } else { + result.put("unitNumber", fjtEvaluation.getRoomNum()); + } - if (fjtEvaluation.getHouseArea() > 0) { - result.put("size", DataUtil.roundDouble(fjtEvaluation.getHouseArea(), 2) + ""); - } else { - result.put("size", ""); - } - if (fjtEvaluation.getHouseFloor() > 0) { - result.put("floor", fjtEvaluation.getHouseFloor() + ""); - } else { - result.put("floor", ""); - } - if (fjtEvaluation.getHouseHight() > 0) { - result.put("maxFloor", fjtEvaluation.getHouseHight() + ""); - } else { - result.put("maxFloor", ""); - } - if (fjtEvaluation.getHouseRoom() != null) { - result.put("room", fjtEvaluation.getHouseRoom().toString()); - } else { - result.put("room", ""); - } - if (fjtEvaluation.getHouseHall() != null) { - result.put("hall", fjtEvaluation.getHouseHall().toString()); - } else { - result.put("room", ""); - } - if (FJT_DIRECTION.get(fjtEvaluation.getDirection() + "") == null) { - result.put("direction", ""); - } else { - result.put("direction", FJT_DIRECTION.get(fjtEvaluation.getDirection() + "")); - } - if (FJT_FITMENT.get(fjtEvaluation.getFitment() + "") == null) { - result.put("decoration", ""); - } else { - result.put("decoration", - HouseValidator.fetchFitmentInfo(FJT_FITMENT.get(fjtEvaluation.getFitment() + ""))); - } - } else if (in instanceof Evaluation) { - Evaluation evaluation = (Evaluation) in; - result.put("city", district.getCity()); - result.put("district", district.getRegion()); - result.put("name", district.getName()); - result.put("address", district.getAddress()); - result.put("propertyType", district.getEstateType2()); - if (null == evaluation.getHouseNum()) { - result.put("buildingNumber", ""); - } else { - result.put("buildingNumber", evaluation.getHouseNum()); - } - if (null == evaluation.getRoomNum()) { - result.put("unitNumber", ""); - } else { - result.put("unitNumber", evaluation.getRoomNum()); - } - if (null == evaluation.getArea() || evaluation.getArea() < 0) { - result.put("size", ""); - } else { - result.put("size", DataUtil.roundDouble(evaluation.getArea(), 2) + ""); - } - if (null == evaluation.getFloor() || evaluation.getFloor() < 0) { - result.put("floor", ""); - } else { - result.put("floor", evaluation.getFloor().toString()); - } - if (null == evaluation.getHeight() || evaluation.getHeight() < 0) { - result.put("maxFloor", ""); - } else { - result.put("maxFloor", evaluation.getHeight().toString()); - } - if (evaluation.getRoom() != null && evaluation.getRoom() > 0) { - result.put("room", evaluation.getRoom().toString()); - } else { - result.put("room", 0); - } - if (evaluation.getHall() != null && evaluation.getHall() > 0) { - result.put("hall", evaluation.getHall().toString()); - } else { - result.put("hall", ""); - } - if (evaluation.getToilet() != null && evaluation.getToilet() > 0) { - result.put("toilet", evaluation.getToilet().toString()); - } else { - result.put("toilet", ""); - } - if (evaluation.getDirection() == null) { - result.put("direction", ""); - } else { - result.put("direction", evaluation.getDirection()); - } - if (evaluation.getFitment() == null) { - result.put("decoration", ""); - } else { - result.put("decoration", HouseValidator.fetchFitmentInfo(evaluation.getFitment())); - } - } + if (fjtEvaluation.getHouseArea() > 0) { + result.put("size", DataUtil.roundDouble(fjtEvaluation.getHouseArea(), 2) + ""); + } else { + result.put("size", ""); + } + if (fjtEvaluation.getHouseFloor() > 0) { + result.put("floor", fjtEvaluation.getHouseFloor() + ""); + } else { + result.put("floor", ""); + } + if (fjtEvaluation.getHouseHight() > 0) { + result.put("maxFloor", fjtEvaluation.getHouseHight() + ""); + } else { + result.put("maxFloor", ""); + } + if (fjtEvaluation.getHouseRoom() != null) { + result.put("room", fjtEvaluation.getHouseRoom().toString()); + } else { + result.put("room", ""); + } + if (fjtEvaluation.getHouseHall() != null) { + result.put("hall", fjtEvaluation.getHouseHall().toString()); + } else { + result.put("room", ""); + } + if (FJT_DIRECTION.get(fjtEvaluation.getDirection() + "") == null) { + result.put("direction", ""); + } else { + result.put("direction", FJT_DIRECTION.get(fjtEvaluation.getDirection() + "")); + } + if (FJT_FITMENT.get(fjtEvaluation.getFitment() + "") == null) { + result.put("decoration", ""); + } else { + result.put("decoration", + HouseValidator.fetchFitmentInfo(FJT_FITMENT.get(fjtEvaluation.getFitment() + ""))); + } + } else if (in instanceof Evaluation) { + Evaluation evaluation = (Evaluation) in; + result.put("city", district.getCity()); + result.put("district", district.getRegion()); + result.put("name", district.getName()); + result.put("address", district.getAddress()); + result.put("propertyType", district.getEstateType2()); + if (null == evaluation.getHouseNum()) { + result.put("buildingNumber", ""); + } else { + result.put("buildingNumber", evaluation.getHouseNum()); + } + if (null == evaluation.getRoomNum()) { + result.put("unitNumber", ""); + } else { + result.put("unitNumber", evaluation.getRoomNum()); + } + if (null == evaluation.getArea() || evaluation.getArea() < 0) { + result.put("size", ""); + } else { + result.put("size", DataUtil.roundDouble(evaluation.getArea(), 2) + ""); + } + if (null == evaluation.getFloor() || evaluation.getFloor() < 0) { + result.put("floor", ""); + } else { + result.put("floor", evaluation.getFloor().toString()); + } + if (null == evaluation.getHeight() || evaluation.getHeight() < 0) { + result.put("maxFloor", ""); + } else { + result.put("maxFloor", evaluation.getHeight().toString()); + } + if (evaluation.getRoom() != null && evaluation.getRoom() > 0) { + result.put("room", evaluation.getRoom().toString()); + } else { + result.put("room", 0); + } + if (evaluation.getHall() != null && evaluation.getHall() > 0) { + result.put("hall", evaluation.getHall().toString()); + } else { + result.put("hall", ""); + } + if (evaluation.getToilet() != null && evaluation.getToilet() > 0) { + result.put("toilet", evaluation.getToilet().toString()); + } else { + result.put("toilet", ""); + } + if (evaluation.getDirection() == null) { + result.put("direction", ""); + } else { + result.put("direction", evaluation.getDirection()); + } + if (evaluation.getFitment() == null) { + result.put("decoration", ""); + } else { + result.put("decoration", HouseValidator.fetchFitmentInfo(evaluation.getFitment())); + } + } - return result; + return result; - } + } - public AddressParser getAddressParser() { - return addressParser; - } + public AddressParser getAddressParser() { + return addressParser; + } - public void setAddressParser(AddressParser addressParser) { - this.addressParser = addressParser; - } + public void setAddressParser(AddressParser addressParser) { + this.addressParser = addressParser; + } - private String convertToString(String[] strs) { - if (ArrayUtils.isNotEmpty(strs)) { - StringBuffer ret = new StringBuffer(); - for (String str : strs) { - if (StringUtils.isEmpty(ret.toString())) { - ret.append(str); - } else { - ret.append(",").append(str); - } - } - return ret.toString(); - } - return null; - } + private String convertToString(String[] strs) { + if (ArrayUtils.isNotEmpty(strs)) { + StringBuffer ret = new StringBuffer(); + for (String str : strs) { + if (StringUtils.isEmpty(ret.toString())) { + ret.append(str); + } else { + ret.append(",").append(str); + } + } + return ret.toString(); + } + return null; + } - private List findDealPricesByNames(String city, String region, List names, int max, - DealPriceModel model) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("region", region)); - params.add(new QueryParam("districtName", QueryParam.IN_OPERATOR, names)); - if (model.getRoom() != null) { - params.add(new QueryParam("room", model.getRoom())); - } - if (model.getHall() != null) { - params.add(new QueryParam("hall", model.getHall())); - } - // 18年之后抓住的数据没有score字段 + private List findDealPricesByNames(String city, String region, List names, int max, + DealPriceModel model) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("region", region)); + params.add(new QueryParam("districtName", QueryParam.IN_OPERATOR, names)); + if (model.getRoom() != null) { + params.add(new QueryParam("room", model.getRoom())); + } + if (model.getHall() != null) { + params.add(new QueryParam("hall", model.getHall())); + } + // 18年之后抓住的数据没有score字段 // params.add(new QueryParam("score", QueryParam.GREATER_THAN_OPERATOR, 200000000000l)); - List dealPrices = dealPriceService.findDealPrices(params, max); - List distinctDealPrices = new ArrayList(); - for (DealPrice dealPrice : dealPrices) { - if (dealPrice.getAvgPrice() == null) { - dealPrice.setAvgPrice((int) (dealPrice.getTotalPrice() / dealPrice.getArea())); - } - if (!checkExists(distinctDealPrices, dealPrice)) { - distinctDealPrices.add(dealPrice); - } - } - return distinctDealPrices; - } + List dealPrices = dealPriceService.findDealPrices(params, max); + List distinctDealPrices = new ArrayList(); + for (DealPrice dealPrice : dealPrices) { + if (dealPrice.getAvgPrice() == null) { + dealPrice.setAvgPrice((int) (dealPrice.getTotalPrice() / dealPrice.getArea())); + } + if (!checkExists(distinctDealPrices, dealPrice)) { + distinctDealPrices.add(dealPrice); + } + } + return distinctDealPrices; + } - private List findDealPricesByName(String city, String region, String name, int max, - DealPriceModel model) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("region", region)); - params.add(new QueryParam("districtName", name)); - if (model.getRoom() != null) { - params.add(new QueryParam("room", model.getRoom())); - } - if (model.getHall() != null) { - params.add(new QueryParam("hall", model.getHall())); - } - // 18年之后抓住的数据没有score字段 + private List findDealPricesByName(String city, String region, String name, int max, + DealPriceModel model) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("region", region)); + params.add(new QueryParam("districtName", name)); + if (model.getRoom() != null) { + params.add(new QueryParam("room", model.getRoom())); + } + if (model.getHall() != null) { + params.add(new QueryParam("hall", model.getHall())); + } + // 18年之后抓住的数据没有score字段 // params.add(new QueryParam("score", QueryParam.GREATER_THAN_OPERATOR, 200000000000l)); - List dealPrices = dealPriceService.findDealPrices(params, max); - List distinctDealPrices = new ArrayList(); - for (DealPrice dealPrice : dealPrices) { - if (dealPrice.getAvgPrice() == null) { - dealPrice.setAvgPrice((int) (dealPrice.getTotalPrice() / dealPrice.getArea())); - } - if (!checkExists(distinctDealPrices, dealPrice)) { - distinctDealPrices.add(dealPrice); - } - } - return distinctDealPrices; - } + List dealPrices = dealPriceService.findDealPrices(params, max); + List distinctDealPrices = new ArrayList(); + for (DealPrice dealPrice : dealPrices) { + if (dealPrice.getAvgPrice() == null) { + dealPrice.setAvgPrice((int) (dealPrice.getTotalPrice() / dealPrice.getArea())); + } + if (!checkExists(distinctDealPrices, dealPrice)) { + distinctDealPrices.add(dealPrice); + } + } + return distinctDealPrices; + } - private boolean checkExists(List dealPrices, DealPrice dealPrice) { - for (DealPrice bo : dealPrices) { - if (bo.getArea().equals(dealPrice.getArea()) && bo.getAvgPrice().equals(dealPrice.getAvgPrice()) - && bo.getTradeDate().equals(dealPrice.getTradeDate())) { - return true; - } - } - return false; - } + private boolean checkExists(List dealPrices, DealPrice dealPrice) { + for (DealPrice bo : dealPrices) { + if (bo.getArea().equals(dealPrice.getArea()) && bo.getAvgPrice().equals(dealPrice.getAvgPrice()) + && bo.getTradeDate().equals(dealPrice.getTradeDate())) { + return true; + } + } + return false; + } - private void orderHouseList(List houseBoList, final DealPriceModel model) { + private void orderHouseList(List houseBoList, final DealPriceModel model) { - Integer floor = null; - final Double size = model.getSize(); + Integer floor = null; + final Double size = model.getSize(); - try { - floor = Integer.valueOf(model.getFloor()); - } catch (Exception e) { + try { + floor = Integer.valueOf(model.getFloor()); + } catch (Exception e) { - } - final Integer fFloor = floor; + } + final Integer fFloor = floor; - Collections.sort(houseBoList, new Comparator() { - @Override - public int compare(NewHousePojo o1, NewHousePojo o2) { - Double score1 = computeScore(o1); - Double score2 = computeScore(o2); - return score2.compareTo(score1); - } + Collections.sort(houseBoList, new Comparator() { + @Override + public int compare(NewHousePojo o1, NewHousePojo o2) { + Double score1 = computeScore(o1); + Double score2 = computeScore(o2); + return score2.compareTo(score1); + } - private double computeScore(NewHousePojo bo) { - double score = 0; - if (StringUtils.isNotBlank(bo.getFloor()) && fFloor != null) { - double _floor = Double.valueOf(bo.getFloor()); - score += computeAreaScore(_floor, fFloor) * 0.02; - } - if (StringUtils.isNotBlank(bo.getSize()) && size != null) { - double _size = Double.valueOf(bo.getSize()); - score += computeAreaScore(_size, size) * 0.98; - } - return score; - } + private double computeScore(NewHousePojo bo) { + double score = 0; + if (StringUtils.isNotBlank(bo.getFloor()) && fFloor != null) { + double _floor = Double.valueOf(bo.getFloor()); + score += computeAreaScore(_floor, fFloor) * 0.02; + } + if (StringUtils.isNotBlank(bo.getSize()) && size != null) { + double _size = Double.valueOf(bo.getSize()); + score += computeAreaScore(_size, size) * 0.98; + } + return score; + } - private double computeAreaScore(double a1, double a2) { - return 2 / (1 + Math.exp(Math.abs(1 - a1 / a2))); - } + private double computeAreaScore(double a1, double a2) { + return 2 / (1 + Math.exp(Math.abs(1 - a1 / a2))); + } - }); - } + }); + } - /** - * ????С????? - * - * @param district - * @return - */ - private FacetQueryResult findDistrictHouses(District district, int max) { - return houseService.findHouses(district, null, 0, max); - } + /** + * ????С????? + * + * @param district + * @return + */ + private FacetQueryResult findDistrictHouses(District district, int max) { + return houseService.findHouses(district, null, 0, max); + } - /** - * 新版token验证 - * - * @param token - * @return - */ - private ApiUser checkNewAuthorized(String token) { - Map tokenMap = FangjiaApiUtil.parseToken(token); - if (tokenMap == null) { - return null; - } - // token验证后,拿取出的字段再去数据库验证一遍 - if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { - List params = new ArrayList(); - params.add(new QueryParam("ID", tokenMap.get("userid"))); - ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); - if (apiUser != null) { - if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { - return apiUser; - } - } - } - return null; - } + /** + * 新版token验证 + * + * @param token + * @return + */ + private ApiUser checkNewAuthorized(String token) { + Map tokenMap = FangjiaApiUtil.parseToken(token); + if (tokenMap == null) { + return null; + } + // token验证后,拿取出的字段再去数据库验证一遍 + if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { + List params = new ArrayList(); + params.add(new QueryParam("ID", tokenMap.get("userid"))); + ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); + if (apiUser != null) { + if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { + return apiUser; + } + } + } + return null; + } - private JSONObject getJsonParam(HttpServletRequest request) { - JSONObject jo = null; - StringBuffer sb = new StringBuffer(); - try { - BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8")); - String line; - while ((line = br.readLine()) != null) { - sb.append(line); - } - try { - jo = JSONObject.fromObject(sb.toString()); - } catch (Exception e) { - LOGGER.error("getJsonParam:" + sb.toString()); - } - } catch (Exception e) { - jo = null; - } + private JSONObject getJsonParam(HttpServletRequest request) { + JSONObject jo = null; + StringBuffer sb = new StringBuffer(); + try { + BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8")); + String line; + while ((line = br.readLine()) != null) { + sb.append(line); + } + try { + jo = JSONObject.fromObject(sb.toString()); + } catch (Exception e) { + LOGGER.error("getJsonParam:" + sb.toString()); + } + } catch (Exception e) { + jo = null; + } - return jo; - } + return jo; + } - private List fillDistrictInfoForHouse(FacetQueryResult houseList, - District district, boolean convert) { - FacetQueryResult list = new FacetQueryResult(); - for (com.fangjia.service.bo.HouseBo bo : houseList) { - House house = bo.getHouse(); - NewHousePojo b = new NewHousePojo(); - b.setCity(house.getCity()); - b.setDistrict(district.getRegion()); - if (null == district.getBlock()) { - b.setBlock(""); - } else { - b.setBlock(district.getBlock()); - } - b.setName(district.getName()); - b.setAddress(bo.getAddress() == null ? district.getAddress() : bo.getAddress()); - if (house.getArea() != null) { - b.setSize(house.getArea().toString()); - } else { - b.setSize(""); - } - if (house.getTotalPrice() != null) { - b.setListingPrice(house.getTotalPrice().toString()); - } else { - b.setListingPrice(""); - } - if (b.getSize() != null && b.getListingPrice() != null && house.getArea() != 0) { - b.setAvgPrice((int) (house.getTotalPrice() / house.getArea())); - if (b.getAvgPrice() > 300000 || b.getAvgPrice() < 1000) { - continue; - } - } + private List fillDistrictInfoForHouse(FacetQueryResult houseList, + District district, boolean convert) { + FacetQueryResult list = new FacetQueryResult(); + for (com.fangjia.service.bo.HouseBo bo : houseList) { + House house = bo.getHouse(); + NewHousePojo b = new NewHousePojo(); + b.setCity(house.getCity()); + b.setDistrict(district.getRegion()); + if (null == district.getBlock()) { + b.setBlock(""); + } else { + b.setBlock(district.getBlock()); + } + b.setName(district.getName()); + b.setAddress(bo.getAddress() == null ? district.getAddress() : bo.getAddress()); + if (house.getArea() != null) { + b.setSize(house.getArea().toString()); + } else { + b.setSize(""); + } + if (house.getTotalPrice() != null) { + b.setListingPrice(house.getTotalPrice().toString()); + } else { + b.setListingPrice(""); + } + if (b.getSize() != null && b.getListingPrice() != null && house.getArea() != 0) { + b.setAvgPrice((int) (house.getTotalPrice() / house.getArea())); + if (b.getAvgPrice() > 300000 || b.getAvgPrice() < 1000) { + continue; + } + } - if (house.getFloor() != null && house.getFloor() > 0) { - b.setFloor(house.getFloor().toString()); - } else { - b.setFloor(""); - } - if (house.getHeight() != null && house.getHeight() > 0) { - b.setMaxFloor(house.getHeight().toString()); - } else { - b.setMaxFloor(""); - } - if (null != house.getRoom() && house.getRoom() > 0) { - b.setRoom(house.getRoom().toString()); - } else { - b.setRoom(""); - } - if (null != house.getHall() && house.getHall() > 0) { - b.setHall(house.getHall().toString()); - } else { - b.setHall(""); - } - if (null != house.getToilet() && house.getToilet() > 0) { - b.setToilet(house.getToilet().toString()); - } else { - b.setToilet(""); - } - String fitment = HouseValidator.fetchFitmentInfo(house.getFitment()); - if (null != fitment) { - b.setDecoration(fitment); - } else { - b.setDecoration(""); - } - String direction = HouseValidator.fetchDirectionInfo(house.getDirection()); - if (null != direction) { - b.setDirection(direction); - } else { - b.setDirection(""); - } + if (house.getFloor() != null && house.getFloor() > 0) { + b.setFloor(house.getFloor().toString()); + } else { + b.setFloor(""); + } + if (house.getHeight() != null && house.getHeight() > 0) { + b.setMaxFloor(house.getHeight().toString()); + } else { + b.setMaxFloor(""); + } + if (null != house.getRoom() && house.getRoom() > 0) { + b.setRoom(house.getRoom().toString()); + } else { + b.setRoom(""); + } + if (null != house.getHall() && house.getHall() > 0) { + b.setHall(house.getHall().toString()); + } else { + b.setHall(""); + } + if (null != house.getToilet() && house.getToilet() > 0) { + b.setToilet(house.getToilet().toString()); + } else { + b.setToilet(""); + } + String fitment = HouseValidator.fetchFitmentInfo(house.getFitment()); + if (null != fitment) { + b.setDecoration(fitment); + } else { + b.setDecoration(""); + } + String direction = HouseValidator.fetchDirectionInfo(house.getDirection()); + if (null != direction) { + b.setDirection(direction); + } else { + b.setDirection(""); + } // if (house.getPics() != null && !house.getPics().isEmpty()) { // b.setPic(transformPicsToFangJia(house.getPics().get(house.getPics().size() / 2))); // } else { // b.setPic(""); // } - if (house.getPublishDate() != null) { - if (new Date().before(house.getPublishDate())) { - house.setPublishDate(house.getModificationDate()); - } else { - house.setPublishDate(house.getPublishDate()); - } - } - if (house.getPublishDate() == null) { - b.setPublishDate("");// 发布时间 - } else { - b.setPublishDate(DateUtil.formatByPattern(house.getPublishDate(), "yyyy-MM-dd"));// 发布时间 - } - b.setSource(getDomainName(house.getUrl())); - if (HouseValidator.validateBuildingType(house.getBuildType())) { - b.setBuildingType(house.getBuildType()); - } - if (HouseValidator.validateArea(house.getArea()) && !checkExists(list, b)) { - list.add(b); - } - - } - return list; - } - - // 200~900ms - public Object similarAction(PropertyEvaluationModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getName())) { - mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); - return mav; - } - if (0 >= model.getSize()) { - mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); - return mav; - } - // 在库中找到对应的小区 - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - // 查找均价 - List districtStats = districtStatService.findAllDistrictStatsSort(district.getCity(), - district.getRegion(), district.getName(), model.getCalDate()); - Integer districtAvg = 0; - if (districtStats != null && !districtStats.isEmpty()) { - DistrictStat districtStat = districtStats.get(0); - districtAvg = districtStat.getAvgPrice(); - } - Integer avgPrice = 0; - Integer tatalPrice = 0; - int count = 0; - List listHouse = similarCommMethod(model, "similar", district); - for (House house : listHouse) { - long temp = Math.round(house.getTotalPrice() / house.getArea()); - // 均价范围在0.8~1.2 - if (temp > districtAvg * 1.3 || temp < districtAvg * 0.7) { - continue; - } - avgPrice = (int) temp + avgPrice; - count++; - } - - if (count == 0) { - mav.setModel(BasicModel.buildOKModel().setMsg("该小区无均价")); - return mav; - } - avgPrice = avgPrice / count; - tatalPrice = (int)Math.round(avgPrice * model.getSize()); - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", tatalPrice); - districtPriceMap.put("avgPrice", avgPrice); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } - - // 寻找相似房源 - public List similarCommMethod(PropertyEvaluationModel model, String kind, District district) { - model.setName(district.getName()); - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (model.getCalDate() != null) { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - List listHouse = new ArrayList(); - FacetQueryResult houseBos = houseService.findSeabirdHouses(district, 0, 1000); - if ("similarSort".equals(kind)) { - listHouse = houseService.findSimilarDistrictParam(houseBos, FJT_DIRECTION.get(model.getDirection()), - FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), model.getFloor(), - model.getRoom(), model.getHall(), model.getSize(), 1); - } else if ("similar".equals(kind)) { - for (int param = 1; param <= 5; param++) { - listHouse.addAll(houseService.findSimilarDistrict(houseBos, FJT_DIRECTION.get(model.getDirection()), - FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), - model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), param)); - if (listHouse.size() > 50) { - break; - } - } - } - if (listHouse == null || listHouse.size() < 5) { - List districts = houseService.findAroundDistrict(district); - for (District around : districts) { - FacetQueryResult aroundBos = houseService.findSeabirdHouses(around, 0, 1000); - if (listHouse == null || listHouse.isEmpty()) { - listHouse = houseService.findSimilarDistrict(aroundBos, FJT_DIRECTION.get(model.getDirection()), - FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), - model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), 3); - } else { - listHouse - .addAll(houseService.findSimilarDistrict(aroundBos, FJT_DIRECTION.get(model.getDirection()), - FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), - model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), 3)); - } - if (listHouse.size() > 10) { - break; - } - } - } - return listHouse; - } - - public static final String[] DFIELDS = { "city", "region", "name", "address" }; - - public Object autoCompleteAction(PropertySearchModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (!"全国".equals(model.getCity())) { - if (!RegionData.isCity(model.getCity())) { - String city = RegionData.formatCity(model.getCity()); - if (null == city) { - mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); - return mav; - } else { - model.setCity(city); - } - } - } - - if (StringUtils.isNotBlank(model.getDistrict())) { - model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); - } - - if (StringUtils.isBlank(model.getKeyword())) { - mav.setModel(BasicModel.buildBadRequestModel("keyword(关键字)不能为空")); - return mav; - } - - String type = "name"; - if (StringUtils.isNotBlank(model.getFilter())) { - type = model.getFilter(); - } - //强行启用小区库 - if ("true".equals(model.getUseSeaweed())) { - if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 100) { - model.setMax(10); - } - List params = new ArrayList(); - if (!"全国".equals(model.getCity())) { - params.add(new QueryParam("city", model.getCity())); - } - if (StringUtils.isNotBlank(model.getDistrict())) { - params.add(new QueryParam("region", model.getDistrict())); - } - params.add(new QueryParam("category", "district")); - params.add(new QueryParam("visible", 0)); - // BooleanQuery srQuery1 = new BooleanQuery(); - // BooleanQuery nameQuery = new BooleanQuery(); - // nameQuery.add(new TermQuery(new Term("district_name", model.getKeyword())), - // BooleanClause.Occur.SHOULD); - // nameQuery.add(new PrefixQuery(new Term("name", - // QueryParser.escape(model.getKeyword()).toLowerCase())), - // BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("alias_std", model.getKeyword())), - // BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("address", model.getKeyword())), - // BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("addr_alias_std", model.getKeyword())), - // BooleanClause.Occur.SHOULD); - - if (StringUtils.isNotBlank(model.getKeyword())) { - BooleanQuery query = new BooleanQuery(); - if (model.getUseOrQuery()) { - params.add(new QueryParam("$fangjiawang_query_type", "or")); - } - // 2017-11-02新增, 指定查询字段,以:分割为多个字段查询,处理pds搜索问题,不指定默认用keyword查询 - String queryFields = model.getQueryField(); - if (StringUtils.isNotBlank(queryFields) && queryFields.contains(":")) { - String[] fs = queryFields.split(":"); - for (String f : fs) { - Query q1 = new TermQuery(new Term(f, QueryParser.escape(model.getKeyword()).toLowerCase())); - q1.setBoost(0.99f); - query.add(q1, BooleanClause.Occur.SHOULD); - } - } else { - Query q1 = new TermQuery( - new Term(model.getQueryField(), QueryParser.escape(model.getKeyword()).toLowerCase())); - q1.setBoost(0.99f); - query.add(q1, BooleanClause.Occur.SHOULD); - } - - /* - * Query q2 = new TermQuery(new Term("keyword_cjk", - * QueryParser.escape(model.getKeyword()).toLowerCase())); q2.setBoost(0.01f); - * query.add(q2, BooleanClause.Occur.SHOULD); - */ - - /* - * String districtName = tokenDistrictName(model.getKeyword()); - * if(StringUtils.isNotBlank(districtName)){ Query q3 = new TermQuery(new - * Term("keyword_cjk", districtName)); q3.setBoost(0.99f); query.add(q3, - * BooleanClause.Occur.SHOULD); } - */ - // Query query = - // boostQueryDistrictNewPolicy.create(ServiceUtil.removeAndGetKeyword(params)); - params.add(new QueryParam("$sr", new SrQuery(query))); - // params.add(new QueryParam("keyword", - // QueryParser.escape(model.getKeyword()).toLowerCase())); - - } - List districts = districtService.findAllByParams(params, 0, model.getMax(), new String[] { "city", - "region", "name", "alias", "address", "addrAlias", "lat2", "lng2", "householdCount" }); - - List result = new ArrayList(); - if (districts != null) { - for (District district : districts) { - BasicDBObject item = new BasicDBObject(); - item.append("city", district.getCity()); - item.append("district", district.getRegion()); - item.append("name", district.getName()); - item.append("address", district.getAddress()); - item.append("latBaidu", district.getLat2()); - item.append("lngBaidu", district.getLng2()); - item.append("houseHoldCount", district.getHouseholdCount()); - if (district.getAlias() != null && district.getAlias().size() > 0) { - item.append("alias", district.getAlias()); - } - if (CollectionUtils.isNotEmpty(district.getAddrAlias())) { - item.append("address_alias", district.getAddrAlias()); - } - result.add(item); - } - } - mav.setModel(BasicModel.buildOKModel().setResult(result)); - } else { - if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 20) { - model.setMax(10); - } - List autoCompleteBos = autoCompleteService.suggest("district", type, model.getCity(), - model.getKeyword(), model.getMax()); - List result = new ArrayList(); - if (autoCompleteBos != null) { - for (AutoCompleteBo bo : autoCompleteBos) { - BasicDBObject item = new BasicDBObject(); - item.append("city", model.getCity()); - item.append("district", bo.getRegion()); - item.append("name", bo.getVal()); - item.append("address", bo.getDesc()); - result.add(item); - } - } - mav.setModel(BasicModel.buildOKModel().setResult(result)); - } - - return mav; - } - - /** - * 解析出关键字中的小区名 - * - * @param keyword - * @return - */ - private String tokenDistrictName(String keyword) { - List tokens = CnTokenizer.tokenizer(keyword); - Token token = getTokenByType(tokens, KeywordEnum.district); - if (token != null && "district".equals(token.getKeywordTypes())) { - return token.getName(); - } - return null; - } - - private Token getTokenByType(List tokens, KeywordEnum type) { - for (Token token : tokens) { - if (token.containsType(type)) { - return token; - } - } - return null; - } - - public Object similarSortAction(PropertyEvaluationModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); - return mav; - } - if (StringUtils.isBlank(model.getName())) { - mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); - return mav; - } - if (0 >= model.getSize()) { - mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); - return mav; - } - // 在库中找到对应的小区 - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - - Integer avgPrice = 0; - Integer tatalPrice = 0; - int count = 0; - List listHouse = similarCommMethod(model, "similarSort", district); - - // 查找均价 - List districtStats = districtStatService.findAllDistrictStatsSort(district.getCity(), - district.getRegion(), district.getName(), model.getCalDate()); - Integer districtAvg = 0; - if (districtStats != null && !districtStats.isEmpty()) { - DistrictStat districtStat = districtStats.get(0); - districtAvg = districtStat.getAvgPrice(); - } - for (House house : listHouse) { - long temp = Math.round(house.getTotalPrice() / house.getArea()); - if (temp > districtAvg * 1.3 || temp < districtAvg * 0.7) { - continue; - } - avgPrice = (int) temp + avgPrice; - count++; - } - if (count == 0) { - mav.setModel(BasicModel.buildOKModel().setMsg("该小区无均价")); - return mav; - } - avgPrice = avgPrice / count; - tatalPrice = (int)Math.round(avgPrice * model.getSize()); - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", tatalPrice); - districtPriceMap.put("avgPrice", avgPrice); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } - - public String getDomainName(String url) { - if (StringUtils.isNotBlank(url)) { - Pattern p = Pattern.compile("[^//]*?\\.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE); - Matcher matcher = p.matcher(url); - if (matcher.find()) { - return matcher.group(); - } - } - return "fangjia.com"; - } - - private Integer getFloor(String roomNumber){ - if(StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)){ - if(roomNumber.length() == 3){ - return Integer.valueOf(roomNumber.substring(0,1)); - }else if(roomNumber.length() == 4){ - return Integer.valueOf(roomNumber.substring(0,2)); - }else{ - return null; - } - } - return null; - } - - private boolean checkExists(FacetQueryResult houseBoList, NewHousePojo house) { - for (NewHousePojo bo : houseBoList) { - boolean sameName = bo.getName().equals(house.getName()); - boolean sameAddress = bo.getAddress() != null ? bo.getAddress().equals(house.getAddress()) - : house.getAddress() == null; - boolean sameTotalPrice = bo.getListingPrice() != null ? bo.getListingPrice().equals(house.getListingPrice()) - : house.getListingPrice() == null; - boolean samePublishDate = bo.getPublishDate() != null ? bo.getPublishDate().equals(house.getPublishDate()) - : house.getPublishDate() == null; - boolean sameArea = bo.getSize() != null ? bo.getSize().equals(house.getSize()) : house.getSize() == null; - boolean sameFloor = bo.getFloor() != null ? bo.getFloor().equals(house.getFloor()) - : house.getFloor() == null; - if (sameName && sameAddress && sameFloor && sameTotalPrice && samePublishDate && sameArea) { - return true; - } - } - return false; - } - - /** - * 小区统计分析接口 - * - * @param model - * @return - */ - public Object analysisAction(DistrictQueryModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (district.getLat2() == null || district.getLng2() == null) { - - mav.setModel(BasicModel.buildOKModel()); - return mav; - } - - DistrictKey districtKey = new DistrictKey(district.getCity(), district.getRegion(), district.getName()); - DistrictAttentionRank attention = districtAttentionRankService.findByDistrictKey(districtKey);// 小区关注度信息 - CityHot cityHot = cityHotService.findByCity(district.getCity()); - DistrictHot districtHot = districtHotService.findDistrictHotByDistrictKey(districtKey); - if (null != districtHot) { - if (null != districtHot.getHouseLastMonth() && districtHot.getHouseLastMonth() > 0) { - int lastMonthHouses = districtHot.getHouseLastMonth();// 上月挂牌量 - - if (null != cityHot && null != cityHot.getSellMarkupMonth()) { - districtHot.setHouseHalfYear( - (int) (lastMonthHouses * 6 * (1 + cityHot.getSellMarkupMonth() / 10000.0))); - } else { - districtHot.setHouseHalfYear((int) (lastMonthHouses * 6 * 0.9625)); - } - } - } - - double lat = district.getLat2() / 10000000000d; - double lng = district.getLng2() / 10000000000d; - double radius = 1000d; - double aroundAvgConsumption = bizShopService.findAroundAvgConsumption(lat, lng, radius, "餐厅");// 周边消费人均 - - int regionClickRank = 0; - int cityClickRank = 0; - int houseLastMonth = 0; - int houseHalfYear = 0; - - if (attention != null) { - if (attention.getRegionClickRank() != null) { - regionClickRank = attention.getRegionClickRank(); - } - if (attention.getCityClickRank() != null) { - cityClickRank = attention.getCityClickRank(); - } - } - - if (districtHot != null) { - if (districtHot.getHouseHalfYear() != null) { - houseHalfYear = districtHot.getHouseHalfYear(); - } - if (districtHot.getHouseLastMonth() != null) { - houseLastMonth = districtHot.getHouseLastMonth(); - } - } - - DistrictAnalysisDto districtAnalysisDto = new DistrictAnalysisDto(); - districtAnalysisDto.setCity(district.getCity());// 城市 - districtAnalysisDto.setDistrict(district.getRegion());// 区域 - districtAnalysisDto.setName(district.getName());// 小区名 - districtAnalysisDto.setAvgPriceAround((int) aroundAvgConsumption);// 周边餐饮平均消费 - districtAnalysisDto.setDistrictClickRank(regionClickRank);// 区域关注度排名 - districtAnalysisDto.setCityClickRank(cityClickRank);// 全市关注度排名 - districtAnalysisDto.setHouseHalfYear(houseHalfYear);// 近半年小区挂牌量 - districtAnalysisDto.setHouseLastMonth(houseLastMonth);// 上月小区挂牌量 - - mav.setModel(BasicModel.buildOKModel().setResult(districtAnalysisDto)); - return mav; - } - - /** - * 小区交通接口 - * - * @param model - * @return - */ - public Object trafficAction(DistrictQueryModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (district.getLat2() == null || district.getLng2() == null) { - - mav.setModel(BasicModel.buildOKModel()); - return mav; - } - - double lat = district.getLat2() / 10000000000d; - double lng = district.getLng2() / 10000000000d; - double radius = 1000d; - - Map> stationMap = busStationService.getNearByStations(district.getCity(), lat, lng, - radius);// 查询交通信息(公交,地铁) bus_station,bus_line - List MetroStations = stationMap.get("地铁"); - List BusStation = stationMap.get("公交"); - - List StationDtos = new ArrayList(); - if (MetroStations != null) { - for (BusStation station : MetroStations) { - StationDto stationDto = new StationDto(); - stationDto.setName(station.getStation()); - stationDto.setLineName(station.getLineId()); - StationDtos.add(stationDto); - } - } - - if (BusStation != null) { - for (BusStation station : BusStation) { - StationDto stationDto = new StationDto(); - stationDto.setName(station.getStation()); - stationDto.setLineName(station.getLineId()); - StationDtos.add(stationDto); - } - } - - mav.setModel(BasicModel.buildOKModel().setResult(StationDtos)); - return mav; - } - - /** - * 小区周边接口 - * - * @param model - * @return - */ - public Object aroundAction(DistrictQueryModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict())) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); - return mav; - } - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (district.getLat2() == null || district.getLng2() == null) { - - mav.setModel(BasicModel.buildOKModel()); - return mav; - } - - double radius = 1000d;// 查周围半径为1公里距离的信息 - - List arrs = baiduApiService.searchNearbyLocalDatabase(district, radius);// 查询小区周边(所有类型) - Map> districtAroundMap = new HashMap>(); - - for (String key : AROUND_KEYWORD_FACTOR.keySet()) { - - List aroundNames = new ArrayList(); - districtAroundMap.put(AROUND_KEYWORD_FACTOR.get(key), aroundNames);// 把key的英文put到map并把value设置为一个List引用 - - } - for (int i = 0; i < arrs.size(); i++) { - BaiduPlacePoi poiObj = arrs.get(i); - String name = poiObj.getName(); - String keyword = poiObj.getKeyword(); - double latjs = poiObj.getLat(); - double lngjs = poiObj.getLng(); - String key = AROUND_KEYWORD_FACTOR.get(keyword); - - AroundDto dto = new AroundDto(); - dto.setName(name); - dto.setLat(latjs); - dto.setLng(lngjs); - if (districtAroundMap.get(key) != null) { - districtAroundMap.get(key).add(dto);// 按key值取出list add 周边名称已经经纬度 - } - - } - mav.setModel(BasicModel.buildOKModel().setResult(districtAroundMap)); - return mav; - } - - /** - * 相同小区相似户型房源挂牌量接口
- * 获取该小区的满足指定相似条件的挂牌房源量 条件说明: 1.输入面积-5<=房源面积<=输入面积+5 2.上个月发布的房源 - * - * @author yinjihuan - * @date 2016年9月1日 - * @param city - * 城市 - * @param district - * 区域 - * @param name - * 小区名 - * @param size - * 面积 - * @return - */ - public Object similarHouseAmoutAction(@Param(name = "city") String city, @Param(name = "district") String district, - @Param(name = "name") String name, @Param(name = "size") Double size) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(name) || StringUtils.isBlank(district) || size == null) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名),size(面积)是必须参数")); - return mav; - } - if (size <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能小于0")); - return mav; - } - District districtInfo = districtService.findByNameAndAlias(city, district, name, "district"); - if (null == districtInfo) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - long result = districtHouseResourceStatService.findSimilarHouseAmoutCount(districtInfo.getId(), size); - BasicModel model = new BasicModel(200, "ok"); - model.setResult(result); - mav.setModel(model); - return mav; - } - - /** - * 周边小区相似户型挂牌量接口
- * 获取该小区的满足指定相似条件的挂牌房源量 条件说明: 1.输入面积-5<=房源面积<=输入面积+5 2.上个月发布的房源 - * - * @author yinjihuan - * @date 2016年9月1日 - * @param city - * 城市 - * @param district - * 区域 - * @param name - * 小区名 - * @param size - * 面积 - * @param radius - * 周边小区最大半径(单位:米,默认2000) - * @return - */ - public Object nearbySimilarHouseAmoutAction(@Param(name = "city") String city, - @Param(name = "district") String district, @Param(name = "name") String name, - @Param(name = "size") Double size, @Param(name = "radius") Integer radius) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(name) || StringUtils.isBlank(district) || size == null) { - mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名),size(面积)是必须参数")); - return mav; - } - if (size <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能小于0")); - return mav; - } - District districtInfo = districtService.findByNameAndAlias(city, district, name, "district"); - if (null == districtInfo) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (radius == null) { - radius = 2000; - } - // 找出小区周边范围类的小区 - List districts = districtService.findNearestDistrict(districtInfo, radius, 500); - List districtIds = new ArrayList(); - for (District dis : districts) { - districtIds.add(dis.getId()); - } - districtIds.add(districtInfo.getId()); - BasicModel model = new BasicModel(200, "ok"); - model.setResult(districtHouseResourceStatService.findNearbySimilarHouseAmoutCount(size, districtIds)); - mav.setModel(model); - return mav; - } - - /** - * 小区周边一公里均价 - * - * @author wenyan - * @param model - * @return - */ - public Object aroundAverageAction(@Valid AroundAverageModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - DistrictKey key = new DistrictKey(model.getCity(), model.getDistrict(), model.getName()); - DistrictAnalyData districtAnalyData = districtAnalyDataService.findByDistrictKey(key); - BasicModel dataModel = BasicModel.buildOKModel(); - if (districtAnalyData != null && districtAnalyData.getAroundDistrictAvgPrice() != null) { - UniversalDto dto = UniversalDto.newDto(); - dto.append("averagePrice", districtAnalyData.getAroundDistrictAvgPrice()); - dataModel.setResult(dto); - } - mav.setModel(dataModel); - return mav; - - } - - /** - * 相同小区相似户型租金范围查询接口 - * - * @param model - * @return - */ - public Object similarHouseRentRangeAction(@Valid RentModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - - // List houseBos = - // houseService.findDistrictHouseByCat(district.getCity(), district.getRegion(), - // district.getName(), 100, null, model.getSize()-5, model.getSize()+5); - Integer room = houseService.getDistrictRoomType(model.getSize()); - if (null == room) { - mav.setModel(BasicModel.buildBadRequestModel("根据size(面积)没有找到相应的室")); - return mav; - } - - List districtStatRents = districtStatRentService.findLatestDistrictStatRent(district, 1, - (int) room); - if (null == districtStatRents || districtStatRents.size() == 0) { - mav.setModel(BasicModel.buildOKModel()); - } else { - DistrictStatRent districtStatRent = districtStatRents.get(0); - Map rentRangeMap = new HashMap(); - if (districtStatRent.getAvgPrice() > 0) { - Integer avgPrice = districtStatRent.getAvgPrice(); - rentRangeMap.put("min", (int) (avgPrice - avgPrice * 0.08)); - rentRangeMap.put("max", (int) (avgPrice + avgPrice * 0.08)); - } - mav.setModel(BasicModel.buildOKModel().setResult(rentRangeMap)); - } - return mav; - } - - /** - * 周边小区相似户型租金范围查询接口 - * - * @param model - * @return - */ - public Object nearlySimilarHouseRentRangeAction(@Valid RentModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (null == district) { - mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); - return mav; - } - if (null == model.getRadius()) {// 设置默认值 - model.setRadius(2000); - } - - List districts = districtService.findNearestDistrict(district, model.getRadius(), 500); - if (null != districts) { - // List houseBos = new ArrayList(); - // for(District dist : districts){ - // List bos = houseService.findDistrictHouseByCat(dist.getCity(), - // dist.getRegion(), dist.getName(), 100, null, model.getSize()-5, - // model.getSize()+5); - // houseBos.addAll(bos); - // } - Integer room = houseService.getDistrictRoomType(model.getSize()); - if (null == room) { - mav.setModel(BasicModel.buildBadRequestModel("根据size(面积)没有找到相应的室")); - return mav; - } - - List prices = new ArrayList(); - for (District dist : districts) { - List districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, - room); - if (null != districtStatRents && districtStatRents.size() > 0) { - DistrictStatRent districtStatRent = districtStatRents.get(0); - if (districtStatRent.getAvgPrice() > 0) { - Integer avgPrice = districtStatRent.getAvgPrice(); - prices.add(avgPrice); - } - } - } - - Map rentRangeMap = new HashMap(); - if (prices.size() > 0) { - Collections.sort(prices); - rentRangeMap.put("min", prices.get(0)); - rentRangeMap.put("max", prices.get(prices.size() - 1)); - mav.setModel(BasicModel.buildOKModel().setResult(rentRangeMap)); - } else { - mav.setModel(BasicModel.buildOKModel()); - } - } else { - mav.setModel(BasicModel.buildBadRequestModel("没找到周边小区")); - } - - return mav; - } - - /** - * 室号查询接口 - * - * @param model - * @return - */ - public Object roomAction(@Valid RoomModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - - List queryParams = new ArrayList(); - queryParams.add(new QueryParam("city", model.getCity())); - queryParams.add(new QueryParam("region", model.getDistrict())); - queryParams.add(new QueryParam("name", model.getProjectName())); - queryParams.add(new QueryParam("houseNum", model.getBuildingNumber())); - queryParams.add(new QueryParam("houseNumUnit", model.getUnitNumber())); - if (model.getFloor() != null) { - queryParams.add(new QueryParam("houseFloor", model.getFloor())); - } - List sortParams = new ArrayList(); - sortParams.add(new SortParam("houseFloor", true)); - List houseLoudongs = houseLoudongService.findAll(queryParams, new Pager(Integer.MAX_VALUE)); - List rooms = new ArrayList(); - for (HouseLoudong houseLoudong : houseLoudongs) { - if ("--".equals(houseLoudong.getRoomNum())) { - continue; - } - RoomDto dto = new RoomDto(); - dto.setDisplay(houseLoudong.getRoomNum() + "室"); - dto.setUnitNumber(houseLoudong.getHouseNumUnit()); - dto.setRoom(houseLoudong.getRoomNum()); - rooms.add(dto); - } - mav.setModel(BasicModel.buildOKModel().setResult(rooms)); - return mav; - } - - /** - * 楼栋楼层信息查询接口 - * - * @param model - * @return - */ - public Object floorsAction(@Valid FloorsModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), - model.getBuildingNumber(), model.getUnitNumber(), Integer.MAX_VALUE); - if (null == loudongs || loudongs.isEmpty()) { - mav.setModel(BasicModel.buildBadRequestModel("楼栋不存在")); - return mav; - } - List floors = new ArrayList(); - if (loudongs.get(0).getFloors() > 0) { - for (int i = 1; i <= loudongs.get(0).getFloors(); i++) { - floors.add(i); - } - } - mav.setModel(BasicModel.buildOKModel().setResult(floors)); - return mav; - } - - /** - * 楼栋查询接口 - * - * @param model - * @return - */ - public Object buildingAction(@Valid BuildingModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - - List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), - null, null, Integer.MAX_VALUE); - List dtos = new ArrayList(); - List keys = new ArrayList(); - for (Loudong loudong : loudongs) { - if (keys.contains(loudong.getHouseNumber()) || "--".equals(loudong.getHouseNumber())) { - continue; - } - BuildingDto dto = new BuildingDto(); - dto.setId(loudong.getId()); - dto.setBuildingNumber(loudong.getHouseNumber()); - dto.setLabel(loudong.getHouseNumber()); - dtos.add(dto); - keys.add(loudong.getHouseNumber()); - } - - Collections.sort(dtos, new Comparator() { - @Override - public int compare(BuildingDto o1, BuildingDto o2) { - if (StringUtils.isNumeric(o1.getBuildingNumber()) && StringUtils.isNumeric(o2.getBuildingNumber())) { - return new Double(o1.getBuildingNumber()).compareTo(new Double(o2.getBuildingNumber())); - } else if (StringUtils.isNumeric(o1.getBuildingNumber())) { - return -1; - } else if (StringUtils.isNumeric(o2.getBuildingNumber())) { - return 1; - } else { - return o1.getBuildingNumber().compareTo(o2.getBuildingNumber()); - } - - } - }); - - mav.setModel(BasicModel.buildOKModel().setResult(dtos)); - return mav; - } - - /** - * 楼栋查询接口 - * - * @param model - * @return - */ - public Object unitNumberAction(@Valid UnitNumberModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - - List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), - model.getBuildingNumber(), null, Integer.MAX_VALUE); - - List dtos = new ArrayList(); - List keys = new ArrayList(); - for (Loudong loudong : loudongs) { - if (keys.contains(loudong.getUnitNumber()) || "--".equals(loudong.getUnitNumber())) { - continue; - } - UnitNumberDto dto = new UnitNumberDto(); - dto.setId(loudong.getId()); - dto.setBuildingNumber(loudong.getHouseNumber()); - dto.setUnitNumber(loudong.getUnitNumber()); - dto.setLabel(loudong.getUnitNumber()); - dtos.add(dto); - keys.add(loudong.getUnitNumber()); - } - Collections.sort(dtos, new Comparator() { - @Override - public int compare(UnitNumberDto o1, UnitNumberDto o2) { - if (StringUtils.isNumeric(o1.getUnitNumber()) && StringUtils.isNumeric(o2.getUnitNumber())) { - return new Double(o1.getUnitNumber()).compareTo(new Double(o2.getUnitNumber())); - } else if (StringUtils.isNumeric(o1.getUnitNumber())) { - return -1; - } else if (StringUtils.isNumeric(o2.getUnitNumber())) { - return 1; - } else { - return o1.getUnitNumber().compareTo(o2.getUnitNumber()); - } - - } - }); - - mav.setModel(BasicModel.buildOKModel().setResult(dtos)); - return mav; - } - - public Object avgPrice2Action(@Param(name = "city") String city, @Param(name = "district") String district, - @Param(name = "name") String name) { - - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(district) || StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("小区所在城市,所在区域,小区名为必填项")); - return mav; - } - - District districtBo = districtService.findByNameAndAlias(city, district, name, "district"); - if (null == districtBo) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - - DistrictStatBo districtStatBo = districtStatService - .findDistrictStat(new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName())); - if (null == districtStatBo || (districtStatBo != null && districtStatBo.getDistrictStat() == null - && districtStatBo.getVillaDistrictStat() == null)) { - mav.setModel(BasicModel.buildOKModel()); - return mav; - } - Integer lastAvgPrice = averageAnalyService.getLastAvgPrice(districtBo, districtStatBo); - Map map = new HashMap(); - map.put("city", districtBo.getCity()); - map.put("district", districtBo.getRegion()); - map.put("name", districtBo.getName()); - map.put("avgPrice", lastAvgPrice); - if (districtStatBo.getDistrictStat() != null) { - map.put("date", DateUtil.formatByPattern(districtStatBo.getDistrictStat().getWeekend(), "yyyy-MM-dd")); - } else if (districtStatBo.getVillaDistrictStat() == null) { - map.put("date", DateUtil.formatByPattern(districtStatBo.getVillaDistrictStat().getWeekend(), "yyyy-MM-dd")); - } - - mav.setModel(BasicModel.buildOKModel().setResult(map)); - return mav; - } - - private Map getLastEvaluationPrice(District district, Evaluation evaluation, double dCredit) - throws NumberFormatException, IllegalAccessException { - Date startDate = DateUtil.parseDate(DateUtil.addMonth(new Date(), -6), "yyyy-MM-dd"); - // 第三方价格 - Map otherPriceRets = averageStatisticsService.findFirstAverageStatictics(district.getCity(), - district.getRegion(), district.getName(), district.getCategory(), startDate); - if (null == otherPriceRets) { - otherPriceRets = new HashMap(); - } - - otherPriceRets.put("fjw_price", evaluation.getAvgPrice()); - Map levelMap = getPriceLevel(otherPriceRets, evaluation.getCredit()); - Long lastPrice = getLastPrice(levelMap, otherPriceRets, evaluation, dCredit); - - Map rMap = new HashMap(); - rMap.put("lastPrice", lastPrice); - if (null != levelMap && levelMap.containsKey("level")) { - String priceLevel = (String) levelMap.get("level"); - rMap.put("level", priceLevel); - } - rMap.put("other_price", otherPriceRets); - return rMap; - } - - private Long getLastPrice(Map retMap, Map otherPriceRets, Evaluation evaluation, double dCredit) { - Long lastPrice = null; - if (null != retMap) { - String priceLevel = (String) retMap.get("level"); - - if (priceLevel.equals("D")) { - - lastPrice = inputResultByWebsite(otherPriceRets, evaluation, dCredit); - - } else if (priceLevel.equals("E")) { - if (evaluation.getCredit() >= 0.65) { - lastPrice = evaluation.getBigTotalPrice(); - } else { - List prices = (List) retMap.get("prices"); - int avgPrice = 0; - if (prices != null) { - avgPrice = findNewPrice(prices, evaluation.getAvgPrice()); - } - // 在 dCredit与0.65之间 - if (evaluation.getCredit() >= dCredit && dCredit < 0.65) { - if (avgPrice > 0) { - Double newTotalPrice = avgPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else { - if (null != otherPriceRets.get("lianjia_price")) { - Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); - Double newTotalPrice = lianjiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("zhugezhaofang_price")) { - Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); - Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("yungujia_price")) { - Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); - Double newTotalPrice = yungujiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("fanggugu_price")) { - Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); - Double newTotalPrice = fangguguPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else { - lastPrice = evaluation.getBigTotalPrice(); - } - } - } else if (evaluation.getCredit() < dCredit) {// 在dCredit以下 - if (avgPrice > 0) { - Double newTotalPrice = avgPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else { - if (null != otherPriceRets.get("lianjia_price")) { - Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); - Double newTotalPrice = lianjiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("zhugezhaofang_price")) { - Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); - Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("yungujia_price")) { - Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); - Double newTotalPrice = yungujiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("fanggugu_price")) { - Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); - Double newTotalPrice = fangguguPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } - } - } - } - - } else if (priceLevel.equals("C")) { - List smallPrices = (List) retMap.get("small_prices"); - if (smallPrices != null) { - smallPrices.add(evaluation.getAvgPrice()); - int avgPrice = sum(smallPrices) / smallPrices.size(); - Double newTotalPrice = avgPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } - } else { - lastPrice = evaluation.getBigTotalPrice(); - } - } - return lastPrice; - } - - private Long inputResultByWebsite(Map otherPriceRets, Evaluation evaluation, double dCredit) { - Long lastPrice = null; - if (evaluation.getCredit() >= dCredit) { - lastPrice = evaluation.getBigTotalPrice(); - } else { - if (evaluation.getCredit() < dCredit) { - if (null != otherPriceRets.get("lianjia_price")) { - Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); - Double newTotalPrice = lianjiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("zhugezhaofang_price")) { - Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); - Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("yungujia_price")) { - Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); - Double newTotalPrice = yungujiaPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else if (null != otherPriceRets.get("fanggugu_price")) { - Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); - Double newTotalPrice = fangguguPrice * evaluation.getArea(); - lastPrice = newTotalPrice.longValue(); - } else { - lastPrice = evaluation.getBigTotalPrice(); - } - } else { - lastPrice = evaluation.getBigTotalPrice(); - } - } - return lastPrice; - } - - private Integer findNewPrice(List prices, int avgPrice) { - int minValue1 = Integer.MAX_VALUE; - List> values = new ArrayList>(); - int fjw_price = avgPrice; - - // 找出最小差 - for (int i = 0; i < prices.size() - 1; i++) { - int a = prices.get(i); - for (int j = i + 1; j < prices.size(); j++) { - int b = prices.get(j); - int mod = Math.abs(a - b); - if (mod < minValue1) { - minValue1 = mod; - } - } - } - - // 根据最小差找出结果 - for (int i = 0; i < prices.size() - 1; i++) { - int a = prices.get(i); - for (int j = i + 1; j < prices.size(); j++) { - int b = prices.get(j); - int mod = Math.abs(a - b); - if (mod == minValue1) { - values.add(Arrays.asList(a, b)); - } - } - } - - int minValue2 = Integer.MAX_VALUE; - int lastValue = 0; - if (values.size() >= 1) { - for (List value : values) { - int newPrice = (value.get(0) + value.get(1)) / 2; - int mod = Math.abs(fjw_price - newPrice); - if (mod < minValue2) { - minValue2 = mod; - lastValue = newPrice; - } - } - } - - if (lastValue > 0) { - double temp = DataUtil.getDoubleRound(2, minValue1 * 100 / lastValue); - temp = Math.abs(temp); - if (temp > 15) { - lastValue = 0; - } - } - return lastValue; - } - - private Integer sum(List smallPrices) { - int sum = 0; - for (int price : smallPrices) { - sum += price; - } - return sum; - } - - private Map getPriceLevel(Map otherPriceRets, double credit) { - - Integer avgPrice = (Integer) otherPriceRets.get("fjw_price"); - - int keyCount = 0; - int commonCount = 0; - int isExistCount = 0; - - List prices = new ArrayList(); - List smallPrices = new ArrayList(); - - if (null != otherPriceRets.get("fanggugu_price")) { - Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); - int mod = avgPrice - fangguguPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - keyCount++; - } else { - prices.add(fangguguPrice); - } - isExistCount++; - } - if (null != otherPriceRets.get("yungujia_price")) { - Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); - int mod = avgPrice - yungujiaPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - keyCount++; - } else { - prices.add(yungujiaPrice); - } - - isExistCount++; - } - - if (null != otherPriceRets.get("zhugezhaofang_price")) { - Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); - int mod = avgPrice - zhugezhaofangPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - keyCount++; - } else { - prices.add(zhugezhaofangPrice); - } - - isExistCount++; - } - - if (null != otherPriceRets.get("lianjia_price")) { - Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); - int mod = avgPrice - lianjiaPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - keyCount++; - } else { - prices.add(lianjiaPrice); - } - isExistCount++; - } - if (null != otherPriceRets.get("anjuke_price")) { - Integer anjukePrice = (Integer) otherPriceRets.get("anjuke_price"); - int mod = avgPrice - anjukePrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - commonCount++; - smallPrices.add(anjukePrice); - } else { - prices.add(anjukePrice); - } - - isExistCount++; - } - if (null != otherPriceRets.get("ganji_price")) { - Integer ganjiPrice = (Integer) otherPriceRets.get("ganji_price"); - int mod = avgPrice - ganjiPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - commonCount++; - smallPrices.add(ganjiPrice); - } else { - prices.add(ganjiPrice); - } - - isExistCount++; - } - if (null != otherPriceRets.get("soufan_price")) { - Integer soufan_price = (Integer) otherPriceRets.get("soufan_price"); - int mod = avgPrice - soufan_price; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - commonCount++; - smallPrices.add(soufan_price); - } else { - prices.add(soufan_price); - } - - isExistCount++; - } - if (null != otherPriceRets.get("tobushi_price")) { - Integer tobushi = (Integer) otherPriceRets.get("tobushi_price"); - int mod = avgPrice - tobushi; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - commonCount++; - smallPrices.add(tobushi); - } else { - prices.add(tobushi); - } - - isExistCount++; - } - - if (null != otherPriceRets.get("zhongyuan_price")) { - Integer zhongyuanPrice = (Integer) otherPriceRets.get("zhongyuan_price"); - int mod = avgPrice - zhongyuanPrice; - double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); - temp = Math.abs(temp); - if (temp <= 15) { - commonCount++; - smallPrices.add(zhongyuanPrice); - } else { - prices.add(zhongyuanPrice); - } - - isExistCount++; - } - - Map retMap = new HashMap(); - String level = null; - if (keyCount >= 2) { - level = "A"; - } else if (keyCount >= 1 && commonCount >= 1) { - level = "A"; - } else if (keyCount >= 1 || commonCount >= 2) { - level = "B"; - } else if (commonCount >= 1) { - level = "C"; - } else if (isExistCount == 0) { - level = "D"; - } else if (isExistCount >= 1) { - if (isExistCount == 1) { - level = "D"; - } else { - level = "E"; - } - } - - if (credit == 0) { - level = "E"; - } - - if (StringUtils.isNotBlank(level)) { - retMap.put("level", level); - retMap.put("prices", prices); - retMap.put("small_prices", smallPrices); - } - return retMap; - } - - /** - * 房产交易记录查询 - * - * @param model - * @return - */ - public Object transactionRecordAction(PropertySearchModel model) { - // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) trade_date倒序 - // max查询条数 - // 输出 - // {"result":{"districtCnt":"小区1年内成交数量","transactionList":[{"time":"yyyy-MM-dd","price":"xxx万"}]}} - // time是每笔的成交时间,price是每笔的成交金额,注意看数据格式 - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - String city = model.getCity(); - String district = model.getDistrict(); - String name = model.getName(); - String houseNum = model.getHouseNum(); - String roomNum = model.getRoomNum(); - int max = model.getMax() == null ? 10 : model.getMax(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); - return mav; - } - if (StringUtils.isBlank(district)) { - mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); - return mav; - } - if (StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); - return mav; - } - if (StringUtils.isBlank(houseNum)) { - mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); - return mav; - } - if (StringUtils.isBlank(roomNum)) { - mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); - return mav; - } - Date curDate = new Date(); - // 小区1年内成交数量 - long count = dealPriceService.findTradeCount(city, district, name, DateUtil.getDateOfLastMonth(curDate, -12), - curDate); - List list = dealPriceService.findMaxTrade(city, district, name, houseNum, roomNum, max); - List transactionList = new ArrayList(); - for (DealPrice dealPrice : list) { - HouseDealPriceDetailDto detail = new HouseDealPriceDetailDto(); - detail.setPrice(dealPrice.getTotalPrice()); - detail.setPriceStr(DataUtil.roundDouble((dealPrice.getTotalPrice() / 10000d), 2) + "万"); - detail.setTime(DateUtil.formatByPattern(dealPrice.getTradeDate(), "yyyy-MM-dd")); - transactionList.add(detail); - } - HouseDealPriceDto dto = new HouseDealPriceDto(); - dto.setDistrictCnt(count); - dto.setTransactionList(transactionList); - mav.setModel(BasicModel.buildOKModel().setResult(dto)); - return mav; - } - - /** - * 房产拍卖记录 - * - * @param model - * @return - */ - public Object auctionRecordAction(PropertySearchModel model) { - // 拍卖记录表是fangjia_crawl.house_auction HouseAuction - // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) announcement_date倒序 - // max查询条数 - // 输入对应的表查询字段 cityMatch+regionMatch+nameMatch+buildingNumber+roomNumber - // 输出 - // {"result":{"districtCnt":"小区1年内拍卖数量","transactionList":[{"time":"yyyy-MM-dd","name":"xxx拍卖行"}]}} - // time是每笔的成交时间,name是每笔的拍卖机构,注意看数据格式 - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - String city = model.getCity(); - String district = model.getDistrict(); - String name = model.getName(); - String houseNum = model.getHouseNum(); - String roomNum = model.getRoomNum(); - int max = model.getMax() == null ? 10 : model.getMax(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); - return mav; - } - if (StringUtils.isBlank(district)) { - mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); - return mav; - } - if (StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); - return mav; - } - if (StringUtils.isBlank(houseNum)) { - mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); - return mav; - } - if (StringUtils.isBlank(roomNum)) { - mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); - return mav; - } - Date curDate = new Date(); - // 小区1年内成交数量 - long count = houseAuctionService.findHouseAuctionCount(city, district, name, - DateUtil.getDateOfLastMonth(curDate, -12), curDate); - List list = houseAuctionService.findMaxHouseAuction(city, district, name, houseNum, roomNum, max); - List transactionList = new ArrayList(); - for (HouseAuction houseAuction : list) { - HouseAuctionDetailDto detail = new HouseAuctionDetailDto(); - detail.setName(houseAuction.getCourt()); - detail.setTime(DateUtil.formatByPattern(houseAuction.getAuctionTime(), "yyyy-MM-dd")); - transactionList.add(detail); - } - HouseAuctionDto dto = new HouseAuctionDto(); - dto.setDistrictCnt(count); - dto.setTransactionList(transactionList); - mav.setModel(BasicModel.buildOKModel().setResult(dto)); - return mav; - } - - /** - * 房产近期评估次数 - * - * @param model - * @return - */ - public Object evaluateNumAction(PropertySearchModel model) { - // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) - // 输出 {"result":{"oneMonth":"房屋最近30天的评估次数","threeMonth":"房屋最近90天的评估次数"}} - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - String city = model.getCity(); - String district = model.getDistrict(); - String name = model.getName(); - String houseNum = model.getHouseNum(); - String roomNum = model.getRoomNum(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); - return mav; - } - if (StringUtils.isBlank(district)) { - mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); - return mav; - } - if (StringUtils.isBlank(name)) { - mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); - return mav; - } - if (StringUtils.isBlank(houseNum)) { - mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); - return mav; - } - if (StringUtils.isBlank(roomNum)) { - mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); - return mav; - } - Date curDate = new Date(); - long oneMonth = evaluationService.countByHouse(city, district, name, houseNum, roomNum, - DateUtil.getDateOfLastMonth(curDate, -1), curDate); - long threeMonth = evaluationService.countByHouse(city, district, name, houseNum, roomNum, - DateUtil.getDateOfLastMonth(curDate, -3), curDate); - mav.setModel(BasicModel.buildOKModel().setResult(new HouseEvaluateNumDto(oneMonth, threeMonth))); - return mav; - } - - /*** - * 小区租金估值报告(上半部分) - * @param model - * @param request - * @return - * @throws NumberFormatException - * @throws IllegalAccessException - */ - @Authority(role = Role.NONE) - public Object rentReportAction(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { - - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - - Evaluation evaluation = buildEvaluation(model, request); - evaluation.setSource("api_property_evaluate_rent"); - evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); - - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - evaluation.setAvgPrice((int)(evaluation.getTotalPrice()/evaluation.getArea())); - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("address", district.getAddress()); - districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("totalPriceUpper", CurrencyConverter.toChinese(String.valueOf(evaluation.getTotalPrice()))); - districtPriceMap.put("cal_date", DateUtil.formatByPattern(new Date(), "yyyy/MM/dd")); - districtPriceMap.put("direction", evaluation.getDirection()); - districtPriceMap.put("size", evaluation.getArea()); - districtPriceMap.put("floor", model.getFloor()); - districtPriceMap.put("height", model.getHeight()); - districtPriceMap.put("fitment", evaluation.getFitment()); - districtPriceMap.put("buildYear",district.getFinishBuildingDate()); - - Integer startPrice = (int)(evaluation.getTotalPrice() - evaluation.getTotalPrice()*0.2); - Integer endPrice = (int)(evaluation.getTotalPrice() + evaluation.getTotalPrice()*0.2); - - //周边相似小区 + if (house.getPublishDate() != null) { + if (new Date().before(house.getPublishDate())) { + house.setPublishDate(house.getModificationDate()); + } else { + house.setPublishDate(house.getPublishDate()); + } + } + if (house.getPublishDate() == null) { + b.setPublishDate("");// 发布时间 + } else { + b.setPublishDate(DateUtil.formatByPattern(house.getPublishDate(), "yyyy-MM-dd"));// 发布时间 + } + b.setSource(getDomainName(house.getUrl())); + if (HouseValidator.validateBuildingType(house.getBuildType())) { + b.setBuildingType(house.getBuildType()); + } + if (HouseValidator.validateArea(house.getArea()) && !checkExists(list, b)) { + list.add(b); + } + + } + return list; + } + + // 200~900ms + public Object similarAction(PropertyEvaluationModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); + return mav; + } + if (0 >= model.getSize()) { + mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); + return mav; + } + // 在库中找到对应的小区 + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + // 查找均价 + List districtStats = districtStatService.findAllDistrictStatsSort(district.getCity(), + district.getRegion(), district.getName(), model.getCalDate()); + Integer districtAvg = 0; + if (districtStats != null && !districtStats.isEmpty()) { + DistrictStat districtStat = districtStats.get(0); + districtAvg = districtStat.getAvgPrice(); + } + Integer avgPrice = 0; + Integer tatalPrice = 0; + int count = 0; + List listHouse = similarCommMethod(model, "similar", district); + for (House house : listHouse) { + long temp = Math.round(house.getTotalPrice() / house.getArea()); + // 均价范围在0.8~1.2 + if (temp > districtAvg * 1.3 || temp < districtAvg * 0.7) { + continue; + } + avgPrice = (int) temp + avgPrice; + count++; + } + + if (count == 0) { + mav.setModel(BasicModel.buildOKModel().setMsg("该小区无均价")); + return mav; + } + avgPrice = avgPrice / count; + tatalPrice = (int) Math.round(avgPrice * model.getSize()); + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("totalPrice", tatalPrice); + districtPriceMap.put("avgPrice", avgPrice); + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } + + // 寻找相似房源 + public List similarCommMethod(PropertyEvaluationModel model, String kind, District district) { + model.setName(district.getName()); + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (model.getCalDate() != null) { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + List listHouse = new ArrayList(); + FacetQueryResult houseBos = houseService.findSeabirdHouses(district, 0, 1000); + if ("similarSort".equals(kind)) { + listHouse = houseService.findSimilarDistrictParam(houseBos, FJT_DIRECTION.get(model.getDirection()), + FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), model.getFloor(), + model.getRoom(), model.getHall(), model.getSize(), 1); + } else if ("similar".equals(kind)) { + for (int param = 1; param <= 5; param++) { + listHouse.addAll(houseService.findSimilarDistrict(houseBos, FJT_DIRECTION.get(model.getDirection()), + FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), + model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), param)); + if (listHouse.size() > 50) { + break; + } + } + } + if (listHouse == null || listHouse.size() < 5) { + List districts = houseService.findAroundDistrict(district); + for (District around : districts) { + FacetQueryResult aroundBos = houseService.findSeabirdHouses(around, 0, 1000); + if (listHouse == null || listHouse.isEmpty()) { + listHouse = houseService.findSimilarDistrict(aroundBos, FJT_DIRECTION.get(model.getDirection()), + FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), + model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), 3); + } else { + listHouse + .addAll(houseService.findSimilarDistrict(aroundBos, FJT_DIRECTION.get(model.getDirection()), + FITMENT_MAP.get(model.getFitment()), PROPERTY_TYPES.get(model.getEstateType()), + model.getFloor(), model.getRoom(), model.getHall(), model.getSize(), 3)); + } + if (listHouse.size() > 10) { + break; + } + } + } + return listHouse; + } + + public static final String[] DFIELDS = {"city", "region", "name", "address"}; + + public Object autoCompleteAction(PropertySearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (!"全国".equals(model.getCity())) { + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } + } + + if (StringUtils.isNotBlank(model.getDistrict())) { + model.setDistrict(RegionData.formatRegion(model.getCity(), model.getDistrict())); + } + + if (StringUtils.isBlank(model.getKeyword())) { + mav.setModel(BasicModel.buildBadRequestModel("keyword(关键字)不能为空")); + return mav; + } + + String type = "name"; + if (StringUtils.isNotBlank(model.getFilter())) { + type = model.getFilter(); + } + //强行启用小区库 + if ("true".equals(model.getUseSeaweed())) { + if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 100) { + model.setMax(10); + } + List params = new ArrayList(); + if (!"全国".equals(model.getCity())) { + params.add(new QueryParam("city", model.getCity())); + } + if (StringUtils.isNotBlank(model.getDistrict())) { + params.add(new QueryParam("region", model.getDistrict())); + } + params.add(new QueryParam("category", "district")); + params.add(new QueryParam("visible", 0)); + // BooleanQuery srQuery1 = new BooleanQuery(); + // BooleanQuery nameQuery = new BooleanQuery(); + // nameQuery.add(new TermQuery(new Term("district_name", model.getKeyword())), + // BooleanClause.Occur.SHOULD); + // nameQuery.add(new PrefixQuery(new Term("name", + // QueryParser.escape(model.getKeyword()).toLowerCase())), + // BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("alias_std", model.getKeyword())), + // BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("address", model.getKeyword())), + // BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("addr_alias_std", model.getKeyword())), + // BooleanClause.Occur.SHOULD); + + if (StringUtils.isNotBlank(model.getKeyword())) { + BooleanQuery query = new BooleanQuery(); + if (model.getUseOrQuery()) { + params.add(new QueryParam("$fangjiawang_query_type", "or")); + } + // 2017-11-02新增, 指定查询字段,以:分割为多个字段查询,处理pds搜索问题,不指定默认用keyword查询 + String queryFields = model.getQueryField(); + if (StringUtils.isNotBlank(queryFields) && queryFields.contains(":")) { + String[] fs = queryFields.split(":"); + for (String f : fs) { + Query q1 = new TermQuery(new Term(f, QueryParser.escape(model.getKeyword()).toLowerCase())); + q1.setBoost(0.99f); + query.add(q1, BooleanClause.Occur.SHOULD); + } + } else { + Query q1 = new TermQuery( + new Term(model.getQueryField(), QueryParser.escape(model.getKeyword()).toLowerCase())); + q1.setBoost(0.99f); + query.add(q1, BooleanClause.Occur.SHOULD); + } + + /* + * Query q2 = new TermQuery(new Term("keyword_cjk", + * QueryParser.escape(model.getKeyword()).toLowerCase())); q2.setBoost(0.01f); + * query.add(q2, BooleanClause.Occur.SHOULD); + */ + + /* + * String districtName = tokenDistrictName(model.getKeyword()); + * if(StringUtils.isNotBlank(districtName)){ Query q3 = new TermQuery(new + * Term("keyword_cjk", districtName)); q3.setBoost(0.99f); query.add(q3, + * BooleanClause.Occur.SHOULD); } + */ + // Query query = + // boostQueryDistrictNewPolicy.create(ServiceUtil.removeAndGetKeyword(params)); + params.add(new QueryParam("$sr", new SrQuery(query))); + // params.add(new QueryParam("keyword", + // QueryParser.escape(model.getKeyword()).toLowerCase())); + + } + List districts = districtService.findAllByParams(params, 0, model.getMax(), new String[]{"city", + "region", "name", "alias", "address", "addrAlias", "lat2", "lng2", "householdCount"}); + + List result = new ArrayList(); + if (districts != null) { + for (District district : districts) { + BasicDBObject item = new BasicDBObject(); + item.append("city", district.getCity()); + item.append("district", district.getRegion()); + item.append("name", district.getName()); + item.append("address", district.getAddress()); + item.append("latBaidu", district.getLat2()); + item.append("lngBaidu", district.getLng2()); + item.append("houseHoldCount", district.getHouseholdCount()); + if (district.getAlias() != null && district.getAlias().size() > 0) { + item.append("alias", district.getAlias()); + } + if (CollectionUtils.isNotEmpty(district.getAddrAlias())) { + item.append("address_alias", district.getAddrAlias()); + } + result.add(item); + } + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 20) { + model.setMax(10); + } + List autoCompleteBos = autoCompleteService.suggest("district", type, model.getCity(), + model.getKeyword(), model.getMax()); + List result = new ArrayList(); + if (autoCompleteBos != null) { + for (AutoCompleteBo bo : autoCompleteBos) { + BasicDBObject item = new BasicDBObject(); + item.append("city", model.getCity()); + item.append("district", bo.getRegion()); + item.append("name", bo.getVal()); + item.append("address", bo.getDesc()); + result.add(item); + } + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } + + return mav; + } + + /** + * 解析出关键字中的小区名 + * + * @param keyword + * @return + */ + private String tokenDistrictName(String keyword) { + List tokens = CnTokenizer.tokenizer(keyword); + Token token = getTokenByType(tokens, KeywordEnum.district); + if (token != null && "district".equals(token.getKeywordTypes())) { + return token.getName(); + } + return null; + } + + private Token getTokenByType(List tokens, KeywordEnum type) { + for (Token token : tokens) { + if (token.containsType(type)) { + return token; + } + } + return null; + } + + public Object similarSortAction(PropertyEvaluationModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("district(区域)不能为空")); + return mav; + } + if (StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("name(小区名)不能为空")); + return mav; + } + if (0 >= model.getSize()) { + mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能为空")); + return mav; + } + // 在库中找到对应的小区 + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + + Integer avgPrice = 0; + Integer tatalPrice = 0; + int count = 0; + List listHouse = similarCommMethod(model, "similarSort", district); + + // 查找均价 + List districtStats = districtStatService.findAllDistrictStatsSort(district.getCity(), + district.getRegion(), district.getName(), model.getCalDate()); + Integer districtAvg = 0; + if (districtStats != null && !districtStats.isEmpty()) { + DistrictStat districtStat = districtStats.get(0); + districtAvg = districtStat.getAvgPrice(); + } + for (House house : listHouse) { + long temp = Math.round(house.getTotalPrice() / house.getArea()); + if (temp > districtAvg * 1.3 || temp < districtAvg * 0.7) { + continue; + } + avgPrice = (int) temp + avgPrice; + count++; + } + if (count == 0) { + mav.setModel(BasicModel.buildOKModel().setMsg("该小区无均价")); + return mav; + } + avgPrice = avgPrice / count; + tatalPrice = (int) Math.round(avgPrice * model.getSize()); + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("totalPrice", tatalPrice); + districtPriceMap.put("avgPrice", avgPrice); + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } + + public String getDomainName(String url) { + if (StringUtils.isNotBlank(url)) { + Pattern p = Pattern.compile("[^//]*?\\.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE); + Matcher matcher = p.matcher(url); + if (matcher.find()) { + return matcher.group(); + } + } + return "fangjia.com"; + } + + private Integer getFloor(String roomNumber) { + if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) { + if (roomNumber.length() == 3) { + return Integer.valueOf(roomNumber.substring(0, 1)); + } else if (roomNumber.length() == 4) { + return Integer.valueOf(roomNumber.substring(0, 2)); + } else { + return null; + } + } + return null; + } + + private boolean checkExists(FacetQueryResult houseBoList, NewHousePojo house) { + for (NewHousePojo bo : houseBoList) { + boolean sameName = bo.getName().equals(house.getName()); + boolean sameAddress = bo.getAddress() != null ? bo.getAddress().equals(house.getAddress()) + : house.getAddress() == null; + boolean sameTotalPrice = bo.getListingPrice() != null ? bo.getListingPrice().equals(house.getListingPrice()) + : house.getListingPrice() == null; + boolean samePublishDate = bo.getPublishDate() != null ? bo.getPublishDate().equals(house.getPublishDate()) + : house.getPublishDate() == null; + boolean sameArea = bo.getSize() != null ? bo.getSize().equals(house.getSize()) : house.getSize() == null; + boolean sameFloor = bo.getFloor() != null ? bo.getFloor().equals(house.getFloor()) + : house.getFloor() == null; + if (sameName && sameAddress && sameFloor && sameTotalPrice && samePublishDate && sameArea) { + return true; + } + } + return false; + } + + /** + * 小区统计分析接口 + * + * @param model + * @return + */ + public Object analysisAction(DistrictQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (district.getLat2() == null || district.getLng2() == null) { + + mav.setModel(BasicModel.buildOKModel()); + return mav; + } + + DistrictKey districtKey = new DistrictKey(district.getCity(), district.getRegion(), district.getName()); + DistrictAttentionRank attention = districtAttentionRankService.findByDistrictKey(districtKey);// 小区关注度信息 + CityHot cityHot = cityHotService.findByCity(district.getCity()); + DistrictHot districtHot = districtHotService.findDistrictHotByDistrictKey(districtKey); + if (null != districtHot) { + if (null != districtHot.getHouseLastMonth() && districtHot.getHouseLastMonth() > 0) { + int lastMonthHouses = districtHot.getHouseLastMonth();// 上月挂牌量 + + if (null != cityHot && null != cityHot.getSellMarkupMonth()) { + districtHot.setHouseHalfYear( + (int) (lastMonthHouses * 6 * (1 + cityHot.getSellMarkupMonth() / 10000.0))); + } else { + districtHot.setHouseHalfYear((int) (lastMonthHouses * 6 * 0.9625)); + } + } + } + + double lat = district.getLat2() / 10000000000d; + double lng = district.getLng2() / 10000000000d; + double radius = 1000d; + double aroundAvgConsumption = bizShopService.findAroundAvgConsumption(lat, lng, radius, "餐厅");// 周边消费人均 + + int regionClickRank = 0; + int cityClickRank = 0; + int houseLastMonth = 0; + int houseHalfYear = 0; + + if (attention != null) { + if (attention.getRegionClickRank() != null) { + regionClickRank = attention.getRegionClickRank(); + } + if (attention.getCityClickRank() != null) { + cityClickRank = attention.getCityClickRank(); + } + } + + if (districtHot != null) { + if (districtHot.getHouseHalfYear() != null) { + houseHalfYear = districtHot.getHouseHalfYear(); + } + if (districtHot.getHouseLastMonth() != null) { + houseLastMonth = districtHot.getHouseLastMonth(); + } + } + + DistrictAnalysisDto districtAnalysisDto = new DistrictAnalysisDto(); + districtAnalysisDto.setCity(district.getCity());// 城市 + districtAnalysisDto.setDistrict(district.getRegion());// 区域 + districtAnalysisDto.setName(district.getName());// 小区名 + districtAnalysisDto.setAvgPriceAround((int) aroundAvgConsumption);// 周边餐饮平均消费 + districtAnalysisDto.setDistrictClickRank(regionClickRank);// 区域关注度排名 + districtAnalysisDto.setCityClickRank(cityClickRank);// 全市关注度排名 + districtAnalysisDto.setHouseHalfYear(houseHalfYear);// 近半年小区挂牌量 + districtAnalysisDto.setHouseLastMonth(houseLastMonth);// 上月小区挂牌量 + + mav.setModel(BasicModel.buildOKModel().setResult(districtAnalysisDto)); + return mav; + } + + /** + * 小区交通接口 + * + * @param model + * @return + */ + public Object trafficAction(DistrictQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (district.getLat2() == null || district.getLng2() == null) { + + mav.setModel(BasicModel.buildOKModel()); + return mav; + } + + double lat = district.getLat2() / 10000000000d; + double lng = district.getLng2() / 10000000000d; + double radius = 1000d; + + Map> stationMap = busStationService.getNearByStations(district.getCity(), lat, lng, + radius);// 查询交通信息(公交,地铁) bus_station,bus_line + List MetroStations = stationMap.get("地铁"); + List BusStation = stationMap.get("公交"); + + List StationDtos = new ArrayList(); + if (MetroStations != null) { + for (BusStation station : MetroStations) { + StationDto stationDto = new StationDto(); + stationDto.setName(station.getStation()); + stationDto.setLineName(station.getLineId()); + StationDtos.add(stationDto); + } + } + + if (BusStation != null) { + for (BusStation station : BusStation) { + StationDto stationDto = new StationDto(); + stationDto.setName(station.getStation()); + stationDto.setLineName(station.getLineId()); + StationDtos.add(stationDto); + } + } + + mav.setModel(BasicModel.buildOKModel().setResult(StationDtos)); + return mav; + } + + /** + * 小区周边接口 + * + * @param model + * @return + */ + public Object aroundAction(DistrictQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (district.getLat2() == null || district.getLng2() == null) { + + mav.setModel(BasicModel.buildOKModel()); + return mav; + } + + double radius = 1000d;// 查周围半径为1公里距离的信息 + + List arrs = baiduApiService.searchNearbyLocalDatabase(district, radius);// 查询小区周边(所有类型) + Map> districtAroundMap = new HashMap>(); + + for (String key : AROUND_KEYWORD_FACTOR.keySet()) { + + List aroundNames = new ArrayList(); + districtAroundMap.put(AROUND_KEYWORD_FACTOR.get(key), aroundNames);// 把key的英文put到map并把value设置为一个List引用 + + } + for (int i = 0; i < arrs.size(); i++) { + BaiduPlacePoi poiObj = arrs.get(i); + String name = poiObj.getName(); + String keyword = poiObj.getKeyword(); + double latjs = poiObj.getLat(); + double lngjs = poiObj.getLng(); + String key = AROUND_KEYWORD_FACTOR.get(keyword); + + AroundDto dto = new AroundDto(); + dto.setName(name); + dto.setLat(latjs); + dto.setLng(lngjs); + if (districtAroundMap.get(key) != null) { + districtAroundMap.get(key).add(dto);// 按key值取出list add 周边名称已经经纬度 + } + + } + mav.setModel(BasicModel.buildOKModel().setResult(districtAroundMap)); + return mav; + } + + /** + * 相同小区相似户型房源挂牌量接口
+ * 获取该小区的满足指定相似条件的挂牌房源量 条件说明: 1.输入面积-5<=房源面积<=输入面积+5 2.上个月发布的房源 + * + * @param city 城市 + * @param district 区域 + * @param name 小区名 + * @param size 面积 + * @return + * @author yinjihuan + * @date 2016年9月1日 + */ + public Object similarHouseAmoutAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "size") Double size) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(name) || StringUtils.isBlank(district) || size == null) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名),size(面积)是必须参数")); + return mav; + } + if (size <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能小于0")); + return mav; + } + District districtInfo = districtService.findByNameAndAlias(city, district, name, "district"); + if (null == districtInfo) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + long result = districtHouseResourceStatService.findSimilarHouseAmoutCount(districtInfo.getId(), size); + BasicModel model = new BasicModel(200, "ok"); + model.setResult(result); + mav.setModel(model); + return mav; + } + + /** + * 周边小区相似户型挂牌量接口
+ * 获取该小区的满足指定相似条件的挂牌房源量 条件说明: 1.输入面积-5<=房源面积<=输入面积+5 2.上个月发布的房源 + * + * @param city 城市 + * @param district 区域 + * @param name 小区名 + * @param size 面积 + * @param radius 周边小区最大半径(单位:米,默认2000) + * @return + * @author yinjihuan + * @date 2016年9月1日 + */ + public Object nearbySimilarHouseAmoutAction(@Param(name = "city") String city, + @Param(name = "district") String district, @Param(name = "name") String name, + @Param(name = "size") Double size, @Param(name = "radius") Integer radius) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(name) || StringUtils.isBlank(district) || size == null) { + mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域),name(小区名),size(面积)是必须参数")); + return mav; + } + if (size <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("size(面积)不能小于0")); + return mav; + } + District districtInfo = districtService.findByNameAndAlias(city, district, name, "district"); + if (null == districtInfo) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (radius == null) { + radius = 2000; + } + // 找出小区周边范围类的小区 + List districts = districtService.findNearestDistrict(districtInfo, radius, 500); + List districtIds = new ArrayList(); + for (District dis : districts) { + districtIds.add(dis.getId()); + } + districtIds.add(districtInfo.getId()); + BasicModel model = new BasicModel(200, "ok"); + model.setResult(districtHouseResourceStatService.findNearbySimilarHouseAmoutCount(size, districtIds)); + mav.setModel(model); + return mav; + } + + /** + * 小区周边一公里均价 + * + * @param model + * @return + * @author wenyan + */ + public Object aroundAverageAction(@Valid AroundAverageModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + DistrictKey key = new DistrictKey(model.getCity(), model.getDistrict(), model.getName()); + DistrictAnalyData districtAnalyData = districtAnalyDataService.findByDistrictKey(key); + BasicModel dataModel = BasicModel.buildOKModel(); + if (districtAnalyData != null && districtAnalyData.getAroundDistrictAvgPrice() != null) { + UniversalDto dto = UniversalDto.newDto(); + dto.append("averagePrice", districtAnalyData.getAroundDistrictAvgPrice()); + dataModel.setResult(dto); + } + mav.setModel(dataModel); + return mav; + + } + + /** + * 相同小区相似户型租金范围查询接口 + * + * @param model + * @return + */ + public Object similarHouseRentRangeAction(@Valid RentModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + + // List houseBos = + // houseService.findDistrictHouseByCat(district.getCity(), district.getRegion(), + // district.getName(), 100, null, model.getSize()-5, model.getSize()+5); + Integer room = houseService.getDistrictRoomType(model.getSize()); + if (null == room) { + mav.setModel(BasicModel.buildBadRequestModel("根据size(面积)没有找到相应的室")); + return mav; + } + + List districtStatRents = districtStatRentService.findLatestDistrictStatRent(district, 1, + (int) room); + if (null == districtStatRents || districtStatRents.size() == 0) { + mav.setModel(BasicModel.buildOKModel()); + } else { + DistrictStatRent districtStatRent = districtStatRents.get(0); + Map rentRangeMap = new HashMap(); + if (districtStatRent.getAvgPrice() > 0) { + Integer avgPrice = districtStatRent.getAvgPrice(); + rentRangeMap.put("min", (int) (avgPrice - avgPrice * 0.08)); + rentRangeMap.put("max", (int) (avgPrice + avgPrice * 0.08)); + } + mav.setModel(BasicModel.buildOKModel().setResult(rentRangeMap)); + } + return mav; + } + + /** + * 周边小区相似户型租金范围查询接口 + * + * @param model + * @return + */ + public Object nearlySimilarHouseRentRangeAction(@Valid RentModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); + return mav; + } + if (null == model.getRadius()) {// 设置默认值 + model.setRadius(2000); + } + + List districts = districtService.findNearestDistrict(district, model.getRadius(), 500); + if (null != districts) { + // List houseBos = new ArrayList(); + // for(District dist : districts){ + // List bos = houseService.findDistrictHouseByCat(dist.getCity(), + // dist.getRegion(), dist.getName(), 100, null, model.getSize()-5, + // model.getSize()+5); + // houseBos.addAll(bos); + // } + Integer room = houseService.getDistrictRoomType(model.getSize()); + if (null == room) { + mav.setModel(BasicModel.buildBadRequestModel("根据size(面积)没有找到相应的室")); + return mav; + } + + List prices = new ArrayList(); + for (District dist : districts) { + List districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, + room); + if (null != districtStatRents && districtStatRents.size() > 0) { + DistrictStatRent districtStatRent = districtStatRents.get(0); + if (districtStatRent.getAvgPrice() > 0) { + Integer avgPrice = districtStatRent.getAvgPrice(); + prices.add(avgPrice); + } + } + } + + Map rentRangeMap = new HashMap(); + if (prices.size() > 0) { + Collections.sort(prices); + rentRangeMap.put("min", prices.get(0)); + rentRangeMap.put("max", prices.get(prices.size() - 1)); + mav.setModel(BasicModel.buildOKModel().setResult(rentRangeMap)); + } else { + mav.setModel(BasicModel.buildOKModel()); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("没找到周边小区")); + } + + return mav; + } + + /** + * 室号查询接口 + * + * @param model + * @return + */ + public Object roomAction(@Valid RoomModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + + List queryParams = new ArrayList(); + queryParams.add(new QueryParam("city", model.getCity())); + queryParams.add(new QueryParam("region", model.getDistrict())); + queryParams.add(new QueryParam("name", model.getProjectName())); + queryParams.add(new QueryParam("houseNum", model.getBuildingNumber())); + queryParams.add(new QueryParam("houseNumUnit", model.getUnitNumber())); + if (model.getFloor() != null) { + queryParams.add(new QueryParam("houseFloor", model.getFloor())); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("houseFloor", true)); + List houseLoudongs = houseLoudongService.findAll(queryParams, new Pager(Integer.MAX_VALUE)); + List rooms = new ArrayList(); + for (HouseLoudong houseLoudong : houseLoudongs) { + if ("--".equals(houseLoudong.getRoomNum())) { + continue; + } + RoomDto dto = new RoomDto(); + dto.setDisplay(houseLoudong.getRoomNum() + "室"); + dto.setUnitNumber(houseLoudong.getHouseNumUnit()); + dto.setRoom(houseLoudong.getRoomNum()); + rooms.add(dto); + } + mav.setModel(BasicModel.buildOKModel().setResult(rooms)); + return mav; + } + + /** + * 楼栋楼层信息查询接口 + * + * @param model + * @return + */ + public Object floorsAction(@Valid FloorsModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), + model.getBuildingNumber(), model.getUnitNumber(), Integer.MAX_VALUE); + if (null == loudongs || loudongs.isEmpty()) { + mav.setModel(BasicModel.buildBadRequestModel("楼栋不存在")); + return mav; + } + List floors = new ArrayList(); + if (loudongs.get(0).getFloors() > 0) { + for (int i = 1; i <= loudongs.get(0).getFloors(); i++) { + floors.add(i); + } + } + mav.setModel(BasicModel.buildOKModel().setResult(floors)); + return mav; + } + + /** + * 楼栋查询接口 + * + * @param model + * @return + */ + public Object buildingAction(@Valid BuildingModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + + List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), + null, null, Integer.MAX_VALUE); + List dtos = new ArrayList(); + List keys = new ArrayList(); + for (Loudong loudong : loudongs) { + if (keys.contains(loudong.getHouseNumber()) || "--".equals(loudong.getHouseNumber())) { + continue; + } + BuildingDto dto = new BuildingDto(); + dto.setId(loudong.getId()); + dto.setBuildingNumber(loudong.getHouseNumber()); + dto.setLabel(loudong.getHouseNumber()); + dtos.add(dto); + keys.add(loudong.getHouseNumber()); + } + + Collections.sort(dtos, new Comparator() { + @Override + public int compare(BuildingDto o1, BuildingDto o2) { + if (StringUtils.isNumeric(o1.getBuildingNumber()) && StringUtils.isNumeric(o2.getBuildingNumber())) { + return new Double(o1.getBuildingNumber()).compareTo(new Double(o2.getBuildingNumber())); + } else if (StringUtils.isNumeric(o1.getBuildingNumber())) { + return -1; + } else if (StringUtils.isNumeric(o2.getBuildingNumber())) { + return 1; + } else { + return o1.getBuildingNumber().compareTo(o2.getBuildingNumber()); + } + + } + }); + + mav.setModel(BasicModel.buildOKModel().setResult(dtos)); + return mav; + } + + /** + * 楼栋查询接口 + * + * @param model + * @return + */ + public Object unitNumberAction(@Valid UnitNumberModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + + List loudongs = loudongService.findAll(model.getCity(), model.getDistrict(), model.getProjectName(), + model.getBuildingNumber(), null, Integer.MAX_VALUE); + + List dtos = new ArrayList(); + List keys = new ArrayList(); + for (Loudong loudong : loudongs) { + if (keys.contains(loudong.getUnitNumber()) || "--".equals(loudong.getUnitNumber())) { + continue; + } + UnitNumberDto dto = new UnitNumberDto(); + dto.setId(loudong.getId()); + dto.setBuildingNumber(loudong.getHouseNumber()); + dto.setUnitNumber(loudong.getUnitNumber()); + dto.setLabel(loudong.getUnitNumber()); + dtos.add(dto); + keys.add(loudong.getUnitNumber()); + } + Collections.sort(dtos, new Comparator() { + @Override + public int compare(UnitNumberDto o1, UnitNumberDto o2) { + if (StringUtils.isNumeric(o1.getUnitNumber()) && StringUtils.isNumeric(o2.getUnitNumber())) { + return new Double(o1.getUnitNumber()).compareTo(new Double(o2.getUnitNumber())); + } else if (StringUtils.isNumeric(o1.getUnitNumber())) { + return -1; + } else if (StringUtils.isNumeric(o2.getUnitNumber())) { + return 1; + } else { + return o1.getUnitNumber().compareTo(o2.getUnitNumber()); + } + + } + }); + + mav.setModel(BasicModel.buildOKModel().setResult(dtos)); + return mav; + } + + public Object avgPrice2Action(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name) { + + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(district) || StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("小区所在城市,所在区域,小区名为必填项")); + return mav; + } + + District districtBo = districtService.findByNameAndAlias(city, district, name, "district"); + if (null == districtBo) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + + DistrictStatBo districtStatBo = districtStatService + .findDistrictStat(new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName())); + if (null == districtStatBo || (districtStatBo != null && districtStatBo.getDistrictStat() == null + && districtStatBo.getVillaDistrictStat() == null)) { + mav.setModel(BasicModel.buildOKModel()); + return mav; + } + Integer lastAvgPrice = averageAnalyService.getLastAvgPrice(districtBo, districtStatBo); + Map map = new HashMap(); + map.put("city", districtBo.getCity()); + map.put("district", districtBo.getRegion()); + map.put("name", districtBo.getName()); + map.put("avgPrice", lastAvgPrice); + if (districtStatBo.getDistrictStat() != null) { + map.put("date", DateUtil.formatByPattern(districtStatBo.getDistrictStat().getWeekend(), "yyyy-MM-dd")); + } else if (districtStatBo.getVillaDistrictStat() == null) { + map.put("date", DateUtil.formatByPattern(districtStatBo.getVillaDistrictStat().getWeekend(), "yyyy-MM-dd")); + } + + mav.setModel(BasicModel.buildOKModel().setResult(map)); + return mav; + } + + private Map getLastEvaluationPrice(District district, Evaluation evaluation, double dCredit) + throws NumberFormatException, IllegalAccessException { + Date startDate = DateUtil.parseDate(DateUtil.addMonth(new Date(), -6), "yyyy-MM-dd"); + // 第三方价格 + Map otherPriceRets = averageStatisticsService.findFirstAverageStatictics(district.getCity(), + district.getRegion(), district.getName(), district.getCategory(), startDate); + if (null == otherPriceRets) { + otherPriceRets = new HashMap(); + } + + otherPriceRets.put("fjw_price", evaluation.getAvgPrice()); + Map levelMap = getPriceLevel(otherPriceRets, evaluation.getCredit()); + Long lastPrice = getLastPrice(levelMap, otherPriceRets, evaluation, dCredit); + + Map rMap = new HashMap(); + rMap.put("lastPrice", lastPrice); + if (null != levelMap && levelMap.containsKey("level")) { + String priceLevel = (String) levelMap.get("level"); + rMap.put("level", priceLevel); + } + rMap.put("other_price", otherPriceRets); + return rMap; + } + + private Long getLastPrice(Map retMap, Map otherPriceRets, Evaluation evaluation, double dCredit) { + Long lastPrice = null; + if (null != retMap) { + String priceLevel = (String) retMap.get("level"); + + if (priceLevel.equals("D")) { + + lastPrice = inputResultByWebsite(otherPriceRets, evaluation, dCredit); + + } else if (priceLevel.equals("E")) { + if (evaluation.getCredit() >= 0.65) { + lastPrice = evaluation.getBigTotalPrice(); + } else { + List prices = (List) retMap.get("prices"); + int avgPrice = 0; + if (prices != null) { + avgPrice = findNewPrice(prices, evaluation.getAvgPrice()); + } + // 在 dCredit与0.65之间 + if (evaluation.getCredit() >= dCredit && dCredit < 0.65) { + if (avgPrice > 0) { + Double newTotalPrice = avgPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else { + if (null != otherPriceRets.get("lianjia_price")) { + Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); + Double newTotalPrice = lianjiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("zhugezhaofang_price")) { + Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); + Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("yungujia_price")) { + Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); + Double newTotalPrice = yungujiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("fanggugu_price")) { + Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); + Double newTotalPrice = fangguguPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else { + lastPrice = evaluation.getBigTotalPrice(); + } + } + } else if (evaluation.getCredit() < dCredit) {// 在dCredit以下 + if (avgPrice > 0) { + Double newTotalPrice = avgPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else { + if (null != otherPriceRets.get("lianjia_price")) { + Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); + Double newTotalPrice = lianjiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("zhugezhaofang_price")) { + Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); + Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("yungujia_price")) { + Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); + Double newTotalPrice = yungujiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("fanggugu_price")) { + Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); + Double newTotalPrice = fangguguPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } + } + } + } + + } else if (priceLevel.equals("C")) { + List smallPrices = (List) retMap.get("small_prices"); + if (smallPrices != null) { + smallPrices.add(evaluation.getAvgPrice()); + int avgPrice = sum(smallPrices) / smallPrices.size(); + Double newTotalPrice = avgPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } + } else { + lastPrice = evaluation.getBigTotalPrice(); + } + } + return lastPrice; + } + + private Long inputResultByWebsite(Map otherPriceRets, Evaluation evaluation, double dCredit) { + Long lastPrice = null; + if (evaluation.getCredit() >= dCredit) { + lastPrice = evaluation.getBigTotalPrice(); + } else { + if (evaluation.getCredit() < dCredit) { + if (null != otherPriceRets.get("lianjia_price")) { + Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); + Double newTotalPrice = lianjiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("zhugezhaofang_price")) { + Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); + Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("yungujia_price")) { + Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); + Double newTotalPrice = yungujiaPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else if (null != otherPriceRets.get("fanggugu_price")) { + Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); + Double newTotalPrice = fangguguPrice * evaluation.getArea(); + lastPrice = newTotalPrice.longValue(); + } else { + lastPrice = evaluation.getBigTotalPrice(); + } + } else { + lastPrice = evaluation.getBigTotalPrice(); + } + } + return lastPrice; + } + + private Integer findNewPrice(List prices, int avgPrice) { + int minValue1 = Integer.MAX_VALUE; + List> values = new ArrayList>(); + int fjw_price = avgPrice; + + // 找出最小差 + for (int i = 0; i < prices.size() - 1; i++) { + int a = prices.get(i); + for (int j = i + 1; j < prices.size(); j++) { + int b = prices.get(j); + int mod = Math.abs(a - b); + if (mod < minValue1) { + minValue1 = mod; + } + } + } + + // 根据最小差找出结果 + for (int i = 0; i < prices.size() - 1; i++) { + int a = prices.get(i); + for (int j = i + 1; j < prices.size(); j++) { + int b = prices.get(j); + int mod = Math.abs(a - b); + if (mod == minValue1) { + values.add(Arrays.asList(a, b)); + } + } + } + + int minValue2 = Integer.MAX_VALUE; + int lastValue = 0; + if (values.size() >= 1) { + for (List value : values) { + int newPrice = (value.get(0) + value.get(1)) / 2; + int mod = Math.abs(fjw_price - newPrice); + if (mod < minValue2) { + minValue2 = mod; + lastValue = newPrice; + } + } + } + + if (lastValue > 0) { + double temp = DataUtil.getDoubleRound(2, minValue1 * 100 / lastValue); + temp = Math.abs(temp); + if (temp > 15) { + lastValue = 0; + } + } + return lastValue; + } + + private Integer sum(List smallPrices) { + int sum = 0; + for (int price : smallPrices) { + sum += price; + } + return sum; + } + + private Map getPriceLevel(Map otherPriceRets, double credit) { + + Integer avgPrice = (Integer) otherPriceRets.get("fjw_price"); + + int keyCount = 0; + int commonCount = 0; + int isExistCount = 0; + + List prices = new ArrayList(); + List smallPrices = new ArrayList(); + + if (null != otherPriceRets.get("fanggugu_price")) { + Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price"); + int mod = avgPrice - fangguguPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + keyCount++; + } else { + prices.add(fangguguPrice); + } + isExistCount++; + } + if (null != otherPriceRets.get("yungujia_price")) { + Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price"); + int mod = avgPrice - yungujiaPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + keyCount++; + } else { + prices.add(yungujiaPrice); + } + + isExistCount++; + } + + if (null != otherPriceRets.get("zhugezhaofang_price")) { + Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price"); + int mod = avgPrice - zhugezhaofangPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + keyCount++; + } else { + prices.add(zhugezhaofangPrice); + } + + isExistCount++; + } + + if (null != otherPriceRets.get("lianjia_price")) { + Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price"); + int mod = avgPrice - lianjiaPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + keyCount++; + } else { + prices.add(lianjiaPrice); + } + isExistCount++; + } + if (null != otherPriceRets.get("anjuke_price")) { + Integer anjukePrice = (Integer) otherPriceRets.get("anjuke_price"); + int mod = avgPrice - anjukePrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + commonCount++; + smallPrices.add(anjukePrice); + } else { + prices.add(anjukePrice); + } + + isExistCount++; + } + if (null != otherPriceRets.get("ganji_price")) { + Integer ganjiPrice = (Integer) otherPriceRets.get("ganji_price"); + int mod = avgPrice - ganjiPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + commonCount++; + smallPrices.add(ganjiPrice); + } else { + prices.add(ganjiPrice); + } + + isExistCount++; + } + if (null != otherPriceRets.get("soufan_price")) { + Integer soufan_price = (Integer) otherPriceRets.get("soufan_price"); + int mod = avgPrice - soufan_price; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + commonCount++; + smallPrices.add(soufan_price); + } else { + prices.add(soufan_price); + } + + isExistCount++; + } + if (null != otherPriceRets.get("tobushi_price")) { + Integer tobushi = (Integer) otherPriceRets.get("tobushi_price"); + int mod = avgPrice - tobushi; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + commonCount++; + smallPrices.add(tobushi); + } else { + prices.add(tobushi); + } + + isExistCount++; + } + + if (null != otherPriceRets.get("zhongyuan_price")) { + Integer zhongyuanPrice = (Integer) otherPriceRets.get("zhongyuan_price"); + int mod = avgPrice - zhongyuanPrice; + double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice); + temp = Math.abs(temp); + if (temp <= 15) { + commonCount++; + smallPrices.add(zhongyuanPrice); + } else { + prices.add(zhongyuanPrice); + } + + isExistCount++; + } + + Map retMap = new HashMap(); + String level = null; + if (keyCount >= 2) { + level = "A"; + } else if (keyCount >= 1 && commonCount >= 1) { + level = "A"; + } else if (keyCount >= 1 || commonCount >= 2) { + level = "B"; + } else if (commonCount >= 1) { + level = "C"; + } else if (isExistCount == 0) { + level = "D"; + } else if (isExistCount >= 1) { + if (isExistCount == 1) { + level = "D"; + } else { + level = "E"; + } + } + + if (credit == 0) { + level = "E"; + } + + if (StringUtils.isNotBlank(level)) { + retMap.put("level", level); + retMap.put("prices", prices); + retMap.put("small_prices", smallPrices); + } + return retMap; + } + + /** + * 房产交易记录查询 + * + * @param model + * @return + */ + public Object transactionRecordAction(PropertySearchModel model) { + // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) trade_date倒序 + // max查询条数 + // 输出 + // {"result":{"districtCnt":"小区1年内成交数量","transactionList":[{"time":"yyyy-MM-dd","price":"xxx万"}]}} + // time是每笔的成交时间,price是每笔的成交金额,注意看数据格式 + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + String city = model.getCity(); + String district = model.getDistrict(); + String name = model.getName(); + String houseNum = model.getHouseNum(); + String roomNum = model.getRoomNum(); + int max = model.getMax() == null ? 10 : model.getMax(); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); + return mav; + } + if (StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); + return mav; + } + if (StringUtils.isBlank(houseNum)) { + mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); + return mav; + } + if (StringUtils.isBlank(roomNum)) { + mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); + return mav; + } + Date curDate = new Date(); + // 小区1年内成交数量 + long count = dealPriceService.findTradeCount(city, district, name, DateUtil.getDateOfLastMonth(curDate, -12), + curDate); + List list = dealPriceService.findMaxTrade(city, district, name, houseNum, roomNum, max); + List transactionList = new ArrayList(); + for (DealPrice dealPrice : list) { + HouseDealPriceDetailDto detail = new HouseDealPriceDetailDto(); + detail.setPrice(dealPrice.getTotalPrice()); + detail.setPriceStr(DataUtil.roundDouble((dealPrice.getTotalPrice() / 10000d), 2) + "万"); + detail.setTime(DateUtil.formatByPattern(dealPrice.getTradeDate(), "yyyy-MM-dd")); + transactionList.add(detail); + } + HouseDealPriceDto dto = new HouseDealPriceDto(); + dto.setDistrictCnt(count); + dto.setTransactionList(transactionList); + mav.setModel(BasicModel.buildOKModel().setResult(dto)); + return mav; + } + + /** + * 房产拍卖记录 + * + * @param model + * @return + */ + public Object auctionRecordAction(PropertySearchModel model) { + // 拍卖记录表是fangjia_crawl.house_auction HouseAuction + // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) announcement_date倒序 + // max查询条数 + // 输入对应的表查询字段 cityMatch+regionMatch+nameMatch+buildingNumber+roomNumber + // 输出 + // {"result":{"districtCnt":"小区1年内拍卖数量","transactionList":[{"time":"yyyy-MM-dd","name":"xxx拍卖行"}]}} + // time是每笔的成交时间,name是每笔的拍卖机构,注意看数据格式 + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + String city = model.getCity(); + String district = model.getDistrict(); + String name = model.getName(); + String houseNum = model.getHouseNum(); + String roomNum = model.getRoomNum(); + int max = model.getMax() == null ? 10 : model.getMax(); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); + return mav; + } + if (StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); + return mav; + } + if (StringUtils.isBlank(houseNum)) { + mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); + return mav; + } + if (StringUtils.isBlank(roomNum)) { + mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); + return mav; + } + Date curDate = new Date(); + // 小区1年内成交数量 + long count = houseAuctionService.findHouseAuctionCount(city, district, name, + DateUtil.getDateOfLastMonth(curDate, -12), curDate); + List list = houseAuctionService.findMaxHouseAuction(city, district, name, houseNum, roomNum, max); + List transactionList = new ArrayList(); + for (HouseAuction houseAuction : list) { + HouseAuctionDetailDto detail = new HouseAuctionDetailDto(); + detail.setName(houseAuction.getCourt()); + detail.setTime(DateUtil.formatByPattern(houseAuction.getAuctionTime(), "yyyy-MM-dd")); + transactionList.add(detail); + } + HouseAuctionDto dto = new HouseAuctionDto(); + dto.setDistrictCnt(count); + dto.setTransactionList(transactionList); + mav.setModel(BasicModel.buildOKModel().setResult(dto)); + return mav; + } + + /** + * 房产近期评估次数 + * + * @param model + * @return + */ + public Object evaluateNumAction(PropertySearchModel model) { + // 输入(model中拿取) city+district+name+houseNum(楼栋号)+roomNum(室号) + // 输出 {"result":{"oneMonth":"房屋最近30天的评估次数","threeMonth":"房屋最近90天的评估次数"}} + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + String city = model.getCity(); + String district = model.getDistrict(); + String name = model.getName(); + String houseNum = model.getHouseNum(); + String roomNum = model.getRoomNum(); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city)不能为空")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("区域(district)不能为空")); + return mav; + } + if (StringUtils.isBlank(name)) { + mav.setModel(BasicModel.buildBadRequestModel("小区名(name)不能为空")); + return mav; + } + if (StringUtils.isBlank(houseNum)) { + mav.setModel(BasicModel.buildBadRequestModel("楼栋号(houseNum)不能为空")); + return mav; + } + if (StringUtils.isBlank(roomNum)) { + mav.setModel(BasicModel.buildBadRequestModel("室号(roomNum)不能为空")); + return mav; + } + Date curDate = new Date(); + long oneMonth = evaluationService.countByHouse(city, district, name, houseNum, roomNum, + DateUtil.getDateOfLastMonth(curDate, -1), curDate); + long threeMonth = evaluationService.countByHouse(city, district, name, houseNum, roomNum, + DateUtil.getDateOfLastMonth(curDate, -3), curDate); + mav.setModel(BasicModel.buildOKModel().setResult(new HouseEvaluateNumDto(oneMonth, threeMonth))); + return mav; + } + + /*** + * 小区租金估值报告(上半部分) + * @param model + * @param request + * @return + * @throws NumberFormatException + * @throws IllegalAccessException + */ + @Authority(role = Role.NONE) + public Object rentReportAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"}); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + + Evaluation evaluation = buildEvaluation(model, request); + evaluation.setSource("api_property_evaluate_rent"); + evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); + + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + evaluation.setAvgPrice((int) (evaluation.getTotalPrice() / evaluation.getArea())); + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("address", district.getAddress()); + districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); + districtPriceMap.put("totalPriceUpper", CurrencyConverter.toChinese(String.valueOf(evaluation.getTotalPrice()))); + districtPriceMap.put("cal_date", DateUtil.formatByPattern(new Date(), "yyyy/MM/dd")); + districtPriceMap.put("direction", evaluation.getDirection()); + districtPriceMap.put("size", evaluation.getArea()); + districtPriceMap.put("floor", model.getFloor()); + districtPriceMap.put("height", model.getHeight()); + districtPriceMap.put("fitment", evaluation.getFitment()); + districtPriceMap.put("buildYear", district.getFinishBuildingDate()); + + Integer startPrice = (int) (evaluation.getTotalPrice() - evaluation.getTotalPrice() * 0.2); + Integer endPrice = (int) (evaluation.getTotalPrice() + evaluation.getTotalPrice() * 0.2); + + //周边相似小区 // if (null == model.getRadius()) {// 设置默认值 // model.setRadius(1000); // } @@ -5472,7 +5528,7 @@ public class PropertyController { // } // } - //相似房源 + //相似房源 // Double startArea = model.getSize() - model.getSize()*0.1; // Double endArea = model.getSize() + model.getSize()*0.1; // Integer startDate = Integer.parseInt(org.apache.tools.ant.util.DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); @@ -5553,488 +5609,488 @@ public class PropertyController { // List rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5); // districtPriceMap.put("trades", rentTrades); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); - return mav; - } - } + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); + return mav; + } + } - /*** - * 小区租金估值报告(下半部分) - * @param model - * @param request - * @return - * @throws NumberFormatException - * @throws IllegalAccessException - */ - @Authority(role = Role.NONE) - public Object rentReport2Action(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district"); - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - Evaluation evaluation = buildEvaluation(model, request); - evaluation.setSource("api_property_evaluate_rent"); - evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); + /*** + * 小区租金估值报告(下半部分) + * @param model + * @param request + * @return + * @throws NumberFormatException + * @throws IllegalAccessException + */ + @Authority(role = Role.NONE) + public Object rentReport2Action(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + Evaluation evaluation = buildEvaluation(model, request); + evaluation.setSource("api_property_evaluate_rent"); + evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - evaluation.setAvgPrice((int)(evaluation.getTotalPrice()/evaluation.getArea())); - Map districtPriceMap = new HashMap(); - Integer startPrice = (int)(evaluation.getTotalPrice() - evaluation.getTotalPrice()*0.2); - Integer endPrice = (int)(evaluation.getTotalPrice() + evaluation.getTotalPrice()*0.2); + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + evaluation.setAvgPrice((int) (evaluation.getTotalPrice() / evaluation.getArea())); + Map districtPriceMap = new HashMap(); + Integer startPrice = (int) (evaluation.getTotalPrice() - evaluation.getTotalPrice() * 0.2); + Integer endPrice = (int) (evaluation.getTotalPrice() + evaluation.getTotalPrice() * 0.2); - //周边相似小区 - if (null == model.getRadius()) {// 设置默认值 - model.setRadius(1000); - } - String[] fields = { "city", "region", "name", "estateType2", "id","finishBuildingDate"}; - List allDistricts = districtService.findNearestDistrict(district, model.getRadius(), fields, Integer.MAX_VALUE); - //按条件过滤相似小区 - Integer buildYear = null; - List districts = new ArrayList(); - if(StringUtils.isNotBlank(district.getFinishBuildingDate())){ - buildYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate()); - if(buildYear!=null){ - districts = new ArrayList(); - int startYear = buildYear -7; - int endYear = buildYear + 7; - for(District dist : allDistricts){ - if(StringUtils.isNotBlank(dist.getFinishBuildingDate())){ - int simlarDistYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate()); - if(simlarDistYear>=startYear && simlarDistYear<=endYear && StringUtils.isNotBlank(district.getEstateType2()) && StringUtils.isNotBlank(dist.getEstateType2()) && district.getEstateType2().equals(dist.getEstateType2())){ - districts.add(dist); - } - } - } - } - } + //周边相似小区 + if (null == model.getRadius()) {// 设置默认值 + model.setRadius(1000); + } + String[] fields = {"city", "region", "name", "estateType2", "id", "finishBuildingDate"}; + List allDistricts = districtService.findNearestDistrict(district, model.getRadius(), fields, Integer.MAX_VALUE); + //按条件过滤相似小区 + Integer buildYear = null; + List districts = new ArrayList(); + if (StringUtils.isNotBlank(district.getFinishBuildingDate())) { + buildYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate()); + if (buildYear != null) { + districts = new ArrayList(); + int startYear = buildYear - 7; + int endYear = buildYear + 7; + for (District dist : allDistricts) { + if (StringUtils.isNotBlank(dist.getFinishBuildingDate())) { + int simlarDistYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate()); + if (simlarDistYear >= startYear && simlarDistYear <= endYear && StringUtils.isNotBlank(district.getEstateType2()) && StringUtils.isNotBlank(dist.getEstateType2()) && district.getEstateType2().equals(dist.getEstateType2())) { + districts.add(dist); + } + } + } + } + } - //相似房源 - Double startArea = model.getSize() - model.getSize()*0.1; - Double endArea = model.getSize() + model.getSize()*0.1; - Integer startDate = Integer.parseInt(org.apache.tools.ant.util.DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); - List houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null, - startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc"); - //无评估小区房源用周边相似小区的房源 - if(null == houses || houses.size()==0){ - for (District dist : districts) { - houses = seawaterService.findSeawatersFromEs2("rent", dist.getCity(), dist.getRegion(), dist.getName(), null, null, startDate, null, - startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc"); - if(houses!=null && houses.size()>0){ - break; - } - } - } - districtPriceMap.put("houses", houses); + //相似房源 + Double startArea = model.getSize() - model.getSize() * 0.1; + Double endArea = model.getSize() + model.getSize() * 0.1; + Integer startDate = Integer.parseInt(org.apache.tools.ant.util.DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + List houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null, + startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5, null, "seawater-20*/_doc"); + //无评估小区房源用周边相似小区的房源 + if (null == houses || houses.size() == 0) { + for (District dist : districts) { + houses = seawaterService.findSeawatersFromEs2("rent", dist.getCity(), dist.getRegion(), dist.getName(), null, null, startDate, null, + startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5, null, "seawater-20*/_doc"); + if (houses != null && houses.size() > 0) { + break; + } + } + } + districtPriceMap.put("houses", houses); - //周边相似小区租金 - Integer room = null; - if(model.getRoom()!=null && model.getRoom()>0){ - room = model.getRoom(); - }else{ - room = houseService.getDistrictRoomType((float)model.getSize()); - } - if (null != districts) { - if (null != room) { - List dtos = new ArrayList(); - Date weekend = DateUtil.getFirstDayOfWeek(new Date()); - for (District dist : districts) { + //周边相似小区租金 + Integer room = null; + if (model.getRoom() != null && model.getRoom() > 0) { + room = model.getRoom(); + } else { + room = houseService.getDistrictRoomType((float) model.getSize()); + } + if (null != districts) { + if (null != room) { + List dtos = new ArrayList(); + Date weekend = DateUtil.getFirstDayOfWeek(new Date()); + for (District dist : districts) { - List districtRoomSqmetreRents = districtRoomSqmetreRentService.findDistrictRoomSqmetreRents(dist, 1, room); + List districtRoomSqmetreRents = districtRoomSqmetreRentService.findDistrictRoomSqmetreRents(dist, 1, room); - ///List districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room); - if (null != districtRoomSqmetreRents && districtRoomSqmetreRents.size() > 0) { - DistrictRoomSqmetreRent districtRoomSqmetreRent = districtRoomSqmetreRents.get(0); - if (districtRoomSqmetreRent.getAvgPrice() > 0) { + ///List districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room); + if (null != districtRoomSqmetreRents && districtRoomSqmetreRents.size() > 0) { + DistrictRoomSqmetreRent districtRoomSqmetreRent = districtRoomSqmetreRents.get(0); + if (districtRoomSqmetreRent.getAvgPrice() > 0) { - int startSqPrice = (int)(evaluation.getAvgPrice() - evaluation.getAvgPrice()*0.1); - int endSqPrice = (int)(evaluation.getAvgPrice() + evaluation.getAvgPrice()*0.1); + int startSqPrice = (int) (evaluation.getAvgPrice() - evaluation.getAvgPrice() * 0.1); + int endSqPrice = (int) (evaluation.getAvgPrice() + evaluation.getAvgPrice() * 0.1); // SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district"); - if(districtRoomSqmetreRent.getAvgPrice()>=startSqPrice && districtRoomSqmetreRent.getAvgPrice()<=endSqPrice){ - DistrictHouseDtao dto = new DistrictHouseDtao(); - dto.setCity(dist.getCity()); - dto.setRegion(dist.getRegion()); - dto.setDistrictName(dist.getName()); - dto.setSqAvgPrice(districtRoomSqmetreRent.getAvgPrice()); - dto.setRoom(room); - dtos.add(dto); - if(dtos.size()>=5){ - break; - } - } - } - } - } - districtPriceMap.put("districts", dtos); - } - } - - - //近一年户型租金走势 - // Map trendsMap = districtRoomSqmetreRentService.getRentTrends(district.getCity(), district.getRegion(), district.getName(), room, -12); - Map trendsMap = districtStatRentService.getRentTrend(district.getCity(), district.getRegion(), district.getDistrictName(), -12); - if (MapUtils.isNotEmpty(trendsMap)) { - Map distMap = (Map) trendsMap.get("distMap"); - Map trendMap = (Map) distMap.get(String.valueOf(trendsMap.get("room"))); - if (MapUtils.isNotEmpty(trendMap)) { - for (String key : trendMap.keySet()) { - Double totalPrice = (trendMap.get(key) * evaluation.getArea()); - trendMap.put(key, totalPrice.intValue()); - } - } - } - districtPriceMap.put("trends", trendsMap); - - - //成交的租房房源 - List rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5); - districtPriceMap.put("trades", rentTrades); - - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); - return mav; - } - } - - - public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { - - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - - Evaluation evaluation = buildEvaluation(model, request); - evaluation.setSource("api_property_evaluate_rent"); - evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); - - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("address", district.getAddress()); - districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("cal_date", model.getCalDate()); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); - return mav; - } - } - - public Object searchHouseLoudongAction(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - if (StringUtils.isBlank(model.getId()) || StringUtils.isBlank(model.getHouseNumber()) || StringUtils.isBlank(model.getRoomNumber())){ - mav.setModel(BasicModel.buildBadRequestModel("参数非法:楼盘编号,楼栋号,室为必填项")); - return mav; - } - - List houseLoudongs = houseLoudongService.findAll(model.getId(), model.getHouseNumber(), model.getUnitNumber(), model.getRoomNumber()); - mav.setModel(BasicModel.buildOKModel().setResult(houseLoudongs)); - return mav; - } - - - public Object searchLoudongAction(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - if (StringUtils.isBlank(model.getId()) || StringUtils.isBlank(model.getHouseNumber())){ - mav.setModel(BasicModel.buildBadRequestModel("参数非法:楼盘编号,楼栋号为必填项")); - return mav; - } - - - List loudongs = loudongService.findAll(model.getId(), model.getHouseNumber(), model.getUnitNumber()); - mav.setModel(BasicModel.buildOKModel().setResult(loudongs)); - return mav; - } - - - public void setHouseLoudongService(HouseLoudongService houseLoudongService) { - this.houseLoudongService = houseLoudongService; - } - - public void setFieldFilterService(FieldFilterService fieldFilterService) { - this.fieldFilterService = fieldFilterService; - } - - public void setApiUserService(ApiUserService apiUserService) { - this.apiUserService = apiUserService; - } - - public void setEvaluationService(EvaluationService evaluationService) { - this.evaluationService = evaluationService; - } - - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; - } - - public void setNoHouseDistrictService(NoHouseDistrictService noHouseDistrictService) { - this.noHouseDistrictService = noHouseDistrictService; - } - - public void setUserService(UserService userService) { - this.userService = userService; - } - - public void setHouseService(HouseService houseService) { - this.houseService = houseService; - } - - public void setAddressService(AddressService addressService) { - } - - public void setDistrictStatService(DistrictStatService districtStatService) { - this.districtStatService = districtStatService; - } - - public void setDealPriceService(DealPriceService dealPriceService) { - this.dealPriceService = dealPriceService; - } + if (districtRoomSqmetreRent.getAvgPrice() >= startSqPrice && districtRoomSqmetreRent.getAvgPrice() <= endSqPrice) { + DistrictHouseDtao dto = new DistrictHouseDtao(); + dto.setCity(dist.getCity()); + dto.setRegion(dist.getRegion()); + dto.setDistrictName(dist.getName()); + dto.setSqAvgPrice(districtRoomSqmetreRent.getAvgPrice()); + dto.setRoom(room); + dtos.add(dto); + if (dtos.size() >= 5) { + break; + } + } + } + } + } + districtPriceMap.put("districts", dtos); + } + } + + + //近一年户型租金走势 + // Map trendsMap = districtRoomSqmetreRentService.getRentTrends(district.getCity(), district.getRegion(), district.getName(), room, -12); + Map trendsMap = districtStatRentService.getRentTrend(district.getCity(), district.getRegion(), district.getDistrictName(), -12); + if (MapUtils.isNotEmpty(trendsMap)) { + Map distMap = (Map) trendsMap.get("distMap"); + Map trendMap = (Map) distMap.get(String.valueOf(trendsMap.get("room"))); + if (MapUtils.isNotEmpty(trendMap)) { + for (String key : trendMap.keySet()) { + Double totalPrice = (trendMap.get(key) * evaluation.getArea()); + trendMap.put(key, totalPrice.intValue()); + } + } + } + districtPriceMap.put("trends", trendsMap); + + + //成交的租房房源 + List rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5); + districtPriceMap.put("trades", rentTrades); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); + return mav; + } + } + + + public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"}); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + + Evaluation evaluation = buildEvaluation(model, request); + evaluation.setSource("api_property_evaluate_rent"); + evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); + + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("address", district.getAddress()); + districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); + districtPriceMap.put("cal_date", model.getCalDate()); + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); + return mav; + } + } + + public Object searchHouseLoudongAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + if (StringUtils.isBlank(model.getId()) || StringUtils.isBlank(model.getHouseNumber()) || StringUtils.isBlank(model.getRoomNumber())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:楼盘编号,楼栋号,室为必填项")); + return mav; + } + + List houseLoudongs = houseLoudongService.findAll(model.getId(), model.getHouseNumber(), model.getUnitNumber(), model.getRoomNumber()); + mav.setModel(BasicModel.buildOKModel().setResult(houseLoudongs)); + return mav; + } + + + public Object searchLoudongAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + if (StringUtils.isBlank(model.getId()) || StringUtils.isBlank(model.getHouseNumber())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:楼盘编号,楼栋号为必填项")); + return mav; + } + + + List loudongs = loudongService.findAll(model.getId(), model.getHouseNumber(), model.getUnitNumber()); + mav.setModel(BasicModel.buildOKModel().setResult(loudongs)); + return mav; + } + + + public void setHouseLoudongService(HouseLoudongService houseLoudongService) { + this.houseLoudongService = houseLoudongService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setEvaluationService(EvaluationService evaluationService) { + this.evaluationService = evaluationService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setNoHouseDistrictService(NoHouseDistrictService noHouseDistrictService) { + this.noHouseDistrictService = noHouseDistrictService; + } + + public void setUserService(UserService userService) { + this.userService = userService; + } + + public void setHouseService(HouseService houseService) { + this.houseService = houseService; + } + + public void setAddressService(AddressService addressService) { + } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDealPriceService(DealPriceService dealPriceService) { + this.dealPriceService = dealPriceService; + } - protected AddressMatchLogService addressMatchLogService; + protected AddressMatchLogService addressMatchLogService; - public AddressMatchLogService getAddressMatchLogService() { - return addressMatchLogService; - } + public AddressMatchLogService getAddressMatchLogService() { + return addressMatchLogService; + } - public void setAddressMatchLogService(AddressMatchLogService addressMatchLogService) { - this.addressMatchLogService = addressMatchLogService; - } + public void setAddressMatchLogService(AddressMatchLogService addressMatchLogService) { + this.addressMatchLogService = addressMatchLogService; + } - public OpenLogService getOpenLogService() { - return openLogService; - } + public OpenLogService getOpenLogService() { + return openLogService; + } - public void setOpenLogService(OpenLogService openLogService) { - this.openLogService = openLogService; - } + public void setOpenLogService(OpenLogService openLogService) { + this.openLogService = openLogService; + } - public void setAutoCompleteService(AutoCompleteService autoCompleteService) { - this.autoCompleteService = autoCompleteService; - } + public void setAutoCompleteService(AutoCompleteService autoCompleteService) { + this.autoCompleteService = autoCompleteService; + } - public void setDistrictStatRentService(DistrictStatRentService districtStatRentService) { - this.districtStatRentService = districtStatRentService; - } + public void setDistrictStatRentService(DistrictStatRentService districtStatRentService) { + this.districtStatRentService = districtStatRentService; + } - public BatchEvaluateService getBatchEvaluateService() { - return batchEvaluateService; - } + public BatchEvaluateService getBatchEvaluateService() { + return batchEvaluateService; + } - public void setBatchEvaluateService(BatchEvaluateService batchEvaluateService) { - this.batchEvaluateService = batchEvaluateService; - } + public void setBatchEvaluateService(BatchEvaluateService batchEvaluateService) { + this.batchEvaluateService = batchEvaluateService; + } - public void setDistrictAttentionRankService(DistrictAttentionRankService districtAttentionRankService) { - this.districtAttentionRankService = districtAttentionRankService; - } + public void setDistrictAttentionRankService(DistrictAttentionRankService districtAttentionRankService) { + this.districtAttentionRankService = districtAttentionRankService; + } - public void setDistrictHotService(DistrictHotService districtHotService) { - this.districtHotService = districtHotService; - } + public void setDistrictHotService(DistrictHotService districtHotService) { + this.districtHotService = districtHotService; + } - public void setCityHotService(CityHotService cityHotService) { - this.cityHotService = cityHotService; - } + public void setCityHotService(CityHotService cityHotService) { + this.cityHotService = cityHotService; + } - public void setBizShopService(BizShopService bizShopService) { - this.bizShopService = bizShopService; - } + public void setBizShopService(BizShopService bizShopService) { + this.bizShopService = bizShopService; + } - public void setBusStationService(BusStationService busStationService) { - this.busStationService = busStationService; - } + public void setBusStationService(BusStationService busStationService) { + this.busStationService = busStationService; + } - public void setBaiduApiService(BaiduApiService baiduApiService) { - this.baiduApiService = baiduApiService; - } + public void setBaiduApiService(BaiduApiService baiduApiService) { + this.baiduApiService = baiduApiService; + } - public void setDistrictHouseResourceStatService(DistrictHouseResourceStatService districtHouseResourceStatService) { - this.districtHouseResourceStatService = districtHouseResourceStatService; - } + public void setDistrictHouseResourceStatService(DistrictHouseResourceStatService districtHouseResourceStatService) { + this.districtHouseResourceStatService = districtHouseResourceStatService; + } - public void setDistrictSellStatService(DistrictSellStatService districtSellStatService) { - this.districtSellStatService = districtSellStatService; - } + public void setDistrictSellStatService(DistrictSellStatService districtSellStatService) { + this.districtSellStatService = districtSellStatService; + } - public void setDistrictAnalyDataService(DistrictAnalyDataService districtAnalyDataService) { - this.districtAnalyDataService = districtAnalyDataService; - } + public void setDistrictAnalyDataService(DistrictAnalyDataService districtAnalyDataService) { + this.districtAnalyDataService = districtAnalyDataService; + } - public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { - this.addressMatchProxyService = addressMatchProxyService; - } + public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { + this.addressMatchProxyService = addressMatchProxyService; + } - public void setLoudongService(LoudongService loudongService) { - this.loudongService = loudongService; - } + public void setLoudongService(LoudongService loudongService) { + this.loudongService = loudongService; + } - public void setAddressParserService(AddressParserService addressParserService) { - this.addressParserService = addressParserService; - } + public void setAddressParserService(AddressParserService addressParserService) { + this.addressParserService = addressParserService; + } - public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) { - this.apiUserAuthorityService = apiUserAuthorityService; - } + public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) { + this.apiUserAuthorityService = apiUserAuthorityService; + } - public void setAverageStatisticsService(AverageStatisticsService averageStatisticsService) { - this.averageStatisticsService = averageStatisticsService; - } + public void setAverageStatisticsService(AverageStatisticsService averageStatisticsService) { + this.averageStatisticsService = averageStatisticsService; + } - public void setNetworkPriceService(NetworkPriceService networkPriceService) { - this.networkPriceService = networkPriceService; - } + public void setNetworkPriceService(NetworkPriceService networkPriceService) { + this.networkPriceService = networkPriceService; + } - public void setAverageAnalyService(AverageAnalyService averageAnalyService) { - this.averageAnalyService = averageAnalyService; - } + public void setAverageAnalyService(AverageAnalyService averageAnalyService) { + this.averageAnalyService = averageAnalyService; + } - public void setServerAreaService(ServerAreaService serverAreaService) { - this.serverAreaService = serverAreaService; - } + public void setServerAreaService(ServerAreaService serverAreaService) { + this.serverAreaService = serverAreaService; + } - public void setHouseAuctionService(HouseAuctionService houseAuctionService) { - this.houseAuctionService = houseAuctionService; - } + public void setHouseAuctionService(HouseAuctionService houseAuctionService) { + this.houseAuctionService = houseAuctionService; + } - public void setFjtEvaluationService(FjtEvaluationService fjtEvaluationService) { - this.fjtEvaluationService = fjtEvaluationService; - } + public void setFjtEvaluationService(FjtEvaluationService fjtEvaluationService) { + this.fjtEvaluationService = fjtEvaluationService; + } - public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) { - this.apiUserCfgService = apiUserCfgService; - } + public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) { + this.apiUserCfgService = apiUserCfgService; + } - public void setOpenApiLogService(OpenApiLogService openApiLogService) { - this.openApiLogService = openApiLogService; - } + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } - public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { - this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; - } + public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { + this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; + } - public void setSeawaterDao(SeawaterDao seawaterDao) { - this.seawaterDao = seawaterDao; - } + public void setSeawaterDao(SeawaterDao seawaterDao) { + this.seawaterDao = seawaterDao; + } - public void setRegionAnaDataService(RegionAnaDataService regionAnaDataService) { - this.regionAnaDataService = regionAnaDataService; - } + public void setRegionAnaDataService(RegionAnaDataService regionAnaDataService) { + this.regionAnaDataService = regionAnaDataService; + } - public void setSeawaterService(SeawaterService seawaterService) { - this.seawaterService = seawaterService; - } + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } - public void setSqmetreRentService(SqmetreRentService sqmetreRentService) { - this.sqmetreRentService = sqmetreRentService; - } + public void setSqmetreRentService(SqmetreRentService sqmetreRentService) { + this.sqmetreRentService = sqmetreRentService; + } - public void setDistrictRoomSqmetreRentService(DistrictRoomSqmetreRentService districtRoomSqmetreRentService) { - this.districtRoomSqmetreRentService = districtRoomSqmetreRentService; - } + public void setDistrictRoomSqmetreRentService(DistrictRoomSqmetreRentService districtRoomSqmetreRentService) { + this.districtRoomSqmetreRentService = districtRoomSqmetreRentService; + } - public void setRentDealPriceService(RentDealPriceService rentDealPriceService) { - this.rentDealPriceService = rentDealPriceService; - } + public void setRentDealPriceService(RentDealPriceService rentDealPriceService) { + this.rentDealPriceService = rentDealPriceService; + } - public void setEvaluateRatioService(EvaluateRatioService evaluateRatioService) { - this.evaluateRatioService = evaluateRatioService; - } + public void setEvaluateRatioService(EvaluateRatioService evaluateRatioService) { + this.evaluateRatioService = evaluateRatioService; + } - public void setCommunityPoiService(CommunityPoiService communityPoiService) { - this.communityPoiService = communityPoiService; - } + public void setCommunityPoiService(CommunityPoiService communityPoiService) { + this.communityPoiService = communityPoiService; + } - public void setEvaluateFactorService(EvaluateFactorService evaluateFactorService) { - this.evaluateFactorService = evaluateFactorService; - } + public void setEvaluateFactorService(EvaluateFactorService evaluateFactorService) { + this.evaluateFactorService = evaluateFactorService; + } - public void setCommunityBasePriceService(CommunityBasePriceService communityBasePriceService) { - this.communityBasePriceService = communityBasePriceService; - } + public void setCommunityBasePriceService(CommunityBasePriceService communityBasePriceService) { + this.communityBasePriceService = communityBasePriceService; + } - public void setAliasFangService(AliasFangService aliasFangService) { - this.aliasFangService = aliasFangService; - } + public void setAliasFangService(AliasFangService aliasFangService) { + this.aliasFangService = aliasFangService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/RentController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/RentController.java index d745b80dc..0c5f5004f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/RentController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/RentController.java @@ -203,7 +203,7 @@ public class RentController { private Double getSqmetreRent(District district){ SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), null, "district"); if(null != sqmetreRent){ - return Double.valueOf(sqmetreRent.getAvgPrice()); + return Double.valueOf(sqmetreRent.getAvgPrice().intValue()); } return null; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/AvgPriceQueryModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/AvgPriceQueryModel.java index 8095e9091..ef8e44a85 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/AvgPriceQueryModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/AvgPriceQueryModel.java @@ -27,6 +27,15 @@ public class AvgPriceQueryModel { Integer periodCount; String periodType; Integer houseType; + String cat; + + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } public Integer getPeriodCount() { return periodCount; diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java index 817db88d3..ac396fe4b 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java @@ -1038,7 +1038,7 @@ public class EvaluationServiceImpl implements EvaluationService { SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), DateUtil.formatToYYYYMMDD(weekend), "district"); if(sqmetreRent!=null){ - long totalPrice = evaluationRateService.evaluationRent(sqmetreRent.getAvgPrice(), evaluation); + long totalPrice = evaluationRateService.evaluationRent(sqmetreRent.getAvgPrice().intValue(), evaluation); evaluation.setTotalPrice(((Number) (totalPrice)).intValue()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/HouseReportServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/HouseReportServiceImpl.java index 03adaa106..36c8859d4 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/HouseReportServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/HouseReportServiceImpl.java @@ -194,7 +194,7 @@ public class HouseReportServiceImpl implements HouseReportService{ SqmetreRent citySqmetreRent = sqmetreRentService.findNearestSqmetreRent(city, null, null, "city"); RegionStat cityRegionStat = regionStatService.findByCity(city); if(null != citySqmetreRent && null != cityRegionStat){ - Double rate = DataUtil.getDoubleRound(2, citySqmetreRent.getAvgPrice()*12*100/cityRegionStat.getAvgPrice()); + Double rate = DataUtil.getDoubleRound(2, citySqmetreRent.getAvgPrice().intValue()*12*100/cityRegionStat.getAvgPrice()); return rate; } return null; @@ -205,7 +205,7 @@ public class HouseReportServiceImpl implements HouseReportService{ SqmetreRent regionSqmetreRent = sqmetreRentService.findNearestSqmetreRent(city, region, null, "region"); RegionStat regionStat = regionStatService.findRegionStat(city, region); if(null != regionSqmetreRent && null != regionStat){ - Double rate = DataUtil.getDoubleRound(2, regionSqmetreRent.getAvgPrice()*12*100/regionStat.getAvgPrice()); + Double rate = DataUtil.getDoubleRound(2, regionSqmetreRent.getAvgPrice().intValue()*12*100/regionStat.getAvgPrice()); return rate; } return null; @@ -224,7 +224,7 @@ public class HouseReportServiceImpl implements HouseReportService{ distAvgPrice = statBo.getVillaDistrictStat().getAvgPrice(); } if(distAvgPrice > 0){ - Double rate = DataUtil.getDoubleRound(2, distSqmetreRent.getAvgPrice()*12*100/distAvgPrice); + Double rate = DataUtil.getDoubleRound(2, distSqmetreRent.getAvgPrice().intValue()*12*100/distAvgPrice); return rate; } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/SqmetreRentServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/SqmetreRentServiceImpl.java index 56630bc77..0a681b403 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/SqmetreRentServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/SqmetreRentServiceImpl.java @@ -126,6 +126,13 @@ public class SqmetreRentServiceImpl implements SqmetreRentService{ if(StringUtils.isNotBlank(cat)){ params.add(new QueryParam("cat", cat)); } + if(null != startDate){ + params.add(new QueryParam("weekend",QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + + if(null != endDate){ + params.add(new QueryParam("weekend",QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } List sortParams = new ArrayList(); sortParams.add(new SortParam("weekend", true)); From 44131c3e94d2665160dbe1c686181e7916911bc5 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 15 Aug 2024 17:56:57 +0800 Subject: [PATCH 30/45] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B9=B3=E7=B1=B3?= =?UTF-8?q?=E7=A7=9F=E9=87=91=20=E5=9F=8E=E5=B8=82=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E5=85=A8=E7=AE=80=E7=A7=B0=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 10e92ff24..ae8b64282 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -2507,7 +2507,7 @@ public class PropertyController { } Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -model.getPeriodCount()); - List sqmetreRents = sqmetreRentService.findSqmetreRents(model.getCity(), model.getDistrict(), model.getName(), model.getCat(), startDate, null); + List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(),model.getDistrict()), model.getName(), model.getCat(), startDate, null); List> result = new ArrayList>(model.getPeriodCount()); for (SqmetreRent sqmetreRent : sqmetreRents) { From e9adefff80fc0d996417782d0303ec04bc0667f6 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 16 Aug 2024 10:17:58 +0800 Subject: [PATCH 31/45] update --- .../script/commData/CommonDatautils.groovy | 1 + .../gj/data_handle/BaiduBaikeTown.groovy | 102 ++++++++++++++++++ .../script/gj/data_handle/DevProcess.groovy | 83 +++++++------- .../gj/data_handle/DevUpdateTestBatch.groovy | 25 ++--- .../gj/data_handle/GXDdistrictMatch.groovy | 4 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 14 +-- 6 files changed, 167 insertions(+), 62 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BaiduBaikeTown.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index d36b853dc..b9b6bd4bf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -1212,6 +1212,7 @@ class CommonDatautils { public static def findAllCount(String cat){ DBObject q = new BasicDBObject(); q.put("cat", cat); + q.put("status", 0) return SEAWEED_MONGO_COLL.count(q) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BaiduBaikeTown.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BaiduBaikeTown.groovy new file mode 100644 index 000000000..77356d988 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BaiduBaikeTown.groovy @@ -0,0 +1,102 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.crawl.JQueryUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.google.gson.JsonObject +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.sf.json.JSONObject +import org.jsoup.Jsoup + +class BaiduBaikeTown { + + DBCollection dzb_COLL = MongoUtils.getCollectionByName("crawl", "development_zone_bdbk", "192.168.0.206",27020) + + + static main(args) { + def task = new BaiduBaikeTown() + task.run() + } + + def run(){ + ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\百度百科下辖街道解析.xlsx",{row-> + if(!row['E'] && row['A']=="郑州经济技术开发区"){ + def q = new BasicDBObject() + q.put("desc",new BasicDBObject('$ne', 'null')) + q.put("name",row['A']) + def d = dzb_COLL.findOne(q) + def townMap = parse(d.desc, d.name) + row['D'] = townMap.town_str1 + row['F'] = townMap.town_str2 + +// def ret = [] +// ret << ["名称", "基本信息", "目录", "全文"] +// for(def d : dbcursor){ +// def townMap = parse(d.desc, d.name) +// if(townMap.town){ +// println d.name+" "+townMap.town +// } +// ret << [d.name, townMap.town, townMap.towns, townMap.town_str1, townMap.town_str2] +// } + } + + }) + +// ExcelUtils.write("D:\\数据\\数据建设\\开发区\\百度百科下辖街道解析.xlsx", ret, "数据") + } + + def parse(desc, name){ + def map = [:] + if(desc){ + def doc = Jsoup.parse(desc) + def town = JQueryUtils.selectText(".basicInfoBlock_Ex6IU div:contains(下辖地区) dd", doc) + + def s = doc.toString() + def dataStr = DataHandleUtils.findMatchPattern(s,"PAGE_DATA=.*").replace("PAGE_DATA= ","").replace("","") + def jsonObj = JSONObject.fromObject(dataStr) + + def str = DataHandleUtils.findMatchPattern(doc.text(),"下辖.*[街道|镇]、?和?") + def towns = [] + if(jsonObj && jsonObj.catalog){ + def catalogs = jsonObj.catalog + def index = null + for(def log : catalogs){ + def curIndex = log.index + if(log.title=="行政区划"){ + index = log.index + } + if(index && curIndex.toString().startsWith(index+"-")){ + towns << log.title + } + } + } + + + + map.town_str1 = str + if(town){ + map.town = town + }else{ + map.town = "" + } + + if(towns){ + map.towns = towns.join(",") + }else{ + map.towns = "" + } + + + def str2 = DataHandleUtils.findMatchPattern(doc.text(),"开发区辖.*[,|。]") + map.town_str2 = str2 + return map + } + map.town_str1 = "" + map.town_str2 = "" + map.town = "" + map.towns = "" + return map + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 772bbaf62..69a4318b0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -37,7 +37,7 @@ class DevProcess { def task = new DevProcess(); // task.run() // task.parseCityAndDist() - task.devSplitRoad() +// task.devSplitRoad() // task.devNameSplitRoad() // task.addFlag() // task.matchDev() @@ -69,7 +69,7 @@ class DevProcess { // task.addKfc() // task.devToPark() //开发区下辖园区 -// task.checkTown() + task.checkTown() } @@ -898,66 +898,67 @@ class DevProcess { } def devToPark(){ - def datas = ExcelUtils.read("D:\\数据\\数据建设\\开发区\\开发区下辖街道-处理后表格.xlsx",0, 1) + def datas = ExcelUtils.read("D:\\数据\\数据建设\\开发区\\百度百科下辖街道解析.xlsx",0, 1) def rets = [] rets << ["开发区名称", "下辖街道", "城市", "区域"] for(def d : datas){ if(d['E']){ - def arrs = d['E'].split(",") - def q = new BasicDBObject().append("name", d['B']) + def arrs = d['E'].split("、") + def q = new BasicDBObject().append("name", d['A']) def obj = development_zone_CONN.findOne(q) if(obj){ for(def park : arrs){ - rets << [d['B'], park, obj.city, obj.district] + rets << [d['A'], park, obj.city, obj.district] } } } } - ExcelUtils.write("D:\\数据\\数据建设\\开发区\\开发区下辖园区.xlsx", rets, "下辖街道") + ExcelUtils.write("D:\\数据\\数据建设\\开发区\\百度百科开发区下辖街道.xlsx", rets, "下辖街道") } def checkTown(){ - ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\前瞻网开发区对应园区.xlsx",{d-> + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\百度百科开发区下辖街道.xlsx",{d-> if(!d['E']){ if(d['A']){ -// if(d['A']=="长春高新技术产业开发区"){ - def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['A']) - if(jsonObject1) { - if (jsonObject1.get("townCode") && jsonObject1.get("townCode")!='null' && jsonObject1.get("townCode")!='') { - def township = jsonObject1.get("township") - def district = jsonObject1.get("district") - d['E'] = "接口" - if(district && district!='null'){ - d['F'] = district - } - if(township && township!='null'){ - d['G'] = township - } - - d['H'] = jsonObject1.get("townCode") - if(jsonObject1.get("provinceCode") && jsonObject1.get("provinceCode")!='null'){ - d['I'] = jsonObject1.get("provinceCode") - } - } -// } - } - -// def q = new BasicDBObject() -// q.put("city", d['C']) -//// q.put("district", d['D']) -// q.put("mzb_district_name", d['D']) -// q.put("type", "乡镇街道") -// q.put("street", d['B']) -// def obj = ADMINISTRATIVE_MAPPING_COLL.findOne(q) -// if(obj){ -// d['E'] = "可入库2" -// d['F'] = obj.district +// def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['C'], d['D']+d['B']) +// if(jsonObject1) { +// if (jsonObject1.get("townCode") && jsonObject1.get("townCode")!='null' && jsonObject1.get("townCode")!='') { +// def township = jsonObject1.get("township") +// def district = jsonObject1.get("district") +// d['E'] = "接口" +// if(district && district!='null'){ +// d['F'] = district +// } +// if(township && township!='null'){ +// d['G'] = township +// } +// +// d['H'] = jsonObject1.get("townCode") +// if(jsonObject1.get("provinceCode") && jsonObject1.get("provinceCode")!='null'){ +// d['I'] = jsonObject1.get("provinceCode") +// } +// } // } + + def q = new BasicDBObject() + q.put("city", d['C']) +// q.put("district", d['D']) +// q.put("mzb_district_name", d['D']) + q.put("type", "乡镇街道") + q.put('street',new BasicDBObject('$regex', Pattern.compile(d['B'].toString().trim()+'.*$', Pattern.CASE_INSENSITIVE))) +// q.put("street", d['B']) +// q.put('alias', new BasicDBObject('$in',[d['B']])) + def obj = ADMINISTRATIVE_MAPPING_COLL.findOne(q) + if(obj){ + d['E'] = "可入库-忽略区域模糊2" + d['F'] = obj.district + d['G'] = obj.street + } } } - },1) + },0) } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy index 405fdbde8..8af68c5fa 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy @@ -29,7 +29,7 @@ class DevUpdateTestBatch { static main(args) { def task = new DevUpdateTestBatch() - def path = "D:\\数据\\数据建设\\开发区\\文心一言获取开发区下辖园区及街道.xlsx"//开发区-园区.xlsx + def path = "D:\\数据\\数据建设\\开发区\\开发区下辖园区及街道\\前瞻网开发区下辖园区入库.xlsx"//开发区-园区.xlsx // task.addDev(path) task.addDevAddress(path) @@ -137,26 +137,27 @@ class DevUpdateTestBatch { DEV_MAPPING_100_CONN.save(o) - o.id = o._id.toString() - o.remove("_id") - o.remove("c_date") - addEs(o, "192.168.0.89", "dev_mapping") - try{ - addEs(o, "192.168.0.52", "dev_mapping") - }catch(Exception e){ - println "52 es error: "+e.printStackTrace() - } +// o.id = o._id.toString() +// o.remove("_id") +// o.remove("c_date") +// addEs(o, "192.168.0.89", "dev_mapping") +// try{ +// addEs(o, "192.168.0.52", "dev_mapping") +// }catch(Exception e){ +// println "52 es error: "+e.printStackTrace() +// } d['D'] = "已完成" }else{ - d['D'] = "存在" + d['D'] = "重复" println d['A'] +" "+ d['C']+" 重复" } }else{ + d['D'] = "不存在" println d['A'] +" 不存在" } } - },2) + },0) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy index f814cceb2..61ed0ea7b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy @@ -40,11 +40,11 @@ class GXDdistrictMatch { def addOldMatch(){ //老匹配 - def fileName = "D:\\数据\\建行\\房产估值\\20240616-20240715系统业务反馈.xlsx"//11城重新匹配.xlsx + def fileName = "D:\\数据\\建行\\房产估值\\20240716-20240815 _业务反馈价格.xlsx"//11城重新匹配.xlsx ExcelUtils.multiThreadingModify(fileName, { d -> println d['C'] if(!d['AJ'] && d['I']){ - def jsonObject = OpenApiClient.addressMatch(d['C'], d['I'], "district", false,null, d['D']) + def jsonObject = OpenApiClient.addressMatch(d['C'], d['D'], "district", false,null, d['D']) if (jsonObject != null && !jsonObject.containsKey("result")) { d['AJ'] = jsonObject.get("id") d['AK'] = jsonObject.get("city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy index 2dd8a91a7..14b6a5c26 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy @@ -33,11 +33,11 @@ class AddPriceTest { task.run(); } def run(){ - def filePath = "D:\\数据\\建行\\房产估值\\20240616-20240715系统业务反馈.xlsx" + def filePath = "D:\\数据\\建行\\房产估值\\20240716-20240815 _业务反馈价格.xlsx" // addGXDPrice(filePath) -// addCcbPrice(filePath) + addCcbPrice(filePath) // addThirdPrice(filePath) - addFjwPrice(filePath) +// addFjwPrice(filePath) // exportPkPrice() // addRegion() // addTradePrice(filePath) @@ -169,9 +169,9 @@ class AddPriceTest { def addCcbPrice(filepath){ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() ExcelUtils.multiThreadingModify(filepath,{ d-> - if(d['AJ']){ - def cityId = cityCodeDataMap.get(d['AK']) - def map = findAvgPrice(d['AJ'], cityId) + if(d['U']){ + def cityId = cityCodeDataMap.get(d['V']) + def map = findAvgPrice(d['U'], cityId) if(map){ d['F'] = map.avg_price // d['P'] = map.calc_type @@ -183,7 +183,7 @@ class AddPriceTest { def findAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202406 order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202407 order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc From df68744bcf579ccfca0acb4547203f64c833eedb Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 16 Aug 2024 14:14:55 +0800 Subject: [PATCH 32/45] =?UTF-8?q?5432-=E3=80=8B5433?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/fjwPriceBaseData/FjwBigdataCommbuildtypeBatch.groovy | 2 +- .../script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy | 2 +- .../script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy | 2 +- .../script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy | 2 +- .../script/gj/fjwPriceBaseData/FjwGuiDingPriceBatch.groovy | 2 +- .../fangjia/script/gj/fjwPriceBaseData/FjwPgsqlCommUtils.groovy | 2 +- .../script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommbuildtypeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommbuildtypeBatch.groovy index 16e99a043..f649b98ff 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommbuildtypeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommbuildtypeBatch.groovy @@ -25,7 +25,7 @@ class FjwBigdataCommbuildtypeBatch extends BaseBatch{ public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(40) //235为房价网内部计算均价的库 - def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy index 0291a1e8c..e01c76779 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataCommunityBatch.groovy @@ -33,7 +33,7 @@ class FjwBigdataCommunityBatch extends BaseBatch{ public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) //235为房价网内部计算均价的库 - def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy index 3234ddbbd..936382db2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy @@ -40,7 +40,7 @@ class FjwBigdataDealBatch extends BaseBatch{ static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") - def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy index afcedfa60..5f43810f6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy @@ -67,7 +67,7 @@ class FjwBigdataForsaleBatch extends BaseBatch{ // def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", // "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") - def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwGuiDingPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwGuiDingPriceBatch.groovy index d7246795a..dae99b102 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwGuiDingPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwGuiDingPriceBatch.groovy @@ -34,7 +34,7 @@ class FjwGuiDingPriceBatch extends BaseBatch{ def curDate= DateUtils.formatDateByPattern(new Date(), "yyyy-MM")+"-15"; - def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwPgsqlCommUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwPgsqlCommUtils.groovy index f8a140633..eed97969b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwPgsqlCommUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwPgsqlCommUtils.groovy @@ -13,7 +13,7 @@ class FjwPgsqlCommUtils { public static def database = "fangjia" - public static def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/"+database+"?stringtype=unspecified", + public static def sqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/"+database+"?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") public static def findAllDistrictIdsByOracle(def cityid){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index daa08b17c..52d65e101 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -36,7 +36,7 @@ class FjwThirdPartyPriceBatch extends BaseBatch { "房多多":"13","我爱我家":"14","禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20"] - def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5432/fangjia?stringtype=unspecified", + def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") static main(args) { From 6faa15235d4c137fd9d504d3513322e7c1799617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 19 Aug 2024 13:22:37 +0800 Subject: [PATCH 33/45] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 392a896a4..28f780026 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -467,11 +467,15 @@ public class AddrSvcController { } else { map.put("addrVerify", "地址有效"); map.put("typeName", areaMap.get(map.get("typeCode"))); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); basicModel.setResult(map); } } else { map.put("addrVerify", "地址有效"); map.put("typeName", areaMap.get(map.get("typeCode"))); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); basicModel.setResult(map); } @@ -498,6 +502,45 @@ public class AddrSvcController { } return mav; } + + /** + * 判断县级市 + */ + public String countyLevelCity(Map map) { + if (map.get("city") == null) { + return ""; + } + if (map.get("city").endsWith("区")) { + return "否"; + } + if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市") ) { + return "否"; + } + return "是"; + } + + /** + * 判断所属区域 + * + * @param map + * @return + */ + public String addrArea(Map map, String type) { + if (map.get("verifyFlag") == null ) { + return ""; + } + if (map.get("verifyFlag").equals("非农")) { + return "城市区域"; + } + if (map.get("verifyFlag").equals("农")) { + return "农村区域"; + } + if ("2".equals(type) && "是".equals(map.get("countyGov"))) { + return "县城城区"; + } + return ""; + } + /** * 涉农识别-新规则-上海征信 * @@ -565,11 +608,15 @@ public class AddrSvcController { basicModel.setResult(result); } else { map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); map.put("typeName", areaMap.get(map.get("typeCode"))); basicModel.setResult(map); } } else { map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); map.put("typeName", areaMap.get(map.get("typeCode"))); basicModel.setResult(map); } @@ -703,11 +750,15 @@ public class AddrSvcController { basicModel.setResult(result); } else { map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); map.put("typeName", areaMap.get(map.get("typeCode"))); basicModel.setResult(map); } } else { map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); map.put("typeName", areaMap.get(map.get("typeCode"))); basicModel.setResult(map); } From 8d819cef951c280f93afdf6af2c6d9e408695da6 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 19 Aug 2024 13:27:27 +0800 Subject: [PATCH 34/45] =?UTF-8?q?=E5=86=85=E9=83=A8=E6=88=BF=E6=BA=90?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=BF=AE=E6=94=B9=E5=8F=8A=E7=99=BE=E5=BA=A6?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/DevProcess.groovy | 38 +++++-- .../gj/data_handle/DevUpdateTestBatch.groovy | 4 +- .../FjwBigdataForsaleBatch.groovy | 6 +- .../script/gj/village/QiliangTest.groovy | 2 +- .../gj/xiamen/GaoDePoiDataProcess.groovy | 100 ++++++++++-------- 5 files changed, 92 insertions(+), 58 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 69a4318b0..9b4d34ff1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -25,9 +25,11 @@ class DevProcess { def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; DBCollection development_zone_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL) - DBCollection DEV_MAPPING_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + DBCollection DEV_MAPPING_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + DBCollection DEV_MAPPING_CONN2 = MongoUtils.getCollectionByName2("fangjia", "dev_mapping_2", MONGO100_URL) + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") @@ -54,7 +56,7 @@ class DevProcess { // task.createDevMapping() // task.deleteAddr() // task.deleteAddr2() -// task.synchDevTo43() +// task.synchDevTo100() // task.addNewDev2() // task.addAlias() @@ -69,7 +71,9 @@ class DevProcess { // task.addKfc() // task.devToPark() //开发区下辖园区 - task.checkTown() +// task.checkTown() + +// task.repeatSave() } @@ -692,13 +696,13 @@ class DevProcess { }); } - def synchDevTo43(){ - def dbcursor = development_zone_CONN.find() + def synchDevTo100(){ + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find() def rets = [] for(def r : dbcursor){ rets << r } - DEVELOPMENT_ZONE_43_COLL.insert(rets) + development_zone_CONN.insert(rets) } @@ -961,4 +965,26 @@ class DevProcess { },0) } + + def repeatSave(){ + def dbcursor = DEV_MAPPING_CONN.find(new BasicDBObject()) + def list = [] + for(def map : dbcursor){ + def columns = ["_id","province","city","district","name","type","address","dev_district", "township","park"] + def udata = new BasicDBObject() + map.each{k,v-> + if(columns.contains(k)){ + if(v instanceof String){ + if(k=="_id"){ + udata.put("_id", new ObjectId(v)) + }else{ + udata.put(k, v) + } + } + } + } + list << udata + } + DEV_MAPPING_CONN2.insert(list) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy index 8af68c5fa..052f2d046 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy @@ -29,7 +29,7 @@ class DevUpdateTestBatch { static main(args) { def task = new DevUpdateTestBatch() - def path = "D:\\数据\\数据建设\\开发区\\开发区下辖园区及街道\\前瞻网开发区下辖园区入库.xlsx"//开发区-园区.xlsx + def path = "D:\\数据\\数据建设\\开发区\\开发区-园区.xlsx"//开发区-园区.xlsx // task.addDev(path) task.addDevAddress(path) @@ -157,7 +157,7 @@ class DevUpdateTestBatch { println d['A'] +" 不存在" } } - },0) + },1) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy index 5f43810f6..1cb508851 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataForsaleBatch.groovy @@ -492,9 +492,9 @@ class FjwBigdataForsaleBatch extends BaseBatch{ def findHousesByMdate(def city, def region, def cat, def startDate, def endDate, def name, def alias, def estate_type2, rets1){ - def date = "20200101"//DateUtils.addMonth(endDate.toString(), -3, "yyyyMMdd") - def startMdate = DateUtils.parseFromTightByPattern("20240519","yyyyMMdd")//DateUtils.parseFromTightByPattern(date,"yyyyMMdd") - def endMdate = DateUtils.parseFromTightByPattern("20240718", "yyyyMMdd")//DateUtils.parseFromTightByPattern(endDate.toString(), "yyyyMMdd") + def date = DateUtils.addMonth(endDate.toString(), -3, "yyyyMMdd") + def startMdate = DateUtils.parseFromTightByPattern(date,"yyyyMMdd")//DateUtils.parseFromTightByPattern("20240519","yyyyMMdd") + def endMdate = DateUtils.parseFromTightByPattern(endDate.toString(), "yyyyMMdd")//DateUtils.parseFromTightByPattern("20240718", "yyyyMMdd") QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(date.toInteger()).to(endDate).includeLower(false).includeUpper(false); QueryBuilder area_range = QueryBuilders.rangeQuery("area").from(20).to(500).includeLower(true).includeUpper(false); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy index b6fea9896..c2f11e6f8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/QiliangTest.groovy @@ -27,7 +27,7 @@ class QiliangTest { // task.run() def data = [ - 'address': '江阴市澄杨路77号', + 'address': '景县开发区东区', 'type': '1' //1:对公 0:对私 ] def s = task.getProxyResult(data); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy index 024a20faf..a4ff32dad 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy @@ -15,6 +15,8 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils +import com.google.common.hash.BloomFilter +import com.google.common.hash.Funnels import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl @@ -29,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders +import java.nio.charset.StandardCharsets import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService @@ -123,51 +126,54 @@ class GaoDePoiDataProcess extends BaseBatch{ } def sysnchVillage(){ - def buducitys = [ '七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市', - '东营市', '中卫市', '中山市', '临夏回族自治州', '临汾市', '临沂市', '临沧市', '临高县', '丹东市', - '丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市', - '云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市', - '佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州', - '克拉玛依市', '六安市', '六盘水市', '兰州市', '兴安盟', '内江市', '包头市', '北京市', '北海市', - '十堰市', '南京市', '南充市', '南宁市', '南平市', '南昌市', '南通市', '南阳市', - '博尔塔拉蒙古自治州', '厦门市', '双鸭山市', '台州市', '合肥市', '吉安市', '吉林市', '吐鲁番地区', - '吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市', - '哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市', - '固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市', - '天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市', - '安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市', - '宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市', - '巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市', - '广州市', '庆阳市', '廊坊市', '延安市', '延边朝鲜族自治州', '开封市', '张家口市', '张家界市', - '张掖市', '徐州市', '德州市', '德阳市', '忻州市', '怀化市', '恩施土家族苗族自治州', '惠州市', - '成都市', '扬州市', '承德市', '抚州市', '抚顺市', '拉萨市', '揭阳市', '攀枝花市', '文昌市', - '新乡市', '新余市', '无锡市', '日喀则地区', '日照市', '昆明市', '昌吉回族自治州', '昌江黎族自治县', - '昌都地区', '昭通市', '晋中市', '晋城市', '普洱市', '景德镇市', '曲靖市', '朔州市', '朝阳市', - '本溪市', '来宾市', '杭州市', '松原市', '林芝地区', '枣庄市', '柳州市', '株洲市', '桂林市', - '梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市', - '汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市', - '泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市', - '淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市', - '湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市', - '潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市', - '珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县', - '白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市', - '神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市', - '肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市', - '菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市', - '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市', - '辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', - '邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市', - '重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市', - '锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市', - '阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市', - '陵水黎族自治县', '随州市', '雅安市', '青岛市', '鞍山市', '韶关市', '马鞍山市', '驻马店市', - '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', - '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] +// def buducitys = [ '七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市', +// '东营市', '中卫市', '中山市', '临夏回族自治州', '临汾市', '临沂市', '临沧市', '临高县', '丹东市', +// '丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市', +// '云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市', +// '佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州', +// '克拉玛依市', '六安市', '六盘水市', '兰州市', '兴安盟', '内江市', '包头市', '北京市', '北海市', +// '十堰市', '南京市', '南充市', '南宁市', '南平市', '南昌市', '南通市', '南阳市', +// '博尔塔拉蒙古自治州', '厦门市', '双鸭山市', '台州市', '合肥市', '吉安市', '吉林市', '吐鲁番地区', +// '吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市', +// '哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市', +// '固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市', +// '天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市', +// '安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市', +// '宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市', +// '巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市', +// '广州市', '庆阳市', '廊坊市', '延安市', '延边朝鲜族自治州', '开封市', '张家口市', '张家界市', +// '张掖市', '徐州市', '德州市', '德阳市', '忻州市', '怀化市', '恩施土家族苗族自治州', '惠州市', +// '成都市', '扬州市', '承德市', '抚州市', '抚顺市', '拉萨市', '揭阳市', '攀枝花市', '文昌市', +// '新乡市', '新余市', '无锡市', '日喀则地区', '日照市', '昆明市', '昌吉回族自治州', '昌江黎族自治县', +// '昌都地区', '昭通市', '晋中市', '晋城市', '普洱市', '景德镇市', '曲靖市', '朔州市', '朝阳市', +// '本溪市', '来宾市', '杭州市', '松原市', '林芝地区', '枣庄市', '柳州市', '株洲市', '桂林市', +// '梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市', +// '汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市', +// '泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市', +// '淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市', +// '湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市', +// '潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市', +// '珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县', +// '白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市', +// '神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市', +// '肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市', +// '菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市', +// '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市', +// '辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', +// '邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市', +// '重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市', +// '锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市', +// '阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市', +// '陵水黎族自治县', '随州市', '雅安市', '青岛市', '鞍山市', '韶关市', '马鞍山市', '驻马店市', +// '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', +// '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] + + def buducitys = ["丽水市","杭州市","宁波市","温州市","嘉兴市","台州市","湖州市","绍兴市","金华市","舟山市","衢州市"] for(def city : buducitys){ def pois = findAllVillagePoiMap(city) def rows = createVillageData(city, pois) + save(city, rows) // saveToMG(city, rows) println city +" "+pois.size()+" add:"+rows.size() @@ -182,7 +188,7 @@ class GaoDePoiDataProcess extends BaseBatch{ final CountDownLatch latch = new CountDownLatch(pois.size()) // def townMap = findTownRange(city) def townMap = CommonDatautils.queryTownByCity(city) - def poiKeys = findEsPoiByCity(city) + def poiKeysFilter = findEsPoiByCity(city) for(def i=0;i filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001); ElasticUtils89.executeQuery("192.168.0.89", "didata_map_poi_single", queryBuilder, { String id, Map d-> - rets << d.city +"##"+d.district+"##"+d.name +// rets << d.city +"##"+d.district+"##"+d.name + filter.put(d.city +"##"+d.district+"##"+d.name) }) - return rets + return filter } def queryMapPoi(city){ From a7bb5f2890643f8c0f750531619cab17308dfbd6 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 19 Aug 2024 18:48:25 +0800 Subject: [PATCH 35/45] =?UTF-8?q?=E6=B9=96=E5=B7=9E=E6=94=BE=E5=89=8D?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/MinglujiData.groovy | 221 ++++++++++++++++++ .../gj/xiamen/GaoDePoiDataProcess.groovy | 10 +- 2 files changed, 227 insertions(+), 4 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy new file mode 100644 index 000000000..e68ef59b1 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy @@ -0,0 +1,221 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +import java.util.regex.Pattern + +/** + * 名录集 + */ +class MinglujiData { + + DBCollection mlj_COLL = MongoUtils.getCollectionByName("crawl", "kfq_mingluji_com", "192.168.0.206",27020) + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection development_zone_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL) + + DBCollection dev_mapping_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + DBCollection community_100_CONN = MongoUtils.getCollectionByName2("fangjia", "community", MONGO100_URL) + + static main(args) { + def task = new MinglujiData() + task.run() + } + + def run(){ +// exportDatas("湖州") +// matchDev("浙江省","湖州") + matchCommunity("湖州") + } + def exportDatas(city){ + def datas = findMinglujiDatas(city) + ExcelUtils.write("D:\\数据\\数据建设\\名录集\\${city}.xlsx", datas, "数据") + } + def matchDev(prov, city){ + def devs = loadAllDevs(prov) + ExcelUtils.modify("D:\\数据\\数据建设\\名录集\\${city}.xlsx",{d-> + if(d['E'] && !d['N'] ){ + def obj = findDevByName(d['E']) + if(!obj){ + obj = findDevByAlias(d['E']) + if(!obj){ + obj = findDebBySimlar(devs, d['E'], d['B']) + if(!obj){ + obj = findDevByPark(d['A'], d['B'], d['E']) + if (!obj) { + }else{ + d['N'] = "园区" + } + }else{ + d['N'] = "相似" + } + }else{ + d['N'] = "别名" + } + }else{ + d['N'] = "相同" + } + if(obj){ + d['M'] = obj.name + d['O'] = obj.city + d['P'] = obj.district + } + } + }) + } + + def matchCommunity(city){ + ExcelUtils.modify("D:\\数据\\数据建设\\名录集\\${city}.xlsx",{d-> + if(d['A'] && d['B'] && d['L'] && !d['Q'] && d['L']=="东村委会"){ + def list = findCommunityByName(d['A'], d['B'], d['L']) + if(!list){ + list = findCommunityBySimlar(d['A'], d['B'], d['L']) + if(!list){ + + }else{ + d['T'] = "包含" + } + }else{ + d['T'] = "相同" + } + if(list){ + if(list.size()==1){ + def obj = list[0] + d['Q'] = obj.name + d['R'] = obj.street_name + }else if(list.size()>=2){ + for(def l : list){ + if(d['C']==l.area_name){ + d['Q'] = l.name + d['R'] = l.street_name + break; + } + } + d['S'] = list.size() + } + } + } + }) + } + + def loadAllDevs(prov){ + def q = new BasicDBObject() + q.put("province", prov) + return development_zone_CONN.find(q).toList() + } + + def findDebBySimlar(def devs, def name, def city){ + name = name.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园") + def last = null + for(def d : devs){ + def alias = null + if(!d.alias){ + alias = [] + }else{ + alias = d.alias + } + alias << d.name + for(def n : alias){ + n = n.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园") + if(d.city && d.city.contains(city) && (n.contains(name) || name.contains(n))){ + last = d + break + } + } + if(last){ + break + } + } + return last + } + def findDevByName(name){ + def q = new BasicDBObject() + q.put("name", name) + return development_zone_CONN.findOne(q) + } + + def findDevByAlias(name){ + def q = new BasicDBObject() + q.put('alias', new BasicDBObject('$in',[name])) + return development_zone_CONN.findOne(q) + } + + def findDevBySimlar(name){ + def q = new BasicDBObject() + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 + return development_zone_CONN.findOne(q) + } + + def findDevByPark(prov, city, name){ + def q = new BasicDBObject() + q.put('province',new BasicDBObject('$regex', Pattern.compile('^.*'+prov+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 + q.put('city',new BasicDBObject('$regex', Pattern.compile('^.*'+city+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 + q.put('park',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 + q.put("type", "园区") + return dev_mapping_CONN.findOne(q) + } + + def findCommunityByName(province, city, name){ + def q = new BasicDBObject() + q.put("province_name", province+"省") + q.put("city_name", city+"市") + q.put("name", name) + def dbcursor = community_100_CONN.find(q) + def list = [] + for(def d : dbcursor){ + list << d + } + return list + } + + def findCommunityBySimlar(province, city, name){ + def q = new BasicDBObject() + q.put("province_name", province+"省") + q.put("city_name", city+"市") + q.put("name", new BasicDBObject('$regex', Pattern.compile(name+'.*$', Pattern.CASE_INSENSITIVE))) + def dbcursor = community_100_CONN.find(q) + def list = [] + for(def d : dbcursor){ + list << d + } + return list + } + + def findMinglujiDatas(city){ + def keys = new BasicDBObject() + keys.put("c_address",1) + keys.put("c_city",1) + keys.put("c_committee",1) + keys.put("c_community",1) + keys.put("c_company",1) + keys.put("c_district",1) + keys.put("c_street",1) + keys.put("kind",1) + keys.put("name",1) + keys.put("province",1) + def datas = mlj_COLL.find(new BasicDBObject("c_city", city), keys) + def rets = [] + rets << ["省","城市","区域","街道","开发区名","类型","公司名","社区","居委","地址","拆分街道","拆分居委","匹配开发区名"] + for(def d : datas){ + def street = d.c_street + def splitStreet = "" + if(street){ + if(street.contains(d.c_district)){ + def start = street.toString().lastIndexOf(d.c_district)+d.c_district.size() + def end = street.toString().size() + splitStreet = street.toString().substring(start, end) + } + } + def splitCommunity = "" + if(d.c_committee){ + if(d.c_committee.contains(d.c_district)){ + splitCommunity = d.c_committee.substring(d.c_committee.lastIndexOf(d.c_district)+d.c_district.size(), d.c_committee.toString().size()) + } + } + rets << [d.province, d.c_city, d.c_district, d.c_street, d.name, d.kind, d.c_company, d.c_community, d.c_committee, d.c_address, splitStreet, splitCommunity] + } + return rets + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy index a4ff32dad..06ddf6d39 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy @@ -168,7 +168,8 @@ class GaoDePoiDataProcess extends BaseBatch{ // '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', // '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] - def buducitys = ["丽水市","杭州市","宁波市","温州市","嘉兴市","台州市","湖州市","绍兴市","金华市","舟山市","衢州市"] + //"丽水市","杭州市", + def buducitys = ["湖州市","宁波市","温州市","嘉兴市","台州市","绍兴市","金华市","舟山市","衢州市"] for(def city : buducitys){ def pois = findAllVillagePoiMap(city) def rows = createVillageData(city, pois) @@ -189,7 +190,6 @@ class GaoDePoiDataProcess extends BaseBatch{ // def townMap = findTownRange(city) def townMap = CommonDatautils.queryTownByCity(city) def poiKeysFilter = findEsPoiByCity(city) - for(def i=0;i=1){ retMap.type = nameArr[0] @@ -416,6 +415,9 @@ class GaoDePoiDataProcess extends BaseBatch{ } def findAllVillagePoiMap(city){ + def q = new BasicDBObject("city", city); + q.put("std_tag", new BasicDBObject('$exists', true)) + def keys = new BasicDBObject() keys.put("city", 1) keys.put("district", 1) @@ -424,7 +426,7 @@ class GaoDePoiDataProcess extends BaseBatch{ keys.put("gcj02_x", 1) keys.put("gcj02_y", 1) keys.put("std_tag", 1) - def list = BAIDU_POI_COLL.find(new BasicDBObject("city", city), keys).toList() + def list = BAIDU_POI_COLL.find(q, keys).toList() return list; } From 657d058394f97aa54bbdae827d08724dd0cbe04f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 20 Aug 2024 16:47:41 +0800 Subject: [PATCH 36/45] =?UTF-8?q?=E5=8A=A0=E6=88=BF=E4=BA=A7=E8=B6=85?= =?UTF-8?q?=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccbevaluation/AddThirdPriceSample.groovy | 40 +++++++++ .../fangjia/script/ccbevaluation/Test.groovy | 84 +++++++++++++------ .../ccbevaluation/ThirdPartyPriceBatch.groovy | 9 ++ .../script/gj/data_handle/MinglujiData.groovy | 35 +++++--- 4 files changed, 129 insertions(+), 39 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy new file mode 100644 index 000000000..d1ec16934 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy @@ -0,0 +1,40 @@ +package com.fangjia.script.ccbevaluation + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +/** + * 将国信达及成交对标数据加入到第三方均价表,做为均价参考 + */ +class AddThirdPriceSample { + + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + + static main(args) { + def task = new AddThirdPriceSample() + task.run() + } + def run(){ + for(def i=1;i<19;i++){ + ExcelUtils.multiThreadingModify("D:\\数据\\建行\\房产估值\\级联待优化小区集合_7月.xlsx",{d-> + if(d['A'] && d['C']){ + def dist = CommonDatautils.findDistrictById(d['A'].toString().trim()) + if(dist){ + def q = new BasicDBObject("city", dist.city).append("region", dist.region).append("name", dist.name).append("s_date", 202407) + def udata = new BasicDBObject("zhongyuan_esf_price", d['C'].toString().toDouble().toInteger()) + + AVERAGE_STATISTICS.update(q,new BasicDBObject('$set', udata),false, false) + }else{ + println d['A'] +" 没查到" + } + } + }, i) + + println(i) + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy index 13a46482e..0d36523e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy @@ -612,9 +612,9 @@ def findAllData(sqlInstance236, citycode){ ////},0) // -//ExcelUtils.multiThreadingModify("D:\\数据\\建行\\二期\\252个城市删除小区.xlsx",{d-> +//ExcelUtils.multiThreadingModify("D:\\数据\\建行\\房产估值\\删除小区.xlsx",{d-> // if(d['A']){ -// def dbo = CommonDatautils.findDistrictById(d['D']) +// def dbo = CommonDatautils.findDistrictById(d['A']) // if(dbo){ // def udata = new BasicDBObject() //// udata.put("name_cat", 11) @@ -630,6 +630,38 @@ def findAllData(sqlInstance236, citycode){ // } //},0) + +ExcelUtils.modify("D:\\数据\\建行\\房产估值\\添加别名.xlsx",{d-> + if(d['A'] && d['B']){ + def dbo = CommonDatautils.findDistrictById(d['A']) + if(dbo){ + def alias = null + if(!dbo.alias){ + alias = [] + }else{ + alias = dbo.alias + } + if(!alias.contains(d['B'])){ + alias << d['B'] + } + if(alias){ + def udata = new BasicDBObject() + udata.put("alias", alias) + udata.put("m_date",new Date()) + + def q = new BasicDBObject() + q.put("_id", dbo._id) + DbUtils.seaweed.update(q, new BasicDBObject('$set', udata)) + }else{ + println d['A']+" "+"别名已存在" + } + + }else{ + println dbo._id.toString() +" 没找到" + } + } +}) + //def citys = ["海口","三亚","三沙","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中"] //for(def c : citys){ // def districts = CommonDatautils.findAllDistrictByCity(c, "district", ["city","name"]) @@ -1299,34 +1331,34 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){ -def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240806--国信达价格录入.xlsx" - -ExcelUtils.multiThreadingModify(fileName, {d-> - if(d['J']){ -// def region = RegionData.formatRegion(d['A'], d['J']) -// if(region){ -// def dist = CommonDatautils.findDistrict(d['A'], region, d['K'], "district") +//def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240806--国信达价格录入.xlsx" +// +//ExcelUtils.multiThreadingModify(fileName, {d-> +// if(d['J']){ +//// def region = RegionData.formatRegion(d['A'], d['J']) +//// if(region){ +//// def dist = CommonDatautils.findDistrict(d['A'], region, d['K'], "district") +//// if(dist){ +//// d['B'] = dist.region +//// d['C'] = dist.name +//// d['L'] = dist.status-dist.name_cat +//// } +//// } +//// if(d['J'] instanceof String){ +// def dist = CommonDatautils.findDistrictById(d['J']) // if(dist){ +// d['A'] = dist.city // d['B'] = dist.region // d['C'] = dist.name -// d['L'] = dist.status-dist.name_cat +// d['K'] = dist.estate_type2 +// d['L'] = dist.status +// d['M'] = dist.name_cat +// +//// d['H'] = dist.name // } -// } -// if(d['J'] instanceof String){ - def dist = CommonDatautils.findDistrictById(d['J']) - if(dist){ - d['A'] = dist.city - d['B'] = dist.region - d['C'] = dist.name - d['K'] = dist.estate_type2 - d['L'] = dist.status - d['M'] = dist.name_cat - -// d['H'] = dist.name - } -// } - } -},0) +//// } +// } +//},0) //def file = "D:\\数据\\建行\\房产估值\\指导价\\5城价格翻新6-21.xlsx" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy index 52fd3ddb2..5f5a53f33 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy @@ -257,6 +257,9 @@ class ThirdPartyPriceBatch extends BaseBatch { if(third.get("5i5j_esf_price")){ price_map.wiwj_avg_price = third.get("5i5j_esf_price") } + if(third.get("fccs_esf_price")){ + price_map.fccs_avg_price = third.get("fccs_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -303,6 +306,8 @@ class ThirdPartyPriceBatch extends BaseBatch { web = "房多多" }else if(k=="wiwj_avg_price"){ web = "我爱我家" + }else if(k=="fccs_avg_price"){ + web = "房产超市" } ret << sourceMap.get(web) @@ -584,6 +589,10 @@ class ThirdPartyPriceBatch extends BaseBatch { if(!dataMap.get("5i5j_esf_price") && db.get("5i5j_esf_price") && db.get("5i5j_esf_price")>3000){ dataMap.put("5i5j_esf_price", db.get("5i5j_esf_price")) } + + if(!dataMap.get("fccs_esf_price") && db.get("fccs_esf_price") && db.get("fccs_esf_price")>3000){ + dataMap.put("fccs_esf_price", db.get("fccs_esf_price")) + } // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy index e68ef59b1..0ae018d53 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy @@ -35,7 +35,7 @@ class MinglujiData { } def matchDev(prov, city){ def devs = loadAllDevs(prov) - ExcelUtils.modify("D:\\数据\\数据建设\\名录集\\${city}.xlsx",{d-> + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\名录集\\${city}.xlsx",{d-> if(d['E'] && !d['N'] ){ def obj = findDevByName(d['E']) if(!obj){ @@ -67,8 +67,8 @@ class MinglujiData { } def matchCommunity(city){ - ExcelUtils.modify("D:\\数据\\数据建设\\名录集\\${city}.xlsx",{d-> - if(d['A'] && d['B'] && d['L'] && !d['Q'] && d['L']=="东村委会"){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\名录集\\${city}-5.xlsx",{d-> + if(d['A'] && d['B'] && d['L'] && !d['Q']){ def list = findCommunityByName(d['A'], d['B'], d['L']) if(!list){ list = findCommunityBySimlar(d['A'], d['B'], d['L']) @@ -97,7 +97,7 @@ class MinglujiData { } } } - }) + }, 0) } def loadAllDevs(prov){ @@ -110,19 +110,28 @@ class MinglujiData { name = name.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园") def last = null for(def d : devs){ - def alias = null + def alias1 = null if(!d.alias){ - alias = [] + alias1 = [] }else{ - alias = d.alias + alias1 = d.alias } - alias << d.name - for(def n : alias){ - n = n.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园") - if(d.city && d.city.contains(city) && (n.contains(name) || name.contains(n))){ - last = d - break + if(!alias1.contains(d.name)){ + alias1 << d.name + } + if(alias1){ + try { + for(def n : alias1){ + n = n.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园") + if(d.city && d.city.contains(city) && (n.contains(name) || name.contains(n))){ + last = d + break + } + } + }catch(exception){ + println alias1 } + } if(last){ break From 30444f6d8458e8f60510a96ea0cdf3b43c9435ce Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 20 Aug 2024 18:03:30 +0800 Subject: [PATCH 37/45] =?UTF-8?q?=E6=88=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/ccbevaluation/BigdataDealBatch.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy index db19c3e41..8a924e652 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy @@ -70,12 +70,12 @@ class BigdataDealBatch extends BaseBatch{ //664b73800000000000000000 5-21 def citys = CcbCommonUtils.getRunningCitys(args) -// println "curDate:"+curDate -// def allCitys = CommonDatautils.findAllCity() -// for(def city : allCitys){ -// addDealPriceMatch(city); -// } -// updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 + println "curDate:"+curDate + def allCitys = CommonDatautils.findAllCity() + for(def city : allCitys){ + addDealPriceMatch(city); + } + updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 def rows = [] From 2b34b9d610eab1d60700f3ef02929e9af032eb60 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 20 Aug 2024 18:16:23 +0800 Subject: [PATCH 38/45] update --- .../com/fangjia/script/gj/data_handle/DevProcess.groovy | 2 +- .../com/fangjia/script/gj/data_handle/MinglujiData.groovy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 9b4d34ff1..411c7e92e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -39,7 +39,7 @@ class DevProcess { def task = new DevProcess(); // task.run() // task.parseCityAndDist() -// task.devSplitRoad() + task.devSplitRoad() // task.devNameSplitRoad() // task.addFlag() // task.matchDev() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy index 0ae018d53..327e48a2e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy @@ -67,7 +67,7 @@ class MinglujiData { } def matchCommunity(city){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\名录集\\${city}-5.xlsx",{d-> + ExcelUtils.modify("D:\\数据\\数据建设\\名录集\\${city}-没配居委1.xlsx",{d-> if(d['A'] && d['B'] && d['L'] && !d['Q']){ def list = findCommunityByName(d['A'], d['B'], d['L']) if(!list){ @@ -183,7 +183,7 @@ class MinglujiData { def q = new BasicDBObject() q.put("province_name", province+"省") q.put("city_name", city+"市") - q.put("name", new BasicDBObject('$regex', Pattern.compile(name+'.*$', Pattern.CASE_INSENSITIVE))) + q.put("name", new BasicDBObject('$regex', Pattern.compile('^'+name+'.*$', Pattern.CASE_INSENSITIVE))) def dbcursor = community_100_CONN.find(q) def list = [] for(def d : dbcursor){ From f1325affa7e139c1ffc14640fca4867d60214bbe Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 21 Aug 2024 09:55:30 +0800 Subject: [PATCH 39/45] =?UTF-8?q?=E5=85=A8=E5=9B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/xiamen/GaoDePoiDataProcess.groovy | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy index 06ddf6d39..b8d657c89 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/GaoDePoiDataProcess.groovy @@ -126,51 +126,54 @@ class GaoDePoiDataProcess extends BaseBatch{ } def sysnchVillage(){ -// def buducitys = [ '七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市', -// '东营市', '中卫市', '中山市', '临夏回族自治州', '临汾市', '临沂市', '临沧市', '临高县', '丹东市', -// '丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市', -// '云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市', -// '佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州', -// '克拉玛依市', '六安市', '六盘水市', '兰州市', '兴安盟', '内江市', '包头市', '北京市', '北海市', -// '十堰市', '南京市', '南充市', '南宁市', '南平市', '南昌市', '南通市', '南阳市', -// '博尔塔拉蒙古自治州', '厦门市', '双鸭山市', '台州市', '合肥市', '吉安市', '吉林市', '吐鲁番地区', -// '吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市', -// '哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市', -// '固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市', -// '天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市', -// '安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市', -// '宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市', -// '巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市', -// '广州市', '庆阳市', '廊坊市', '延安市', '延边朝鲜族自治州', '开封市', '张家口市', '张家界市', -// '张掖市', '徐州市', '德州市', '德阳市', '忻州市', '怀化市', '恩施土家族苗族自治州', '惠州市', -// '成都市', '扬州市', '承德市', '抚州市', '抚顺市', '拉萨市', '揭阳市', '攀枝花市', '文昌市', -// '新乡市', '新余市', '无锡市', '日喀则地区', '日照市', '昆明市', '昌吉回族自治州', '昌江黎族自治县', -// '昌都地区', '昭通市', '晋中市', '晋城市', '普洱市', '景德镇市', '曲靖市', '朔州市', '朝阳市', -// '本溪市', '来宾市', '杭州市', '松原市', '林芝地区', '枣庄市', '柳州市', '株洲市', '桂林市', -// '梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市', -// '汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市', -// '泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市', -// '淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市', -// '湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市', -// '潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市', -// '珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县', -// '白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市', -// '神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市', -// '肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市', -// '菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市', -// '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市', -// '辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', -// '邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市', -// '重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市', -// '锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市', -// '阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市', -// '陵水黎族自治县', '随州市', '雅安市', '青岛市', '鞍山市', '韶关市', '马鞍山市', '驻马店市', -// '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', -// '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] + def buducitys = [ '七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市', + '东营市', '中卫市', '中山市', '临夏回族自治州', '临汾市', '临沂市', '临沧市', '临高县', '丹东市', + '丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市', + '云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市', + '佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州', + '克拉玛依市', '六安市', '六盘水市', '兰州市', '兴安盟', '内江市', '包头市', '北京市', '北海市', + '十堰市', '南京市', '南充市', '南宁市', '南平市', '南昌市', '南通市', '南阳市', + '博尔塔拉蒙古自治州', '厦门市', '双鸭山市', '台州市', '合肥市', '吉安市', '吉林市', '吐鲁番地区', + '吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市', + '哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市', + '固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市', + '天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市', + '安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市', + '宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市', + '巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市', + '广州市', '庆阳市', '廊坊市', '延安市', '延边朝鲜族自治州', '开封市', '张家口市', '张家界市', + '张掖市', '徐州市', '德州市', '德阳市', '忻州市', '怀化市', '恩施土家族苗族自治州', '惠州市', + '成都市', '扬州市', '承德市', '抚州市', '抚顺市', '拉萨市', '揭阳市', '攀枝花市', '文昌市', + '新乡市', '新余市', '无锡市', '日喀则地区', '日照市', '昆明市', '昌吉回族自治州', '昌江黎族自治县', + '昌都地区', '昭通市', '晋中市', '晋城市', '普洱市', '景德镇市', '曲靖市', '朔州市', '朝阳市', + '本溪市', '来宾市', '杭州市', '松原市', '林芝地区', '枣庄市', '柳州市', '株洲市', '桂林市', + '梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市', + '汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市', + '泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市', + '淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市', + '湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市', + '潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市', + '珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县', + '白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市', + '神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市', + '肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市', + '菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市', + '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市', + '辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', + '邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市', + '重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市', + '锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市', + '阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市', + '陵水黎族自治县', '随州市', '雅安市', '青岛市', '鞍山市', '韶关市', '马鞍山市', '驻马店市', + '鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市', + '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市'] //"丽水市","杭州市", - def buducitys = ["湖州市","宁波市","温州市","嘉兴市","台州市","绍兴市","金华市","舟山市","衢州市"] + def runbuducitys = ["湖州市","宁波市","温州市","嘉兴市","台州市","绍兴市","金华市","舟山市","衢州市"] for(def city : buducitys){ + if(runbuducitys.contains(city)){ + continue + } def pois = findAllVillagePoiMap(city) def rows = createVillageData(city, pois) From bdbac0e02bd90dbe7111f445f566cbf877baf7e6 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 21 Aug 2024 10:05:31 +0800 Subject: [PATCH 40/45] =?UTF-8?q?=E5=86=85=E9=83=A8=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index 52d65e101..baae234f8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -265,6 +265,10 @@ class FjwThirdPartyPriceBatch extends BaseBatch { if(third.get("5i5j_esf_price")){ price_map.wiwj_avg_price = third.get("5i5j_esf_price") } + + if(third.get("fccs_esf_price")){ + price_map.fccs_avg_price = third.get("fccs_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -311,6 +315,8 @@ class FjwThirdPartyPriceBatch extends BaseBatch { web = "房多多" }else if(k=="wiwj_avg_price"){ web = "我爱我家" + }else if(k=="fccs_avg_price"){ + web = "房产超市" } ret << sourceMap.get(web) @@ -459,6 +465,11 @@ class FjwThirdPartyPriceBatch extends BaseBatch { if(!dataMap.get("5i5j_esf_price") && db.get("5i5j_esf_price") && db.get("5i5j_esf_price")>3000){ dataMap.put("5i5j_esf_price", db.get("5i5j_esf_price")) } + + if(!dataMap.get("fccs_esf_price") && db.get("fccs_esf_price") && db.get("fccs_esf_price")>3000){ + dataMap.put("fccs_esf_price", db.get("fccs_esf_price")) + } + // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } From 7ab052c9668df08834f534581386a9f626d77724 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 21 Aug 2024 15:23:36 +0800 Subject: [PATCH 41/45] =?UTF-8?q?=E5=AE=A2=E6=88=B7API=E7=94=A8=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkoff/controllers/ApiUserController.java | 257 +++++++++++++++++- .../src/main/webapp/apiUser/apiVisitStat.ftl | 117 ++++++-- .../src/main/webapp/apiUser/userVisitStat.ftl | 8 + .../com/fangjia/service/open/StatAnalyBo.java | 53 ++++ 4 files changed, 392 insertions(+), 43 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index e93f2e177..ca2a516e3 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -1,11 +1,13 @@ package com.fangjia.bkoff.controllers; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.util.DateUtils; +import com.alibaba.excel.write.metadata.WriteSheet; import com.fangjia.bkoff.model.ApiUserModel; import com.fangjia.bkoff.model.JsonModel; -import com.fangjia.core.util.BeanUtils; -import com.fangjia.core.util.DataUtil; -import com.fangjia.core.util.DateUtil; -import com.fangjia.core.util.StringUtil; +import com.fangjia.core.util.*; +import com.fangjia.dal.QueryParam; import com.fangjia.dal.mongo.fangjia.model.ServerArea; import com.fangjia.dal.mongo.model.ApiInvokeStatistical; import com.fangjia.dal.mongo.model.ApiUserCfg; @@ -27,23 +29,33 @@ import com.fangjia.service.sql.UserService; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DateUtils; import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.bson.types.ObjectId; import org.json.JSONArray; +import org.sothis.core.util.CollectionUtils; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.annotation.Param; +import scala.Int; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; import java.net.URLEncoder; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.*; + /** * api用户开通等管理controller * @@ -61,8 +73,6 @@ public class ApiUserController { private ApiInvokeStatisticalService apiInvokeStatisticalService; private ApiVisitCountService apiVisitCountService; private ApiCountCityService apiCountCityService; - - /** * 所有api用户的信息展示 * @@ -303,14 +313,15 @@ public class ApiUserController { user.put("password", DigestUtils.md5Hex(model.getPassword())); // // // 更改用户密码 - this.userService.updateById(user,userId); + this.userService.updateById(user, userId); // 刷新缓存 this.apiUserService.clearApiUserAuthorityCache(userId); model.setViewType("redirect"); - model.setViewParam("location", "/apiUser/edit?userId="+userId); + model.setViewParam("location", "/apiUser/edit?userId=" + userId); return model; } + public Object editPwdAction(ApiUserModel model) { Long userId = model.getUserId(); User user = this.userService.findById(userId); @@ -975,7 +986,21 @@ public class ApiUserController { } else { cities = new ArrayList(); } - List analys = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate); + // 只查询正式账号 + List queryParams = Arrays.asList(new QueryParam("isTest", 0)); + List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams); + // 获取正式账号的ids + List ids = new ArrayList(); + for (ApiUser apiUser : apiUsers) { + ids.add((int) apiUser.getId()); + } + List analyAll = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate); + List analys = new ArrayList(); + for (OpenUriAnaly analy : analyAll) { + if (ids.contains(analy.getApiUserId())) { + analys.add(analy); + } + } List bos = null; List eachCityBos = null; if (model.getWay() == null) { @@ -1016,9 +1041,7 @@ public class ApiUserController { } } } - List userIds = new ArrayList(); for (StatAnalyBo boTemp : bos) { - userIds.add(Long.valueOf(boTemp.getUserId())); List apiVisitCounts = apiVisitCountService.findAllApiVisitCount(Long.valueOf(boTemp.getUserId()), null, startDate, endDate); int total = 0; for (ApiVisitCount apiVisitCount : apiVisitCounts) { @@ -1027,7 +1050,6 @@ public class ApiUserController { boTemp.setBillingCount(total); } - List apiUsers = apiUserService.findApiUserByIds(userIds); Map idUserMap = new HashMap(); for (ApiUser apiUser : apiUsers) { idUserMap.put(apiUser.getId(), apiUser); @@ -1051,8 +1073,199 @@ public class ApiUserController { return model; } + public Object exportAction(ApiUserModel model, HttpServletResponse response) throws IllegalAccessException { + Date startDate = null; + Date endDate = null; + if (StringUtils.isBlank(model.getBegDate()) && StringUtils.isBlank(model.getEndDate())) { + startDate = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -7); + endDate = DateUtil.parseStringToDate(DateUtil.formatToYYYYMMDD(new Date())); + } else { + if (StringUtils.isNotBlank(model.getBegDate())) { + startDate = DateUtil.parseStringToDate(model.getBegDate()); + } + if (StringUtils.isNotBlank(model.getEndDate())) { + endDate = DateUtil.parseStringToDate(model.getEndDate()); + } - public Object userVisitStatAction(ApiUserModel model) { + } + if (startDate != null) { + model.setBegDate(DateUtil.formatToYYYYMMDD(startDate)); + } + + if (endDate != null) { + model.setEndDate(DateUtil.formatToYYYYMMDD(endDate)); + } + + long diffInMillies = Math.abs(endDate.getTime() - startDate.getTime()); + + // 将毫秒转换为天数 + long days = diffInMillies / (1000 * 60 * 60 * 24); // 使用long来计算天数 + // 只查询正式账号 + List queryParams = Arrays.asList(new QueryParam("isTest", 0)); + List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams); + // 获取正式账号的ids + List ids = new ArrayList(); + for (ApiUser apiUser : apiUsers) { + ids.add((int) apiUser.getId()); + } + // 只获取正式用户的 + List analyAll = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate); + List analys = new ArrayList(); + for (OpenUriAnaly analy : analyAll) { + if (ids.contains(analy.getApiUserId())) { + analys.add(analy); + } + } + List userIds = new ArrayList(); + // 获取有访问记录的用户ID + for (OpenUriAnaly analy : analys) { + if (!userIds.contains(analy.getApiUserId())) { + userIds.add(analy.getApiUserId()); + } + } + List bosAll = new ArrayList(); + if (CollectionUtils.isNotEmpty(userIds)) { + // 根据访问遍历用户 + for (Integer userId : userIds) { + long id = (long) userId; + // 获取每个用户的访问 + List analyUser = openUriAnalyService.findOpenUriAnalyLogs(id, null, startDate, endDate); + ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id); + Map countMap = authority.getTotalCountMap(); + // 获取 deadline + ApiUser apiUser = apiUserService.findApiUserById(id); + // 获取用户名 + User user = userService.findById(id); + List bos = null; + bos = createAnalyBosByLink(analyUser); + long date = DateUtil.parseStringToDate("2016-11-23").getTime(); + if (startDate.getTime() >= date && endDate.getTime() > date) { + List apiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, startDate, endDate); + if (bos != null && apiInvokeStatisticalList.size() > 0) { + Map> resultMap = getCountByUri(apiInvokeStatisticalList); + for (StatAnalyBo boTemp : bos) { + boTemp.setPurpose(apiUser.getPurpose()); + String url = boTemp.getKey(); + boTemp.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount")); + boTemp.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount")); + boTemp.setDefeatTime(resultMap.get(url).get("defeatCount")); + if (apiUser != null) { + boTemp.setDeadline(apiUser.getDeadTime()); + } + long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, url, DateUtil.truncateDay(new Date())); + long historyCount = apiVisitCountService.findApiVisitAllCount(id, url, DateUtil.truncateDay(new Date())); + if (countMap != null && countMap.containsKey(url)) { + Integer totalCount = countMap.get(url); + long usedCount = curVistedCount + historyCount; + boTemp.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount))); + } + if (user != null) { + boTemp.setName(user.getDisplayName()); + boTemp.setUserId((int) user.getId()); + } + + List apiVisitCounts = apiVisitCountService.findAllApiVisitCount(id, boTemp.getKey(), startDate, endDate); + int total = 0; + for (ApiVisitCount apiVisitCount : apiVisitCounts) { + total += apiVisitCount.getVisitCount(); + } + boTemp.setBillingCount(total); + double dailyUse = boTemp.getCount() * 1.0 / days; + boTemp.setDailyUse(dailyUse); + } + } + } + bosAll.addAll(bos); + + } + } + this.buildReport(bosAll, response, startDate, endDate); + model.setViewType("stream"); + return model; + } + + private void buildReport(List bos, HttpServletResponse response, Date startDate, Date endDate) { + try { + List> dataList = new ArrayList>(); + + for (StatAnalyBo bo : bos) { + List row = new ArrayList(); + row.add(bo.getUserId() != null ? bo.getUserId().toString() : ""); + row.add(bo.getName() != null ? bo.getName().toString() : ""); + if (bo.getPurpose() != null) { + Integer purpose = bo.getPurpose(); + if (purpose == 1) { + row.add("API"); + } else if (purpose == 2) { + row.add("PDS"); + } else if (purpose == 4) { + row.add("房生活"); + } + }else { + row.add(""); + } + row.add(bo.getKey() != null ? bo.getKey().toString() : ""); + row.add(bo.getSurplusCallCount() != null ? bo.getSurplusCallCount().toString() : ""); + row.add(bo.getDeadline() != null ? DateUtils.format(bo.getDeadline(), "yyyy/MM/dd") : ""); + row.add(bo.getCount() != null ? bo.getCount().toString() : ""); + if (bo.getDailyUse() !=null){ + // 格式化为保留一位小数的字符串 + String formattedDailyUse = String.format("%.1f", bo.getDailyUse()); + row.add(formattedDailyUse); + }else { + row.add(""); + } + row.add(bo.getPercent() != null ? bo.getPercent().toString() : ""); + row.add(bo.getSuccessEffectiveTime() != null ? bo.getSuccessEffectiveTime().toString() : ""); + row.add(bo.getSuccessInvalidTime() != null ? bo.getSuccessInvalidTime().toString() : ""); + row.add(bo.getDefeatTime() != null ? bo.getDefeatTime().toString() : ""); + row.add(bo.getBillingCount() != null ? bo.getBillingCount().toString() : ""); + dataList.add(row); + } + + String fileName = "用户账号使用统计(" + DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") + ").xlsx"; +// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); + String displayName = URLEncoder.encode(fileName, "UTF-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + displayName + "\""); + response.setContentType("application/x-download;charset=utf-8"); + Workbook workbook = new XSSFWorkbook(); + Sheet sheet = workbook.createSheet("用户账号使用统计"); + List head = Arrays.asList( + "用户ID", "账号", "账号用途", "接口", "剩余使用次数", "合同到期时间", "访问次数", "日均访问量", + "占比(%)", "成功并有效", "成功并无效", "失败次数", "计费次数"); + // 创建表头 + Row headRow = sheet.createRow(0); + for (int i = 0; i < head.size(); i++) { + Cell cell = headRow.createCell(i); + cell.setCellValue(head.get(i)); + } + // 写入数据,从第二行 + for (int i = 0; i < dataList.size(); i++) { + Row row = sheet.createRow(i + 1); + List data = dataList.get(i); + for (int j = 0; j < data.size(); j++) { + Cell cell = row.createCell(j); + cell.setCellValue(data.get(j)); + } + } + ServletOutputStream outputStream = response.getOutputStream(); + workbook.write(outputStream); + } catch (IOException e) { + } + + } + + List> formatHead(String[] headArr) { + List> head = new ArrayList>(); + for (String name : headArr) { + List temp = new ArrayList(); + temp.add(name); + head.add(temp); + } + return head; + } + + public Object userVisitStatAction(ApiUserModel model) throws IllegalAccessException { Date startDate = null; Date endDate = null; if (StringUtils.isNotBlank(model.getBegDate())) { @@ -1075,8 +1288,12 @@ public class ApiUserController { // bos = createAnalyBosByUser(analys); // model.setChartSeries(toChartString(bos)); // }else if(model.getWay() == 2){ + Long userId = model.getUserId(); + ApiUserAuthority authority = apiUserAuthorityService.findByUserId(userId); + Map countMap = authority.getTotalCountMap(); + ApiUser apiUser = apiUserService.findApiUserById(userId); if (model.getWay() == 2) { - User user = userService.findById(model.getUserId()); + User user = userService.findById(userId); if (user != null) { model.setUserName(user.getDisplayName()); } @@ -1120,6 +1337,16 @@ public class ApiUserController { boTemp.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount")); boTemp.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount")); boTemp.setDefeatTime(resultMap.get(url).get("defeatCount")); + if (apiUser != null) { + boTemp.setDeadline(apiUser.getDeadTime()); + } + long curVistedCount = apiVisitCountService.findApiVisitCountByDay(userId, url, DateUtil.truncateDay(new Date())); + long historyCount = apiVisitCountService.findApiVisitAllCount(userId, url, DateUtil.truncateDay(new Date())); + if (countMap != null && countMap.containsKey(url)) { + Integer totalCount = countMap.get(url); + long usedCount = curVistedCount + historyCount; + boTemp.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount))); + } } } } diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl index 893f21d79..4f5ec9781 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl @@ -12,9 +12,9 @@