From d0cd6e575ecb640e872134ccff3f343b84fae138 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Thu, 28 Nov 2024 17:36:46 +0800 Subject: [PATCH 001/247] update --- .../script/ccbevaluation/AddSzDealData.groovy | 5 +- .../data_handle/AddDistrictShapeBatch.groovy | 18 +- .../data_handle/AutoAddDistrictBatch.groovy | 29 +-- .../script/gj/data_handle/DevProcess.groovy | 43 ++++- .../gj/data_handle/DevUpdateTestBatch.groovy | 5 +- .../script/gj/data_handle/NewPoiData.groovy | 175 ++++++++++++++++++ .../gj/data_handle/PoiNineSplitBatch.groovy | 18 +- .../fangjia/script/gj/data_handle/Test.groovy | 131 +++++-------- .../gj/zhongshu/DistrictArrountOffice.groovy | 134 ++++++++++++++ 9 files changed, 428 insertions(+), 130 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/zhongshu/DistrictArrountOffice.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 0bf6ec4b9..4473e1e49 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 @@ -1,15 +1,14 @@ package com.fangjia.script.ccbevaluation -import com.fangjia.script.util.DateUtils + import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection - /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年9月深圳二手房成交.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\2024年10月深圳二手房成交.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/gj/data_handle/AddDistrictShapeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy index 12879d5ed..72d64ea09 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy @@ -30,6 +30,9 @@ class AddDistrictShapeBatch extends BaseBatch{ DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") + + public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) @@ -54,8 +57,8 @@ class AddDistrictShapeBatch extends BaseBatch{ // // } -// checkRangeCount() - synch100() + checkRangeCount() +// synch100() } def baiduMatch(city,districts){ @@ -378,20 +381,21 @@ class AddDistrictShapeBatch extends BaseBatch{ def checkRangeCount(){ - def dbcursor = seaweed_fence_coll.find(new BasicDBObject()).batchSize(100) +// def dbcursor = seaweed_fence_coll.find(new BasicDBObject()).batchSize(100) + def dbcursor = administrative_mapping_coll.find(new BasicDBObject("type","乡镇街道")).batchSize(100) def count = 0 def index =0 for(def d : dbcursor){ index ++ - if(d.location){ - def coordinates = d.location.coordinates + if(d.shape){ + def coordinates = d.shape.coordinates if(coordinates.size()>1){ count++ - println count +" "+ d.city +" "+d.name + println count +" "+ d.city +" "+d.street } }else{ - println d.city + " "+d.name + println d.city + " "+d.street } if(index%1000==0){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy index 5367882e6..809fa216c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy @@ -35,22 +35,22 @@ class AutoAddDistrictBatch extends BaseBatch{ @Override void process(Object args) { - //查找第三方匹配没有匹配上的小区 - def citys = CommonDatautils.findAllCity() - def list = [] - list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "高德地图"] - for(def c : citys){ - def noMatchDatas = findNoMatchResult(c) - println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() - def rets = checkDatas(noMatchDatas.keySet()) - list.addAll(rets) - } +// //查找第三方匹配没有匹配上的小区 +// def citys = CommonDatautils.findAllCity() +// def list = [] +// list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "百度类型","高德地图", "高德类型"] +// for(def c : citys){ +// def noMatchDatas = findNoMatchResult(c) +// println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() +// def rets = checkDatas(noMatchDatas.keySet()) +// list.addAll(rets) +// } def fileName = "/home/goojia/gj/add_dist_info.xlsx" if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\数据建设\\小区\\第三方待入库数据.xlsx" + fileName = "D:\\数据\\add_dist_info_1.xlsx" } - ExcelUtils.write(fileName, list, "待入库数据") +// ExcelUtils.write(fileName, list, "待入库数据") check(fileName) @@ -61,6 +61,11 @@ class AutoAddDistrictBatch extends BaseBatch{ def dists = CommonDatautils.findAllDistrictByName(d[0], d[1], d[2], "district") if(dists){ d['J'] = "库中已存在" + }else{ + dists = CommonDatautils.findDistrictByAlias(d[0], d[1], d[2], "district") + if(dists){ + d['J'] = "库中别名中存在" + } } }) } 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 f722db94c..acf416bff 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 @@ -5,21 +5,15 @@ import com.fangjia.core.util.GeoUtils import com.fangjia.script.commData.CommonDatautils 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 import com.mongodb.BasicDBObject -import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject -import org.apache.poi.ss.util.RegionUtil import org.bson.types.ObjectId -import org.joda.time.Instant -import java.time.format.DateTimeFormatter import java.util.regex.Pattern class DevProcess { @@ -64,6 +58,7 @@ class DevProcess { // task.deleteAddr() // task.deleteAddr2() task.synchDevTo100() +// task.statShape() // task.addNewDev2() // task.addAlias() @@ -87,6 +82,8 @@ class DevProcess { // task.matchDevShape()//匹配开发区围栏 // task.addQiDevResult() //获取齐梁数据结果 + +// task.updateDevShape()//修改开发区结构 } @@ -794,6 +791,18 @@ class DevProcess { development_zone_CONN.insert(rets) } + def statShape(){ + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find(new BasicDBObject("shape", new BasicDBObject('$exists', true))) + def index = 0 + for(def r : dbcursor){ + index ++ + def coordinates = r.shape.coordinates + println index+" "+r.name+" "+coordinates.size() + + + } + } + def matchDevAndAddAddress(){ ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\新跑省份\\福建重庆去重后地址.xlsx",{d-> @@ -1148,4 +1157,26 @@ class DevProcess { } },0) } + + def updateDevShape(){ + def q = new BasicDBObject() + q.put("shape", new BasicDBObject('$exists', true)) + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find(q) + for(def d : dbcursor){ + if(d.name!="福州长乐国际机场综合保税区"){ + def udata = new BasicDBObject() + if(d.shape.coordinates){ + d.shape.coordinates = [d.shape.coordinates] + udata.put("shape", d.shape) + } + if(d.bd_shape && d.bd_shape.coordinates){ + d.bd_shape.coordinates = [d.bd_shape.coordinates] + udata.put("bd_shape", d.bd_shape) + } + def updateQuery = new BasicDBObject("_id",d._id) + DEVELOPMENT_ZONE_43_COLL.update(updateQuery, new BasicDBObject('$set',udata)) + } + + } + } } 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 49d2547b7..aaf80284e 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 @@ -7,7 +7,6 @@ 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 @@ -33,7 +32,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) // @@ -168,7 +167,7 @@ class DevUpdateTestBatch { println d['A'] +" 不存在" } } - },2) + },0) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy new file mode 100644 index 000000000..767209f83 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy @@ -0,0 +1,175 @@ +package com.fangjia.script.gj.data_handle + + +import com.fangjia.core.util.BaiDuApiUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper +import com.mongodb.BasicDBObject + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +class NewPoiData { + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + def task = new NewPoiData() + task.run() + } + def run(){ +// export() +// exportNetWorkOffice() +// matchByCity() +// noMatchData() + calcuteDistance() + } + + def noMatchData(){ + ExcelUtils.multiThreadingModify("d:\\数据\\未匹配写字楼2.xlsx", { d -> + if(d['H']!='地图'){ + def map = CommonDatautils.findOneThirdNetWorkOffice(d['A'], d['B'], d['C']) + if(map){ + d['E'] = map.lng + d['F'] = map.lat + } + } + }) + } + def matchByCity(){ + ExcelUtils.multiThreadingModify("d:\\数据\\入库写字楼.xlsx",{d-> + def jsonObject = FangjiaClientUtils.newMatch(d['A'], d['A']+d['B']+d['C'], "office", false) + def formatAddress = null + if(d['D']){ + formatAddress = AddressUtil.formatAddress(d['A'], d['D']) + d['G'] = formatAddress + } + if(!jsonObject && formatAddress){ + if(DataUtil.isPreciseAddress(formatAddress)){ + def address = d['A'] + if(d['B']){ + address = address + d['B'] + } + address = address + formatAddress + jsonObject = FangjiaClientUtils.newMatch(d['A'], address, "office", false) + } + } + if(jsonObject) { + d['H'] = jsonObject.get("id") + d['I'] = jsonObject.get("city") + d['J'] = jsonObject.get("district") + d['K'] = jsonObject.get("name") + d['L'] = jsonObject.get("propertyType") + d['M'] = jsonObject.get("credit") + } + }) + } + + + def export(){ + def rets = [] + rets << ["城市", "区域", "名称", "地址", "经度", "纬度"] + rets.addAll(CommonDatautils.findNewPoiDatas()) + ExcelUtils.write("d:\\数据\\poi写字楼.xlsx", rets, "写字楼") + } + + def exportNetWorkOffice(){ + def rets = [] + rets << ["城市", "区域", "名称", "地址", "经度", "纬度"] + rets.addAll(CommonDatautils.findThirdNetWorkOffice()) + ExcelUtils.write("d:\\数据\\poi写字楼-网站.xlsx", rets, "写字楼") + } + + def calcuteDistance(){ + ExcelUtils.multiThreadingModify("d:\\数据\\写字楼测试-1118-新增.xlsx", { d -> + if(d['F']){ + if(d['A'].contains("北京")){ + def distance = GeoHelper.GetDistance(d['F'].toString().toDouble(), d['E'].toString().toDouble(), 39.996743, 116.481075) + d['K'] = distance + }else if(d['A'].contains("烟台")){ + def distance = GeoHelper.GetDistance(d['F'].toString().toDouble(), d['E'].toString().toDouble(), 37.459645, 121.438616) + d['K'] = distance + } + } + }, 1) + } + + + + + def addDistrict(){ + def path = "D:\\数据\\入库写字楼.xlsx" + def keys = new CopyOnWriteArrayList() + def index = 0 + ExcelUtils.modify(path, { d-> + def city = d['A'] + def region = d['B'] + def name = d['C'] + + def formatAddress = null + def address = d['D'] + if(address){ + if(d['G']){ + formatAddress = AddressUtil.formatAddress(city, address) + } + if(!formatAddress){ + if(address.contains("交叉口")){ + formatAddress = address.substring(0, address.toString().indexOf("交叉口")+3) + }else if(address.contains("交叉")){ + formatAddress = address.substring(0, address.toString().indexOf("交叉")+2) + } + } + } + + Long glat = null + Long glng = null + Long blat = null + Long blng = null + if(d['K']){ + glat = d['L'].toString().toDouble() * 10000000000L + glng = d['K'].toString().toDouble() * 10000000000L + def baidu = BaiDuApiUtils.geoconv(d['K'].toString().toDouble(), d['L'].toString().toDouble(), 3) + blng = baidu.x * 10000000000L + blat = baidu.y * 10000000000L + } + + def estateType2 = "普通住宅" + def key = city+"##"+region+"##"+name + if(name && !keys.contains(key)){ + def dist = CommonDatautils.findDistrict(city, region, name, "district") + if(!dist){ + keys << key + def data = new BasicDBObject(); + data.put("name_cat",0) + data.put("status",0) + data.put("cat","office") + data.put("c_date", new Date()) + data.put("m_date", new Date()) + data.put("city", city) + data.put("region",region) + data.put("name", name) + data.put("estate_type2",estateType2) + data.put("address", formatAddress) + if(glat){ + data.put("lat",glat) + data.put("lng",glng) + data.put("lat2",blat) + data.put("lng2",blng) + } + def markMap = [:] + markMap.put("data_source", "机器入库") + data.put("mark_map",markMap) + index++ + DbUtils.seaweed.save(data); + println index+" "+data + } + } + },0) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy index c5ea6d76d..21432c057 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy @@ -1,22 +1,20 @@ 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.commData.CommonDatautils import com.fangjia.script.util.ExcelUtils -@BatchOwner(Watcher.GaoJuan) -class PoiNineSplitBatch extends BaseBatch{ +class PoiNineSplitBatch{ static main(args) { - runBatch(new PoiNineSplitBatch(), args) + def task = new PoiNineSplitBatch() + task.run() } - @Override - void process(Object args) { - run() - } +// @Override +// void process(Object args) { +// run() +// } def run(){ def i = 0; while(i<360) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy index 4d77b4cdf..3f08229ce 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy @@ -1,105 +1,58 @@ package com.fangjia.script.gj.data_handle -import com.fangjia.script.ccbevaluation.CcbCommonUtils -import com.fangjia.script.gj.ccb.CcbCodeUtils -import com.google.common.hash.BloomFilter -import com.google.common.hash.Funnels +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.apache.commons.lang.math.RandomUtils -import java.nio.charset.StandardCharsets -import java.util.concurrent.ConcurrentHashMap -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 +def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; +DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) -class Test{ - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(60) -// 最大重试次数 - private static final int MAX_TRY_COUNT = 5; +def city = "昌江" +ExcelUtils.modify("D:\\数据\\海南\\海南省城市均价.xlsx",{d-> + def date = d['B'] + def start = DateUtils.getFirstDayOfMonth(date) + def end = DateUtils.getLastDayOfMonth(date) + def weekends = DateUtils.getWeekendBetweenDates(start, end) + for(def weekend : weekends){ + def avg_price = d['I'] + def val = random(-200,200) + def new_price = (int)(avg_price*val/10000 + avg_price) + def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) + def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) - static main(args) { - def task = new Test() - task.run() - } - - def run(){ - def i=1 - while(i<2){ - def districts = CcbCommonUtils.findAllDistrictByCity("深圳", "district", ["city", "region", "name", "lng", "estate_type2", "name_cat", "address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"], "all"); - def rets = process(districts) - println i + " "+districts.size() +" "+rets.size() - i++ + def o = new BasicDBObject() + o.put("avg_price", new_price) + o.put("c_date" , new Date()) + o.put("city", city) + o.put("m_date" , new Date()) + o.put("weekend", weekend) + o.put("cat","城市") + o.put("moving_average" , (int)avg_price) + if(!last_price){ + o.put("weekend_markup" , 0) + }else{ + def weekend_markup = (int)((new_price-last_price)*100/last_price) + o.put("weekend_markup" , weekend_markup) } + def q = new BasicDBObject("cat", "城市").append("city", city).append("weekend", weekend) + REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) } - - def process(districts){ - def totalCount = new AtomicLong() - final CountDownLatch latch = new CountDownLatch(districts.size()) - - - def rets = new CopyOnWriteArrayList() - for(def i=0;i + def locations = v.split(",") + def arroundOffices = CommonDatautils.getSeaweedArroundByCat(k, locations[0], locations[1], "office") + println k +" "+arroundOffices.size() + if(arroundOffices){ + def index = 0 + for(def o : arroundOffices){ + index++ + def priceMap = findEsOffice(o.city, o.region, o.name) + if(!priceMap){ + priceMap = findEsHouse(o, "20231112") + } + def start_price = null + def end_price = null + def source = null + if(priceMap){ + if(priceMap.avg_start_price){ + start_price = DataHandleUtils.getDoubleRound(2, priceMap.avg_start_price) + } + if(priceMap.avg_end_price){ + end_price = DataHandleUtils.getDoubleRound(2, priceMap.avg_end_price) + } + source = priceMap.source + } + def lng = DataHandleUtils.getDoubleRound(6, o.lng/10000000000.0) + def lat = DataHandleUtils.getDoubleRound(6, o.lat/10000000000.0) + def row = [o.city, o.region, o.name, o.address, lng, lat, o.bed_kind, start_price, end_price, source] + rets << row + println index +" "+ row + } + } + } + ExcelUtils.write("d:\\数据\\写字楼测试-1118.xlsx", rets, "数据") + } + + + def findEsOffice(city, region, name){ + def map = [:] + def start_rent_prices = [] + def end_rent_prices = [] + def rent_prices = [] + + ElasticUtils.executeSqlQuery("select * from office where city='${city}' and region='${region}' and name='${name}'", { r-> + if(r.start_rent_price){ + start_rent_prices << r.start_rent_price + } + if(r.end_rent_price){ + end_rent_prices << r.end_rent_price + } + if(r.rent_price){ + rent_prices << r.rent_price + } + + }) + def avg_start_price = null + if(start_rent_prices){ + avg_start_price = start_rent_prices.sum()/start_rent_prices.size() + } + def avg_end_price = null + if(end_rent_prices){ + avg_end_price = end_rent_prices.sum()/end_rent_prices.size() + } + + if(!avg_start_price && !avg_end_price){ + if(rent_prices){ + if(rent_prices.size()>1){ + rent_prices = rent_prices.sort() + avg_start_price = rent_prices[0] + avg_end_price = rent_prices[rent_prices.size()-1] + }else{ + avg_start_price = rent_prices[0] - rent_prices[0]*0.2 + avg_end_price = rent_prices[0] + rent_prices[0]*0.2 + } + } + } + + if(avg_start_price){ + map.put("avg_start_price", avg_start_price) + } + if(avg_end_price){ + map.put("avg_end_price", avg_end_price) + } + if(map){ + map.source = "非房源" + } + return map + } + + def findEsHouse(o, startDate){ + def rent_prices = CommonDatautils.findHousePriceByDate(o.city, o.region, o.name, o.alias, "office_rent", startDate) + def avg_start_price = null + def avg_end_price = null + def map = [:] + if(rent_prices){ + if(rent_prices.size()>1){ + rent_prices = rent_prices.sort() + avg_start_price = rent_prices[0] + avg_end_price = rent_prices[rent_prices.size()-1] + }else{ + avg_start_price = rent_prices[0] - rent_prices[0]*0.2 + avg_end_price = rent_prices[0] + rent_prices[0]*0.2 + } + } + if(avg_start_price){ + map.put("avg_start_price", avg_start_price) + } + if(avg_end_price){ + map.put("avg_end_price", avg_end_price) + } + if(map){ + map.source = "房源" + } + return map + } + +} From f58bebc6f2475fd1168f9809cfb93d946f61e5eb Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 29 Nov 2024 10:10:31 +0800 Subject: [PATCH 002/247] =?UTF-8?q?/house/around=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 8 +++- .../service/datastore/HouseService.java | 1 - .../service/datastore/HouseServiceImpl.java | 20 --------- .../service/datastore/RentHouseService.java | 3 ++ .../datastore/RentHouseServiceImpl.java | 43 +++++++++++++------ 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 69313c28b..c56e7d63b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -77,6 +77,8 @@ public class HouseController { private AddressParser addressParser; private HouseService houseService; + + private RentHouseService rentHouseService; private MenuService menuService; private NoHouseDistrictService noHouseDistrictService; private ApiUserService apiUserService; @@ -1010,7 +1012,7 @@ public class HouseController { } } } else { - List nearestHasHouseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); + List nearestHasHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) { for (House house : nearestHasHouseByLocation) { Seawater seawater = new Seawater(); @@ -1869,4 +1871,8 @@ public class HouseController { public void setSeaweedService(SeaweedService seaweedService) { this.seaweedService = seaweedService; } + + public void setRentHouseService(RentHouseService rentHouseService) { + this.rentHouseService = rentHouseService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java index ac2e7863b..83f24d433 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java @@ -470,5 +470,4 @@ public interface HouseService extends ModeService { HashMap findHouseStat(District districtKey, Integer avgPrice); - List findNearestHasHouseByLocation(String city, Double lat,Double lng,String cat, int radiusMeters, int limit); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java index c380ef49f..3093de0a2 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java @@ -2612,25 +2612,5 @@ public class HouseServiceImpl implements HouseService { CacheUtils.putValue(CacheUtils.CachePolicyEnum.MIDDLE, HouseServiceImpl.class, key, value); return value; } - @Override - public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { - if (lat == null || lng == null || lat <= 0 ||lng <= 0) { - return Collections.EMPTY_LIST; - } - List params = new ArrayList(); -// params.add(new QueryParam("cat", cat)); - if (StringUtils.isNotBlank(city)){ - params.add(new QueryParam("city", city)); - } - SdQuery sdQuery = new SdQuery(); - sdQuery.setPoint(lat + "," + lng); - sdQuery.setField("lat_lng"); -// sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); - sdQuery.setDistance(String.valueOf(radiusMeters)); - params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); -// List sortParams = Arrays.asList(new SortParam("distance", true)); - List list = houseDao.findAllByParams(params, null, 0, limit); - return list; - } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java index e12108154..9c7cbfbba 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java @@ -3,6 +3,7 @@ package com.fangjia.service.datastore; import java.util.List; import java.util.Map; +import com.fangjia.dal.datastore.model.House; import org.sothis.core.util.Pager; import com.fangjia.dal.FacetQueryResult; @@ -208,4 +209,6 @@ public interface RentHouseService extends ModeService { boolean refreshHouse(String houseId, int userId); // 用户中心发布房源接口 END + + List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index 647f14f8d..0b6f2a90e 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -1,14 +1,10 @@ package com.fangjia.service.datastore; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import com.fangjia.dal.*; +import com.fangjia.dal.datastore.dao.HouseDao; +import com.fangjia.dal.datastore.model.House; import org.apache.commons.lang.StringUtils; import org.apache.lucene.search.Query; import org.sothis.core.util.CollectionUtils; @@ -16,11 +12,6 @@ import org.sothis.core.util.Pager; import com.fangjia.core.util.DateUtil; import com.fangjia.core.util.RandomUtil; -import com.fangjia.dal.FacetQuery; -import com.fangjia.dal.FacetQueryResult; -import com.fangjia.dal.QueryParam; -import com.fangjia.dal.SortParam; -import com.fangjia.dal.SrQuery; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.common.ServerAreaData; @@ -70,6 +61,8 @@ public class RentHouseServiceImpl implements RentHouseService { private UserHouseDao userHouseDao; private MetroDistanceService metroDistanceService; + private HouseDao houseDao; + public FacetQueryResult randomGainHouse(RentHouseQueryBean queryBean, int count) { long totalCount = this.findHouseCount(queryBean); int endCount = count * 100; @@ -831,6 +824,27 @@ public class RentHouseServiceImpl implements RentHouseService { return true; } + @Override + public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { + if (lat == null || lng == null || lat <= 0 ||lng <= 0) { + return Collections.EMPTY_LIST; + } + List params = new ArrayList(); +// params.add(new QueryParam("cat", cat)); + if (StringUtils.isNotBlank(city)){ + params.add(new QueryParam("city", city)); + } + SdQuery sdQuery = new SdQuery(); + sdQuery.setPoint(lat + "," + lng); + sdQuery.setField("lat_lng"); +// sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); + sdQuery.setDistance(String.valueOf(radiusMeters)); + params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); +// List sortParams = Arrays.asList(new SortParam("latLng", true)); + List list = houseDao.findAllByParams(params, null, 0, limit); + return list; + } + public boolean refreshHouse(String houseId, int userId,String source) { List params = new ArrayList(2); params.add(new QueryParam("userId", userId)); @@ -899,4 +913,7 @@ public class RentHouseServiceImpl implements RentHouseService { this.metroDistanceService = metroDistanceService; } + public void setHouseDao(HouseDao houseDao) { + this.houseDao = houseDao; + } } From 1813a88045f31d400961b3325203f2e0f42f932d Mon Sep 17 00:00:00 2001 From: sjshenjian Date: Fri, 29 Nov 2024 10:11:44 +0800 Subject: [PATCH 003/247] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b8b0cf0b7..8ff5b77db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any parameters { - choice(name: 'PROJECT_NAME', choices: ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'], description: '璇烽�夋嫨鍙戝竷鐨勯」鐩�') + choice(name: 'PROJECT_NAME', choices: ['chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'], description: '璇烽�夋嫨鍙戝竷鐨勯」鐩�') } tools { jdk 'JDK8' From 78fda7e9ac2c58edbcb1f91de9fa8aae0b367282 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 29 Nov 2024 13:18:09 +0800 Subject: [PATCH 004/247] =?UTF-8?q?/house/around=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/service/datastore/RentHouseServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index 0b6f2a90e..919351bc0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -830,17 +830,17 @@ public class RentHouseServiceImpl implements RentHouseService { return Collections.EMPTY_LIST; } List params = new ArrayList(); -// params.add(new QueryParam("cat", cat)); + params.add(new QueryParam("cat", cat)); if (StringUtils.isNotBlank(city)){ params.add(new QueryParam("city", city)); } SdQuery sdQuery = new SdQuery(); sdQuery.setPoint(lat + "," + lng); sdQuery.setField("lat_lng"); -// sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); - sdQuery.setDistance(String.valueOf(radiusMeters)); + sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); +// sdQuery.setDistance(String.valueOf(radiusMeters)); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); -// List sortParams = Arrays.asList(new SortParam("latLng", true)); + List sortParams = Arrays.asList(new SortParam("latLng", true)); List list = houseDao.findAllByParams(params, null, 0, limit); return list; } From 108e81edae047f648250adc36e690a4680d6bc78 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 29 Nov 2024 15:43:41 +0800 Subject: [PATCH 005/247] =?UTF-8?q?/house/around=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/dal/seawater/model/Seawater.java | 6 +++--- .../com/fangjia/open/controllers/HouseController.java | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index 88cd97297..890ee0ddd 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -37,7 +37,7 @@ public class Seawater implements SeawaterEntity { private String id; private String category; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int status; + private Integer status; private String city; private String region; private String district; @@ -100,11 +100,11 @@ public class Seawater implements SeawaterEntity { } @Column(name = "status") - public int getStatus() { + public Integer getStatus() { return status; } - public void setStatus(int status) { + public void setStatus(Integer status) { this.status = status; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index c56e7d63b..18d402e24 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1021,7 +1021,13 @@ public class HouseController { seawater.setAddress(house.getAddress()); seawater.setName(house.getDistrictName()); seawater.setSize(house.getArea()); - seawater.setUnitPrice(house.getAvgPrice()); + if (house.getAvgPrice() != null) { + seawater.setUnitPrice(house.getAvgPrice()); + }else { + if (house.getTotalPrice() != null &&house.getTotalPrice()>0 && house.getArea()!=null && house.getArea()>0){ + seawater.setUnitPrice((int) (house.getTotalPrice() / house.getArea())); + } + } seawater.setTotalPrice(house.getTotalPrice()); seawater.setDirection(house.getDirection()); seawater.setFloor(house.getFloor()); From 1b1ecfa770a490869f0331ddd4e08a487f550fcb Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 29 Nov 2024 17:19:12 +0800 Subject: [PATCH 006/247] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 1193 +++++++++-------- 1 file changed, 626 insertions(+), 567 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 9b4164baf..f00d7c267 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 @@ -718,15 +718,13 @@ public class AddrSvcController { return mav; } - /** - * 涉农识别-新规则-基础版本 + * 涉农识别-新规则-上海银行 * * @param model * @return */ - public Object villageIdentifyAction(AddressModel model) { - + public Object boscVillageIdentifyAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); @@ -740,40 +738,317 @@ public class AddrSvcController { String address = model.getAddress(); params.put("address", address); String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; - String villageType = "2".equals(model.getType()) ? "对公" : "对私"; params.put("type", type); - params.put("showFullValue", "2"); - Pager pager = new Pager(1, 1); - 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(); - resultMap.put("province", villageResult.getProvince()); - resultMap.put("city", villageResult.getCity1()); - resultMap.put("district", villageResult.getDistrict()); - resultMap.put("town", villageResult.getTown()); - resultMap.put("committee", villageResult.getCommittee()); - resultMap.put("provinceCode", villageResult.getCityCode()); - resultMap.put("cityCode", villageResult.getCityCode()); - resultMap.put("districtCode", villageResult.getDistrictCode()); - resultMap.put("townCode", villageResult.getTownCode()); - resultMap.put("committeeCode", villageResult.getCommitteeCode()); - resultMap.put("typeCode", villageResult.getTypeCode()); - resultMap.put("typeName", villageResult.getTypeName()); - resultMap.put("verifyFlag", villageResult.getVerifyFlag()); - resultMap.put("addrVerify", villageResult.getAddrVerify()); - resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); - resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); - resultMap.put("countyGov", villageResult.getCountyGov()); - resultMap.put("devDistrict", villageResult.getDevDistrict()); - resultMap.put("devDistrictName", villageResult.getDevDistrictName()); - resultMap.put("devLevel", villageResult.getDevLevel()); - resultMap.put("addrArea", villageResult.getAddrArea()); - BasicModel basicModel = new BasicModel(200, "OK"); - basicModel.setResult(resultMap); - mav.setModel(basicModel); - } else { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + if (json.containsKey("result")) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + HashMap map = new HashMap(); + //我们的结果 + JSONObject result = json.getJSONObject("result"); + if (result.containsKey("addrArea")) { + map.put("addrArea", result.getString("addrArea")); + } + if (result.containsKey("devDistrictName")) { + map.put("devDistrictName", result.getString("devDistrictName")); + } + if (result.containsKey("countyGovTown")) { + map.put("countyGovTown", result.getString("countyGovTown")); + } + if (result.containsKey("town")) { + map.put("town", result.getString("town")); + } + basicModel.setResult(map); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + } + return mav; + } + + /** + * 涉农识别-新规则-基础版本 + * + * @param model + * @return + */ + public Object villageIdentifyAction(AddressModel model){ + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + String villageType = "2".equals(model.getType()) ? "对公" : "对私"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + 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(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { // params.put("showTestValue", "2"); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + //我们的结果 + JSONObject result = json.getJSONObject("result"); + //我们省级及以上有开发区,直接用我们的结果 + if (result.containsKey("devDistrictName")) { + basicModel.setResult(result); + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); + } else { + try { + //如果是江苏省或者浙江省 调用齐梁的结果 + if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + + //结果比较,如果涉农结果不一致 + //调用齐梁 type :1 对公 0 对私 + //我们 type :1 对私 2 对共 + String qltype = "2".equals(type) ? "1" : "0"; + 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")))) { + 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); + } + + } else { + basicModel.setResult(result); + } + + } else { + basicModel.setResult(result); + + } + + } catch (Exception e) { + e.printStackTrace(); + basicModel.setResult(result); + } + + } + + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + } + return mav; + } + + private static Map senRequest (String address, String type) throws IOException { + String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + String proxyHost = "tunnel2.qg.net"; + int proxyPort = 14186; + final String proxyUsername = "113BBC06"; + final String proxyPassword = "3B2FBD05B0AF"; + String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; + String authKey = proxyUsername; + String password = proxyPassword; + String auth = authKey + ":" + password; + String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); + + HttpHost proxy = new HttpHost(proxyHost, proxyPort); + DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); + CloseableHttpClient httpClient = HttpClients.custom() + .setRoutePlanner(routePlanner) + .build(); + HttpPost httpPost = new HttpPost(targetURL); + Authenticator.setDefault(new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); + } + }); + httpPost.setHeader("Content-Type", "application/json"); + httpPost.setHeader("Accept", "*/*"); + httpPost.setHeader("Host", "146.56.217.44:9010"); + httpPost.setHeader("Proxy-Authorization", authHeader); + StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); + httpPost.setEntity(stringEntity); + + CloseableHttpResponse httpResponse = null; + int retryCount = 2; // 设置重试次数 + int retryDelay = 10; // 设置重试延迟时间(毫秒) + boolean success = false; + for (int i = 0; i < retryCount; i++) { + try { + httpResponse = httpClient.execute(httpPost); + success = true; + break; + } catch (IOException e) { + System.err.println("代理请求失败,进行重试..."); + try { + Thread.sleep(retryDelay); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } + + if (success) { + HttpEntity responseEntity = httpResponse.getEntity(); + String responseString = EntityUtils.toString(responseEntity); + + // 使用 Gson 解析 JSON 字符串 + Gson gson = new Gson(); + JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); + + + // 创建 Map 存储各个值 + Map dataMap = new HashMap(); + + // 获取各个值并放入 Map +// dataMap.put("code", jsonObject.get("code").getAsString()); +// dataMap.put("msg", jsonObject.get("msg").getAsString()); + JsonElement dataElement = jsonObject.get("data"); + if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { + JsonObject data = dataElement.getAsJsonObject(); + // 在这里继续处理 data 对象 + + if (data != null && !data.isJsonNull()) { + +// dataMap.put("version", data.get("version").getAsString()); + dataMap.put("province", data.get("province").getAsString()); + dataMap.put("city", data.get("city").getAsString()); + dataMap.put("district", data.get("district").getAsString()); + dataMap.put("town", data.get("town").getAsString()); + dataMap.put("committee", data.get("village").getAsString()); + dataMap.put("provinceCode", data.get("provinceCode").getAsString()); + dataMap.put("cityCode", data.get("cityCode").getAsString()); + dataMap.put("districtCode", data.get("districtCode").getAsString()); + dataMap.put("townCode", data.get("townCode").getAsString()); + dataMap.put("committeeCode", data.get("villageCode").getAsString()); + dataMap.put("typeCode", data.get("areaCode").getAsString()); + dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); + dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); +// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 + JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); + + if (indusParkList != null) { + JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); + dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); + dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); + dataMap.put("devDistrict", "是"); + } + } + } + + httpResponse.close(); + return dataMap; + } else { + System.err.println("重试次数已用完,请求失败。"); + } + + httpClient.close(); + return null; + } + + /** + * 涉农识别-新规则-标准版 + * + * @param model + * @return + */ + public Object villageIdentifyStandardAction (AddressModel model){ + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", model.getAddress()); + params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); + params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); + params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); Integer radius = model.getRadius(); params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); try { @@ -786,577 +1061,361 @@ public class AddrSvcController { } } + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + basicModel.setResult(json.get("result")); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + + /** + * 地址联想-PRO + * + * @param model + * @return + */ + @Deprecated + public Object addressAssociationAction (AddressModel model){ + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { + mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); + if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { + params.put("lat", model.getLat()); + params.put("lng", model.getLng()); + } + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } if (json != null) { int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - //我们的结果 - JSONObject result = json.getJSONObject("result"); - //我们省级及以上有开发区,直接用我们的结果 - if (result.containsKey("devDistrictName")) { - basicModel.setResult(result); - } else if (!"2".equals(type)) { // 对私的不用齐梁 - basicModel.setResult(result); - } else { - try { - //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { - - //结果比较,如果涉农结果不一致 - //调用齐梁 type :1 对公 0 对私 - //我们 type :1 对私 2 对共 - String qltype = "2".equals(type) ? "1" : "0"; - 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")))) { - 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); - } - - } else { - basicModel.setResult(result); - } - - } else { - basicModel.setResult(result); - - } - - } catch (Exception e) { - e.printStackTrace(); - basicModel.setResult(result); - } - - } - + basicModel.setResult(json.get("result")); } mav.setModel(basicModel); } else { mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } - } - return mav; - } - - private static Map senRequest(String address, String type) throws IOException { - String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; - String proxyHost = "tunnel2.qg.net"; - int proxyPort = 14186; - final String proxyUsername = "113BBC06"; - final String proxyPassword = "3B2FBD05B0AF"; - String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; - String authKey = proxyUsername; - String password = proxyPassword; - String auth = authKey + ":" + password; - String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); - - HttpHost proxy = new HttpHost(proxyHost, proxyPort); - DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); - CloseableHttpClient httpClient = HttpClients.custom() - .setRoutePlanner(routePlanner) - .build(); - HttpPost httpPost = new HttpPost(targetURL); - Authenticator.setDefault(new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); - } - }); - httpPost.setHeader("Content-Type", "application/json"); - httpPost.setHeader("Accept", "*/*"); - httpPost.setHeader("Host", "146.56.217.44:9010"); - httpPost.setHeader("Proxy-Authorization", authHeader); - StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); - httpPost.setEntity(stringEntity); - - CloseableHttpResponse httpResponse = null; - int retryCount = 2; // 设置重试次数 - int retryDelay = 10; // 设置重试延迟时间(毫秒) - boolean success = false; - for (int i = 0; i < retryCount; i++) { - try { - httpResponse = httpClient.execute(httpPost); - success = true; - break; - } catch (IOException e) { - System.err.println("代理请求失败,进行重试..."); - try { - Thread.sleep(retryDelay); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - } - } - } - - if (success) { - HttpEntity responseEntity = httpResponse.getEntity(); - String responseString = EntityUtils.toString(responseEntity); - - // 使用 Gson 解析 JSON 字符串 - Gson gson = new Gson(); - JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); - - - // 创建 Map 存储各个值 - Map dataMap = new HashMap(); - - // 获取各个值并放入 Map -// dataMap.put("code", jsonObject.get("code").getAsString()); -// dataMap.put("msg", jsonObject.get("msg").getAsString()); - JsonElement dataElement = jsonObject.get("data"); - if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { - JsonObject data = dataElement.getAsJsonObject(); - // 在这里继续处理 data 对象 - - if (data != null && !data.isJsonNull()) { - -// dataMap.put("version", data.get("version").getAsString()); - dataMap.put("province", data.get("province").getAsString()); - dataMap.put("city", data.get("city").getAsString()); - dataMap.put("district", data.get("district").getAsString()); - dataMap.put("town", data.get("town").getAsString()); - dataMap.put("committee", data.get("village").getAsString()); - dataMap.put("provinceCode", data.get("provinceCode").getAsString()); - dataMap.put("cityCode", data.get("cityCode").getAsString()); - dataMap.put("districtCode", data.get("districtCode").getAsString()); - dataMap.put("townCode", data.get("townCode").getAsString()); - dataMap.put("committeeCode", data.get("villageCode").getAsString()); - dataMap.put("typeCode", data.get("areaCode").getAsString()); - dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); - dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); -// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 - JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); - - if (indusParkList != null) { - JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); - dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); - dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); - dataMap.put("devDistrict", "是"); - } - } - } - - httpResponse.close(); - return dataMap; - } else { - System.err.println("重试次数已用完,请求失败。"); - } - - httpClient.close(); - return null; - } - - /** - * 涉农识别-新规则-标准版 - * - * @param model - * @return - */ - public Object villageIdentifyStandardAction(AddressModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); return mav; } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", model.getAddress()); - params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); - params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); - params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - - - /** - * 地址联想-PRO - * - * @param model - * @return - */ - @Deprecated - public Object addressAssociationAction(AddressModel model) { - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { - mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); - return mav; - } - - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); - params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); - if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { - params.put("lat", model.getLat()); - params.put("lng", model.getLng()); - } - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - - /** - * 市级行政区划查询接口 - * - * @param model - * @return - */ - public Object listCityAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception e) { + /** + * 市级行政区划查询接口 + * + * @param model + * @return + */ + public Object listCityAction (AddressModel model){ + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - list.add(map); - } + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - /** - * 省级行政区划查询接口 - * - * @param model - * @return - */ - public Object listProvinceAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception e) { + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 省级行政区划查询接口 + * + * @param model + * @return + */ + public Object listProvinceAction (AddressModel model){ + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - list.add(map); - } + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - /** - * 区域级行政区划查询接口 - * - * @param model - * @return - */ - public Object listDistrictAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception e) { + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 区域级行政区划查询接口 + * + * @param model + * @return + */ + public Object listDistrictAction (AddressModel model){ + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - list.add(map); - } + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - public Object listTownshipAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception e) { + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + public Object listTownshipAction (AddressModel model){ + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - if (result.containsKey("street")) { - map.put("street", result.getString("street")); - } - if (result.containsKey("tjjStreetCode")) { - map.put("streetCode", result.getString("tjjStreetCode")); - } - list.add(map); - } + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; - } - public Object levelAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception e) { + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + if (result.containsKey("street")) { + map.put("street", result.getString("street")); + } + if (result.containsKey("tjjStreetCode")) { + map.put("streetCode", result.getString("tjjStreetCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + public Object levelAction (AddressModel model){ + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; } - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - JSONObject result = json.getJSONObject("result"); - basicModel.setResult(result); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + public void setDistrictStatService (DistrictStatService districtStatService){ + this.districtStatService = districtStatService; } - return mav; - } - public void setDistrictStatService(DistrictStatService districtStatService) { - this.districtStatService = districtStatService; - } + public void setDistrictService (DistrictService districtService){ + this.districtService = districtService; + } - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; + public void setVillageIdentifyService (VillageIdentifyService villageIdentifyService){ + this.villageIdentifyService = villageIdentifyService; + } } - - public void setVillageIdentifyService(VillageIdentifyService villageIdentifyService) { - this.villageIdentifyService = villageIdentifyService; - } -} From 28519f9094ab3b00396bf47c0199b3dc9e1ece8c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 2 Dec 2024 10:31:21 +0800 Subject: [PATCH 007/247] update --- .../groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f722db94c..b6b36149f 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 @@ -77,7 +77,7 @@ class DevProcess { // println DateUtils.add("2024-7-24", 7); // task.addKfc() -// task.devToPark() //开发区下辖园区 +// task.devToPark() //开发区下辖园 // task.checkTown() // task.repeatSave() From 29210bd5fcd6f2f93fad25bdd243d1a160cb2204 Mon Sep 17 00:00:00 2001 From: sjshenjian Date: Mon, 2 Dec 2024 17:36:52 +0800 Subject: [PATCH 008/247] =?UTF-8?q?=E6=96=B0=E5=A2=9EOPEN=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8ff5b77db..fe1323a0e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any parameters { - choice(name: 'PROJECT_NAME', choices: ['chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'], description: '璇烽�夋嫨鍙戝竷鐨勯」鐩�') + choice(name: 'PROJECT_NAME', choices: ['chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'], description: '璇烽�夋嫨鍙戝竷鐨勯」鐩�') } tools { jdk 'JDK8' @@ -17,7 +17,7 @@ pipeline { stage('Maven Build') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("deliverables/${project}") { @@ -33,8 +33,8 @@ pipeline { stage('Docker Build') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] - def imagesName = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke"] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] + def imagesName = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke", 'fangjiaopen': 'fangjia-open'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("projects/${imagesName[project]}") { @@ -53,8 +53,8 @@ pipeline { stage('K8S Deploy') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] - def k8s_config_map = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke"] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] + def k8s_config_map = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke", 'fangjiaopen': 'fangjia-open'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("deliverables/k8s") { From c40de8839565e2b6a87d7b38253c5eb51eef5c6f Mon Sep 17 00:00:00 2001 From: sjshenjian Date: Mon, 2 Dec 2024 17:46:51 +0800 Subject: [PATCH 009/247] =?UTF-8?q?=E6=96=B0=E5=A2=9EOPEN=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deliverables/k8s/fangjia-open.yaml | 33 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/deliverables/k8s/fangjia-open.yaml b/deliverables/k8s/fangjia-open.yaml index 32ce4bb75..09660e137 100644 --- a/deliverables/k8s/fangjia-open.yaml +++ b/deliverables/k8s/fangjia-open.yaml @@ -1,4 +1,4 @@ -锛歛piVersion: apps/v1 +apiVersion: apps/v1 kind: Deployment metadata: name: fangjia-open @@ -37,20 +37,39 @@ spec: - containerPort: 8080 name: web protocol: TCP + # readinessProbe: + # httpGet: + # path: /k8s/readiness + # port: web + # initialDelaySeconds: 5 + # periodSeconds: 10 + # livenessProbe: + # httpGet: + # path: /k8s/liveness + # port: web + # initialDelaySeconds: 10 + # periodSeconds: 5 volumeMounts: - name: host-time mountPath: /etc/localtime - - name: nfs + - name: goojiaconfig mountPath: /home/goojia/goojiaconfig volumes: - name: host-time hostPath: path: /etc/localtime - - name: nfs - nfs: - path: /home/nfs_data/goojiaconfig - server: 192.168.0.18 + - name: goojiaconfig + cephfs: + monitors: + - 192.168.0.208:6789 + - 192.168.0.209:6789 + - 192.168.0.210:6789 + user: admin + path: /k8s/goojiaconfig + secretRef: + name: ceph-secret + readOnly: false --- apiVersion: v1 @@ -69,4 +88,4 @@ spec: ports: - port: 8080 targetPort: 8080 - nodePort: 38089 \ No newline at end of file + nodePort: 31088 \ No newline at end of file From 48c043787badb4defed065293feb39f82e14e46e Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Dec 2024 15:42:51 +0800 Subject: [PATCH 010/247] =?UTF-8?q?/house/around=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 30 +++++--- .../fangjia/dal/seawater/model/Seawater.java | 20 ++++++ .../open/controllers/HouseController.java | 69 +++++++++++++------ .../datastore/RentHouseServiceImpl.java | 2 +- 4 files changed, 90 insertions(+), 31 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index dd74c4224..e32cd035d 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -15,11 +15,11 @@ import net.sf.json.JSONObject; import org.sothis.core.util.Pager; public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl implements SeawaterDao { - - + + private static final String ES_USER = "developer"; private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; - + @Override public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, @@ -267,6 +267,10 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i seawater.setCity(source.getString("city")); seawater.setRegion(source.getString("region")); seawater.setDistrictName(source.getString("district_name")); + if (source.containsKey("location")){ + String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); + seawater.setLocation(location); + } if(source.containsKey("address")){ seawater.setAddress(source.getString("address")); } @@ -372,11 +376,16 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i if(source.containsKey("elevator")){ seawater.setElevator(source.getString("elevator")); } + try { + seawater.setDistance((int)jsonList.get(i).getJSONArray("sort").getDouble(0)); + }catch (Exception e){ + seawater.setDistance(null); + } seawaterList.add(seawater); } return seawaterList; } - + private JSONObject query(String id,String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){ @@ -399,7 +408,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("term", param); jsonList.add(temp); } - + Set namesList = new LinkedHashSet(); if(StringUtils.isNotBlank(name)) { namesList.add(name); @@ -414,7 +423,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("terms", param); jsonList.add(temp); } - + Set regionsList = new LinkedHashSet(); if(StringUtils.isNotBlank(region)) { regionsList.add(region); @@ -429,7 +438,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("terms", param); jsonList.add(temp); } - + if(StringUtils.isNotBlank(city)){ JSONObject param = new JSONObject(); param.put("city", city); @@ -451,7 +460,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("term", param); jsonList.add(temp); } - + if(startDate != null || endDate != null){ JSONObject param = new JSONObject(); JSONObject temp = new JSONObject(); @@ -497,7 +506,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("range", param); jsonList.add(temp); } - + if(StringUtils.isNotBlank(sort)){ JSONObject jsonOrder = new JSONObject(); if(order){ @@ -511,7 +520,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i sortJsonList.add(jsonSort); reqBody.put("sort", sortJsonList); } - + if(start >= 0){ reqBody.put("from", start); } @@ -557,6 +566,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i Double lat = query.getLat(); Double lng = query.getLng(); Integer radius = query.getRadius(); + // 添加地理位置过滤器和排序 if (lat != null && lng != null && radius != null) { // 1. 设置地理位置参数 JSONObject geoDistanceParam = new JSONObject(); diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index 890ee0ddd..c47b1830f 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -80,6 +80,10 @@ public class Seawater implements SeawaterEntity { private String decoration; + private Integer distance; + + private String location; + @Id @Column(name = "_id") public String getId() { @@ -453,4 +457,20 @@ public class Seawater implements SeawaterEntity { public void setDecoration(String decoration) { this.decoration = decoration; } + + public Integer getDistance() { + return distance; + } + + public void setDistance(Integer distance) { + this.distance = distance; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 18d402e24..b5966d647 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -897,8 +897,22 @@ public class HouseController { @Authority(role = Role.USER) public Object aroundAction(final HouseSearchModel model) { + List type3 = Arrays.asList("1", "2", "0"); + List type2 = Arrays.asList("1", "0"); RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())){ + mav.setModel(BasicModel.buildBadRequestModel("参数(locationType)有误")); + return mav; + } + if (StringUtils.isNotBlank(model.getPropertyType()) && !type3.contains(model.getPropertyType())){ + mav.setModel(BasicModel.buildBadRequestModel("参数(propertyType)有误")); + return mav; + } + if (StringUtils.isNotBlank(model.getHouseType()) && !type2.contains(model.getHouseType())){ + mav.setModel(BasicModel.buildBadRequestModel("参数(houseType)有误")); + return mav; + } // 获取当前日期 Calendar today = Calendar.getInstance(); @@ -925,8 +939,17 @@ public class HouseController { return mav; } String[] locationStr = model.getLocation().split(","); + String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数 + for (String loc : locationStr) { + if (!loc.trim().matches(numberPattern)) { + mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)格式错误")); + return mav; + } + } Double lng = Double.valueOf(locationStr[0]); Double lat = Double.valueOf(locationStr[1]); + +// if (model.getSize()) if ("2".equals(model.getLocationType())) { Map gcj02Location = GeoUtils.bd09ToGcj02(lat, lng); lng = gcj02Location.get("lng"); @@ -985,19 +1008,20 @@ public class HouseController { if (houses != null && !houses.isEmpty()) { for (Seawater house : houses) { Seawater seawater = new Seawater(); + seawater.setId(house.getId()); seawater.setCity(house.getCity()); seawater.setDistrict(house.getRegion()); seawater.setAddress(house.getAddress()); seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea()); - seawater.setUnitPrice(house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice()); + seawater.setSize(house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice()); seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor()); - seawater.setMaxFloor(house.getHeight()); - seawater.setRoom(house.getRoom()); - seawater.setHall(house.getHall()); - seawater.setToilet(house.getToilet()); + seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getMaxFloor()); + seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet()); seawater.setDecoration(house.getFitment()); if (house.getpDate() != null && house.getpDate() > 10000000) { String numberStr = String.valueOf(house.getpDate()); @@ -1008,6 +1032,8 @@ public class HouseController { String formattedDate = year + "-" + month + "-" + day; seawater.setPublishDate(formattedDate); } + seawater.setDistance(house.getDistance()); + seawater.setLocation(house.getLocation()); houseList.add(seawater); } } @@ -1016,25 +1042,28 @@ public class HouseController { if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) { for (House house : nearestHasHouseByLocation) { Seawater seawater = new Seawater(); + seawater.setId(house.getId()); seawater.setCity(house.getCity()); seawater.setDistrict(house.getRegion()); seawater.setAddress(house.getAddress()); seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea()); - if (house.getAvgPrice() != null) { + seawater.setSize(house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == 0 || house.getAvgPrice() == null ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet()); + if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { seawater.setUnitPrice(house.getAvgPrice()); - }else { - if (house.getTotalPrice() != null &&house.getTotalPrice()>0 && house.getArea()!=null && house.getArea()>0){ - seawater.setUnitPrice((int) (house.getTotalPrice() / house.getArea())); + } else { + if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { + int price = (int) (house.getTotalPrice() / house.getArea()); + seawater.setUnitPrice(price == 0 ? null : price); } } - seawater.setTotalPrice(house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor()); - seawater.setMaxFloor(house.getHeight()); - seawater.setRoom(house.getRoom()); - seawater.setHall(house.getHall()); - seawater.setToilet(house.getToilet()); seawater.setDecoration(house.getFitment()); if (house.getPublishDate() != null) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index 919351bc0..a065292bb 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -841,7 +841,7 @@ public class RentHouseServiceImpl implements RentHouseService { // sdQuery.setDistance(String.valueOf(radiusMeters)); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); List sortParams = Arrays.asList(new SortParam("latLng", true)); - List list = houseDao.findAllByParams(params, null, 0, limit); + List list = houseDao.findAllByParams(params, sortParams, 0, limit); return list; } From f68de68ceed44cbc5659831093bb67af9541b70f Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Dec 2024 17:09:38 +0800 Subject: [PATCH 011/247] =?UTF-8?q?/house/around=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 34 ++++++++++++------- .../datastore/RentHouseServiceImpl.java | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index b5966d647..6ff0fc537 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -901,15 +901,15 @@ public class HouseController { List type2 = Arrays.asList("1", "0"); RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); - if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())){ + if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())) { mav.setModel(BasicModel.buildBadRequestModel("参数(locationType)有误")); return mav; } - if (StringUtils.isNotBlank(model.getPropertyType()) && !type3.contains(model.getPropertyType())){ + if (StringUtils.isNotBlank(model.getPropertyType()) && !type3.contains(model.getPropertyType())) { mav.setModel(BasicModel.buildBadRequestModel("参数(propertyType)有误")); return mav; } - if (StringUtils.isNotBlank(model.getHouseType()) && !type2.contains(model.getHouseType())){ + if (StringUtils.isNotBlank(model.getHouseType()) && !type2.contains(model.getHouseType())) { mav.setModel(BasicModel.buildBadRequestModel("参数(houseType)有误")); return mav; } @@ -1033,7 +1033,17 @@ public class HouseController { seawater.setPublishDate(formattedDate); } seawater.setDistance(house.getDistance()); - seawater.setLocation(house.getLocation()); + if (StringUtils.isNotBlank(house.getLocation())) { + if ("2".equals(model.getLocationType())) { + String[] split = house.getLocation().split(","); + Double lon = Double.valueOf(split[0]); + Double latt = Double.valueOf(split[1]); + Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); + seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat")); + } else { + seawater.setLocation(house.getLocation()); + } + } houseList.add(seawater); } } @@ -1047,15 +1057,15 @@ public class HouseController { seawater.setDistrict(house.getRegion()); seawater.setAddress(house.getAddress()); seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea() == 0 ? null : house.getArea()); - seawater.setUnitPrice(house.getAvgPrice() == 0 || house.getAvgPrice() == null ? null : house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor()); - seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getHeight()); - seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { seawater.setUnitPrice(house.getAvgPrice()); } else { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index a065292bb..919351bc0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -841,7 +841,7 @@ public class RentHouseServiceImpl implements RentHouseService { // sdQuery.setDistance(String.valueOf(radiusMeters)); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); List sortParams = Arrays.asList(new SortParam("latLng", true)); - List list = houseDao.findAllByParams(params, sortParams, 0, limit); + List list = houseDao.findAllByParams(params, null, 0, limit); return list; } From 5cea2bc1058c68851cb378c35249cfea6eb163c7 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Dec 2024 17:45:54 +0800 Subject: [PATCH 012/247] =?UTF-8?q?/house/around=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/datastore/model/RentHouse.java | 12 ++ .../open/controllers/HouseController.java | 144 +++++++++++------- .../service/datastore/HouseService.java | 4 + .../service/datastore/HouseServiceImpl.java | 22 +++ .../service/datastore/RentHouseService.java | 2 +- .../datastore/RentHouseServiceImpl.java | 4 +- 6 files changed, 131 insertions(+), 57 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java index da86e9653..63a13c075 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java @@ -38,6 +38,8 @@ public class RentHouse extends BaseHouse implements DatastoreEntity { private String block; private Integer totalPrice; private Integer totalPriceRange; + + private Integer avgPrice; /** * 出租类型 */ @@ -760,4 +762,14 @@ public class RentHouse extends BaseHouse implements DatastoreEntity { this.houseRequire = houseRequire; } + @Transient + @Column(name = "avg_price") + public Integer getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Integer avgPrice) { + this.avgPrice = avgPrice; + } + } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 6ff0fc537..c3b904787 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -8,6 +8,7 @@ import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.datastore.model.House; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; import com.fangjia.dal.mongo.model.Metro; @@ -1007,50 +1008,6 @@ public class HouseController { houses = seawaterDao.findSeawatersByQuery(query); if (houses != null && !houses.isEmpty()) { for (Seawater house : houses) { - Seawater seawater = new Seawater(); - seawater.setId(house.getId()); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea() == 0 ? null : house.getArea()); - seawater.setUnitPrice(house.getAvgPrice() == 0 ? null : house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor()); - seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getMaxFloor()); - seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet()); - seawater.setDecoration(house.getFitment()); - if (house.getpDate() != null && house.getpDate() > 10000000) { - String numberStr = String.valueOf(house.getpDate()); - // 拆分字符串并格式化 - String year = numberStr.substring(0, 4); // 前四位是年份 - String month = numberStr.substring(4, 6); // 中间两位是月份 - String day = numberStr.substring(6, 8); // 最后两位是日期 - String formattedDate = year + "-" + month + "-" + day; - seawater.setPublishDate(formattedDate); - } - seawater.setDistance(house.getDistance()); - if (StringUtils.isNotBlank(house.getLocation())) { - if ("2".equals(model.getLocationType())) { - String[] split = house.getLocation().split(","); - Double lon = Double.valueOf(split[0]); - Double latt = Double.valueOf(split[1]); - Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); - seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat")); - } else { - seawater.setLocation(house.getLocation()); - } - } - houseList.add(seawater); - } - } - } else { - List nearestHasHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); - if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) { - for (House house : nearestHasHouseByLocation) { Seawater seawater = new Seawater(); seawater.setId(house.getId()); seawater.setCity(house.getCity()); @@ -1067,19 +1024,98 @@ public class HouseController { seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { - seawater.setUnitPrice(house.getAvgPrice()); - } else { - if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { - int price = (int) (house.getTotalPrice() / house.getArea()); - seawater.setUnitPrice(price == 0 ? null : price); + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); } + seawater.setDistance(house.getDistance()); + if (StringUtils.isNotBlank(house.getLocation())) { + if ("2".equals(model.getLocationType())) { + String[] split = house.getLocation().split(","); + Double lon = Double.valueOf(split[0]); + Double latt = Double.valueOf(split[1]); + Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); + seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat")); + } else { + seawater.setLocation(house.getLocation()); + } + } + houseList.add(seawater); } - seawater.setDecoration(house.getFitment()); - if (house.getPublishDate() != null) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - seawater.setPublishDate(sdf.format(house.getPublishDate())); + } + } else { + if ("sell".equals(cat)) { + List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); + for (House house : houseByLocation) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { + seawater.setUnitPrice(house.getAvgPrice()); + } else { + if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { + int price = (int) (house.getTotalPrice() / house.getArea()); + seawater.setUnitPrice(price == 0 ? null : price); + } + } + seawater.setDecoration(house.getFitment()); + if (house.getPublishDate() != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + seawater.setPublishDate(sdf.format(house.getPublishDate())); + } + houseList.add(seawater); + } + } else if ("rent".equals(cat)) { + List rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); + for (RentHouse house : rentHouseByLocation) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { + seawater.setUnitPrice(house.getAvgPrice()); + } else { + if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { + int price = (int) (house.getTotalPrice() / house.getArea()); + seawater.setUnitPrice(price == 0 ? null : price); + } + } + seawater.setDecoration(house.getFitment()); + if (house.getPublishDate() != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + seawater.setPublishDate(sdf.format(house.getPublishDate())); + } + houseList.add(seawater); } - houseList.add(seawater); } } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java index 83f24d433..1b112e38c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java @@ -7,6 +7,7 @@ import java.util.Map; import com.fangjia.dal.FacetQuery; import com.fangjia.dal.common.DistrictKey; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.datastore.driver.FacetResult; import com.fangjia.service.bo.HousePDSBo; import com.fangjia.service.bo.HouseScorer; @@ -470,4 +471,7 @@ public interface HouseService extends ModeService { HashMap findHouseStat(District districtKey, Integer avgPrice); + List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); + + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java index 3093de0a2..5eb20dfea 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java @@ -8,6 +8,7 @@ import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.datastore.dao.HouseDao; import com.fangjia.dal.datastore.model.House; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.dal.mongo.dao.UserHouseDao; import com.fangjia.dal.mongo.fangjia.model.ServerArea; import com.fangjia.dal.mongo.model.UserHouse; @@ -2613,4 +2614,25 @@ public class HouseServiceImpl implements HouseService { return value; } + @Override + public List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit) { + if (lat == null || lng == null || lat <= 0 ||lng <= 0) { + return Collections.EMPTY_LIST; + } + List params = new ArrayList(); + params.add(new QueryParam("cat", cat)); + if (StringUtils.isNotBlank(city)){ + params.add(new QueryParam("city", city)); + } + SdQuery sdQuery = new SdQuery(); + sdQuery.setPoint(lat + "," + lng); + sdQuery.setField("lat_lng"); + sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); +// sdQuery.setDistance(String.valueOf(radiusMeters)); + params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); + List sortParams = Arrays.asList(new SortParam("latLng", true)); + List list = houseDao.findAllByParams(params, null, 0, limit); + return list; + } + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java index 9c7cbfbba..1bdd09d3c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java @@ -210,5 +210,5 @@ public interface RentHouseService extends ModeService { // 用户中心发布房源接口 END - List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); + List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index 919351bc0..7cfdba6f9 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -825,7 +825,7 @@ public class RentHouseServiceImpl implements RentHouseService { } @Override - public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { + public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { if (lat == null || lng == null || lat <= 0 ||lng <= 0) { return Collections.EMPTY_LIST; } @@ -841,7 +841,7 @@ public class RentHouseServiceImpl implements RentHouseService { // sdQuery.setDistance(String.valueOf(radiusMeters)); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); List sortParams = Arrays.asList(new SortParam("latLng", true)); - List list = houseDao.findAllByParams(params, null, 0, limit); + List list = rentHouseDao.findAllByParams(params, null, 0, limit); return list; } From 9f930e2e364fd1be40b6bc71bce4e6d1781b242f Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 4 Dec 2024 15:19:48 +0800 Subject: [PATCH 013/247] =?UTF-8?q?/comprehensiveQuery/houseValueInformati?= =?UTF-8?q?on=20POI=20=E5=8C=BB=E9=99=A2=E6=94=B9=E6=88=90=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=E7=BB=93=E5=B0=BE=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 1abcab0fa..b5b990ada 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -416,6 +416,14 @@ public class ComprehensiveQueryController { // 原周边POI DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(district); + List hospitalList = facilitys.getHospital(); + List hospitals = new ArrayList(); + for (String hospital : hospitalList) { + if (hospital.endsWith("医院")){ + hospitals.add(hospital); + } + } + facilitys.setHospital(hospitals); // 将周边POI数据放到结果集 houseValueInformation.setSurroundingPoi(facilitys); mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); From 576ce5ab2beb92b33bb8c95705e41a3b1f7ab796 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 4 Dec 2024 15:28:00 +0800 Subject: [PATCH 014/247] =?UTF-8?q?/house/around=20=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E6=9F=A5=E8=AF=A2ES?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index c3b904787..ac24cd972 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -986,7 +986,7 @@ public class HouseController { } List houses = null; List houseList = new ArrayList(); - if (cat.contains("_")) { +// if (cat.contains("_")) { // 商铺,写字楼有经纬度,直接查 SeawaterQuery query = new SeawaterQuery(); query.setLat(lat); @@ -1049,75 +1049,75 @@ public class HouseController { houseList.add(seawater); } } - } else { - if ("sell".equals(cat)) { - List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); - for (House house : houseByLocation) { - Seawater seawater = new Seawater(); - seawater.setId(house.getId()); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); - seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); - seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); - seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); - if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { - seawater.setUnitPrice(house.getAvgPrice()); - } else { - if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { - int price = (int) (house.getTotalPrice() / house.getArea()); - seawater.setUnitPrice(price == 0 ? null : price); - } - } - seawater.setDecoration(house.getFitment()); - if (house.getPublishDate() != null) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - seawater.setPublishDate(sdf.format(house.getPublishDate())); - } - houseList.add(seawater); - } - } else if ("rent".equals(cat)) { - List rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); - for (RentHouse house : rentHouseByLocation) { - Seawater seawater = new Seawater(); - seawater.setId(house.getId()); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); - seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); - seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); - seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); - if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { - seawater.setUnitPrice(house.getAvgPrice()); - } else { - if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { - int price = (int) (house.getTotalPrice() / house.getArea()); - seawater.setUnitPrice(price == 0 ? null : price); - } - } - seawater.setDecoration(house.getFitment()); - if (house.getPublishDate() != null) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - seawater.setPublishDate(sdf.format(house.getPublishDate())); - } - houseList.add(seawater); - } - } - } +// } else { +// if ("sell".equals(cat)) { +// List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); +// for (House house : houseByLocation) { +// Seawater seawater = new Seawater(); +// seawater.setId(house.getId()); +// seawater.setCity(house.getCity()); +// seawater.setDistrict(house.getRegion()); +// seawater.setAddress(house.getAddress()); +// seawater.setName(house.getDistrictName()); +// seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); +// seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); +// seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); +// seawater.setDirection(house.getDirection()); +// seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); +// seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); +// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); +// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); +// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); +// if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { +// seawater.setUnitPrice(house.getAvgPrice()); +// } else { +// if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { +// int price = (int) (house.getTotalPrice() / house.getArea()); +// seawater.setUnitPrice(price == 0 ? null : price); +// } +// } +// seawater.setDecoration(house.getFitment()); +// if (house.getPublishDate() != null) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// seawater.setPublishDate(sdf.format(house.getPublishDate())); +// } +// houseList.add(seawater); +// } +// } else if ("rent".equals(cat)) { +// List rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); +// for (RentHouse house : rentHouseByLocation) { +// Seawater seawater = new Seawater(); +// seawater.setId(house.getId()); +// seawater.setCity(house.getCity()); +// seawater.setDistrict(house.getRegion()); +// seawater.setAddress(house.getAddress()); +// seawater.setName(house.getDistrictName()); +// seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); +// seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); +// seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); +// seawater.setDirection(house.getDirection()); +// seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); +// seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); +// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); +// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); +// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); +// if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { +// seawater.setUnitPrice(house.getAvgPrice()); +// } else { +// if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { +// int price = (int) (house.getTotalPrice() / house.getArea()); +// seawater.setUnitPrice(price == 0 ? null : price); +// } +// } +// seawater.setDecoration(house.getFitment()); +// if (house.getPublishDate() != null) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// seawater.setPublishDate(sdf.format(house.getPublishDate())); +// } +// houseList.add(seawater); +// } +// } +// } } From 84973853880884bff7c51d80a2ce44dd870d8ef2 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 4 Dec 2024 17:34:35 +0800 Subject: [PATCH 015/247] =?UTF-8?q?/house/around=20=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E6=9F=A5=E8=AF=A2ES?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/seawater/dao/SeawaterDaoImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index e32cd035d..4f0de8fc4 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -566,6 +566,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i Double lat = query.getLat(); Double lng = query.getLng(); Integer radius = query.getRadius(); + JSONObject filter = new JSONObject(); // 添加地理位置过滤器和排序 if (lat != null && lng != null && radius != null) { // 1. 设置地理位置参数 @@ -574,14 +575,16 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i geoDistanceParam.put("lon", lng); // 2. 设置 geo_distance 过滤器,限制结果在指定的半径范围内 - JSONObject geoDistanceFilter = new JSONObject(); + JSONObject geoDistance = new JSONObject(); geoDistance.put("distance", radius + "m"); // 半径设置为 3000km geoDistance.put("location", geoDistanceParam); // 使用给定的经纬度 - geoDistanceFilter.put("geo_distance", geoDistance); + filter.put("geo_distance", geoDistance); // 3. 构建查询体 - reqBody.put("query", new JSONObject().put("filter", geoDistanceFilter)); +// filter.put("filter", geoDistanceFilter); +// jsonList.add(filter); +// reqBody.put("query", filter); // 4. 添加按距离排序的部分 JSONObject geoDistanceSort = new JSONObject(); JSONObject jsonObject = new JSONObject(); @@ -745,6 +748,9 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i } queryJson.put("must", jsonList); + ArrayList filterList = new ArrayList(); + filterList.add(filter); + queryJson.put("filter", filterList); q.put("bool", queryJson); reqBody.put("query", q); //用户名:密码 From e0b1380c356c6ab8808d6a03d0a53b1acf9a6e75 Mon Sep 17 00:00:00 2001 From: shenjian Date: Thu, 5 Dec 2024 09:55:05 +0800 Subject: [PATCH 016/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=BB=E4=BB=B7BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index b5b990ada..0c1a6e302 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -747,12 +747,15 @@ public class ComprehensiveQueryController { districtPriceMap.put("city", district.getCity()); districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); + // 修复总价BUG + //districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); if (evaluation.getAvgPrice2b() != null && evaluation.getAvgPrice2b() != 0) { districtPriceMap.put("avgPrice", evaluation.getAvgPrice2b()); } else { districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); } + Long totalPrice = new BigDecimal((Integer)districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); + districtPriceMap.put("totalPrice", totalPrice); // 根据城市等 级设置D级可信度 ApiUserAuthority apiUserAuthority = apiUserAuthorityService From 620c615fba509c18a27003cbc2807df0992bf9dc Mon Sep 17 00:00:00 2001 From: shenjian Date: Thu, 5 Dec 2024 10:20:43 +0800 Subject: [PATCH 017/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=BB=E4=BB=B7BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 0c1a6e302..5597209d3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -747,8 +747,6 @@ public class ComprehensiveQueryController { districtPriceMap.put("city", district.getCity()); districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); - // 修复总价BUG - //districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); if (evaluation.getAvgPrice2b() != null && evaluation.getAvgPrice2b() != 0) { districtPriceMap.put("avgPrice", evaluation.getAvgPrice2b()); } else { @@ -815,7 +813,10 @@ public class ComprehensiveQueryController { } catch (Exception e) { e.printStackTrace(); } - + // 根据单价重新计算总价 + Integer avgPrice = (Integer) districtPriceMap.get("avgPrice"); + totalPrice = new BigDecimal(avgPrice).multiply(new BigDecimal(evaluation.getArea())).longValue(); + districtPriceMap.put("totalPrice", totalPrice); return mav; } else { evaluationService.remove(evaluation.getId()); From b5071ce01a8ec3d441e18ab9b28b5aaa7424ab52 Mon Sep 17 00:00:00 2001 From: shenjian Date: Thu, 5 Dec 2024 10:23:36 +0800 Subject: [PATCH 018/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=BB=E4=BB=B7BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 5597209d3..4800e992c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -755,48 +755,6 @@ public class ComprehensiveQueryController { Long totalPrice = new BigDecimal((Integer)districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); districtPriceMap.put("totalPrice", totalPrice); - // 根据城市等 级设置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()); From 657fa827c6dd395121784f01440dc84827d17d1f Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 5 Dec 2024 14:01:13 +0800 Subject: [PATCH 019/247] =?UTF-8?q?/house/around=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 133 ++++++++++-------- 1 file changed, 75 insertions(+), 58 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index ac24cd972..e643e3b3a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -68,6 +68,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import java.io.IOException; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; @@ -987,68 +988,78 @@ public class HouseController { List houses = null; List houseList = new ArrayList(); // if (cat.contains("_")) { - // 商铺,写字楼有经纬度,直接查 - SeawaterQuery query = new SeawaterQuery(); - query.setLat(lat); - query.setLng(lng); - query.setCat(cat); - query.setRadius(model.getRadius()); - query.setStartDate(model.getStartTime()); - query.setEndDate(model.getEndTime()); - if (model.getSize() != null && model.getSize() != 0) { - query.setStartArea(model.getSize() * 0.9); - query.setEndArea(model.getSize() * 1.1); - } - query.setCityDisplay(model.getCity()); - Pager pager = new Pager(); - pager.setStartRow(0); - pager.setPageSize(5); - query.setPager(pager); - query.setTable("latest_seawater"); - houses = seawaterDao.findSeawatersByQuery(query); - if (houses != null && !houses.isEmpty()) { - for (Seawater house : houses) { - Seawater seawater = new Seawater(); - seawater.setId(house.getId()); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); - seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); - seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); - seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); - if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { - seawater.setDecoration(house.getFitment()); - if (house.getpDate() != null && house.getpDate() > 10000000) { - String numberStr = String.valueOf(house.getpDate()); - // 拆分字符串并格式化 - String year = numberStr.substring(0, 4); // 前四位是年份 - String month = numberStr.substring(4, 6); // 中间两位是月份 - String day = numberStr.substring(6, 8); // 最后两位是日期 - String formattedDate = year + "-" + month + "-" + day; - seawater.setPublishDate(formattedDate); - } - seawater.setDistance(house.getDistance()); - if (StringUtils.isNotBlank(house.getLocation())) { - if ("2".equals(model.getLocationType())) { - String[] split = house.getLocation().split(","); - Double lon = Double.valueOf(split[0]); - Double latt = Double.valueOf(split[1]); - Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); - seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat")); - } else { - seawater.setLocation(house.getLocation()); + // 商铺,写字楼有经纬度,直接查 + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat(cat); + query.setRadius(model.getRadius()); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + String districtName = house.getDistrictName(); + if (!"暂无数据".equals(districtName) && StringUtils.isNotBlank(districtName)) { + seawater.setName(districtName); + }else { + seawater.setName(house.getName()); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + seawater.setDistance(house.getDistance()); + if (StringUtils.isNotBlank(house.getLocation())) { + if ("2".equals(model.getLocationType())) { + String[] split = house.getLocation().split(","); + Double lon = Double.valueOf(split[0]); + Double latt = Double.valueOf(split[1]); + Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); + seawater.setLocation(sub6(toBd09.get("lng")) + "," + sub6(toBd09.get("lat"))); + } else { + String location = house.getLocation(); + String[] split = location.split(","); + if (split.length == 2) { + String location1 = sub6(Double.valueOf(split[0])) + "," + sub6(Double.valueOf(split[1])); + seawater.setLocation(location1); } } - houseList.add(seawater); } + houseList.add(seawater); } + } // } else { // if ("sell".equals(cat)) { // List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); @@ -1129,6 +1140,12 @@ public class HouseController { return mav; } + Double sub6(Double a) { + BigDecimal bd = new BigDecimal(a); + BigDecimal bigDecimal = bd.setScale(6, BigDecimal.ROUND_DOWN); + return bigDecimal.doubleValue(); + } + // 格式化日期为 yyyyMMdd private static int formatDate(Calendar calendar) { int year = calendar.get(Calendar.YEAR); From f716ee45f9eea66bab5412dd4bcbdd8f66065afa Mon Sep 17 00:00:00 2001 From: shenjian Date: Thu, 5 Dec 2024 16:03:35 +0800 Subject: [PATCH 020/247] =?UTF-8?q?=E5=85=89=E5=A4=A7=E6=B6=89=E5=86=9C?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/GdBankController.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java index 304f4813b..4f46c6782 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java @@ -89,7 +89,7 @@ public class GdBankController { } /** - * 涉农识别-新规则-光大银行 + * 涉农识别-新规则-光大银行对公识别接口 * * @param model * @return @@ -108,15 +108,15 @@ public class GdBankController { JSONObject json = null; Map params = new HashMap(); params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("type", type); - params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null); + //params.put("type", type); + //params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null); params.put("address", model.getAddress()); - params.put("showFullValue", "2"); + //params.put("showFullValue", "2"); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cebEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception e) { try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cebEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception ex) { ex.printStackTrace(); } @@ -131,11 +131,14 @@ public class GdBankController { //我们省级及以上有开发区,直接用我们的结果 if (result.containsKey("devDistrictName")) { basicModel.setResult(result); - - } else if (!"2".equals(type)) { // 对私的不用齐梁 - basicModel.setResult(result); } else { try { + // 我们是县政府,且涉农结果为农,取我们结果,因为光大部分逻辑调整 + if ("是".equals(result.get("countyGov")) && "农".equals(result.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } //如果是江苏省或者浙江省 调用齐梁的结果 if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { //结果比较,如果涉农结果不一致 From 0bec20be417bedb3b1d1c0c4cc8f526227d7b2fd Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 6 Dec 2024 13:16:47 +0800 Subject: [PATCH 021/247] =?UTF-8?q?/house/around=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 6 ++ .../fangjia/dal/seawater/model/Seawater.java | 56 ++++++++++++++ .../open/controllers/HouseController.java | 74 ++++++++++--------- 3 files changed, 103 insertions(+), 33 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 4f0de8fc4..2fbbd9384 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -376,6 +376,12 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i if(source.containsKey("elevator")){ seawater.setElevator(source.getString("elevator")); } + if(source.containsKey("level")){ + seawater.setLevel(source.getString("level")); + } + if(source.containsKey("business_range")){ + seawater.setBusinessRange(source.getString("business_range")); + } try { seawater.setDistance((int)jsonList.get(i).getJSONArray("sort").getDouble(0)); }catch (Exception e){ diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index c47b1830f..225242e88 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -84,6 +84,20 @@ public class Seawater implements SeawaterEntity { private String location; + private String title; + + // 商铺经营范围 + private String businessScope; + private String businessRange; + + //商铺类型 + private String shopType; + + // 写字楼等级 + private String level; + + + @Id @Column(name = "_id") public String getId() { @@ -473,4 +487,46 @@ public class Seawater implements SeawaterEntity { public void setLocation(String location) { this.location = location; } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBusinessScope() { + return businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public String getShopType() { + return shopType; + } + + public void setShopType(String shopType) { + this.shopType = shopType; + } + + @Column(name = "level") + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + @Column(name = "business_range") + public String getBusinessRange() { + return businessRange; + } + + public void setBusinessRange(String businessRange) { + this.businessRange = businessRange; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index e643e3b3a..9b723e050 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1014,11 +1014,21 @@ public class HouseController { seawater.setCity(house.getCity()); seawater.setDistrict(house.getRegion()); seawater.setAddress(house.getAddress()); - String districtName = house.getDistrictName(); - if (!"暂无数据".equals(districtName) && StringUtils.isNotBlank(districtName)) { - seawater.setName(districtName); - }else { - seawater.setName(house.getName()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + if (cat.contains("office")){ + seawater.setLevel(house.getLevel()); + } + if (cat.contains("shop")){ + if (StringUtils.isNotBlank(house.getEstateType()) && !"其他".equals(house.getEstateType())){ + seawater.setShopType(house.getEstateType()); + } + if (StringUtils.isNotBlank(house.getBusinessRange())){ + seawater.setBusinessScope(house.getBusinessRange()); + } } seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); @@ -1029,37 +1039,36 @@ public class HouseController { seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); - if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { - seawater.setDecoration(house.getFitment()); - if (house.getpDate() != null && house.getpDate() > 10000000) { - String numberStr = String.valueOf(house.getpDate()); - // 拆分字符串并格式化 - String year = numberStr.substring(0, 4); // 前四位是年份 - String month = numberStr.substring(4, 6); // 中间两位是月份 - String day = numberStr.substring(6, 8); // 最后两位是日期 - String formattedDate = year + "-" + month + "-" + day; - seawater.setPublishDate(formattedDate); - } - seawater.setDistance(house.getDistance()); - if (StringUtils.isNotBlank(house.getLocation())) { - if ("2".equals(model.getLocationType())) { - String[] split = house.getLocation().split(","); - Double lon = Double.valueOf(split[0]); - Double latt = Double.valueOf(split[1]); - Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); - seawater.setLocation(sub6(toBd09.get("lng")) + "," + sub6(toBd09.get("lat"))); - } else { - String location = house.getLocation(); - String[] split = location.split(","); - if (split.length == 2) { - String location1 = sub6(Double.valueOf(split[0])) + "," + sub6(Double.valueOf(split[1])); - seawater.setLocation(location1); - } + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + seawater.setDistance(house.getDistance()); + if (StringUtils.isNotBlank(house.getLocation())) { + if ("2".equals(model.getLocationType())) { + String[] split = house.getLocation().split(","); + Double lon = Double.valueOf(split[0]); + Double latt = Double.valueOf(split[1]); + Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); + seawater.setLocation(sub6(toBd09.get("lng")) + "," + sub6(toBd09.get("lat"))); + } else { + String location = house.getLocation(); + String[] split = location.split(","); + if (split.length == 2) { + String location1 = sub6(Double.valueOf(split[0])) + "," + sub6(Double.valueOf(split[1])); + seawater.setLocation(location1); } } - houseList.add(seawater); } + houseList.add(seawater); } + } // } else { // if ("sell".equals(cat)) { // List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); @@ -1129,7 +1138,6 @@ public class HouseController { // } // } // } - } BasicModel basicModel = new BasicModel(200, "ok"); From 0b3e4099803b28ddcb2965b8ee3b21e83806992a Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 6 Dec 2024 16:56:31 +0800 Subject: [PATCH 022/247] =?UTF-8?q?=E5=85=89=E5=A4=A7=E6=B6=89=E5=86=9C?= =?UTF-8?q?=E5=8E=BBQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/GdBankController.java | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java index 4f46c6782..8745f5969 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java @@ -129,65 +129,65 @@ public class GdBankController { //我们的结果 JSONObject result = json.getJSONObject("result"); //我们省级及以上有开发区,直接用我们的结果 - if (result.containsKey("devDistrictName")) { - basicModel.setResult(result); - } else { - try { - // 我们是县政府,且涉农结果为农,取我们结果,因为光大部分逻辑调整 - if ("是".equals(result.get("countyGov")) && "农".equals(result.get("verifyFlag"))) { - basicModel.setResult(result); - mav.setModel(basicModel); - return mav; - } - //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { - //结果比较,如果涉农结果不一致 - //调用齐梁 type :1 对公 0 对私 - //我们 type :1 对私 2 对共 - String qltype = "2".equals(type) ? "1" : "0"; - 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")))) { - basicModel.setResult(result); - } 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); - } - - } else { - basicModel.setResult(result); - } - - } else { - basicModel.setResult(result); - - } - - } catch (Exception e) { - e.printStackTrace(); - basicModel.setResult(result); - } - - } + basicModel.setResult(result); +// if (result.containsKey("devDistrictName")) { +// } else { +// try { +// // 我们是县政府,且涉农结果为农,取我们结果,因为光大部分逻辑调整 +// if ("是".equals(result.get("countyGov")) && "农".equals(result.get("verifyFlag"))) { +// basicModel.setResult(result); +// mav.setModel(basicModel); +// return mav; +// } +// //如果是江苏省或者浙江省 调用齐梁的结果 +// if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { +// //结果比较,如果涉农结果不一致 +// //调用齐梁 type :1 对公 0 对私 +// //我们 type :1 对私 2 对共 +// String qltype = "2".equals(type) ? "1" : "0"; +// 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")))) { +// basicModel.setResult(result); +// } 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); +// } +// +// } else { +// basicModel.setResult(result); +// } +// +// } else { +// basicModel.setResult(result); +// +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// basicModel.setResult(result); +// } +// +// } } mav.setModel(basicModel); From 63ba2bf204a2f38e6b6980b1ed6bb98f35110179 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 6 Dec 2024 16:55:44 +0800 Subject: [PATCH 023/247] update --- .../script/gj/xiamen/SeaweedDataSynch.groovy | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) 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 e78bc7018..41ccc9e38 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 @@ -226,16 +226,17 @@ class SeaweedDataSynch extends BaseBatch{ for(def key : dist.mapping_alias){ if(key && !key.toString().equals("null")){ aliasNames << key - if(aliasNames.size()>5){ - map.alias = aliasNames - break; - }else{ - if(aliasNames){ - map.alias = aliasNames - } - } +// if(aliasNames.size()>5){ +// map.alias = aliasNames +// break; +// }else{ +// if(aliasNames){ +// map.alias = aliasNames +// } +// } } } + map.alias = aliasNames } if(dist.addr_alias){ @@ -243,16 +244,17 @@ class SeaweedDataSynch extends BaseBatch{ for(def key : dist.addr_alias){ if(key && !key.toString().equals("null")){ names << key - if(names.size()>5){ - map.addr_alias = names - break; - }else{ - if(names){ - map.addr_alias = names - } - } +// if(names.size()>5){ +// map.addr_alias = names +// break; +// }else{ +// if(names){ +// map.addr_alias = names +// } +// } } } + map.addr_alias = names } map.category = dist.cat From ab00d90310f58c5afe6a477e1a907b5442a4eb91 Mon Sep 17 00:00:00 2001 From: shenjian Date: Mon, 9 Dec 2024 11:15:44 +0800 Subject: [PATCH 024/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/weixin/UserController.java | 13 +++ .../fangjia/open/model/weixin/UserModel.java | 13 +++ .../src/main/webapp/user/aiLoginPage.ftl | 101 ++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java index 73e27d8a6..54431f46f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java @@ -65,6 +65,10 @@ public class UserController { return model; } + public Object aiLoginPageAction(UserModel model) { + return model; + } + //渤海银行登录 public Object bhydLoginPageAction(UserModel model, HttpServletResponse response, HttpServletRequest request) { String type = StringUtils.trimToNull(model.getType()); @@ -296,6 +300,15 @@ public class UserController { String pass = StringUtils.trimToNull(model.getPass()); String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id"); + String source = model.getSource(); + + // AI估价小程序 + if ("ai-price-mp".equals(source)) { + model.setCode(usersInfoService.randomCode()); + model.setAppId("wx30979dc8c24a82b6"); + model.setAppSecret("ec013ae42882368bf3b157545042249a"); + } + if(StringUtils.isBlank(weiXinId) && StringUtils.isNotBlank(model.getCode())){ System.out.println("小程序code:"+model.getCode()); System.out.println("小程序AppId:"+model.getAppId()); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java index 400112bfb..88d8fb971 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java @@ -22,6 +22,11 @@ public class UserModel extends BaseModel { private String appId;//测试 private String appSecret;//测试 private String sid;//测试 + + /** + * 登录来源:AI估价小程序 + */ + private String source; public List getCitys() { return citys; @@ -126,4 +131,12 @@ public class UserModel extends BaseModel { public void setPass2(String pass2) { this.pass2 = pass2; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } } diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl new file mode 100644 index 000000000..42256a7fb --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -0,0 +1,101 @@ +<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> +<#compress> + + + + + + +鐢ㄦ埛鐧诲綍 + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + + \ No newline at end of file From 433ee16dd5793afd43615447f34cf4cf6ad22936 Mon Sep 17 00:00:00 2001 From: shenjian Date: Mon, 9 Dec 2024 16:20:51 +0800 Subject: [PATCH 025/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/UserController.java | 1 - .../fangjia-open/src/main/webapp/H9YtlL0T8j.txt | 1 + .../src/main/webapp/user/aiLoginPage.ftl | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java index 54431f46f..0b4541194 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java @@ -304,7 +304,6 @@ public class UserController { // AI估价小程序 if ("ai-price-mp".equals(source)) { - model.setCode(usersInfoService.randomCode()); model.setAppId("wx30979dc8c24a82b6"); model.setAppSecret("ec013ae42882368bf3b157545042249a"); } diff --git a/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt b/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt new file mode 100644 index 000000000..a1532152f --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt @@ -0,0 +1 @@ +9995d79df0ea4a6f4d1f55fd2eeabb38 \ No newline at end of file diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index 42256a7fb..ce0b02476 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -51,6 +51,19 @@ + diff --git a/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js b/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js new file mode 100644 index 000000000..fef4b636c --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js @@ -0,0 +1,385 @@ +// JavaScript Document + +/* + Highcharts JS v5.0.6 (2016-12-07) + + (c) 2009-2016 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(L,a){"object"===typeof module&&module.exports?module.exports=L.document?a(L):a:L.Highcharts=a(L)})("undefined"!==typeof window?window:this,function(L){L=function(){var a=window,D=a.document,C=a.navigator&&a.navigator.userAgent||"",G=D&&D.createElementNS&&!!D.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,I=/(edge|msie|trident)/i.test(C)&&!window.opera,h=!G,f=/Firefox/.test(C),p=f&&4>parseInt(C.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16,!0):{product:"Highcharts", +version:"5.0.6",deg2rad:2*Math.PI/360,doc:D,hasBidiBug:p,hasTouch:D&&void 0!==D.documentElement.ontouchstart,isMS:I,isWebKit:/AppleWebKit/.test(C),isFirefox:f,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(C),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:G,vml:h,win:a,charts:[],marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){}}}();(function(a){var D=[],C=a.charts,G=a.doc,I=a.win;a.error=function(h,f){h=a.isNumber(h)?"Highcharts error #"+ +h+": www.highcharts.com/errors/"+h:h;if(f)throw Error(h);I.console&&console.log(h)};a.Fx=function(a,f,p){this.options=f;this.elem=a;this.prop=p};a.Fx.prototype={dSetter:function(){var a=this.paths[0],f=this.paths[1],p=[],v=this.now,l=a.length,u;if(1===v)p=this.toD;else if(l===f.length&&1>v)for(;l--;)u=parseFloat(a[l]),p[l]=isNaN(u)?a[l]:v*parseFloat(f[l]-u)+u;else p=f;this.elem.attr("d",p,null,!0)},update:function(){var a=this.elem,f=this.prop,p=this.now,v=this.options.step;if(this[f+"Setter"])this[f+ +"Setter"]();else a.attr?a.element&&a.attr(f,p,null,!0):a.style[f]=p+this.unit;v&&v.call(a,p,this)},run:function(a,f,p){var h=this,l=function(a){return l.stopped?!1:h.step(a)},u;this.startTime=+new Date;this.start=a;this.end=f;this.unit=p;this.now=this.start;this.pos=0;l.elem=this.elem;l.prop=this.prop;l()&&1===D.push(l)&&(l.timerId=setInterval(function(){for(u=0;u=u+this.startTime){this.now=this.end;this.pos=1;this.update();a=d[this.prop]=!0;for(c in d)!0!==d[c]&&(a=!1);a&&l&&l.call(h);h=!1}else this.pos=v.easing((f-this.startTime)/u),this.now=this.start+(this.end-this.start)*this.pos,this.update(),h=!0;return h},initPath:function(h,f,p){function v(a){var e,b;for(q=a.length;q--;)e="M"===a[q]||"L"===a[q],b=/[a-zA-Z]/.test(a[q+3]),e&&b&&a.splice(q+1,0,a[q+1],a[q+2],a[q+1],a[q+ +2])}function l(a,e){for(;a.lengthd?"AM":"PM",P:12>d?"am":"pm",S:z(l.getSeconds()),L:z(Math.round(f% +1E3),3)},a.dateFormats);for(u in v)for(;-1!==h.indexOf("%"+u);)h=h.replace("%"+u,"function"===typeof v[u]?v[u](f):v[u]);return p?h.substr(0,1).toUpperCase()+h.substr(1):h};a.formatSingle=function(h,f){var p=/\.([0-9])/,v=a.defaultOptions.lang;/f$/.test(h)?(p=(p=h.match(p))?p[1]:-1,null!==f&&(f=a.numberFormat(f,p,v.decimalPoint,-1=p&&(f=[1/p]))); +for(v=0;v=h||!l&&u<=(f[v]+(f[v+1]||f[v]))/2);v++);return d*p};a.stableSort=function(a,f){var p=a.length,h,l;for(l=0;lp&&(p=a[f]);return p};a.destroyObjectProperties=function(a,f){for(var p in a)a[p]&&a[p]!==f&&a[p].destroy&& +a[p].destroy(),delete a[p]};a.discardElement=function(h){var f=a.garbageBin;f||(f=a.createElement("div"));h&&f.appendChild(h);f.innerHTML=""};a.correctFloat=function(a,f){return parseFloat(a.toPrecision(f||14))};a.setAnimation=function(h,f){f.renderer.globalAnimation=a.pick(h,f.options.chart.animation,!0)};a.animObject=function(h){return a.isObject(h)?a.merge(h):{duration:h?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat= +function(h,f,p,v){h=+h||0;f=+f;var l=a.defaultOptions.lang,u=(h.toString().split(".")[1]||"").length,d,c,n=Math.abs(h);-1===f?f=Math.min(u,20):a.isNumber(f)||(f=2);d=String(a.pInt(n.toFixed(f)));c=3h?"-":"")+(c?d.substr(0,c)+v:"");h+=d.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+v);f&&(v=Math.abs(n-d+Math.pow(10,-Math.max(f,u)-1)),h+=p+v.toFixed(f).slice(2));return h};Math.easeInOutSine=function(a){return-.5*(Math.cos(Math.PI* +a)-1)};a.getStyle=function(h,f){return"width"===f?Math.min(h.offsetWidth,h.scrollWidth)-a.getStyle(h,"padding-left")-a.getStyle(h,"padding-right"):"height"===f?Math.min(h.offsetHeight,h.scrollHeight)-a.getStyle(h,"padding-top")-a.getStyle(h,"padding-bottom"):(h=I.getComputedStyle(h,void 0))&&a.pInt(h.getPropertyValue(f))};a.inArray=function(a,f){return f.indexOf?f.indexOf(a):[].indexOf.call(f,a)};a.grep=function(a,f){return[].filter.call(a,f)};a.find=function(a,f){return[].find.call(a,f)};a.map=function(a, +f){for(var p=[],h=0,l=a.length;hf;f++)v[f]+=h(255*a),0>v[f]&&(v[f]=0),255E.width)E={width:0, +height:0}}else E=this.htmlGetBBox();H.isSVG&&(a=E.width,H=E.height,e&&c&&"11px"===c.fontSize&&"16.9"===H.toPrecision(3)&&(E.height=H=14),g&&(E.width=Math.abs(H*Math.sin(k))+Math.abs(a*Math.cos(k)),E.height=Math.abs(H*Math.cos(k))+Math.abs(a*Math.sin(k))));if(x&&0]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a, +g,e){"string"===typeof a?e.setAttribute(g,a):a&&this.colorGradient(a,g,e)},visibilitySetter:function(a,g,e){"inherit"===a?e.removeAttribute(g):e.setAttribute(g,a)},zIndexSetter:function(a,g){var e=this.renderer,k=this.parentGroup,b=(k||e).element||e.box,c,B=this.element,H;c=this.added;var r;u(a)&&(B.zIndex=a,a=+a,this[g]===a&&(c=!1),this[g]=a);if(c){(a=this.zIndex)&&k&&(k.handleZ=!0);g=b.childNodes;for(r=0;ra||!u(a)&&u(c)||0>a&&!u(c)&&b!==e.box)&&(b.insertBefore(B, +k),H=!0);H||b.appendChild(B)}return H},_defaultSetter:function(a,g,e){e.setAttribute(g,a)}};D.prototype.yGetter=D.prototype.xGetter;D.prototype.translateXSetter=D.prototype.translateYSetter=D.prototype.rotationSetter=D.prototype.verticalAlignSetter=D.prototype.scaleXSetter=D.prototype.scaleYSetter=function(a,g){this[g]=a;this.doTransform=!0};D.prototype["stroke-widthSetter"]=D.prototype.strokeSetter=function(a,g,e){this[g]=a;this.stroke&&this["stroke-width"]?(D.prototype.fillSetter.call(this,this.stroke, +"stroke",e),e.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&&(e.removeAttribute("stroke"),this.hasStroke=!1)};C=a.SVGRenderer=function(){this.init.apply(this,arguments)};C.prototype={Element:D,SVG_NS:S,init:function(a,g,e,k,b,c){var B;k=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(k));B=k.element;a.appendChild(B);-1===a.innerHTML.indexOf("xmlns")&&h(B,"xmlns",this.SVG_NS);this.isSVG=!0; +this.box=B;this.boxWrapper=k;this.alignedObjects=[];this.url=(F||A)&&n.getElementsByTagName("base").length?R.location.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(n.createTextNode("Created with Highcharts 5.0.6"));this.defs=this.createElement("defs").add();this.allowHTML=c;this.forExport=b;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,e,!1);var H;F&&a.getBoundingClientRect&&(g=function(){v(a, +{left:0,top:0});H=a.getBoundingClientRect();v(a,{left:Math.ceil(H.left)-H.left+"px",top:Math.ceil(H.top)-H.top+"px"})},g(),this.unSubPixelFix=G(R,"resize",g))},getStyle:function(a){return this.style=t({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy(); +c(this.gradients||{});this.gradients=null;a&&(this.defs=a.destroy());this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:w,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},buildText:function(a){for(var g=a.element,e=this,k=e.forExport,c=K(a.textStr,"").toString(),r=-1!==c.indexOf("\x3c"),m=g.childNodes,w,E,q,x,d=h(g,"x"),t=a.styles,A=a.textWidth,z=t&& +t.lineHeight,l=t&&t.textOutline,F=t&&"ellipsis"===t.textOverflow,f=m.length,u=A&&!a.added&&this.box,p=function(a){var k;k=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:t&&t.fontSize||e.style.fontSize||12;return z?J(z):e.fontMetrics(k,a.getAttribute("style")?a:g).h};f--;)g.removeChild(m[f]);r||l||F||A||-1!==c.indexOf(" ")?(w=/<.*class="([^"]+)".*>/,E=/<.*style="([^"]+)".*>/,q=/<.*href="(http[^"]+)".*>/,u&&u.appendChild(g),c=r?c.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g, +'\x3cspan style\x3d"font-style:italic"\x3e').replace(//g,"\x3c/span\x3e").split(//g):[c],c=b(c,function(a){return""!==a}),y(c,function(b,c){var r,H=0;b=b.replace(/^\s+|\s+$/g,"").replace(//g,"\x3c/span\x3e|||");r=b.split("|||");y(r,function(b){if(""!==b||1===r.length){var m={},l=n.createElementNS(e.SVG_NS,"tspan"),z,f;w.test(b)&&(z=b.match(w)[1],h(l,"class",z));E.test(b)&&(f=b.match(E)[1].replace(/(;| |^)color([ :])/, +"$1fill$2"),h(l,"style",f));q.test(b)&&!k&&(h(l,"onclick",'location.href\x3d"'+b.match(q)[1]+'"'),v(l,{cursor:"pointer"}));b=(b.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"\x3c").replace(/>/g,"\x3e");if(" "!==b){l.appendChild(n.createTextNode(b));H?m.dx=0:c&&null!==d&&(m.x=d);h(l,m);g.appendChild(l);!H&&c&&(!B&&k&&v(l,{display:"block"}),h(l,"dy",p(l)));if(A){m=b.replace(/([^\^])-/g,"$1- ").split(" ");z="nowrap"===t.whiteSpace;for(var K=1A,void 0===x&&(x=u),F&&x?(N/=2,""===O||!u&&.5>N?m=[]:(O=b.substring(0,O.length+(u?-1:1)*Math.ceil(N)),m=[O+(3A&&(A=y)),m.length&& +l.appendChild(n.createTextNode(m.join(" ").replace(/- /g,"-")));a.rotation=P}H++}}})}),x&&a.attr("title",a.textStr),u&&u.removeChild(g),l&&a.applyTextOutline&&a.applyTextOutline(l)):g.appendChild(n.createTextNode(c.replace(/</g,"\x3c").replace(/>/g,"\x3e")))},getContrast:function(a){a=p(a).rgba;return 510e?k>g+B&&kr?k>g+B&&kb&&r>a+B&&rk&&r>a+B&&ra?a+3:Math.round(1.2* +a);return{h:g,b:Math.round(.8*g),f:a}},rotCorr:function(a,g,e){var b=a;g&&e&&(b=Math.max(b*Math.cos(g*d),4));return{x:-a/3*Math.sin(g*d),y:b}},label:function(a,g,e,b,c,B,r,m,w){var q=this,x=q.g("button"!==w&&"label"),d=x.text=q.text("",0,0,r).attr({zIndex:1}),H,n,l=0,A=3,z=0,F,f,K,p,J,h={},M,S,E=/^url\((.*?)\)$/.test(b),v=E,P,R,O,Q;w&&x.addClass("highcharts-"+w);v=E;P=function(){return(M||0)%2/2};R=function(){var a=d.element.style,g={};n=(void 0===F||void 0===f||J)&&u(d.textStr)&&d.getBBox();x.width= +(F||n.width||0)+2*A+z;x.height=(f||n.height||0)+2*A;S=A+q.fontMetrics(a&&a.fontSize,d).b;v&&(H||(x.box=H=q.symbols[b]||E?q.symbol(b):q.rect(),H.addClass(("button"===w?"":"highcharts-label-box")+(w?" highcharts-"+w+"-box":"")),H.add(x),a=P(),g.x=a,g.y=(m?-S:0)+a),g.width=Math.round(x.width),g.height=Math.round(x.height),H.attr(t(g,h)),h={})};O=function(){var a=z+A,g;g=m?0:S;u(F)&&n&&("center"===J||"right"===J)&&(a+={center:.5,right:1}[J]*(F-n.width));if(a!==d.x||g!==d.y)d.attr("x",a),void 0!==g&&d.attr("y", +g);d.x=a;d.y=g};Q=function(a,g){H?H.attr(a,g):h[a]=g};x.onAdd=function(){d.add(x);x.attr({text:a||0===a?a:"",x:g,y:e});H&&u(c)&&x.attr({anchorX:c,anchorY:B})};x.widthSetter=function(a){F=a};x.heightSetter=function(a){f=a};x["text-alignSetter"]=function(a){J=a};x.paddingSetter=function(a){u(a)&&a!==A&&(A=x.padding=a,O())};x.paddingLeftSetter=function(a){u(a)&&a!==z&&(z=a,O())};x.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==l&&(l=a,n&&x.attr({x:K}))};x.textSetter=function(a){void 0!== +a&&d.textSetter(a);R();O()};x["stroke-widthSetter"]=function(a,g){a&&(v=!0);M=this["stroke-width"]=a;Q(g,a)};x.strokeSetter=x.fillSetter=x.rSetter=function(a,g){"fill"===g&&a&&(v=!0);Q(g,a)};x.anchorXSetter=function(a,g){c=a;Q(g,Math.round(a)-P()-K)};x.anchorYSetter=function(a,g){B=a;Q(g,a-p)};x.xSetter=function(a){x.x=a;l&&(a-=l*((F||n.width)+2*A));K=Math.round(a);x.attr("translateX",K)};x.ySetter=function(a){p=x.y=Math.round(a);x.attr("translateY",p)};var V=x.css;return t(x,{css:function(a){if(a){var g= +{};a=k(a);y(x.textProps,function(e){void 0!==a[e]&&(g[e]=a[e],delete a[e])});d.css(g)}return V.call(x,a)},getBBox:function(){return{width:n.width+2*A,height:n.height+2*A,x:n.x-A,y:n.y-A}},shadow:function(a){a&&(R(),H&&H.shadow(a));return x},destroy:function(){N(x.element,"mouseenter");N(x.element,"mouseleave");d&&(d=d.destroy());H&&(H=H.destroy());D.prototype.destroy.call(x);x=q=R=O=Q=null}})}};a.Renderer=C})(L);(function(a){var D=a.attr,C=a.createElement,G=a.css,I=a.defined,h=a.each,f=a.extend,p= +a.isFirefox,v=a.isMS,l=a.isWebKit,u=a.pInt,d=a.SVGRenderer,c=a.win,n=a.wrap;f(a.SVGElement.prototype,{htmlCss:function(a){var c=this.element;if(c=a&&"SPAN"===c.tagName&&a.width)delete a.width,this.textWidth=c,this.updateTransform();a&&"ellipsis"===a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=f(this.styles,a);G(this.element,a);return this},htmlGetBBox:function(){var a=this.element;"text"===a.nodeName&&(a.style.position="absolute");return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth, +height:a.offsetHeight}},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,c=this.element,m=this.translateX||0,b=this.translateY||0,q=this.x||0,d=this.y||0,n=this.textAlign||"left",e={left:0,center:.5,right:1}[n],r=this.styles;G(c,{marginLeft:m,marginTop:b});this.shadows&&h(this.shadows,function(a){G(a,{marginLeft:m+1,marginTop:b+1})});this.inverted&&h(c.childNodes,function(e){a.invertChild(e,c)});if("SPAN"===c.tagName){var x=this.rotation,A=u(this.textWidth),k=r&&r.whiteSpace,w=[x, +n,c.innerHTML,this.textWidth,this.textAlign].join();w!==this.cTT&&(r=a.fontMetrics(c.style.fontSize).b,I(x)&&this.setSpanRotation(x,e,r),G(c,{width:"",whiteSpace:k||"nowrap"}),c.offsetWidth>A&&/[ \-]/.test(c.textContent||c.innerText)&&G(c,{width:A+"px",display:"block",whiteSpace:k||"normal"}),this.getSpanCorrection(c.offsetWidth,r,e,x,n));G(c,{left:q+(this.xCorr||0)+"px",top:d+(this.yCorr||0)+"px"});l&&(r=c.offsetHeight);this.cTT=w}}else this.alignOnAdd=!0},setSpanRotation:function(a,d,m){var b={}, +q=v?"-ms-transform":l?"-webkit-transform":p?"MozTransform":c.opera?"-o-transform":"";b[q]=b.transform="rotate("+a+"deg)";b[q+(p?"Origin":"-origin")]=b.transformOrigin=100*d+"% "+m+"px";G(this.element,b)},getSpanCorrection:function(a,c,m){this.xCorr=-a*m;this.yCorr=-c}});f(d.prototype,{html:function(a,c,m){var b=this.createElement("span"),q=b.element,d=b.renderer,l=d.isSVG,e=function(a,e){h(["opacity","visibility"],function(b){n(a,b+"Setter",function(a,b,c,r){a.call(this,b,c,r);e[c]=b})})};b.textSetter= +function(a){a!==q.innerHTML&&delete this.bBox;q.innerHTML=this.textStr=a;b.htmlUpdateTransform()};l&&e(b,b.element.style);b.xSetter=b.ySetter=b.alignSetter=b.rotationSetter=function(a,e){"align"===e&&(e="textAlign");b[e]=a;b.htmlUpdateTransform()};b.attr({text:a,x:Math.round(c),y:Math.round(m)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});q.style.whiteSpace="nowrap";b.css=b.htmlCss;l&&(b.add=function(a){var c,r=d.box.parentNode,k=[];if(this.parentGroup= +a){if(c=a.div,!c){for(;a;)k.push(a),a=a.parentGroup;h(k.reverse(),function(a){var m,x=D(a.element,"class");x&&(x={className:x});c=a.div=a.div||C("div",x,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},c||r);m=c.style;f(a,{on:function(){b.on.apply({element:k[0].div},arguments);return a},translateXSetter:function(e,g){m.left=e+"px";a[g]=e;a.doTransform=!0},translateYSetter:function(e,g){m.top= +e+"px";a[g]=e;a.doTransform=!0}});e(a,m)})}}else c=r;c.appendChild(q);b.added=!0;b.alignOnAdd&&b.htmlUpdateTransform();return b});return b}})})(L);(function(a){var D,C,G=a.createElement,I=a.css,h=a.defined,f=a.deg2rad,p=a.discardElement,v=a.doc,l=a.each,u=a.erase,d=a.extend;D=a.extendClass;var c=a.isArray,n=a.isNumber,y=a.isObject,t=a.merge;C=a.noop;var m=a.pick,b=a.pInt,q=a.SVGElement,z=a.SVGRenderer,F=a.win;a.svg||(C={docMode8:v&&8===v.documentMode,init:function(a,b){var e=["\x3c",b,' filled\x3d"f" stroked\x3d"f"'], +c=["position: ","absolute",";"],k="div"===b;("shape"===b||k)&&c.push("left:0;top:0;width:1px;height:1px;");c.push("visibility: ",k?"hidden":"visible");e.push(' style\x3d"',c.join(""),'"/\x3e');b&&(e=k||"span"===b||"img"===b?e.join(""):a.prepVML(e),this.element=G(e));this.renderer=a},add:function(a){var e=this.renderer,b=this.element,c=e.box,k=a&&a.inverted,c=a?a.element||a:c;a&&(this.parentGroup=a);k&&e.invertChild(b,c);c.appendChild(b);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform(); +if(this.onAdd)this.onAdd();this.className&&this.attr("class",this.className);return this},updateTransform:q.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Math.cos(a*f),c=Math.sin(a*f);I(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11\x3d",b,", M12\x3d",-c,", M21\x3d",c,", M22\x3d",b,", sizingMethod\x3d'auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,c,q,k){var e=q?Math.cos(q*f):1,r=q?Math.sin(q*f):0,x=m(this.elemHeight,this.element.offsetHeight), +d;this.xCorr=0>e&&-a;this.yCorr=0>r&&-x;d=0>e*r;this.xCorr+=r*b*(d?1-c:c);this.yCorr-=e*b*(q?d?c:1-c:1);k&&"left"!==k&&(this.xCorr-=a*c*(0>e?-1:1),q&&(this.yCorr-=x*c*(0>r?-1:1)),I(this.element,{textAlign:k}))},pathToVML:function(a){for(var e=a.length,b=[];e--;)n(a[e])?b[e]=Math.round(10*a[e])-5:"Z"===a[e]?b[e]="x":(b[e]=a[e],!a.isArc||"wa"!==a[e]&&"at"!==a[e]||(b[e+5]===b[e+7]&&(b[e+7]+=a[e+7]>a[e+5]?1:-1),b[e+6]===b[e+8]&&(b[e+8]+=a[e+8]>a[e+6]?1:-1)));return b.join(" ")||"x"},clip:function(a){var e= +this,b;a?(b=a.members,u(b,e),b.push(e),e.destroyClip=function(){u(b,e)},a=a.getCSS(e)):(e.destroyClip&&e.destroyClip(),a={clip:e.docMode8?"inherit":"rect(auto)"});return e.css(a)},css:q.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&p(a)},destroy:function(){this.destroyClip&&this.destroyClip();return q.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=F.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,c){var e;a=a.split(/[ ,]/); +e=a.length;if(9===e||11===e)a[e-4]=a[e-2]=b(a[e-2])-10*c;return a.join(" ")},shadow:function(a,c,q){var e=[],k,r=this.element,d=this.renderer,x,n=r.style,g,B=r.path,l,t,z,f;B&&"string"!==typeof B.value&&(B="x");t=B;if(a){z=m(a.width,3);f=(a.opacity||.15)/z;for(k=1;3>=k;k++)l=2*z+1-2*k,q&&(t=this.cutOffPath(B.value,l+.5)),g=['\x3cshape isShadow\x3d"true" strokeweight\x3d"',l,'" filled\x3d"false" path\x3d"',t,'" coordsize\x3d"10 10" style\x3d"',r.style.cssText,'" /\x3e'],x=G(d.prepVML(g),null,{left:b(n.left)+ +m(a.offsetX,1),top:b(n.top)+m(a.offsetY,1)}),q&&(x.cutOff=l+1),g=['\x3cstroke color\x3d"',a.color||"#000000",'" opacity\x3d"',f*k,'"/\x3e'],G(d.prepVML(g),null,null,x),c?c.element.appendChild(x):r.parentNode.insertBefore(x,r),e.push(x);this.shadows=e}return this},updateShadows:C,setAttr:function(a,b){this.docMode8?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){(this.added?this.element:this).className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]|| +G(this.renderer.prepVML(["\x3cstroke/\x3e"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var e=this.shadows;a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(e)for(c=e.length;c--;)e[c].path=e[c].cutOff?this.cutOffPath(a,e[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var e=c.nodeName;"SPAN"===e?c.style.color=a:"IMG"!==e&&(c.filled="none"!==a,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},"fill-opacitySetter":function(a,b,c){G(this.renderer.prepVML(["\x3c", +b.split("-")[0],' opacity\x3d"',a,'"/\x3e']),null,null,c)},opacitySetter:C,rotationSetter:function(a,b,c){c=c.style;this[b]=c[b]=a;c.left=-Math.round(Math.sin(a*f)+1)+"px";c.top=Math.round(Math.cos(a*f))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b,this))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;n(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&& +(a="visible");this.shadows&&l(this.shadows,function(c){c.style[b]=a});"DIV"===c.nodeName&&(a="hidden"===a?"-999em":0,this.docMode8||(c.style[b]=a?"visible":"hidden"),b="top");c.style[b]=a},xSetter:function(a,b,c){this[b]=a;"x"===b?b="left":"y"===b&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},C["stroke-opacitySetter"]=C["fill-opacitySetter"],a.VMLElement=C=D(q,C),C.prototype.ySetter=C.prototype.widthSetter=C.prototype.heightSetter= +C.prototype.xSetter,C={Element:C,isIE8:-1h[0]&&b.push([1,h[1]]);l(b,function(g,b){d.test(g[1])?(r=a.color(g[1]),B=r.get("rgb"),t=r.get("a")):(B=g[1],t=1);y.push(100*g[0]+"% "+B);b?(H=t,A=B):(F=t,u=B)});if("fill"===m)if("gradient"===x)m=z.x1||z[0]||0,b=z.y1||z[1]||0,f=z.x2||z[2]||0,z=z.y2||z[3]||0,p='angle\x3d"'+(90-180*Math.atan((z-b)/(f-m))/Math.PI)+'"', +v();else{var g=z.r,C=2*g,D=2*g,I=z.cx,U=z.cy,L=c.radialReference,T,g=function(){L&&(T=q.getBBox(),I+=(L[0]-T.x)/T.width-.5,U+=(L[1]-T.y)/T.height-.5,C*=L[2]/T.width,D*=L[2]/T.height);p='src\x3d"'+a.getOptions().global.VMLRadialGradientURL+'" size\x3d"'+C+","+D+'" origin\x3d"0.5,0.5" position\x3d"'+I+","+U+'" color2\x3d"'+u+'" ';v()};q.added?g():q.onAdd=g;g=A}else g=B}else d.test(b)&&"IMG"!==c.tagName?(r=a.color(b),q[m+"-opacitySetter"](r.get("a"),m,c),g=r.get("rgb")):(g=c.getElementsByTagName(m), +g.length&&(g[0].opacity=1,g[0].type="solid"),g=b);return g},prepVML:function(a){var b=this.isIE8;a=a.join("");b?(a=a.replace("/\x3e",' xmlns\x3d"urn:schemas-microsoft-com:vml" /\x3e'),a=-1===a.indexOf('style\x3d"')?a.replace("/\x3e",' style\x3d"display:inline-block;behavior:url(#default#VML);" /\x3e'):a.replace('style\x3d"','style\x3d"display:inline-block;behavior:url(#default#VML);')):a=a.replace("\x3c","\x3chcv:");return a},text:z.prototype.html,path:function(a){var b={coordsize:"10 10"};c(a)?b.d= +a:y(a)&&d(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var e=this.symbol("circle");y(a)&&(c=a.r,b=a.y,a=a.x);e.isCircle=!0;e.r=c;return e.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement("div").attr(b)},image:function(a,b,c,m,k){var e=this.createElement("img").attr({src:a});1t&&h-m*bc&&(e=Math.round((d-h)/Math.cos(t*p)));else if(d=h+(1-m)*b,h-m*bc&&(z=c-a.x+z*m,F=-1),z=Math.min(q, +z),zz||l.autoRotation&&(y.styles||{}).width)e=z;e&&(r.width=e,(l.options.labels.style||{}).textOverflow||(r.textOverflow="ellipsis"),y.css(r))},getPosition:function(a,f,h,d){var c=this.axis,n=c.chart,l=d&&n.oldChartHeight||n.chartHeight;return{x:a?c.translate(f+h,null,null,d)+c.transB:c.left+c.offset+(c.opposite?(d&&n.oldChartWidth||n.chartWidth)-c.right-c.left:0),y:a?l-c.bottom+c.offset-(c.opposite?c.height:0):l-c.translate(f+h,null, +null,d)-c.transB}},getLabelPosition:function(a,f,h,d,c,n,y,t){var m=this.axis,b=m.transA,q=m.reversed,z=m.staggerLines,l=m.tickRotCorr||{x:0,y:0},e=c.y;C(e)||(e=0===m.side?h.rotation?-8:-h.getBBox().height:2===m.side?l.y+8:Math.cos(h.rotation*p)*(l.y-h.getBBox(!1,0).height/2));a=a+c.x+l.x-(n&&d?n*b*(q?-1:1):0);f=f+e-(n&&!d?n*b*(q?1:-1):0);z&&(h=y/(t||1)%z,m.opposite&&(h=z-h-1),f+=m.labelOffset/z*h);return{x:a,y:Math.round(f)}},getMarkPath:function(a,f,h,d,c,n){return n.crispLine(["M",a,f,"L",a+(c? +0:-h),f+(c?h:0)],d)},render:function(a,l,h){var d=this.axis,c=d.options,n=d.chart.renderer,p=d.horiz,t=this.type,m=this.label,b=this.pos,q=c.labels,z=this.gridLine,F=t?t+"Tick":"tick",e=d.tickSize(F),r=this.mark,x=!r,A=q.step,k={},w=!0,K=d.tickmarkOffset,J=this.getPosition(p,b,K,l),u=J.x,J=J.y,g=p&&u===d.pos+d.len||!p&&J===d.pos?-1:1,B=t?t+"Grid":"grid",S=c[B+"LineWidth"],M=c[B+"LineColor"],v=c[B+"LineDashStyle"],B=f(c[F+"Width"],!t&&d.isXAxis?1:0),F=c[F+"Color"];h=f(h,1);this.isActive=!0;z||(k.stroke= +M,k["stroke-width"]=S,v&&(k.dashstyle=v),t||(k.zIndex=1),l&&(k.opacity=0),this.gridLine=z=n.path().attr(k).addClass("highcharts-"+(t?t+"-":"")+"grid-line").add(d.gridGroup));if(!l&&z&&(b=d.getPlotLinePath(b+K,z.strokeWidth()*g,l,!0)))z[this.isNew?"attr":"animate"]({d:b,opacity:h});e&&(d.opposite&&(e[0]=-e[0]),x&&(this.mark=r=n.path().addClass("highcharts-"+(t?t+"-":"")+"tick").add(d.axisGroup),r.attr({stroke:F,"stroke-width":B})),r[x?"attr":"animate"]({d:this.getMarkPath(u,J,e[0],r.strokeWidth()* +g,p,n),opacity:h}));m&&I(u)&&(m.xy=J=this.getLabelPosition(u,J,m,p,q,K,a,A),this.isFirst&&!this.isLast&&!f(c.showFirstLabel,1)||this.isLast&&!this.isFirst&&!f(c.showLastLabel,1)?w=!1:!p||d.isRadial||q.step||q.rotation||l||0===h||this.handleOverflow(J),A&&a%A&&(w=!1),w&&I(J.y)?(J.opacity=h,m[this.isNew?"attr":"animate"](J)):m.attr("y",-9999),this.isNew=!1)},destroy:function(){G(this,this.axis)}}})(L);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,I=a.arrayMin,h=a.AxisPlotLineOrBandExtension, +f=a.color,p=a.correctFloat,v=a.defaultOptions,l=a.defined,u=a.deg2rad,d=a.destroyObjectProperties,c=a.each,n=a.extend,y=a.fireEvent,t=a.format,m=a.getMagnitude,b=a.grep,q=a.inArray,z=a.isArray,F=a.isNumber,e=a.isString,r=a.merge,x=a.normalizeTickInterval,A=a.pick,k=a.PlotLineOrBand,w=a.removeEvent,K=a.splat,J=a.syncTimeout,N=a.Tick;a.Axis=function(){this.init.apply(this,arguments)};a.Axis.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M", +day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"},x:0},minPadding:.01,maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",lineColor:"#ccd6eb",lineWidth:1, +gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05,minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15}, +title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var g=b.isX;this.chart=a;this.horiz=a.inverted?!g:g;this.isXAxis=g;this.coll=this.coll||(g?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var c=this.options,e=c.type;this.labelFormatter=c.labels.formatter||this.defaultLabelFormatter; +this.userOptions=b;this.minPixelPadding=0;this.reversed=c.reversed;this.visible=!1!==c.visible;this.zoomEnabled=!1!==c.zoomEnabled;this.hasNames="category"===e||!0===c.categories;this.categories=c.categories||this.hasNames;this.names=this.names||[];this.isLog="logarithmic"===e;this.isDatetimeAxis="datetime"===e;this.isLinked=l(c.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks={};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=c.minRange||c.maxZoom; +this.range=c.range;this.offset=c.offset||0;this.stacks={};this.oldStacks={};this.stacksTouched=0;this.min=this.max=null;this.crosshair=A(c.crosshair,K(a.options.tooltip.crosshairs)[g?0:1],!1);var k;b=this.options.events;-1===q(this,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];a.inverted&&g&&void 0===this.reversed&&(this.reversed=!0);this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(k in b)D(this,k,b[k]); +this.isLog&&(this.val2lin=this.log2lin,this.lin2val=this.lin2log)},setOptions:function(a){this.options=r(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],r(v[this.coll],a))},defaultLabelFormatter:function(){var g=this.axis,b=this.value,c=g.categories,e=this.dateTimeLabelFormat,k=v.lang,m=k.numericSymbols,k=k.numericSymbolMagnitude||1E3,q=m&&m.length,d,r=g.options.labels.format, +g=g.isLog?b:g.tickInterval;if(r)d=t(r,this);else if(c)d=b;else if(e)d=a.dateFormat(e,b);else if(q&&1E3<=g)for(;q--&&void 0===d;)c=Math.pow(k,q+1),g>=c&&0===10*b%c&&null!==m[q]&&0!==b&&(d=a.numberFormat(b/c,-1)+m[q]);void 0===d&&(d=1E4<=Math.abs(b)?a.numberFormat(b,-1):a.numberFormat(b,-1,void 0,""));return d},getSeriesExtremes:function(){var a=this,e=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();c(a.series,function(g){if(g.visible|| +!e.options.chart.ignoreHiddenSeries){var c=g.options,k=c.threshold,B;a.hasVisibleSeries=!0;a.isLog&&0>=k&&(k=null);if(a.isXAxis)c=g.xData,c.length&&(g=I(c),F(g)||g instanceof Date||(c=b(c,function(a){return F(a)}),g=I(c)),a.dataMin=Math.min(A(a.dataMin,c[0]),g),a.dataMax=Math.max(A(a.dataMax,c[0]),G(c)));else if(g.getExtremes(),B=g.dataMax,g=g.dataMin,l(g)&&l(B)&&(a.dataMin=Math.min(A(a.dataMin,g),g),a.dataMax=Math.max(A(a.dataMax,B),B)),l(k)&&(a.threshold=k),!c.softThreshold||a.isLog)a.softThreshold= +!1}})},translate:function(a,b,c,e,k,m){var g=this.linkedParent||this,B=1,q=0,d=e?g.oldTransA:g.transA;e=e?g.oldMin:g.min;var r=g.minPixelPadding;k=(g.isOrdinal||g.isBroken||g.isLog&&k)&&g.lin2val;d||(d=g.transA);c&&(B*=-1,q=g.len);g.reversed&&(B*=-1,q-=B*(g.sector||g.len));b?(a=(a*B+q-r)/d+e,k&&(a=g.lin2val(a))):(k&&(a=g.val2lin(a)),a=B*(a-e)*d+q+B*r+(F(m)?d*m:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a- +(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,e,k){var g=this.chart,B=this.left,m=this.top,q,d,r=c&&g.oldChartHeight||g.chartHeight,n=c&&g.oldChartWidth||g.chartWidth,f;q=this.transB;var w=function(a,g,b){if(ab)e?a=Math.min(Math.max(g,a),b):f=!0;return a};k=A(k,this.translate(a,null,null,c));a=c=Math.round(k+q);q=d=Math.round(r-k-q);F(k)?this.horiz?(q=m,d=r-this.bottom,a=c=w(a,B,B+this.width)):(a=B,c=n-this.right,q=d=w(q,m,m+this.height)):f=!0;return f&&!e?null:g.renderer.crispLine(["M", +a,q,"L",c,d],b||1)},getLinearTickPositions:function(a,b,c){var g,k=p(Math.floor(b/a)*a),e=p(Math.ceil(c/a)*a),B=[];if(b===c&&F(b))return[b];for(b=k;b<=e;){B.push(b);b=p(b+a);if(b===g)break;g=b}return B},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,k=[],e,m=this.pointRangePadding||0;e=this.min-m;var m=this.max+m,q=m-e;if(q&&q/c=this.minRange,q,d,r,f,n,w;this.isXAxis&&void 0===this.minRange&&!this.isLog&&(l(a.min)||l(a.max)?this.minRange=null:(c(this.series,function(a){f=a.xData;for(d=n=a.xIncrement? +1:f.length-1;0=J?(N=J,t=0):g.dataMax<=J&&(v=J,w=0)),g.min=A(C,N,g.dataMin),g.max=A(D,v,g.dataMax));q&&(!b&&0>= +Math.min(g.min,A(g.dataMin,g.min))&&a.error(10,1),g.min=p(d(g.min),15),g.max=p(d(g.max),15));g.range&&l(g.max)&&(g.userMin=g.min=C=Math.max(g.min,g.minFromRange()),g.userMax=D=g.max,g.range=null);y(g,"foundExtremes");g.beforePadding&&g.beforePadding();g.adjustForMinRange();!(K||g.axisPointRange||g.usePercentage||n)&&l(g.min)&&l(g.max)&&(d=g.max-g.min)&&(!l(C)&&t&&(g.min-=d*t),!l(D)&&w&&(g.max+=d*w));F(e.floor)?g.min=Math.max(g.min,e.floor):F(e.softMin)&&(g.min=Math.min(g.min,e.softMin));F(e.ceiling)? +g.max=Math.min(g.max,e.ceiling):F(e.softMax)&&(g.max=Math.max(g.max,e.softMax));u&&l(g.dataMin)&&(J=J||0,!l(C)&&g.min=J?g.min=J:!l(D)&&g.max>J&&g.dataMax<=J&&(g.max=J));g.tickInterval=g.min===g.max||void 0===g.min||void 0===g.max?1:n&&!z&&h===g.linkedParent.options.tickPixelInterval?z=g.linkedParent.tickInterval:A(z,this.tickAmount?(g.max-g.min)/Math.max(this.tickAmount-1,1):void 0,K?1:(g.max-g.min)*h/Math.max(g.len,h));f&&!b&&c(g.series,function(a){a.processData(g.min!==g.oldMin||g.max!== +g.oldMax)});g.setAxisTranslation(!0);g.beforeSetTickPositions&&g.beforeSetTickPositions();g.postProcessTickInterval&&(g.tickInterval=g.postProcessTickInterval(g.tickInterval));g.pointRange&&!z&&(g.tickInterval=Math.max(g.pointRange,g.tickInterval));b=A(e.minTickInterval,g.isDatetimeAxis&&g.closestPointRange);!z&&g.tickIntervalg.tickInterval&&1E3g.max)),!!this.tickAmount)); +this.tickAmount||(g.tickInterval=g.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions,k=a.tickPositioner,e=a.startOnTick,m=a.endOnTick,q;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval="auto"===a.minorTickInterval&&this.tickInterval?this.tickInterval/5:a.minorTickInterval;this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval, +a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,k&&(k=k.apply(this,[this.min,this.max])))&&(this.tickPositions=b=k);this.isLinked||(this.trimTicks(b,e,m),this.min===this.max&&l(this.min)&&!this.tickAmount&&(q=!0,this.min-=.5,this.max+=.5),this.single=q,c||k||this.adjustTickAmount())}, +trimTicks:function(a,b,c){var g=a[0],k=a[a.length-1],e=this.minPointOffset||0;if(b)this.min=g;else for(;this.min-e>a[0];)a.shift();if(c)this.max=k;else for(;this.max+eb&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,k=this.finalTickAmt,e=b&&b.length;if(ec&&(this.tickInterval*=2,this.setTickPositions());if(l(k)){for(a=c=b.length;a--;)(3===k&&1===a%2||2>=k&&0k&&(a=k)),l(c)&&(bk&&(b=k))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,k=this.horiz,e=A(b.width,a.plotWidth-c+(b.offsetRight||0)),m=A(b.height,a.plotHeight),q=A(b.top,a.plotTop),b=A(b.left, +a.plotLeft+c),c=/%$/;c.test(m)&&(m=Math.round(parseFloat(m)/100*a.plotHeight));c.test(q)&&(q=Math.round(parseFloat(q)/100*a.plotHeight+a.plotTop));this.left=b;this.top=q;this.width=e;this.height=m;this.bottom=a.chartHeight-m-q;this.right=a.chartWidth-e-b;this.len=Math.max(k?e:m,0);this.pos=k?b:q},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?p(b(this.min)):this.min,max:a?p(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}}, +getThreshold:function(a){var b=this.isLog,g=this.lin2log,c=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=c:c>a?a=c:ba?"right":195a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],c=A(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(c&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,c]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style&& +this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,k=this.tickInterval,e=k,m=this.len/(((this.categories?1:0)+this.max-this.min)/k),q,d=a.rotation,r=this.labelMetrics(),f,n=Number.MAX_VALUE,w,t=function(a){a/=m||1;a=1=a)f=t(Math.abs(r.h/Math.sin(u*a))),b=f+ +Math.abs(a/360),b(c.step||0)&&!c.rotation&&(this.staggerLines||1)*a.plotWidth/k||!b&&(e&&e-a.spacing[3]||.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,k=this.tickPositions,m=this.ticks,q=this.options.labels,d=this.horiz, +f=this.getSlotWidth(),n=Math.max(1,Math.round(f-2*(q.padding||5))),w={},t=this.labelMetrics(),z=q.style&&q.style.textOverflow,h,l=0,x,F;e(q.rotation)||(w.rotation=q.rotation||0);c(k,function(a){(a=m[a])&&a.labelLength>l&&(l=a.labelLength)});this.maxLabelLength=l;if(this.autoRotation)l>n&&l>t.h?w.rotation=this.labelRotation:this.labelRotation=0;else if(f&&(h={width:n+"px"},!z))for(h.textOverflow="clip",x=k.length;!d&&x--;)if(F=k[x],n=m[F].label)n.styles&&"ellipsis"===n.styles.textOverflow?n.css({textOverflow:"clip"}): +m[F].labelLength>f&&n.css({width:f+"px"}),n.getBBox().height>this.len/k.length-(t.h-t.f)&&(n.specCss={textOverflow:"ellipsis"});w.rotation&&(h={width:(l>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},z||(h.textOverflow="ellipsis"));if(this.labelAlign=q.align||this.autoLabelAlign(this.labelRotation))w.align=this.labelAlign;c(k,function(a){var b=(a=m[a])&&a.label;b&&(b.attr(w),h&&b.css(r(h,b.specCss)),delete b.specCss,a.rotation=w.rotation)});this.tickRotCorr=b.rotCorr(t.b,this.labelRotation|| +0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||l(this.min)&&l(this.max)&&!!this.tickPositions},addTitle:function(a){var b=this.chart.renderer,g=this.horiz,c=this.opposite,k=this.options.title,e;this.axisTitle||((e=k.textAlign)||(e=(g?{low:"left",middle:"center",high:"right"}:{low:c?"right":"left",middle:"center",high:c?"left":"right"})[k.align]),this.axisTitle=b.text(k.text,0,0,k.useHTML).attr({zIndex:7,rotation:k.rotation||0,align:e}).addClass("highcharts-axis-title").css(k.style).add(this.axisGroup), +this.axisTitle.isNew=!0);this.axisTitle[a?"show":"hide"](!0)},getOffset:function(){var a=this,b=a.chart,k=b.renderer,e=a.options,m=a.tickPositions,q=a.ticks,d=a.horiz,r=a.side,n=b.inverted?[1,0,3,2][r]:r,w,f,t=0,z,h=0,x=e.title,F=e.labels,p=0,K=b.axisOffset,b=b.clipOffset,J=[-1,1,1,-1][r],u,y=e.className,v=a.axisParent,C=this.tickSize("tick");w=a.hasData();a.showAxis=f=w||A(e.showEmpty,!0);a.staggerLines=a.horiz&&F.staggerLines;a.axisGroup||(a.gridGroup=k.g("grid").attr({zIndex:e.gridZIndex||1}).addClass("highcharts-"+ +this.coll.toLowerCase()+"-grid "+(y||"")).add(v),a.axisGroup=k.g("axis").attr({zIndex:e.zIndex||2}).addClass("highcharts-"+this.coll.toLowerCase()+" "+(y||"")).add(v),a.labelGroup=k.g("axis-labels").attr({zIndex:F.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels "+(y||"")).add(v));if(w||a.isLinked)c(m,function(b){q[b]?q[b].addLabel():q[b]=new N(a,b)}),a.renderUnsquish(),!1===F.reserveSpace||0!==r&&2!==r&&{1:"left",3:"right"}[r]!==a.labelAlign&&"center"!==a.labelAlign||c(m,function(a){p= +Math.max(q[a].getLabelSize(),p)}),a.staggerLines&&(p*=a.staggerLines,a.labelOffset=p*(a.opposite?-1:1));else for(u in q)q[u].destroy(),delete q[u];x&&x.text&&!1!==x.enabled&&(a.addTitle(f),f&&(t=a.axisTitle.getBBox()[d?"height":"width"],z=x.offset,h=l(z)?0:A(x.margin,d?5:10)));a.renderLine();a.offset=J*A(e.offset,K[r]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};k=0===r?-a.labelMetrics().h:2===r?a.tickRotCorr.y:0;h=Math.abs(p)+h;p&&(h=h-k+J*(d?A(F.y,a.tickRotCorr.y+8*J):F.x));a.axisTitleMargin=A(z,h); +K[r]=Math.max(K[r],a.axisTitleMargin+t+J*a.offset,h,w&&m.length&&C?C[0]:0);e=e.offset?0:2*Math.floor(a.axisLine.strokeWidth()/2);b[n]=Math.max(b[n],e)},getLinePath:function(a){var b=this.chart,c=this.opposite,g=this.offset,k=this.horiz,e=this.left+(c?this.width:0)+g,g=b.chartHeight-this.bottom-(c?this.height:0)+g;c&&(a*=-1);return b.renderer.crispLine(["M",k?this.left:e,k?g:this.top,"L",k?b.chartWidth-this.right:e,k?g:b.chartHeight-this.bottom],a)},renderLine:function(){this.axisLine||(this.axisLine= +this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,k=this.len,e=this.options.title,m=a?b:c,q=this.opposite,d=this.offset,r=e.x||0,n=e.y||0,w=this.chart.renderer.fontMetrics(e.style&&e.style.fontSize,this.axisTitle).f,k={low:m+(a?0:k),middle:m+k/2,high:m+(a?k:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)* +(q?-1:1)*this.axisTitleMargin+(2===this.side?w:0);return{x:a?k+r:b+(q?this.width:0)+d+r,y:a?b+n-(q?this.height:0)+d:k+n}},render:function(){var a=this,b=a.chart,e=b.renderer,m=a.options,q=a.isLog,d=a.lin2log,r=a.isLinked,n=a.tickPositions,w=a.axisTitle,f=a.ticks,t=a.minorTicks,z=a.alternateBands,h=m.stackLabels,l=m.alternateGridColor,x=a.tickmarkOffset,p=a.axisLine,A=b.hasRendered&&F(a.oldMin),K=a.showAxis,u=C(e.globalAnimation),y,v;a.labelEdge.length=0;a.overlap=!1;c([f,t,z],function(a){for(var b in a)a[b].isActive= +!1});if(a.hasData()||r)a.minorTickInterval&&!a.categories&&c(a.getMinorTickPositions(),function(b){t[b]||(t[b]=new N(a,b,"minor"));A&&t[b].isNew&&t[b].render(null,!0);t[b].render(null,!1,1)}),n.length&&(c(n,function(b,c){if(!r||b>=a.min&&b<=a.max)f[b]||(f[b]=new N(a,b)),A&&f[b].isNew&&f[b].render(c,!0,.1),f[b].render(c)}),x&&(0===a.min||a.single)&&(f[-1]||(f[-1]=new N(a,-1,null,!0)),f[-1].render(-1))),l&&c(n,function(c,g){v=void 0!==n[g+1]?n[g+1]+x:a.max-x;0===g%2&&c=c.second?0:A*Math.floor(e.getMilliseconds()/A));if(x>=c.second)e[C.hcSetSeconds](x>=c.minute?0:A*Math.floor(e.getSeconds()/A));if(x>=c.minute)e[C.hcSetMinutes](x>=c.hour?0:A*Math.floor(e[C.hcGetMinutes]()/A));if(x>=c.hour)e[C.hcSetHours](x>=c.day?0:A*Math.floor(e[C.hcGetHours]()/A));if(x>=c.day)e[C.hcSetDate](x>=c.month?1:A*Math.floor(e[C.hcGetDate]()/A));x>=c.month&&(e[C.hcSetMonth](x>=c.year?0:A*Math.floor(e[C.hcGetMonth]()/A)),F=e[C.hcGetFullYear]()); +if(x>=c.year)e[C.hcSetFullYear](F-F%A);if(x===c.week)e[C.hcSetDate](e[C.hcGetDate]()-e[C.hcGetDay]()+d(m,1));F=e[C.hcGetFullYear]();m=e[C.hcGetMonth]();var w=e[C.hcGetDate](),K=e[C.hcGetHours]();if(C.hcTimezoneOffset||C.hcGetTimezoneOffset)k=(!n||!!C.hcGetTimezoneOffset)&&(t-y>4*c.month||l(y)!==l(t)),e=e.getTime(),e=new C(e+l(e));n=e.getTime();for(y=1;np&&(!l||q<=v)&&void 0!==q&&y.push(q),q>v&&(z=!0),q=b;else p=c(p),v=c(v),a=f[l?"minorTickInterval":"tickInterval"],a=h("auto"===a?null:a,this._minorAutoInterval,f.tickPixelInterval/(l?5:1)*(v-p)/((l?d/this.tickPositions.length:d)||1)),a=I(a,null,C(a)),y=G(this.getLinearTickPositions(a,p,v),n),l||(this._minorAutoInterval=a/5);l||(this.tickInterval=a);return y};D.prototype.log2lin= +function(a){return Math.log(a)/Math.LN10};D.prototype.lin2log=function(a){return Math.pow(10,a)}})(L);(function(a){var D=a.dateFormat,C=a.each,G=a.extend,I=a.format,h=a.isNumber,f=a.map,p=a.merge,v=a.pick,l=a.splat,u=a.syncTimeout,d=a.timeUnits;a.Tooltip=function(){this.init.apply(this,arguments)};a.Tooltip.prototype={init:function(a,d){this.chart=a;this.options=d;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.split=d.split&&!a.inverted;this.shared=d.shared||this.split},cleanSplit:function(a){C(this.chart.series, +function(c){var d=c&&c.tt;d&&(!d.isActive||a?c.tt=d.destroy():d.isActive=!1)})},getLabel:function(){var a=this.chart.renderer,d=this.options;this.label||(this.split?this.label=a.g("tooltip"):(this.label=a.label("",0,0,d.shape||"callout",null,null,d.useHTML,null,"tooltip").attr({padding:d.padding,r:d.borderRadius}),this.label.attr({fill:d.backgroundColor,"stroke-width":d.borderWidth}).css(d.style).shadow(d.shadow)),this.label.attr({zIndex:8}).add());return this.label},update:function(a){this.destroy(); +this.init(this.chart,p(!0,this.options,a))},destroy:function(){this.label&&(this.label=this.label.destroy());this.split&&this.tt&&(this.cleanSplit(this.chart,!0),this.tt=this.tt.destroy());clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,d,f,t){var c=this,b=c.now,q=!1!==c.options.animation&&!c.isHidden&&(1n-q?n:n-q);else if(w)b[a]=Math.max(e,g+q+k>c?g:g+q);else return!1},p=function(a,c,k,g){var e;gc-m?e=!1:b[a]=gc-k/2?c-k-2:g-k/2;return e},k=function(a){var b=h;h=e;e=b;n=a},w=function(){!1!==l.apply(0,h)?!1!==p.apply(0,e)||n||(k(!0),w()):n?b.x=b.y=0:(k(!0), +w())};(c.inverted||1w&&(q=!1);a=(c.series&&c.series.yAxis&&c.series.yAxis.pos)+(c.plotY||0);a-=m.plotTop;n.push({target:c.isHeader? +m.plotHeight+l:a,rank:c.isHeader?1:0,size:r.tt.getBBox().height+1,point:c,x:w,tt:k})});this.cleanSplit();a.distribute(n,m.plotHeight+l);C(n,function(a){var b=a.point,c=b.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:q||b.isHeader?a.x:b.plotX+m.plotLeft+v(h.distance,16),y:a.pos+m.plotTop,anchorX:b.isHeader?b.plotX+m.plotLeft:b.plotX+c.xAxis.pos,anchorY:b.isHeader?a.pos+m.plotTop-15:b.plotY+c.yAxis.pos})})},updatePosition:function(a){var c=this.chart,d=this.getLabel(),d=(this.options.positioner|| +this.getPosition).call(this,d.width,d.height,a);this.move(Math.round(d.x),Math.round(d.y||0),a.plotX+c.plotLeft,a.plotY+c.plotTop)},getXDateFormat:function(a,f,h){var c;f=f.dateTimeLabelFormats;var m=h&&h.closestPointRange,b,q={millisecond:15,second:12,minute:9,hour:6,day:3},n,l="millisecond";if(m){n=D("%m-%d %H:%M:%S.%L",a.x);for(b in d){if(m===d.week&&+D("%w",a.x)===h.options.startOfWeek&&"00:00:00.000"===n.substr(6)){b="week";break}if(d[b]>m){b=l;break}if(q[b]&&n.substr(q[b])!=="01-01 00:00:00.000".substr(q[b]))break; +"week"!==b&&(l=b)}b&&(c=f[b])}else c=f.day;return c||f.year},tooltipFooterHeaderFormatter:function(a,d){var c=d?"footer":"header";d=a.series;var f=d.tooltipOptions,m=f.xDateFormat,b=d.xAxis,q=b&&"datetime"===b.options.type&&h(a.key),c=f[c+"Format"];q&&!m&&(m=this.getXDateFormat(a,f,b));q&&m&&(c=c.replace("{point.key}","{point.key:"+m+"}"));return I(c,{point:a,series:d})},bodyFormatter:function(a){return f(a,function(a){var c=a.series.tooltipOptions;return(c.pointFormatter||a.point.tooltipFormatter).call(a.point, +c.pointFormat)})}}})(L);(function(a){var D=a.addEvent,C=a.attr,G=a.charts,I=a.color,h=a.css,f=a.defined,p=a.doc,v=a.each,l=a.extend,u=a.fireEvent,d=a.offset,c=a.pick,n=a.removeEvent,y=a.splat,t=a.Tooltip,m=a.win;a.Pointer=function(a,c){this.init(a,c)};a.Pointer.prototype={init:function(a,m){this.options=m;this.chart=a;this.runChartClick=m.chart.events&&!!m.chart.events.click;this.pinchDown=[];this.lastValidTouch={};t&&m.tooltip.enabled&&(a.tooltip=new t(a,m.tooltip),this.followTouchMove=c(m.tooltip.followTouchMove, +!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,m=b.options.chart,d=m.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=c(m.pinchType,d));this.zoomX=a=/x/.test(d);this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&&!b||a&&b;this.hasZoom=a||d},normalize:function(a,c){var b,q;a=a||m.event;a.target||(a.target=a.srcElement);q=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;c||(this.chartPosition=c=d(this.chart.container));void 0===q.pageX?(b=Math.max(a.x, +a.clientX-c.left),c=a.y):(b=q.pageX-c.left,c=q.pageY-c.top);return l(a,{chartX:Math.round(b),chartY:Math.round(c)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};v(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},runPointActions:function(b){var m=this.chart,d=m.series,f=m.tooltip,e=f?f.shared:!1,r=!0,n=m.hoverPoint,h=m.hoverSeries,k,w,l,t=[],u;if(!e&&!h)for(k=0;kb.series.index?-1:1}));if(e)for(k=t.length;k--;)(t[k].x!==t[0].x||t[k].series.noSharedTooltip)&& +t.splice(k,1);if(t[0]&&(t[0]!==this.prevKDPoint||f&&f.isHidden)){if(e&&!t[0].series.noSharedTooltip){for(k=0;kn+w&&(m=n+w),ek+h&&(e=k+h),this.hasDragged=Math.sqrt(Math.pow(g-m,2)+Math.pow(p-e,2)),10k.max&&(f=k.max-e,B=!0);B?(J-=.8*(J-n[m][0]),w||(g-=.8*(g-n[m][1])),h()):n[m]=[J, +g];A||(c[m]=r-p,c[l]=e);c=A?1/x:x;d[l]=e;d[m]=f;u[A?a?"scaleY":"scaleX":"scale"+b]=x;u["translate"+b]=c*p+(J-c*K)},pinch:function(a){var p=this,l=p.chart,u=p.pinchDown,d=a.touches,c=d.length,n=p.lastValidTouch,y=p.hasZoom,t=p.selectionMarker,m={},b=1===c&&(p.inClass(a.target,"highcharts-tracker")&&l.runTrackerClick||p.runChartClick),q={};1c-6&&h(p||b.chartWidth-2*k-B-m.x)&&(this.itemX=B,this.itemY+=g+this.lastLineHeight+y,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,e);this.lastItemY=g+this.itemY+y;this.lastLineHeight=Math.max(h,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];f?this.itemX+=e: +(this.itemY+=g+h+y,this.lastLineHeight=h);this.offsetWidth=p||Math.max((f?this.itemX-B-w:e)+k,this.offsetWidth)},getAllItems:function(){var a=[];f(this.chart.series,function(b){var c=b&&b.options;b&&d(c.showInLegend,h(c.linkedTo)?!1:void 0,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?b.data:b)))});return a},adjustMargins:function(a,b){var c=this.chart,m=this.options,n=m.align.charAt(0)+m.verticalAlign.charAt(0)+m.layout.charAt(0);m.floating||f([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/, +/(lbv|lm|ltv)/],function(e,f){e.test(n)&&!h(a[f])&&(c[l[f]]=Math.max(c[l[f]],c.legend[(f+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][f]*m[f%2?"x":"y"]+d(m.margin,12)+b[f]))})},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,h,e,r,l,t=a.box,k=a.options,w=a.padding;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;d||(a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup));a.renderTitle(); +h=a.getAllItems();n(h,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});k.reversed&&h.reverse();a.allItems=h;a.display=e=!!h.length;a.lastLineHeight=0;f(h,function(b){a.renderItem(b)});r=(k.width||a.offsetWidth)+w;l=a.lastItemY+a.lastLineHeight+a.titleHeight;l=a.handleOverflow(l);l+=w;t||(a.box=t=c.rect().addClass("highcharts-legend-box").attr({r:k.borderRadius}).add(d),t.isNew=!0);t.attr({stroke:k.borderColor,"stroke-width":k.borderWidth||0,fill:k.backgroundColor|| +"none"}).shadow(k.shadow);0c&&!1!==t.enabled?(this.clipHeight=n=Math.max(c-20-this.titleHeight-y,0),this.currentPage=d(this.currentPage,1),this.fullHeight= +a,f(B,function(a,b){var c=a._legendItemPos[1];a=Math.round(a.legendItem.getBBox().height);var k=u.length;if(!k||c-u[k-1]>n&&(g||c)!==u[k-1])u.push(g||c),k++;b===B.length-1&&c+a-u[k-1]>n&&u.push(c);c!==g&&(g=c)}),l||(l=b.clipRect=m.clipRect(0,y,9999,0),b.contentGroup.clip(l)),v(n),p||(this.nav=p=m.g().attr({zIndex:1}).add(this.group),this.up=m.symbol("triangle",0,0,w,w).on("click",function(){b.scroll(-1,k)}).add(p),this.pager=m.text("",15,10).addClass("highcharts-legend-navigation").css(t.style).add(p), +this.down=m.symbol("triangle-down",0,0,w,w).on("click",function(){b.scroll(1,k)}).add(p)),b.scroll(0),a=c):p&&(v(),p.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,b){var d=this.pages,f=d.length;a=this.currentPage+a;var m=this.clipHeight,e=this.options.navigation,h=this.pager,n=this.padding;a>f&&(a=f);0m&&(d=typeof a[0],"string"===d?c.name=a[0]:"number"===d&&(c.x=a[0]),b++);l=h.value;)h=c[++f];h&&h.color&&!this.options.color&&(this.color=h.color);return h},destroy:function(){var a=this.series.chart,c=a.hoverPoints,f;a.pointCount--;c&&(this.setState(),I(c,this),c.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)u(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(f in this)this[f]=null},destroyElements:function(){for(var a= +["graphic","dataLabel","dataLabelUpper","connector","shadowGroup"],c,f=6;f--;)c=a[f],this[c]&&(this[c]=this[c].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var c=this.series,d=c.tooltipOptions,h=l(d.valueDecimals,""),t=d.valuePrefix||"",m=d.valueSuffix||"";C(c.pointArrayMap||["y"],function(b){b="{point."+b; +if(t||m)a=a.replace(b+"}",t+b+"}"+m);a=a.replace(b+"}",b+":,."+h+"f}")});return f(a,{point:this,series:this.series})},firePointEvent:function(a,c,f){var d=this,n=this.series.options;(n.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();"click"===a&&n.allowPointSelect&&(f=function(a){d.select&&d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});h(this,a,c,f)},visible:!0}})(L);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,I=a.arrayMin,h=a.correctFloat, +f=a.Date,p=a.defaultOptions,v=a.defaultPlotOptions,l=a.defined,u=a.each,d=a.erase,c=a.extend,n=a.fireEvent,y=a.grep,t=a.isArray,m=a.isNumber,b=a.isString,q=a.merge,z=a.pick,F=a.removeEvent,e=a.splat,r=a.SVGElement,x=a.syncTimeout,A=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc", +lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3},{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0, +directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var k=this,e,d,g=a.series,f;k.chart=a;k.options=b=k.setOptions(b);k.linkedSeries=[];k.bindAxes();c(k,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});d=b.events;for(e in d)D(k,e,d[e]);if(d&&d.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;k.getColor();k.getSymbol();u(k.parallelArrays,function(a){k[a+"Data"]=[]});k.setData(b.data, +!1);k.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(f=g[g.length-1]);k._i=z(f&&f._i,-1)+1;for(a=this.insert(g);a=z(a[c].options.index,a[c]._i)){a.splice(c+1,0,this);break}-1===c&&a.unshift(this);c+=1}else a.push(this);return z(c,a.length-1)},bindAxes:function(){var b=this,c=b.options,e=b.chart,d;u(b.axisTypes||[],function(k){u(e[k],function(a){d= +a.options;if(c[k]===d.index||void 0!==c[k]&&c[k]===d.id||void 0===c[k]&&0===d.index)b.insert(a.series),b[k]=a,a.isDirty=!0});b[k]||b.optionalAxis===k||a.error(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,k=arguments,e=m(b)?function(g){var k="y"===g&&c.toYData?c.toYData(a):a[g];c[g+"Data"][b]=k}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(k,2))};u(c.parallelArrays,e)},autoIncrement:function(){var a=this.options,b=this.xIncrement,c,e=a.pointIntervalUnit, +b=z(b,a.pointStart,0);this.pointInterval=c=z(this.pointInterval,a.pointInterval,1);e&&(a=new f(b),"day"===e?a=+a[f.hcSetDate](a[f.hcGetDate]()+c):"month"===e?a=+a[f.hcSetMonth](a[f.hcGetMonth]()+c):"year"===e&&(a=+a[f.hcSetFullYear](a[f.hcGetFullYear]()+c)),c=a-b);this.xIncrement=b+c;return b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},k=b.plotOptions||{},e=c[this.type];this.userOptions=a;c=q(e,c.series,a);this.tooltipOptions=q(p.tooltip,p.plotOptions[this.type].tooltip, +b.tooltip,k.series&&k.series.tooltip,k[this.type]&&k[this.type].tooltip,a.tooltip);null===e.marker&&delete c.marker;this.zoneAxis=c.zoneAxis;a=this.zones=(c.zones||[]).slice();!c.negativeColor&&!c.negativeFillColor||c.zones||a.push({value:c[this.zoneAxis+"Threshold"]||c.threshold||0,className:"highcharts-negative",color:c.negativeColor,fillColor:c.negativeFillColor});a.length&&l(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return c},getCyclic:function(a,b,c){var k,e=this.userOptions, +g=a+"Index",d=a+"Counter",f=c?c.length:z(this.chart.options.chart[a+"Count"],this.chart[a+"Count"]);b||(k=z(e[g],e["_"+g]),l(k)||(e["_"+g]=k=this.chart[d]%f,this.chart[d]+=1),c&&(b=c[k]));void 0!==k&&(this[g]=k);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",this.options.color||v[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker, +setData:function(c,e,d,f){var k=this,g=k.points,h=g&&g.length||0,n,r=k.options,w=k.chart,l=null,q=k.xAxis,p=r.turboThreshold,x=this.xData,A=this.yData,F=(n=k.pointArrayMap)&&n.length;c=c||[];n=c.length;e=z(e,!0);if(!1!==f&&n&&h===n&&!k.cropped&&!k.hasGroupedData&&k.visible)u(c,function(a,b){g[b].update&&a!==r.data[b]&&g[b].update(a,!1,null,!1)});else{k.xIncrement=null;k.colorCounter=0;u(this.parallelArrays,function(a){k[a+"Data"].length=0});if(p&&n>p){for(d=0;null===l&&dh||this.forceCrop))if(c[e-1]p)c=[], +k=[];else if(c[0]p)d=this.cropData(this.xData,this.yData,t,p),c=d.xData,k=d.yData,d=d.start,g=!0;for(h=c.length||1;--h;)e=q?n(c[h])-n(c[h-1]):c[h]-c[h-1],0e&&this.requireSorting&&a.error(15);this.cropped=g;this.cropStart=d;this.processedXData=c;this.processedYData=k;this.closestPointRange=f},cropData:function(a,b,c,e){var k=a.length,g=0,d=k,f=z(this.cropShoulder,1),h;for(h=0;h=c){g=Math.max(0,h-f);break}for(c=h;ce){d=c+f;break}return{xData:a.slice(g, +d),yData:b.slice(g,d),start:g,end:d}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,f=this.processedYData,g=this.pointClass,h=d.length,m=this.cropStart||0,n,r=this.hasGroupedData,l,q=[],t;b||r||(b=[],b.length=a.length,b=this.data=b);for(t=0;t=d&&(c[r-1]||n)<=f,h&&n)if(h=l.length)for(;h--;)null!==l[h]&&(k[g++]= +l[h]);else k[g++]=l;this.dataMin=I(k);this.dataMax=G(k)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,b=a.stacking,c=this.xAxis,e=c.categories,d=this.yAxis,g=this.points,f=g.length,n=!!this.modifyValue,r=a.pointPlacement,t="between"===r||m(r),q=a.threshold,p=a.startFromThreshold?q:0,x,u,A,F,v=Number.MAX_VALUE;"between"===r&&(r=.5);m(r)&&(r*=z(a.pointRange||c.pointRange));for(a=0;a=D&&(y.isNull=!0);y.plotX=x=h(Math.min(Math.max(-1E5,c.translate(C,0,0,0,1,r,"flags"===this.type)),1E5));b&&this.visible&&!y.isNull&&G&&G[C]&&(F=this.getStackIndicator(F,C,this.index),I=G[C],D=I.points[F.key],u=D[0],D=D[1],u===p&&F.key===G[C].base&&(u=z(q,d.min)),d.isLog&&0>=u&&(u=null),y.total=y.stackTotal=I.total,y.percentage=I.total&&y.y/I.total*100,y.stackY=D,I.setOffset(this.pointXOffset||0,this.barW||0));y.yBottom=l(u)?d.translate(u,0, +1,0,1):null;n&&(D=this.modifyValue(D,y));y.plotY=u="number"===typeof D&&Infinity!==D?Math.min(Math.max(-1E5,d.translate(D,0,1,0,1)),1E5):void 0;y.isInside=void 0!==u&&0<=u&&u<=d.len&&0<=x&&x<=c.len;y.clientX=t?h(c.translate(C,0,0,0,1,r)):x;y.negative=y.y<(q||0);y.category=e&&void 0!==e[y.x]?e[y.x]:y.x;y.isNull||(void 0!==A&&(v=Math.min(v,Math.abs(x-A))),A=x);y.zone=this.zones.length&&y.getZone()}this.closestPointRangePx=v},getValidPoints:function(a,b){var c=this.chart;return y(a||this.points||[], +function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,e=b.renderer,k=b.inverted,g=this.clipBox,d=g||b.clipBox,f=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,d.height,c.xAxis,c.yAxis].join(),h=b[f],m=b[f+"m"];h||(a&&(d.width=0,b[f+"m"]=m=e.clipRect(-99,k?-b.plotLeft:-b.plotTop,99,k?b.chartWidth:b.chartHeight)),b[f]=h=e.clipRect(d),h.count={length:0});a&&!h.count[this.index]&&(h.count[this.index]=!0,h.count.length+= +1);!1!==c.clip&&(this.group.clip(a||g?h:b.clipRect),this.markerGroup.clip(m),this.sharedClipKey=f);a||(h.count[this.index]&&(delete h.count[this.index],--h.count.length),0===h.count.length&&f&&b[f]&&(g||(b[f]=b[f].destroy()),b[f+"m"]&&(b[f+"m"]=b[f+"m"].destroy())))},animate:function(a){var b=this.chart,c=C(this.options.animation),e;a?this.setClip(c):(e=this.sharedClipKey,(a=b[e])&&a.animate({width:b.plotSizeX},c),b[e+"m"]&&b[e+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip(); +n(this,"afterAnimate")},drawPoints:function(){var a=this.points,b=this.chart,c,e,d,g,f=this.options.marker,h,n,r,l,t=this.markerGroup,q=z(f.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>2*f.radius);if(!1!==f.enabled||this._hasPointMarkers)for(e=a.length;e--;)d=a[e],c=d.plotY,g=d.graphic,h=d.marker||{},n=!!d.marker,r=q&&void 0===h.enabled||h.enabled,l=d.isInside,r&&m(c)&&null!==d.y?(c=z(h.symbol,this.symbol),d.hasImage=0===c.indexOf("url"),r=this.markerAttribs(d,d.selected&&"select"), +g?g[l?"show":"hide"](!0).animate(r):l&&(0g&&b.shadow));d&&(d.startX=c.xMap,d.isArea=c.isArea)})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,e=this.zones,d,g,f=this.clips||[], +h,m=this.graph,n=this.area,r=Math.max(b.chartWidth,b.chartHeight),l=this[(this.zoneAxis||"y")+"Axis"],q,t,p=b.inverted,x,A,F,y,v=!1;e.length&&(m||n)&&l&&void 0!==l.min&&(t=l.reversed,x=l.horiz,m&&m.hide(),n&&n.hide(),q=l.getExtremes(),u(e,function(e,k){d=t?x?b.plotWidth:0:x?0:l.toPixels(q.min);d=Math.min(Math.max(z(g,d),0),r);g=Math.min(Math.max(Math.round(l.toPixels(z(e.value,q.max),!0)),0),r);v&&(d=g=l.toPixels(q.max));A=Math.abs(d-g);F=Math.min(d,g);y=Math.max(d,g);l.isXAxis?(h={x:p?y:F,y:0,width:A, +height:r},x||(h.x=b.plotHeight-h.x)):(h={x:0,y:p?y:F,width:r,height:A},x&&(h.y=b.plotWidth-h.y));p&&c.isVML&&(h=l.isXAxis?{x:0,y:t?F:y,height:h.width,width:b.chartWidth}:{x:h.y-b.plotLeft-b.spacingBox.x,y:0,width:h.height,height:b.chartHeight});f[k]?f[k].animate(h):(f[k]=c.clipRect(h),m&&a["zone-graph-"+k].clip(f[k]),n&&a["zone-area-"+k].clip(f[k]));v=e.value>q.max}),this.clips=f)},invertGroups:function(a){function b(){var b={width:c.yAxis.len,height:c.xAxis.len};u(["group","markerGroup"],function(e){c[e]&& +c[e].attr(b).invert(a)})}var c=this,e;c.xAxis&&(e=D(c.chart,"resize",b),D(c,"destroy",e),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,e,d){var g=this[a],k=!g;k&&(this[a]=g=this.chart.renderer.g(b).attr({zIndex:e||.1}).add(d),g.addClass("highcharts-series-"+this.index+" highcharts-"+this.type+"-series highcharts-color-"+this.colorIndex+" "+(this.options.className||"")));g.attr({visibility:c})[k?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c= +this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,e=a.options,d=!!a.animate&&b.renderer.isSVG&&C(e.animation).duration,g=a.visible?"inherit":"hidden",f=e.zIndex,h=a.hasRendered,m=b.seriesGroup,n=b.inverted;c=a.plotGroup("group","series",g,f,m);a.markerGroup=a.plotGroup("markerGroup","markers",g,f,m);d&&a.animate(!0);c.inverted=a.isCartesian?n:!1;a.drawGraph&&(a.drawGraph(),a.applyZones()); +a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(n);!1===e.clip||a.sharedClipKey||h||c.clip(b.clipRect);d&&a.animate();h||(a.animationTimeout=x(function(){a.afterAnimate()},d));a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,e=this.xAxis,d=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:z(e&& +e.left,a.plotLeft),translateY:z(d&&d.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdDimensions:1,kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,e=this.yAxis,d=this.chart.inverted;return this.searchKDTree({clientX:d?c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:d?e.len-a.chartX+e.pos:a.chartY-e.pos},b)},buildKDTree:function(){function a(c,e,g){var d,k;if(k=c&&c.length)return d=b.kdAxisArray[e%g],c.sort(function(a,b){return a[d]-b[d]}),k=Math.floor(k/ +2),{point:c[k],left:a(c.slice(0,k),e+1,g),right:a(c.slice(k+1),e+1,g)}}var b=this,c=b.kdDimensions;delete b.kdTree;x(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c)},b.options.kdNow?0:1)},searchKDTree:function(a,b){function c(a,b,f,h){var m=b.point,n=e.kdAxisArray[f%h],r,q,t=m;q=l(a[d])&&l(m[d])?Math.pow(a[d]-m[d],2):null;r=l(a[g])&&l(m[g])?Math.pow(a[g]-m[g],2):null;r=(q||0)+(r||0);m.dist=l(r)?Math.sqrt(r):Number.MAX_VALUE;m.distX=l(q)?Math.sqrt(q):Number.MAX_VALUE;n=a[n]-m[n];r= +0>n?"left":"right";q=0>n?"right":"left";b[r]&&(r=c(a,b[r],f+1,h),t=r[k]p;)q--;this.updateParallelArrays(g,"splice",q,0,0);this.updateParallelArrays(g,q);m&&g.name&&(m[p]=g.name);n.splice(q,0,a);l&&(this.data.splice(q,0,null),this.processData());"point"===e.legendType&&this.generatePoints();c&&(f[0]&&f[0].remove? +f[0].remove(!1):(f.shift(),this.updateParallelArrays(g,"shift"),n.shift()));this.isDirtyData=this.isDirty=!0;b&&h.redraw(d)},removePoint:function(a,b,c){var e=this,d=e.data,f=d[a],h=e.points,m=e.chart,n=function(){h&&h.length===d.length&&h.splice(a,1);d.splice(a,1);e.options.data.splice(a,1);e.updateParallelArrays(f||{series:e},"splice",a,1);f&&f.destroy();e.isDirty=!0;e.isDirtyData=!0;b&&m.redraw()};z(c,m);b=t(b,!0);f?f.firePointEvent("remove",null,n):n()},remove:function(a,b,c){function e(){d.destroy(); +f.isDirtyLegend=f.isDirtyBox=!0;f.linkSeries();t(a,!0)&&f.redraw(b)}var d=this,f=d.chart;!1!==c?u(d,"remove",null,e):e()},update:function(a,b){var c=this,e=this.chart,d=this.userOptions,f=this.type,h=a.type||d.type||e.options.chart.type,m=q[f].prototype,n=["group","markerGroup","dataLabelsGroup"],g;if(h&&h!==f||void 0!==a.zIndex)n.length=0;p(n,function(a){n[a]=c[a];delete c[a]});a=y(d,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1,null,!1);for(g in m)this[g]= +void 0;l(this,q[h||f].prototype);p(n,function(a){c[a]=n[a]});this.init(e,a);e.linkSeries();t(b,!0)&&e.redraw(!1)}});l(G.prototype,{update:function(a,b){var c=this.chart;a=c.options[this.coll][this.options.index]=y(this.userOptions,a);this.destroy(!0);this.init(c,l(a,{events:void 0}));c.isDirtyBox=!0;t(b,!0)&&c.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,e=this.series,d=e.length;d--;)e[d]&&e[d].remove(!1);v(b.axes,this);v(b[c],this);b.options[c].splice(this.options.index,1);p(b[c], +function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;t(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(L);(function(a){var D=a.color,C=a.each,G=a.map,I=a.pick,h=a.Series,f=a.seriesType;f("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(){var a=[],f=[],h=this.xAxis,u=this.yAxis,d=u.stacks[this.stackKey],c={},n=this.points,y=this.index,t=u.series,m=t.length,b,q=I(u.options.reversedStacks, +!0)?1:-1,z,F;if(this.options.stacking){for(z=0;za&&l>f?(l=Math.max(a,f),d=2*f-l):lI&&d>f?(d=Math.max(I,f),l=2*f-d):d=Math.abs(c)&&.5a.closestPointRange*a.xAxis.transA,h=a.borderWidth=p(f.borderWidth,h?0:1),l=a.yAxis,m=a.translatedThreshold=l.getThreshold(f.threshold),b=p(f.minPointLength, +5),q=a.getColumnMetrics(),u=q.width,F=a.barW=Math.max(u,1+2*h),e=a.pointXOffset=q.offset;c.inverted&&(m-=.5);f.pointPadding&&(F=Math.ceil(F));v.prototype.translate.apply(a);G(a.points,function(d){var f=p(d.yBottom,m),h=999+Math.abs(f),h=Math.min(Math.max(-h,d.plotY),l.len+h),k=d.plotX+e,n=F,q=Math.min(h,f),r,t=Math.max(h,f)-q;Math.abs(t)b?f-b:m-(r?b:0));d.barX=k;d.pointWidth=u;d.tooltipPos=c.inverted?[l.len+l.pos-c.plotLeft- +h,a.xAxis.len-k-n/2,t]:[k+n/2,h+l.pos-c.plotTop,t];d.shapeType="rect";d.shapeArgs=a.crispCol.apply(a,d.isNull?[d.plotX,l.len/2,0,0]:[k,q,n,t])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")},pointAttribs:function(a,c){var d=this.options,f,h=this.pointAttrToOptions||{};f=h.stroke||"borderColor";var m=h["stroke-width"]||"borderWidth",b=a&&a.color||this.color,l=a[f]||d[f]||this.color|| +b,p=a[m]||d[m]||this[m]||0,h=d.dashStyle;a&&this.zones.length&&(b=(b=a.getZone())&&b.color||a.options.color||this.color);c&&(a=d.states[c],c=a.brightness,b=a.color||void 0!==c&&C(b).brighten(a.brightness).get()||b,l=a[f]||l,p=a[m]||p,h=a.dashStyle||h);f={fill:b,stroke:l,"stroke-width":p};d.borderRadius&&(f.r=d.borderRadius);h&&(f.dashstyle=h);return f},drawPoints:function(){var a=this,c=this.chart,l=a.options,p=c.renderer,t=l.animationLimit||250,m;G(a.points,function(b){var d=b.graphic;if(h(b.plotY)&& +null!==b.y){m=b.shapeArgs;if(d)d[c.pointCountl;++l)u=p[l],a=2>l||2===l&&/%$/.test(u),p[l]=C(u,[f,I,v,p[2]][l])+(a?h:0);p[3]>p[2]&&(p[3]=p[2]);return p}}})(L);(function(a){var D=a.addEvent,C=a.defined,G=a.each,I=a.extend,h=a.inArray,f=a.noop,p=a.pick,v=a.Point,l=a.Series,u=a.seriesType,d=a.setAnimation;u("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return null===this.y? +void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c=this,d=c.points,f=c.startAngleRad;a||(G(d,function(a){var b= +a.graphic,d=a.shapeArgs;b&&(b.attr({r:a.startR||c.center[3]/2,start:f,end:f}),b.animate({r:d.r,start:d.start,end:d.end},c.options.animation))}),c.animate=null)},updateTotals:function(){var a,d=0,f=this.points,h=f.length,m,b=this.options.ignoreHiddenPoint;for(a=0;am.y&&(m.y=null),d+=b&&!m.visible?0:m.y;this.total=d;for(a=0;a1.5*Math.PI?u-=2*Math.PI:u<-Math.PI/2&&(u+=2*Math.PI);w.slicedTranslation={translateX:Math.round(Math.cos(u)*f),translateY:Math.round(Math.sin(u)*f)};b=Math.cos(u)*a[2]/2;l=Math.sin(u)*a[2]/2;w.tooltipPos=[a[0]+.7*b,a[1]+.7*l];w.half=u<-Math.PI/2||u>Math.PI/2?1:0;w.angle=u;h=Math.min(h,x/5);w.labelPos=[a[0]+b+Math.cos(u)*x,a[1]+l+Math.sin(u)*x,a[0]+b+Math.cos(u)*h,a[1]+l+Math.sin(u)* +h,a[0]+b,a[1]+l,0>x?"center":w.half?"right":"left",u]}},drawGraph:null,drawPoints:function(){var a=this,d=a.chart.renderer,f,h,m,b,l=a.options.shadow;l&&!a.shadowGroup&&(a.shadowGroup=d.g("shadow").add(a.group));G(a.points,function(c){if(null!==c.y){h=c.graphic;b=c.shapeArgs;f=c.sliced?c.slicedTranslation:{};var n=c.shadowGroup;l&&!n&&(n=c.shadowGroup=d.g("shadow").add(a.shadowGroup));n&&n.attr(f);m=a.pointAttribs(c,c.selected&&"select");h?h.setRadialReference(a.center).attr(m).animate(I(b,f)):(c.graphic= +h=d[c.shapeType](b).addClass(c.getClassName()).setRadialReference(a.center).attr(f).add(a.group),c.visible||h.attr({visibility:"hidden"}),h.attr(m).attr({"stroke-linejoin":"round"}).shadow(l,n))}})},searchPoint:f,sortByAngle:function(a,d){a.sort(function(a,c){return void 0!==a.angle&&(c.angle-a.angle)*d})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:a.CenteredSeriesMixin.getCenter,getSymbol:f},{init:function(){v.prototype.init.apply(this,arguments);var a=this,d;a.name=p(a.name,"Slice"); +d=function(c){a.slice("select"===c.type)};D(a,"select",d);D(a,"unselect",d);return a},setVisible:function(a,d){var c=this,f=c.series,m=f.chart,b=f.options.ignoreHiddenPoint;d=p(d,b);a!==c.visible&&(c.visible=c.options.visible=a=void 0===a?!c.visible:a,f.options.data[h(c,f.data)]=c.options,G(["graphic","dataLabel","connector","shadowGroup"],function(b){if(c[b])c[b][a?"show":"hide"](!0)}),c.legendItem&&m.legend.colorizeItem(c,a),a||"hover"!==c.state||c.setState(""),b&&(f.isDirty=!0),d&&m.redraw())}, +slice:function(a,f,l){var c=this.series;d(l,c.chart);p(f,!0);this.sliced=this.options.sliced=a=C(a)?a:!this.sliced;c.options.data[h(this,c.data)]=this.options;a=a?this.slicedTranslation:{translateX:0,translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r,start:c.start,end:c.end})}})})(L);(function(a){var D= +a.addEvent,C=a.arrayMax,G=a.defined,I=a.each,h=a.extend,f=a.format,p=a.map,v=a.merge,l=a.noop,u=a.pick,d=a.relativeLength,c=a.Series,n=a.seriesTypes,y=a.stableSort;a.distribute=function(a,c){function b(a,b){return a.target-b.target}var d,f=!0,h=a,e=[],m;m=0;for(d=a.length;d--;)m+=a[d].size;if(m>c){y(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(m=d=0;m<=c;)m+=a[d].size,d++;e=a.splice(d-1,a.length)}y(a,b);for(a=p(a,function(a){return{size:a.size,targets:[a.target]}});f;){for(d=a.length;d--;)f= +a[d],m=(Math.min.apply(0,f.targets)+Math.max.apply(0,f.targets))/2,f.pos=Math.min(Math.max(0,m-f.size/2),c-f.size);d=a.length;for(f=!1;d--;)0a[d].pos&&(a[d-1].size+=a[d].size,a[d-1].targets=a[d-1].targets.concat(a[d].targets),a[d-1].pos+a[d-1].size>c&&(a[d-1].pos=c-a[d-1].size),a.splice(d,1),f=!0)}d=0;I(a,function(a){var b=0;I(a.targets,function(){h[d].pos=a.pos+b;b+=h[d].size;d++})});h.push.apply(h,e);y(h,b)};c.prototype.drawDataLabels=function(){var a=this,c=a.options, +b=c.dataLabels,d=a.points,l,n,e=a.hasRendered||0,r,p,A=u(b.defer,!0),k=a.chart.renderer;if(b.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(b),p=a.plotGroup("dataLabelsGroup","data-labels",A&&!e?"hidden":"visible",b.zIndex||6),A&&(p.attr({opacity:+e}),e||D(a,"afterAnimate",function(){a.visible&&p.show(!0);p[c.animation?"animate":"attr"]({opacity:1},{duration:200})})),n=b,I(d,function(e){var d,m=e.dataLabel,q,g,t=e.connector,F=!0,x,A={};l=e.dlOptions||e.options&&e.options.dataLabels; +d=u(l&&l.enabled,n.enabled)&&null!==e.y;if(m&&!d)e.dataLabel=m.destroy();else if(d){b=v(n,l);x=b.style;d=b.rotation;q=e.getLabelConfig();r=b.format?f(b.format,q):b.formatter.call(q,b);x.color=u(b.color,x.color,a.color,"#000000");if(m)G(r)?(m.attr({text:r}),F=!1):(e.dataLabel=m=m.destroy(),t&&(e.connector=t.destroy()));else if(G(r)){m={fill:b.backgroundColor,stroke:b.borderColor,"stroke-width":b.borderWidth,r:b.borderRadius||0,rotation:d,padding:b.padding,zIndex:1};"contrast"===x.color&&(A.color=b.inside|| +0>b.distance||c.stacking?k.getContrast(e.color||a.color):"#000000");c.cursor&&(A.cursor=c.cursor);for(g in m)void 0===m[g]&&delete m[g];m=e.dataLabel=k[d?"text":"label"](r,0,-9999,b.shape,null,null,b.useHTML,null,"data-label").attr(m);m.addClass("highcharts-data-label-color-"+e.colorIndex+" "+(b.className||"")+(b.useHTML?"highcharts-tracker":""));m.css(h(x,A));m.add(p);m.shadow(b.shadow)}m&&a.alignDataLabel(e,m,b,null,F)}})};c.prototype.alignDataLabel=function(a,c,b,d,f){var m=this.chart,e=m.inverted, +l=u(a.plotX,-9999),n=u(a.plotY,-9999),p=c.getBBox(),k,q=b.rotation,t=b.align,v=this.visible&&(a.series.forceDL||m.isInsidePlot(l,Math.round(n),e)||d&&m.isInsidePlot(l,e?d.x+1:d.y+d.height-1,e)),z="justify"===u(b.overflow,"justify");v&&(k=b.style.fontSize,k=m.renderer.fontMetrics(k,c).b,d=h({x:e?m.plotWidth-n:l,y:Math.round(e?m.plotHeight-l:n),width:0,height:0},d),h(b,{width:p.width,height:p.height}),q?(z=!1,e=m.renderer.rotCorr(k,q),e={x:d.x+b.x+d.width/2+e.x,y:d.y+b.y+{top:0,middle:.5,bottom:1}[b.verticalAlign]* +d.height},c[f?"attr":"animate"](e).attr({align:t}),l=(q+720)%360,l=180l,"left"===t?e.y-=l?p.height:0:"center"===t?(e.x-=p.width/2,e.y-=p.height/2):"right"===t&&(e.x-=p.width,e.y-=l?0:p.height)):(c.align(b,null,d),e=c.alignAttr),z?this.justifyDataLabel(c,b,e,p,d,f):u(b.crop,!0)&&(v=m.isInsidePlot(e.x,e.y)&&m.isInsidePlot(e.x+p.width,e.y+p.height)),b.shape&&!q&&c.attr({anchorX:a.plotX,anchorY:a.plotY}));v||(c.attr({y:-9999}),c.placed=!1)};c.prototype.justifyDataLabel=function(a,c,b,d,f,h){var e= +this.chart,m=c.align,l=c.verticalAlign,n,k,p=a.box?0:a.padding||0;n=b.x+p;0>n&&("right"===m?c.align="left":c.x=-n,k=!0);n=b.x+d.width-p;n>e.plotWidth&&("left"===m?c.align="right":c.x=e.plotWidth-n,k=!0);n=b.y+p;0>n&&("bottom"===l?c.verticalAlign="top":c.y=-n,k=!0);n=b.y+d.height-p;n>e.plotHeight&&("top"===l?c.verticalAlign="bottom":c.y=e.plotHeight-n,k=!0);k&&(a.placed=!h,a.align(c,null,f))};n.pie&&(n.pie.prototype.drawDataLabels=function(){var d=this,f=d.data,b,h=d.chart,l=d.options.dataLabels,n= +u(l.connectorPadding,10),e=u(l.connectorWidth,1),r=h.plotWidth,v=h.plotHeight,A,k=l.distance,w=d.center,y=w[2]/2,D=w[1],G=0m-2?u:H,e),g._attr={visibility:P,align:L[6]},g._pos={x:E+l.x+({left:n,right:-n}[L[6]]||0),y:H+l.y-10},L.x=E,L.y=H,null===d.options.size&&(B=g.width,E-Br-n&& +(O[1]=Math.max(Math.round(E+B-r+n),O[1])),0>H-M/2?O[0]=Math.max(Math.round(-H+M/2),O[0]):H+M/2>v&&(O[2]=Math.max(Math.round(H+M/2-v),O[2])))}),0===C(O)||this.verifyDataLabelOverflow(O))&&(this.placeDataLabels(),G&&e&&I(this.points,function(a){var b;A=a.connector;if((g=a.dataLabel)&&g._pos&&a.visible){P=g._attr.visibility;if(b=!A)a.connector=A=h.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+a.colorIndex).add(d.dataLabelsGroup),A.attr({"stroke-width":e,stroke:l.connectorColor|| +a.color||"#666666"});A[b?"attr":"animate"]({d:d.connectorPath(a.labelPos)});A.attr("visibility",P)}else A&&(a.connector=A.destroy())}))},n.pie.prototype.connectorPath=function(a){var c=a.x,b=a.y;return u(this.options.dataLabels.softConnector,!0)?["M",c+("left"===a[6]?5:-5),b,"C",c,b,2*a[2]-a[4],2*a[3]-a[5],a[2],a[3],"L",a[4],a[5]]:["M",c+("left"===a[6]?5:-5),b,"L",a[2],a[3],"L",a[4],a[5]]},n.pie.prototype.placeDataLabels=function(){I(this.points,function(a){var c=a.dataLabel;c&&a.visible&&((a=c._pos)? +(c.attr(c._attr),c[c.moved?"animate":"attr"](a),c.moved=!0):c&&c.attr({y:-9999}))})},n.pie.prototype.alignDataLabel=l,n.pie.prototype.verifyDataLabelOverflow=function(a){var c=this.center,b=this.options,f=b.center,h=b.minSize||80,l,e;null!==f[0]?l=Math.max(c[2]-Math.max(a[1],a[3]),h):(l=Math.max(c[2]-a[1]-a[3],h),c[0]+=(a[3]-a[1])/2);null!==f[1]?l=Math.max(Math.min(l,c[2]-Math.max(a[0],a[2])),h):(l=Math.max(Math.min(l,c[2]-a[0]-a[2]),h),c[1]+=(a[0]-a[2])/2);lu(this.translatedThreshold,e.yAxis.len)),p=u(b.inside,!!this.options.stacking);m&&(f=v(m),0>f.y&&(f.height+=f.y,f.y=0),m=f.y+f.height-e.yAxis.len,0a+d||e+lc+f||h+mthis.pointCount))}, +pan:function(a,b){var c=this,e=c.hoverPoints,d;e&&p(e,function(a){a.setState()});p("xy"===b?[1,0]:[1],function(b){b=c[b?"xAxis":"yAxis"][0];var e=b.horiz,f=a[e?"chartX":"chartY"],e=e?"mouseDownX":"mouseDownY",h=c[e],k=(b.pointRange||0)/2,g=b.getExtremes(),l=b.toValue(h-f,!0)+k,k=b.toValue(h+b.len-f,!0)-k,m=kk&&0>g&&(b.setExtremes(h,l,!1,!1,{trigger:"pan"}),d=!0);c[e]=f});d&&c.redraw(!1);I(c.container, +{cursor:"move"})}});v(m.prototype,{select:function(a,b){var c=this,e=c.series,f=e.chart;a=t(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a;e.options.data[d(c,e.data)]=c.options;c.setState(a&&"select");b||p(f.getSelectedPoints(),function(a){a.selected&&a!==c&&(a.selected=a.options.selected=!1,e.options.data[d(a,e.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a,b){var c=this.series,e=c.chart,d= +e.tooltip,f=e.hoverPoint;if(this.series){if(!b){if(f&&f!==this)f.onMouseOut();if(e.hoverSeries!==c)c.onMouseOver();e.hoverPoint=this}!d||d.shared&&!c.noSharedTooltip?d||this.setState("hover"):(this.setState("hover"),d.refresh(this,a));this.firePointEvent("mouseOver")}},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;this.firePointEvent("mouseOut");b&&-1!==d(this,b)||(this.setState(),a.hoverPoint=null)},importEvents:function(){if(!this.hasImportedEvents){var a=y(this.series.options.point, +this.options).events,b;this.events=a;for(b in a)D(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var c=Math.floor(this.plotX),d=this.plotY,e=this.series,h=e.options.states[a]||{},l=f[e.type].marker&&e.options.marker,m=l&&!1===l.enabled,n=l&&l.states&&l.states[a]||{},p=!1===n.enabled,g=e.stateMarkerGraphic,q=this.marker||{},u=e.chart,y=e.halo,z,F=l&&e.markerAttribs;a=a||"";if(!(a===this.state&&!b||this.selected&&"select"!==a||!1===h.enabled||a&&(p||m&&!1===n.enabled)||a&&q.states&& +q.states[a]&&!1===q.states[a].enabled)){F&&(z=e.markerAttribs(this,a));if(this.graphic)this.state&&this.graphic.removeClass("highcharts-point-"+this.state),a&&this.graphic.addClass("highcharts-point-"+a),this.graphic.attr(e.pointAttribs(this,a)),z&&this.graphic.animate(z,t(u.options.chart.animation,n.animation,l.animation)),g&&g.hide();else{if(a&&n){l=q.symbol||e.symbol;g&&g.currentSymbol!==l&&(g=g.destroy());if(g)g[b?"animate":"attr"]({x:z.x,y:z.y});else l&&(e.stateMarkerGraphic=g=u.renderer.symbol(l, +z.x,z.y,z.width,z.height).add(e.markerGroup),g.currentSymbol=l);g&&g.attr(e.pointAttribs(this,a))}g&&(g[a&&u.isInsidePlot(c,d,u.inverted)?"show":"hide"](),g.element.point=this)}(c=h.halo)&&c.size?(y||(e.halo=y=u.renderer.path().add(F?e.markerGroup:e.group)),y[b?"animate":"attr"]({d:this.haloPath(c.size)}),y.attr({"class":"highcharts-halo highcharts-color-"+t(this.colorIndex,e.colorIndex)}),y.point=this,y.attr(v({fill:this.color||e.color,"fill-opacity":c.opacity,zIndex:-1},c.attributes))):y&&y.point&& +y.point.haloPath&&y.animate({d:y.point.haloPath(0)});this.state=a}},haloPath:function(a){return this.series.chart.renderer.symbols.circle(Math.floor(this.plotX)-a,this.plotY-a,2*a,2*a)}});v(b.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&l(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;b.hoverSeries=null;if(d)d.onMouseOut(); +this&&a.events.mouseOut&&l(this,"mouseOut");!c||a.stickyTracking||c.shared&&!this.noSharedTooltip||c.hide();this.setState()},setState:function(a){var b=this,c=b.options,d=b.graph,f=c.states,h=c.lineWidth,c=0;a=a||"";if(b.state!==a&&(p([b.group,b.markerGroup],function(c){c&&(b.state&&c.removeClass("highcharts-series-"+b.state),a&&c.addClass("highcharts-series-"+a))}),b.state=a,!f[a]||!1!==f[a].enabled)&&(a&&(h=f[a].lineWidth||h+(f[a].lineWidthPlus||0)),d&&!d.dashstyle))for(f={"stroke-width":h},d.attr(f);b["zone-graph-"+ +c];)b["zone-graph-"+c].attr(f),c+=1},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,h=d.options.chart.ignoreHiddenSeries,m=c.visible;f=(c.visible=a=c.options.visible=c.userOptions.visible=void 0===a?!m:a)?"show":"hide";p(["group","dataLabelsGroup","markerGroup","tracker","tt"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c||(d.hoverPoint&&d.hoverPoint.series)===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&p(d.series,function(a){a.options.stacking&& +a.visible&&(a.isDirty=!0)});p(c.linkedSeries,function(b){b.setVisible(a,!1)});h&&(d.isDirtyBox=!0);!1!==b&&d.redraw();l(c,f)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=void 0===a?!this.selected:a;this.checkbox&&(this.checkbox.checked=a);l(this,a?"select":"unselect")},drawTracker:a.drawTrackerGraph})})(L);(function(a){var D=a.Chart,C=a.each,G=a.inArray,I=a.isObject,h=a.pick,f=a.splat;D.prototype.setResponsive=function(a){var f=this.options.responsive; +f&&f.rules&&C(f.rules,function(f){this.matchResponsiveRule(f,a)},this)};D.prototype.matchResponsiveRule=function(f,v){var l=this.respRules,p=f.condition,d;d=p.callback||function(){return this.chartWidth<=h(p.maxWidth,Number.MAX_VALUE)&&this.chartHeight<=h(p.maxHeight,Number.MAX_VALUE)&&this.chartWidth>=h(p.minWidth,0)&&this.chartHeight>=h(p.minHeight,0)};void 0===f._id&&(f._id=a.uniqueKey());d=d.call(this);!l[f._id]&&d?f.chartOptions&&(l[f._id]=this.currentOptions(f.chartOptions),this.update(f.chartOptions, +v)):l[f._id]&&!d&&(this.update(l[f._id],v),delete l[f._id])};D.prototype.currentOptions=function(a){function h(a,d,c){var l,p;for(l in a)if(-1 - + diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index fd5351b5d..1dba2a851 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -381,7 +381,7 @@ <#include '/layout/footer.ftl'/> - + + From 38978bac8f4605754c7db991e98dc94d3542605e Mon Sep 17 00:00:00 2001 From: shenjian Date: Wed, 18 Dec 2024 10:55:33 +0800 Subject: [PATCH 045/247] =?UTF-8?q?=E5=8C=BA=E5=88=86=E5=AF=B9=E5=85=AC?= =?UTF-8?q?=E5=AF=B9=E7=A7=81=E6=B6=89=E5=86=9C=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 224 +++++++++++++++++- 1 file changed, 223 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 f00d7c267..f9b9ec857 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 @@ -778,7 +778,229 @@ public class AddrSvcController { return mav; } - /** + /** + * 对私涉农识别 + */ + public Object residentialVillageIdentify(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + // 对公 + model.setType("1"); + String villageType = "2".equals(model.getType()) ? "对公" : "对私"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + 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(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + //我们的结果 + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + } + return mav; + } + + /** + * 对公涉农识别 + */ + public Object enterpriseVillageIdentify(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + // 对公 + model.setType("2"); + String villageType = "2".equals(model.getType()) ? "对公" : "对私"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + 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(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + //我们的结果 + JSONObject result = json.getJSONObject("result"); + //我们省级及以上有开发区,直接用我们的结果 + if (result.containsKey("devDistrictName")) { + basicModel.setResult(result); + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); + } else { + try { + //如果是江苏省或者浙江省 调用齐梁的结果 + if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + + //结果比较,如果涉农结果不一致 + //调用齐梁 type :1 对公 0 对私 + //我们 type :1 对私 2 对共 + String qltype = "2".equals(type) ? "1" : "0"; + 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")))) { + 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); + } + + } else { + basicModel.setResult(result); + } + + } else { + basicModel.setResult(result); + + } + + } catch (Exception e) { + e.printStackTrace(); + basicModel.setResult(result); + } + + } + + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + } + return mav; + } + + /** * 涉农识别-新规则-基础版本 * * @param model From ee8d15a0985a0e5063fc0c1a1b644bf541e8a4b7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 18 Dec 2024 10:58:22 +0800 Subject: [PATCH 046/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/commData/CommonDatautils.groovy | 4 ++-- .../script/gj/data_handle/NewGaoDePoiBatch.groovy | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 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 42b0e3dc2..4656356ff 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 @@ -4209,13 +4209,13 @@ class CommonDatautils { static def findAllNewPoiDatas(city){ - String sql = "select pname,cityname,adname,name,address,location,type,id from poi_amap_2024 where cityname='${city}'" + String sql = "select pname,cityname,adname,name,address,location,type,id,parent from poi_amap_2024 where cityname='${city}'" def rets = [] def index= 0 ElasticUtils.executeSqlQuery(sql, { map-> // if(map.address && map.address.contains("五角场")){ index++ - rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y] + rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y, "parent_id":map.parent] // } }) return rets; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 822eee441..a749b5541 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -40,11 +40,12 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { run() +// oldPoiMagre() } def run(){ if (CommonDatautils.isWindow()) { - TAGS = getAllPoiType("D:\\数据\\福建省_POI_GCJ02_20240630\\POI分类白名单.xlsx") + TAGS = getAllPoiType("D:\\数据\\数据建设\\Poi\\POI分类白名单.xlsx") }else{ TAGS = getAllPoiType("/home/goojia/gj/POI_TYPES.xlsx") } @@ -145,6 +146,7 @@ class NewGaoDePoiBatch extends BaseBatch{ saveObj.data_id = map.map_id saveObj.data_source = "高德地图" saveObj.data_source_year = "2024-11" + saveObj.parent_id = map.parent_id if(saveObj.cat && TAGS.contains(saveObj.cat)){ saveObj.status = 0 @@ -314,7 +316,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("didata_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { @@ -346,4 +348,8 @@ class NewGaoDePoiBatch extends BaseBatch{ } + def oldPoiMagre(){ + + } + } From 110fc4003f136b9c80e8174511e12060bf8249dd Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 18 Dec 2024 11:05:59 +0800 Subject: [PATCH 047/247] =?UTF-8?q?=E6=8D=A2=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/commData/CommonDatautils.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4656356ff..8e7863c2e 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 @@ -4209,7 +4209,7 @@ class CommonDatautils { static def findAllNewPoiDatas(city){ - String sql = "select pname,cityname,adname,name,address,location,type,id,parent from poi_amap_2024 where cityname='${city}'" + String sql = "select pname,cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" def rets = [] def index= 0 ElasticUtils.executeSqlQuery(sql, { map-> From 33c08fd17f62e381da535be27ca4599da61a1d21 Mon Sep 17 00:00:00 2001 From: shenjian Date: Wed, 18 Dec 2024 11:26:26 +0800 Subject: [PATCH 048/247] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/AddrSvcController.java | 4 ++-- 1 file changed, 2 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 f9b9ec857..0cb2d58f6 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 @@ -781,7 +781,7 @@ public class AddrSvcController { /** * 对私涉农识别 */ - public Object residentialVillageIdentify(AddressModel model) { + public Object residentialVillageIdentifyAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); @@ -863,7 +863,7 @@ public class AddrSvcController { /** * 对公涉农识别 */ - public Object enterpriseVillageIdentify(AddressModel model) { + public Object enterpriseVillageIdentifyAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); From e25ef8822f0828ef6450ec3a64027e9021c23bad Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 18 Dec 2024 14:06:50 +0800 Subject: [PATCH 049/247] =?UTF-8?q?UserController=20=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/weixin/UserController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java index 7437ed56e..460a95e78 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java @@ -338,10 +338,10 @@ public class UserController { } //测试时可以先去掉 -// if (StringUtils.isBlank(username) || StringUtils.isBlank(pass) || StringUtils.isBlank(weiXinId)){ -// resultModel.setMsg(Message.PARAM_NOT_NULL); -// return resultModel; -// } + if (StringUtils.isBlank(username) || StringUtils.isBlank(pass) || StringUtils.isBlank(weiXinId)){ + resultModel.setMsg(Message.PARAM_NOT_NULL); + return resultModel; + } try { FjtUsers user = usersInfoService.enterpriseLogin(username, pass); From 6521433267f038319bfabc15a53862d61327545f Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 18 Dec 2024 15:19:17 +0800 Subject: [PATCH 050/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/weixin/DistrictController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index 937384fc0..a6b5943bb 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -187,7 +187,9 @@ public class DistrictController { // } // } SeaweedImages seaweedImages = seaweedImagesService.findById(district.getId()); - district.setOutPics(seaweedImages.getOutPics()); + if (seaweedImages != null) { + district.setOutPics(seaweedImages.getOutPics()); + } districtModel.setDistrict(district); districtModel.setDistrictStatBo(districtStatBo); districtModel.setDistrictStatRentBos(districtStatRentBos); From 9b98d1c8e64aac9481e035c23a970ab2b0d8106a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 18 Dec 2024 17:04:54 +0800 Subject: [PATCH 051/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/weixin/DistrictController.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index a6b5943bb..3ddeeaaeb 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -102,6 +102,23 @@ public class DistrictController { return model; } + /** + * 获取小区图片 + * + * @param districtModel + * @return + */ + public Object listPicAction(DistrictModel districtModel) { + if (StringUtils.isBlank(districtModel.getId())) { + return null; + } + SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); + if (seaweedImages != null) { + return seaweedImages.getOutPics(); + } + return null; + } + private List getDistrictByKeyword(String cat, String city, String keyword, int limit, final Double lng, final Double lat) { keyword = DataUtil.escapeSolr(keyword); From 6cda247c8d37f5c65095220dbc5866a14435b97b Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 18 Dec 2024 18:31:33 +0800 Subject: [PATCH 052/247] =?UTF-8?q?=E8=AF=84=E4=BC=B0=E9=A1=B5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia-open/src/main/webapp/district/districtDetail.ftl | 2 +- projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index d1f3b86cd..49cf33ecf 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -65,7 +65,7 @@
灏忓尯绉熼噾
-

+

<#if districtStatRentBos?? && districtStatRentBos?size gt 0> <#list districtStatRentBos as districtStatRentBo>

<#if districtStatRentBo.districtStatRent??>${districtStatRentBo.districtStatRent.avgPrice} 鍏�/鏈�

diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 1f48d1dc5..dec6ff49f 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -100,7 +100,7 @@ placeholder="璇疯緭鍏ユ墍鍦ㄦゼ灞�" min="1" max="200"> + placeholder="璇疯緭鍏ユゼ灞傛弿杩�">
From e02d91bf57c1a2f2c60d79f596c25d08ac94c7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 19 Dec 2024 09:42:26 +0800 Subject: [PATCH 053/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/DistrictController.java | 29 +++++++++++++++++++ .../weixin/DistrictController.java | 16 ---------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index 90bd877e3..a35805605 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -12,6 +12,7 @@ import com.fangjia.dal.mongo.model.*; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.model.AvgPriceQueryModel; import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.weixin.DistrictModel; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.service.datastore.RegionStatService; import com.fangjia.service.district.DistrictFacilitysService; @@ -20,6 +21,7 @@ import com.fangjia.service.district.RegionStatRentService; import com.fangjia.service.mongo.fangjia.AverageAnalyService; import com.fangjia.service.mongo.fangjia.RegionBlockService; +import com.fangjia.service.mongo.fangjia.SeaweedImagesService; import net.sf.json.JSONArray; import net.sf.json.JSONException; import net.sf.json.JSONObject; @@ -95,6 +97,7 @@ public class DistrictController { private RegionStatService regionStatService; private RegionStatRentService regionStatRentService; private DistrictFacilitysService districtFacilitysService; + private SeaweedImagesService seaweedImagesService; public static final String[] COLUMNS = { "id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", @@ -1168,6 +1171,28 @@ public class DistrictController { return mav; } + /** + * 获取小区图片 + * + * @param districtModel + * @return + */ + public Object listPicAction(DistrictModel districtModel) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(districtModel.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); + if (seaweedImages != null) { + mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages.getOutPics())); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "图片数据不存在")); + } + return mav; + } + public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception{ RestfulModelAndView mav = new RestfulModelAndView(); @@ -1288,4 +1313,8 @@ public class DistrictController { public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { this.districtFacilitysService = districtFacilitysService; } + + public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { + this.seaweedImagesService = seaweedImagesService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index 3ddeeaaeb..ed11d51ae 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -102,22 +102,6 @@ public class DistrictController { return model; } - /** - * 获取小区图片 - * - * @param districtModel - * @return - */ - public Object listPicAction(DistrictModel districtModel) { - if (StringUtils.isBlank(districtModel.getId())) { - return null; - } - SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); - if (seaweedImages != null) { - return seaweedImages.getOutPics(); - } - return null; - } private List getDistrictByKeyword(String cat, String city, String keyword, int limit, final Double lng, final Double lat) { From 02eeab9399abe1ca2d12f2d7094e93cbc30cad22 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 11:19:30 +0800 Subject: [PATCH 054/247] =?UTF-8?q?=E6=97=A7poi=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/NewGaoDePoiBatch.groovy | 168 +++++++++++++++++- 1 file changed, 166 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index a749b5541..fa7fa0ac7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.util.GeoUtils import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher @@ -8,13 +9,19 @@ import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.ProvinceData +import com.mongodb.BasicDBObject +import org.apache.commons.io.FileUtils 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 +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService @@ -39,8 +46,8 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { - run() -// oldPoiMagre() +// run() + oldPoiMagre() } def run(){ @@ -349,7 +356,164 @@ class NewGaoDePoiBatch extends BaseBatch{ } def oldPoiMagre(){ + def cityList = CommonDatautils.findFullNameCitys().reverse() + for(def cityObj : cityList){ +// if(!cityObj.city.contains("固原")){ +// continue +// } + def fileName = "/home/goojia/gj/poi/poi/${cityObj.city}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" + } + File file=new File(fileName); + if(file.exists()){ + def results = readCSV(fileName) + println cityObj.province+" " +cityObj.city+" "+results.size() + if(results){ + def megerMap = poiRepeat(cityObj.city, results) + save(megerMap.values()) + } + } + } + } + + def poiRepeat(city, oldPois){ + def rets = new ConcurrentHashMap() + + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(oldPois.size()) + def townMap = CommonDatautils.queryTownByCity(city) + def esMap = findEsPoiByCity(city) + + println "Es 加载完成:"+new Date().format("yyyy-MM-dd HH:mm:ss") + for(def i=0;i + def district = "" + if(d.district){ + district = d.district + } + def regionMap = map.get(district) + if(!regionMap){ + regionMap = new HashMap() + } + def o = new BasicDBObject() + o.put("city", d.city) + o.put("district", d.district) + o.put("name", d.name) + o.put("township", d.township) + o.put("location", d.location) + regionMap.put(d.name.replace("-","").replace("·",""), o) + map.put(district, regionMap) + }) + return map + } + + + def readCSV(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + for(line in lines) { + if(line){ + String[] arrs = line.split("\\|@\\|") + def o = new BasicDBObject() + o.put("province",arrs[0]) + o.put("city" , arrs[1]) + o.put("district",arrs[2]) + o.put("name",arrs[3]) + o.put("township",arrs[4]) + o.put("address",arrs[5]) + o.put("cat",arrs[6]) + o.put("type",arrs[7]) + o.put("secondary_type",arrs[8]) + o.put("small_type" ,arrs[9]) + if(arrs[10]){ + o.put("data_id",arrs[10]) + }else{ + o.put("data_id",arrs[11]) + } + + o.put("spell_name",arrs[12]) + def location = [:] + if(arrs[13]){ + location.lon = arrs[13].toString().toDouble() + location.lat = arrs[14].toString().toDouble() + } + o.put("location",location) + o.put("data_source",arrs[15]) + o.put("status",arrs[16]) + o.put("version",arrs[17]) + rets << o + } + } + return rets; } } From c5c222c45ca8260e32b6f179f7cfdc8345d9cab6 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 11:30:18 +0800 Subject: [PATCH 055/247] =?UTF-8?q?=E8=AF=84=E4=BC=B0=E9=A1=B5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/sql/model/FjtEvaluation.java | 11 +++ .../src/main/webapp/static/js/select.js | 70 +++++++++---------- .../src/main/webapp/weiXinEvaluation/form.ftl | 28 ++++++-- .../main/webapp/weiXinEvaluation/report.ftl | 67 +++++++++--------- 4 files changed, 104 insertions(+), 72 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java index 4b72f411c..90af3ec7e 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java @@ -92,6 +92,8 @@ public class FjtEvaluation implements SqlEntity{ private String contact; private String reportNum; private Double carSiteArea; + + private Integer carSitePrice; // 车位价 private String source; private String accountChecker; private String floorDesc; //别墅楼层描述 @@ -783,6 +785,15 @@ public class FjtEvaluation implements SqlEntity{ this.loan = loan; } + @Column(name = "car_site_price") + public Integer getCarSitePrice() { + return carSitePrice; + } + + public void setCarSitePrice(Integer carSitePrice) { + this.carSitePrice = carSitePrice; + } + @Override public String toString() { return "FjtEvaluation{" + diff --git a/projects/fangjia-open/src/main/webapp/static/js/select.js b/projects/fangjia-open/src/main/webapp/static/js/select.js index 1202c4ad6..6adecdba3 100644 --- a/projects/fangjia-open/src/main/webapp/static/js/select.js +++ b/projects/fangjia-open/src/main/webapp/static/js/select.js @@ -66,41 +66,41 @@ $(document).on('click', '.create-actions01', function () { $.actions(groups); }); - -// 閫夋嫨鎿嶄綔-鎴垮瀷-瀹� -$(document).on('click', '.create-actions01', function () { - var buttons1 = [ - { - text: '璇烽�夋嫨瀹�', - label: true - } - ]; - for (var i = 1; i < 6; i++) { - buttons1.push({ - text: i + '', - onClick: function () { - $("#room").val(this.text) - $(".create-actions01").empty().text(this.text).addClass("selected") - } - }) - } - buttons1.push({ - text: '>5', - onClick: function () { - $("#room").val("") - $(".create-actions01").empty().text(">5") - } - }) - - var buttons2 = [ - { - text: '鍙栨秷', - bg: 'gray' - } - ]; - var groups = [buttons1, buttons2]; - $.actions(groups); -}); +// +// // 閫夋嫨鎿嶄綔-鎴垮瀷-瀹� +// $(document).on('click', '.create-actions01', function () { +// var buttons1 = [ +// { +// text: '璇烽�夋嫨瀹�', +// label: true +// } +// ]; +// for (var i = 1; i < 6; i++) { +// buttons1.push({ +// text: i + '', +// onClick: function () { +// $("#room").val(this.text) +// $(".create-actions01").empty().text(this.text).addClass("selected") +// } +// }) +// } +// buttons1.push({ +// text: '>5', +// onClick: function () { +// $("#room").val("") +// $(".create-actions01").empty().text(">5") +// } +// }) +// +// var buttons2 = [ +// { +// text: '鍙栨秷', +// bg: 'gray' +// } +// ]; +// var groups = [buttons1, buttons2]; +// $.actions(groups); +// }); // 閫夋嫨鎿嶄綔-鎴垮瀷-鍙� $(document).on('click', '.create-actions02', function () { diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index dec6ff49f..f9bc96179 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -211,13 +211,33 @@ +<#--
  • --> +<#-- --> +<#--
  • -->
  • -
    -
    杞︿綅鎯呭喌锛�
    - -

    璇烽�夋嫨杞︿綅鎯呭喌

    +
    杞︿綅闈㈢Н锛�
    +
    + +
    +
    +
    +
  • +
  • +
    +
    +
    杞︿綅浠凤細
    +
    +
    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index 1dba2a851..7ba706719 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -209,21 +209,22 @@ -

    -

    -

    - <#if role?? && role==16> -

    - - - <#if fjtEvaluation.onlyOne! == 1> - 鏄� - <#elseif fjtEvaluation.onlyOne! == 2> - 鍚� - <#else> - - - - -

    - +

    <#if fjtEvaluation.carSitePrice??>${fjtEvaluation.carSitePrice!}涓囧厓<#else>-

    + <#--

    -

    --> +<#-- <#if role?? && role==16>--> +<#--

    --> +<#-- --> +<#-- --> +<#-- <#if fjtEvaluation.onlyOne! == 1>--> +<#-- 鏄�--> +<#-- <#elseif fjtEvaluation.onlyOne! == 2>--> +<#-- 鍚�--> +<#-- <#else>--> +<#-- - --> +<#-- --> +<#-- --> +<#--

    --> +<#-- -->

    @@ -273,10 +274,7 @@

    <#if fjtEvaluation.gardenArea??>${fjtEvaluation.gardenArea!?string('0.##')}骞崇背<#else>-

    <#if fjtEvaluation.outerArea??>${fjtEvaluation.outerArea!?string('0.##')}骞崇背<#else>-

    -

    <#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}骞崇背<#else>-

    - <#if fjtEvaluation.city! == "涓婃捣"> -

    ${fjtEvaluation.loopLine!}

    - +

    <#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}骞崇背<#else>-

    @@ -326,20 +324,23 @@

    <#if fjtEvaluation.basementArea??&&(fjtEvaluation.basementArea!>0)>${fjtEvaluation.basementArea!?string('0.##')}骞崇背<#else>-

    <#if fjtEvaluation.basementArea??&&(fjtEvaluation.atticArea!>0)>${fjtEvaluation.atticArea!?string('0.##')}骞崇背<#else>-

    -

    - - - <#if fjtEvaluation.carport! == 1> - 宸茬 - <#elseif fjtEvaluation.carport! == 3> - 宸茶喘 - <#elseif fjtEvaluation.carport! == 2> - 鏆傛棤 - <#else> - - - - -

    + <#if fjtEvaluation.city! == "涓婃捣"> +

    ${fjtEvaluation.loopLine!}

    + + <#--

    --> +<#-- --> +<#-- --> +<#-- <#if fjtEvaluation.carport! == 1>--> +<#-- 宸茬--> +<#-- <#elseif fjtEvaluation.carport! == 3>--> +<#-- 宸茶喘--> +<#-- <#elseif fjtEvaluation.carport! == 2>--> +<#-- 鏆傛棤--> +<#-- <#else>--> +<#-- ---> +<#-- --> +<#-- --> +<#--

    -->
    鍏ㄩ儴淇℃伅
    From 27f27c2f0fdda9411151fe23c3a441ef5f62dd7c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 11:31:57 +0800 Subject: [PATCH 056/247] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index fa7fa0ac7..60ff6fe3c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -365,6 +365,7 @@ class NewGaoDePoiBatch extends BaseBatch{ if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } + println fileName File file=new File(fileName); if(file.exists()){ def results = readCSV(fileName) @@ -373,6 +374,8 @@ class NewGaoDePoiBatch extends BaseBatch{ def megerMap = poiRepeat(cityObj.city, results) save(megerMap.values()) } + }else{ + println fileName +" 不存在" } } } From a98613692f1718d06eed81c916da44cdf47c7fb9 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 11:46:10 +0800 Subject: [PATCH 057/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 60ff6fe3c..d65f086bf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -361,7 +361,7 @@ class NewGaoDePoiBatch extends BaseBatch{ // if(!cityObj.city.contains("固原")){ // continue // } - def fileName = "/home/goojia/gj/poi/poi/${cityObj.city}.csv" + def fileName = "/home/goojia/gj/poi/old_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } From 0defcebdafd2d68b3198184317ba717b6ffa7143 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 15:25:35 +0800 Subject: [PATCH 058/247] =?UTF-8?q?=E7=A7=9F=E9=87=91=E6=8C=82=E7=89=8C?= =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 91 +++++++++++++++++++ .../fangjia/open/model/HouseSearchModel.java | 10 ++ 2 files changed, 101 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 9b723e050..68e6d22d3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1147,6 +1147,97 @@ public class HouseController { mav.setViewType("rest"); return mav; } + public Object rentAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize()<0) { + mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); + return mav; + } + if (StringUtils.isNotBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + + // 获取当前日期 + Calendar today = Calendar.getInstance(); + + // 复制一份当前日期,用于计算半年前的日期 + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // 减去 6 个月 + sixMonthsAgo.add(Calendar.MONTH, -6); + + // 格式化日期为 yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + + List houses = null; + List houseList = new ArrayList(); +// if (cat.contains("_")) { + // 商铺,写字楼有经纬度,直接查 + SeawaterQuery query = new SeawaterQuery(); + query.setCat("rent"); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicModel basicModel = new BasicModel(200, "ok"); + // 组装数据 + basicModel.setResult(houseList); + mav.setModel(basicModel); + mav.setViewType("rest"); + return mav; + } Double sub6(Double a) { BigDecimal bd = new BigDecimal(a); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index a78519c7a..987f6f3d2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -23,6 +23,8 @@ public class HouseSearchModel extends SearchModel { private String propertyType; private String houseType; + + private String district; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -177,4 +179,12 @@ public class HouseSearchModel extends SearchModel { public void setHouseType(String houseType) { this.houseType = houseType; } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } } From 2d626b5930bea667945ef392e5560d6010bba8ce Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 16:20:55 +0800 Subject: [PATCH 059/247] =?UTF-8?q?=E7=A7=9F=E9=87=91=E6=8C=82=E7=89=8C?= =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 1674 +++++++++-------- .../open/controllers/HouseController.java | 4 +- 2 files changed, 840 insertions(+), 838 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 2fbbd9384..39a29c099 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -17,520 +17,520 @@ import org.sothis.core.util.Pager; public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl implements SeawaterDao { - private static final String ES_USER = "developer"; - private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; + private static final String ES_USER = "developer"; + private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; - @Override - public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String table) { - int count = queryCount(null,category,city,region,name,alias,regionAlias,startDate,endDate,room,root,null,false,-1,-1,table); - return count; - } + @Override + public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String table) { + int count = queryCount(null, category, city, region, name, alias, regionAlias, startDate, endDate, room, root, null, false, -1, -1, table); + return count; + } - @Override - public Seawater findByIdFromEs(String id,String table) { - Seawater seawater = null; - SeawaterQuery query = new SeawaterQuery(); - query.setId(id); - query.setTable(table); - Pager pager = new Pager(); - pager.setStartRow(-1); - pager.setPageSize(-1); - query.setPager(pager); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - List seawaterList = wrapSeawater(jsonList); - if(seawaterList.size() > 0){ - seawater = seawaterList.get(0); - } - } - return seawater; - } + @Override + public Seawater findByIdFromEs(String id, String table) { + Seawater seawater = null; + SeawaterQuery query = new SeawaterQuery(); + query.setId(id); + query.setTable(table); + Pager pager = new Pager(); + pager.setStartRow(-1); + pager.setPageSize(-1); + query.setPager(pager); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + List seawaterList = wrapSeawater(jsonList); + if (seawaterList.size() > 0) { + seawater = seawaterList.get(0); + } + } + return seawater; + } - @Override - public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { - List seawaterList= new ArrayList(); - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setStartArea(startArea); - query.setEndArea(endArea); - query.setStartPrice(startPrice); - query.setEndPrice(endPrice); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } + @Override + public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + List seawaterList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setStartArea(startArea); + query.setEndArea(endArea); + query.setStartPrice(startPrice); + query.setEndPrice(endPrice); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } - @Override - public List findSeawatersByQuery(SeawaterQuery query){ - List seawaterList; - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } + @Override + public List findSeawatersByQuery(SeawaterQuery query) { + List seawaterList; + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } - @Override - public long findSeawatersCountByQuery(SeawaterQuery query) { - int count = queryCount(query); - return count; - } + @Override + public long findSeawatersCountByQuery(SeawaterQuery query) { + int count = queryCount(query); + return count; + } - @Override - public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { - JSONObject reqBody = new JSONObject(); - reqBody.put("from", 0); - reqBody.put("size", limit); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addMatch("city", city)); - must.add(addMatch("region", region)); - must.add(addTerms("district_name", alias)); - must.add(addMatch("cat", "sell")); - must.add(addRange("avg_price", minPrice, maxPrice)); - must.add(addRangeGte("p_date", 20210501)); + @Override + public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { + JSONObject reqBody = new JSONObject(); + reqBody.put("from", 0); + reqBody.put("size", limit); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addMatch("city", city)); + must.add(addMatch("region", region)); + must.add(addTerms("district_name", alias)); + must.add(addMatch("cat", "sell")); + must.add(addRange("avg_price", minPrice, maxPrice)); + must.add(addRangeGte("p_date", 20210501)); - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return Collections.emptyList(); - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return wrapSeawater(results); + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return Collections.emptyList(); + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return wrapSeawater(results); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return new ArrayList(); - } + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return new ArrayList(); + } - @Override - public void deleteById(String id) { - deleteByIds(Arrays.asList(id)); - } + @Override + public void deleteById(String id) { + deleteByIds(Arrays.asList(id)); + } - private Map buildHeader() { - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic " + authenticationEncoding + ""); - return headers; - } + private Map buildHeader() { + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + return headers; + } - @Override - public void deleteByIds(List idList) { - HttpRequest request = new HttpRequest(); + @Override + public void deleteByIds(List idList) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = new JSONObject(); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addTerms("_id", idList)); - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); + JSONObject reqBody = new JSONObject(); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addTerms("_id", idList)); + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - @Override - public void batchDeleteByParams(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); + @Override + public void batchDeleteByParams(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = wrapQueryParams(query); + JSONObject reqBody = wrapQueryParams(query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - script.put("lang", "painless"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + script.put("lang", "painless"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - @Override - public void batchUpdateEstateType(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); + @Override + public void batchUpdateEstateType(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = wrapQueryParams(query); + JSONObject reqBody = wrapQueryParams(query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.estate_type="+"'"+query.getEditEstateType()+"'"); - script.put("lang", "painless"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.estate_type=" + "'" + query.getEditEstateType() + "'"); + script.put("lang", "painless"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - private JSONObject addMatch(String name, String value){ - JSONObject term = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - term.put("match", match); - return term; - } + private JSONObject addMatch(String name, String value) { + JSONObject term = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + term.put("match", match); + return term; + } - private JSONObject addTerms(String name, List value){ - JSONObject terms = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - terms.put("terms", match); - return terms; - } + private JSONObject addTerms(String name, List value) { + JSONObject terms = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + terms.put("terms", match); + return terms; + } - private JSONObject addRange(String name, Number min, Number max){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gt", min); - rangeValue.put("lt", max); - range.put(name, rangeValue); - term.put("range", range); - return term; - } + private JSONObject addRange(String name, Number min, Number max) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gt", min); + rangeValue.put("lt", max); + range.put(name, rangeValue); + term.put("range", range); + return term; + } - private JSONObject addRangeGte(String name, Number min){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gte", min); - range.put(name, rangeValue); - term.put("range", range); - return term; - } + private JSONObject addRangeGte(String name, Number min) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gte", min); + range.put(name, rangeValue); + term.put("range", range); + return term; + } - private List wrapSeawater(List jsonList){ - List seawaterList= new ArrayList(); - for(int i=0 ;i < jsonList.size(); i++){ - Seawater seawater = new Seawater(); - seawater.setId(jsonList.get(i).getString("_id")); - JSONObject source = jsonList.get(i).getJSONObject("_source"); - seawater.setCategory(source.getString("cat")); - seawater.setCity(source.getString("city")); - seawater.setRegion(source.getString("region")); - seawater.setDistrictName(source.getString("district_name")); - if (source.containsKey("location")){ - String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); - seawater.setLocation(location); - } - if(source.containsKey("address")){ - seawater.setAddress(source.getString("address")); - } - if(source.containsKey("name")){ - seawater.setName(source.getString("name")); - } - if(source.containsKey("direction")){ - seawater.setDirection(source.getString("direction")); - } - if(source.containsKey("block")){ - seawater.setBlock(source.getString("block")); - } - try{ - seawater.setTotalPrice(source.getInt("total_price")); - }catch(NumberFormatException e){ - seawater.setTotalPrice(0); - } - try{ - seawater.setArea(source.getDouble("area")); - }catch(NumberFormatException e){ - seawater.setArea(0d); - } - try{ - seawater.setHeight(source.getInt("height")); - }catch(Exception e){ - seawater.setHeight(0); - } - try{ - seawater.setFloor(source.getInt("floor")); - }catch(Exception e){ - seawater.setFloor(0); - } - try{ - seawater.setFloorInfo(source.getString("floor_info")); - }catch(Exception e){ - - } - if(source.containsKey("fitment")){ - seawater.setFitment(source.getString("fitment")); - } - try{ - seawater.setRoom(source.getInt("room")); - }catch(Exception e){ - seawater.setRoom(0); - } - try{ - seawater.setHall(source.getInt("hall")); - }catch(Exception e){ - seawater.setHall(0); - } - try{ - seawater.setToilet(source.getInt("toilet")); - }catch(Exception e){ - seawater.setToilet(0); - } - try{ - seawater.setpDate(source.getInt("p_date")); - }catch(Exception e){ - seawater.setpDate(0); - } - if(source.containsKey("url")){ - seawater.setUrl(source.getString("url")); - } - if(source.containsKey("avg_price")){ - seawater.setAvgPrice(source.getInt("avg_price")); - } - if(source.containsKey("root")){ - seawater.setRoot(source.getString("root")); - } - - if(source.containsKey("estate_type")){ - seawater.setEstateType(source.getString("estate_type")); - } - - if(source.containsKey("build_type")){ - seawater.setBuildType(source.getString("build_type")); - } - if(source.containsKey("status")){ - seawater.setStatus(source.getInt("status")); - } - - if(source.containsKey("lift")){ - seawater.setLift(source.getInt("lift")); - } - - if(source.containsKey("lift_household")){ - seawater.setLiftHousehold(source.getInt("lift_household")); - } - - if(source.containsKey("room_structure")){ - seawater.setRoomStructure(source.getString("room_structure")); - } - - if(source.containsKey("trade_property")){ - seawater.setTradeProperty(source.getString("trade_property")); - } - if(source.containsKey("property_ownership")){ - seawater.setPropertyOwnership(source.getString("property_ownership")); - } - if(source.containsKey("housing_age")){ - seawater.setHousingAge(source.getString("housing_age")); - } - if(source.containsKey("elevator")){ - seawater.setElevator(source.getString("elevator")); - } - if(source.containsKey("level")){ - seawater.setLevel(source.getString("level")); - } - if(source.containsKey("business_range")){ - seawater.setBusinessRange(source.getString("business_range")); - } + private List wrapSeawater(List jsonList) { + List seawaterList = new ArrayList(); + for (int i = 0; i < jsonList.size(); i++) { + Seawater seawater = new Seawater(); + seawater.setId(jsonList.get(i).getString("_id")); + JSONObject source = jsonList.get(i).getJSONObject("_source"); + seawater.setCategory(source.getString("cat")); + seawater.setCity(source.getString("city")); + seawater.setRegion(source.getString("region")); + seawater.setDistrictName(source.getString("district_name")); + if (source.containsKey("location")) { + String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); + seawater.setLocation(location); + } + if (source.containsKey("address")) { + seawater.setAddress(source.getString("address")); + } + if (source.containsKey("name")) { + seawater.setName(source.getString("name")); + } + if (source.containsKey("direction")) { + seawater.setDirection(source.getString("direction")); + } + if (source.containsKey("block")) { + seawater.setBlock(source.getString("block")); + } try { - seawater.setDistance((int)jsonList.get(i).getJSONArray("sort").getDouble(0)); - }catch (Exception e){ + seawater.setTotalPrice(source.getInt("total_price")); + } catch (NumberFormatException e) { + seawater.setTotalPrice(0); + } + try { + seawater.setArea(source.getDouble("area")); + } catch (NumberFormatException e) { + seawater.setArea(0d); + } + try { + seawater.setHeight(source.getInt("height")); + } catch (Exception e) { + seawater.setHeight(0); + } + try { + seawater.setFloor(source.getInt("floor")); + } catch (Exception e) { + seawater.setFloor(0); + } + try { + seawater.setFloorInfo(source.getString("floor_info")); + } catch (Exception e) { + + } + if (source.containsKey("fitment")) { + seawater.setFitment(source.getString("fitment")); + } + try { + seawater.setRoom(source.getInt("room")); + } catch (Exception e) { + seawater.setRoom(0); + } + try { + seawater.setHall(source.getInt("hall")); + } catch (Exception e) { + seawater.setHall(0); + } + try { + seawater.setToilet(source.getInt("toilet")); + } catch (Exception e) { + seawater.setToilet(0); + } + try { + seawater.setpDate(source.getInt("p_date")); + } catch (Exception e) { + seawater.setpDate(0); + } + if (source.containsKey("url")) { + seawater.setUrl(source.getString("url")); + } + if (source.containsKey("avg_price")) { + seawater.setAvgPrice(source.getInt("avg_price")); + } + if (source.containsKey("root")) { + seawater.setRoot(source.getString("root")); + } + + if (source.containsKey("estate_type")) { + seawater.setEstateType(source.getString("estate_type")); + } + + if (source.containsKey("build_type")) { + seawater.setBuildType(source.getString("build_type")); + } + if (source.containsKey("status")) { + seawater.setStatus(source.getInt("status")); + } + + if (source.containsKey("lift")) { + seawater.setLift(source.getInt("lift")); + } + + if (source.containsKey("lift_household")) { + seawater.setLiftHousehold(source.getInt("lift_household")); + } + + if (source.containsKey("room_structure")) { + seawater.setRoomStructure(source.getString("room_structure")); + } + + if (source.containsKey("trade_property")) { + seawater.setTradeProperty(source.getString("trade_property")); + } + if (source.containsKey("property_ownership")) { + seawater.setPropertyOwnership(source.getString("property_ownership")); + } + if (source.containsKey("housing_age")) { + seawater.setHousingAge(source.getString("housing_age")); + } + if (source.containsKey("elevator")) { + seawater.setElevator(source.getString("elevator")); + } + if (source.containsKey("level")) { + seawater.setLevel(source.getString("level")); + } + if (source.containsKey("business_range")) { + seawater.setBusinessRange(source.getString("business_range")); + } + try { + seawater.setDistance((int) jsonList.get(i).getJSONArray("sort").getDouble(0)); + } catch (Exception e) { seawater.setDistance(null); } - seawaterList.add(seawater); + seawaterList.add(seawater); } - return seawaterList; - } + return seawaterList; + } - private JSONObject query(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, - Integer room, String root,String sort, boolean order, int start, int limit,String table){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); + private JSONObject query(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, + Integer room, String root, String sort, boolean order, int start, int limit, String table) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); JSONObject q = new JSONObject(); JSONObject query = new JSONObject(); List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(id)) { - JSONObject param = new JSONObject(); - param.put("_id", id); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(category)) { - JSONObject param = new JSONObject(); - param.put("cat", category); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(id)) { + JSONObject param = new JSONObject(); + param.put("_id", id); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(category)) { + JSONObject param = new JSONObject(); + param.put("cat", category); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(name)) { - namesList.add(name); - } - if (alias != null) { - namesList.addAll(alias); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(name)) { + namesList.add(name); + } + if (alias != null) { + namesList.addAll(alias); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(region)) { - regionsList.add(region); - } - if (regionAlias != null) { - regionsList.addAll(regionAlias); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(region)) { + regionsList.add(region); + } + if (regionAlias != null) { + regionsList.addAll(regionAlias); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(city)){ - JSONObject param = new JSONObject(); - param.put("city", city); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(room != null) { - JSONObject param = new JSONObject(); - param.put("room", room); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(root)) { - JSONObject param = new JSONObject(); - param.put("root", root); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(city)) { + JSONObject param = new JSONObject(); + param.put("city", city); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (room != null) { + JSONObject param = new JSONObject(); + param.put("room", room); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(root)) { + JSONObject param = new JSONObject(); + param.put("root", root); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(startDate != null || endDate != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startDate != null){ - temp2.put("gte", startDate); - } - if(endDate != null){ - temp2.put("lte", endDate); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startDate != null || endDate != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startDate != null) { + temp2.put("gte", startDate); + } + if (endDate != null) { + temp2.put("lte", endDate); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startArea != null || endArea != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startArea != null){ - temp2.put("gte", startArea); - } - if(endArea != null){ - temp2.put("lte", endArea); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startArea != null || endArea != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startArea != null) { + temp2.put("gte", startArea); + } + if (endArea != null) { + temp2.put("lte", endArea); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startPrice != null || endPrice != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startPrice != null){ - temp2.put("gte", startPrice); - } - if(endPrice != null){ - temp2.put("lte", endPrice); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startPrice != null || endPrice != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startPrice != null) { + temp2.put("gte", startPrice); + } + if (endPrice != null) { + temp2.put("lte", endPrice); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(sort)){ - JSONObject jsonOrder = new JSONObject(); - if(order){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(sort, jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } + if (StringUtils.isNotBlank(sort)) { + JSONObject jsonOrder = new JSONObject(); + if (order) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(sort, jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } - if(start >= 0){ + if (start >= 0) { reqBody.put("from", start); } - if(limit >= 0){ + if (limit >= 0) { reqBody.put("size", limit); } @@ -544,239 +544,241 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i query.put("must", jsonList); q.put("bool", query); reqBody.put("query", q); - //用户名:密码 + //用户名:密码 Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); HttpRequest request = new HttpRequest(); Map headers = new HashMap(); headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+table+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + String response = request.postWithBody("http://es.fangjia.com:9200/" + table + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); JSONObject json = JSONObject.fromObject(response); long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); + System.out.println(time2 - time1); return json; } catch (HttpRequestException e) { e.printStackTrace(); } return null; - } + } - private JSONObject query(SeawaterQuery query){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - Double lat = query.getLat(); - Double lng = query.getLng(); - Integer radius = query.getRadius(); - JSONObject filter = new JSONObject(); - // 添加地理位置过滤器和排序 - if (lat != null && lng != null && radius != null) { - // 1. 设置地理位置参数 - JSONObject geoDistanceParam = new JSONObject(); - geoDistanceParam.put("lat", lat); - geoDistanceParam.put("lon", lng); + private JSONObject query(SeawaterQuery query) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + Double lat = query.getLat(); + Double lng = query.getLng(); + Integer radius = query.getRadius(); + JSONObject filter = new JSONObject(); + // 添加地理位置过滤器和排序 + if (lat != null && lng != null && radius != null) { + // 1. 设置地理位置参数 + JSONObject geoDistanceParam = new JSONObject(); + geoDistanceParam.put("lat", lat); + geoDistanceParam.put("lon", lng); - // 2. 设置 geo_distance 过滤器,限制结果在指定的半径范围内 + // 2. 设置 geo_distance 过滤器,限制结果在指定的半径范围内 - JSONObject geoDistance = new JSONObject(); - geoDistance.put("distance", radius + "m"); // 半径设置为 3000km - geoDistance.put("location", geoDistanceParam); // 使用给定的经纬度 - filter.put("geo_distance", geoDistance); + JSONObject geoDistance = new JSONObject(); + geoDistance.put("distance", radius + "m"); // 半径设置为 3000km + geoDistance.put("location", geoDistanceParam); // 使用给定的经纬度 + filter.put("geo_distance", geoDistance); - // 3. 构建查询体 + // 3. 构建查询体 // filter.put("filter", geoDistanceFilter); // jsonList.add(filter); // reqBody.put("query", filter); - // 4. 添加按距离排序的部分 - JSONObject geoDistanceSort = new JSONObject(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("order", "asc"); - jsonObject.put("location", geoDistanceParam); - jsonObject.put("unit", "m"); - jsonObject.put("distance_type", "arc"); - geoDistanceSort.put("_geo_distance", jsonObject); - // 5. 将排序部分添加到请求体 - List sortJsonList = new ArrayList(); - sortJsonList.add(geoDistanceSort); - reqBody.put("sort", sortJsonList); - } - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + // 4. 添加按距离排序的部分 + JSONObject geoDistanceSort = new JSONObject(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("order", "asc"); + jsonObject.put("location", geoDistanceParam); + jsonObject.put("unit", "m"); + jsonObject.put("distance_type", "arc"); + geoDistanceSort.put("_geo_distance", jsonObject); + // 5. 将排序部分添加到请求体 + List sortJsonList = new ArrayList(); + sortJsonList.add(geoDistanceSort); + reqBody.put("sort", sortJsonList); + } + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if (query.getDistrictAlias() != null) { - namesList.addAll(query.getDistrictAlias()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (query.getDistrictAlias() != null) { + namesList.addAll(query.getDistrictAlias()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getSortField())){ - JSONObject jsonOrder = new JSONObject(); - if(query.getOrder()){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(query.getSortField(), jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } + if (StringUtils.isNotBlank(query.getSortField())) { + JSONObject jsonOrder = new JSONObject(); + if (query.getOrder()) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(query.getSortField(), jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } - if(query.getPager().getStartRow() >= 0){ - reqBody.put("from", query.getPager().getStartRow()); - } - if(query.getPager().getPageSize() >= 0){ - reqBody.put("size", query.getPager().getPageSize()); - } + if (query.getPager().getStartRow() >= 0) { + reqBody.put("from", query.getPager().getStartRow()); + } + if (query.getPager().getPageSize() >= 0) { + reqBody.put("size", query.getPager().getPageSize()); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - ArrayList filterList = new ArrayList(); - filterList.add(filter); - queryJson.put("filter", filterList); - q.put("bool", queryJson); - reqBody.put("query", q); - //用户名:密码 - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+query.getTable()+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); - return json; - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return null; - } + queryJson.put("must", jsonList); + ArrayList filterList = new ArrayList(); + if (filter.size() > 0) { + filterList.add(filter); + queryJson.put("filter", filterList); + } + q.put("bool", queryJson); + reqBody.put("query", q); + //用户名:密码 + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/" + query.getTable() + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + long time2 = System.currentTimeMillis(); + System.out.println(time2 - time1); + return json; + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return null; + } // private List queryList(String id,String category, String city, String region, String name, List alias, // List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){ @@ -793,188 +795,188 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i // return results; // } - private List queryList(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return null; - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return results; - } + private List queryList(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return null; + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return results; + } - private int queryCount(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String sort, boolean order, int start, int limit,String table){ - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ + private int queryCount(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { return 0; } return json.getJSONObject("hits").getInt("total"); - } + } - private int queryCount(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ - return 0; - } - return json.getJSONObject("hits").getInt("total"); - } + private int queryCount(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { + return 0; + } + return json.getJSONObject("hits").getInt("total"); + } - private JSONObject wrapQueryParams(SeawaterQuery query){ - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + private JSONObject wrapQueryParams(SeawaterQuery query) { + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - q.put("bool", queryJson); - reqBody.put("query", q); - return reqBody; - } + queryJson.put("must", jsonList); + q.put("bool", queryJson); + reqBody.put("query", q); + return reqBody; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 68e6d22d3..84994dbee 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1150,11 +1150,11 @@ public class HouseController { public Object rentAction(final HouseSearchModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); - if (model.getSize()<0) { + if (model.getSize()!= null && model.getSize()<0) { mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); return mav; } - if (StringUtils.isNotBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); return mav; } From 2c1f3c043a81bca353348f75f1b8065e27a26686 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 16:25:31 +0800 Subject: [PATCH 060/247] update --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index d65f086bf..3dc4ffbca 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -361,7 +361,7 @@ class NewGaoDePoiBatch extends BaseBatch{ // if(!cityObj.city.contains("固原")){ // continue // } - def fileName = "/home/goojia/gj/poi/old_poi/${cityObj.city}.csv" + def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } From 6c2b70c18f7520c521f1f8d74e5a471012c8cb11 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 16:50:36 +0800 Subject: [PATCH 061/247] =?UTF-8?q?bug=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/NewGaoDePoiBatch.groovy | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 3dc4ffbca..29c5560d4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -439,12 +439,17 @@ class NewGaoDePoiBatch extends BaseBatch{ def esValue = regionMap.get(key) if(esValue.township && ret.township){ if(esValue.name.contains(ret.name) || ret.name.contains(esValue.name)){//|| - def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat); - if(distance <100){ - simlarObj = esValue - println esValue.name +" "+ret.name+" "+distance - break; + if(ret.location && ret.location.lon){ + def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat); + if(distance <100){ + simlarObj = esValue + println esValue.name +" "+ret.name+" "+distance + break; + } + }else{ + println ret.data_id +" 无经纬度信息" } + } } } From db1208eac37ae8230c62a7d62e98a074bb041ed7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 11:33:10 +0800 Subject: [PATCH 062/247] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/DistrictController.java | 139 +++++++++++++++--- .../src/main/webapp/district/hidelist.ftl | 138 ++++++++++++++--- .../src/main/webapp/index.ftl | 2 +- 3 files changed, 244 insertions(+), 35 deletions(-) diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java index 23728998e..0e25c9471 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java @@ -325,7 +325,85 @@ public class DistrictController { return model.redirectPermanently(model.getCityUrl() + "/ershoufang/" + URLEncoder.encode(model.getKeyword(), "UTF-8") + "--"); } - /*if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// return model.redirectPermanently("http://www.fangjia.com"); +// } + +// Pager pager = model.getPager(20); +// pager.setMaxPage(FangjiaConfig.getConfig().getSearchListMaxPageNo()); +// +// // 小区列表支持新盘搜索 +// model.setCategory("district"); +// Object obj = FangjiaRudder.listMan(model.getKeyword()); +// if (obj != null) { +// return obj; +// } +// +// String city = ((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()).getDisplay(); +// Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, +// getCurrentParams(), 1); +// model.setMenu(menu); +// +// FacetQueryResult result; +// DistrictQueryBean queryBean = modelToBean(model); +// queryBean.setCity(city); +// +// // 老网站的URL中区域是带“区”的 +// if (StringUtils.isNotBlank(queryBean.getRegion())) { +// List gList = menu.getGroupList(); +// for (Group g : gList) { +// if (!"region".equals(g.getName())) { +// continue; +// } +// +// List iList = g.getItemList(); +// for (Item i : iList) { +// if (i.isSelected()) { +// queryBean.setRegion(i.getName()); +// break; +// } +// } +// break; +// } +// } +// +// if (StringUtils.isBlank(model.getKeyword())) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, "bscore", false, false); +// } else { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false); +// if (result.getNumberFound() <= 0) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false, true); +// } +// } +// +// List districtList = districtService.processDistrictInfo(result.getEntityResults(), model.getKeyword()); +// model.setDistrictList(districtList); +// if (StringUtils.isNotBlank(model.getKeyword()) && districtList.size() <= 3) { +// Map parseMap = knowbaseService.parseKeyword(model.getKeyword()); +// if (parseMap.get("district_name") != null) { +// List otherDistrictList = otherCitiesDistrict(model.getKeyword(), model.getKeyword()); +// model.setOtherDistrictList(otherDistrictList); +// } +// } +// +// pager.setTotalRows(result.getNumberFound()); +// model.setPager(pager); +// +// model.setConditions(menuService.getConditions(((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// +//// */ +//// * gasm统计 +//// */ +// model.addGaMap(Gakey.rc, pager.getTotalRows()); +// +// feedFooter(model); +// return model; + } + public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { + if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { return model.redirectPermanently("http://www.fangjia.com"); } @@ -394,26 +472,12 @@ public class DistrictController { model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, getCurrentParams())); - *//** - * gasm统计 - *//* + model.addGaMap(Gakey.rc, pager.getTotalRows()); feedFooter(model); - return model;*/ - } - public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { - if(StringUtils.isNotBlank(model.getCityName())){ - List params = new ArrayList(); - params.add(new QueryParam("visible", 0)); - params.add(new QueryParam("city", model.getCityName())); - params.add(new QueryParam("category", "district")); - List districts = districtService.findAllByParams(params, 0, 0,new String[]{"city", "region", "name"}); - model.setDistricts(districts); - CacheUtils.putValue(CacheUtils.CachePolicyEnum.NEXT_MONTH, this.getClass(), "district-hide-list-crawl-"+model.getCityName(), (Serializable) districts); - } - return model; + } /** @@ -1764,6 +1828,47 @@ public class DistrictController { // return model; } + + /** + * 小区信息 + * + * @param model + * @return + */ + @SuppressWarnings("unchecked") + public Object seoInfoAction(DistrictModel model) { + + District district = districtService.findDistrictById(model.getId()); + if (district == null) + return model; + + model.setCityName(district.getCity()); + model.setDistrictName(district.getName()); + model.setDistrictAddress(district.getAddress()); + model.setRegion(district.getRegion()); + model.setId(district.getId()); + model.setType(String.valueOf(model.getType())); + + + DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district.getCity(), district.getRegion(), district.getName())); + if (null == districtStatBo || null == districtStatBo.getDefaultDistrictStat()) { + return model; + } + + int districtAvgPrice = 0; + int villaAvgPrice = 0; + if (null != districtStatBo.getDistrictStat()) { + districtAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); + } + if (null != districtStatBo.getVillaDistrictStat()) { + villaAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); + } + model.setDistrictAvgPrice((Integer) (districtAvgPrice / 100) * 100); + model.setVillaAvgPrice((Integer) (villaAvgPrice / 100) * 100); + model.setDistrictStatBo(districtStatBo); + return model; + } + private List getSubList(List fullList, int start, int pageSize, int total) { if (start >= total) { return Collections.emptyList(); diff --git a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl index 9963b48ae..e3de86858 100644 --- a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl +++ b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl @@ -1,21 +1,125 @@ <#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#compress> - - - - <#include "../jsconstants.ftl" /> - - - - + + + - -
    - <#list districts! as dist> - ${dist.name!} - -
    -<#include "/analytics.ftl" /> - - + <#assign fangjiaShareContent = "鎴夸环缃戯細 鎻愪緵${cityName!}灏忓尯鎴夸环鍙婂湪鍞埧婧愶紝杩樻湁灏忓尯鍛ㄨ竟閰嶅鍙婃柊闂昏瘎璁猴紒" /> + <#assign title="${cityName}"> + <#assign keywords="${cityName}"> + <#assign descr="${cityName}鎴夸环缃戜负鎮ㄦ彁渚涚儹闂ㄥ皬鍖烘悳绱㈡湇鍔�"> + <#assign addedKeywords="false"> + + <#if region?exists && region != ''> + <#assign keywords="${keywords}${region}"> + <#assign descr="${descr!''}${region!''}"> + <#assign title="${title!''}${region!''}"> + <#assign addedKeywords="true"> + + + <#if keyword?exists && keyword != ''> + <#assign keywords="${keywords}${keyword}"> + <#assign descr="${descr!''}${keyword!''}"> + <#assign title="${title!''}${keyword!''}"> + <#assign addedKeywords="true"> + + + <#assign title="${title}"> + <#assign keywords="${keywords}灏忓尯,鐑棬灏忓尯鎼滅储"> + <#assign descr="${descr}浜屾墜鎴�"> + + <#if block?exists && block != ''> + <#assign title="${title!''}${block!''}鏉垮潡"> + <#assign keywords="${keywords!''}${block!''}鏉垮潡"> + <#assign descr="${descr!''}${block!''}鏉垮潡"> + <#assign addedKeywords="true"> + + + <#assign title2="${cityName}灏忓尯淇℃伅"> + <#if (conditions?? && conditions?size gt 0)> + <#list conditions as c> + <#assign title2="${title2}${c}"> + <#if c_has_next> + <#assign title2="${title2}_"> + <#else> + <#assign title2="${title2}闄勮繎灏忓尯鎴夸环"> + + + <#else> + <#assign title2="${cityName}灏忓尯淇℃伅"> + + + <#assign PAGE_TITLE>銆�${title2}銆� + <#assign PAGE_DESCRIPTION>${title2!''}灏忓尯鎼滅储, 鎴夸环缃戝悓鏃舵彁渚�${cityName!''}灏忓尯鎴夸环,灏忓尯鍦ㄥ敭浜屾墜鎴挎埧婧�,鏂版埧鎴挎簮,绉熸埧鎴挎簮.浠ュ強灏忓尯閰嶅璁炬柦,灏忓尯鐩稿叧鏂伴椈绛夊唴瀹�. + <#assign PAGE_KEYWORDS>${keywords!''}锛屾埧浠风綉 + <#assign GA_PAGEVIEW_PATH = "/district/list/${fullQueryString}" /> + <#include "/header/head.ftl" /> + + + + + + + + + + + + <#include "../jsconstants.ftl" /> + + + + + <#include "/header/v6/_header.ftl"/> +
    + <#if pager.totalRows gt 0> +
    + <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages theme="topSearch" anchor="pagelist"/> +
    + + + +
    + <#if pager.totalRows gt pager.pageSize> +
    + <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages anchor="pagelist"/> +
    + +
    + +
    + + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/index.ftl b/projects/fangjia-coresite/src/main/webapp/index.ftl index 99dd2f6bd..356dea3ad 100644 --- a/projects/fangjia-coresite/src/main/webapp/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/index.ftl @@ -965,7 +965,7 @@ - + <#include "/header/v6/_footer.ftl"/> From f0d1afa7fac8d99bfeeff76f636e8b9093a0e246 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 11:48:51 +0800 Subject: [PATCH 063/247] update --- .../fangjia/coresite/model/DistrictModel.java | 10 ++ .../src/main/webapp/district/seoInfo.ftl | 111 +++++++++++++++ .../houseReport/district_around_map2.ftl | 128 ++++++++++++++++++ .../main/webapp/style/fangjia/v6/seoInfo.css | 37 +++++ 4 files changed, 286 insertions(+) create mode 100644 projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl create mode 100644 projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl create mode 100644 projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java index 5ac69e8ef..2e5f579d3 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java @@ -140,6 +140,8 @@ public class DistrictModel extends BaseModel { private int allPicCount; private List districts; + private String type; + public boolean isHousePriceInfo() { return housePriceInfo; } @@ -787,4 +789,12 @@ public class DistrictModel extends BaseModel { public void setDistricts(List districts) { this.districts = districts; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl new file mode 100644 index 000000000..076a12008 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl @@ -0,0 +1,111 @@ + +<#compress> + + + + <#include "../jsconstants.ftl" /> + + + + + + + + + + + + + + + + +<#include "/header/v6/_header.ftl"/> + + +
    +
    +
    +
    +
    +

    +

    ${city!} ${region!} ${districtAddress!}

    +
    +
    +
    • 灏忓尯鍧囦环
    • 56565鍏�/銕�
    +
    • 鐜瘮
    • 3.6
    +
    • 鍚屾瘮
    • 12.3
    +
    +
    + + <#include "../houseReport/district_price.ftl"/> + + + <#include "../houseReport/district_around_map2.ftl"/> +
    +
    +
    +<#include "/header/v6/_footer.ftl"/> + + + +<#----> +<#----> + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl new file mode 100644 index 000000000..4b1b758da --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl @@ -0,0 +1,128 @@ + + + + + +
    +
    灏忓尯鍛ㄨ竟閰嶅 +<#-- --> +
    +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css new file mode 100644 index 000000000..83c2d72fe --- /dev/null +++ b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css @@ -0,0 +1,37 @@ +@charset "utf-8"; +/* CSS Document */ +.main { width: 1200px;margin: auto; margin-top: 100px;overflow: hidden;position: relative;} +.main_left {margin: auto;} +.topic {padding: 40px 0;border-bottom: solid 1px #e5e5e5;} +.topic_top {font-size: 18px;margin-bottom: 20px;align-items: center;display: flex;float: left;} +.topic_top i {width: 30px;height: 36px;display: inline-flex;background: url(../../../images/fangjia/v6/4-2-13.png) no-repeat left bottom;margin-left: -10px;} +.overview01 .overview_left{margin-bottom: 80px;} +.overview01 .overview_left p { margin-bottom: 10px;width: 100%; text-align: justify;font-size: 20px;line-height: 30px;} +.overview01 .overview_left p label {color: #3c3f46;font-size: 24px;font-weight: 500;} +.overview01 .overview_left p i {width: 11px;height: 30px;background: url(../../../images/fangjia/v6/address.png) no-repeat center center;float: left;margin-right: 5px;} +.overview01 .overview_left p{font-size: 16px;} + +.price_div{display: flex;float: left;flex-direction: row;justify-content: flex-start;width: 1200px; margin: auto auto; padding-bottom: 10px;} +.price_div ul{width:25%;} +.price_div ul li{color: #878682;} +.price_div ul li .unit_price{color: #db4c3f;font-size: 32px;font-weight: bold;line-height: 50px;} +.price_div ul li .dw{color: #db4c3f;font-size: 16px;} +.price_div ul li .up{ color: #db4c3f;} +.price_div ul li .down{color:#00ae66;} +.price_div ul li .hb_tb{font-size: 22px;line-height: 50px;} +.price_div ul li .down i {background: url(../../../images/fangjia/v6/down.png) no-repeat left center;} +.price_div ul li .up i {background: url(../../../images/fangjia/v6/up.png) no-repeat left center;} + + +.districtMap{width:100%;height:400px;} +/* 鍦板浘鏍峰紡 */ +.mark-icon-box .mark-icon {width: 20px;height: 30px;display: block;cursor: pointer;font-size: 14px;color: #fff;font-weight: bold;text-align: center;line-height: 24px;background: url(../../../images/fangjia/v5/dw.png) no-repeat;} +.mark-icon-box { width: 24px; height: 30px; position: absolute; z-index: 98; } +.mark-icon-box .mark-icon:hover, .mark-icon-box .mark-icon-h { background: url(../../../images/fangjia/v5/dw_h.png) no-repeat ; } + +.mark-tip {font-size: 14px;position: absolute;z-index: 99;margin-top: -74px;margin-left: -20px;} +.mark-tip .title1 {line-height: 20px;color: #000;background: #fff;padding: 5px 40px 5px 15px;border-radius: 5px;box-shadow: 3px 3px 8px #888;height: 20px;} +.mark-tip .title1 span {display: inline-block;max-width: 170px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin-right: 25px;} +.mark-tip .title1 b { font-weight: normal; display: block; position: absolute; top: 5px; right: 10px; } +.mark-tip .icon { width: 21px; height:14px; background: url(../../../images/fangjia/v5/sj.png) no-repeat ; position: absolute; bottom: -14px; left: 20px; } + From 9bbe22212ab431f53d79d5b2f17287871ef36523 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 13:24:01 +0800 Subject: [PATCH 064/247] css update --- .../fangjia-coresite/src/main/webapp/district/hidelist.ftl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl index e3de86858..7c88e857e 100644 --- a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl +++ b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl @@ -67,6 +67,9 @@ <#include "../jsconstants.ftl" /> - + +銆� +
    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index f9bc96179..8abcd7c2a 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -14,16 +14,25 @@ - + +銆� +
    -
    +
    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index 7ba706719..286d93991 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -16,11 +16,20 @@ - + +銆� +
    From 73076f0b2204cf2c36f50de6efd1496331a439da Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 20 Dec 2024 17:58:57 +0800 Subject: [PATCH 067/247] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=8A=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/district/districtDetail.ftl | 7 +++++++ .../src/main/webapp/report/downloadList.ftl | 15 ++++++++++++++- .../src/main/webapp/weiXinEvaluation/form.ftl | 7 +++++++ .../main/webapp/weiXinEvaluation/recordList.ftl | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index ad794d865..fd925c430 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -211,6 +211,13 @@ $(function(){initMap();}); + + if (typeof WeixinJSBridge !== "undefined") { + WeixinJSBridge.on('menu:back', function () { + window.history.back(); // 杩斿洖涓婁竴椤� + }); + } + diff --git a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl index 55d2fbd97..f54286437 100644 --- a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl +++ b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl @@ -13,10 +13,23 @@ + -
    + +銆� + +
    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 8abcd7c2a..1da5a0547 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -436,6 +436,13 @@ } }) }) + + if (typeof WeixinJSBridge !== "undefined") { + WeixinJSBridge.on('menu:back', function () { + window.history.back(); // 杩斿洖涓婁竴椤� + }); + } + diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl index 93cc7a993..cf6070a5c 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl @@ -13,11 +13,22 @@ - + - + +銆� + -
    +
    From aa6ec4e50ae29a97b9ef54bd06f7d34cbde388e0 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 20 Dec 2024 18:13:48 +0800 Subject: [PATCH 068/247] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=8A=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/webapp/district/districtDetail.ftl | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index fd925c430..32a704887 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -134,6 +134,7 @@ + From 0e723d4bbac94bedc30e0c9bb49783c8e630bed8 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:26:39 +0800 Subject: [PATCH 069/247] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/user/aiLoginPage.ftl | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index 67948a07a..faf18a1c5 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -88,6 +88,47 @@ } return true; } + // 璁剧疆 Cookie 鍑芥暟 + function setLoginCookie(username, token) { + var expirationDate = new Date(); + expirationDate.setTime(expirationDate.getTime() + (3 * 24 * 60 * 60 * 1000)); // 3澶╁悗杩囨湡 + var expires = "expires=" + expirationDate.toUTCString(); + + // 灏嗙敤鎴蜂俊鎭紙鐢ㄦ埛鍚嶅拰 token锛夊瓨鍏� Cookie + document.cookie = "login_username=" + encodeURIComponent(username) + ";" + expires + ";path=/"; + document.cookie = "login_token=" + encodeURIComponent(token) + ";" + expires + ";path=/"; + } + + // 鑾峰彇 Cookie 涓殑鍊� + function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return decodeURIComponent(c.substring(nameEQ.length, c.length)); + } + return null; + } + + // 妫�鏌ョ櫥褰曠姸鎬� + function checkLoginStatus() { + var username = getCookie("login_username"); + var token = getCookie("login_token"); + + if (username && token) { + // 鑷姩鐧诲綍 + console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); + window.location.href = "reqCityChoicePage?type=gb"; + // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� + // 姣斿锛歸indow.location.href = 'dashboard.html'; + } else { + console.log("娌℃湁鐧诲綍淇℃伅锛岃烦杞埌鐧诲綍椤甸潰"); + // 濡傛灉娌℃湁鐧诲綍淇℃伅锛岃烦杞埌鐧诲綍椤甸潰 + // window.location.href = 'login.html'; + // window.location.href = "aiLoginPage"; + } + } $(".login_btn").click(function(){ var username = $("#username").val(); @@ -115,6 +156,8 @@ }); } }); + // 鍦ㄩ〉闈㈠姞杞芥椂妫�鏌ョ櫥褰曠姸鎬� + checkLoginStatus(); }); From 49160d7513eb49859427b020c64b9ea6c820317f Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:28:43 +0800 Subject: [PATCH 070/247] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index faf18a1c5..600cf8f4b 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -119,7 +119,7 @@ if (username && token) { // 鑷姩鐧诲綍 console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); - window.location.href = "reqCityChoicePage?type=gb"; + window.location.href = "district/weXinList?type=gb"; // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� // 姣斿锛歸indow.location.href = 'dashboard.html'; } else { From 2845eaeb86011c7cbc862415ef6add59e8254a5e Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:51:10 +0800 Subject: [PATCH 071/247] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index 600cf8f4b..cec747b40 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -119,7 +119,7 @@ if (username && token) { // 鑷姩鐧诲綍 console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); - window.location.href = "district/weXinList?type=gb"; + window.location.href = "../district/weXinList?type=gb&cityName=涓婃捣"; // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� // 姣斿锛歸indow.location.href = 'dashboard.html'; } else { @@ -148,6 +148,7 @@ if(re.result == "fail"){ $.toast(re.msg); } else { + setLoginCookie(username, re.token); window.location.href = "reqCityChoicePage?type=gb"; } },error:function (data, status) { From d7ba02d699f618f9b442a02e6620842d12340113 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 23 Dec 2024 14:49:25 +0800 Subject: [PATCH 072/247] =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E6=88=90=E4=BA=A4=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 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 c65f09175..f6baf3541 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 @@ -71,8 +71,7 @@ class BigdataDealBatch extends BaseBatch{ for(def city : allCitys){ addDealPriceMatch(city); } - updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 - +// updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 def rows = [] def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] From 5a0529e1b76aa36752b0ef4eb7bdaf45e8419353 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 23 Dec 2024 18:10:40 +0800 Subject: [PATCH 073/247] =?UTF-8?q?poi=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/NewGaoDePoiBatch.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 29c5560d4..046585431 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -46,8 +46,8 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { -// run() - oldPoiMagre() + run() +// oldPoiMagre() } def run(){ @@ -323,7 +323,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("gaode_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { @@ -358,9 +358,9 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ -// if(!cityObj.city.contains("固原")){ -// continue -// } + if(!cityObj.city.contains("五指山市")){ + continue + } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" From 4c6716694ed8dadb3f47edb7665f202ceaab2846 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 11:15:06 +0800 Subject: [PATCH 074/247] =?UTF-8?q?=E8=87=AA=E8=BA=AB=E6=88=BF=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/seawater/model/Seawater.java | 2 +- .../open/controllers/HouseController.java | 138 ++++++- .../fangjia/open/model/BasicPageModel.java | 115 ++++++ .../open/model/DistrictFacilitysModel.java | 344 ++++++++++++++++++ .../fangjia/open/model/HouseSearchModel.java | 10 + 5 files changed, 599 insertions(+), 10 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index 225242e88..c553d2f46 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -234,7 +234,7 @@ public class Seawater implements SeawaterEntity { this.floor = floor; } - @Column(name = "floorInfo") + @Column(name = "floor_info") public String getFloorInfo() { return floorInfo; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 5c8ef119a..fba91b6eb 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -27,10 +27,7 @@ import com.fangjia.open.dto.UniversalDto; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.BasicModel; -import com.fangjia.open.model.HousePublishModel; -import com.fangjia.open.model.HouseSearchModel; -import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.model.*; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.FileDao; import com.fangjia.open.ws.query.CollateralSampleQuery; @@ -1019,14 +1016,14 @@ public class HouseController { if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { seawater.setTitle(name); } - if (cat.contains("office")){ + if (cat.contains("office")) { seawater.setLevel(house.getLevel()); } - if (cat.contains("shop")){ - if (StringUtils.isNotBlank(house.getEstateType()) && !"其他".equals(house.getEstateType())){ + if (cat.contains("shop")) { + if (StringUtils.isNotBlank(house.getEstateType()) && !"其他".equals(house.getEstateType())) { seawater.setShopType(house.getEstateType()); } - if (StringUtils.isNotBlank(house.getBusinessRange())){ + if (StringUtils.isNotBlank(house.getBusinessRange())) { seawater.setBusinessScope(house.getBusinessRange()); } } @@ -1147,10 +1144,11 @@ public class HouseController { mav.setViewType("rest"); return mav; } + public Object rentAction(final HouseSearchModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); - if (model.getSize()!= null && model.getSize()<0) { + if (model.getSize() != null && model.getSize() < 0) { mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); return mav; } @@ -1243,6 +1241,128 @@ public class HouseController { return mav; } + public Object resourcesAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize() != null && model.getSize() < 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + if (null == property) { + mav.setModel(BasicModel.buildBadRequestModel("未找到该小区")); + return mav; + } + // 没有输入时间范围,则是默认六个月的 + if (model.getStartTime() == null && model.getEndTime() == null) { + // 获取当前日期 + Calendar today = Calendar.getInstance(); + + // 复制一份当前日期,用于计算半年前的日期 + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // 减去 6 个月 + sixMonthsAgo.add(Calendar.MONTH, -6); + + // 格式化日期为 yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + } + + List houses = null; + List houseList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + List catList = Arrays.asList("rent", "sell", "office_rent", "office_sell", "shop_sell", "shop_rent"); + if (!catList.contains(model.getCat())) { + model.setCat("rent"); + } + query.setCat(model.getCat()); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + // 没有查询数量,默认查前五个 + if (model.getPageIndex() == null) { + pager.setStartRow(0); + } else { + pager.setStartRow(model.getPageIndex()); + } + pager.setPageSize(model.getPageSize()); + query.setPager(pager); + query.setTable("latest_seawater"); + if (StringUtils.isNotBlank(model.getSortField())){ + query.setSortField(model.getSortField()); + }else { + query.setSortField("p_date"); + } + if ("asc".equals(model.getSortBy())) { + query.setOrder(true); + }else { + query.setOrder(false); + } + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + seawater.setFloorInfo(house.getFloorInfo()); + seawater.setRoot(house.getRoot()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicPageModel pageModel = new BasicPageModel(200, "ok"); + pager.setPageSize(-1); + pager.setStartRow(-1); + query.setPager(pager); + long count = seawaterDao.findSeawatersCountByQuery(query); + pageModel.setTotal((int) count); + // 组装数据 + pageModel.setResult(houseList); + mav.setModel(pageModel); + mav.setViewType("rest"); + return mav; + } + Double sub6(Double a) { BigDecimal bd = new BigDecimal(a); BigDecimal bigDecimal = bd.setScale(6, BigDecimal.ROUND_DOWN); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java new file mode 100644 index 000000000..34512f434 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java @@ -0,0 +1,115 @@ +package com.fangjia.open.model; + +import com.fangjia.open.APIConstant; +import com.fangjia.open.HttpStatusCodeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.sothis.web.mvc.ActionContext; + +@XStreamAlias("xml") +public class BasicPageModel { + + private int code; + + private String msg; + + private Object result; + + private String tid; + + private int total; + + public BasicPageModel(int code, String msg) { + super(); + this.code = code; + this.msg = msg; + } + + public BasicPageModel(HttpStatusCodeEnum status){ + this.code = status.getCode(); + this.msg = status.getMsg(); + } + + public static BasicPageModel buildOKModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.OK); + return model; + } + + public static BasicPageModel buildModel(int code, String msg){ + return new BasicPageModel( code, msg); + } + + public static BasicPageModel buildUnAuthorizedModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.UN_AUTHORIZED); + return model; + } + + public static BasicPageModel buildBadRequestModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.BAD_REQUEST); + model.setMsg(msg); + return model; + } + + public static BasicPageModel buildForbidModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_FORBID); + model.setMsg(msg); + return model; + } + + + public static BasicPageModel buildServerErrorModel(){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_ERROR); + return model; + } + + public static void markNoDataRequest(){ + ActionContext.getContext().set(APIConstant.IS_RETURN_DATA, Boolean.FALSE); + } + + public BasicPageModel markNoData(){ + markNoDataRequest(); + return this; + } + + public int getCode() { + return code; + } + + public BasicPageModel setCode(int code) { + this.code = code; + return this; + } + + public String getMsg() { + return msg; + } + + public BasicPageModel setMsg(String msg) { + this.msg = msg; + return this; + } + + public Object getResult() { + return result; + } + + public BasicPageModel setResult(Object result) { + this.result = result; + return this; + } + + public void setTid(String tid) { + this.tid = tid; + } + + public String getTid() { + return tid; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java new file mode 100644 index 000000000..ddc05adec --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java @@ -0,0 +1,344 @@ +package com.fangjia.open.model; + +import java.util.Date; +import java.util.List; + +/** + * 灏忓尯鍛ㄨ竟閰嶅 + */ +public class DistrictFacilitysModel { + private static final long serialVersionUID = -9200383212669643823L; + private String id; + private String city; + private String region; + private String districtName; + private List kindergarten; + private List primarySchool; + private List middleSchool; + private List university; + private List hospital; + private List shop; + private List supermarket; + private List foodShop; + private List bus; + private List metro; + private List bank; + private List atm; + private String innerFacilities; + private String carSite; + private String carSiteDes; + + private Double trafficScore; + private Double hospitalScore; + private Double shopScore; + private Double schoolScore; + private Double bankScore; + + private Date creationDate; + + private List positives; // 姝i潰 + private List negatives; // 璐熼潰 + private List appraisalNegative; // 璐熼潰 + private List appraisalPositive; // 姝i潰 + + /** + * 閺嶅洨顒峰妤�鍨� + */ + private Double traScore; + private Double virScore; + private Double aroScore; + private Double tradScore; + + private String imgUrl3D; + + private List school; + private List keySchool; + + public String getCity() { + return city; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getDistrictName() { + return districtName; + } + + public void setDistrictName(String districtName) { + this.districtName = districtName; + } + + public List getKindergarten() { + return kindergarten; + } + + public void setKindergarten(List kindergarten) { + this.kindergarten = kindergarten; + } + + public List getPrimarySchool() { + return primarySchool; + } + + public void setPrimarySchool(List primarySchool) { + this.primarySchool = primarySchool; + } + + public List getMiddleSchool() { + return middleSchool; + } + + public void setMiddleSchool(List middleSchool) { + this.middleSchool = middleSchool; + } + + public List getUniversity() { + return university; + } + + public void setUniversity(List university) { + this.university = university; + } + + public List getHospital() { + return hospital; + } + + public void setHospital(List hospital) { + this.hospital = hospital; + } + + public List getShop() { + return shop; + } + + public void setShop(List shop) { + this.shop = shop; + } + + public List getSupermarket() { + return supermarket; + } + + public void setSupermarket(List supermarket) { + this.supermarket = supermarket; + } + + public List getFoodShop() { + return foodShop; + } + + public void setFoodShop(List foodShop) { + this.foodShop = foodShop; + } + + public List getBus() { + return bus; + } + + public void setBus(List bus) { + this.bus = bus; + } + + public List getMetro() { + return metro; + } + + public void setMetro(List metro) { + this.metro = metro; + } + + public List getBank() { + return bank; + } + + public void setBank(List bank) { + this.bank = bank; + } + + public List getAtm() { + return atm; + } + + public void setAtm(List atm) { + this.atm = atm; + } + + public String getInnerFacilities() { + return innerFacilities; + } + + public void setInnerFacilities(String innerFacilities) { + this.innerFacilities = innerFacilities; + } + + public String getCarSite() { + return carSite; + } + + public void setCarSite(String carSite) { + this.carSite = carSite; + } + + public String getCarSiteDes() { + return carSiteDes; + } + + public void setCarSiteDes(String carSiteDes) { + this.carSiteDes = carSiteDes; + } + + public Double getTrafficScore() { + return trafficScore; + } + + public void setTrafficScore(Double trafficScore) { + this.trafficScore = trafficScore; + } + + public Double getHospitalScore() { + return hospitalScore; + } + + public void setHospitalScore(Double hospitalScore) { + this.hospitalScore = hospitalScore; + } + + public Double getShopScore() { + return shopScore; + } + + public void setShopScore(Double shopScore) { + this.shopScore = shopScore; + } + + public Double getSchoolScore() { + return schoolScore; + } + + public void setSchoolScore(Double schoolScore) { + this.schoolScore = schoolScore; + } + + public Double getBankScore() { + return bankScore; + } + + public void setBankScore(Double bankScore) { + this.bankScore = bankScore; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public List getPositives() { + return positives; + } + + public void setPositives(List positives) { + this.positives = positives; + } + + public List getNegatives() { + return negatives; + } + + public void setNegatives(List negatives) { + this.negatives = negatives; + } + + public List getAppraisalNegative() { + return appraisalNegative; + } + + public void setAppraisalNegative(List appraisalNegative) { + this.appraisalNegative = appraisalNegative; + } + + public List getAppraisalPositive() { + return appraisalPositive; + } + + public void setAppraisalPositive(List appraisalPositive) { + this.appraisalPositive = appraisalPositive; + } + + public Double getTraScore() { + return traScore; + } + + public void setTraScore(Double traScore) { + this.traScore = traScore; + } + + public Double getVirScore() { + return virScore; + } + + public void setVirScore(Double virScore) { + this.virScore = virScore; + } + + public Double getAroScore() { + return aroScore; + } + + public void setAroScore(Double aroScore) { + this.aroScore = aroScore; + } + + public Double getTradScore() { + return tradScore; + } + + public void setTradScore(Double tradScore) { + this.tradScore = tradScore; + } + + public String getImgUrl3D() { + return imgUrl3D; + } + + public void setImgUrl3D(String imgUrl3D) { + this.imgUrl3D = imgUrl3D; + } + + public List getSchool() { + return school; + } + + public void setSchool(List school) { + this.school = school; + } + + public List getKeySchool() { + return keySchool; + } + + public void setKeySchool(List keySchool) { + this.keySchool = keySchool; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index 987f6f3d2..8f695b729 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -25,6 +25,8 @@ public class HouseSearchModel extends SearchModel { private String houseType; private String district; + + private String cat; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -187,4 +189,12 @@ public class HouseSearchModel extends SearchModel { public void setDistrict(String district) { this.district = district; } + + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } } From 6ab477367b37815e90c9de2d2cc13f9ad32dbd62 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 11:17:59 +0800 Subject: [PATCH 075/247] =?UTF-8?q?=E8=87=AA=E8=BA=AB=E6=88=BF=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/model/DistrictFacilitysModel.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java index ddc05adec..ca5c12046 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java @@ -4,7 +4,7 @@ import java.util.Date; import java.util.List; /** - * 灏忓尯鍛ㄨ竟閰嶅 + * 小区周边配套 */ public class DistrictFacilitysModel { private static final long serialVersionUID = -9200383212669643823L; @@ -36,13 +36,13 @@ public class DistrictFacilitysModel { private Date creationDate; - private List positives; // 姝i潰 - private List negatives; // 璐熼潰 - private List appraisalNegative; // 璐熼潰 - private List appraisalPositive; // 姝i潰 + private List positives; // 正面 + private List negatives; // 负面 + private List appraisalNegative; // 负面 + private List appraisalPositive; // 正面 /** - * 閺嶅洨顒峰妤�鍨� + * 鏍囩寰楀垎 */ private Double traScore; private Double virScore; From 63782f4ea2fbe59076338c444748a5f38acd1456 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 14:13:27 +0800 Subject: [PATCH 076/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/SeaweedImages.java | 8 +- .../open/controllers/DistrictController.java | 2103 +++++++++-------- 2 files changed, 1102 insertions(+), 1009 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java index 33ff36050..33d6b6dee 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java @@ -5,6 +5,7 @@ import com.fangjia.dal.MongoEntity; import javax.persistence.*; import java.util.Date; import java.util.List; +import java.util.Map; @Entity @Table(name = "fangjia_base.seaweed_images") @@ -15,7 +16,7 @@ public class SeaweedImages implements MongoEntity { private String city; private String district; - private List floorplanPics; + private Map> floorplanPics; private Date mDate; private String name; @@ -51,13 +52,12 @@ public class SeaweedImages implements MongoEntity { public void setDistrict(String district) { this.district = district; } - @Column(name = "floorplan_pics") - public List getFloorplanPics() { + public Map> getFloorplanPics() { return floorplanPics; } - public void setFloorplanPics(List floorplanPics) { + public void setFloorplanPics(Map> floorplanPics) { this.floorplanPics = floorplanPics; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index a35805605..ba7c22ede 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -10,8 +10,7 @@ import com.fangjia.core.util.DateUtil; import com.fangjia.core.util.HttpRequest; import com.fangjia.dal.mongo.model.*; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; -import com.fangjia.open.model.AvgPriceQueryModel; -import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.*; import com.fangjia.open.model.weixin.DistrictModel; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.service.datastore.RegionStatService; @@ -58,8 +57,6 @@ import com.fangjia.open.dto.NewDistrictDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.DistrictSearchModel; -import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.service.api.AutoCompleteService; import com.fangjia.service.api.CategoryEnum; import com.fangjia.service.api.KnowbaseService; @@ -79,655 +76,655 @@ import com.fangjia.service.web.MenuService; /** * 小区接口 - * + * * @author velna - * */ @Authority(role = Role.USER) public class DistrictController { - private DistrictService districtService; - private MenuService menuService; - private DistrictStatService districtStatService; - private DistrictHouseService districtHouseService; - private AutoCompleteService autoCompleteService; - private KnowbaseService knowbaseService; - private ApiUserService apiUserService; - private ExtractDistrictService extractDistrictService; + private DistrictService districtService; + private MenuService menuService; + private DistrictStatService districtStatService; + private DistrictHouseService districtHouseService; + private AutoCompleteService autoCompleteService; + private KnowbaseService knowbaseService; + private ApiUserService apiUserService; + private ExtractDistrictService extractDistrictService; private RegionBlockService regionBlockService; private RegionStatService regionStatService; private RegionStatRentService regionStatRentService; - private DistrictFacilitysService districtFacilitysService; - private SeaweedImagesService seaweedImagesService; - + private DistrictFacilitysService districtFacilitysService; + private SeaweedImagesService seaweedImagesService; - public static final String[] COLUMNS = { "id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", - "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", - "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", - "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", - "fitmentMaterials", "floorInfo", "creationDate", "modificationDate" }; - public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - @Param(name = "cat") String cat, @Param(name = "limit") int limit) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "所在城市必须输入")); - } + public static final String[] COLUMNS = {"id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", + "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", + "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", + "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", + "fitmentMaterials", "floorInfo", "creationDate", "modificationDate"}; - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键字必须输入")); - } + public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + @Param(name = "cat") String cat, @Param(name = "limit") int limit) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "所在城市必须输入")); + } - List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键字必须输入")); + } - List> result = new ArrayList>(); + List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); - for (District district : districts) { - Map resMap = new HashMap(); - resMap.put("_id", district.getId()); - resMap.put("city", district.getCity()); - resMap.put("region", district.getRegion()); - resMap.put("block", district.getBlock()); - resMap.put("districtName", district.getName()); - resMap.put("address", district.getAddress()); - resMap.put("category", district.getCategory()); - result.add(resMap); - } + List> result = new ArrayList>(); - mav.setModel(result); - return mav; - } + for (District district : districts) { + Map resMap = new HashMap(); + resMap.put("_id", district.getId()); + resMap.put("city", district.getCity()); + resMap.put("region", district.getRegion()); + resMap.put("block", district.getBlock()); + resMap.put("districtName", district.getName()); + resMap.put("address", district.getAddress()); + resMap.put("category", district.getCategory()); + result.add(resMap); + } - public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, - @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, - @Param(name = "lastUpdateTime") Long lastUpdateTime) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } + mav.setModel(result); + return mav; + } - if (!"district".equals(cat) && !"new_district".equals(cat)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区类型必须输入正确")); - return mav; - } + public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, + @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, + @Param(name = "lastUpdateTime") Long lastUpdateTime) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } - skip = null == skip ? 0 : skip; - limit = null == limit ? 20 : limit; - System.out.println(new Date().getTime()); + if (!"district".equals(cat) && !"new_district".equals(cat)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区类型必须输入正确")); + return mav; + } - if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请求数量参数不正确")); - return mav; - } + skip = null == skip ? 0 : skip; + limit = null == limit ? 20 : limit; + System.out.println(new Date().getTime()); - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("category", cat)); - params.add(new QueryParam("visible", 0)); - if (null != lastUpdateTime) { - params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); - } + if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请求数量参数不正确")); + return mav; + } - Pager pager = new Pager(limit); - pager.setStartRow(skip); - List districtLists = districtService.findDistrictList(pager, params, COLUMNS); + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("category", cat)); + params.add(new QueryParam("visible", 0)); + if (null != lastUpdateTime) { + params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); + } - List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, - new Closure() { - public DistrictDto execute(District obj) { - DistrictBo bo = new DistrictBo(obj); - DistrictDto ret = null; - if ("new_district".equals(cat)) { - ret = new NewDistrictDto(bo, true); - } else { - ret = new DistrictDto(bo, true); - } - ret.setAlias(obj.getAlias()); - return ret; - } - }); + Pager pager = new Pager(limit); + pager.setStartRow(skip); + List districtLists = districtService.findDistrictList(pager, params, COLUMNS); - mav.setModel(districtDtos); - return mav; - } + List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, + new Closure() { + public DistrictDto execute(District obj) { + DistrictBo bo = new DistrictBo(obj); + DistrictDto ret = null; + if ("new_district".equals(cat)) { + ret = new NewDistrictDto(bo, true); + } else { + ret = new DistrictDto(bo, true); + } + ret.setAlias(obj.getAlias()); + return ret; + } + }); - /** - * 根据城市和关键词取小区 - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); - return mav; - } - List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - DistrictDto districtDto = null; - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(city); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictBo bo = districtBos.get(0); - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - break; - } - } - if (null != districtDto) { - mav.setModel(districtDto); - } - } - return mav; - } + mav.setModel(districtDtos); + return mav; + } - /** - * 根据关键词取小区 - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); - return mav; - } + /** + * 根据城市和关键词取小区 + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); + return mav; + } + List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + DistrictDto districtDto = null; + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(city); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictBo bo = districtBos.get(0); + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + break; + } + } + if (null != districtDto) { + mav.setModel(districtDto); + } + } + return mav; + } - ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); - if (serverArea == null) { - serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); - if (null == serverArea) { - serverArea = ServerAreaData.valueOfName(city); - } - } + /** + * 根据关键词取小区 + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); + return mav; + } - List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - List> ret = new ArrayList>(10); - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(serverArea.getDisplay()); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictKey key = districtBos.get(0).getDistrictKey(); - Map info = new HashMap(3); - info.put("city", serverArea.getDisplay()); - info.put("region", key.getRegion()); - info.put("name", key.getName()); - ret.add(info); - } - } - if (ret.size() > 0) { - mav.setModel(ret); - } - } - return mav; - } + ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); + if (serverArea == null) { + serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); + if (null == serverArea) { + serverArea = ServerAreaData.valueOfName(city); + } + } - /** - * 小区搜索 - * - * @return - */ - public Object listAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - // 是否输入半径查询,其他情况直接moedel查询即可 - if (isRadiusSearch(model)) { - Long lng = model.getLng(); - Long lat = model.getLat(); + List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + List> ret = new ArrayList>(10); + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(serverArea.getDisplay()); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictKey key = districtBos.get(0).getDistrictKey(); + Map info = new HashMap(3); + info.put("city", serverArea.getDisplay()); + info.put("region", key.getRegion()); + info.put("name", key.getName()); + ret.add(info); + } + } + if (ret.size() > 0) { + mav.setModel(ret); + } + } + return mav; + } - model.setLng(lng); - model.setLat(lat); + /** + * 小区搜索 + * + * @return + */ + public Object listAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + // 是否输入半径查询,其他情况直接moedel查询即可 + if (isRadiusSearch(model)) { + Long lng = model.getLng(); + Long lat = model.getLat(); - Long lngMin = (lng - (model.getRadius() * 100000L)); - model.setLngMin(lngMin); - Long lngMax = (lng + (model.getRadius() * 100000L)); - model.setLngMax(lngMax); - Long latMin = (lat - (model.getRadius() * 100000L)); - model.setLatMin(latMin); - Long latMax = (lat + (model.getRadius() * 100000L)); - model.setLatMax(latMax); + model.setLng(lng); + model.setLat(lat); - model.setRegion(null); - model.setName(null); - } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { - Long lngMin = Math.min(model.getLngA(), model.getLngB()); - Long lngMax = Math.max(model.getLngA(), model.getLngB()); - Long latMin = Math.min(model.getLatA(), model.getLatB()); - Long latMax = Math.max(model.getLatA(), model.getLatB()); + Long lngMin = (lng - (model.getRadius() * 100000L)); + model.setLngMin(lngMin); + Long lngMax = (lng + (model.getRadius() * 100000L)); + model.setLngMax(lngMax); + Long latMin = (lat - (model.getRadius() * 100000L)); + model.setLatMin(latMin); + Long latMax = (lat + (model.getRadius() * 100000L)); + model.setLatMax(latMax); - model.setLngMin(lngMin); - model.setLngMax(lngMax); - model.setLatMin(latMin); - model.setLatMax(latMax); - } - Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, - getCurrentParams(), 1); - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", - false, false); - } else { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, - false); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + model.setRegion(null); + model.setName(null); + } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { + Long lngMin = Math.min(model.getLngA(), model.getLngB()); + Long lngMax = Math.max(model.getLngA(), model.getLngB()); + Long latMin = Math.min(model.getLatA(), model.getLatB()); + Long latMax = Math.max(model.getLatA(), model.getLatB()); - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = null; - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - if (StringUtils.isNotBlank(model.getHouseCountType())) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { - districtDto.setSellCount(dh.getSellCount()); - } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { - districtDto.setRentCount(dh.getRentCount()); - } - } - } - // 若存在外景图则只考虑外景图 - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + model.setLngMin(lngMin); + model.setLngMax(lngMax); + model.setLatMin(latMin); + model.setLatMax(latMax); + } + Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, + getCurrentParams(), 1); + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", + false, false); + } else { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, + false); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); - private Map getCurrentParams() { - Map paramMap = ActionContext.getContext().getParameters(); - Map ret = new HashMap(); + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = null; + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + if (StringUtils.isNotBlank(model.getHouseCountType())) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { + districtDto.setSellCount(dh.getSellCount()); + } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { + districtDto.setRentCount(dh.getRentCount()); + } + } + } + // 若存在外景图则只考虑外景图 + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } - for (String key : paramMap.keySet()) { - Object[] obj = paramMap.get(key); - if (obj != null && obj.length > 0) { - ret.put(key, obj[0].toString()); - } - } - return ret; - } + private Map getCurrentParams() { + Map paramMap = ActionContext.getContext().getParameters(); + Map ret = new HashMap(); - /** - * 是否可以提供经纬度 - * - * @param request - * @return - */ - private boolean isSupportLatLng(HttpServletRequest request) { - AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); - if (null != bean) { - if (null != bean.auth) { - return bean.auth.isSupportLatLng(); - } - } - return false; - } + for (String key : paramMap.keySet()) { + Object[] obj = paramMap.get(key); + if (obj != null && obj.length > 0) { + ret.put(key, obj[0].toString()); + } + } + return ret; + } - /** - * 小区详情 - * - * @return - */ - public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } else { - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // 去除小区描述中的html标签 - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } - } + /** + * 是否可以提供经纬度 + * + * @param request + * @return + */ + private boolean isSupportLatLng(HttpServletRequest request) { + AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (null != bean) { + if (null != bean.auth) { + return bean.auth.isSupportLatLng(); + } + } + return false; + } - /** - * 智能解析小区详情 - * - * @return - */ - public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, - @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } - city = knowbaseService.matchingCityDefaultNull(city); - region = knowbaseService.matchingRegionDefaultNull(region, city); - if (null == city || null == region) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区所在城市或所在区域不存在")); - return mav; - } - District tempDistrict = null; - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (null == city && tempCity != null) { - city = tempCity; - } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - tempDistrict = d; - break; - } - } - } - if (null == tempDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), - tempDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // 去除小区描述中的html标签 - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } + /** + * 小区详情 + * + * @return + */ + public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } else { + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // 去除小区描述中的html标签 + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } + } - // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } + /** + * 智能解析小区详情 + * + * @return + */ + public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, + @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } + city = knowbaseService.matchingCityDefaultNull(city); + region = knowbaseService.matchingRegionDefaultNull(region, city); + if (null == city || null == region) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区所在城市或所在区域不存在")); + return mav; + } + District tempDistrict = null; + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (null == city && tempCity != null) { + city = tempCity; + } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + tempDistrict = d; + break; + } + } + } + if (null == tempDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), + tempDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // 去除小区描述中的html标签 + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } - public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } else { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // 若存在外景图则只考虑外景图 - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setDescription(null); - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } else { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); + + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // 若存在外景图则只考虑外景图 + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setDescription(null); + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } /** * 小区均价查询接口 + * * @param model * @return */ - public Object avgPriceAction(AvgPriceQueryModel model){ + public Object avgPriceAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域)是必须参数")); 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 (!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); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount()< 1 || model.getPeriodCount()>156){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); return mav; } - if(StringUtils.isBlank(model.getPeriodType())){ + if (StringUtils.isBlank(model.getPeriodType())) { model.setPeriodType("weekly"); - }else{ - if(!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())){ + } 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{ + if ("weekly".equals(model.getPeriodType())) { + calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); + } else { calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); } - List regionStats = regionStatService.findRegionBlockStat(model.getCity(),model.getDistrict(),null,calendar.getTime(),new Date(),model.getPeriodType()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatService.findRegionBlockStat(model.getCity(), model.getDistrict(), null, calendar.getTime(), new Date(), model.getPeriodType()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStat regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("block", regionStat.getBlock()); item.put("avgPrice", String.valueOf(regionStat.getAvgPrice())); - if("monthly".equals(model.getPeriodType())){ + if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM")); - }else{ + } else { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM-dd")); } item.put("changePercent", String.valueOf(regionStat.getMarkup() / 100d)); @@ -736,53 +733,55 @@ public class DistrictController { mav.setModel(BasicModel.buildOKModel().setResult(result)); return mav; } + /** * 区域均价查询接口 + * * @param model * @return */ - public Object rentAction(AvgPriceQueryModel model){ + public Object rentAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域)是必须参数")); 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 (!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); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); return mav; } - if (model.getHouseType() == null ||model.getHouseType() < 1) { + if (model.getHouseType() == null || model.getHouseType() < 1) { mav.setModel(BasicModel.buildBadRequestModel("房屋类型不合法")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount() < 1 || model.getPeriodCount() > 72){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 72) { mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-72]")); return mav; } - List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(),model.getDistrict(),model.getHouseType(),model.getPeriodCount()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(), model.getDistrict(), model.getHouseType(), model.getPeriodCount()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStatRent regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("rent", regionStat.getAvgPrice()); @@ -868,423 +867,517 @@ public class DistrictController { // mav.setModel(map); // return mav; // } - - - /** - * 获取小区的均价Action - * - * @param city - * @param region - * @param name - * @return - */ - public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,所在区域,小区名为必填项")); - return mav; - } - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,区域,小区名")); - return mav; - } - - - String kind = ""; - if(StringUtils.isNotBlank(districtBo.getEstateType2())){ - if(districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue())!=-1){ - kind = DistrictKindEnum.bieshu.getValue(); - } - if(districtBo.getEstateType2().indexOf("住宅")!=-1||districtBo.getEstateType2().indexOf("小区")!=-1){ - if(kind.length()>1){ - kind = kind + ","; - } - kind = kind + DistrictKindEnum.gongyu.getValue(); - } - districtBo.setKind(kind); - - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - - - String[] kinds = districtBo.getKind().split(","); - - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, 1); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); - return mav; - } - - DistrictStat stat = null; - if(CollectionUtils.isNotEmpty(districtStatList)){ - stat = districtStatList.get(0); - } - if(CollectionUtils.isNotEmpty(villaStatList)){ - stat = villaStatList.get(0); - } - - Map map = new HashMap(1); - map.put("avgPrice", stat.getAvgPrice()); - map.put("weekendMarkup", stat.getWeekendMarkup()); - mav.setModel(map); - return mav; - } - - /** - * 获取小区的历史均价Action - * - * @param city - * @param region - * @param name - * @param weekCount - * @return - */ - public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, - @Param(name = "weekCount") Integer weekCount) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - int count = OfcChartUtils.YEAR_COUNT * 7; - if (null != weekCount && weekCount > 0) { - count = weekCount; - } - if (StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名为必填项")); - return mav; - } - District currentDistrict = null; - city = knowbaseService.matchingCityDefaultNull(city); - if (StringUtils.isBlank(city)) { - city = "上海"; - } - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - String region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (!city.equals(tempCity)) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - currentDistrict = d; - break; - } - } - } - - if (null == currentDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "未找到相关小区信息")); - return mav; - } - - // 解析出城市区域小区名楼栋号 - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict - .getRegion(), currentDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,小区名")); - return mav; - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - String[] kinds = districtBo.getKind().split(","); - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, count); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); - return mav; - } - districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); - villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); - Map map = new HashMap(1); - map.put("stat", - DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), - DataUtil.descCollection(villaStatList))); - mav.setModel(map); - return mav; - } - - /** - * 根据小区名等获取小区属性 - * - * @param uniqueCodes - * @param districtNames - * @param regionNames - * @param cityNames - * @return - */ - public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, - @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, - @Param(name = "cityNames") String[] cityNames) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码、小区名、小区所在区域、小区所在城市必填")); - return mav; - } - if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码数组、小区名数组、小区所在区域数组、小区所在城市数组数量必须相同")); - return mav; - } - - ArrayList keys = new ArrayList(1); - Map key_uniqueCode = new HashMap(1); - for (int i = 0; i < cityNames.length; i++) { - cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); - regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); - DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); - keys.add(key); - key_uniqueCode.put(key, uniqueCodes[i]); - } - Map districtMap = this.districtService.findDistrictByKeyList(keys, false); - Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); - - Map dtoMap = new HashMap(1); - for (DistrictKey key : districtMap.keySet()) { - District d = districtMap.get(key); - if (null != d) { - String uniqueCode = key_uniqueCode.get(key); - DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); - dto.setUniqueCode(uniqueCode); - dto.setDistrictName(d.getName()); - if (null != newDistrictMap.get(key)) { - dto.setNewDistrict(true); - if (d.getStatus() == 5) { - dto.setOnSale(true); - } - if (StringUtils.isNotBlank(d.getDiscount())) { - dto.setDiscount(true); - } - } - if (null == dto.getOnSale()) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); - if (dh != null && dh.getSellCount() != 0) { - dto.setOnSale(true); - } - } - if (StringUtils.isNotBlank(d.getVideoUrl())) { - dto.setVideo(true); - } - dtoMap.put(uniqueCode, dto); - } - } - mav.setModel(dtoMap); - return mav; - } - - private boolean isRadiusSearch(DistrictSearchModel model) { - return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) - && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; - } - - public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - Map ret = new HashMap(1); - ret.put("RESULT", 500); - - ApiUser apiUser = checkNewAuthorized(token); - if (null == apiUser) { - return mav; - } - - try { - JSONArray disJsonArr = JSONArray.fromObject(data); - for (int i = 0; i < disJsonArr.size(); i++) { - JSONObject disJsonObj = disJsonArr.getJSONObject(i); - ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); - dis.setSource("open_api"); - dis.setUserId((int) apiUser.getId()); - dis.setCreationDate(new Date()); - dis.setModificationDate(dis.getCreationDate()); - extractDistrictService.save(dis); - } - } catch (JSONException e) { - return mav; - } - - ret.put("RESULT", 200); - return mav; - } - - public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } else { - District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - } - return mav; - } - - /** - * 获取小区图片 - * - * @param districtModel - * @return - */ - public Object listPicAction(DistrictModel districtModel) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(districtModel.getId())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); - return mav; - } - SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); - if (seaweedImages != null) { - mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages.getOutPics())); - } else { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "图片数据不存在")); - } - return mav; - } - public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception{ - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(address)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "地址必须输入")); - return mav; - } else { - String cat = "district"; + /** + * 获取小区的均价Action + * + * @param city + * @param region + * @param name + * @return + */ + public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,所在区域,小区名为必填项")); + return mav; + } + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,区域,小区名")); + return mav; + } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", city); - params.put("address", address); - params.put("category", "property"); - //新匹配接口 - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); - District property = null; - if (json != null && json.size() > 0) { - MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); - property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); - if (null == property) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - }else{ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - } - } - return mav; - } - - - /** - * 新版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; - } - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; - } + String kind = ""; + if (StringUtils.isNotBlank(districtBo.getEstateType2())) { + if (districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue()) != -1) { + kind = DistrictKindEnum.bieshu.getValue(); + } + if (districtBo.getEstateType2().indexOf("住宅") != -1 || districtBo.getEstateType2().indexOf("小区") != -1) { + if (kind.length() > 1) { + kind = kind + ","; + } + kind = kind + DistrictKindEnum.gongyu.getValue(); + } + districtBo.setKind(kind); - public void setDistrictStatService(DistrictStatService districtStatService) { - this.districtStatService = districtStatService; - } + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } - public void setDistrictHouseService(DistrictHouseService districtHouseService) { - this.districtHouseService = districtHouseService; - } - public void setAutoCompleteService(AutoCompleteService autoCompleteService) { - this.autoCompleteService = autoCompleteService; - } + String[] kinds = districtBo.getKind().split(","); - public void setMenuService(MenuService menuService) { - this.menuService = menuService; - } + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, 1); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); + return mav; + } - public void setKnowbaseService(KnowbaseService knowbaseService) { - this.knowbaseService = knowbaseService; - } + DistrictStat stat = null; + if (CollectionUtils.isNotEmpty(districtStatList)) { + stat = districtStatList.get(0); + } + if (CollectionUtils.isNotEmpty(villaStatList)) { + stat = villaStatList.get(0); + } - public void setApiUserService(ApiUserService apiUserService) { - this.apiUserService = apiUserService; - } + Map map = new HashMap(1); + map.put("avgPrice", stat.getAvgPrice()); + map.put("weekendMarkup", stat.getWeekendMarkup()); + mav.setModel(map); + return mav; + } - public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { - this.extractDistrictService = extractDistrictService; - } + /** + * 获取小区的历史均价Action + * + * @param city + * @param region + * @param name + * @param weekCount + * @return + */ + public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, + @Param(name = "weekCount") Integer weekCount) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + int count = OfcChartUtils.YEAR_COUNT * 7; + if (null != weekCount && weekCount > 0) { + count = weekCount; + } + if (StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名为必填项")); + return mav; + } + District currentDistrict = null; + city = knowbaseService.matchingCityDefaultNull(city); + if (StringUtils.isBlank(city)) { + city = "上海"; + } + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + String region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (!city.equals(tempCity)) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + currentDistrict = d; + break; + } + } + } + + if (null == currentDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "未找到相关小区信息")); + return mav; + } + + // 解析出城市区域小区名楼栋号 + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict + .getRegion(), currentDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,小区名")); + return mav; + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } + String[] kinds = districtBo.getKind().split(","); + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, count); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); + return mav; + } + districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); + villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); + Map map = new HashMap(1); + map.put("stat", + DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), + DataUtil.descCollection(villaStatList))); + mav.setModel(map); + return mav; + } + + /** + * 根据小区名等获取小区属性 + * + * @param uniqueCodes + * @param districtNames + * @param regionNames + * @param cityNames + * @return + */ + public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, + @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, + @Param(name = "cityNames") String[] cityNames) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码、小区名、小区所在区域、小区所在城市必填")); + return mav; + } + if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码数组、小区名数组、小区所在区域数组、小区所在城市数组数量必须相同")); + return mav; + } + + ArrayList keys = new ArrayList(1); + Map key_uniqueCode = new HashMap(1); + for (int i = 0; i < cityNames.length; i++) { + cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); + regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); + DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); + keys.add(key); + key_uniqueCode.put(key, uniqueCodes[i]); + } + Map districtMap = this.districtService.findDistrictByKeyList(keys, false); + Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); + + Map dtoMap = new HashMap(1); + for (DistrictKey key : districtMap.keySet()) { + District d = districtMap.get(key); + if (null != d) { + String uniqueCode = key_uniqueCode.get(key); + DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); + dto.setUniqueCode(uniqueCode); + dto.setDistrictName(d.getName()); + if (null != newDistrictMap.get(key)) { + dto.setNewDistrict(true); + if (d.getStatus() == 5) { + dto.setOnSale(true); + } + if (StringUtils.isNotBlank(d.getDiscount())) { + dto.setDiscount(true); + } + } + if (null == dto.getOnSale()) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); + if (dh != null && dh.getSellCount() != 0) { + dto.setOnSale(true); + } + } + if (StringUtils.isNotBlank(d.getVideoUrl())) { + dto.setVideo(true); + } + dtoMap.put(uniqueCode, dto); + } + } + mav.setModel(dtoMap); + return mav; + } + + private boolean isRadiusSearch(DistrictSearchModel model) { + return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) + && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; + } + + public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + Map ret = new HashMap(1); + ret.put("RESULT", 500); + + ApiUser apiUser = checkNewAuthorized(token); + if (null == apiUser) { + return mav; + } + + try { + JSONArray disJsonArr = JSONArray.fromObject(data); + for (int i = 0; i < disJsonArr.size(); i++) { + JSONObject disJsonObj = disJsonArr.getJSONObject(i); + ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); + dis.setSource("open_api"); + dis.setUserId((int) apiUser.getId()); + dis.setCreationDate(new Date()); + dis.setModificationDate(dis.getCreationDate()); + extractDistrictService.save(dis); + } + } catch (JSONException e) { + return mav; + } + + ret.put("RESULT", 200); + return mav; + } + + public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } else { + District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } + return mav; + } + + // 保存周边配套 + public Object saveFacilitiesAction(DistrictFacilitysModel model) { + model = processParam(model); + if (StringUtils.isNotBlank(model.getId())) { + Map data = new HashMap(); + data.put("kindergarten", model.getKindergarten()); + data.put("primarySchool", model.getPrimarySchool()); + data.put("middleSchool", model.getMiddleSchool()); + data.put("university", model.getUniversity()); + data.put("hospital", model.getHospital()); + data.put("shop", model.getShop()); + data.put("supermarket", model.getSupermarket()); + data.put("foodShop", model.getFoodShop()); + data.put("bus", model.getBus()); + data.put("bank", model.getBank()); + data.put("atm", model.getAtm()); + data.put("metro",model.getMetro()); + districtService.updateDistrictFacilitysById(data, model.getId()); + } else { + DistrictFacilitys districtFacilitys = CommonDtoUtils.transformV(DistrictFacilitys.class, model); + districtService.saveDistrictFacilitys(districtFacilitys); + } + return null; + } + + public static List convertToList(String value) { + List result = new ArrayList(); + + if (value != null && !value.isEmpty()) { + value = value.replaceAll("\\[", "").replaceAll("]", "").replaceAll(" ",""); + String[] splitValues = value.split(","); // 按逗号分割 + + // 遍历数组并过滤空字符串 + for (String str : splitValues) { + if (!str.isEmpty()) { // 只添加非空字符串 + result.add(str); + } + } + } + + return result.isEmpty() ? null : result; // 如果结果为空,则返回 null + } + + public static DistrictFacilitysModel processParam(DistrictFacilitysModel model) { + // 处理每个字段,确保只有非 null 字段才进行处理 + if (model.getKindergarten() != null) { + model.setKindergarten(convertToList(model.getKindergarten().toString())); + } + + if (model.getPrimarySchool() != null) { + model.setPrimarySchool(convertToList(model.getPrimarySchool().toString())); + } + + if (model.getMiddleSchool() != null) { + model.setMiddleSchool(convertToList(model.getMiddleSchool().toString())); + } + + if (model.getUniversity() != null) { + model.setUniversity(convertToList(model.getUniversity().toString())); + } + + if (model.getHospital() != null) { + model.setHospital(convertToList(model.getHospital().toString())); + } + + if (model.getShop() != null) { + model.setShop(convertToList(model.getShop().toString())); + } + + if (model.getSupermarket() != null) { + model.setSupermarket(convertToList(model.getSupermarket().toString())); + } + + if (model.getFoodShop() != null) { + model.setFoodShop(convertToList(model.getFoodShop().toString())); + } + + if (model.getBus() != null) { + model.setBus(convertToList(model.getBus().toString())); + } + + if (model.getBank() != null) { + model.setBank(convertToList(model.getBank().toString())); + } + + if (model.getAtm() != null) { + model.setAtm(convertToList(model.getAtm().toString())); + } + if (model.getMetro() != null) { + model.setMetro(convertToList(model.getMetro().toString())); + } + return model; + } + + /** + * 获取小区图片 + * + * @param districtModel + * @return + */ + public Object listPicAction(DistrictModel districtModel) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(districtModel.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); + if (seaweedImages != null) { + mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "图片数据不存在")); + } + return mav; + } + + + public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(address)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "地址必须输入")); + return mav; + } else { + String cat = "district"; + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", city); + params.put("address", address); + params.put("category", "property"); + //新匹配接口 + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); + District property = null; + if (json != null && json.size() > 0) { + MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); + property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); + if (null == property) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + } + } + return mav; + } + + + /** + * 新版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; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDistrictHouseService(DistrictHouseService districtHouseService) { + this.districtHouseService = districtHouseService; + } + + public void setAutoCompleteService(AutoCompleteService autoCompleteService) { + this.autoCompleteService = autoCompleteService; + } + + public void setMenuService(MenuService menuService) { + this.menuService = menuService; + } + + public void setKnowbaseService(KnowbaseService knowbaseService) { + this.knowbaseService = knowbaseService; + } + + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { + this.extractDistrictService = extractDistrictService; + } public DistrictService getDistrictService() { return districtService; @@ -1310,11 +1403,11 @@ public class DistrictController { this.regionStatRentService = regionStatRentService; } - public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { - this.districtFacilitysService = districtFacilitysService; - } + public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { + this.districtFacilitysService = districtFacilitysService; + } - public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { - this.seaweedImagesService = seaweedImagesService; - } + public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { + this.seaweedImagesService = seaweedImagesService; + } } From 532c4b5230cc7111fecd70fd3a377b237babb1d8 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 15:14:19 +0800 Subject: [PATCH 077/247] =?UTF-8?q?=E7=99=BE=E5=BA=A6=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0map=5Fpoi=5F2024=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 046585431..ad8c13d64 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -46,8 +46,8 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { - run() -// oldPoiMagre() +// run() + oldPoiMagre() } def run(){ @@ -323,7 +323,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("gaode_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { From 667fae514ced67ec197841eb4930ebc71374a373 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 16:23:10 +0800 Subject: [PATCH 078/247] =?UTF-8?q?=E8=AF=84=E4=BC=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/static/js/select.js | 2 +- .../fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl | 4 ++-- .../fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/static/js/select.js b/projects/fangjia-open/src/main/webapp/static/js/select.js index 6adecdba3..75c84511f 100644 --- a/projects/fangjia-open/src/main/webapp/static/js/select.js +++ b/projects/fangjia-open/src/main/webapp/static/js/select.js @@ -144,7 +144,7 @@ $(document).on('click', '.create-actions03', function () { label: true }, { - text: '鍏瘬', + text: '鏅�氫綇瀹�', bold: true, onClick: function () { $("a.create-actions03").empty().text(this.text).addClass("selected") diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 1da5a0547..8a35807f4 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -92,9 +92,9 @@
    -
    寤虹瓚绫诲瀷锛�
    +
    鎴垮眿绫诲瀷锛�
    -

    璇烽�夋嫨寤虹瓚绫诲瀷

    +

    璇烽�夋嫨鎴垮眿绫诲瀷

    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index 286d93991..821f5f2a7 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -189,7 +189,7 @@ <#if evaluation?? && (fjtEvaluation.buildType)! == 3> 浣忓畢 <#elseif fjtEvaluation.buildType! == 8> - 鍏瘬 + 鏅�氫綇瀹� <#elseif fjtEvaluation.buildType! == 4> 鐙珛鍒 <#elseif fjtEvaluation.buildType! == 5> From 143ec1daff56fedf4e4118a145ea129d0cef827f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 16:25:36 +0800 Subject: [PATCH 079/247] update --- .../fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index ad8c13d64..d62216fa2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -358,9 +358,9 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ - if(!cityObj.city.contains("五指山市")){ - continue - } +// if(!cityObj.city.contains("攀枝花市")){ +// continue +// } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" @@ -463,7 +463,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def findEsPoiByCity(city){ QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) def map = new HashMap() - ElasticUtils89.executeQuery("192.168.0.89", "didata_map_poi", queryBuilder, { String id, Map d-> + ElasticUtils89.executeQuery("192.168.0.89", "map_poi_2024", queryBuilder, { String id, Map d-> def district = "" if(d.district){ district = d.district From 5a79ace9debccaae9d4aec786c11e638e65e4b20 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 16:36:12 +0800 Subject: [PATCH 080/247] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=94=BE=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_handle/AutoAddDistrictBatch.groovy | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy index 809fa216c..9d223e038 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy @@ -35,22 +35,22 @@ class AutoAddDistrictBatch extends BaseBatch{ @Override void process(Object args) { -// //查找第三方匹配没有匹配上的小区 -// def citys = CommonDatautils.findAllCity() -// def list = [] -// list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "百度类型","高德地图", "高德类型"] -// for(def c : citys){ -// def noMatchDatas = findNoMatchResult(c) -// println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() -// def rets = checkDatas(noMatchDatas.keySet()) -// list.addAll(rets) -// } + //查找第三方匹配没有匹配上的小区 + def citys = CommonDatautils.findAllCity() + def list = [] + list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "百度类型","高德地图", "高德类型"] + for(def c : citys){ + def noMatchDatas = findNoMatchResult(c) + println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() + def rets = checkDatas(noMatchDatas.keySet()) + list.addAll(rets) + } def fileName = "/home/goojia/gj/add_dist_info.xlsx" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\add_dist_info_1.xlsx" } -// ExcelUtils.write(fileName, list, "待入库数据") + ExcelUtils.write(fileName, list, "待入库数据") check(fileName) From d84a66dbfb0b07b0e2ca9a5cc4c5c56c765ba79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 26 Dec 2024 10:12:22 +0800 Subject: [PATCH 081/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/WeiXinEvaluationController.java | 21 +++++++++++++++ .../open/model/weixin/EvaluationModel.java | 27 +++++++++++++++++++ .../service/util/EvaluateParamMap.java | 3 +++ 3 files changed, 51 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 716c2156f..2607ac3dc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -763,6 +763,27 @@ public class WeiXinEvaluationController { } return model; } + + // 均价对比接口(房价通小程序用) + public Object otherSourcePlusAction(EvaluationModel model){ + + JsonModel jsonMmodel = new JsonModel(); + Map dataMap = new HashMap(); + if(StringUtils.isNotBlank(model.getCityName()) && StringUtils.isNotBlank(model.getRegion()) && StringUtils.isNotBlank(model.getName()) && model.getBuildType() != null){ + String category = getEnCategory(model.getBuildType()); + AverageStatistics averageStatistics = averageStatisticsService.findOneAverageStatictics(model.getCityName(), model.getName(), category); + + Integer tradeAvgPrice = dealPriceService.findDealPrices(model.getCityName(), model.getRegion(), model.getName(), DateUtil.getFirstDayOfMonth(new Date(), -6), DateUtil.getFirstDayOfMonth(new Date(), 0)); + //columnX = "['成交均价(近半年)','房价网挂牌均价','搜房挂牌均价','安居客挂牌均价']"; + dataMap.put("dealPrice", tradeAvgPrice); + dataMap.put("fjw", averageStatistics.getFangjiaPrice()); + dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); + dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + } + jsonMmodel.setJsonModel(dataMap); + return jsonMmodel; + } + //均价对比 public Object otherSourceAction(EvaluationModel model){ diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java index cdf645a31..44cc2ca36 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java @@ -57,6 +57,9 @@ public class EvaluationModel extends BaseModel{ private Map> reportFileMap; private UserTrades userTrades; private String address; + private Integer buildType; + private String name; + private String region; public void setId(String id) { @@ -326,4 +329,28 @@ public class EvaluationModel extends BaseModel{ public void setLoan(Integer loan) { this.loan = loan; } + + public Integer getBuildType() { + return buildType; + } + + public void setBuildType(Integer buildType) { + this.buildType = buildType; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java index 0bc28d9f5..2bc49ea24 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java @@ -52,6 +52,9 @@ public class EvaluateParamMap { BUILD_TYPE_MAP.put("6", "联排别墅"); BUILD_TYPE_MAP.put("7", "叠加别墅"); BUILD_TYPE_MAP.put("8", "公寓"); + BUILD_TYPE_MAP.put("9","联列住宅"); + BUILD_TYPE_MAP.put("10","花园住宅"); + BUILD_TYPE_MAP.put("11","旧式里弄2"); HOUSE_PROPERTY_MAP.put("1","个人产权"); HOUSE_PROPERTY_MAP.put("2","集体产权"); From 278ce11890c62983893e87739e2482838e1d18ec Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 27 Dec 2024 11:02:03 +0800 Subject: [PATCH 082/247] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/DistrictController.java | 25 ++++++++++ .../open/model/weixin/DistrictModel.java | 40 +++++++++++++++ .../mongo/fangjia/SeaweedImagesService.java | 4 ++ .../fangjia/SeaweedImagesServiceImpl.java | 50 +++++++++++++++++++ 4 files changed, 119 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index ba7c22ede..28559ace3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -1285,6 +1285,31 @@ public class DistrictController { } return mav; } + public Object deletePicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + seaweedImagesService.deleteImage(model.getId(),model.getUrl(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "删除成功")); + return mav; + } + public Object addPicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getImageUrls()!=null){ + model.setImageUrls(convertToList(model.getImageUrls().toString())); + } + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + seaweedImagesService.addImage(model.getId(),model.getImageUrls(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "添加成功")); + return mav; + } public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java index 5f9c5a223..b3c210301 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java @@ -57,6 +57,15 @@ public class DistrictModel extends BaseModel { * 判断是不是友达 */ private boolean isYouDa; + //用于删除和新增 + // 图片url + private String url; + //房型图 或 外景图 + private String PicType; + //几室 + private String roomType; + + private List imageUrls; public Boolean getShowPrice() { return showPrice; @@ -241,4 +250,35 @@ public class DistrictModel extends BaseModel { // public void setBuildName(String buildName) { // this.buildName = buildName; // } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRoomType() { + return roomType; + } + public void setRoomType(String roomType) { + this.roomType = roomType; + } + + public String getPicType() { + return PicType; + } + + public void setPicType(String picType) { + PicType = picType; + } + + public List getImageUrls() { + return imageUrls; + } + + public void setImageUrls(List imageUrls) { + this.imageUrls = imageUrls; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java index 945437de1..ae7dd522d 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java @@ -12,4 +12,8 @@ import java.util.Map; */ public interface SeaweedImagesService { public SeaweedImages findById(String id); + + public void deleteImage(String id, String url,String picType,String roomType); + public void addImage(String id, List urls,String picType,String roomType); + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java index a58462040..37143cc5d 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java @@ -3,13 +3,63 @@ package com.fangjia.service.mongo.fangjia; import com.fangjia.dal.mongo.dao.SeaweedImagesDao; import com.fangjia.dal.mongo.model.SeaweedImages; +import java.util.List; +import java.util.Map; + public class SeaweedImagesServiceImpl implements SeaweedImagesService { private SeaweedImagesDao seaweedImagesDao; + @Override public SeaweedImages findById(String id) { return seaweedImagesDao.findById(id); } + @Override + public void deleteImage(String id, String url, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.remove(url); + floorplanPics.put(roomType,roomPicList); + seaweedImages.setFloorplanPics(floorplanPics); + } + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.remove(url); + seaweedImages.setOutPics(outPics); + } + } + seaweedImagesDao.update(seaweedImages); + } + + @Override + public void addImage(String id, List urls, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.addAll(urls); + floorplanPics.put(roomType,roomPicList); + }else { + floorplanPics.put(roomType,urls); + } + seaweedImages.setFloorplanPics(floorplanPics); + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.addAll(urls); + seaweedImages.setOutPics(outPics); + }else { + seaweedImages.setOutPics(urls); + } + } + seaweedImagesDao.update(seaweedImages); + } + public void setSeaweedImagesDao(SeaweedImagesDao seaweedImagesDao) { this.seaweedImagesDao = seaweedImagesDao; } From 3790007a0b518e09ebeffd8562d27d94cfb9ce47 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 11:38:53 +0800 Subject: [PATCH 083/247] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index d62216fa2..8bef2fbe0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -358,7 +358,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ -// if(!cityObj.city.contains("攀枝花市")){ +// if(!cityObj.city.contains("商洛市")){ // continue // } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" From 9ccae42cf1c30b2cb4f94043c82fa1c6cc4ecc7b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 13:59:24 +0800 Subject: [PATCH 084/247] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccbevaluation/ThirdPartyPriceBatch.groovy | 67 ++++++++++++++++++- .../thirdPriceCrawl/SynchDistrictPrice.groovy | 4 +- .../ThirdDataToGatherBatch.groovy | 2 +- 3 files changed, 69 insertions(+), 4 deletions(-) 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 98612d573..ffd743d5c 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 @@ -30,8 +30,11 @@ class ThirdPartyPriceBatch extends BaseBatch { static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - 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 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", + "乐有家":"21","幸福里":"22","中国房价行情":"23","常州住房":"24" + ] def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") @@ -263,6 +266,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(third.get("csjj_esf_price")){ price_map.csjj_avg_price = third.get("csjj_esf_price") } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -313,6 +340,18 @@ class ThirdPartyPriceBatch extends BaseBatch { web = "房产超市" }else if(k=="csjj_avg_price"){ web = "城市居家" + }else if(k=="leyoujia_avg_price"){ + web = "乐有家" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "吉屋网" + }else if(k=="xingfuli_avg_price"){ + web = "幸福里" + }else if(k=="creprice_avg_price"){ + web = "中国房价行情" + }else if(k=="zwfc_avg_price"){ + web = "常州住房" } ret << sourceMap.get(web) @@ -603,6 +642,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_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/thirdPriceCrawl/SynchDistrictPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy index 5f07adb27..1b9e9e1e1 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,9 @@ 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 = ["安居客小程序":"安居客","搜房":"搜房","诸葛找房APP":"诸葛找房","幸福里APP":"幸福里","吉屋":"吉屋","中国房价行情":"中国房价行情","贝壳找房":"贝壳找房", + "链家":"链家","C21":"C21","城市房产小程序":"城市房产","乐有家":"乐有家","我爱我家":"我爱我家","中原地产":"中原地产","兔博士PC端":"兔博士", + "365淘房":"365淘房","Q房":"Q房","麦田":"麦田","常州住房":"常州住房"] 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 aaf9d6380..d1fb7dc6f 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 @@ -33,7 +33,7 @@ class ThirdDataToGatherBatch extends BaseBatch{ "链家":"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", - "中国房价行情":"creprice_esf","常州住房":"zwfc_esf" + "中国房价行情":"creprice_esf","常州住房":"zwfc_esf", "房天下":"fang_esf" ] public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2) From 37a0d75bc5ba3c20838bc5b0ce03a6fad9f94682 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 15:49:18 +0800 Subject: [PATCH 085/247] =?UTF-8?q?=E5=86=85=E9=83=A8=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FjwThirdPartyPriceBatch.groovy | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) 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 f1925938e..892ebfea5 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 @@ -32,8 +32,11 @@ class FjwThirdPartyPriceBatch extends BaseBatch { static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - 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 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", + "乐有家":"21","幸福里":"22","中国房价行情":"23","常州住房":"24" + ] def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", @@ -269,6 +272,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { if(third.get("fccs_esf_price")){ price_map.fccs_avg_price = third.get("fccs_esf_price") } + if(third.get("csjj_esf_price")){ + price_map.csjj_avg_price = third.get("csjj_esf_price") + } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -317,6 +347,20 @@ class FjwThirdPartyPriceBatch extends BaseBatch { web = "我爱我家" }else if(k=="fccs_avg_price"){ web = "房产超市" + }else if(k=="csjj_avg_price"){ + web = "城市居家" + }else if(k=="leyoujia_avg_price"){ + web = "乐有家" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "吉屋网" + }else if(k=="xingfuli_avg_price"){ + web = "幸福里" + }else if(k=="creprice_avg_price"){ + web = "中国房价行情" + }else if(k=="zwfc_avg_price"){ + web = "常州住房" } ret << sourceMap.get(web) @@ -470,6 +514,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { dataMap.put("fccs_esf_price", db.get("fccs_esf_price")) } + if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ + dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) + } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_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 140470bbc576ba7c2933d207d25a66c67c7de8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 16:09:03 +0800 Subject: [PATCH 086/247] =?UTF-8?q?500=E9=94=99=E8=AF=AF=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=8D=87=E7=BA=A7=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 2 +- .../fangjia/open/interceptors/AuthenticationInterceptor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 7848e9b25..3b2021dce 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -35,7 +35,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { context.getResponse().setStatus(500); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}"); + context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务升级中...\"}"); } public static String getLocalHostIP() { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index b3e60dcbd..c04cab406 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -111,7 +111,7 @@ public class AuthenticationInterceptor implements Interceptor { String ip = getLocalHostIP(); String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; try { - DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!"); + DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication error!"); } catch (Exception e1) { e1.printStackTrace(); } From e880ab201510a2571bbdf084d938034ccf26e640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 16:57:18 +0800 Subject: [PATCH 087/247] 503 --- .../src/main/java/com/fangjia/open/HttpStatusCodeEnum.java | 3 ++- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java index 402218d72..a20704090 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java @@ -8,7 +8,8 @@ public enum HttpStatusCodeEnum { BAD_REQUEST_DECRYPT_ERROR(4002,"加密参数解密失败"), UN_AUTHORIZED(401,"请求未被授权"), SERVER_ERROR(500,"服务器内部错误"), - SERVER_FORBID(403,"请求频繁"); + SERVER_FORBID(403,"请求频繁"), + UPGRADE(503,"服务升级中"); private final int code; private final String msg; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 3b2021dce..3948d69ca 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -32,10 +32,11 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { } catch (Exception e1) { e1.printStackTrace(); } - context.getResponse().setStatus(500); + // 临时改,后面还原 TODO + context.getResponse().setStatus(503); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务升级中...\"}"); + context.getResponse().getWriter().println("{\"code\":503, \"msg\":\"服务升级中\"}"); } public static String getLocalHostIP() { From 9dd5a962d1df24742c4c4f1b92469a98ed4afd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 17:23:32 +0800 Subject: [PATCH 088/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 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 adc9f45e3..34bc9be15 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 @@ -5879,7 +5879,8 @@ public class PropertyController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("address", district.getAddress()); districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("cal_date", model.getCalDate()); + //districtPriceMap.put("cal_date", model.getCalDate()); + districtPriceMap.put("unitPrice", (int)(evaluation.getTotalPrice() / evaluation.getArea())); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); return mav; } else { From f13137cb24d12a09e1a43cd5457ecc83880f16c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 17:24:54 +0800 Subject: [PATCH 089/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 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 34bc9be15..45f930632 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 @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.ParseException; @@ -5880,7 +5881,7 @@ public class PropertyController { districtPriceMap.put("address", district.getAddress()); districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); //districtPriceMap.put("cal_date", model.getCalDate()); - districtPriceMap.put("unitPrice", (int)(evaluation.getTotalPrice() / evaluation.getArea())); + districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); return mav; } else { From 0dc186a334742da684fc142b9d2b9ac50d0ce2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 30 Dec 2024 09:30:37 +0800 Subject: [PATCH 090/247] =?UTF-8?q?=E8=BF=98=E5=8E=9F500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 3948d69ca..7848e9b25 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -32,11 +32,10 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { } catch (Exception e1) { e1.printStackTrace(); } - // 临时改,后面还原 TODO - context.getResponse().setStatus(503); + context.getResponse().setStatus(500); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":503, \"msg\":\"服务升级中\"}"); + context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}"); } public static String getLocalHostIP() { From ca239765c99dd452bf5cc08555720ecae2f7de20 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 30 Dec 2024 10:43:18 +0800 Subject: [PATCH 091/247] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=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/NewGaoDePoiBatch.groovy | 11 +++++++---- .../gj/data_handle/ThirdPriceMappingBatch.groovy | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 8bef2fbe0..fd631c5e0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -357,10 +357,12 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() + def index = 0 for(def cityObj : cityList){ -// if(!cityObj.city.contains("商洛市")){ -// continue -// } + index ++ + if(index <140){ + continue + } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" @@ -369,9 +371,10 @@ class NewGaoDePoiBatch extends BaseBatch{ File file=new File(fileName); if(file.exists()){ def results = readCSV(fileName) - println cityObj.province+" " +cityObj.city+" "+results.size() + println "运行城市:"+cityObj.province+" " +cityObj.city+" "+results.size() if(results){ def megerMap = poiRepeat(cityObj.city, results) + println "待保存:" + cityObj.city +" "+megerMap.size() save(megerMap.values()) } }else{ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy index d1db63f64..7560c83ef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy @@ -40,7 +40,7 @@ class ThirdPriceMappingBatch extends BaseBatch{ @Override public void process(Object args) { // //将新增数据同步过来 - addNemCommunity() +// addNemCommunity() //// //接口进行匹配 match() From 2fc12021c97fa1b0a88e36d907415a4dfad51009 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 2 Jan 2025 13:23:46 +0800 Subject: [PATCH 092/247] =?UTF-8?q?/district/suggest=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/DistrictController.java | 57 ++++++++++--------- .../fangjia/service/api/AutoCompleteBo.java | 11 ++++ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index ed11d51ae..c254da4bf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -46,7 +46,7 @@ public class DistrictController { private DistrictStatRentService districtStatRentService; private DistrictStatService districtStatService; private UserCityService userCityService; - private FjtUsersService fjtUsersService; + private FjtUsersService fjtUsersService; private SeaweedImagesService seaweedImagesService; @@ -59,14 +59,14 @@ public class DistrictController { * @param keyword * @return */ - public Object suggestAction( @Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, - @Param(name = "limit") Integer limit,@Param(name="lat")Double lat, @Param(name="lng")Double lng) { + public Object suggestAction(@Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, + @Param(name = "limit") Integer limit, @Param(name = "lat") Double lat, @Param(name = "lng") Double lng) { JsonModel model = new JsonModel(); if (limit == null || limit > 100 || limit <= 0) { limit = 10; } System.out.println(cat + "#" + city + "#" + keyword + "#" + limit + "#" + lng + "#" + lat); - List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); + List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); model.setJsonModel(suggestList); return model; } @@ -79,14 +79,14 @@ public class DistrictController { String login_user_type = CookieUtils.getCookieValue(request, "login_user_type"); //保存企业用户选择的城市,企业用户7天 - String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id"); + String weiXinId = CookieUtils.getCookieValue(request, "we_chat_open_id"); // if(StringUtils.isBlank(login_user_type) || StringUtils.isBlank(weiXinId)){ // response.sendRedirect("/coming"); // return null; // } - if("b".equals(login_user_type) || "gb".equals(login_user_type)){ - CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_"+ login_user_type , model.getCityName()); - } + if ("b".equals(login_user_type) || "gb".equals(login_user_type)) { + CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_" + login_user_type, model.getCityName()); + } try { Long userId = Long.parseLong(CookieUtils.getCookieValue(request, "login_user_id")); if (userId != null) { @@ -118,14 +118,14 @@ public class DistrictController { BooleanQuery srQuery1 = new BooleanQuery(); BooleanQuery nameQuery = new BooleanQuery(); - // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); nameQuery.add(new TermQuery(new Term("keyword", keyword)), BooleanClause.Occur.SHOULD); //nameQuery.add(new TermQuery(new Term("keyword_cjk", keyword)), BooleanClause.Occur.SHOULD);//这个重要,因seaweed不支持模糊搜索,当输入"中远两"需用此进行搜索 srQuery1.add(nameQuery, BooleanClause.Occur.SHOULD); - if(lat != null && lng != null && lat != 0 && lng != 0){ + if (lat != null && lng != null && lat != 0 && lng != 0) { Map geo = GeocodeUtils.geoconvBaiduToGoogle(lng, lat); SdQuery sdQuery = new SdQuery(); sdQuery.setPoint(geo.get("lat") + "," + geo.get("lng")); @@ -134,7 +134,7 @@ public class DistrictController { params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); } params.add(new QueryParam("$sr", new SrQuery(srQuery1))); - List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias","id"}); + List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias", "id", "alias"}); List ret = new ArrayList(districts.size()); for (District district : districts) { AutoCompleteBo bo = new AutoCompleteBo(); @@ -143,24 +143,27 @@ public class DistrictController { bo.setDesc(district.getAddress()); bo.setRegion(district.getRegion()); bo.setId(district.getId()); + if (!district.getAlias().isEmpty()) { + bo.setAlias(district.getAlias()); + } ret.add(bo); } return ret; } - public Object districtDetailAction(DistrictModel districtModel,HttpServletRequest request,HttpServletResponse response) { + public Object districtDetailAction(DistrictModel districtModel, HttpServletRequest request, HttpServletResponse response) { //id和name不能同时为空 - if(StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { + if (StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { districtModel.setMsg("参数错误"); return districtModel; } District district = null; - if(StringUtils.isNotBlank(districtModel.getId())) { + if (StringUtils.isNotBlank(districtModel.getId())) { district = districtService.findById(districtModel.getId()); - if(district != null) { + if (district != null) { districtModel.setCityName(district.getCity()); districtModel.setRegion(district.getRegion()); districtModel.setName(district.getName()); @@ -176,7 +179,6 @@ public class DistrictController { String userId = CookieUtils.getCookieValue(request, "login_user_id"); - //小区租金 List districtStatRentBos = districtStatRentService.findAllHouseTypeByDistrictStatRent(new DistrictKey(district)); //处理图片链接 @@ -195,8 +197,8 @@ public class DistrictController { districtModel.setDistrictStatBo(districtStatBo); districtModel.setDistrictStatRentBos(districtStatRentBos); - String city=request.getParameter("city"); - boolean is=true; + String city = request.getParameter("city"); + boolean is = true; if (null != districtStatBo && null != districtStatBo.getDefaultDistrictStat()) { double credit = districtStatBo.getDefaultDistrictStat().getCredit(); @@ -215,7 +217,7 @@ public class DistrictController { } else { is = true; } - if(!is){ + if (!is) { try { response.sendRedirect("wrongPrice"); } catch (Exception e) { @@ -225,7 +227,6 @@ public class DistrictController { } - private DistrictStatBo getDistrictStat(DistrictKey districtKey) { District district = districtService.findDistrict(districtKey, true); DistrictStatBo statBo = null; @@ -239,8 +240,8 @@ public class DistrictController { // 同比数据 if (statBo != null) { Date date = DateUtil.getThisWeekInLastYear(); - Date[] dateList = { DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), - DateUtil.getAfterDay(date, 14), date }; + Date[] dateList = {DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), + DateUtil.getAfterDay(date, 14), date}; DistrictStatBo yearPeriodStatBo = null; Integer markup = Integer.MAX_VALUE; @@ -330,9 +331,9 @@ public class DistrictController { this.userCityService = userCityService; } - public void setFjtUsersService(FjtUsersService fjtUsersService) { - this.fjtUsersService = fjtUsersService; - } + public void setFjtUsersService(FjtUsersService fjtUsersService) { + this.fjtUsersService = fjtUsersService; + } public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { this.seaweedImagesService = seaweedImagesService; diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 0b886ac78..3e8c53c6a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -2,6 +2,8 @@ package com.fangjia.service.api; import com.fangjia.dal.mongo.model.PriceJiucuo; +import java.util.List; + public class AutoCompleteBo { private String val; private String desc; @@ -20,6 +22,8 @@ public class AutoCompleteBo { private Double lat; private Double lng; + private List alias; + /*** @Deprecated end ****/ public String getName() { @@ -133,4 +137,11 @@ public class AutoCompleteBo { public void setLng(Double lng) { this.lng = lng; } + public List getAlias() { + return alias; + } + + public void setAlias(List alias) { + this.alias = alias; + } } From 8b5fddd200da3dffa5c92443d857ce0dc4e8a3d9 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 2 Jan 2025 13:54:55 +0800 Subject: [PATCH 093/247] =?UTF-8?q?/district/suggest=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/DistrictController.java | 11 +++++++++-- .../java/com/fangjia/service/api/AutoCompleteBo.java | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index c254da4bf..442e4b77a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -143,8 +143,15 @@ public class DistrictController { bo.setDesc(district.getAddress()); bo.setRegion(district.getRegion()); bo.setId(district.getId()); - if (!district.getAlias().isEmpty()) { - bo.setAlias(district.getAlias()); + if (!district.getName().contains(keyword)) { + if (district.getAlias() != null && !district.getAlias().isEmpty()) { + for (String alias : district.getAlias()) { + if (alias.contains(keyword)){ + bo.setAlias(alias); + break; + } + } + } } ret.add(bo); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 3e8c53c6a..9e714a4bb 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -22,7 +22,7 @@ public class AutoCompleteBo { private Double lat; private Double lng; - private List alias; + private String alias; /*** @Deprecated end ****/ @@ -137,11 +137,12 @@ public class AutoCompleteBo { public void setLng(Double lng) { this.lng = lng; } - public List getAlias() { + + public String getAlias() { return alias; } - public void setAlias(List alias) { + public void setAlias(String alias) { this.alias = alias; } } From 1a4817c33896b2e7595301179e1a02e23519b49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 3 Jan 2025 17:40:28 +0800 Subject: [PATCH 094/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A6=86=E7=9B=96BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 4800e992c..bc9ada616 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -747,11 +747,8 @@ public class ComprehensiveQueryController { districtPriceMap.put("city", district.getCity()); districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); - if (evaluation.getAvgPrice2b() != null && evaluation.getAvgPrice2b() != 0) { - districtPriceMap.put("avgPrice", evaluation.getAvgPrice2b()); - } else { - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - } + // 估值中已经取过评估2B价格,且经过系数调整,不能在覆盖 + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); Long totalPrice = new BigDecimal((Integer)districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); districtPriceMap.put("totalPrice", totalPrice); From 761f6221c15c3416cc5eefc684ea806de6d1a32f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 07:56:47 +0800 Subject: [PATCH 095/247] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=88=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dealPrice/SynchDealPriceToEs.groovy | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy new file mode 100644 index 000000000..7d06921dc --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -0,0 +1,83 @@ +package com.fangjia.script.dealPrice + +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +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 SynchDealPriceToEs { + static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + + static main(args) { + def task = new SynchDealPriceToEs() + task.run() + } + + def run(){ + def batchsize = 1000 + def dbcursor = dealPriceConn.find(new BasicDBObject()).batchSize(batchsize) + def ret = [] + def index = 0 + for(def d : dbcursor){ + ret << d + if(ret.size()>=2000){ + save(ret) + ret.clear() + index ++ + println index + } + } + + } + + + def save(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 500; + int processedCount = 0; + def client = ElasticUtils.getClient("192.168.0.206") + + for(def map : rows){ +// def map = rows.get(key) + def data_id = map._id.toString() + map.remove("_id") + request.add(new IndexRequest("deal_price", "_doc", data_id).source(map, XContentType.JSON)); + + // 批量提交数据 + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+new Date().format("yyyy-MM-dd HH:mm:ss") + } + + request = new BulkRequest(); + } + } + + 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" + } + } + + } + +} From 920b3969b98d0becd0d58b2ac2e28a53eafb5752 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 10:21:32 +0800 Subject: [PATCH 096/247] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index fd631c5e0..a87c0b154 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -360,7 +360,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def index = 0 for(def cityObj : cityList){ index ++ - if(index <140){ + if(index <291){ continue } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" From 96e13d215ff1ef5d6a2fd891ebd37f272d88bd21 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 13:29:30 +0800 Subject: [PATCH 097/247] update --- .../dealPrice/SynchDealPriceToEs.groovy | 60 +++++++++++++++---- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 7d06921dc..13ea5e3de 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -3,8 +3,10 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.util.ElasticUtils +import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import com.mongodb.DBObject import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse import org.elasticsearch.action.index.IndexRequest @@ -21,23 +23,57 @@ class SynchDealPriceToEs { } def run(){ - def batchsize = 1000 - def dbcursor = dealPriceConn.find(new BasicDBObject()).batchSize(batchsize) - def ret = [] - def index = 0 - for(def d : dbcursor){ - ret << d - if(ret.size()>=2000){ - save(ret) - ret.clear() - index ++ - println index + def batchsize = 2000 + def citys = getCityCount() + citys.each{city,count-> + def dbcursor = dealPriceConn.find(new BasicDBObject("city", city)).batchSize(batchsize) + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) +// def index = 0 +// for(def d : dbcursor){ +// ret << d +// if(ret.size()>=2000){ +// save(ret) +// ret.clear() +// index ++ +// println index +// } +// } + } + } + + + def getCityCount(){ + + BasicDBObject match = null; + // 定义聚合管道,按 city 字段分组,并计算每个城市的数量 + DBObject groupFields = new BasicDBObject(); + +// match = new BasicDBObject('$match', new BasicDBObject("level", "城市")); + groupFields.put("_id", new BasicDBObject("city",'$city')) + + groupFields.put("count", new BasicDBObject('$sum', 1)); + DBObject group = new BasicDBObject('$group', groupFields); + + // 执行聚合查询 + AggregationOutput output = dealPriceConn.aggregate(Arrays.asList(group)); + def map = [:] + // 遍历结果 + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + if(obj.get("city")) { + int count = (Integer) result.get("count"); + map.put(obj.get("city"), count) } } - + return map; } + def save(rows){ BulkRequest request = new BulkRequest(); int batchSize = 500; From a1243552838406daee482bdc7f2b42ef91ca6d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 13:54:38 +0800 Subject: [PATCH 098/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=B9=E4=B8=BA2B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PropertyController.java | 4 +- .../service/district/DistrictStatService.java | 11 +++++ .../district/DistrictStatServiceImpl.java | 46 +++++++++++++++++++ 3 files changed, 60 insertions(+), 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 45f930632..fcee9783d 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 @@ -752,7 +752,9 @@ public class PropertyController { districtInfoDto.setDistrict(district.getRegion()); districtInfoDto.setName(district.getName()); districtInfoDto.setAddress(district.getAddress()); - int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + //int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + // 返回2B价格,小程序用,其他也改为2B + int avgPrice = districtStatService.findLatestDistrictAvgPrice2B(new DistrictKey(district), null); if (avgPrice != 0) { districtInfoDto.setAvgPrice(avgPrice); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java index a308e1a67..623a779b0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java @@ -295,6 +295,17 @@ public interface DistrictStatService { * @return */ public int findLatestDistrictAvgPrice(DistrictKey districtKey,Date weekend); + + /** + * 获得指定时间的小区均价2B + * + * @param districtKey + * @param weekend + * @return + */ + int findLatestDistrictAvgPrice2B(DistrictKey districtKey,Date weekend); + + /** diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 242aac83e..9d7d57f50 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1524,6 +1524,52 @@ public class DistrictStatServiceImpl implements DistrictStatService { return value; } + @Override + public int findLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend) { + if (weekend == null) { + weekend = DateUtil.getFirstDayOfWeek(new Date()); + } + String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_" + DateUtil.formatToYYMMDD(weekend); + Object obj = CacheUtils.getValue(this.getClass(), cacheKey); + if (obj != null) { + return (Integer)obj; + } + Integer value = doFindLatestDistrictAvgPrice2B(districtKey, weekend); + CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass(), cacheKey, value); + return value; + } + + public Integer doFindLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend){ + + DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); + if (statBo != null && statBo.getDefaultDistrictStat() != null) { + if (statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { + return statBo.getDefaultDistrictStat().getAvg_price_2b(); + } + if (statBo.getDefaultDistrictStat().getAvgPrice() > 0) { + return statBo.getDefaultDistrictStat().getAvgPrice(); + } + } + + double r = AveragerUtil.getFloatingRate(districtKey, weekend); + if (StringUtils.isNotBlank(districtKey.getCity()) && StringUtils.isNotBlank(districtKey.getRegion())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), districtKey.getRegion(), null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + if (StringUtils.isNotBlank(districtKey.getCity())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), null, null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + return 0; + + } + public Integer doFindLatestDistrictAvgPrice(DistrictKey districtKey, Date weekend){ DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); From ad5b9535d7839cf3187049b35dc26d7d18f8cc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:05:56 +0800 Subject: [PATCH 099/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/district/DistrictStatServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 9d7d57f50..9d2259bd7 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1529,7 +1529,7 @@ public class DistrictStatServiceImpl implements DistrictStatService { if (weekend == null) { weekend = DateUtil.getFirstDayOfWeek(new Date()); } - String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_" + DateUtil.formatToYYMMDD(weekend); + String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_2B_" + DateUtil.formatToYYMMDD(weekend); Object obj = CacheUtils.getValue(this.getClass(), cacheKey); if (obj != null) { return (Integer)obj; From 423e22f54ba6d8d9c582b5b1f7a21f54195fc4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:22:50 +0800 Subject: [PATCH 100/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E6=94=B9=E4=B8=BA2B=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/DistrictTrendController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java index 3005fcf82..18c8f0bbe 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java @@ -559,7 +559,7 @@ public class DistrictTrendController { DistrictStat ds = districtStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); districtJa.put(ja); } @@ -567,7 +567,7 @@ public class DistrictTrendController { DistrictStat ds = villaDistrictStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); villaJa.put(ja); } From 9f5f3812c3413128762f1f29e5eceea0b7f067f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:43:17 +0800 Subject: [PATCH 101/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E6=94=B9=E4=B8=BA2B=E4=BB=B7=E6=A0=BC?= 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 fcee9783d..89ee1cfcf 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 @@ -2429,7 +2429,7 @@ public class PropertyController { item.put("city", districtStat.getCity()); item.put("district", districtStat.getRegion()); item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvgPrice()); + item.put("avgPrice", districtStat.getAvg_price_2b()); if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); } else { From e7054d75f18438894f9b6cee9abdc4864cb92f77 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 6 Jan 2025 18:40:36 +0800 Subject: [PATCH 102/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/mongo/fangjia/SeaweedImagesServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java index 37143cc5d..e738c4d3b 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java @@ -3,6 +3,7 @@ package com.fangjia.service.mongo.fangjia; import com.fangjia.dal.mongo.dao.SeaweedImagesDao; import com.fangjia.dal.mongo.model.SeaweedImages; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,6 +41,9 @@ public class SeaweedImagesServiceImpl implements SeaweedImagesService { SeaweedImages seaweedImages = seaweedImagesDao.findById(id); if ("floorplanPics".equals(picType)) { Map> floorplanPics = seaweedImages.getFloorplanPics(); + if (floorplanPics==null){ + floorplanPics = new HashMap>(); + } List roomPicList = floorplanPics.get(roomType); if (roomPicList!=null && !roomPicList.isEmpty()){ roomPicList.addAll(urls); From 30736280a925d28fbf8cb252febe6d6afdec6a49 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:02:29 +0800 Subject: [PATCH 103/247] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dealPrice/SynchDealPriceToEs.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 13ea5e3de..355968064 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -2,6 +2,7 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject @@ -26,12 +27,17 @@ class SynchDealPriceToEs { def batchsize = 2000 def citys = getCityCount() citys.each{city,count-> - def dbcursor = dealPriceConn.find(new BasicDBObject("city", city)).batchSize(batchsize) - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } // def index = 0 // for(def d : dbcursor){ // ret << d From 82ef32206fd7e654fb668e244534bf97f6eab25a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:12:54 +0800 Subject: [PATCH 104/247] update --- .../dealPrice/SynchDealPriceToEs.groovy | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 355968064..f9f518cb8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -26,18 +26,21 @@ class SynchDealPriceToEs { def run(){ def batchsize = 2000 def citys = getCityCount() - citys.each{city,count-> - for(def year = 1999;year<=2025;year++){ - def q = new BasicDBObject("city", city) - q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) - def dbcursor = dealPriceConn.find(q).batchSize(batchsize) - println city +" "+ dbcursor.count() - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) - } + citys.each{city,count-> + if(city instanceof String){ + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } + } + // def index = 0 // for(def d : dbcursor){ // ret << d From 6959b95aeb1579118b7f9be08487f3f75f890a29 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 7 Jan 2025 14:58:55 +0800 Subject: [PATCH 105/247] =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/HouseController.java | 12 ++++++++---- .../com/fangjia/open/model/HouseSearchModel.java | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index fba91b6eb..8870454dc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1000,7 +1000,11 @@ public class HouseController { query.setCityDisplay(model.getCity()); Pager pager = new Pager(); pager.setStartRow(0); - pager.setPageSize(5); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize()); + } else { + pager.setPageSize(5); + } query.setPager(pager); query.setTable("latest_seawater"); houses = seawaterDao.findSeawatersByQuery(query); @@ -1303,14 +1307,14 @@ public class HouseController { pager.setPageSize(model.getPageSize()); query.setPager(pager); query.setTable("latest_seawater"); - if (StringUtils.isNotBlank(model.getSortField())){ + if (StringUtils.isNotBlank(model.getSortField())) { query.setSortField(model.getSortField()); - }else { + } else { query.setSortField("p_date"); } if ("asc".equals(model.getSortBy())) { query.setOrder(true); - }else { + } else { query.setOrder(false); } houses = seawaterDao.findSeawatersByQuery(query); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index 8f695b729..39fefbbdc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -27,6 +27,8 @@ public class HouseSearchModel extends SearchModel { private String district; private String cat; + + private Integer pageSize; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -197,4 +199,14 @@ public class HouseSearchModel extends SearchModel { public void setCat(String cat) { this.cat = cat; } + + @Override + public Integer getPageSize() { + return pageSize; + } + + @Override + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } } From 8539eadacace6d7dd15f1b06d2ace9c0f781c9b3 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 10 Jan 2025 13:58:12 +0800 Subject: [PATCH 106/247] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=89=88=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/evaluation/reportNew.ftl | 1 + .../src/main/webapp/user/login.ftl | 7 +- .../src/main/webapp/user/regSuccess.ftl | 12 +-- .../src/main/webapp/user/register.ftl | 76 +++++++++++++------ .../src/main/webapp/js/fangjia/v5/register.js | 4 +- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl index 65a71bdff..34a2e10c4 100644 --- a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl +++ b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl @@ -36,6 +36,7 @@ .adBoxLoan{width:100%;height:auto;background:none;border:solid 1px #f3f3f3;} .swiper-container{margin:0 1rem;margin-top:2rem;padding-bottom:1.5rem;top:0;} .swiper-container-horizontal > .swiper-pagination{bottom:0;} + .evaluation_content1 .error {top: 380px;} } @media (min-width:450px) and (max-width:600px) { .evaluation_inputInfo .cityChoice,.evaluation_inputInfo > div > div span{width:82%;} diff --git a/projects/fangjia-coresite/src/main/webapp/user/login.ftl b/projects/fangjia-coresite/src/main/webapp/user/login.ftl index ec4a9dc8b..254c8002f 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/login.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/login.ftl @@ -28,7 +28,7 @@ .main{width:768px;padding-top:0;} .main_left{width:768px;height: 650px;} .main_left div{padding-top: 140px;margin-left:30px;} - .main_left div p{text-align: left;} + .main_left div p{text-align: left; margin-top: 20px;} .main_left div p label{font-size: 42px;letter-spacing: 0px;} .main_left div p span{font-size: 30px;} .main_left div p small{display: none;} @@ -38,10 +38,10 @@ @media(max-device-width:414px){ .main_left{background:url(${staticUrl}/images/fangjia/v6/login-1.jpg);background-size: 100% 100%;background-repeat: no-repeat;background-position: center;} .main{width:414px;} - .main_left{width:414px;height: 450px;} + .main_left{width:414px;height: 200px;} .main_right{width:414px;height: 560px;} .main_left div {margin-left: 10px;margin-right: 70px;padding-top: 20px;} - .main_left div p label{font-size: 42px;letter-spacing: 0px;} + .main_left div p label{font-size: 22px;letter-spacing: 0px;} .main_left div p span {font-size: 27px;} .user00{width: 350px;height: 400px;margin-top: 30px;} .inputInfo {margin-bottom: 20px;} @@ -74,6 +74,7 @@ } .error {top: -20px;left: 106px;} + .main_left div {margin-top: 50px;} diff --git a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl index 5e5d02187..cd9b74e06 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl @@ -62,12 +62,12 @@ diff --git a/projects/fangjia-coresite/src/main/webapp/user/register.ftl b/projects/fangjia-coresite/src/main/webapp/user/register.ftl index 53127ca3a..6fce0e272 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/register.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/register.ftl @@ -12,11 +12,11 @@ - + @@ -69,7 +99,7 @@
      -
    • 娆㈣繋娉ㄥ唽鎴夸环缃�
    • +
    • 娆㈣繋娉ㄥ唽鎴夸环缃�
    @@ -99,7 +129,7 @@
    - +
    涓ゆ瀵嗙爜涓嶄竴鑷�
    @@ -110,11 +140,13 @@ 鎴戝凡闃呰骞舵帴鍙�銆婄敤鎴峰崗璁��
    - -
    鎴�
    - -

    鑻ユ湁浠讳綍闂锛岃鑷寸數瀹㈡湇锛�400-188-3787

    +
    + + +
    鎴�
    + +

    鑻ユ湁浠讳綍闂锛岃鑷寸數瀹㈡湇锛�400-188-3787

    diff --git a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js index 42db3b6a2..3457900c1 100644 --- a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js +++ b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js @@ -239,7 +239,9 @@ $(function() { if(refererUrl.endWith("gujia/report")){ refererUrl = refererUrl+"?fangjia=true"; } - window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + //鎴愬姛椤甸潰 + // window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + window.location.href = refererUrl } else { if (re.msg == "杈撳叆鐨勯獙璇佺爜涓嶆纭紝璇烽噸鏂拌緭鍏�") { $(".smscode_err").html("鐭俊楠岃瘉鐮侀敊璇�"); From 450e00c2cb43f7343143a9f1ad53f277c7a5b085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 10:53:48 +0800 Subject: [PATCH 107/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index bc9ada616..cf62e6111 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -416,16 +416,18 @@ public class ComprehensiveQueryController { // 原周边POI DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(district); - List hospitalList = facilitys.getHospital(); - List hospitals = new ArrayList(); - for (String hospital : hospitalList) { - if (hospital.endsWith("医院")){ - hospitals.add(hospital); + if (facilitys != null) { + List hospitalList = facilitys.getHospital(); + List hospitals = new ArrayList(); + for (String hospital : hospitalList) { + if (hospital.endsWith("医院")) { + hospitals.add(hospital); + } } + facilitys.setHospital(hospitals); + // 将周边POI数据放到结果集 + houseValueInformation.setSurroundingPoi(facilitys); } - facilitys.setHospital(hospitals); - // 将周边POI数据放到结果集 - houseValueInformation.setSurroundingPoi(facilitys); mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); return mav; } From 7953a15916bc4a1db0d54bcbaddd5ce9482b36a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 10:56:24 +0800 Subject: [PATCH 108/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index cf62e6111..e181b8af2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -425,9 +425,11 @@ public class ComprehensiveQueryController { } } facilitys.setHospital(hospitals); - // 将周边POI数据放到结果集 - houseValueInformation.setSurroundingPoi(facilitys); + } else { + facilitys = new DistrictFacilitys(); } + // 将周边POI数据放到结果集 + houseValueInformation.setSurroundingPoi(facilitys); mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); return mav; } From 5369465059adaedac4ab6c4fcff5d8f0887f0c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 12:10:50 +0800 Subject: [PATCH 109/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=A9=E4=B8=9A?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/ComprehensiveQueryController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index e181b8af2..1088d4648 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -245,7 +245,7 @@ public class ComprehensiveQueryController { Map communityAvgPriceParams = new HashMap(); communityAvgPriceParams.put("city", model.getCity()); communityAvgPriceParams.put("address", model.getAddress()); - communityAvgPriceParams.put("category", model.getCategory()); + communityAvgPriceParams.put("category", "district"); communityAvgPriceParams.put("useMap", "true"); communityAvgPriceParams.put("suggestName", String.valueOf(model.getName())); communityAvgPriceParams.put("preciseLevel", "strict"); From 774bef6b488df4be395ea9abd74e336eef82eb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 12:12:29 +0800 Subject: [PATCH 110/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=A9=E4=B8=9A?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 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 0cb2d58f6..3ed1c5b08 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 @@ -719,12 +719,12 @@ public class AddrSvcController { } /** - * 涉农识别-新规则-上海银行 + * 对公涉农识别-新规则-上海银行 * * @param model * @return */ - public Object boscVillageIdentifyAction(AddressModel model) { + public Object boscEnterpriseVillageIdentifyAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); @@ -737,13 +737,11 @@ public class AddrSvcController { params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); String address = model.getAddress(); params.put("address", address); - String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; - params.put("type", type); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception e) { try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception ex) { ex.printStackTrace(); } From 00d777ccdcd297ecbee5e0830548fa57ddac237b Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 13 Jan 2025 15:23:22 +0800 Subject: [PATCH 111/247] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E6=B6=89=E5=86=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 1232 +++++++++-------- 1 file changed, 653 insertions(+), 579 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 3ed1c5b08..118cf497c 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 @@ -44,10 +44,7 @@ import java.io.IOException; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 地址治理 @@ -752,9 +749,89 @@ public class AddrSvcController { int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); - HashMap map = new HashMap(); + HashMap map = new LinkedHashMap(); //我们的结果 +// "province": "江苏省", +// "city": "苏州市", +// "district": "昆山市", +// "town": "玉山镇", +// "committee": "南星渎村委会", +// "provinceCode": "320000000000", +// "cityCode": "320500000000", +// "districtCode": "320583000000", +// "townCode": "320583100000", +// "committeeCode": "320583100222", +// "typeCode": "220", +// "typeName": "村庄", +// "verifyFlag": "非农", +// "addrVerify": "地址有效", +// "countyLevelCity": "是", +// "administrativeTowns": "否", +// "countyGov": "否", +// "devDistrict": "是", +// "devDistrictName": "昆山高新技术产业开发区", +// "devLevel": "国家级", +// "addrArea": "开发区", +// "countyGovTown": "昆山开发区" JSONObject result = json.getJSONObject("result"); + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("town")) { + map.put("town", result.getString("town")); + } + if (result.containsKey("committee")) { + map.put("committee", result.getString("committee")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("provinceCode")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("cityCode")); + } + if (result.containsKey("districtCode")) { + map.put("districtCode", result.getString("districtCode")); + } + if (result.containsKey("townCode")) { + map.put("townCode", result.getString("townCode")); + } + if (result.containsKey("committeeCode")) { + map.put("committeeCode", result.getString("committeeCode")); + } + if (result.containsKey("typeCode")) { + map.put("typeCode", result.getString("typeCode")); + } + if (result.containsKey("typeName")) { + map.put("typeName", result.getString("typeName")); + } + if (result.containsKey("verifyFlag")) { + map.put("verifyFlag", result.getString("verifyFlag")); + } + if (result.containsKey("addrVerify")) { + map.put("addrVerify", result.getString("addrVerify")); + } + if (result.containsKey("countyLevelCity")) { + map.put("countyLevelCity", result.getString("countyLevelCity")); + } + if (result.containsKey("administrativeTowns")) { + map.put("administrativeTowns", result.getString("administrativeTowns")); + } + if (result.containsKey("countyGov")) { + map.put("countyGov", result.getString("countyGov")); + } + if (result.containsKey("devDistrict")) { + map.put("devDistrict", result.getString("devDistrict")); + } + if (result.containsKey("devLevel")) { + map.put("devLevel", result.getString("devLevel")); + } + if (result.containsKey("addrArea")) { map.put("addrArea", result.getString("addrArea")); } @@ -764,9 +841,6 @@ public class AddrSvcController { if (result.containsKey("countyGovTown")) { map.put("countyGovTown", result.getString("countyGovTown")); } - if (result.containsKey("town")) { - map.put("town", result.getString("town")); - } basicModel.setResult(map); mav.setModel(basicModel); } else { @@ -999,276 +1073,60 @@ public class AddrSvcController { } /** - * 涉农识别-新规则-基础版本 - * - * @param model - * @return - */ - public Object villageIdentifyAction(AddressModel model){ + * 涉农识别-新规则-基础版本 + * + * @param model + * @return + */ + public Object villageIdentifyAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); - return mav; - } - - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - String address = model.getAddress(); - params.put("address", address); - String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; - String villageType = "2".equals(model.getType()) ? "对公" : "对私"; - params.put("type", type); - params.put("showFullValue", "2"); - Pager pager = new Pager(1, 1); - 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(); - resultMap.put("province", villageResult.getProvince()); - resultMap.put("city", villageResult.getCity1()); - resultMap.put("district", villageResult.getDistrict()); - resultMap.put("town", villageResult.getTown()); - resultMap.put("committee", villageResult.getCommittee()); - resultMap.put("provinceCode", villageResult.getCityCode()); - resultMap.put("cityCode", villageResult.getCityCode()); - resultMap.put("districtCode", villageResult.getDistrictCode()); - resultMap.put("townCode", villageResult.getTownCode()); - resultMap.put("committeeCode", villageResult.getCommitteeCode()); - resultMap.put("typeCode", villageResult.getTypeCode()); - resultMap.put("typeName", villageResult.getTypeName()); - resultMap.put("verifyFlag", villageResult.getVerifyFlag()); - resultMap.put("addrVerify", villageResult.getAddrVerify()); - resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); - resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); - resultMap.put("countyGov", villageResult.getCountyGov()); - resultMap.put("devDistrict", villageResult.getDevDistrict()); - resultMap.put("devDistrictName", villageResult.getDevDistrictName()); - resultMap.put("devLevel", villageResult.getDevLevel()); - resultMap.put("addrArea", villageResult.getAddrArea()); - BasicModel basicModel = new BasicModel(200, "OK"); - basicModel.setResult(resultMap); - mav.setModel(basicModel); - } else { -// params.put("showTestValue", "2"); - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - //我们的结果 - JSONObject result = json.getJSONObject("result"); - //我们省级及以上有开发区,直接用我们的结果 - if (result.containsKey("devDistrictName")) { - basicModel.setResult(result); - } else if (!"2".equals(type)) { // 对私的不用齐梁 - basicModel.setResult(result); - } else { - try { - //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { - - //结果比较,如果涉农结果不一致 - //调用齐梁 type :1 对公 0 对私 - //我们 type :1 对私 2 对共 - String qltype = "2".equals(type) ? "1" : "0"; - 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")))) { - 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); - } - - } else { - basicModel.setResult(result); - } - - } else { - basicModel.setResult(result); - - } - - } catch (Exception e) { - e.printStackTrace(); - basicModel.setResult(result); - } - - } - - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - } + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); return mav; } - private static Map senRequest (String address, String type) throws IOException { - String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; - String proxyHost = "tunnel2.qg.net"; - int proxyPort = 14186; - final String proxyUsername = "113BBC06"; - final String proxyPassword = "3B2FBD05B0AF"; - String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; - String authKey = proxyUsername; - String password = proxyPassword; - String auth = authKey + ":" + password; - String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); - - HttpHost proxy = new HttpHost(proxyHost, proxyPort); - DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); - CloseableHttpClient httpClient = HttpClients.custom() - .setRoutePlanner(routePlanner) - .build(); - HttpPost httpPost = new HttpPost(targetURL); - Authenticator.setDefault(new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); - } - }); - httpPost.setHeader("Content-Type", "application/json"); - httpPost.setHeader("Accept", "*/*"); - httpPost.setHeader("Host", "146.56.217.44:9010"); - httpPost.setHeader("Proxy-Authorization", authHeader); - StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); - httpPost.setEntity(stringEntity); - - CloseableHttpResponse httpResponse = null; - int retryCount = 2; // 设置重试次数 - int retryDelay = 10; // 设置重试延迟时间(毫秒) - boolean success = false; - for (int i = 0; i < retryCount; i++) { - try { - httpResponse = httpClient.execute(httpPost); - success = true; - break; - } catch (IOException e) { - System.err.println("代理请求失败,进行重试..."); - try { - Thread.sleep(retryDelay); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - } - } - } - - if (success) { - HttpEntity responseEntity = httpResponse.getEntity(); - String responseString = EntityUtils.toString(responseEntity); - - // 使用 Gson 解析 JSON 字符串 - Gson gson = new Gson(); - JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); - - - // 创建 Map 存储各个值 - Map dataMap = new HashMap(); - - // 获取各个值并放入 Map -// dataMap.put("code", jsonObject.get("code").getAsString()); -// dataMap.put("msg", jsonObject.get("msg").getAsString()); - JsonElement dataElement = jsonObject.get("data"); - if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { - JsonObject data = dataElement.getAsJsonObject(); - // 在这里继续处理 data 对象 - - if (data != null && !data.isJsonNull()) { - -// dataMap.put("version", data.get("version").getAsString()); - dataMap.put("province", data.get("province").getAsString()); - dataMap.put("city", data.get("city").getAsString()); - dataMap.put("district", data.get("district").getAsString()); - dataMap.put("town", data.get("town").getAsString()); - dataMap.put("committee", data.get("village").getAsString()); - dataMap.put("provinceCode", data.get("provinceCode").getAsString()); - dataMap.put("cityCode", data.get("cityCode").getAsString()); - dataMap.put("districtCode", data.get("districtCode").getAsString()); - dataMap.put("townCode", data.get("townCode").getAsString()); - dataMap.put("committeeCode", data.get("villageCode").getAsString()); - dataMap.put("typeCode", data.get("areaCode").getAsString()); - dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); - dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); -// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 - JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); - - if (indusParkList != null) { - JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); - dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); - dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); - dataMap.put("devDistrict", "是"); - } - } - } - - httpResponse.close(); - return dataMap; - } else { - System.err.println("重试次数已用完,请求失败。"); - } - - httpClient.close(); - return null; - } - - /** - * 涉农识别-新规则-标准版 - * - * @param model - * @return - */ - public Object villageIdentifyStandardAction (AddressModel model){ - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); - return mav; - } - - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", model.getAddress()); - params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); - params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); - params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + String villageType = "2".equals(model.getType()) ? "对公" : "对私"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + 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(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); Integer radius = model.getRadius(); params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); try { @@ -1281,361 +1139,577 @@ public class AddrSvcController { } } + if (json != null) { int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); + //我们的结果 + JSONObject result = json.getJSONObject("result"); + //我们省级及以上有开发区,直接用我们的结果 + if (result.containsKey("devDistrictName")) { + basicModel.setResult(result); + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); + } else { + try { + //如果是江苏省或者浙江省 调用齐梁的结果 + if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + + //结果比较,如果涉农结果不一致 + //调用齐梁 type :1 对公 0 对私 + //我们 type :1 对私 2 对共 + String qltype = "2".equals(type) ? "1" : "0"; + 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")))) { + 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); + } + + } else { + basicModel.setResult(result); + } + + } else { + basicModel.setResult(result); + + } + + } catch (Exception e) { + e.printStackTrace(); + basicModel.setResult(result); + } + + } + } mav.setModel(basicModel); } else { mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + } + return mav; + } + + private static Map senRequest(String address, String type) throws IOException { + String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + String proxyHost = "tunnel2.qg.net"; + int proxyPort = 14186; + final String proxyUsername = "113BBC06"; + final String proxyPassword = "3B2FBD05B0AF"; + String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; + String authKey = proxyUsername; + String password = proxyPassword; + String auth = authKey + ":" + password; + String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); + + HttpHost proxy = new HttpHost(proxyHost, proxyPort); + DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); + CloseableHttpClient httpClient = HttpClients.custom() + .setRoutePlanner(routePlanner) + .build(); + HttpPost httpPost = new HttpPost(targetURL); + Authenticator.setDefault(new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); + } + }); + httpPost.setHeader("Content-Type", "application/json"); + httpPost.setHeader("Accept", "*/*"); + httpPost.setHeader("Host", "146.56.217.44:9010"); + httpPost.setHeader("Proxy-Authorization", authHeader); + StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); + httpPost.setEntity(stringEntity); + + CloseableHttpResponse httpResponse = null; + int retryCount = 2; // 设置重试次数 + int retryDelay = 10; // 设置重试延迟时间(毫秒) + boolean success = false; + for (int i = 0; i < retryCount; i++) { + try { + httpResponse = httpClient.execute(httpPost); + success = true; + break; + } catch (IOException e) { + System.err.println("代理请求失败,进行重试..."); + try { + Thread.sleep(retryDelay); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } + + if (success) { + HttpEntity responseEntity = httpResponse.getEntity(); + String responseString = EntityUtils.toString(responseEntity); + + // 使用 Gson 解析 JSON 字符串 + Gson gson = new Gson(); + JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); + + + // 创建 Map 存储各个值 + Map dataMap = new HashMap(); + + // 获取各个值并放入 Map +// dataMap.put("code", jsonObject.get("code").getAsString()); +// dataMap.put("msg", jsonObject.get("msg").getAsString()); + JsonElement dataElement = jsonObject.get("data"); + if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { + JsonObject data = dataElement.getAsJsonObject(); + // 在这里继续处理 data 对象 + + if (data != null && !data.isJsonNull()) { + +// dataMap.put("version", data.get("version").getAsString()); + dataMap.put("province", data.get("province").getAsString()); + dataMap.put("city", data.get("city").getAsString()); + dataMap.put("district", data.get("district").getAsString()); + dataMap.put("town", data.get("town").getAsString()); + dataMap.put("committee", data.get("village").getAsString()); + dataMap.put("provinceCode", data.get("provinceCode").getAsString()); + dataMap.put("cityCode", data.get("cityCode").getAsString()); + dataMap.put("districtCode", data.get("districtCode").getAsString()); + dataMap.put("townCode", data.get("townCode").getAsString()); + dataMap.put("committeeCode", data.get("villageCode").getAsString()); + dataMap.put("typeCode", data.get("areaCode").getAsString()); + dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); + dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); +// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 + JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); + + if (indusParkList != null) { + JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); + dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); + dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); + dataMap.put("devDistrict", "是"); + } + } + } + + httpResponse.close(); + return dataMap; + } else { + System.err.println("重试次数已用完,请求失败。"); + } + + httpClient.close(); + return null; + } + + /** + * 涉农识别-新规则-标准版 + * + * @param model + * @return + */ + public Object villageIdentifyStandardAction(AddressModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); return mav; } - - /** - * 地址联想-PRO - * - * @param model - * @return - */ - @Deprecated - public Object addressAssociationAction (AddressModel model){ - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { - mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); - return mav; + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", model.getAddress()); + params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); + params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); + params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } + } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); - params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); - if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { - params.put("lat", model.getLat()); - params.put("lng", model.getLng()); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + basicModel.setResult(json.get("result")); } - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + + /** + * 地址联想-PRO + * + * @param model + * @return + */ + @Deprecated + public Object addressAssociationAction(AddressModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { + mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); + if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { + params.put("lat", model.getLat()); + params.put("lng", model.getLng()); + } + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 市级行政区划查询接口 - * - * @param model - * @return - */ - public Object listCityAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + basicModel.setResult(json.get("result")); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 市级行政区划查询接口 + * + * @param model + * @return + */ + public Object listCityAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 省级行政区划查询接口 - * - * @param model - * @return - */ - public Object listProvinceAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 省级行政区划查询接口 + * + * @param model + * @return + */ + public Object listProvinceAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 区域级行政区划查询接口 - * - * @param model - * @return - */ - public Object listDistrictAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 区域级行政区划查询接口 + * + * @param model + * @return + */ + public Object listDistrictAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - public Object listTownshipAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + public Object listTownshipAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } + } - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - if (result.containsKey("street")) { - map.put("street", result.getString("street")); - } - if (result.containsKey("tjjStreetCode")) { - map.put("streetCode", result.getString("tjjStreetCode")); - } - list.add(map); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + if (result.containsKey("street")) { + map.put("street", result.getString("street")); + } + if (result.containsKey("tjjStreetCode")) { + map.put("streetCode", result.getString("tjjStreetCode")); + } + list.add(map); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } - return mav; + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + return mav; + } - public Object levelAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + public Object levelAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } + } - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - JSONObject result = json.getJSONObject("result"); - basicModel.setResult(result); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); } - return mav; - } - - public void setDistrictStatService (DistrictStatService districtStatService){ - this.districtStatService = districtStatService; - } - - public void setDistrictService (DistrictService districtService){ - this.districtService = districtService; - } - - public void setVillageIdentifyService (VillageIdentifyService villageIdentifyService){ - this.villageIdentifyService = villageIdentifyService; + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + return mav; } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setVillageIdentifyService(VillageIdentifyService villageIdentifyService) { + this.villageIdentifyService = villageIdentifyService; + } +} From e0aa49ebc3646e12bb77e45944f1a5638ae72047 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:29:08 +0800 Subject: [PATCH 112/247] update --- .../java/com/fangjia/core/util/GeoUtils.java | 3 + projects/fangjia-script/pom.xml | 6 + .../script/ccbevaluation/AddSzDealData.groovy | 2 +- .../script/commData/CommonDatautils.groovy | 4 +- .../fangjia/script/gj/ProxyHttpUtils.groovy | 62 +++++ .../gj/coresite/AddUrlToBaiduSpider.groovy | 48 ++++ .../gj/data_handle/AddDevShapeData.groovy | 202 ++++++++++++++ .../gj/data_handle/AddDistrictAddress.groovy | 159 +++++++++-- .../data_handle/AddDistrictShapeBatch.groovy | 2 +- .../script/gj/data_handle/DevProcess.groovy | 28 +- .../script/gj/data_handle/DevQlCheck.groovy | 113 ++++++++ .../gj/data_handle/DevUpdateTestBatch.groovy | 4 +- .../gj/data_handle/GXDdistrictMatch.groovy | 179 +++++++++--- .../gj/data_handle/NewGaoDePoiBatch.groovy | 5 +- .../gj/data_handle/PoiNineSplitBatch.groovy | 2 +- .../gj/data_handle/TownStandardBatch.groovy | 255 +++++++++++++++--- .../data_handle/TownshipStrandUpdate.groovy | 8 +- .../gj/district/DistrictFieldAddBatch.groovy | 43 ++- .../gj/district/FangjiaClientUtils.groovy | 28 ++ .../script/gj/meishubao/MsbPocTest.groovy | 28 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 44 +-- .../com/fangjia/script/util/GeoHelper.groovy | 161 ++++++++++- .../yinjihaun/amap/GaoDeApiUtils.groovy | 2 +- 23 files changed, 1237 insertions(+), 151 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java index bcb042e67..059a2bcb9 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java @@ -3,6 +3,7 @@ package com.fangjia.core.util; import java.util.HashMap; import java.util.Map; + public class GeoUtils { public static final String LAT ="lat"; @@ -258,6 +259,8 @@ public class GeoUtils { return ret; } + + public static void main(String[] args){ Map location = gps84ToGcj02(31.218024629574998,121.36562884455); System.out.println(location.toString()); diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml index e639f76e3..2b61cb696 100644 --- a/projects/fangjia-script/pom.xml +++ b/projects/fangjia-script/pom.xml @@ -537,6 +537,12 @@ 1.70 + + org.locationtech.jts + jts-core + 1.18.2 + + 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 4473e1e49..dfd784e71 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 @@ -8,7 +8,7 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\2024年10月深圳二手房成交.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年11月深圳二手房成交.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/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index 8e7863c2e..d77e63373 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 @@ -4209,7 +4209,7 @@ class CommonDatautils { static def findAllNewPoiDatas(city){ - String sql = "select pname,cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" + String sql = "select cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" def rets = [] def index= 0 ElasticUtils.executeSqlQuery(sql, { map-> @@ -4222,6 +4222,8 @@ class CommonDatautils { } + + static def findOneThirdNetWorkOffice(city, region, name){ String sql = "select location from office where city='${city}' and region='${region}' and name='${name}'" def map = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy new file mode 100644 index 000000000..72495191d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy @@ -0,0 +1,62 @@ +package com.fangjia.script.gj + +import groovy.json.JsonOutput + +class ProxyHttpUtils { + + static String proxyHost = 'tunnel2.qg.net'; + static Integer proxyPort = 14186; + static String proxyUsername = '113BBC06'; + static String proxyPassword = '3B2FBD05B0AF'; + + static String getProxyResult(targetUrl, data){ + // 将 JSON 对象转换为字符串 + String jsonData = new JsonOutput().toJson(data); + // 创建代理对象 + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); + + // 创建 URL 对象 + URL url = new URL(targetUrl); + + // 创建连接对象 + URLConnection connection = url.openConnection(proxy); + + // 设置代理认证 + java.net.Authenticator.setDefault(new java.net.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()) + } + }) + + // 设置请求方法为 POST + connection.setRequestMethod("POST"); + + // 允许输出流 + connection.setDoOutput(true); + + // 设置请求头 + connection.setRequestProperty("Content-Type", "application/json"); + + // 发送请求参数 + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(jsonData.getBytes("UTF-8")); + outputStream.flush(); + outputStream.close(); + + // 读取响应 + int responseCode = connection.getResponseCode() + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + return response.toString(); + } else { + println "HTTP request failed with response code ${responseCode}"; + } + return null; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy new file mode 100644 index 000000000..2b03fd2ae --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy @@ -0,0 +1,48 @@ +package com.fangjia.script.gj.coresite + +import java.net.HttpURLConnection +import java.net.URL +import java.io.OutputStream + +// 目标服务器的URL +def targetUrlString = "http://data.zz.baidu.com/urls?site=sh.fangjia.com&token=UaKTemkcQ6I4YvSA" + +// 需要POST的URL数据 +def postData = "https://sh.fangjia.com/zoushi?cityName=%E4%B8%8A%E6%B5%B7&keyword=%E5%A4%A9%E5%B1%B1%E6%96%B0%E8%8B%91" + +// 创建URL对象 +URL url = new URL(targetUrlString) + +// 打开连接 +HttpURLConnection connection = (HttpURLConnection) url.openConnection() +connection.setDoOutput(true) // 表明我们将发送POST请求的输出数据 +connection.setRequestMethod("POST") // 设置请求方法为POST +connection.setRequestProperty("User-Agent", "curl/7.12.1") // 设置User-Agent,尽管这在实际应用中可能并非必需 +connection.setRequestProperty("Content-Type", "text/plain") // 设置内容类型,因为我们将发送纯文本数据 +connection.setRequestProperty("Content-Length", Integer.toString(postData.getBytes().length)) // 设置内容长度 + +// 发送POST数据 +//try (OutputStream os = connection.getOutputStream()) { +// byte[] input = postData.getBytes("utf-8") +// os.write(input, 0, input.length) +//} +outputStream = connection.getOutputStream(); +outputStream.write(postData.getBytes()); +outputStream.flush(); +outputStream.close(); + +// 获取响应码 +int responseCode = connection.getResponseCode() +println "POST Response Code :: $responseCode" + +// 可选:读取响应内容 +def reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")) +StringBuilder response = new StringBuilder() +String responseLine +while ((responseLine = reader.readLine()) != null) { + response.append(responseLine.trim()) +} +println "Response Body :: ${response.toString()}" + +// 关闭连接 +connection.disconnect() \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy new file mode 100644 index 000000000..4df41ffc4 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy @@ -0,0 +1,202 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.BaiDuApiUtils +import com.fangjia.core.util.ExcelUtil +import com.fangjia.core.util.GeoUtils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import groovy.json.JsonSlurper +import groovy.io.FileType +import org.bson.types.ObjectId + +import java.util.regex.Pattern + +class AddDevShapeData { + + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + public static final def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection dev_mapping_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + + def devAreaMap = [:] + + static main(args) { + def task = new AddDevShapeData(); + task.run() +// task.streetInfo() + } + + def run(){ + def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\111开发区\\' + def dir = new File(directoryPath) + if (dir.isDirectory()) { +// dir.eachFileRecurse(FileType.FILES) { file -> +// process(file.absolutePath) +// } + addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") + } else { + println "The specified path is not a directory." + } + } + + def addDevInfo(file){ + ExcelUtils.multiThreadingModify(file, {d-> +// if(!d['I']){ + def name = d['D'] + def q = new BasicDBObject() + q.put('_id',new ObjectId(d['A'])) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + if(obj.operator){ + d['H'] = obj.operator + } + if(obj.operate_result){ + d['I'] = obj.operate_result + } + if(obj.m_date){ + d['P'] = DateUtils.formatDateByPattern(obj.m_date, "yyyy-MM-dd") + } + } +// } + devAreaMap.each {k,v-> + if(name.contains(k)){ + d['M'] = v.area_info + d['N'] = v.count + d['O'] = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") + } + } + }) + } + + def process(file){ + def retMap = getNewLocations(file) + if(retMap && retMap.gaode.size()>0){ + def q = new BasicDBObject() + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+retMap.name+'.*$', Pattern.CASE_INSENSITIVE))) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + for(def i=0;i0){ + obj.removeField("_id") + obj.put("create_time", new Date()) + obj.put("block", retMap.name+"-地块"+i) + obj.put("shape", resultMap) + obj.put("m_date", new Date()) + obj.put("bd_shape",bd_resultMap) + obj.put("operator", "外包") + obj.put( "operate_result" , "已处理") + DEVELOPMENT_ZONE_43_COLL.save(obj) + }else{ + udata.put("shape", resultMap) + udata.put("m_date", new Date()) + udata.put("bd_shape",bd_resultMap) + udata.put("operate_result" , "已处理") + udata.put("operator", "外包") + DEVELOPMENT_ZONE_43_COLL.update(q, new BasicDBObject('$set', udata), false, false) + } + } + } + } + } + + def getNewLocations(file){ + def jsonObj = readJson(file) + def features = jsonObj.features + def gaode_locations = [] + def baidu_locations = [] + def name = null + def areaMap = [:] + if(features && features.size()==1){ + name = features[0].properties.Name + def coordinates = features[0].geometry.coordinates + + def index = 0 + println name +" 有 "+coordinates.size()+" 块" + + areaMap.count = coordinates.size() + def areas = [] + if(name.contains("泉州经济技术开发区")){ + for(def pointList : coordinates){ + index ++ + def gaode_coordinates = [] + def bd_coordinates = [] + def points = null + if(pointList.size()>1){ + points = pointList + }else{ + points = pointList[0] + } + double area = com.fangjia.script.util.GeoHelper.calculateArea(points) + println name +" 地块"+index + "围栏面积是: ${area} 平方公里" + areas << area + def locationstr = "" + for(def arrs : points){ + def gaode_map = GeoUtils.gps84ToGcj02(arrs[1].toString().toDouble(), arrs[0].toString().toDouble()) + gaode_coordinates << [gaode_map.get("lng"), gaode_map.get("lat")] + + //此高德转百度 有偏差 + def bd_map = GeoUtils.gcj02ToBd09(gaode_map.get("lat"), gaode_map.get("lng")) +// bd_coordinates << [bd_map.get("lng"), bd_map.get("lat")] + // 高德转百度 通过接口有次数限制 +// def baidu = BaiDuApiUtils.geoconv(gaode_map.get("lng"), gaode_map.get("lat"), 3) +// bd_coordinates << [baidu.x, baidu.y] + + locationstr = arrs[0].toString()+","+arrs[1].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()), 6) + if(bdpoint){ + bd_coordinates << bdpoint + } + } + //整个一串一起传超过4029会报错 +// bd_coordinates = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()-1), 6) + gaode_locations << gaode_coordinates + if(bd_coordinates){ + baidu_locations << bd_coordinates + }else{ + println name +" 转换有问题" + } + + } + areaMap.area_info = areas.join("\n") + } + + }else{ + println file +" 有多个" + } + + devAreaMap.put(name, areaMap) + def retMap = [:] + retMap.name = name + retMap.gaode = gaode_locations + retMap.baidu = baidu_locations + return retMap + } + + def readJson(def file){ + def jsonSlurper = new JsonSlurper() + def jsonFile = new File(file) + def jsonText = jsonFile.text + def jsonObj = jsonSlurper.parseText(jsonText) + return jsonObj + } + + def streetInfo(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx", {d-> + def count = dev_mapping_CONN.count(new BasicDBObject("name", d['E']).append("type", "乡镇街道")) + d['L'] = count + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy index d85eefdca..977423309 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy @@ -23,19 +23,19 @@ import java.util.concurrent.atomic.AtomicLong //补充库中没有详细地址的小区 class AddDistrictAddress extends BaseBatch{ - def fullCityMap = CommonDatautils.queryFullNameCity() - def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() - - DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) - public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") - - - public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") - - def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; - DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) - - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) +// def fullCityMap = CommonDatautils.queryFullNameCity() +// def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() +// +// DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) +// public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") +// +// +// public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") +// +// def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; +// DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) +// +// public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) static main(args) { runBatch(new AddDistrictAddress(), args) @@ -43,7 +43,16 @@ class AddDistrictAddress extends BaseBatch{ @Override public void process(Object args) { -// def citys = CommonDatautils.findAllCity() +// addNoAddressDist() //为不精确的地址通过地图补充地址 +// mapOtherAddress() //有精确地址的寻找其它地址 + +// addressSelect() + addrUpdateToDB() + } + + + def addNoAddressDist(){ + // def citys = CommonDatautils.findAllCity() // def index = 0 // def allrets = [] // for(def c : citys){ @@ -65,9 +74,95 @@ class AddDistrictAddress extends BaseBatch{ // allrets.clear() // } // } + updateDistAddr() + } - updateDistAddr() + def mapOtherAddress(){ + def citys = CommonDatautils.findAllCity() + def index = 0 + def allrets = [] + for(def c : citys){ + index ++ + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "estate_type2", "address", "addr_alias"]) + def radInfoDists = haveRoadInfoDistricts(districts) + println c +" "+index +" 原始小区量:"+districts.size() +" 有详细地址量:"+radInfoDists.size() + radInfoDists = baiduMatch(c, radInfoDists) + radInfoDists = gaodeMatch(c, radInfoDists) + + def rets = [] + rets << ["id", "城市", "区域", "名称", "地址","地址别名", "百度原地址", "百度标准地址", "高德原地址", "高德标准地址"] + for(def d : radInfoDists){ + def addr_alias_str = ''; + if(d.addr_alias){ + addr_alias_str = d.addr_alias.join(" ") + } + rets << [d._id.toString(), d.city, d.region, d.name, d.address, addr_alias_str,d.baidu_old_addr?d.baidu_old_addr:'',d.baidu_address?d.baidu_address:'', d.gaode_old_addr?d.gaode_old_addr:'', d.gaode_addr?d.gaode_addr:""] + } + allrets.addAll(rets) + if(allrets.size()>50000){ + ExcelUtils.write("D:\\数据\\小区\\小区精确地址补充"+index+".xlsx", allrets, "补充地址") + allrets.clear() + } + } + } + + def addressSelect(){ + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\精确地址补充-all-2.xlsx",{d-> + if(d['G']){ + d['O'] = AddressUtil.formatAddress(d['B'], d['G']) + } + if(d['I']){ + d['P'] = AddressUtil.formatAddress(d['B'], d['I']) + } + }) + } + + def addrUpdateToDB(){ + def updateDist = 0 + def addAddrCount = 0 + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\精确地址补充-入库-2.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + if(dist){ + def oldAddrAliasCount = 0 + if(dist.addr_alias){ + oldAddrAliasCount = dist.addr_alias.size() + } + def new_addr_alias = null + if(d['K'].contains("新增百度地址") || d['K'].contains("双地图新增")){ + new_addr_alias = getNewAddressAlias(d['L'], dist.address, dist.addr_alias) + } + if(d['K'].contains("新增高德地址") || d['K'].contains("双地图新增")){ + new_addr_alias = getNewAddressAlias(d['M'], dist.address, dist.addr_alias) + } + if(new_addr_alias){ + updateDist++ + println updateDist + addAddrCount = addAddrCount + new_addr_alias.size()-oldAddrAliasCount + + def udata = new BasicDBObject() + udata.put("addr_alias", new_addr_alias) + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set',udata)) + } + } + }) + println "修改小区数:"+updateDist + println "新增地址数:"+addAddrCount + } + + def getNewAddressAlias(new_addr, old_addr, dist_addr_alias){ + def arrs = new_addr.split(";") + def addr_alias = [] + if(dist_addr_alias){ + addr_alias = dist_addr_alias + } + for(def address : arrs){ + if(old_addr!=address && !addr_alias.contains(address)){ + addr_alias << address + } + } + return addr_alias } def updateDistAddr(){ @@ -108,6 +203,19 @@ class AddDistrictAddress extends BaseBatch{ return rets; } + def haveRoadInfoDistricts(districts){ + def rets = [] + for(def d : districts){ + if(d.address){ + def flag = DataHandleUtils.isStandardRoad(d.address) + if(flag){ + rets << d + } + } + } + return rets; + } + def baiduMatch(city,districts){ def data = fullCityMap.get(city) def fullCityName = null @@ -166,7 +274,8 @@ class AddDistrictAddress extends BaseBatch{ retMap.old_addr = temp_address } if(temp_address && DataHandleUtils.isStandardRoad(temp_address)){ - retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_address) +// retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_address) + retMap.new_addr = nineAddrSplit(fullCityName, temp_address) continue } } @@ -175,6 +284,21 @@ class AddDistrictAddress extends BaseBatch{ } + def nineAddrSplit(city, addr){ + def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(city, addr) + def address = "" + if (jsonObject) { + if (jsonObject.get("street") && jsonObject.get("street") != "null") { + address = jsonObject.get("street") + } + if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { + address = address + jsonObject.get("streetNumber") + } + } + return address + } + + def findBaiduDatas(city, district, name){ def q = new BasicDBObject() q.put("city", city) @@ -250,7 +374,8 @@ class AddDistrictAddress extends BaseBatch{ if(temp_addr){ retMap.old_addr = temp_addr if(temp_addr && DataHandleUtils.isStandardRoad(temp_addr)){ - retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_addr ) +// retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_addr ) + retMap.new_addr = nineAddrSplit(fullCityName, temp_addr) continue } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy index 72d64ea09..796237eb0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy @@ -57,7 +57,7 @@ class AddDistrictShapeBatch extends BaseBatch{ // // } - checkRangeCount() +// checkRangeCount() // synch100() } 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 521be8be2..a6503133c 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 @@ -84,6 +84,7 @@ class DevProcess { // task.addQiDevResult() //获取齐梁数据结果 // task.updateDevShape()//修改开发区结构 + } @@ -439,30 +440,33 @@ class DevProcess { } def matchDev(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\新跑省份\\江苏省\\江苏省-齐梁待跑地址.xlsx",{d-> - if(!d['B'] && d['A']){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\高新区.xls",{d-> + if(!d['E'] && d['D']){ def q = new BasicDBObject() -// q.put("name", d['A']) -// q.put("city",d['G']) -// q.put('alias', new BasicDBObject('$in',[d['A']])) - def name = d['A'].replace('经济技术开发区','经济开发区') +// q.put("name", d['D']) + q.put("city",d['C']) +// q.put('alias', new BasicDBObject('$in',[d['D']])) + def name = d['D'] //.replace('经济技术开发区','经济开发区') q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 def obj = development_zone_CONN.findOne(q) if(obj){ - d['I'] = "库中有开发区-相似2" + d['G'] = "相似" // d['K'] = obj.name // d['C'] = obj._id.toString() - d['B'] = obj.name -// if(obj.name == d['A']){ -// d['E'] = "相同" + d['E'] = obj.name +// if(obj.name == d['D']){ +// d['G'] = "相同" // }else{ -// d['E'] = "包含" +// d['G'] = "包含" // } + if(obj.shape){ + d['F'] = "是" + } // d['E'] = "别名" // d['F'] = obj.name } } - },1); + },0); } def calAddrDistince(){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy new file mode 100644 index 000000000..f37e917d2 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy @@ -0,0 +1,113 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.ExcelUtil +import com.fangjia.script.gj.ProxyHttpUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.sf.json.JSONObject +import org.apache.commons.io.FileUtils + +class DevQlCheck { + + //http://146.56.217.44:8088/uams/index + String targetUrl = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + static main(args) { + def task = new DevQlCheck() + task.run() + } + + def run(){ + def devName = "福建龙海经济开发区" + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(new BasicDBObject("name",devName)) + def pois = readCSV("C:\\Users\\gaojuan\\Downloads\\漳州市POI.csv") + def devPois = [] + devPois << ["省", "城市", "区域", "名称", "地址", "类型", "经度", "纬度", "齐梁开发区"] + for(def poi : pois){ + def flag = InsidePolygon.isInArea(poi.lng.toString().toDouble(), poi.lat.toString().toDouble(), InsidePolygon.createPoint4(obj.shape.coordinates)) + if(flag){ + devPois << [poi.province, poi.city, poi.district, poi.name, poi.address, poi.cat, poi.lng, poi.lat] + } + } + println "共:"+devPois.size()+" 个" + ExcelUtils.write("D:\\数据\\数据建设\\开发区外包\\${devName}poi齐梁校验.xlsx", devPois, "齐梁开发区") + def index = 0 + ExcelUtils.modify("D:\\数据\\数据建设\\开发区外包\\${devName}poi齐梁校验.xlsx",{d-> + def address = d['B']+d['C']+d['D'] +// if(d['E']){ +// address = address + d['E'] +// } + Thread.sleep(3000) + def s = getQlResult(address) + d['I'] = s + index ++ + println index+" "+ s + }) + + + } + + def getQlResult(address){ + def params = [ + 'address': address, + 'type': '1' //1:对公 0:对私 + ] + try{ + def str = ProxyHttpUtils.getProxyResult(targetUrl, params); + println address +" "+ str + JSONObject result = JSONObject.fromObject(str) + if(result && result.code==20000){ + def data = result.data + if(data){ + def list = data.indusParkList + if(list && list!="null"){ + def s = "" + for(def r : list){ + s = s + r.indusParkName +"-"+r.indusParkLevel+"\n" + } + return s + } + } + } + }catch(Exception e){ + println address +" "+e.getMessage() + } + + return null + } + + + def readCSV(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + for(line in lines) { + if(line){ + String[] arrs = line.split("\\|@\\|") + def o = new BasicDBObject() + try{ + o.put("province", arrs[0]) + o.put("city", arrs[1]) + o.put("district", arrs[2]) + o.put("name", arrs[3]) + o.put("township", arrs[4]) + o.put("address", arrs[5]) + o.put("cat", arrs[6]) + o.put("lng", arrs[7]) + o.put("lat", arrs[8]) + o.put("data_source", arrs[9]) + rets << o + }catch(Exception e){ + println filename+" 文件异常" + } + + } + + } + return rets; + } + +} 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 aaf80284e..50ec412b8 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 @@ -32,7 +32,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) // @@ -167,7 +167,7 @@ class DevUpdateTestBatch { println d['A'] +" 不存在" } } - },0) + },1) } 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 ee54817e6..8a5fc6eec 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 @@ -1,12 +1,14 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData +import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.script.ccbevaluation.CcbCommonUtils import com.fangjia.script.ccbevaluation.PgsqlCommUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.EsSearchUtils import com.fangjia.script.gj.district.FangjiaClientUtils 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 @@ -28,14 +30,24 @@ class GXDdistrictMatch { static main(args) { def task = new GXDdistrictMatch(); // task.run() - task.addOldMatch2() +// task.addOldMatch2() // task.runDb() +// task.hainanMatch() // task.updateDistStatus()//恢复name_cat不正常数据 // task.saveToDB() //保存新增小区 // task.restoreDist()//恢复小区status=0 // task.runMatch() + +// task.checkDist() + + task.addPrice() + + } + + def addPrice(){ + addPrice(row['K'],row['L'],row['M'], row['T'], DateUtils.parseFromTightByPattern('2023-10-01','yyyy-MM-dd'),DateUtils.parseFromTightByPattern('2023-10-25','yyyy-MM-dd')) } def addOldMatch(){ @@ -94,6 +106,46 @@ class GXDdistrictMatch { } + def hainanMatch(){ + def fileName = "D:\\数据\\小区\\海南未匹配地址-1.xlsx" + ExcelUtils.multiThreadingModify(fileName, { d -> + if(d['D'] && d['F'] ){// +// def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(null, d['I']) +// if(jsonObject){ +//// if(jsonObject.get("district") && jsonObject.get("district")!='null'){ +//// d['AO'] = jsonObject.get("district") +//// } +// if(jsonObject.get("province") && jsonObject.get("province")!="null"){ +// d['AP'] = jsonObject.get("province") +// } +// if(jsonObject.get("city") && jsonObject.get("city")!="null"){ +// d['AI'] = jsonObject.get("city") +// } +// } + def formatCity = RegionData.formatCity(d['F']) + def fullCityObj = fullCityMap.get(formatCity) + if(fullCityObj){ +// def fullRegion = regionCodeDataMap.get(d['A']+"#"+d['E']) + + def obj = findDatasByCityAndName(formatCity, d['D'].replaceAll('[·\\(\\)()]|·', '')) + if(obj){ + d['U'] = "楼盘抓取库" + d['V'] = obj.city + d['W'] = obj.region + d['X'] = obj.name + d['Y'] = obj.property_type + d['Z'] = obj.address + def loc = obj.location + if(loc){ + d['AA'] = loc.x + d['AB'] = loc.y + } + } + } + } + }) + } + def runDb(){ def fileName = "D:\\数据\\国信达\\国信达11城未匹配数据.xlsx" ExcelUtils.modify(fileName, { d -> @@ -238,43 +290,41 @@ class GXDdistrictMatch { def saveToDB(){ // def fileName = "D:\\数据\\国信达\\国信达11城未匹配数据.xlsx" - def fileName = "D:\\数据\\数据建设\\小区\\东莞未匹配成交数据.xlsx" + def fileName = "D:\\数据\\小区\\海南新增小区.xlsx" ExcelUtils.modify(fileName, { d -> - if(d['A']){ + if(d['A'] && d['C']){ def udata = new BasicDBObject() udata.put("city", d['A']) udata.put("region", d['B']) def name = d['C'].replaceAll('[·\\(\\)()]|·', '').replace("建设中", "") udata.put("name", name) - def alias = [] - if(d['G'] && name!=d['G']){ - alias << d['G'] - } +// def alias = [] +// if(d['G'] && name!=d['G']){ +// alias << d['G'] +// } // if(d['AI'] && !alias.contains(d['AI']) && d['AI']!=name){ // alias << d['AI'] // } - if(alias){ - udata.put("alias", alias) - } +// if(alias){ +// udata.put("alias", alias) +// } - def addr = AddressUtil.formatAddress(d['A'], d['D']) + def addr = AddressUtil.formatAddress(d['A'], d['E']) if(addr){ udata.put("address", addr) } - udata.put("status", "0") - udata.put("name_cat", "0") + udata.put("status", 0) + udata.put("name_cat", 0) udata.put("cat", "district") - udata.put("username", "高娟") +// udata.put("username", "高娟") def estateType2 = "普通住宅" def type = "" -// if(d['AH']){ -// type = d['AH'] -// }else{ -// type = d['Y'] -// } + if(d['D']){ + type = d['D'] + } if(type){ if(type.contains("别墅")){ estateType2 = "别墅" @@ -282,26 +332,50 @@ class GXDdistrictMatch { estateType2 = "商住" } } - udata.put("estateType2", estateType2) + udata.put("estate_type2", estateType2) + if(d['F']){ Long lng = d['F']*10000000000 - udata.put("lng", lng) - } - if(d['E']){ - Long lat = d['E'] * 10000000000 + Long lat = d['G'] * 10000000000 udata.put("lat", lat) - } - - def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) - def opt = "add" - if(s && s=='成功'){ - saveOptLog(udata.city, udata.region, udata.name, opt) + udata.put("lng", lng) + // 高德转百度 + def baidu = BaiDuApiUtils.geoconv(d['F'].toString().toDouble(), d['G'].toString().toDouble(), 3) + def lng2 = baidu.x + def lat2 = baidu.y + if(lng2){ + Long lng2_new = lng2 *10000000000L + Long lat2_new = lat2 *10000000000L + udata.put("lng2", lng2_new) + udata.put("lat2", lat2_new) } } + udata.put("c_date", new Date()) + udata.put("m_date", new Date()) + def markMap = [:] + markMap.put("data_source", "机器入库") + udata.put("mark_map",markMap) +// udata.put("is_new", 0) + DbUtils.seaweed.save(udata) + saveOptLog(udata.city, udata.region, udata.name, "add") +// def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) + println name +// def opt = "add" +// if(s && s=='成功'){ +// saveOptLog(udata.city, udata.region, udata.name, opt) +// } + } }) } + def checkDist(){ + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\海南未匹配地址-1.xlsx", { d -> + if(d['V'] && d['W'] && d['X']){ + matching(d['V'], d['W'], d, d['X'], null, null) + } + }) + } def match(city, region, d){ d = matching(city, region, d, d['C'].replaceAll('[·\\(\\)()]|·', ''), d['D'], "") @@ -391,7 +465,7 @@ class GXDdistrictMatch { if(rets && rets.size()>=1){ d = setRowValue(rets[0], d, "名称在地址中"+str) }else{ - if (d['D']) { + if (d['D'] && alias) { rets = CommonDatautils.findDistrictByAlias(city, region, alias.replaceAll('[·\\(\\)()]|·', ''), "district") if (rets) { if (rets.size() >= 1) { @@ -449,14 +523,14 @@ class GXDdistrictMatch { def setRowValue(dbo, d, remark){ if (dbo) { - d['V'] = dbo.city - d['W'] = dbo.region - d['X'] = dbo.name - d['Y'] = dbo.estate_type2 - d['Z'] = dbo.status - d['AA'] = dbo.name_cat - d['U'] = remark - d['AH'] = dbo.address +// d['V'] = dbo.city +// d['W'] = dbo.region +// d['X'] = dbo.name +// d['Y'] = dbo.estate_type2 + d['AK'] = dbo.status +// d['AA'] = dbo.name_cat + d['AJ'] = remark +// d['AH'] = dbo.address } return d; } @@ -510,6 +584,33 @@ class GXDdistrictMatch { return null; } + + def findDatasByCityAndName(def city, def name){ + def sql = "select * from community where city='${city}' and name='${name}'" + 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 saveOptLog(city, region, name, type){ def obj = new BasicDBObject(); obj.put("city",city); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index a87c0b154..ea28d2c0b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -467,7 +467,7 @@ class NewGaoDePoiBatch extends BaseBatch{ QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) def map = new HashMap() ElasticUtils89.executeQuery("192.168.0.89", "map_poi_2024", queryBuilder, { String id, Map d-> - def district = "" + def district = "嘉峪关市" if(d.district){ district = d.district } @@ -477,11 +477,12 @@ class NewGaoDePoiBatch extends BaseBatch{ } def o = new BasicDBObject() o.put("city", d.city) - o.put("district", d.district) + o.put("district", district) o.put("name", d.name) o.put("township", d.township) o.put("location", d.location) regionMap.put(d.name.replace("-","").replace("·",""), o) +// map.put(district, regionMap) map.put(district, regionMap) }) return map diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy index 21432c057..bf7a84c06 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy @@ -6,7 +6,7 @@ import com.fangjia.script.util.ExcelUtils class PoiNineSplitBatch{ - static main(args) { + public static void main(args) { def task = new PoiNineSplitBatch() task.run() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 4d3e00e32..41588517e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -3,7 +3,9 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils import org.elasticsearch.action.bulk.BulkRequest @@ -12,6 +14,13 @@ 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 +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + /** * 区域标准化 * 1.小区库乡镇街道标准化,包含小区,商铺,写字楼 @@ -22,6 +31,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def updateList = [] def addAliasList = [] @@ -38,7 +48,8 @@ class TownStandardBatch extends BaseBatch{ def TownStandard(){ // townStandardByCat("office") - townStandardByPoi() +// townStandardByPoi() + addTownByTownShape() } def townStandardByCat(def cat){ //"三明","龙岩","南平","漳州","福州","厦门","泉州","莆田","宁德", @@ -69,11 +80,15 @@ class TownStandardBatch extends BaseBatch{ updateList << ["数据ID", "城市","区域","乡镇街道","名称","状态", "修改"] addAliasList << ["城市","区域","乡镇街道", "新增别名"] - //浙江,江苏,安徽 - def citys = ['杭州','宁波','温州','嘉兴','台州','湖州','绍兴','金华','舟山','衢州','丽水']//CommonDatautils.findAllCity() + def runProvinces = ["福建省","浙江省","江苏省","安徽省","山东省","甘肃省"] + def citys = CommonDatautils.findAllCity() + def index = 0 for(def city : citys){ - + index++ def data = fullCityMap.get(city) +// if(runProvinces.contains(data.province)){ +// continue +// } def fullCityName = null if(data){ fullCityName = data.city @@ -95,11 +110,16 @@ class TownStandardBatch extends BaseBatch{ def rets = readPoiCsv(fileName) println city +" "+rets.size() if(set.size()>1){ - poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap) + poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data) }else{ // haveStreetProcess(city, set, cat) } } + if(updateList.size()>50000){ + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-${index}.xlsx", updateList, "数据") + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-需新增别名-${index}.xlsx", addAliasList, "数据") + updateList.clear() + } }else{ println fileName+" 文件没找到" } @@ -107,8 +127,7 @@ class TownStandardBatch extends BaseBatch{ println "没找到相应的全称:"+city } } - ExcelUtils.write("D:\\数据\\乡镇街道待查数据.xlsx", updateList, "数据") - ExcelUtils.write("D:\\数据\\乡镇街道待查数据-需新增别名.xlsx", addAliasList, "数据") + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-最后.xlsx", updateList, "数据") } def haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap){ @@ -168,7 +187,7 @@ class TownStandardBatch extends BaseBatch{ } - def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap){ + def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data){ def results = [] if(fullCityName){ for(def d : rets){ @@ -221,21 +240,21 @@ class TownStandardBatch extends BaseBatch{ def m = [:] m.put(d.id, ["township":updateTown]) results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name,d.township, d.status, updateTown] + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name,d.township, d.status, updateTown] // println d.city +" "+d.district+" "+d.name +" "+d.township+" 乡镇修改为:"+updateTown }else{ def m = [:] m.put(d.id, ["township":""]) -// results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name, d.township, d.status, ""] + results << m + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name, d.township, d.status, ""] println d.city +" "+d.district+" "+d.name +" "+d.township+" 状态修改为:空值" } } @@ -244,10 +263,10 @@ class TownStandardBatch extends BaseBatch{ } } -// if(results.size()>0){ -// updateByEs(results) -// results.clear() -// } + if(results.size()>0){ + updateByEs(results) + results.clear() + } println fullCityName +" 处理完成" } @@ -322,18 +341,194 @@ class TownStandardBatch extends BaseBatch{ if(line){ String[] arrs = line.split("\\|@\\|") def o = new BasicDBObject() - o.put("city", arrs[0]) - o.put("district", arrs[1]) - o.put("name", arrs[2]) - o.put("township", arrs[3]) - o.put("status", arrs[4]) - o.put("id", arrs[5]) - rets << o + try{ + o.put("city", arrs[0]) + o.put("district", arrs[1]) + o.put("name", arrs[2]) + o.put("township", arrs[3]) + o.put("status", arrs[4]) + o.put("id", arrs[5]) + rets << o + }catch(Exception e){ + println arrs + } + } } return rets; } + def readCSV2(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + def o = new BasicDBObject() + try{ + o.put("id", arrs[1]) + o.put("province", arrs[2]) + o.put("city", arrs[3]) + o.put("district", arrs[4]) + o.put("lng", arrs[5]) + o.put("lat", arrs[6]) + o.put("data_source", arrs[7]) + rets << o + }catch(Exception e){ + println arrs + } + } + index++ + } + return rets; + } + + def addTownByTownShape(){ + def i = 0 + def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式"] + while(i<50){ + def fileName = "/home/goojia/gj/new_poi/input/no_township_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\原始\\no_township_${i}.csv" + } + File file=new File(fileName); + if(file.exists()) { + def rets = readCSV2(fileName) + def rows = addTownshipBatch(rets) + if (CommonDatautils.isWindow()) { + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + }else{ + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + } + println fileName +" 运行完成" + }else{ + println fileName +" 不存在" + } + i++ + } + } + + def addTownshipBatch(def rets){ + def results = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + for(def i=0;i= 1) { + addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source] + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + return results + } + + def addTown(saveObj, townMap, location) { + //在poi本区域下通过乡镇街道围栏选出所在乡镇街道 + def towns = townMap.get(saveObj.district) + if (towns) { + for (def town : towns) { + if (town.shape && town.shape.coordinates) { + def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) + if (flag) { + saveObj.township = town.street + saveObj.town_source = "同区域" + break + } + } + } + } + //忽略poi中的区域 通过乡镇街道围栏选出所在乡镇街道 + if(!saveObj.township){ + def townNames = townMap.keySet() + for(def townName : townNames){ + towns = townMap.get(townName) + for (def town : towns) { + if (town.shape && town.shape.coordinates) { + def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) + if (flag) { + saveObj.township = town.street + saveObj.new_district = town.mzb_district_name + saveObj.town_source = "忽略区域" + break + } + } + } + if(saveObj.township){ + break; + } + } + } + //通过调取地图api接口获取乡镇街道 +// if(!saveObj.township){ +// def gaodeMap = getTownshipInfo(location.lon+","+location.lat) +// if(gaodeMap && gaodeMap.township){ +// saveObj.township = gaodeMap.township +// saveObj.new_district = gaodeMap.district +// saveObj.town_source = "高德API" +// } +// } + return saveObj + } + + + def getTownshipInfo(def glocation){ + def township = null + def district = null + def city = null + def format_addr = null + def stop = false + def count = 0 + while(!stop){ + if(glocation){ + def jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { + def addressComponent = jsonObject.regeocode.addressComponent + if(addressComponent){ + township = addressComponent.township + district = addressComponent.district + city = addressComponent.city + format_addr = jsonObject.regeocode.formatted_address + + } + } + } + if(district || count>10){ + stop = true + }else{ + count ++ + Thread.sleep(3000) + print "." + } + } + + def map = [:] + map.city = city + map.district = district + map.township = township + map.format_addr = format_addr + return map; + } + + } 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 d99e249c9..bbe074507 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 @@ -38,16 +38,16 @@ class TownshipStrandUpdate { static main(args) { def task = new TownshipStrandUpdate() -// task.process() -// task.updateTown() + task.process() + task.updateTown() // task.stat() - task.updateDiffRegionTown() +// task.updateDiffRegionTown() // task.cleanTown() // task.checkTownFromMongo() // task.updateTownMapping() // task.updateDevMapping() - println new Date().getTime() +// println new Date().getTime() // task.updateSpecCityTown() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 3b3aed61a..d6e73b168 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -67,7 +67,39 @@ class DistrictFieldAddBatch extends BaseBatch{ ] static main(args) { - runBatch(new DistrictFieldAddBatch(), args) +// runBatch(new DistrictFieldAddBatch(), args) + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> + def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") +// if(dist){ +// d['L'] = dist.loudong_count +// d['M'] = dist.household_count +// d['Q'] = dist.estate_type2 +// } + def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") + if(!list && dist){ + def alias = dist.alias + for(def name : alias){ + list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") + if(list){ + d['Z'] = "别名" + } + } + }else{ + d['Z'] = "名称" + } + if(list){ + def obj = list[0] + if(obj.loudong_cnt){ + d['W'] = obj.loudong_cnt + } + + if(obj.households){ + d['X'] = obj.households + } + d['Y'] = obj.url + } + + }) } @Override @@ -361,6 +393,15 @@ class DistrictFieldAddBatch extends BaseBatch{ return list } + + static def findEsDatasByCityAndName(c, district, name, esWebSource){ + def list = [] + ElasticUtils.executeSqlQuery("select * from community where city='${c}' and source='${esWebSource}' and region='${district}' and name='${name}'", {r-> + list << r + }) + return list + } + def fieldUpdate(total,updateRets){ def countMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 15e4cc80b..35179b3d9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -398,4 +398,32 @@ class FangjiaClientUtils { return jsonObj; } + + /** + * 经纬度转换 + * 1、高德转百度 2、高德转WGS84 3、百度转高德 4、WGS84转高德 5、百度转WGS84 6、WGS84转百度 + */ + public static def convert(String locationstr, type){ + def jsonObj = null + def content = null + def points = [] + try { + def url = "http://192.168.0.19:31080/FangJiaNlpService/convert?locations="+URLEncoder.encode(locationstr,"UTF-8")+"&coordsys=${type}" + + content = new HttpRequest().newGet(url, null, "utf-8") + jsonObj = JSONObject.fromObject(content) + if(jsonObj && jsonObj.locations){ + def locations = jsonObj.locations + for(def s : locations){ + def arrs = s.split(",") + points = [arrs[0].toString().toDouble(), arrs[1].toString().toDouble()] + } + } + return points + } catch (Exception e) { + println e.getMessage() + } + return null; + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy index 99b913307..3ea63b7e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy @@ -13,18 +13,18 @@ class MsbPocTest { task.run(); } def run(){ - def inputfile = "D:\\数据\\建行\\房产估值\\_业务5月份系统反馈问题价格核查20240416-20240516 - 国信达0524.xlsx" + def inputfile = "D:\\数据\\建行\\房产估值\\房讯通10月价格核查_1126-FXT提交结果20241205.xlsx" // def inputfile = "D:\\数据\\美术宝\\美术宝测试数据(匹配V2).xlsx"//美术宝测试数据(匹配).xlsx // standard(inputfile) // match(inputfile) -// matchOld(inputfile) + matchOld(inputfile) // addPrice("D:\\数据\\美术宝\\美术宝测试数据(价格).xlsx") // test("D:\\数据\\美术宝\\test2.xlsx") // cityPrice() // mergeMatchPrice("D:\\数据\\美术宝\\美术宝-新接口价格.xlsx") - addCCBPrice(inputfile) +// addCCBPrice(inputfile) } def cityPrice(){ @@ -69,24 +69,24 @@ class MsbPocTest { def matchOld(path){ ExcelUtils.multiThreadingModify(path, { row -> - if(!row['Y'] && row['G']){ + if(!row['AD'] ){ def city = row['C'] def region = null //row['D'] - def name = row['E'] - def address = row['G'] + def name = null// row['E'] + def address = row['D'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = OpenApiClient.addressMatch(city, address, "property", false, region, name) if(jsonObject != null && jsonObject.precise!=-1) { - row['Y'] = jsonObject.get("id") - row['Z'] = jsonObject.get("city") - row['AA'] = jsonObject.get("district") - row['AB'] = jsonObject.get("name") - row['AC'] = jsonObject.get("propertyType") + row['AD'] = jsonObject.get("id") + row['AE'] = jsonObject.get("city") + row['AF'] = jsonObject.get("district") + row['AG'] = jsonObject.get("name") + row['AH'] = jsonObject.get("propertyType") // row['X'] = jsonObject.get("credit") } } - }) + },1) } @@ -114,7 +114,7 @@ class MsbPocTest { if(!row['Y']){ def city = row['C'] def region = null //row['B'] - def address = row['G'] //row['G']//row['F'] + def address = row['D'] //row['G']//row['F'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = FangjiaClientUtils.newMatch(city, address, "property", false) @@ -125,7 +125,7 @@ class MsbPocTest { row['AB'] = jsonObject.get("name") } } - }) + },1) } 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 d314427a9..5cd666999 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 @@ -38,9 +38,9 @@ class AddPriceTest { task.run(); } def run(){ - def filePath = "D:\\数据\\建行\\房产估值\\202410测试偏差较大案例统计数据test.xlsx" - addGXDPrice(filePath) -// addCcbPrice(filePath) + def filePath = "D:\\数据\\价格\\惠州.xlsx" +// addGXDPrice(filePath) + addCcbPrice(filePath) // addThirdPrice(filePath) // addFjwPrice(filePath) // exportPkPrice() @@ -174,26 +174,28 @@ class AddPriceTest { def addCcbPrice(filepath){ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() ExcelUtils.multiThreadingModify(filepath,{ d-> - if(d['U']){ - def cityId = cityCodeDataMap.get(d['V']) - def map = findAvgPrice(d['U'], cityId) + if(d['A']){ + def cityId = cityCodeDataMap.get(d['B']) + def map = findAvgPrice(d['A'], cityId) if(map){ - d['H'] = map.avg_price - d['I'] = map.calc_type + d['I'] = map.avg_price + d['J'] = map.month +// d['H'] = map.calc_type // d['AM'] = map.credit_value } -// def newPriceMap = findNewFjwAvgPrice(d['U'], cityId) -// if(newPriceMap){ -// d['Q'] = newPriceMap.avg_price -// } + def newPriceMap = findNewFjwAvgPrice(d['A'], cityId) + if(newPriceMap){ + d['G'] = newPriceMap.avg_price + d['H'] = newPriceMap.month + } } }) } 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=202409 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}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -213,7 +215,7 @@ class AddPriceTest { def findNewFjwAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202409 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 price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance235.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -270,14 +272,14 @@ class AddPriceTest { def addGXDPrice(filepath){ ExcelUtils.multiThreadingModify(filepath, { d -> - if (!d['B']) { + if (!d['H']) { def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ def gxdPrice = findGXDPrice(dist.city, dist.region, dist.name) // def gxdPrice = findGXDPrice(d['D'], d['E'], d['C']) if(gxdPrice){ - d['B'] = gxdPrice.price - d['C'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") + d['H'] = gxdPrice.price + d['I'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") } } @@ -305,11 +307,11 @@ class AddPriceTest { ExcelUtils.multiThreadingModify(path,{d-> // if(!d['L']){ // if(d['J'] instanceof String){ - def dist = CommonDatautils.findDistrictById(d['AJ']) + def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ // d['A'] = dist.city // d['B'] = dist.region - d['E'] = dist.name +// d['E'] = dist.name // d['D'] = dist.status // d['E'] = dist.name_cat // d['F'] = dist.estate_type2 @@ -318,9 +320,9 @@ class AddPriceTest { // d['N'] = dist.region def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) if(dbo){ - d['G'] = dbo.avg_price + d['E'] = dbo.avg_price_2b // d['X'] = dbo.cal_type -// d['E'] = dbo.avg_price_2b +// d['E'] = dbo.avg_price } } // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy index cb59203cf..e04562271 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy @@ -1,4 +1,8 @@ package com.fangjia.script.util + + +import java.text.DecimalFormat + class GeoHelper { @@ -60,10 +64,159 @@ class GeoHelper { // return GetLatLon(a, distance, angle); // } // - public static void main(String[] args){ - GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); - GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); - } + public static haversine(lat1, lon1, lat2, lon2) { + def R = 6371; // 地球半径(公里) + def lat1Rad = lat1 * (Math.PI / 180); + def lat2Rad = lat2 * (Math.PI / 180); + def deltaLat = (lat2 - lat1) * (Math.PI / 180); + def deltaLon = (lon2 - lon1) * (Math.PI / 180); + + def a = Math.sin(deltaLat / 2) ** 2 + + Math.cos(lat1Rad) * Math.cos(lat2Rad) * + Math.sin(deltaLon / 2) ** 2; + + def c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + return R * c; // 返回距离(公里) + } + + public static calculateArea(coords) { + def area = 0; + def n = coords.size(); + + for (def i = 0; i < n; i++) { + def j = (i + 1) % n; + area += coords[i][0] * coords[j][1]; + area -= coords[j][0] * coords[i][1]; + } + area = Math.abs(area) / 2; // 平方度 + + // 转换为平方公里 + def conversionFactor = 111.32; // 大约每度经纬度的公里数(考虑到地球的曲率) + + def df = new DecimalFormat("#.000000") + return Double.parseDouble(df.format(area * conversionFactor * conversionFactor)) // 返回面积(平方公里) +// return area * conversionFactor * conversionFactor + } + + + public static void main(String[] args){ +// GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); +// GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); + + List> coordinates = [ + [ + 117.61878540582734, + 24.667331307258223 + ], + [ + 117.61400840589488, + 24.670008244935104 + ], + [ + 117.60936140565889, + 24.671837202755682 + ], + [ + 117.60834440585768, + 24.668667276729821 + ], + [ + 117.60696440583342, + 24.667256309201207 + ], + [ + 117.60517040553236, + 24.667762297657362 + ], + [ + 117.60272340547806, + 24.660100475272998 + ], + [ + 117.60254340555321, + 24.658630509428463 + ], + [ + 117.60206940590035, + 24.654781598282568 + ], + [ + 117.60254840557604, + 24.652731645907636 + ], + [ + 117.60346440599301, + 24.651555673447035 + ], + [ + 117.6070314057805, + 24.652578649754957 + ], + [ + 117.61605140571805, + 24.651939664372833 + ], + [ + 117.6156454058372, + 24.654165613124405 + ], + [ + 117.61559340595863, + 24.655023593107103 + ], + [ + 117.61535440558418, + 24.658990501065318 + ], + [ + 117.61662340528017, + 24.659352492642654 + ], + [ + 117.61678740531192, + 24.661365445721003 + ], + [ + 117.61472940542001, + 24.661623439403797 + ], + [ + 117.61462940586114, + 24.661837434759093 + ], + [ + 117.61470140583106, + 24.662665415879701 + ], + [ + 117.61487240553515, + 24.663165403873506 + ], + [ + 117.61522940591078, + 24.663494396452791 + ], + [ + 117.6157014059138, + 24.663523395394918 + ], + [ + 117.61627240565099, + 24.663438397829282 + ], + [ + 117.61693540544979, + 24.663181403867725 + ], + [ + 117.61878540582734, + 24.667331307258223 + ] + ] + + double area = calculateArea(coordinates) + println "The area of the polygon is: ${String.format("%.2f", area)} square kilometers" + } } 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 65da1a7be..7c41bcc1c 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,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "c6fcd4bfbc40d73ee762b8115dca3390" //宝剑 + def static GAO_DE_AK = "dfc2245bac8a7b2d5b62e060e59d4eca" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca /** From 34e2201f899b9919a8ca1e3343d4f1a13efa0a8a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:34:04 +0800 Subject: [PATCH 113/247] update --- .../com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy index e44d4424e..5cf2d132a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy @@ -7,6 +7,7 @@ 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.looplineinfo.Point import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils @@ -17,7 +18,7 @@ import com.mongodb.DBCollection */ -@BatchOwner(Watcher.GaoJuan) +//@BatchOwner(Watcher.GaoJuan) class RelatedTaiWanBatch extends BaseBatch{ @@ -69,7 +70,9 @@ class RelatedTaiWanBatch extends BaseBatch{ if(r.lon && r.lat){ for(def m : zimaoqu_range_datas){ // def flag = InsidePolygon.isInArea(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) - def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) + List> pointsList = InsidePolygon.createPoint4(m.shape) +// def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, pointsList) + def flag = InsidePolygon.isInArea(r.lon, r.lat, pointsList) if(flag){ resKey = m.name break From 82ddcbc4ed3f47cc9d4d696d6b23977f12169c79 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:59:59 +0800 Subject: [PATCH 114/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=90=E4=BA=A4?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dealPrice/SynchDealPriceToEs.groovy | 68 +++++++++++-------- .../gj/district/DistrictFieldAddBatch.groovy | 64 ++++++++--------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index f9f518cb8..dba4650b9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -1,6 +1,9 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils @@ -15,43 +18,52 @@ import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType -class SynchDealPriceToEs { +/** + * 成交同步206,按日同步 + */ +@BatchOwner(Watcher.GaoJuan) +class SynchDealPriceToEs extends BaseBatch{ static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) static main(args) { - def task = new SynchDealPriceToEs() - task.run() + runBatch(new SynchDealPriceToEs(), args) + } + + + @Override + void process(Object args) { + run(); } def run(){ - def batchsize = 2000 - def citys = getCityCount() - citys.each{city,count-> - if(city instanceof String){ - for(def year = 1999;year<=2025;year++){ - def q = new BasicDBObject("city", city) - q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) - def dbcursor = dealPriceConn.find(q).batchSize(batchsize) - println city +" "+ dbcursor.count() - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) - } - } + def startDate = DateUtils.formatDateByPattern(new Date()-1, "yyyy-MM-dd") + def q = new BasicDBObject() + q.put("m_date", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate))) + def dbcursor = dealPriceConn.find(q) + println DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd")+" 更新量:"+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) -// def index = 0 -// for(def d : dbcursor){ -// ret << d -// if(ret.size()>=2000){ +// def batchsize = 2000 +// def citys = getCityCount() +// citys.each{city,count-> +// if(city instanceof String){ +// for(def year = 1999;year<=2025;year++){ +// def q = new BasicDBObject("city", city) +// q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) +// def dbcursor = dealPriceConn.find(q).batchSize(batchsize) +// println city +" "+ dbcursor.count() +// def ret = [] +// for(def o : dbcursor){ +// ret << o +// } // save(ret) -// ret.clear() -// index ++ -// println index // } // } - } +// } } @@ -93,7 +105,7 @@ class SynchDealPriceToEs { // def map = rows.get(key) def data_id = map._id.toString() map.remove("_id") - request.add(new IndexRequest("deal_price", "_doc", data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("trades", "_doc", data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index d6e73b168..e2625366c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -67,39 +67,39 @@ class DistrictFieldAddBatch extends BaseBatch{ ] static main(args) { -// runBatch(new DistrictFieldAddBatch(), args) - ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> - def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") -// if(dist){ -// d['L'] = dist.loudong_count -// d['M'] = dist.household_count -// d['Q'] = dist.estate_type2 + runBatch(new DistrictFieldAddBatch(), args) +// ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> +// def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") +//// if(dist){ +//// d['L'] = dist.loudong_count +//// d['M'] = dist.household_count +//// d['Q'] = dist.estate_type2 +//// } +// def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") +// if(!list && dist){ +// def alias = dist.alias +// for(def name : alias){ +// list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") +// if(list){ +// d['Z'] = "别名" +// } +// } +// }else{ +// d['Z'] = "名称" // } - def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") - if(!list && dist){ - def alias = dist.alias - for(def name : alias){ - list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") - if(list){ - d['Z'] = "别名" - } - } - }else{ - d['Z'] = "名称" - } - if(list){ - def obj = list[0] - if(obj.loudong_cnt){ - d['W'] = obj.loudong_cnt - } - - if(obj.households){ - d['X'] = obj.households - } - d['Y'] = obj.url - } - - }) +// if(list){ +// def obj = list[0] +// if(obj.loudong_cnt){ +// d['W'] = obj.loudong_cnt +// } +// +// if(obj.households){ +// d['X'] = obj.households +// } +// d['Y'] = obj.url +// } +// +// }) } @Override From 81ecc8b9ae974b6301caed3c67234662c6c86ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 20 Jan 2025 15:10:50 +0800 Subject: [PATCH 115/247] =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/PropertyController.java | 6 +++++- .../com/fangjia/open/model/PropertySearchModel.java | 10 ++++++++++ 2 files changed, 15 insertions(+), 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 89ee1cfcf..c48b964ec 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 @@ -540,8 +540,12 @@ public class PropertyController { } } + String cat = "district"; + if (StringUtils.isNotBlank(model.getCat())) { + cat = model.getCat(); + } List result = districtService.searchByKeyword(model.getCity(), model.getDistrict(), - model.getKeyword(), "district", sdQuery, PROPERTY_SEARCH_API_FIELDS, model.getMax()); + model.getKeyword(), cat, 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) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java index b381d4f31..a4607d7ab 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java @@ -40,6 +40,9 @@ public class PropertySearchModel { // 室号 private String roomNum; + // 类型 + private String cat; + public Boolean getUseOrQuery() { return useOrQuery; } @@ -270,4 +273,11 @@ public class PropertySearchModel { this.roomNum = roomNum; } + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } } From 9d594ac45e9ec6cdc71211ddd1ab1641340d7202 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 21 Jan 2025 09:50:21 +0800 Subject: [PATCH 116/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=8A=A0bedkind=E5=92=8CestateType2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PropertyController.java | 2 ++ .../com/fangjia/open/dto/DistrictInfoDto.java | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) 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 c48b964ec..47e091d9f 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 @@ -830,6 +830,8 @@ public class PropertyController { districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); districtInfoDto.setSalesPhoneNumber(district.getMobile()); districtInfoDto.setTownship(district.getTownship()); + districtInfoDto.setBedKind(district.getBedKind()); + districtInfoDto.setEstateType2(district.getEstateType2()); if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { districtInfoDto.setBuildingCount(district.getLoudongCount()); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java index 8d24c760f..805bc15af 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java @@ -17,6 +17,9 @@ public class DistrictInfoDto { private String district; private String block; private String kind; + private String bedKind; + + private String estateType2; private List floorplanPics; private List pics; private List outPics; @@ -857,4 +860,20 @@ public class DistrictInfoDto { public void setLandProperty(String landProperty) { this.landProperty = landProperty; } + + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } + + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } } From d46691356409bb1aebf7765f0f69e394ead2fc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 21 Jan 2025 17:45:19 +0800 Subject: [PATCH 117/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mongo/dao/office/OfficeRentStatDao.java | 13 ++ .../dao/office/OfficeRentStatDaoImpl.java | 23 ++++ .../dal/mongo/model/OfficeRentStat.java | 75 ++++++++++ .../open/controllers/OfficeController.java | 129 ++++++++++++++++++ .../service/datastore/OfficeService.java | 23 ++++ .../service/datastore/OfficeServiceImpl.java | 57 ++++++++ 6 files changed, 320 insertions(+) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java new file mode 100644 index 000000000..84bd6d813 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java @@ -0,0 +1,13 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.RegionStat; + +import java.util.Date; +import java.util.List; + +public interface OfficeRentStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java new file mode 100644 index 000000000..7cbafebad --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java @@ -0,0 +1,23 @@ +package com.fangjia.dal.mongo.dao.office; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fangjia.dal.mongo.dao.RegionStatDao; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import org.apache.commons.lang.StringUtils; + +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.model.RegionStat; + +public class OfficeRentStatDaoImpl extends MongoDaoImpl implements OfficeRentStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java new file mode 100644 index 000000000..900281731 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -0,0 +1,75 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; +import java.util.Date; + +@Entity +@Table(name = "fangjia_stat.office_rent_stat") +public class OfficeRentStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java new file mode 100644 index 000000000..0a9bd116c --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -0,0 +1,129 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.service.datastore.OfficeService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.annotation.Param; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/1/21 + */ +@Authority(role = Role.USER) +public class OfficeController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private OfficeService officeService; + + /** + * 城市出租均价 + * + * @return + */ + public Object cityRentAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, null, startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 区域出租均价 + * + * @return + */ + public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, district, startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + public void setOfficeService(OfficeService officeService) { + this.officeService = officeService; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java new file mode 100644 index 000000000..5e18e3f6e --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -0,0 +1,23 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.OfficeRentStat; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/1/21 + */ +public interface OfficeService { + + + /** + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate); + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java new file mode 100644 index 000000000..104ef39d9 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -0,0 +1,57 @@ +package com.fangjia.service.datastore; + +import com.fangjia.core.util.CacheUtils; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import org.sothis.core.util.Closure; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author shenjian + * @since 2025/1/21 + */ +public class OfficeServiceImpl implements OfficeService { + + private OfficeRentStatDao officeRentStatDao; + + public List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindRegionBlockStat(city, region, startDate, endDate); + } + }); + } + + public List doFindRegionBlockStat(final String city, final String region, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List regionStats = officeRentStatDao.findAllByParams(params, sortParams); + return regionStats; + } + + public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) { + this.officeRentStatDao = officeRentStatDao; + } +} From 4e791bf94994c9543a9a607dadeb644ce8090c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 22 Jan 2025 09:52:34 +0800 Subject: [PATCH 118/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC=E4=BC=B0=E5=80=BC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mongo/dao/office/OfficeRentStatDao.java | 4 - .../fangjia/dal/mongo/model/Evaluation.java | 23 +- .../open/controllers/OfficeController.java | 386 +++++++++++++++++- .../com/fangjia/open/util/CommonUtils.java | 24 +- .../service/datastore/OfficeService.java | 20 + .../service/datastore/OfficeServiceImpl.java | 28 ++ 6 files changed, 466 insertions(+), 19 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java index 84bd6d813..1a4066162 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java @@ -2,10 +2,6 @@ package com.fangjia.dal.mongo.dao.office; import com.fangjia.dal.MongoDao; import com.fangjia.dal.mongo.model.OfficeRentStat; -import com.fangjia.dal.mongo.model.RegionStat; - -import java.util.Date; -import java.util.List; public interface OfficeRentStatDao extends MongoDao { diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java index 692beb580..7fe4170a1 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java @@ -1,17 +1,10 @@ package com.fangjia.dal.mongo.model; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - import com.fangjia.dal.MongoEntity; +import javax.persistence.*; +import java.util.Date; + @Entity @Table(name = "fangjia.evaluation") public class Evaluation implements MongoEntity { @@ -128,6 +121,7 @@ public class Evaluation implements MongoEntity { //我查查状态字段 private int statusCha; + private Double unitPrice; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -180,6 +174,7 @@ public class Evaluation implements MongoEntity { return totalPrice; } + public void setTotalPrice(Integer totalPrice) { this.totalPrice = totalPrice; } @@ -995,4 +990,12 @@ public class Evaluation implements MongoEntity { this.statusCha = statusCha; } + @Column(name = "unit_price") + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 0a9bd116c..a3b62b926 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -1,23 +1,43 @@ package com.fangjia.open.controllers; import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; import com.fangjia.core.util.LoggerFactory; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.seaweed.model.District; import com.fangjia.open.HttpCode; import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.service.api.AddressMatchProxyService; +import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.OfficeService; +import com.fangjia.service.datastore.OpenApiLogService; +import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.annotation.Param; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; /** * @author shenjian @@ -30,6 +50,12 @@ public class OfficeController { private OfficeService officeService; + private DistrictService districtService; + + private AddressMatchProxyService addressMatchProxyService; + + private OpenApiLogService openApiLogService; + /** * 城市出租均价 * @@ -89,6 +115,10 @@ public class OfficeController { mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); return mav; } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } if (!RegionData.isCity(city)) { String formatCity = RegionData.formatCity(city); if (StringUtils.isNotBlank(formatCity)) { @@ -103,6 +133,11 @@ public class OfficeController { mav.setModel(BasicModel.buildBadRequestModel("city非法")); return mav; } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } if (startDate == null || endDate == null) { mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); @@ -113,17 +148,364 @@ public class OfficeController { return mav; } - List regionStats = officeService.findOfficeRentStat(city, district, startDate, endDate); + List regionStats = officeService.findOfficeRentStat(city, region, startDate, endDate); if (CollectionUtils.isEmpty(regionStats)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); return mav; } mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); return mav; } + /** + * 写字楼楼租金地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + 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.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + 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(model.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)); + } + + } + } + + Evaluation evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/addressEvaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + + /** + * 写字楼租金评估 + * + * @param model + * @param request + * @return + */ + public Object evaluateRentAction(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 || model.getCity().contains("全国") + || model.getDistrict().contains("全国")) { + 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(), "office"); + 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)); + } + + } + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + + Evaluation evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); + Double cityPriceCredit = null; + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/evaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该写字楼的评估").markNoData()); + return mav; + } + } + + 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; + } + + /** + * 通过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.setAddress(model.getAddress()); + 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.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_office_evaluateRent"); + return evaluation; + } + + 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", "活动中心"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + public void setOfficeService(OfficeService officeService) { this.officeService = officeService; } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { + this.addressMatchProxyService = addressMatchProxyService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java index f5b3497e9..f5c8ea110 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java @@ -1,18 +1,21 @@ package com.fangjia.open.util; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; + import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; -import org.apache.commons.beanutils.BeanUtils; //公用 public class CommonUtils { - + //对象转map public static Map convertToMap(Object obj) { try { if (obj instanceof Map) { - return (Map)obj; + return (Map) obj; } Map returnMap = BeanUtils.describe(obj); returnMap.remove("class"); @@ -26,4 +29,19 @@ public class CommonUtils { } return new HashMap(); } + + public static 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; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index 5e18e3f6e..a3276a571 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -1,6 +1,8 @@ package com.fangjia.service.datastore; +import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.seaweed.model.District; import java.util.List; @@ -12,6 +14,8 @@ public interface OfficeService { /** + * 租金均价 + * * @param city * @param region * @param startDate @@ -20,4 +24,20 @@ public interface OfficeService { */ List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate); + /** + * 租金评估 + * + * @param district + * @param evaluation + * @return + */ + Evaluation evaluateRent(District district, Evaluation evaluation); + + /** + * 租金地址维度评估 + * + * @param evaluation + * @return + */ + Evaluation addressEvaluateRent(Evaluation evaluation); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 104ef39d9..0ef5351ae 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -4,13 +4,17 @@ import com.fangjia.core.util.CacheUtils; import com.fangjia.dal.QueryParam; import com.fangjia.dal.SortParam; import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao; +import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.seaweed.model.District; import org.sothis.core.util.Closure; import java.util.ArrayList; import java.util.List; /** + * 写字楼相关服务类 + * * @author shenjian * @since 2025/1/21 */ @@ -18,6 +22,30 @@ public class OfficeServiceImpl implements OfficeService { private OfficeRentStatDao officeRentStatDao; + + + @Override + public Evaluation evaluateRent(District district, Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 + evaluation.setUnitPrice(3.04); + return evaluation; + } + + @Override + public Evaluation addressEvaluateRent(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 + evaluation.setUnitPrice(3.05); + return evaluation; + } + public List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) { return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { From b976e6f802c2c5e268b49b951906309552a6ff31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 22 Jan 2025 18:24:32 +0800 Subject: [PATCH 119/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC=E4=BC=B0=E5=80=BC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 1 - .../service/datastore/OfficeServiceImpl.java | 74 ++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index a3b62b926..510b7011f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -300,7 +300,6 @@ public class OfficeController { model.setDistrictName(district.getName()); Evaluation evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); - Double cityPriceCredit = null; if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { Map districtPriceMap = new HashMap(); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 0ef5351ae..403123eec 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -1,15 +1,23 @@ package com.fangjia.service.datastore; import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.SortParam; import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.mongo.fangjia.SeawaterService; import org.sothis.core.util.Closure; +import org.sothis.core.util.Pager; +import weiboclient4j.utils.StringUtils; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -21,6 +29,7 @@ import java.util.List; public class OfficeServiceImpl implements OfficeService { private OfficeRentStatDao officeRentStatDao; + private SeawaterService seawaterService; @@ -30,8 +39,54 @@ public class OfficeServiceImpl implements OfficeService { evaluation.setFloor(null); evaluation.setHeight(null); } + String city = district.getCity(); + String region = district.getRegion(); + String name = district.getName(); + List alias = district.getAlias(); + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + + SeawaterQuery query = new SeawaterQuery(); + query.setCat("office_rent"); + query.setCityDisplay(city); + if (StringUtils.isNotBlank(region)) { + query.setRegion(region); + } + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setDistrictName(name); + query.setDistrictAlias(alias); +// if (evaluation.getArea() != null && evaluation.getArea() != 0) { +// query.setStartArea(evaluation.getArea() * 0.9); +// query.setEndArea(evaluation.getArea() * 1.1); +// } + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + //List seawaters = seawaterService.findSeawatersByQuery("office_rent", city, region, name, alias, startDate, endDate); + // 有样本 + Double unitPrice = null; + if (seawaters.size() > 0) { + // 计算平均值 + Double sum = 0.0; + Double size = 0.0; + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + } + } else if (StringUtils.isNotBlank(evaluation.getLocation())) { + unitPrice = rentEvaluateByLocation(evaluation); + } // 评估逻辑 - evaluation.setUnitPrice(3.04); + evaluation.setUnitPrice(unitPrice); return evaluation; } @@ -42,10 +97,21 @@ public class OfficeServiceImpl implements OfficeService { evaluation.setHeight(null); } // 评估逻辑 - evaluation.setUnitPrice(3.05); + String location = getLocation(evaluation.getAddress()); + evaluation.setLocation(location); + Double unitPrice = rentEvaluateByLocation(evaluation); + evaluation.setUnitPrice(unitPrice); return evaluation; } + private Double rentEvaluateByLocation(Evaluation evaluation) { + return 3.04; + } + + private String getLocation(String address) { + return ""; + } + public List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) { return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { @@ -79,6 +145,10 @@ public class OfficeServiceImpl implements OfficeService { return regionStats; } + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } + public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) { this.officeRentStatDao = officeRentStatDao; } From 5f4b4fc2d1d933ca91dee1c460b9d7320d9ad0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 23 Jan 2025 11:44:37 +0800 Subject: [PATCH 120/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BB=8F=E7=BA=AC?= =?UTF-8?q?=E5=BA=A6=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/OfficeServiceImpl.java | 93 +++++++++++++++---- .../com/fangjia/service/util/GeoUtils.java | 59 ++++++++++++ .../fangjia/service/util/dto/GaodeDto.java | 39 ++++++++ 3 files changed, 172 insertions(+), 19 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 403123eec..70950f939 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -12,7 +12,10 @@ import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.mongo.fangjia.SeawaterService; +import com.fangjia.service.util.GeoUtils; +import com.fangjia.service.util.dto.GaodeDto; import org.sothis.core.util.Closure; +import org.sothis.core.util.CollectionUtils; import org.sothis.core.util.Pager; import weiboclient4j.utils.StringUtils; @@ -56,10 +59,10 @@ public class OfficeServiceImpl implements OfficeService { query.setEndDate(endDate); query.setDistrictName(name); query.setDistrictAlias(alias); -// if (evaluation.getArea() != null && evaluation.getArea() != 0) { -// query.setStartArea(evaluation.getArea() * 0.9); -// query.setEndArea(evaluation.getArea() * 1.1); -// } + if (evaluation.getArea() != null && evaluation.getArea() != 0) { + query.setStartArea(evaluation.getArea() * 0.9); + query.setEndArea(evaluation.getArea() * 1.1); + } Pager pager = new Pager(); pager.setStartRow(0); pager.setPageSize(100); @@ -69,19 +72,14 @@ public class OfficeServiceImpl implements OfficeService { //List seawaters = seawaterService.findSeawatersByQuery("office_rent", city, region, name, alias, startDate, endDate); // 有样本 Double unitPrice = null; + // 如果面积相近查不到,则不限制面积查询一次,如果还是没有查到,则返回null; + if (CollectionUtils.isEmpty(seawaters)) { + query.setStartArea(null); + query.setEndArea(null); + seawaters = seawaterService.findSeawatersByQuery(query); + } if (seawaters.size() > 0) { - // 计算平均值 - Double sum = 0.0; - Double size = 0.0; - for (Seawater seawater : seawaters) { - if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { - sum += seawater.getTotalPrice(); - size += seawater.getArea(); - } - } - if (size > 0) { - unitPrice = DataUtil.roundDouble(sum / size / 30, 2); - } + unitPrice = this.calcRent(seawaters); } else if (StringUtils.isNotBlank(evaluation.getLocation())) { unitPrice = rentEvaluateByLocation(evaluation); } @@ -90,6 +88,23 @@ public class OfficeServiceImpl implements OfficeService { return evaluation; } + public Double calcRent(List seawaters) { + // 计算平均值 + Double sum = 0.0; + Double size = 0.0; + Double unitPrice = null; + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + } + return unitPrice; + } + @Override public Evaluation addressEvaluateRent(Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { @@ -97,7 +112,7 @@ public class OfficeServiceImpl implements OfficeService { evaluation.setHeight(null); } // 评估逻辑 - String location = getLocation(evaluation.getAddress()); + String location = getLocation(evaluation.getCity(), evaluation.getAddress()); evaluation.setLocation(location); Double unitPrice = rentEvaluateByLocation(evaluation); evaluation.setUnitPrice(unitPrice); @@ -105,10 +120,50 @@ public class OfficeServiceImpl implements OfficeService { } private Double rentEvaluateByLocation(Evaluation evaluation) { - return 3.04; + if (StringUtils.isNotBlank(evaluation.getLocation())) { + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // 查询Seawater样本 + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("office_rent"); + query.setRadius(1000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + if (evaluation.getArea() != null && evaluation.getArea() != 0) { + query.setStartArea(evaluation.getArea() * 0.9); + query.setEndArea(evaluation.getArea() * 1.1); + } + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + // 如果面积相近查不到,则不限制面积查询一次,如果还是没有查到,则返回null; + if (CollectionUtils.isEmpty(seawaters)) { + query.setStartArea(null); + query.setEndArea(null); + seawaters = seawaterService.findSeawatersByQuery(query); + } + if (CollectionUtils.isNotEmpty(seawaters)) { + return calcRent(seawaters); + } + } + return null; } - private String getLocation(String address) { + private String getLocation(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + return gaodeDto.getLng() + "," + gaodeDto.getLat(); + } return ""; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java new file mode 100644 index 000000000..20846e7f4 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java @@ -0,0 +1,59 @@ +package com.fangjia.service.util; + +import com.fangjia.core.util.HttpRequest; +import com.fangjia.service.util.dto.GaodeDto; +import groovy.util.logging.Slf4j; +import net.sf.json.JSONArray; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + + +/** + * 高德经纬度逆解析 + */ +@Slf4j +public class GeoUtils { + + private final static Logger LOGGER = LoggerFactory.getLogger(GeoUtils.class); + + public static GaodeDto geo(String city, String address) { + GaodeDto gaodeDto = new GaodeDto(); + Map params = new HashMap(); + params.put("address", address); + params.put("key", "0cb105e7c10e9ae2b178e4744d62319a"); + params.put("city", city); + params.put("batch", "true"); + params.put("output", "json"); + try { + net.sf.json.JSONObject response = new HttpRequest().getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + if ("10004".equals(response.getInt("infocode"))) { + LOGGER.error("高德服务单位时间内(1分钟)访问量超限, 睡眠1分钟"); + // 开发者的单位时间内(1分钟)访问量超限,被系统自动封停,下一分钟自动解封。 + Thread.sleep(60000); + response = new HttpRequest().getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + } + if ("OK".equals(response.getString("info"))) { + JSONArray geocodes = response.getJSONArray("geocodes"); + if (geocodes.size() > 0) { + net.sf.json.JSONObject geocode = net.sf.json.JSONObject.fromObject(geocodes.get(0)); + String level = geocode.getString("level"); + if (!Arrays.asList("省", "市", "区县", "开发区", "乡镇").contains(level)) { + String location = geocode.getString("location"); + Double lng = Double.valueOf(location.split(",")[0]); + Double lat = Double.valueOf(location.split(",")[1]); + gaodeDto.setLevel(level); + gaodeDto.setLng(lng); + gaodeDto.setLat(lat); + } + } + } + } catch (Exception e) { + LOGGER.error("地图辅助解析出错:" + city + " " + city); + } + return gaodeDto; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java new file mode 100644 index 000000000..1fb150d78 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java @@ -0,0 +1,39 @@ +package com.fangjia.service.util.dto; + +/** + * @author shenjian + * @since 2023/4/26 + */ +public class GaodeDto { + + + private Double lng; + + private Double lat; + + private String level; + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } +} From 419603b0cc6fcd866745b9831a21882e6f6ac3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 23 Jan 2025 14:10:00 +0800 Subject: [PATCH 121/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B3=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/mongo/model/Evaluation.java | 56 +++++++ .../open/controllers/OfficeController.java | 6 +- .../open/model/PropertyEvaluationModel.java | 20 ++- .../service/datastore/OfficeServiceImpl.java | 156 +++++++++++++++++- 4 files changed, 225 insertions(+), 13 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java index 7fe4170a1..7b21bbf0a 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java @@ -122,6 +122,26 @@ public class Evaluation implements MongoEntity { private int statusCha; private Double unitPrice; + + /** + * 写字楼类型:1:标准写字楼;2:创意园区;3:商住两用;4:综合体 + */ + private Integer type; + + /** + * 写字楼等级 1:甲级;2:乙级;3:丙级 + */ + private Integer level; + + /** + * 免租期(月) + */ + private Integer rentFreePeriod; + + /** + * 物业费(元/m?/月) + */ + private Double propertyManagementFee; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -998,4 +1018,40 @@ public class Evaluation implements MongoEntity { public void setUnitPrice(Double unitPrice) { this.unitPrice = unitPrice; } + + @Column(name = "type") + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + @Column(name = "level") + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + @Column(name = "rent_free_period") + public Integer getRentFreePeriod() { + return rentFreePeriod; + } + + public void setRentFreePeriod(Integer rentFreePeriod) { + this.rentFreePeriod = rentFreePeriod; + } + + @Column(name = "property_management_fee") + public Double getPropertyManagementFee() { + return propertyManagementFee; + } + + public void setPropertyManagementFee(Double propertyManagementFee) { + this.propertyManagementFee = propertyManagementFee; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 510b7011f..c5d5b9f95 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -346,13 +346,15 @@ public class OfficeController { */ private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + evaluation.setCity(model.getCity()); evaluation.setRegion(model.getRegion()); evaluation.setDistrictName(model.getName()); evaluation.setAddress(model.getAddress()); 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())); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java index 2abc1acf1..feb2119bd 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java @@ -1,7 +1,5 @@ package com.fangjia.open.model; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; import java.util.Date; public class PropertyEvaluationModel extends FangjiaApiModel { @@ -291,6 +289,8 @@ public class PropertyEvaluationModel extends FangjiaApiModel { private Integer avgPrice; + private Integer level; + private Integer type; public void setDecorationAge(int decorationAge) { this.decorationAge = decorationAge; @@ -926,4 +926,20 @@ public class PropertyEvaluationModel extends FangjiaApiModel { public void setId(String id) { this.id = id; } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 70950f939..e249b8eac 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -19,9 +19,7 @@ import org.sothis.core.util.CollectionUtils; import org.sothis.core.util.Pager; import weiboclient4j.utils.StringUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 写字楼相关服务类 @@ -79,7 +77,7 @@ public class OfficeServiceImpl implements OfficeService { seawaters = seawaterService.findSeawatersByQuery(query); } if (seawaters.size() > 0) { - unitPrice = this.calcRent(seawaters); + unitPrice = this.calcRent(seawaters, evaluation); } else if (StringUtils.isNotBlank(evaluation.getLocation())) { unitPrice = rentEvaluateByLocation(evaluation); } @@ -88,11 +86,151 @@ public class OfficeServiceImpl implements OfficeService { return evaluation; } - public Double calcRent(List seawaters) { +// 所在楼层 +// 总楼层 + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "毛坯"); + put("2", "简装"); + put("3", "精装"); + put("4", "豪装"); + } + }; + private static final Map LEVEL_MAP = new HashMap() { + { + put(1, "甲级"); + put(2, "乙级"); + put(3, "丙级"); + } + }; + private static final Map TYPE_MAP = new HashMap() { + { + put(1, "标准写字楼"); + put(2, "创意园区"); + put(3, "商住两用"); + put(4, "综合体"); + } + }; + public Double calcRent(List seawaters, Evaluation evaluation) { // 计算平均值 Double sum = 0.0; Double size = 0.0; Double unitPrice = null; + Double factor = 1.0; + // 按写字楼类型过滤 + List filterWithType = new ArrayList(); + if (evaluation.getType() != null) { + if (TYPE_MAP.get(evaluation.getFitment()) != null) { + for (Seawater seawater : seawaters) { + if (TYPE_MAP.get(evaluation.getType()).equals(seawater.getEstateType())) { + filterWithType.add(seawater); + } + } + } + // 如果样本数量大于5,则按装修过滤 + if (filterWithType.size() > 5) { + seawaters = filterWithType; + } else { + // TODO 按照写字楼类型进行调整,1:标准写字楼;2:创意园区;3:商住两用;4:综合体 + // 拍脑袋 + if (evaluation.getType() == 1) { + factor *= 1.0; + } else if (evaluation.getType() == 2) { + factor *= 0.98; + } else if (evaluation.getType() == 3) { + factor *= 0.97; + } else if (evaluation.getType() == 4) { + factor *= 0.96; + } + } + } + // 按写字楼等级过滤 + List filterWithGrade = new ArrayList(); + if (evaluation.getLevel() != null) { + if (LEVEL_MAP.get(evaluation.getFitment()) != null) { + for (Seawater seawater : seawaters) { + if (LEVEL_MAP.get(evaluation.getLevel()).equals(seawater.getLevel())) { + filterWithGrade.add(seawater); + } + } + } + // 如果样本数量大于5,则按装修过滤 + if (filterWithGrade.size() > 5) { + seawaters = filterWithGrade; + } else { + // TODO 按照写字楼等级进行调整,1:甲级;2:乙级;3:丙级 + // 拍脑袋 + if (evaluation.getLevel() == 1) { + factor *= 1.2; + } else if (evaluation.getLevel() == 2) { + factor *= 1.0; + } else if (evaluation.getLevel() == 3) { + factor *= 0.9; + } + } + } + // 按楼层过滤 + List filterWithFloor = new ArrayList(); + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + String floorDesc = "中层"; + if (floorInfo <= 0.33) { + floorDesc = "低层"; + } else if (floorInfo > 0.66) { + floorDesc = "高层"; + } + if (LEVEL_MAP.get(evaluation.getFitment()) != null) { + for (Seawater seawater : seawaters) { + if (seawater.getFloorInfo() != null && seawater.getFloorInfo().contains(floorDesc)) { + filterWithFloor.add(seawater); + } + } + } + // 如果样本数量大于5,则按装修过滤 + if (filterWithFloor.size() > 5) { + seawaters = filterWithGrade; + } else { + // TODO 按照写字楼楼层进行调整,高层 中层 低层 + // 拍脑袋 + if (floorDesc.equals("高层")) { + factor *= 1.2; + } else if (floorDesc.equals("中层")) { + factor *= 1.0; + } else if (floorDesc.equals("低层")) { + factor *= 0.9; + } + } + } + // 按装修过滤 + List filterWithFitment = new ArrayList(); + + if (evaluation.getFitment() != null) { + if (FITMENT_MAP.get(evaluation.getFitment()) != null) { + for (Seawater seawater : seawaters) { + if (FITMENT_MAP.get(evaluation.getFitment()).equals(seawater.getFitment())) { + filterWithFitment.add(seawater); + } + } + } + // 如果样本数量大于5,则按装修过滤 + if (filterWithFitment.size() > 5) { + seawaters = filterWithFitment; + } else { + // TODO 按照装修系数进行调整,如1: 毛坯,2: 简装,3: 精装,4: 豪装 + // 拍脑袋 + if (evaluation.getFitment().equals(1)) { + factor *= 0.8; + } else if (evaluation.getFitment().equals(2)) { + factor *= 1.0; + } else if (evaluation.getFitment().equals(3)) { + factor *= 1.2; + } else if (evaluation.getFitment().equals(4)) { + factor *= 1.5; + } + } + } + // TODO 3.4免租期factor*调整因子:factory - 免租期/最低起租期 + // TODO 物业费因子 for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { sum += seawater.getTotalPrice(); @@ -100,9 +238,9 @@ public class OfficeServiceImpl implements OfficeService { } } if (size > 0) { - unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + unitPrice = DataUtil.roundDouble(sum / size / 30 * factor, 2); } - return unitPrice; + return unitPrice ; } @Override @@ -142,7 +280,7 @@ public class OfficeServiceImpl implements OfficeService { query.setCityDisplay(evaluation.getCity()); Pager pager = new Pager(); pager.setStartRow(0); - pager.setPageSize(5); + pager.setPageSize(10); query.setPager(pager); query.setTable("latest_seawater"); seawaters = seawaterService.findSeawatersByQuery(query); @@ -153,7 +291,7 @@ public class OfficeServiceImpl implements OfficeService { seawaters = seawaterService.findSeawatersByQuery(query); } if (CollectionUtils.isNotEmpty(seawaters)) { - return calcRent(seawaters); + return calcRent(seawaters, evaluation); } } return null; From ad5ff5627d25b3809684d964034a603633e9766c Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 24 Jan 2025 10:21:14 +0800 Subject: [PATCH 122/247] =?UTF-8?q?/property/detail=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/district/DistrictStatServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 9d2259bd7..6065c2063 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1543,7 +1543,7 @@ public class DistrictStatServiceImpl implements DistrictStatService { DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); if (statBo != null && statBo.getDefaultDistrictStat() != null) { - if (statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { + if (statBo.getDefaultDistrictStat().getAvg_price_2b() != null && statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { return statBo.getDefaultDistrictStat().getAvg_price_2b(); } if (statBo.getDefaultDistrictStat().getAvgPrice() > 0) { From a9cf819a653c942391738ea67e363419982a082a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 11:23:34 +0800 Subject: [PATCH 123/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 13 +++- .../script/gj/es/EsMonthHouseStat.groovy | 76 ++++++++++++++++++- 2 files changed, 84 insertions(+), 5 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 d77e63373..94a3445f5 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 @@ -5137,17 +5137,22 @@ class CommonDatautils { def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) def townMap = [:] for(def d : dbcursor){ + def distName = null if(d.mzb_district_name){ - def list = townMap.get(d.mzb_district_name) + distName = d.mzb_district_name + }else{ + distName = d.district + } + if(distName){ + def list = townMap.get(distName) if(!list){ list = [] } list << d - townMap.put(d.mzb_district_name, list) + townMap.put(distName, list) } } - - println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss") +// println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss") return townMap } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy index 9be75aeb0..e07ac0739 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy @@ -26,7 +26,8 @@ class EsMonthHouseStat { // task.statHouseUpdateCount() // task.statDistHouse() - task.statRent() +// task.statRent() + task.statOfficeHouse() } def statRent(){ @@ -201,6 +202,51 @@ class EsMonthHouseStat { },0) } + def statOfficeHouse(){ + def citys = CommonDatautils.findAllCity() + def allLists = [] + allLists << ["城市", "近一年写字楼出售量", "写字楼量", "近一年出售房源量大于3的写字楼量", "大于3写字楼量占比"] + citys.each{c-> + def count = findHouseCountByCat(c, "office_sell",20240101, 20250201) + + def districts = CommonDatautils.findAllDistricts(c, "office", ["city", "region", "name", "alias"]); + def disthouseCount = 0 + for(def dist : districts){ + def alias = [] + if(dist.alias){ + if(!dist.alias.contains(dist.name)){ + dist.alias << dist.name + } + alias = dist.alias + }else{ + alias << dist.name + } + + def distCount = 0 + if(count){ + distCount = findHouseCountByCat(dist.city, dist.region, alias, 20240101, 20250201, "office_sell") + if(distCount && distCount>=3){ + disthouseCount++ + } + } +// println dist.city+" "+dist.region+" "+dist.name+" "+distCount + } + + println "disthouseCount:"+disthouseCount +// println districts.size() + def precent = 0 + if(districts){ + precent = DataHandleUtils.getDoubleRound(2, disthouseCount*100.0/districts.size()) + } + def row = [c , count, districts.size(), disthouseCount, precent+"%"] + println row + allLists << row + } + + ExcelUtils.write("D:\\数据\\写字楼\\全国写字楼情况占比统计.xlsx", allLists, "写字楼情况") + + } + def findHouseCount(def city, def region, def alias, def startDate, def endDate){ def aliasStr = null; @@ -219,6 +265,23 @@ class EsMonthHouseStat { return total } + def findHouseCountByCat(def city, def region, def alias, def startDate, def endDate, cat){ + def aliasStr = null; + def total = 0 + try{ + aliasStr = escapeExprSpecialWord(alias.join("','")) + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} and region='${region}' and district_name in ('${aliasStr}') " + + ElasticUtils.executeSqlQuery(sql,{data-> + total = data.c + }) + }catch(Exception e){ + e.printStackTrace() + } + + return total + } + /** * 转义字符串中的特殊字符 * 仅过滤Lucene regexps, 其他的勿用 @@ -240,6 +303,17 @@ class EsMonthHouseStat { } + def findHouseCountByCat(def city, def cat, def startDate, def endDate){ + + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} " + def total = 0 + ElasticUtils.executeSqlQuery(sql,{ data-> + total = data.c + }) + return total + } + + From 02c5f23fbf9ebc0c713f4d46928c8ac89e9cc5ca Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 11:35:31 +0800 Subject: [PATCH 124/247] add --- .../gj/district/UpdateDistrictField.groovy | 413 ++++++++++++++++++ 1 file changed, 413 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy new file mode 100644 index 000000000..710eeacca --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy @@ -0,0 +1,413 @@ +package com.fangjia.script.gj.district + +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.gj.FiledStrand +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +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 + +/** + * 根据链家数据修改小区库中字段 + * 使用到中间映射表 + */ +@BatchOwner(Watcher.GaoJuan) +class UpdateDistrictField extends BaseBatch{ + + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + def fields = ["developer","estate_company","household_count","loudong_count","estate_charge","car_site_count"] + + def sources = ["链家", "我爱我家", "安居客"] + + def statMap = [:] + + static main(args) { + runBatch(new UpdateDistrictField(), args) + } + + @Override + void process(Object args) { + def sourceMap = [:] + sources.each {source-> + def valMap = findThirdMatchDist(source) + println source +" "+valMap.size() + if(valMap){ + sourceMap.put(source, valMap) + } + } + def margeResults = megerDatas(sourceMap) +// updateDB(margeResults) + } + + def megerDatas(sourceMap){ + def set = new HashSet() + sources.each {source-> + def valMap = sourceMap.get(source) + set.addAll(valMap.keySet()) + } + def lastValues = [] + set.each {id-> + + def dbObj = CommonDatautils.findDistrictById(id) + + def datas = [] + sources.each {source-> + def valMap = sourceMap.get(source) + def sourceEsObj = findCommunities(valMap.get(id)) + if(sourceEsObj){ + if(source == "链家"){ + sourceEsObj.source = "lianjia" + }else if(source == "我爱我家"){ + sourceEsObj.source = "wiwj" + }else if(source == "安居客"){ + sourceEsObj.source = "anjuke" + } + datas << sourceEsObj + } + } + if(dbObj && datas){ + def newValMap = getNewField2(datas, dbObj) + if(newValMap){ + newValMap.put("id", id) + lastValues << newValMap + } + } + } + + statMap.each {source,fieldMap-> + println source +" "+fieldMap.size() + fieldMap.each{f,v-> + println f+" "+ v + } + println "----------------------------------------" + } + return lastValues + } + + + def margeValue(lianjiaMap, wiwjMap, anjukeMap){ + def lianjisIds = lianjiaMap.keySet() + def wiwjIds = wiwjMap.keySet() + def anjukeIds = anjukeMap.keySet() + def set = new HashSet() + set.addAll(lianjisIds) + set.addAll(wiwjIds) + set.addAll(anjukeIds) + + def lastValues = [] + def lianjiaUpdateCount = 0 + def wiwjUpdateCount = 0 + def anjukeUpdateCount = 0 + def lianjiaCountMap = [:] + def wiwjCountMap = [:] + def anjukeCountMap = [:] + set.each {id-> + BasicDBObject newValMap = new BasicDBObject() + fields.each {field-> + def lianjiaValMap = lianjiaMap.get(id) + def wiwjValMap = wiwjMap.get(id) + def anjukeValMap = anjukeMap.get(id) + if(lianjiaValMap && lianjiaValMap.containsKey(field)){ + newValMap.put(field, lianjiaValMap.get(field)) + lianjiaUpdateCount++ + def count = lianjiaCountMap.get(field) + if(!count){ + lianjiaCountMap.put(field, 1) + }else{ + lianjiaCountMap.put(field, count + 1) + } + }else if(wiwjValMap && wiwjValMap.containsKey(field)){ + newValMap.put(field, wiwjValMap.get(field)) + wiwjUpdateCount++ + def count = wiwjCountMap.get(field) + if(!count){ + wiwjCountMap.put(field, 1) + }else{ + wiwjCountMap.put(field, count + 1) + } + }else if(anjukeValMap && anjukeValMap.containsKey(field)){ + newValMap.put(field, anjukeValMap.get(field)) + anjukeUpdateCount++ + def count = anjukeCountMap.get(field) + if(!count){ + anjukeCountMap.put(field, 1) + }else{ + anjukeCountMap.put(field, count + 1) + } + } + } + newValMap.put("id", id) + lastValues << newValMap + } + + lianjiaCountMap.each {k,v-> + println "[链家] "+k+" "+v + } + + wiwjCountMap.each {k,v-> + println "[我爱我家] "+k+" "+v + } + + anjukeCountMap.each {k,v-> + println "[安居客] "+k+" "+v + } + return lastValues + } + + def updateDB(margeResults){ + for(def mr : margeResults){ + def id = mr.get("id") + mr.remove("id") + mr.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(id)),new BasicDBObject('$set',mr)) + } + } + + def batchUpdateDist(source){ +// def rets = findThirdMatchDist(source) + println "[${source}] 符保条件小区量:"+rets.size() + def updateIndex = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + def allUpdateList = new CopyOnWriteArrayList() + + def sourceMap = new ConcurrentHashMap() + + for(def i=0;i + def count = countMap.get(k) + if(!count){ + countMap.put(k, 1) + }else{ + countMap.put(k, count+1) + } + } + } + + countMap.each {k,v-> + println k +" 更新量:"+v + } + + println "---------------------------------------------------------" + return sourceMap + } + + def running(url, old_match_id){ + def esObj = findCommunities(url) + def dbObj = CommonDatautils.findDistrictById(old_match_id) + if(dbObj){ + def newValMap = getNewField(esObj, dbObj) + return newValMap + } + return null + } + + def getNewField(esObj, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + esObj.each{field, esVal-> + def dbVal = dbObj.get(field) + def newVal = null + if(esVal && field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + + } + if(esVal && field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(esVal && field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(esVal && field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(esVal && field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + if(newVal){ + newValMap.put(field, newVal) + } + + } + + return newValMap + } + + def getNewField2(esDatas, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + def lastValueMap = [:] + def haveValueMap = [:] + fields.each{field-> + for(def esData : esDatas){ + def esVal = esData.get(field) + def dbVal = dbObj.get(field) + def newVal = null + if(haveValueMap.containsKey(field)){ + continue + }else{ + if(lastValueMap.containsKey(field)){ + continue + } + if(esVal){ + + if(field=="estate_charge" || field=="car_site_count") { + esVal = FiledStrand.getNumber(esVal) + } + if(dbVal && esVal.toString()==dbVal.toString()){ + haveValueMap.put(field, esVal) + }else{ + if(field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + } + } + if(newVal){ + lastValueMap.put(field, newVal) + + //以下为统计各网站各字段的更新情况 + def fieldStatMap = statMap.get(esData.source) + if(!fieldStatMap){ + fieldStatMap = [:] + statMap.put(esData.source, fieldStatMap) + } + def count = fieldStatMap.get(field) + if(!count){ + fieldStatMap.put(field, 1) + }else{ + fieldStatMap.put(field, count + 1) + } + } + } + } + } + return lastValueMap + } + + def findThirdMatchDist(source){ + def query = new BasicDBObject("source",source).append("old_match_way", 1) + def keys = new BasicDBObject() + keys.put("url", 1) + keys.put("old_match_id", 1) + keys.put("old_match_city", 1) + keys.put("old_match_district", 1) + keys.put("old_match_name", 1) + def idsMap = [:] + def dbcursor = thirdSeaweedMappingColl.find(query, keys) + for(def db : dbcursor){ + if(!db.old_match_id && db.old_match_name){ + def dbo = CommonDatautils.findDistrict(db.old_match_city, db.old_match_district, db.old_match_name, "district") + if(dbo){ + idsMap.put(dbo._id.toString(), db.url) + } + }else{ + idsMap.put(db.old_match_id, db.url) + } + + } + return idsMap + } + + static def findCommunities(url){ + if(!url){ + return null + } + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("url", url)) + def rets = [] + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "community", queryBuilder); + }catch(Exception e){ + findCommunities(url) + } + def data = [:] + if(datas) { + for (int k = 0; k < datas.size(); k++) { + def d = datas[k]; + data.put("household_count", d.households) + data.put("loudong_count", d.loudong_cnt) + data.put("developer", d.developer) + data.put("estate_company", d.property_company) + data.put("estate_charge", d.property_fee) + data.put("car_site_count", d.parking_cnt) + } + } + return data; + } +} From 4906378a520c39762f8ac96060045de3af1c607b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 13:45:51 +0800 Subject: [PATCH 125/247] update --- .../com/fangjia/script/gj/FiledStrand.groovy | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy index a3c119bec..514dd9631 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy @@ -909,14 +909,18 @@ class FiledStrand { } static def getNumber(def input) { - Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); - Matcher matcher = pattern.matcher(input); - List list = new ArrayList(); - while (matcher.find()) { - list.add(matcher.group()); - } - if(list.size()>0){ - return list.get(0); + try{ + Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); + Matcher matcher = pattern.matcher(input); + List list = new ArrayList(); + while (matcher.find()) { + list.add(matcher.group()); + } + if(list.size()>0){ + return list.get(0); + } + }catch(Exception e){ + println input+" error" } return null; } From eeada6893fd71570b1dc3d47befae4e0e352754e Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 7 Feb 2025 14:10:18 +0800 Subject: [PATCH 126/247] =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6=E6=9F=A5?= =?UTF-8?q?=E5=91=A8=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PoiController.java | 107 +++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java index 1cc608e7e..b02d7ea4b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java @@ -19,6 +19,7 @@ import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.mongo.fangjia.CbmRegionService; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; +import org.apache.commons.codec.binary.Base64; import javax.validation.Valid; import java.util.*; @@ -31,6 +32,8 @@ public class PoiController { private AddressParserService addressParserService; private DistrictService districtService; private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "addrAlias"}; + private static final String ES_USER = "developer"; + private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; public Object getAntiFraudQuestionAction(@Valid AntiFraudQuestionModel model) { RestfulModelAndView mav = new RestfulModelAndView(); @@ -221,7 +224,7 @@ public class PoiController { public Object searchAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) { + if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) { mav.setModel(BasicModel.buildBadRequestModel("城市和经纬度为必填项")); return mav; } @@ -268,6 +271,108 @@ public class PoiController { return mav; } + public Object facilitiesAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + String city = model.getCity(); + String lngStr = model.getLng(); + String latStr = model.getLat(); + String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数 + if (!lngStr.matches(numberPattern) || !latStr.matches(numberPattern)) { + mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)格式错误")); + return mav; + } + double lng = Double.parseDouble(lngStr); + double lat = Double.parseDouble(latStr); + Map> result = new HashMap>(); + List bankSmallType = Arrays.asList("银行", "中国人民银行", "国家开发银行", "中国进出口银行"); + List busSmallType = Collections.singletonList("公交车站相关"); + List hospitalSmallType = Arrays.asList("综合医院", "三级甲等医院", "专科医院"); + List schoolSmallType = Arrays.asList("学校", "高等院校", "中学", "小学", "幼儿园"); + List subwaySmallType = Collections.singletonList("地铁站"); + List supermarketSmallType = Arrays.asList("商场", "购物中心", "普通商场"); + + result.put("bank", findAroundByLocation(city, lng, lat, bankSmallType, 1000, true)); + result.put("bus", findAroundByLocation(city, lng, lat, busSmallType, 1000, false)); + result.put("hospital", findAroundByLocation(city, lng, lat, hospitalSmallType, 1000, true)); + result.put("school", findAroundByLocation(city, lng, lat, schoolSmallType, 1000, true)); + result.put("subway", findAroundByLocation(city, lng, lat, subwaySmallType, 1000, false)); + result.put("supermarket", findAroundByLocation(city, lng, lat, supermarketSmallType, 1000, true)); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + return mav; + } + + private List findAroundByLocation(String city, double lng, double lat, List smallTypes, int distance, boolean excludeStatus) { + List poiNames = new ArrayList(); + JSONObject reqBody = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + List mustNotList = new ArrayList(); + + if (excludeStatus) { + JSONObject statusParam = new JSONObject(); + statusParam.put("status", 1); + JSONObject statusTerm = new JSONObject(); + statusTerm.put("term", statusParam); + mustNotList.add(statusTerm); + } + JSONObject mainTypeParam = new JSONObject(); + mainTypeParam.put("main_type", 0); + JSONObject mainTypeTerm = new JSONObject(); + mainTypeTerm.put("term", mainTypeParam); + mustNotList.add(mainTypeTerm); + + JSONObject cityParam = new JSONObject(); + cityParam.put("city", city); + JSONObject cityTerm = new JSONObject(); + cityTerm.put("term", cityParam); + jsonList.add(cityTerm); + + JSONObject smallTypeParam = new JSONObject(); + smallTypeParam.put("small_type", smallTypes); + JSONObject smallTypeTerm = new JSONObject(); + smallTypeTerm.put("terms", smallTypeParam); + jsonList.add(smallTypeTerm); + + JSONObject geoDistance = new JSONObject(); + geoDistance.put("distance", distance + "m"); + geoDistance.put("location", Arrays.asList(lng, lat)); + JSONObject geoQuery = new JSONObject(); + geoQuery.put("geo_distance", geoDistance); + jsonList.add(geoQuery); + + queryJson.put("must", jsonList); + if (!mustNotList.isEmpty()) { + queryJson.put("must_not", mustNotList); + } + JSONObject boolQuery = new JSONObject(); + boolQuery.put("bool", queryJson); + reqBody.put("query", boolQuery); + + Base64 token = new Base64(); + String authEncoding = token.encodeAsString((ES_USER + ":" + ES_PASSWORD).getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authEncoding); + + try { + String response = request.postWithBody("http://192.168.0.89:9200/gaode_map_poi/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + List> hits = (List>) json.getJSONObject("hits").get("hits"); + + for (Map hit : hits) { + Map source = (Map) hit.get("_source"); + if (source.containsKey("name")) { + poiNames.add(source.get("name").toString()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return poiNames; + } + public void setAmapPoiService(AmapPoiService amapPoiService) { this.amapPoiService = amapPoiService; } From 4d1cba094f9ef58f6ab8d23bc0ed9bd1c70e8a57 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 7 Feb 2025 15:12:37 +0800 Subject: [PATCH 127/247] =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6=E6=9F=A5?= =?UTF-8?q?=E5=91=A8=E8=BE=B9=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PoiController.java | 9 +- .../open/AdministrativeMappingService.java | 19 ++++ .../AdministrativeMappingServiceImpl.java | 97 +++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java index b02d7ea4b..f2cb3aa94 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java @@ -17,6 +17,7 @@ import com.fangjia.service.api.AmapPoiService; import com.fangjia.service.bo.Point; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.mongo.fangjia.CbmRegionService; +import com.fangjia.service.open.AdministrativeMappingService; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.apache.commons.codec.binary.Base64; @@ -31,6 +32,8 @@ public class PoiController { private CbmRegionService cbmRegionService; private AddressParserService addressParserService; private DistrictService districtService; + + private AdministrativeMappingService administrativeMappingService; private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "addrAlias"}; private static final String ES_USER = "developer"; private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; @@ -273,7 +276,7 @@ public class PoiController { public Object facilitiesAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); - String city = model.getCity(); + String city = administrativeMappingService.findCityByCityShort(model.getCity()); String lngStr = model.getLng(); String latStr = model.getLat(); String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数 @@ -388,4 +391,8 @@ public class PoiController { public void setDistrictService(DistrictService districtService) { this.districtService = districtService; } + + public void setAdministrativeMappingService(AdministrativeMappingService administrativeMappingService) { + this.administrativeMappingService = administrativeMappingService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java new file mode 100644 index 000000000..a0fc680e1 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java @@ -0,0 +1,19 @@ +package com.fangjia.service.open; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.dao.AdministrativeMappingDao; +import com.fangjia.dal.mongo.model.AdministrativeMapping; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public interface AdministrativeMappingService { + + + + public String findCityCodeByCityShort(String cityShort); + public String findCityByCityShort(String cityShort) ; + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java new file mode 100644 index 000000000..521b1e5ef --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java @@ -0,0 +1,97 @@ +package com.fangjia.service.open; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.dao.AdministrativeMappingDao; +import com.fangjia.dal.mongo.model.AdministrativeMapping; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class AdministrativeMappingServiceImpl implements AdministrativeMappingService { + private AdministrativeMappingDao administrativeMappingDao; + private List CITY_SHORT = new ArrayList(Arrays.asList( + "五家渠", "图木舒克", "石河子", "吐鲁番", "中卫", "石嘴山", "海北州", + "张掖", "天水", "铜川", "山南", "昌都", "拉萨", "咸阳", "迪庆州", + "楚雄", "白银", "榆林", "普洱", "丽江", "昆明", "玉树州", "甘孜州", + "阿坝州", "银川", "雅安", "文山州", "西双版纳州", "琼中", "保亭", "乐东", + "昌江", "白沙", "临高", "陇南", "定安", "万宁", "宝鸡", "三亚", "来宾", + "贺州", "怒江州", "河池", "贵港", "防城港", "梧州", "柳州", "中山", "清远", + "定西", "临沧", "德宏州", "琼海", "崇左", "鹤岗", "安阳", "宿迁", + "泰州", "盐城", "齐齐哈尔", "淮安", "澄迈", "营口", "宿州", "甘南", "泰安", + "无锡", "鄂州", "吴忠", "玉林", "鄂尔多斯", "湖州", "辽源", "邯郸", "六安", + "海口", "双鸭山", "抚顺", "白城", "贵阳", "运城", "徐州", "蚌埠", + "白山", "延安", "通化", "牡丹江", "临汾", "云浮", "朝阳", "保山", + "铁岭", "淮南", "金华", "长治", "克孜勒苏", "四平", "太原", "梅州", + "北京", "阜新", "晋中", "阿拉善盟", "晋城", "石家庄", "五指山", "鸡西", + "抚州", "果洛州", "驻马店", "芜湖", "呼和浩特", "邢台", "黑河", "七台河", + "承德", "龙岩", "镇江", "苏州", "衡水", "安康", "南宁", "包头", + "赤峰", "济源", "绍兴", "张家口", "大同", "阳泉", "吕梁", "乌海", + "河源", "通辽", "滁州", "东莞", "杭州", "巴彦淖尔", "常州", "乌兰察布", + "新余", "延边", "九江", "临夏", "湘西", "保定", "林芝", "沧州", + "阜阳", "临沂", "乌鲁木齐", "锡林郭勒盟", "本溪", "德州", "扬州", + "鞍山", "松原", "丽水", "衢州", "合肥", "屯昌", "黄山", "武威", + "亳州", "宣城", "三明", "绥化", "湘潭", "衡阳", "南平", "沈阳", + "辽阳", "南昌", "景德镇", "鹰潭", "赣州", "兴安盟", "吉安", + "庆阳", "宜春", "上饶", "潍坊", "济南", "淄博", "哈尔滨", + "枣庄", "忻州", "济宁", "日照", "韶关", "开封", "商丘", "大理", + "菏泽", "西宁", "郑州", "神农架", "平顶山", "朔州", "鹤壁", + "新乡", "东方", "焦作", "伊春", "萍乡", "常德", "周口", + "渭南", "张家界", "阿里", "桂林", "大庆", "长沙", "益阳", + "株洲", "邵阳", "郴州", "永州", "娄底", "胡杨河", "昆玉", + "嘉峪关", "北屯", "塔城", "巴音郭楞", "博尔塔拉", "昌吉", + "阿拉尔", "克拉玛依", "海西州", "黄南州", "酒泉", "平凉", + "汉中", "昭通", "黔西南", "铜仁", "遵义", "资阳", "巴中", + "广安", "宜宾", "眉山", "南充", "毕节", "乐山", "达州", + "遂宁", "广元", "绵阳", "德阳", "伊犁", "成都", "安顺", + "重庆", "陵水", "红河", "可克达拉", "文昌", "儋州", "百色", + "北海", "揭阳", "潮州", "阳江", "汕尾", "双河", "肇庆", + "湛江", "汕头", "深圳", "内江", "广州", "台州", "嘉兴", + "茂名", "宁波", "三沙", "南通", "和田", "舟山", "连云港", + "喀什", "南京", "锦州", "长春", "固原", "温州", "上海", + "佛山", "钦州", "六盘水", "潜江", "葫芦岛", "岳阳", "曲靖", + "佳木斯", "大兴安岭", "濮阳", "信阳", "烟台", "安庆", + "秦皇岛", "天津", "廊坊", "黔南", "那曲", "海南州", + "日喀则", "武汉", "怀化", "三门峡", "海东", "兰州", + "聊城", "凉山州", "泸州", "南阳", "黔东南", "吉林", + "阿克苏", "滨州", "唐山", "铜陵", "金昌", "丹东", + "玉溪", "白杨", "呼伦贝尔", "铁门关", "仙桃", "随州", + "淮北", "商洛", "江门", "池州", "盘锦", "厦门", + "西安", "自贡", "莆田", "泉州", "漳州", "福州", + "马鞍山", "宁德", "大连", "孝感", "十堰", "青岛", + "攀枝花", "东营", "威海", "新星", "洛阳", "黄石", + "阿勒泰", "许昌", "漯河", "宜昌", "哈密", "襄阳", + "荆门", "荆州", "黄冈", "恩施", "天门", "咸宁", + "惠州", "珠海" + )); + + + public String findCityCodeByCityShort(String cityShort) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("cityShort", cityShort)); + params.add(new QueryParam("type", "城市")); + AdministrativeMapping firstByParams = administrativeMappingDao.findFirstByParams(params); + if (firstByParams != null && StringUtils.isNotBlank(firstByParams.getMzbCityCode())) { + return firstByParams.getMzbCityCode(); + } + return null; + } + + public String findCityByCityShort(String cityShort) { + if (CITY_SHORT.contains(cityShort)) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("cityShort", cityShort)); + params.add(new QueryParam("type", "城市")); + AdministrativeMapping firstByParams = administrativeMappingDao.findFirstByParams(params); + if (firstByParams != null && StringUtils.isNotBlank(firstByParams.getMzbCityCode())) { + return firstByParams.getCity(); + } + } + return cityShort; + } + + public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { + this.administrativeMappingDao = administrativeMappingDao; + } +} From fbe0709780a00d4b4fcfcf0132b67750fa9de318 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 7 Feb 2025 15:48:28 +0800 Subject: [PATCH 128/247] =?UTF-8?q?=E6=88=BF=E6=BA=90=E8=B7=9D=E7=A6=BB?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=8F=82=E6=95=B0=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?3km?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/HouseController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 8870454dc..f8bfdcf10 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -927,7 +927,9 @@ public class HouseController { model.setStartTime(sixMonthsAgoInt); model.setEndTime(todayInt); // 默认3000M内 - model.setRadius(3000); + if (model.getRadius() == null) { + model.setRadius(3000); + } if (StringUtils.isBlank(model.getLocation())) { mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)不能为空")); return mav; From c717f3cf6ce6d64285d4ec43ceb1e6a1b202a007 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 16:58:05 +0800 Subject: [PATCH 129/247] update --- .../gj/district/UpdateDistrictField.groovy | 241 +++++++++--------- .../gj/images/AddDistImagesBatch.groovy | 49 ++-- .../thirdPriceCrawl/DataStandardBatch.groovy | 1 + 3 files changed, 150 insertions(+), 141 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy index 710eeacca..f44d8bf4b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy @@ -52,7 +52,8 @@ class UpdateDistrictField extends BaseBatch{ } } def margeResults = megerDatas(sourceMap) -// updateDB(margeResults) + updateDB(margeResults) + println "修改完成 "+new Date().toString() } def megerDatas(sourceMap){ @@ -101,74 +102,74 @@ class UpdateDistrictField extends BaseBatch{ } - def margeValue(lianjiaMap, wiwjMap, anjukeMap){ - def lianjisIds = lianjiaMap.keySet() - def wiwjIds = wiwjMap.keySet() - def anjukeIds = anjukeMap.keySet() - def set = new HashSet() - set.addAll(lianjisIds) - set.addAll(wiwjIds) - set.addAll(anjukeIds) - - def lastValues = [] - def lianjiaUpdateCount = 0 - def wiwjUpdateCount = 0 - def anjukeUpdateCount = 0 - def lianjiaCountMap = [:] - def wiwjCountMap = [:] - def anjukeCountMap = [:] - set.each {id-> - BasicDBObject newValMap = new BasicDBObject() - fields.each {field-> - def lianjiaValMap = lianjiaMap.get(id) - def wiwjValMap = wiwjMap.get(id) - def anjukeValMap = anjukeMap.get(id) - if(lianjiaValMap && lianjiaValMap.containsKey(field)){ - newValMap.put(field, lianjiaValMap.get(field)) - lianjiaUpdateCount++ - def count = lianjiaCountMap.get(field) - if(!count){ - lianjiaCountMap.put(field, 1) - }else{ - lianjiaCountMap.put(field, count + 1) - } - }else if(wiwjValMap && wiwjValMap.containsKey(field)){ - newValMap.put(field, wiwjValMap.get(field)) - wiwjUpdateCount++ - def count = wiwjCountMap.get(field) - if(!count){ - wiwjCountMap.put(field, 1) - }else{ - wiwjCountMap.put(field, count + 1) - } - }else if(anjukeValMap && anjukeValMap.containsKey(field)){ - newValMap.put(field, anjukeValMap.get(field)) - anjukeUpdateCount++ - def count = anjukeCountMap.get(field) - if(!count){ - anjukeCountMap.put(field, 1) - }else{ - anjukeCountMap.put(field, count + 1) - } - } - } - newValMap.put("id", id) - lastValues << newValMap - } - - lianjiaCountMap.each {k,v-> - println "[链家] "+k+" "+v - } - - wiwjCountMap.each {k,v-> - println "[我爱我家] "+k+" "+v - } - - anjukeCountMap.each {k,v-> - println "[安居客] "+k+" "+v - } - return lastValues - } +// def margeValue(lianjiaMap, wiwjMap, anjukeMap){ +// def lianjisIds = lianjiaMap.keySet() +// def wiwjIds = wiwjMap.keySet() +// def anjukeIds = anjukeMap.keySet() +// def set = new HashSet() +// set.addAll(lianjisIds) +// set.addAll(wiwjIds) +// set.addAll(anjukeIds) +// +// def lastValues = [] +// def lianjiaUpdateCount = 0 +// def wiwjUpdateCount = 0 +// def anjukeUpdateCount = 0 +// def lianjiaCountMap = [:] +// def wiwjCountMap = [:] +// def anjukeCountMap = [:] +// set.each {id-> +// BasicDBObject newValMap = new BasicDBObject() +// fields.each {field-> +// def lianjiaValMap = lianjiaMap.get(id) +// def wiwjValMap = wiwjMap.get(id) +// def anjukeValMap = anjukeMap.get(id) +// if(lianjiaValMap && lianjiaValMap.containsKey(field)){ +// newValMap.put(field, lianjiaValMap.get(field)) +// lianjiaUpdateCount++ +// def count = lianjiaCountMap.get(field) +// if(!count){ +// lianjiaCountMap.put(field, 1) +// }else{ +// lianjiaCountMap.put(field, count + 1) +// } +// }else if(wiwjValMap && wiwjValMap.containsKey(field)){ +// newValMap.put(field, wiwjValMap.get(field)) +// wiwjUpdateCount++ +// def count = wiwjCountMap.get(field) +// if(!count){ +// wiwjCountMap.put(field, 1) +// }else{ +// wiwjCountMap.put(field, count + 1) +// } +// }else if(anjukeValMap && anjukeValMap.containsKey(field)){ +// newValMap.put(field, anjukeValMap.get(field)) +// anjukeUpdateCount++ +// def count = anjukeCountMap.get(field) +// if(!count){ +// anjukeCountMap.put(field, 1) +// }else{ +// anjukeCountMap.put(field, count + 1) +// } +// } +// } +// newValMap.put("id", id) +// lastValues << newValMap +// } +// +// lianjiaCountMap.each {k,v-> +// println "[链家] "+k+" "+v +// } +// +// wiwjCountMap.each {k,v-> +// println "[我爱我家] "+k+" "+v +// } +// +// anjukeCountMap.each {k,v-> +// println "[安居客] "+k+" "+v +// } +// return lastValues +// } def updateDB(margeResults){ for(def mr : margeResults){ @@ -179,57 +180,57 @@ class UpdateDistrictField extends BaseBatch{ } } - def batchUpdateDist(source){ -// def rets = findThirdMatchDist(source) - println "[${source}] 符保条件小区量:"+rets.size() - def updateIndex = new AtomicLong() - final CountDownLatch latch = new CountDownLatch(rets.size()) - def allUpdateList = new CopyOnWriteArrayList() - - def sourceMap = new ConcurrentHashMap() - - for(def i=0;i - def count = countMap.get(k) - if(!count){ - countMap.put(k, 1) - }else{ - countMap.put(k, count+1) - } - } - } - - countMap.each {k,v-> - println k +" 更新量:"+v - } - - println "---------------------------------------------------------" - return sourceMap - } +// def batchUpdateDist(source){ +//// def rets = findThirdMatchDist(source) +// println "[${source}] 符保条件小区量:"+rets.size() +// def updateIndex = new AtomicLong() +// final CountDownLatch latch = new CountDownLatch(rets.size()) +// def allUpdateList = new CopyOnWriteArrayList() +// +// def sourceMap = new ConcurrentHashMap() +// +// for(def i=0;i +// def count = countMap.get(k) +// if(!count){ +// countMap.put(k, 1) +// }else{ +// countMap.put(k, count+1) +// } +// } +// } +// +// countMap.each {k,v-> +// println k +" 更新量:"+v +// } +// +// println "---------------------------------------------------------" +// return sourceMap +// } def running(url, old_match_id){ def esObj = findCommunities(url) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy index 60824f8d5..4c710cb47 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy @@ -38,7 +38,7 @@ class AddDistImagesBatch extends BaseBatch{ @Override public void process(Object args) { - def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyy-MM-dd") + def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) // def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) def citys = CommonUtils.findAllCity() citys.each {city-> @@ -48,7 +48,7 @@ class AddDistImagesBatch extends BaseBatch{ matchCommunitys(communitys) } -// statImgCount() + statImgCount() } def findAllEsData2(city, mdate){ QueryBuilder date_range = QueryBuilders.rangeQuery("m_date").from(mdate.getTime()).includeLower(true) @@ -105,40 +105,47 @@ class AddDistImagesBatch extends BaseBatch{ def total = communitys.size() for(def i=0;i Date: Mon, 10 Feb 2025 14:57:57 +0800 Subject: [PATCH 130/247] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=A0=E5=9C=B0=E5=9D=80=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/DistrictController.java | 10 +++++++++- .../java/com/fangjia/service/api/AutoCompleteBo.java | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index 442e4b77a..17ab2c4b2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -146,12 +146,20 @@ public class DistrictController { if (!district.getName().contains(keyword)) { if (district.getAlias() != null && !district.getAlias().isEmpty()) { for (String alias : district.getAlias()) { - if (alias.contains(keyword)){ + if (alias.contains(keyword)) { bo.setAlias(alias); break; } } } + if (district.getAddrAlias() != null && !district.getAddrAlias().isEmpty()) { + for (String addrAlias : district.getAddrAlias()) { + if (addrAlias.contains(keyword)) { + bo.setAddrAlias(addrAlias); + break; + } + } + } } ret.add(bo); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 9e714a4bb..d21cfa34c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -24,6 +24,8 @@ public class AutoCompleteBo { private String alias; + private String addrAlias; + /*** @Deprecated end ****/ public String getName() { @@ -145,4 +147,12 @@ public class AutoCompleteBo { public void setAlias(String alias) { this.alias = alias; } + + public String getAddrAlias() { + return addrAlias; + } + + public void setAddrAlias(String addrAlias) { + this.addrAlias = addrAlias; + } } From 29a456e9453ef59845005215aebc8a05f1cba9db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 10 Feb 2025 16:23:27 +0800 Subject: [PATCH 131/247] =?UTF-8?q?=E5=9D=87=E4=BB=B7=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coresite/controllers/EvaluationController.java | 6 ++++-- .../fangjia/service/datastore/EvaluationServiceImpl.java | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java index be342ece4..30a73fa2f 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java @@ -3665,12 +3665,14 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt SimpleDateFormat format = new SimpleDateFormat("yyyy.MM"); for (Date key : districtStatMap.keySet()) { DistrictStat ds = districtStatMap.get(key); - districtMap.put(format.format(ds.getWeekend()),ds.getAvgPrice()); + Integer avgPrice = ds.getAvg_price_2b() != null ? ds.getAvg_price_2b() : ds.getAvgPrice(); + districtMap.put(format.format(ds.getWeekend()), avgPrice); } for (Date key : villaDistrictStatMap.keySet()) { DistrictStat ds = villaDistrictStatMap.get(key); - districtMap.put(format.format(ds.getWeekend()),ds.getAvgPrice()); + Integer avgPrice = ds.getAvg_price_2b() != null ? ds.getAvg_price_2b() : ds.getAvgPrice(); + districtMap.put(format.format(ds.getWeekend()), avgPrice); } } 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 070094dc1..0146770f1 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 @@ -1,5 +1,6 @@ package com.fangjia.service.datastore; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -338,7 +339,10 @@ public class EvaluationServiceImpl implements EvaluationService { if(useAvgMode) { DistrictStatBo districtStatBo = districtStatService.findDistrictStat(districtKey); if (districtStatBo != null && districtStatBo.getDefaultDistrictStat() != null && districtStatBo.getDefaultDistrictStat().getAvgPrice() > 0) { - long totalPrice = evaluationRateService.evaluation(districtStatBo.getDefaultDistrictStat().getAvgPrice(), evaluation); + Double avgPrice = (double) (districtStatBo.getDefaultDistrictStat().getAvg_price_2b() != null ? districtStatBo.getDefaultDistrictStat().getAvg_price_2b() : districtStatBo.getDefaultDistrictStat().getAvgPrice()); + // 均价乘以系数 + avgPrice *= 1.04; + long totalPrice = evaluationRateService.evaluation(BigDecimal.valueOf(avgPrice).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(), evaluation); avgModeValue = ((Number) (totalPrice)).intValue(); avgModeCredit = districtStatBo.getDefaultDistrictStat().getCredit(); } @@ -1898,7 +1902,8 @@ public class EvaluationServiceImpl implements EvaluationService { private void buildWeekAvgPrice(EvaluationBeforeLoanBean dto, Evaluation evaluation) { DistrictStatBo bo = getNearestDistrictStat(new DistrictKey(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName())); if (bo != null) { - dto.setWeekAvgPrice(bo.getDistrictStat().getAvgPrice()); + Integer avgPrice = bo.getDistrictStat().getAvg_price_2b() != null ? bo.getDistrictStat().getAvg_price_2b() : bo.getDistrictStat().getAvgPrice(); + dto.setWeekAvgPrice(avgPrice); dto.setTopWeekUpDownRange(bo.getDistrictStat().getWeekendMarkup()); } } From 0cd2aa435361a595c15705b48bd4b17ce5a295a1 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 11 Feb 2025 10:45:23 +0800 Subject: [PATCH 132/247] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 1088d4648..40afe3fe6 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -228,7 +228,7 @@ public class ComprehensiveQueryController { String cityStr = model.getCity(); if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) { AdministrativeDivision administrativeDivision = administrativeDivisionService.findcityByCode(cityStr); - if(administrativeDivision == null){ + if (administrativeDivision == null) { mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); return mav; } @@ -289,11 +289,11 @@ public class ComprehensiveQueryController { // return mav; // } JSONObject result = matchResponse.getJSONObject("result"); - if(!result.containsKey("id")){ + if (!result.containsKey("id")) { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); return mav; } - String id = matchResponse.getJSONObject("result") .getString("id"); + String id = matchResponse.getJSONObject("result").getString("id"); District district = districtService.findById(id); if (district == null) { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); @@ -419,9 +419,11 @@ public class ComprehensiveQueryController { if (facilitys != null) { List hospitalList = facilitys.getHospital(); List hospitals = new ArrayList(); - for (String hospital : hospitalList) { - if (hospital.endsWith("医院")) { - hospitals.add(hospital); + if (hospitalList != null && !hospitalList.isEmpty()) { + for (String hospital : hospitalList) { + if (hospital.endsWith("医院")) { + hospitals.add(hospital); + } } } facilitys.setHospital(hospitals); @@ -753,7 +755,7 @@ public class ComprehensiveQueryController { districtPriceMap.put("name", district.getName()); // 估值中已经取过评估2B价格,且经过系数调整,不能在覆盖 districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - Long totalPrice = new BigDecimal((Integer)districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); + Long totalPrice = new BigDecimal((Integer) districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); districtPriceMap.put("totalPrice", totalPrice); if (model.getScope() == EVALUATE_SHOW_DETAIL) { From cf3fbdcc803a89373b19b67d301ce5fca3756be7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 11 Feb 2025 16:12:02 +0800 Subject: [PATCH 133/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 22 ++ .../data_handle/BusinessQuarterProcess.groovy | 268 ++++++++++++++++++ .../gj/district/DistrictFieldAddBatch.groovy | 103 ++++++- .../gj/images/AddDistImagesBatch.groovy | 6 +- 4 files changed, 382 insertions(+), 17 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.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 94a3445f5..82cffedbd 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 @@ -103,6 +103,8 @@ class CommonDatautils { public static final DBCollection STATS_INDEX_COLL = MongoUtils.getCollectionByName("fangjia_stat", "stats_index", "mongo.db.fangjia.com") + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + public static DSCollection getHouseDataStoreConnection(){ if(house_dataStoreConnection != null) { return house_dataStoreConnection @@ -4967,6 +4969,20 @@ class CommonDatautils { return regionMap } + static def queryRangeByCat(cat){ + def q = new BasicDBObject() + q.put("type",cat) + q.put("shape",new BasicDBObject('$exists', true)) + def keys = new BasicDBObject() + keys.put("city_short",1) + keys.put("district_short",1) + keys.put("city",1) + keys.put("district",1) + keys.put("mzb_district_name", 1) + keys.put("shape", 1) + return ADMINISTRATIVE_MAPPING_COLL.find(q,keys).toList() + } + static def queryAllRegionNameByCity(){ @@ -5522,4 +5538,10 @@ class CommonDatautils { return 0 } + static def findBusinessByCity(city){ + def q = new BasicDBObject() + q.put("short_city", city) + return bk_business_coll.find(q).toList() + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy new file mode 100644 index 000000000..f122be3c0 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy @@ -0,0 +1,268 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.lixue.util.DBUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +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.action.update.UpdateRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +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 BusinessQuarterProcess { + + def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() + def fullCityMap = CommonDatautils.queryFullNameCity() + DBCollection bk_map_bussiness_COLL = MongoUtils.getCollectionByName("crawl", "bk_map_sq", "192.168.0.206",27020) + + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + def task = new BusinessQuarterProcess() + task.run() + } + def run(){ +// synchBusinessData() +// updateBusinessQuarter() +// addRegion() + synchBusinessToEs() + } + + def addRegion(){ + def list = CommonDatautils.queryRangeByCat("区域") + println list.size() + def dbcursor = bk_business_coll.find(new BasicDBObject("_id", new ObjectId("67a318893b75f388c80979f2"))) + for(def d : dbcursor){ + if(d.district){ + continue + } + for(def regionShape : list){ + if(d.short_city!=regionShape.city_short){ + continue + } + def flag = InsidePolygon.isInArea(d.location.lon, d.location.lat, InsidePolygon.createPoint4(regionShape.shape.coordinates)) + if(flag){ + def udata = new BasicDBObject() + udata.put("district", regionShape.mzb_district_name) + udata.put("short_district", regionShape.district_short) + bk_business_coll.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + break + } + } + } + } + + def synchBusinessData(){ + def datas = bk_map_bussiness_COLL.find(new BasicDBObject("type", null)).toList() + synchMongoProcess(datas) + + } + + def synchMongoProcess(datas){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(datas.size()) + for(def i=0;i=100){ +// updateByEs(rows) +// rows.clear() +// } + updateByEs(d, index) + } + } + + def updateByEs(row, index){ + BulkRequest request = new BulkRequest(); + def client = ElasticUtils89.getClient("192.168.0.89") + int processedCount = 0; + + def id = row.get("_id").toString() + def doc = [:] + doc.put("province",row.province) + doc.put("short_province",row.short_province) + doc.put("city",row.city) + doc.put("short_city",row.short_city) + doc.put("district",row.district) + doc.put("short_district",row.short_district) + doc.put("name", row.name) + doc.put("location", row.location) + doc.put("bd_location", row.bd_location) + doc.put("shape", row.shape) + doc.put("bd_shape", row.bd_shape) + + + request.add(new IndexRequest("bk_business", "_doc", id).source(doc, XContentType.JSON)); + if (request.numberOfActions() >= 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + println "[${index}] Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); +// println "Processed " + processedCount + " documents" + } + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index e2625366c..83f747d21 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -18,6 +18,8 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.text.SimpleDateFormat import java.util.concurrent.CopyOnWriteArrayList @@ -39,7 +41,7 @@ class DistrictFieldAddBatch extends BaseBatch{ //"安居客":"安居客小程序","链家":"链家","幸福里":"幸福里","城市房产":"城市房产小程序","搜房":"搜房" // - def sourceMap = ["幸福里":"幸福里APP","城市房产":"城市房产小程序","安居客小程序":"安居客小程序","安居客移动端":"安居客移动端","贝壳找房":"贝壳找房","安居客-新房":"安居客-新房","安居客":"安居客","链家":"链家","贝壳找房-新房":"贝壳找房-新房","楼盘网-新房":"楼盘网-新房","禧泰":"中国房价行情","链家":"链家","搜房":"搜房","我爱我家":"我爱我家","诸葛找房":"诸葛找房APP","贝壳找房":"贝壳找房", + def sourceMap = ["贝壳找房":"贝壳找房","链家":"链家","贝壳找房-新房":"贝壳找房-新房","安居客":"安居客","幸福里":"幸福里","安居客小程序":"安居客小程序","城市房产":"城市房产小程序","安居客移动端":"安居客移动端","安居客-新房":"安居客-新房","楼盘网-新房":"楼盘网-新房","禧泰":"中国房价行情", "城市房产":"城市房产","搜房":"搜房","我爱我家":"我爱我家","诸葛找房":"诸葛找房", "乐有家":"乐有家","吉屋":"吉屋","C21":"C21","365淘房":"365淘房"] //key:穆融合表的来源 valve:es解析表的来源 @@ -61,6 +63,7 @@ class DistrictFieldAddBatch extends BaseBatch{ "car_site_count":"车位","car_site":"车位描述","property_life":"产权年限","address":"地址","build_structure":"建筑结构", "build_type":"建筑类型", "land_property":"权属类别","live_date":"入住时间","loop_line_info":"环线"] + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) final static def EMAILS = [ "gaojuan@fangjia.com" @@ -115,18 +118,12 @@ class DistrictFieldAddBatch extends BaseBatch{ headers << fieldsNameMap.get(it) } - headers << "抓取量" - headers << "匹配量" - headers << "0.9分以上量" - headers << "匹配率" - headers << "0.9以上匹配率" -// analysRets << headers - for(def c : citys){ def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 - analysRets = addFieldFromMatch(c, totalCount, analysRets)//匹配 +// analysRets = addFieldFromMatch(c, totalCount, analysRets)//匹配 + analysRets = addFieldFromMatchMapping(c, totalCount, analysRets)//新旧匹配中间表 } } println analysRets.toString() @@ -139,8 +136,10 @@ class DistrictFieldAddBatch extends BaseBatch{ sourceMap.each { seaweedmapSource, esWebSource -> def esRets = findEsDatas(c, esWebSource) + def matchRets1 = matchApi(esRets) def matchRets2 = selectRestByCredit(matchRets1) + println esWebSource +" 抓取量:"+esRets.size()+" 匹配量:"+matchRets1.size()+" 0.9分以上量:"+matchRets2.size() def updateRets = processFieldsFromMatch(c , matchRets2, esWebSource) @@ -172,6 +171,65 @@ class DistrictFieldAddBatch extends BaseBatch{ } + def addFieldFromMatchMapping(c, totalCount, analysRets){ + def fields = fieldsMap.keySet() as List + + sourceMap.each { seaweedmapSource, esWebSource -> + def esRets = findMatchSameDatas(c, esWebSource) + println esWebSource +" 新老算法匹配相同量:"+esRets.size() + + def updateRets = processFieldsFromMatch(c , esRets, esWebSource) + + def precentMap = fieldUpdate(totalCount, updateRets) + println c +" "+precentMap.toString() + updateDB(c, updateRets) + println "------------------------------------------------------------------------------" + + def analyRet = [] + analyRet << seaweedmapSource + analyRet << c + fields.each{key-> + analyRet << precentMap.get(key) + } + analyRet << esRets.size() + analysRets << analyRet + } + return analysRets; + + } + + + def findMatchSameDatas(c, esWebSource){ + def query = new BasicDBObject("city", c).append("source", esWebSource).append("match_id", new BasicDBObject('$exists', true)).append("old_match_id", new BasicDBObject('$exists',true)) + def siteDatas = thirdSeaweedMappingColl.find(query).toList() + def rows = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(siteDatas.size()) + for(def i=0;i Date: Wed, 12 Feb 2025 17:20:16 +0800 Subject: [PATCH 134/247] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=88=AB=E5=90=8D?= =?UTF-8?q?=E8=B7=91=E4=B9=9D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy new file mode 100644 index 000000000..1cf20acc9 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -0,0 +1,86 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.ccb.FileUtils +import com.fangjia.script.util.ExcelUtils + +class AddrAlaisProcess { + + static main(args) { + def task = new AddrAlaisProcess() +// task.run() + task.nineApi() + } + + def nineApi(){ + def fileName = "/home/goojia/gj/district/addr_alias.xlsx" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化-测试.xlsx" + } + + ExcelUtils.multiThreadingModify(fileName, {d-> + def addrMap = nineAddrSplit(d['B'], d['E']) + def addrList = [] + if(addrMap && addrMap.address){ + d['G'] = addrMap.city + d['H'] = addrMap.address + addrList << addrMap.address + } + if(d['F']){ + def addrs = d['F'].split(",") + def addr_alias = [] + for(def addr : addrs){ + def map = nineAddrSplit(d['B'], addr) + if(map && map.address && DataHandleUtils.isStandardRoad(map.address)){ + if(!addrList.contains(map.address)){ + addrList << map.address + addr_alias << map.address + } + } + } + d['I'] = addr_alias.join(",") + } + }) + + } + + def nineAddrSplit(city, addr){ + def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(city, addr) + def address = "" + def map = [:] + if (jsonObject) { + map.province = jsonObject.get("province") + map.city = jsonObject.get("city") + map.district = jsonObject.get("district") + if (jsonObject.get("street") && jsonObject.get("street") != "null") { + address = jsonObject.get("street") + } + if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { + address = address + jsonObject.get("streetNumber") + } + map.address = address + } + return map + } + + def run(){ + def citys = CommonDatautils.findAllCity() + def rows = [] + citys.each{c-> + def districts = CommonDatautils.findAllDistricts(c, "district", ["city","region", "name","address", "addr_alias"]) + println c +" "+districts.size() + def num = 0 + for(def d : districts){ + num++ + def row = [num, d.city, d.region, d.name, d.address] + if(d.addr_alias){ + row << d.addr_alias.join(",") + } + rows << row + } + } +// ExcelUtils.write("D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.xlsx", rows, "小区") + FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.bat", null, "utf-8", false, "#",""); + } +} From 683de63a610ed659d6a21da6eacf6a1465317e1b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 12 Feb 2025 18:09:51 +0800 Subject: [PATCH 135/247] update --- .../gj/district/DistrictFieldAddBatch.groovy | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 83f747d21..5610ae238 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -119,6 +119,7 @@ class DistrictFieldAddBatch extends BaseBatch{ } for(def c : citys){ + def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 @@ -397,12 +398,16 @@ class DistrictFieldAddBatch extends BaseBatch{ newValues.put(seaweedfield, newVal) } if(seaweedfield == "lng"){ - def locationMap = FiledStrand.processLngAndLat(esVal) - if(locationMap){ - newValues.put("lat", locationMap.lat) - newValues.put("lng", locationMap.lng) - newValues.put("lat2", locationMap.lat2) - newValues.put("lng2", locationMap.lng2) + try{ + def locationMap = FiledStrand.processLngAndLat(esVal) + if(locationMap){ + newValues.put("lat", locationMap.lat) + newValues.put("lng", locationMap.lng) + newValues.put("lat2", locationMap.lat2) + newValues.put("lng2", locationMap.lng2) + } + }catch(Exception e){ + println esVal } } } From 8447b62637072b6cfc12f264b333747583cfe484 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 13 Feb 2025 09:47:30 +0800 Subject: [PATCH 136/247] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy index 1cf20acc9..62d1f299e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -50,9 +50,21 @@ class AddrAlaisProcess { def address = "" def map = [:] if (jsonObject) { - map.province = jsonObject.get("province") - map.city = jsonObject.get("city") - map.district = jsonObject.get("district") + if (jsonObject.get("province") && jsonObject.get("province") != "null") { + map.province = jsonObject.get("province") + }else{ + map.province = "" + } + if (jsonObject.get("city") && jsonObject.get("city") != "null") { + map.city = jsonObject.get("city") + }else{ + map.city = "" + } + if (jsonObject.get("district") && jsonObject.get("district") != "null") { + map.district = jsonObject.get("district") + }else{ + map.district = "" + } if (jsonObject.get("street") && jsonObject.get("street") != "null") { address = jsonObject.get("street") } From dc2a8d3fc32971c444a537fe97d0a85ec8bdafc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 13 Feb 2025 10:18:33 +0800 Subject: [PATCH 137/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/OfficeServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index e249b8eac..3c4cdac72 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -78,8 +78,13 @@ public class OfficeServiceImpl implements OfficeService { } if (seawaters.size() > 0) { unitPrice = this.calcRent(seawaters, evaluation); - } else if (StringUtils.isNotBlank(evaluation.getLocation())) { - unitPrice = rentEvaluateByLocation(evaluation); + } else { + if (StringUtils.isNotBlank(evaluation.getLocation())) { + unitPrice = rentEvaluateByLocation(evaluation); + } else if (district != null && district.getLat() != null) { + evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); + unitPrice = rentEvaluateByLocation(evaluation); + } } // 评估逻辑 evaluation.setUnitPrice(unitPrice); @@ -290,6 +295,11 @@ public class OfficeServiceImpl implements OfficeService { query.setEndArea(null); seawaters = seawaterService.findSeawatersByQuery(query); } + // 如果还查不到,取周边三公里,如上海青浦凤新大楼,太偏了 + if (CollectionUtils.isEmpty(seawaters)) { + query.setRadius(3000); + seawaters = seawaterService.findSeawatersByQuery(query); + } if (CollectionUtils.isNotEmpty(seawaters)) { return calcRent(seawaters, evaluation); } From 493e4c343306706bb055ed9483cf6a9dc7923d63 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 14 Feb 2025 17:56:48 +0800 Subject: [PATCH 138/247] update --- .../fangjia/script/gj/district/DistrictFieldAddBatch.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 5610ae238..8507f7d00 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -119,7 +119,7 @@ class DistrictFieldAddBatch extends BaseBatch{ } for(def c : citys){ - + def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 @@ -330,7 +330,9 @@ class DistrictFieldAddBatch extends BaseBatch{ def newVal = null if(seaweedfield == "estate_charge"){ newVal = FiledStrand.processEstateCharge(c, FiledStrand.getNumber(esVal), dist.estate_type2) - newVal = newVal.toString() + if(newVal) { + newVal = newVal.toString() + } } if(seaweedfield == "build_date" || seaweedfield == "live_date"){ newVal = FiledStrand.processFinishBuildingDate(esVal) From 07f1b9a868056a7f53b8930276ee24c99d17671f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 19 Feb 2025 11:15:36 +0800 Subject: [PATCH 139/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC=E6=A0=B7=E6=9C=AC=E5=87=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 11 +++- .../service/datastore/OfficeService.java | 5 +- .../service/datastore/OfficeServiceImpl.java | 39 ++++++++------ .../datastore/dto/OfficeEvaluationDto.java | 52 +++++++++++++++++++ .../service/datastore/dto/OfficeRentDto.java | 32 ++++++++++++ 5 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index c5d5b9f95..d60ec8ae1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -22,6 +22,7 @@ import com.fangjia.service.api.AddressMatchProxyService; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.OfficeService; import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ArrayUtils; @@ -209,11 +210,16 @@ public class OfficeController { } } - Evaluation evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); + OfficeEvaluationDto evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { Map districtPriceMap = new HashMap(); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getRegion()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { @@ -299,7 +305,7 @@ public class OfficeController { model.setRegion(district.getRegion()); model.setDistrictName(district.getName()); - Evaluation evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); + OfficeEvaluationDto evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { Map districtPriceMap = new HashMap(); @@ -307,6 +313,7 @@ public class OfficeController { districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index a3276a571..96ced5b18 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -3,6 +3,7 @@ package com.fangjia.service.datastore; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import java.util.List; @@ -31,7 +32,7 @@ public interface OfficeService { * @param evaluation * @return */ - Evaluation evaluateRent(District district, Evaluation evaluation); + OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation); /** * 租金地址维度评估 @@ -39,5 +40,5 @@ public interface OfficeService { * @param evaluation * @return */ - Evaluation addressEvaluateRent(Evaluation evaluation); + OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 3c4cdac72..393456e10 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -11,6 +11,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.dto.GaodeDto; @@ -35,7 +36,7 @@ public class OfficeServiceImpl implements OfficeService { @Override - public Evaluation evaluateRent(District district, Evaluation evaluation) { + public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { evaluation.setFloor(null); evaluation.setHeight(null); @@ -76,19 +77,19 @@ public class OfficeServiceImpl implements OfficeService { query.setEndArea(null); seawaters = seawaterService.findSeawatersByQuery(query); } + OfficeEvaluationDto officeEvaluationDto = null; if (seawaters.size() > 0) { - unitPrice = this.calcRent(seawaters, evaluation); + officeEvaluationDto = this.calcRent(seawaters, evaluation); } else { if (StringUtils.isNotBlank(evaluation.getLocation())) { - unitPrice = rentEvaluateByLocation(evaluation); + officeEvaluationDto = rentEvaluateByLocation(evaluation); } else if (district != null && district.getLat() != null) { evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); - unitPrice = rentEvaluateByLocation(evaluation); + officeEvaluationDto = rentEvaluateByLocation(evaluation); } } - // 评估逻辑 - evaluation.setUnitPrice(unitPrice); - return evaluation; + + return officeEvaluationDto; } // 所在楼层 @@ -116,7 +117,7 @@ public class OfficeServiceImpl implements OfficeService { put(4, "综合体"); } }; - public Double calcRent(List seawaters, Evaluation evaluation) { + public OfficeEvaluationDto calcRent(List seawaters, Evaluation evaluation) { // 计算平均值 Double sum = 0.0; Double size = 0.0; @@ -242,14 +243,20 @@ public class OfficeServiceImpl implements OfficeService { size += seawater.getArea(); } } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (size > 0) { unitPrice = DataUtil.roundDouble(sum / size / 30 * factor, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); } - return unitPrice ; + return officeEvaluationDto; } @Override - public Evaluation addressEvaluateRent(Evaluation evaluation) { + public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { evaluation.setFloor(null); evaluation.setHeight(null); @@ -257,12 +264,12 @@ public class OfficeServiceImpl implements OfficeService { // 评估逻辑 String location = getLocation(evaluation.getCity(), evaluation.getAddress()); evaluation.setLocation(location); - Double unitPrice = rentEvaluateByLocation(evaluation); - evaluation.setUnitPrice(unitPrice); - return evaluation; + OfficeEvaluationDto officeEvaluationDto = rentEvaluateByLocation(evaluation); + + return officeEvaluationDto; } - private Double rentEvaluateByLocation(Evaluation evaluation) { + private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { if (StringUtils.isNotBlank(evaluation.getLocation())) { Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); @@ -300,8 +307,10 @@ public class OfficeServiceImpl implements OfficeService { query.setRadius(3000); seawaters = seawaterService.findSeawatersByQuery(query); } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (CollectionUtils.isNotEmpty(seawaters)) { - return calcRent(seawaters, evaluation); + officeEvaluationDto = calcRent(seawaters, evaluation); + return officeEvaluationDto; } } return null; diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java new file mode 100644 index 000000000..b445eb392 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -0,0 +1,52 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + private String name; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java new file mode 100644 index 000000000..262858055 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +} From 0ce3d99d2580a549758d7c90a80a3881d55900c6 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 19 Feb 2025 17:12:26 +0800 Subject: [PATCH 140/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=AB=98=E5=BE=B7=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/PropertyController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 47e091d9f..5ff3daea4 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 @@ -765,8 +765,13 @@ public class PropertyController { 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.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); } } From 26591c2d22510572f37c9eca73271aa66b5b3c30 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 11:44:45 +0800 Subject: [PATCH 141/247] =?UTF-8?q?=E8=B7=91=E9=AB=98=E5=BE=B7=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/TownStandardBatch.groovy | 246 ++++++++++++++---- .../fangjia/script/util/BaiduMapUtils.groovy | 42 ++- .../yinjihaun/amap/GaoDeApiUtils.groovy | 5 +- 3 files changed, 230 insertions(+), 63 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 41588517e..3fd7084d4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -4,11 +4,16 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.BaiduMapUtils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils 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.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType @@ -31,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100) def updateList = [] def addAliasList = [] @@ -49,7 +54,8 @@ class TownStandardBatch extends BaseBatch{ def TownStandard(){ // townStandardByCat("office") // townStandardByPoi() - addTownByTownShape() + addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 +// updateTownData() } def townStandardByCat(def cat){ //"三明","龙岩","南平","漳州","福州","厦门","泉州","莆田","宁德", @@ -385,11 +391,41 @@ class TownStandardBatch extends BaseBatch{ return rets; } + def readCSV3(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + if(arrs.size()>=10 && arrs[7] && arrs[9]=="同区域"){ + def o = new BasicDBObject() + try{ + o.put("id", arrs[0]) + o.put("township", arrs[7]) + if(arrs.size()>=9 && arrs[8]){ + o.put("district", arrs[8]) + } + if(arrs.size()>=10 && arrs[9]){ + o.put("way", arrs[9]) + } + rets << o + }catch(Exception e){ + println arrs + } + } + + } + index++ + } + return rets; + } + def addTownByTownShape(){ def i = 0 - def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式"] + def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式", "标准乡镇"] while(i<50){ - def fileName = "/home/goojia/gj/new_poi/input/no_township_${i}.csv" + def fileName = "/home/goojia/gj/new_poi/input/map/no_township_${i}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\原始\\no_township_${i}.csv" } @@ -398,7 +434,7 @@ class TownStandardBatch extends BaseBatch{ def rets = readCSV2(fileName) def rows = addTownshipBatch(rets) if (CommonDatautils.isWindow()) { - com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); }else{ com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); } @@ -425,10 +461,10 @@ class TownStandardBatch extends BaseBatch{ def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() - if (set.size() >= 1) { +// if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) - results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source] - } + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] +// } } } catch (Exception e) { e.printStackTrace() @@ -444,52 +480,87 @@ class TownStandardBatch extends BaseBatch{ def addTown(saveObj, townMap, location) { //在poi本区域下通过乡镇街道围栏选出所在乡镇街道 - def towns = townMap.get(saveObj.district) - if (towns) { - for (def town : towns) { - if (town.shape && town.shape.coordinates) { - def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) - if (flag) { - saveObj.township = town.street - saveObj.town_source = "同区域" - break - } - } - } - } +// def towns = townMap.get(saveObj.district) +// if (towns) { +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.town_source = "同区域" +// saveObj.strand_town = "是" +// break +// } +// } +// } +// } //忽略poi中的区域 通过乡镇街道围栏选出所在乡镇街道 +// if(!saveObj.township){ +// def townNames = townMap.keySet() +// for(def townName : townNames){ +// towns = townMap.get(townName) +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.new_district = town.mzb_district_name +// saveObj.town_source = "忽略区域" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// break +// } +// } +// } +// if(saveObj.township){ +// break; +// } +// } +// } + //通过调取地图api接口获取乡镇街道 if(!saveObj.township){ - def townNames = townMap.keySet() - for(def townName : townNames){ - towns = townMap.get(townName) - for (def town : towns) { - if (town.shape && town.shape.coordinates) { - def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) - if (flag) { - saveObj.township = town.street - saveObj.new_district = town.mzb_district_name - saveObj.town_source = "忽略区域" - break - } - } - } - if(saveObj.township){ - break; + def gaodeMap = getTownshipInfo(location.lon+","+location.lat) + if(gaodeMap && gaodeMap.township){ + saveObj.township = gaodeMap.township + saveObj.new_district = gaodeMap.district + saveObj.town_source = "高德API" + if(townMap.size()>=1){ + saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) } } } - //通过调取地图api接口获取乡镇街道 + +// //通过调取地图api接口获取乡镇街道 // if(!saveObj.township){ -// def gaodeMap = getTownshipInfo(location.lon+","+location.lat) -// if(gaodeMap && gaodeMap.township){ -// saveObj.township = gaodeMap.township -// saveObj.new_district = gaodeMap.district -// saveObj.town_source = "高德API" +// def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) +// if(gaodeMap && gaodeMap.addressComponent) { +// def addressComponent = gaodeMap.addressComponent +// if(addressComponent){ +// if(addressComponent.town){ +// saveObj.township = addressComponent.town +// saveObj.new_district = addressComponent.district +// saveObj.town_source = "百度API" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } +// } // } // } return saveObj } + def isStandTown(townMap, district, town){ + def towns = townMap.get(district) + def flag = "非" + if(towns){ + for(def t : towns){ + if(t.street == town){ + flag = "是" + break + } + } + } + return flag + } + def getTownshipInfo(def glocation){ def township = null @@ -498,9 +569,11 @@ class TownStandardBatch extends BaseBatch{ def format_addr = null def stop = false def count = 0 - while(!stop){ + def jsonObject = null +// while(!stop){ if(glocation){ - def jsonObject = GaoDeApiUtils.geocode(glocation) + jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { def addressComponent = jsonObject.regeocode.addressComponent if(addressComponent){ @@ -512,14 +585,15 @@ class TownStandardBatch extends BaseBatch{ } } } - if(district || count>10){ - stop = true - }else{ - count ++ - Thread.sleep(3000) - print "." - } - } +// if(jsonObject.status==0 || count>3){ +// stop = true +// println "高德调用超3次" +// }else{ +// count ++ +// Thread.sleep(3000) +// print "." +// } +// } def map = [:] map.city = city @@ -529,6 +603,72 @@ class TownStandardBatch extends BaseBatch{ return map; } + def updateTownData(){ + def i = 0 + while(i<50) { + def fileName = "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv" + } + File file = new File(fileName); + if (file.exists()) { + def rets = readCSV3(fileName) + println file.getAbsoluteFile().getName() +" "+(rets.size()*100/200000)+"%"+" "+rets.size() +// if(rets){ +// updateToEs(rets) +// } + } + i++ + } + } + + + def updateToEs(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 1; + int processedCount = 0; + def client = ElasticUtils.getClient89("192.168.0.89") + for (int i = 0; i < rows.size(); i++) { + def map = rows[i] + if(map.containsKey("way")){ + map.remove("way") + } + request.add(new IndexRequest("map_poi_2024", "_doc", map.id).source(map, XContentType.JSON)); + if(i%1000==0){ + print "." + } + + // 批量提交数据 + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + + request = new BulkRequest(); + } + + } + + 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" + } + } + + println "结束时间 "+new Date() + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy index cb84af2c7..9a4003b7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy @@ -9,13 +9,8 @@ import net.sf.json.JSONObject class BaiduMapUtils { - private static String AK = "9E99D3540e4dafb7894f7b9fe27fa6b5"; - def static AKS = ["hj5KqPjaGA3uivtg8uS8XfAnj9X1kPMr","xjFg7DfDqvQleIZasM3ph8Zi2Lw8kgCg", - "4pb6fzrWIzvibDu8L1o8DGoY2h1wRIUq","ZzX6mRFfE5GKn4cpUp24Q3OyUIHnfQAR","79ac4ea49e7dedbf80b0ecd475d07784", - "9E99D3540e4dafb7894f7b9fe27fa6b5","W3M5uHfcrmlAdhQjf6v93LCI", "C8bb035aacf602551e829e4c64575224", - "B42b12d01f2dee712fd66c3e886158a4", "1a3cde429f38434f1811a75e1a90310c","W3M5uHfcrmlAdhQjf6v93LCI", - "C8bb035aacf602551e829e4c64575224", "B42b12d01f2dee712fd66c3e886158a4", - "1a3cde429f38434f1811a75e1a90310c","9E99D3540e4dafb7894f7b9fe27fa6b5"]; + private static String AK = "1a3cde429f38434f1811a75e1a90310c"; + def static AKS = ["1a3cde429f38434f1811a75e1a90310c","1a3cde429f38434f1811a75e1a90310c"]; public static boolean HAS_AVAILABLE_AK = true; static def getAddress(lng, lat) throws Exception{ @@ -83,8 +78,8 @@ class BaiduMapUtils { throw new RuntimeException("无可用百度AK"); } System.out.println("更换AK"); - for(int i = 0 ;i < AKS.length; i++){ - if(i == AKS.length - 1){ + for(int i = 0 ;i < AKS.size(); i++){ + if(i == AKS.size() - 1){ AK = AKS[0]; HAS_AVAILABLE_AK = false; throw new RuntimeException("无可用百度AK"); @@ -127,6 +122,35 @@ class BaiduMapUtils { return null } + + public static JSONObject geocoding(locationstr) { + String url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak="+AK+"&output=json&coordtype=gcj02ll&location="+locationstr + boolean stop = false; + int recount = 0; + JSONObject jsonObj = null + while(!stop && recount<6) { + try{ + HttpRequest request = new HttpRequest(); + try{ + String result = request.get(url,null,"UTF-8"); + def json = JSONObject.fromObject(result); + if(json.getInt("status") >= 300){ + changeAK(); + recount++ + }else{ + jsonObj = json.result + } + }catch (Exception e){ + e.printStackTrace(); + } + }catch (Exception e){ + recount++; + println e.getMessage() + } + } + return jsonObj + } + public static def searchByBounds(key, min_lat, min_lng, max_lat, max_lng){ boolean stop = false; int recount = 0; 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 7c41bcc1c..30419ba47 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,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "dfc2245bac8a7b2d5b62e060e59d4eca" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 + def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca /** @@ -35,6 +35,9 @@ class GaoDeApiUtils { content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") } JSONObject jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!=1){ + println jsonObj + } return jsonObj } From 9beb7b3f8163f88fe93d49d034f5e7e26737aa6c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 12:24:31 +0800 Subject: [PATCH 142/247] update --- .../gj/data_handle/TownStandardBatch.groovy | 1 + .../script/looplineinfo/InPolygon.groovy | 132 ++++++++++++++++++ .../script/looplineinfo/InsidePolygon.groovy | 4 + .../yinjihaun/amap/GaoDeApiUtils.groovy | 2 +- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 3fd7084d4..0034cdb20 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -432,6 +432,7 @@ class TownStandardBatch extends BaseBatch{ File file=new File(fileName); if(file.exists()) { def rets = readCSV2(fileName) + println i +" "+ rets.size() def rows = addTownshipBatch(rets) if (CommonDatautils.isWindow()) { com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy new file mode 100644 index 000000000..4d79373ca --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy @@ -0,0 +1,132 @@ +package com.fangjia.script.looplineinfo + +import com.fangjia.script.common.DataHandleUtils + +import java.awt.geom.Point2D; + +class InPolygon { + + + public static List> createPoint(def pointList){ + List> alllist = new ArrayList<>(); + for(def pointArr : pointList){ + List list = new ArrayList<>(); + for(def arr : pointArr){ + double x = DataHandleUtils.getDoubleRound(6, arr[0]); + double y = DataHandleUtils.getDoubleRound(6, arr[1]); + Point2D.Double point = new Point2D.Double(x,y); + list.add(point); + } + alllist << list + } + return alllist + } + + public static def isInArea(Point2D.Double point, List> pointList){ + def flag = false; + for(List pointArr : pointList){ + flag = isPtInPoly(point, pointArr) + if(flag){ + break; + } + } + return flag; + } + + /** + * 判断点是否在多边形内 + *

    + * 整个算法的思路为:作点平行于y轴的射线,这样就可以直接比较交点是否大于点(x,y)中y的值,可以简化判断。 + * + * @param point 检测点 + * @param pts 多边形的顶点 + * @return 点在多边形内返回true, 否则返回false + */ + public static boolean isPtInPoly(Point2D.Double point, List pts) { + int polygonSidesCount = pts.size(); + //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true + boolean boundOrVertex = true; + // 射线与多边形相交的次数 + int intersectCount = 0; + //浮点类型计算时候与0比较时候的容差 + double precision = 2e-10; + // 相邻两点 + Point2D.Double p1, p2; + // 当前点 + Point2D.Double p = point; + // 线段起点 + p1 = pts.get(0); + for (int i = 1; i <= polygonSidesCount; ++i) { + //按照点录入的顺序依次检查相邻两点组成的线段和当前的点的关系。 + if (p.equals(p1)) { + //如果当前点就是多边形的顶点之一,直接返回。 + return boundOrVertex; + } + // 线段终点 + p2 = pts.get(i % polygonSidesCount); + if (p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)) { + //点在x轴上的映射,明显超出了线段在x轴上的投影。此时冲着上做射线,肯定没有交点,直接跳过。 + p1 = p2; + continue; + } + if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) { + // 当前点在线段于x轴上的投影内 + if (p.y <= Math.max(p1.y, p2.y)) { + //当前点的 y 坐标小于 线段对y轴投影的最大值 + if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) { + // 若线段同样是平行于y轴,则可以断定,当前点,在多边形的这条垂直于x轴的边上。 + return boundOrVertex; + } + if (p1.y == p2.y) { + // 若线段为平行于x轴的水平线 + if (p1.y == p.y) { + //当前点正好位于该水平线上,直接返回该点位于多边形的一条边上。 + return boundOrVertex; + } else { + //如果当前点在水平线以下,增加一个交点。 + ++intersectCount; + } + } else { + // 如果不是水平线,则用两点式求当前点的x带入多边形线段的直线方程后,对应的y的坐标 + double xInSideLineFormulaResultY = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; + if (Math.abs(p.y - xInSideLineFormulaResultY) < precision) { + // 误差允许范围内,改点就在线段上,则表明,该点位于多边形的一个边上。 + return boundOrVertex; + } + + if (p.y < xInSideLineFormulaResultY) { + // 如果线段上取得的y比当前点的y要大,当前做向上的射线,肯定交于上方的一个点。 + ++intersectCount; + } + } + } + } else { + // 当前点不在线段投影到x轴的区间中 + if (p.x == p2.x && p.y <= p2.y) { + // 但恰好位于线段终点的x坐标对应的平行于y轴上的线上的低于终点y的一点 + // 此时检查下一点能否将其x边界包含。 + Point2D.Double p3 = pts.get((i + 1) % polygonSidesCount); + if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) { + // 若当前点的x坐标位于 p1和p3组成的线段关于x轴的投影中,则记为该点的射线只穿过端点一次。 + ++intersectCount; + } else { + // 若当前点的x坐标不能包含在p1和p3组成的线段关于x轴的投影中,则点射线通过的两条线段组成了一个弯折的部分, + // 此时我们记射线穿过该端点两次 + intersectCount += 2; + } + // 此判断的核心思路是由点在两条线段的内部还是外部去思考得出的 + } + } + // 进行下一个线段的判断 + p1 = p2; + } + if (intersectCount % 2 == 0) { + //偶数在多边形外 + return false; + } else { + //奇数在多边形内 + return true; + } + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy index 58a13a34d..25f5c45ed 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy @@ -324,4 +324,8 @@ class InsidePolygon { } return name; } + + + + } 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 30419ba47..f4801828f 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 @@ -35,7 +35,7 @@ class GaoDeApiUtils { content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") } JSONObject jsonObj = JSONObject.fromObject(content) - if(jsonObj.status!=1){ + if(jsonObj.status!="1"){ println jsonObj } return jsonObj From b1819a64701bdab75740fe5bcb08cb599047b240 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 13:13:42 +0800 Subject: [PATCH 143/247] =?UTF-8?q?=E5=85=88=E4=B8=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=B9=A1=E9=95=87=E6=98=AF=E5=90=A6=E6=A0=87=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/TownStandardBatch.groovy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 0034cdb20..d8ee85b0c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -459,7 +459,7 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { - def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) + def townMap = null//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { @@ -524,9 +524,10 @@ class TownStandardBatch extends BaseBatch{ saveObj.township = gaodeMap.township saveObj.new_district = gaodeMap.district saveObj.town_source = "高德API" - if(townMap.size()>=1){ - saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) - } + saveObj.strand_town = "" +// if(townMap.size()>=1){ +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } } } From b519a64b9c3d7fffc7d67221763b998075b6ba25 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 13:46:01 +0800 Subject: [PATCH 144/247] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E9=99=8D?= =?UTF-8?q?=E4=BD=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/TownStandardBatch.groovy | 2 +- .../yinjihaun/amap/GaoDeApiUtils.groovy | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index d8ee85b0c..0feaa0b5e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def updateList = [] def addAliasList = [] 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 f4801828f..60dc4ddb2 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,6 +12,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { + //94c74c60e102972a8d17b7b75d7403be def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca @@ -29,15 +30,28 @@ class GaoDeApiUtils { params.put("location", location) params.put("extensions","all") String content - try { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } catch (Exception e) { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } - JSONObject jsonObj = JSONObject.fromObject(content) - if(jsonObj.status!="1"){ - println jsonObj + def stop = true + JSONObject jsonObj = null + def errorCount = 1 + while (stop){ + try { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } catch (Exception e) { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } + jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!="1"){ + println jsonObj + errorCount ++ + Thread.sleep(3000) + if(errorCount>3){ + stop = false + } + }else{ + stop = false + } } + return jsonObj } From b5efda084a10d95ebba0cb497957508fdbac7f8b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 11:18:04 +0800 Subject: [PATCH 145/247] =?UTF-8?q?=E7=A9=BA=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/TownStandardBatch.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 0feaa0b5e..3ace39f53 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5) def updateList = [] def addAliasList = [] @@ -380,7 +380,12 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - o.put("data_source", arrs[7]) + if(arrs[7]){ + o.put("data_source", arrs[7]) + }else{ + o.put("data_source", "") + } + rets << o }catch(Exception e){ println arrs @@ -459,7 +464,7 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { - def townMap = null//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) +// def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { From 50481d224b2184e73756953f39d6799d94041a0b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 19:50:21 +0800 Subject: [PATCH 146/247] update --- .../script/gj/data_handle/TownStandardBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 3ace39f53..79569b74a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -380,12 +380,12 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - if(arrs[7]){ - o.put("data_source", arrs[7]) + println arrs.size() + if(arrs.size()<=7){ + o.put("data_source","") }else{ - o.put("data_source", "") + o.put("data_source", arrs[7]) } - rets << o }catch(Exception e){ println arrs From e1228c538a81a4b1970261117ddba7b0e17622de Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 20:00:22 +0800 Subject: [PATCH 147/247] update --- .../fangjia/script/gj/data_handle/TownStandardBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 79569b74a..a614c04e5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) def updateList = [] def addAliasList = [] @@ -464,8 +464,8 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { -// def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) - def set = rMap.keySet() + def townMap = [:]//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) +// def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) From ad8cf3b8f5c5a8b8782bd7713697e0aea37144c4 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 20:07:04 +0800 Subject: [PATCH 148/247] update --- .../com/fangjia/script/gj/data_handle/TownStandardBatch.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index a614c04e5..69c368290 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -380,7 +380,6 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - println arrs.size() if(arrs.size()<=7){ o.put("data_source","") }else{ @@ -466,7 +465,7 @@ class TownStandardBatch extends BaseBatch{ if (rMap) { def townMap = [:]//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) // def set = rMap.keySet() - println totalCount.get() +" "+r.city + " " + set.size() + println totalCount.get() +" "+r.city + " " // if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] From 24224e50f7f3104fef5ba08f43af2a53d4249f95 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 24 Feb 2025 16:22:28 +0800 Subject: [PATCH 149/247] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=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 --- .../open/controllers/PropertyController.java | 17 +- .../controllers/SqmetreRentController.java | 267 ++++++++++++++++++ 2 files changed, 276 insertions(+), 8 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java 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 5ff3daea4..a32ceb24f 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 @@ -1069,7 +1069,7 @@ public class PropertyController { mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("全国") - || model.getDistrict().contains("全国")) { + || model.getDistrict().contains("全国")) { mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); return mav; } @@ -1659,8 +1659,8 @@ public class PropertyController { json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8"); if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) { HashMap resultMap = new HashMap(); - resultMap.put("avgPrice",json.getString("unitPrice")); - resultMap.put("totalPrice",json.getString("totalPrice")); + resultMap.put("avgPrice", json.getString("unitPrice")); + resultMap.put("totalPrice", json.getString("totalPrice")); mav.setModel(BasicModel.buildOKModel().setResult(resultMap)); } else { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); @@ -2527,20 +2527,21 @@ public class PropertyController { mav.setModel(BasicModel.buildBadRequestModel("参数缺失:cat(租金类型)是必须参数")); return mav; } - if ("city".equals(model.getCity()) && StringUtils.isBlank(model.getCity())) { + if ("city".equals(model.getCat()) && StringUtils.isBlank(model.getCity())) { mav.setModel(BasicModel.buildBadRequestModel("城市平米租金,city(城市)是必须参数")); return mav; } - if ("region".equals(model.getCity()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()))) { + if ("region".equals(model.getCat()) && (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()))) { + if ("district".equals(model.getCat()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName()))) { mav.setModel(BasicModel.buildBadRequestModel("小区平米租金,city(城市),district(区域),name(小区名)是必须参数")); return mav; } + District district = null; if ("district".equals(model.getCat())) { - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); if (null == district) { mav.setModel(BasicModel.buildBadRequestModel("小区不存在")); @@ -2556,7 +2557,7 @@ public class PropertyController { } Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -model.getPeriodCount()); - List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(), model.getDistrict()), model.getName(), model.getCat(), startDate, null); + List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(), model.getDistrict()), district.getName(), model.getCat(), startDate, null); List> result = new ArrayList>(model.getPeriodCount()); for (SqmetreRent sqmetreRent : sqmetreRents) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java new file mode 100644 index 000000000..313fa748a --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java @@ -0,0 +1,267 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.mongo.model.SqmetreRent; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.AvgPriceQueryModel; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.district.SqmetreRentService; +import org.apache.commons.lang.StringUtils; + +import java.util.*; + +/** + * 平米租金 + */ +@Authority(role = Role.USER) +public class SqmetreRentController { + + private SqmetreRentService sqmetreRentService; + private DistrictService districtService; + + + /** + * 城市平米租金 + * + * @param model + * @return + */ + public Object cityAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("city"); + + // 校验城市参数 + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市)是必须参数")); + return mav; + } + + // 设置默认 periodCount 并校验范围 + 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() + 1)); + + // 查询平米租金数据 + 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()); + Double lastMonthRent = null; + + // 遍历并填充结果 + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "未知日期"); + + // 计算月涨幅 + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // 设置返回结果,防止 subList 越界 + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + /** + * 区域平米租金 + * + * @param model + * @return + */ + public Object districtAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("region"); + + // 校验城市参数 + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市),district(区域)是必须参数")); + return mav; + } + + // 设置默认 periodCount 并校验范围 + 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() + 1)); + + // 查询平米租金数据 + 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()); + Double lastMonthRent = null; + + // 遍历并填充结果 + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + item.put("district", sqmetreRent.getRegion()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "未知日期"); + + // 计算月涨幅 + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // 设置返回结果,防止 subList 越界 + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + /** + * 小区平米租金 + * + * @param model + * @return + */ + public Object propertyAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("district"); + + // 校验城市参数 + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(城市),district(区域),name(小区名)是必须参数")); + return mav; + } + District district = null; + if ("district".equals(model.getCat())) { + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + } + + // 设置默认 periodCount 并校验范围 + 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() + 1)); + + // 查询平米租金数据 + List sqmetreRents = sqmetreRentService.findSqmetreRents( + RegionData.formatCity(model.getCity()), + RegionData.formatRegion(model.getCity(), model.getDistrict()), + district.getName(), + model.getCat(), + startDate, + null + ); + + // 准备结果列表 + List> result = new ArrayList>(model.getPeriodCount()); + Double lastMonthRent = null; + + // 遍历并填充结果 + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + item.put("district", sqmetreRent.getRegion()); + item.put("name", sqmetreRent.getDistrictName()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "未知日期"); + + // 计算月涨幅 + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // 设置返回结果,防止 subList 越界 + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + + public void setSqmetreRentService(SqmetreRentService sqmetreRentService) { + this.sqmetreRentService = sqmetreRentService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } +} From c241012fe0af2bd98354de45f7937f36a82312fc Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 28 Feb 2025 18:50:34 +0800 Subject: [PATCH 150/247] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=8F=91=E9=82=AE?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dataAna/CityInfoAnaBatch.groovy | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy index d008b0f48..8511662a1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy @@ -343,21 +343,21 @@ class CityInfoAnaBatch extends BaseBatch { def totalDbhouseloudongCount = HOUSE_LOUDONG_CONN.count(findObj) datas << ['', totalDistrictCount, totalLoudongCount, df.format(totalLoudongCount * 1.0/ totalDistrictCount), totalFanghaoCount, df.format(totalFanghaoCount * 1.0/ totalDistrictCount), totalDbLoudongCount, totalDbhouseloudongCount] - ExcelUtils.write(fileName, datas, resultTitle) - String id = ObjectId.get().toString() - BasicDBObject file = new BasicDBObject() - file.put("t", "upload") - file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - file.put("c_date", new Date()) - file.put("_id", idGenerator(id, "o")) - file.put("data", new File(fileName).getBytes()) - fsDB.save(file) - def href = DataUtil.encodePicUrl(id, "o", "upload") - href = "点击下载附件" - receivers.each {receiver-> - jms.sendMail(receiver, resultTitle, href) - } - new File(fileName).deleteOnExit() +// ExcelUtils.write(fileName, datas, resultTitle) +// String id = ObjectId.get().toString() +// BasicDBObject file = new BasicDBObject() +// file.put("t", "upload") +// file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") +// file.put("c_date", new Date()) +// file.put("_id", idGenerator(id, "o")) +// file.put("data", new File(fileName).getBytes()) +// fsDB.save(file) +// def href = DataUtil.encodePicUrl(id, "o", "upload") +// href = "点击下载附件" +// receivers.each {receiver-> +// jms.sendMail(receiver, resultTitle, href) +// } +// new File(fileName).deleteOnExit() } private String idGenerator(String url, String size) { From 139e863c595b86db7d092ff8318fdc865c138244 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 3 Mar 2025 17:28:21 +0800 Subject: [PATCH 151/247] =?UTF-8?q?=E6=B6=89=E5=86=9C=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 11 +++++++++++ 1 file changed, 11 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 118cf497c..180d42aae 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 @@ -812,6 +812,8 @@ public class AddrSvcController { } if (result.containsKey("verifyFlag")) { map.put("verifyFlag", result.getString("verifyFlag")); + }else{ + basicModel.markNoData(); } if (result.containsKey("addrVerify")) { map.put("addrVerify", result.getString("addrVerify")); @@ -899,6 +901,9 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + basicModel.markNoData(); + } basicModel.setResult(resultMap); mav.setModel(basicModel); } else { @@ -981,6 +986,9 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + basicModel.markNoData(); + } basicModel.setResult(resultMap); mav.setModel(basicModel); } else { @@ -1123,6 +1131,9 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + basicModel.markNoData(); + } basicModel.setResult(resultMap); mav.setModel(basicModel); } else { From fad86f44a19190300030c920dd3eb11219e8af19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 3 Mar 2025 10:56:18 +0800 Subject: [PATCH 152/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/dal/SeawaterQuery.java | 9 + .../fangjia/dal/mongo/model/Evaluation.java | 12 + .../dal/mongo/model/OfficeRentStat.java | 11 +- .../dal/seawater/dao/SeawaterDaoImpl.java | 26 +- .../open/controllers/OfficeController.java | 14 +- .../service/datastore/OfficeServiceImpl.java | 427 +++++++++++------- 6 files changed, 314 insertions(+), 185 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java index 4eac9a928..7ce356ffa 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java @@ -37,6 +37,7 @@ public class SeawaterQuery { private Double lng; private Integer radius; + private String level; public String getId() { return id; @@ -269,4 +270,12 @@ public class SeawaterQuery { public void setRadius(Integer radius) { this.radius = radius; } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java index 7b21bbf0a..7c8dd0ca2 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java @@ -142,6 +142,10 @@ public class Evaluation implements MongoEntity { * 物业费(元/m?/月) */ private Double propertyManagementFee; + /** + * 楼层描述 + */ + private String floorDesc; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -1054,4 +1058,12 @@ public class Evaluation implements MongoEntity { public void setPropertyManagementFee(Double propertyManagementFee) { this.propertyManagementFee = propertyManagementFee; } + + public String getFloorDesc() { + return floorDesc; + } + + public void setFloorDesc(String floorDesc) { + this.floorDesc = floorDesc; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java index 900281731..1173752c8 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -3,7 +3,6 @@ package com.fangjia.dal.mongo.model; import com.fangjia.dal.MongoEntity; import javax.persistence.*; -import java.util.Date; @Entity @Table(name = "fangjia_stat.office_rent_stat") @@ -16,6 +15,7 @@ public class OfficeRentStat implements MongoEntity { private String district; private Integer date; private Double avgPrice; + private String name; @Id @GeneratedValue @@ -72,4 +72,13 @@ public class OfficeRentStat implements MongoEntity { public void setAvgPrice(Double avgPrice) { this.avgPrice = avgPrice; } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 39a29c099..1f6270cab 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -1,19 +1,17 @@ package com.fangjia.dal.seawater.dao; -import java.util.*; - -import com.fangjia.dal.SeawaterQuery; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; - import com.fangjia.core.util.HttpRequest; import com.fangjia.core.util.HttpRequestException; +import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.seawater.model.Seawater; - import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; import org.sothis.core.util.Pager; +import java.util.*; + public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl implements SeawaterDao { @@ -618,6 +616,20 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i temp.put("term", param); jsonList.add(temp); } + if (StringUtils.isNotBlank(query.getFitment())) { + JSONObject param = new JSONObject(); + param.put("fitment", query.getFitment()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getDirection())) { + JSONObject param = new JSONObject(); + param.put("direction", query.getDirection()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } Set namesList = new LinkedHashSet(); if (StringUtils.isNotBlank(query.getDistrictName())) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index d60ec8ae1..c1e446844 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -361,9 +361,9 @@ public class OfficeController { evaluation.setRegion(model.getRegion()); evaluation.setDistrictName(model.getName()); evaluation.setAddress(model.getAddress()); - evaluation.setDirection(DIRECTION.get(model.getDirection())); + evaluation.setDirection(model.getDirection()); evaluation.setNoise(NOISE.get(model.getNoise())); - evaluation.setEstateType(PROPERTY_TYPES.get(model.getPropertyType())); + evaluation.setType(model.getType()); evaluation.setSight(SIGHT.get(model.getView())); evaluation.setAtticArea(model.getAtticSize()); evaluation.setTerraceArea(model.getOuterSize()); @@ -476,6 +476,16 @@ public class OfficeController { if (model.isNewDistrict()) { evaluation.setNewDistrict(model.isNewDistrict()); } + String floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest()); evaluation.setIp(ip); AuthenticationBean authenticationBean = (AuthenticationBean) request diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 393456e10..caa6b566d 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -41,46 +41,9 @@ public class OfficeServiceImpl implements OfficeService { evaluation.setFloor(null); evaluation.setHeight(null); } - String city = district.getCity(); - String region = district.getRegion(); - String name = district.getName(); - List alias = district.getAlias(); - Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); - Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); - - SeawaterQuery query = new SeawaterQuery(); - query.setCat("office_rent"); - query.setCityDisplay(city); - if (StringUtils.isNotBlank(region)) { - query.setRegion(region); - } - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setDistrictName(name); - query.setDistrictAlias(alias); - if (evaluation.getArea() != null && evaluation.getArea() != 0) { - query.setStartArea(evaluation.getArea() * 0.9); - query.setEndArea(evaluation.getArea() * 1.1); - } - Pager pager = new Pager(); - pager.setStartRow(0); - pager.setPageSize(100); - query.setPager(pager); - query.setTable("latest_seawater"); - List seawaters = seawaterService.findSeawatersByQuery(query); - //List seawaters = seawaterService.findSeawatersByQuery("office_rent", city, region, name, alias, startDate, endDate); - // 有样本 - Double unitPrice = null; - // 如果面积相近查不到,则不限制面积查询一次,如果还是没有查到,则返回null; - if (CollectionUtils.isEmpty(seawaters)) { - query.setStartArea(null); - query.setEndArea(null); - seawaters = seawaterService.findSeawatersByQuery(query); - } - OfficeEvaluationDto officeEvaluationDto = null; - if (seawaters.size() > 0) { - officeEvaluationDto = this.calcRent(seawaters, evaluation); - } else { + OfficeEvaluationDto officeEvaluationDto = this.calcRent(evaluation); + // 如果从基价表中找不到,// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) { if (StringUtils.isNotBlank(evaluation.getLocation())) { officeEvaluationDto = rentEvaluateByLocation(evaluation); } else if (district != null && district.getLat() != null) { @@ -102,6 +65,21 @@ public class OfficeServiceImpl implements OfficeService { put("4", "豪装"); } }; + + private static final Map DIRECTION_MAP = 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 LEVEL_MAP = new HashMap() { { put(1, "甲级"); @@ -117,135 +95,213 @@ public class OfficeServiceImpl implements OfficeService { put(4, "综合体"); } }; - public OfficeEvaluationDto calcRent(List seawaters, Evaluation evaluation) { - // 计算平均值 + // 随机森林模型系数计算 + private static final Map FLOOR_FACTOR = new HashMap() { + { + put("中层", 1.0); + put("低层", 0.9940); + put("高层", 1.0185); + put("中", 1.0); + put("低", 0.9940); + put("高", 1.0185); + } + }; + private static final Map FITMENT_FACTOR = new HashMap() { + { + put("毛坯", 0.9983); + put("简装", 1.0); + put("精装", 1.0153); + put("豪装", 1.0199); + } + }; + private static final Map DIRECTION_FACTOR = new HashMap() { + { + put("东", 1.0040); + put("东北", 1.0048); + put("东南", 1.0121); + put("东西", 1.0003); + put("北", 0.9999); + put("南", 1.0000); + put("南北", 1.0080); + put("西", 1.0060); + put("西北", 1.0099); + put("西南", 1.0103); + } + }; + + public OfficeEvaluationDto calcRent(Evaluation evaluation) { + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + // 第二步:基准价*楼层系数*装修系数*朝向系数 + // 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("office_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "低".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "高".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getOfficeEvaluationDto(selectedSeawaters, evaluation); + } + } + // 查找基准价 + List params = new ArrayList(); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // 获取上个月yyyyMM日期 + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // 第二步:基准价*楼层系数*装修系数*朝向系数 + OfficeRentStat officeRentStat = officeRentStatDao.findFirstByParams(params); + Double avgPrice = officeRentStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (floorDesc != null) { + factor *= FLOOR_FACTOR.get(floorDesc); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation); + } + + return null; + } + + /** + * 根据均价查询样本 + * @param avgPrice + * @param evaluation + * @return + */ + private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation) { + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + query.setCat("office_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + return getOfficeEvaluationDto(seawaters, evaluation); + } + + /** + * 基准价*楼层系数*装修系数*朝向系数 + * @param seawaters + * @param evaluation + * @return + */ + private static OfficeEvaluationDto getOfficeEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { Double sum = 0.0; Double size = 0.0; - Double unitPrice = null; - Double factor = 1.0; - // 按写字楼类型过滤 - List filterWithType = new ArrayList(); - if (evaluation.getType() != null) { - if (TYPE_MAP.get(evaluation.getFitment()) != null) { - for (Seawater seawater : seawaters) { - if (TYPE_MAP.get(evaluation.getType()).equals(seawater.getEstateType())) { - filterWithType.add(seawater); - } - } - } - // 如果样本数量大于5,则按装修过滤 - if (filterWithType.size() > 5) { - seawaters = filterWithType; - } else { - // TODO 按照写字楼类型进行调整,1:标准写字楼;2:创意园区;3:商住两用;4:综合体 - // 拍脑袋 - if (evaluation.getType() == 1) { - factor *= 1.0; - } else if (evaluation.getType() == 2) { - factor *= 0.98; - } else if (evaluation.getType() == 3) { - factor *= 0.97; - } else if (evaluation.getType() == 4) { - factor *= 0.96; - } - } - } - // 按写字楼等级过滤 - List filterWithGrade = new ArrayList(); - if (evaluation.getLevel() != null) { - if (LEVEL_MAP.get(evaluation.getFitment()) != null) { - for (Seawater seawater : seawaters) { - if (LEVEL_MAP.get(evaluation.getLevel()).equals(seawater.getLevel())) { - filterWithGrade.add(seawater); - } - } - } - // 如果样本数量大于5,则按装修过滤 - if (filterWithGrade.size() > 5) { - seawaters = filterWithGrade; - } else { - // TODO 按照写字楼等级进行调整,1:甲级;2:乙级;3:丙级 - // 拍脑袋 - if (evaluation.getLevel() == 1) { - factor *= 1.2; - } else if (evaluation.getLevel() == 2) { - factor *= 1.0; - } else if (evaluation.getLevel() == 3) { - factor *= 0.9; - } - } - } - // 按楼层过滤 - List filterWithFloor = new ArrayList(); - if (evaluation.getFloor() != null && evaluation.getHeight() != null) { - Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); - String floorDesc = "中层"; - if (floorInfo <= 0.33) { - floorDesc = "低层"; - } else if (floorInfo > 0.66) { - floorDesc = "高层"; - } - if (LEVEL_MAP.get(evaluation.getFitment()) != null) { - for (Seawater seawater : seawaters) { - if (seawater.getFloorInfo() != null && seawater.getFloorInfo().contains(floorDesc)) { - filterWithFloor.add(seawater); - } - } - } - // 如果样本数量大于5,则按装修过滤 - if (filterWithFloor.size() > 5) { - seawaters = filterWithGrade; - } else { - // TODO 按照写字楼楼层进行调整,高层 中层 低层 - // 拍脑袋 - if (floorDesc.equals("高层")) { - factor *= 1.2; - } else if (floorDesc.equals("中层")) { - factor *= 1.0; - } else if (floorDesc.equals("低层")) { - factor *= 0.9; - } - } - } - // 按装修过滤 - List filterWithFitment = new ArrayList(); - if (evaluation.getFitment() != null) { - if (FITMENT_MAP.get(evaluation.getFitment()) != null) { - for (Seawater seawater : seawaters) { - if (FITMENT_MAP.get(evaluation.getFitment()).equals(seawater.getFitment())) { - filterWithFitment.add(seawater); - } - } - } - // 如果样本数量大于5,则按装修过滤 - if (filterWithFitment.size() > 5) { - seawaters = filterWithFitment; - } else { - // TODO 按照装修系数进行调整,如1: 毛坯,2: 简装,3: 精装,4: 豪装 - // 拍脑袋 - if (evaluation.getFitment().equals(1)) { - factor *= 0.8; - } else if (evaluation.getFitment().equals(2)) { - factor *= 1.0; - } else if (evaluation.getFitment().equals(3)) { - factor *= 1.2; - } else if (evaluation.getFitment().equals(4)) { - factor *= 1.5; - } - } - } - // TODO 3.4免租期factor*调整因子:factory - 免租期/最低起租期 - // TODO 物业费因子 + String fitment = FITMENT_MAP.get(evaluation.getFitment()); + String direction = DIRECTION_MAP.get(evaluation.getDirection()); for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { - sum += seawater.getTotalPrice(); + Double price = Double.valueOf(seawater.getTotalPrice()); + // 楼层系数修正 + if (seawater.getFloorInfo() != null) { + try { + if (seawater.getFloorInfo().contains("低")) { + price = price / FLOOR_FACTOR.get("低") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } else if (seawater.getFloorInfo().contains("中")) { + price = price / FLOOR_FACTOR.get("中") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } else if (seawater.getFloorInfo().contains("高")) { + price = price / FLOOR_FACTOR.get("高") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + } catch (Exception ex) { + + } + } + // 装修 + if (seawater.getFitment() != null) { + try { + price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); + } catch (Exception ex) { + + } + } + // 朝向 + if (seawater.getDirection() != null) { + try { + price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); + } catch (Exception ex) { + + } + } + + sum += price; size += seawater.getArea(); } } OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (size > 0) { - unitPrice = DataUtil.roundDouble(sum / size / 30 * factor, 2); + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); officeEvaluationDto.setUnitPrice(unitPrice); officeEvaluationDto.setSeawater(seawaters); officeEvaluationDto.setCity(evaluation.getCity()); @@ -255,6 +311,36 @@ public class OfficeServiceImpl implements OfficeService { return officeEvaluationDto; } + /** + * 纯样本查询结果估值 + * + * @param seawaters + * @param evaluation + * @return + */ + private static OfficeEvaluationDto getOfficeEvaluationDto(List seawaters, Evaluation evaluation) { + Integer sum = 0; + Double size = 0.0; + + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + return officeEvaluationDto; + } + + @Override public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { @@ -279,16 +365,14 @@ public class OfficeServiceImpl implements OfficeService { query.setLat(lat); query.setLng(lng); query.setCat("office_rent"); - query.setRadius(1000); + query.setRadius(3000); Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); query.setStartDate(startDate); query.setEndDate(endDate); - if (evaluation.getArea() != null && evaluation.getArea() != 0) { - query.setStartArea(evaluation.getArea() * 0.9); - query.setEndArea(evaluation.getArea() * 1.1); - } + query.setEstateType(TYPE_MAP.get(evaluation.getType())); + query.setLevel(LEVEL_MAP.get(evaluation.getLevel())); query.setCityDisplay(evaluation.getCity()); Pager pager = new Pager(); pager.setStartRow(0); @@ -296,21 +380,14 @@ public class OfficeServiceImpl implements OfficeService { query.setPager(pager); query.setTable("latest_seawater"); seawaters = seawaterService.findSeawatersByQuery(query); - // 如果面积相近查不到,则不限制面积查询一次,如果还是没有查到,则返回null; + // 如果同等级同类型没有查到,则放开 if (CollectionUtils.isEmpty(seawaters)) { - query.setStartArea(null); - query.setEndArea(null); + query.setEstateType(null); + query.setLevel(null); seawaters = seawaterService.findSeawatersByQuery(query); } - // 如果还查不到,取周边三公里,如上海青浦凤新大楼,太偏了 - if (CollectionUtils.isEmpty(seawaters)) { - query.setRadius(3000); - seawaters = seawaterService.findSeawatersByQuery(query); - } - OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (CollectionUtils.isNotEmpty(seawaters)) { - officeEvaluationDto = calcRent(seawaters, evaluation); - return officeEvaluationDto; + return getOfficeEvaluationDtoWithFactor(seawaters, evaluation); } } return null; From e3c79206a60b47aeba50500f442b906a0d351a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 3 Mar 2025 18:12:25 +0800 Subject: [PATCH 153/247] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-coresite/src/main/webapp/trend/trend.ftl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl index 8a7c2935c..c3fbbf0d3 100644 --- a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl +++ b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl @@ -273,13 +273,13 @@ 灏忓尯 - 80涓� + 91涓� >95% 鏉戝簞 - 56.2涓� + 380涓� @@ -297,7 +297,7 @@ 鍐欏瓧妤� - 4.18涓� + 14涓� @@ -321,7 +321,7 @@ 閬撹矾 - 44.6涓� + 105涓� >95% 骞存洿鏂� From 03dcd0bc163ae9f482d6bab90ad2e4af824c864e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 4 Mar 2025 16:35:54 +0800 Subject: [PATCH 154/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BCBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/OfficeServiceImpl.java | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index caa6b566d..1c53e47dc 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -157,32 +157,34 @@ public class OfficeServiceImpl implements OfficeService { query.setPager(pager); query.setTable("latest_seawater"); seawaters = seawaterService.findSeawatersByQuery(query); - for (Seawater seawater : seawaters) { - boolean sameFloorDesc = false; + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "低".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "高".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { - if (seawater.getFloorInfo() != null) { - if (seawater.getFloorInfo().contains(floorDesc)) { - sameFloorDesc = true; - } else { - try { - Integer floor = Integer.parseInt(seawater.getFloorInfo()); - if (floor <= 6 && "低".equals(floorDesc)) { - sameFloorDesc = true; - } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { - sameFloorDesc = true; - } else if (floor > 15 && "高".equals(floorDesc)) { - sameFloorDesc = true; } - } catch (Exception ex) { - } } - } - if (sameFloorDesc) { - selectedSeawaters.add(seawater); - } - if (selectedSeawaters.size() == 3) { - return getOfficeEvaluationDto(selectedSeawaters, evaluation); + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getOfficeEvaluationDto(selectedSeawaters, evaluation); + } } } // 查找基准价 From 0c7aa269a6c93a9b8a7f4742ea87dca867abcb5b Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 5 Mar 2025 11:34:33 +0800 Subject: [PATCH 155/247] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E7=A7=9F=E9=87=91=E8=B5=B0=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 61 ++++++++++++++++++- .../service/datastore/OfficeService.java | 2 +- .../service/datastore/OfficeServiceImpl.java | 20 ++++-- 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index c1e446844..db941aec7 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -93,7 +93,7 @@ public class OfficeController { return mav; } - List regionStats = officeService.findOfficeRentStat(city, null, startDate, endDate); + List regionStats = officeService.findOfficeRentStat(city, null, null, "city", startDate, endDate); if (CollectionUtils.isEmpty(regionStats)) { mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); @@ -149,7 +149,7 @@ public class OfficeController { return mav; } - List regionStats = officeService.findOfficeRentStat(city, region, startDate, endDate); + List regionStats = officeService.findOfficeRentStat(city, region, null, "district", startDate, endDate); if (CollectionUtils.isEmpty(regionStats)) { mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); @@ -159,6 +159,63 @@ public class OfficeController { return mav; } + /** + * 写字楼均价走势 + * + * @return + */ + public Object officeRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, region, name, "office", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + /** * 写字楼楼租金地址估值 * diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index 96ced5b18..fe0b77dfe 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -23,7 +23,7 @@ public interface OfficeService { * @param endDate * @return */ - List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate); + List findOfficeRentStat(final String city, final String region,final String name, final String cat, final Integer startDate, final Integer endDate); /** * 租金评估 diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 1c53e47dc..a1f6d9978 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -34,7 +34,6 @@ public class OfficeServiceImpl implements OfficeService { private SeawaterService seawaterService; - @Override public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { @@ -55,7 +54,7 @@ public class OfficeServiceImpl implements OfficeService { return officeEvaluationDto; } -// 所在楼层 + // 所在楼层 // 总楼层 private static final Map FITMENT_MAP = new HashMap() { { @@ -224,6 +223,7 @@ public class OfficeServiceImpl implements OfficeService { /** * 根据均价查询样本 + * * @param avgPrice * @param evaluation * @return @@ -253,6 +253,7 @@ public class OfficeServiceImpl implements OfficeService { /** * 基准价*楼层系数*装修系数*朝向系数 + * * @param seawaters * @param evaluation * @return @@ -403,26 +404,33 @@ public class OfficeServiceImpl implements OfficeService { return ""; } - public List findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) { - return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate, + public List findOfficeRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + name + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { public List execute(String input) { - return doFindRegionBlockStat(city, region, startDate, endDate); + return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); } }); } - public List doFindRegionBlockStat(final String city, final String region, Integer startDate, Integer endDate) { + public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { if (startDate == null) { throw new IllegalArgumentException("开始日期不能为空"); } if (endDate == null) { throw new IllegalArgumentException("结束日期不能为空"); } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } List params = new ArrayList(); params.add(new QueryParam("city", city)); params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); if (startDate != null) { params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); From 08297d1bee9fedaedd18f134256c218d986243b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 6 Mar 2025 14:31:31 +0800 Subject: [PATCH 156/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 167 +++++++++++++++++- 1 file changed, 164 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index c1e446844..d9cbb49ed 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -1,9 +1,7 @@ package com.fangjia.open.controllers; import com.fangjia.core.RegionData; -import com.fangjia.core.util.AnalyticsUtil; -import com.fangjia.core.util.DataUtil; -import com.fangjia.core.util.LoggerFactory; +import com.fangjia.core.util.*; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.mongo.fangjia.model.ServerArea; import com.fangjia.dal.mongo.model.Evaluation; @@ -11,15 +9,19 @@ import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seaweed.model.District; import com.fangjia.open.HttpCode; import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.dto.DistrictInfoDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; import com.fangjia.open.model.BasicModel; import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.PropertySearchModel; import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.util.CommonUtils; +import com.fangjia.service.address.AddressParser; import com.fangjia.service.api.AddressMatchProxyService; import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.FieldFilterService; import com.fangjia.service.datastore.OfficeService; import com.fangjia.service.datastore.OpenApiLogService; import com.fangjia.service.datastore.dto.OfficeEvaluationDto; @@ -27,6 +29,7 @@ import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; +import org.bson.types.ObjectId; import org.slf4j.Logger; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.annotation.Param; @@ -57,6 +60,9 @@ public class OfficeController { private OpenApiLogService openApiLogService; + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + /** * 城市出租均价 * @@ -237,6 +243,153 @@ public class OfficeController { } } + /** + * 写字楼详情 + * + * @param model + * @return + */ + 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; + } + + 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(), + "office"); + 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(), "office", false); + 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()); + districtInfoDto.setPropertyType(district.getEstateType2()); + 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.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()); + districtInfoDto.setBedKind(district.getBedKind()); + districtInfoDto.setEstateType2(district.getEstateType2()); + if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { + districtInfoDto.setBuildingCount(district.getLoudongCount()); + } + 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; + } + /** * 写字楼租金评估 @@ -526,4 +679,12 @@ public class OfficeController { public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { this.addressMatchProxyService = addressMatchProxyService; } + + public void setAddressParser(AddressParser addressParser) { + this.addressParser = addressParser; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } } From 7e1f0389a74fdf81ac895a6997ed3ffe28654c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 6 Mar 2025 17:19:11 +0800 Subject: [PATCH 157/247] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/OfficeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index ae90cdb69..2eb8b3d73 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -471,7 +471,7 @@ public class OfficeController { District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office"); if (district == null) { if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) { - district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "district"); + district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office"); } if (district == null) { mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在")); From 0ff02ed94571cb898fed49dcc699876b5f54df37 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 6 Mar 2025 18:05:49 +0800 Subject: [PATCH 158/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=8A=A0=E7=89=A9=E4=B8=9A=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 1 + 1 file changed, 1 insertion(+) 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 a32ceb24f..1e9226ecc 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 @@ -832,6 +832,7 @@ public class PropertyController { districtInfoDto.setTransportation(district.getTraffic()); districtInfoDto.setRelatedInfo(district.getRelateInfo()); districtInfoDto.setDescription(district.getDescription()); + districtInfoDto.setEstateCharge(district.getEstateCharge()); districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); districtInfoDto.setSalesPhoneNumber(district.getMobile()); districtInfoDto.setTownship(district.getTownship()); From 538b3bee1c1629dccc3cfb2859990796f48232ea Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 6 Mar 2025 18:26:15 +0800 Subject: [PATCH 159/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=8A=A0=E7=94=B5=E6=A2=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PropertyController.java | 2 ++ .../com/fangjia/open/dto/DistrictInfoDto.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) 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 1e9226ecc..fa331f5f8 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 @@ -833,6 +833,8 @@ public class PropertyController { districtInfoDto.setRelatedInfo(district.getRelateInfo()); districtInfoDto.setDescription(district.getDescription()); districtInfoDto.setEstateCharge(district.getEstateCharge()); + districtInfoDto.setRegister(district.getRegister()); + districtInfoDto.setElevatorsCount(district.getElevatorsCount()); districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); districtInfoDto.setSalesPhoneNumber(district.getMobile()); districtInfoDto.setTownship(district.getTownship()); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java index 805bc15af..f30ccbf54 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java @@ -49,6 +49,8 @@ public class DistrictInfoDto { private String carSite; private Long sellCount; // 出售房源量 private Long rentCount; // 出租房源量 + private String register; // 是否可注册 + private String elevatorsCount; // 电梯数量 private Integer avgPrice; private Integer villaAvgPrice; private Integer totalPrice; @@ -876,4 +878,20 @@ public class DistrictInfoDto { public void setEstateType2(String estateType2) { this.estateType2 = estateType2; } + + public String getRegister() { + return register; + } + + public void setRegister(String register) { + this.register = register; + } + + public String getElevatorsCount() { + return elevatorsCount; + } + + public void setElevatorsCount(String elevatorsCount) { + this.elevatorsCount = elevatorsCount; + } } From a4947fe76c1f1c16014d48527a19d0a93c0b880e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 7 Mar 2025 16:22:42 +0800 Subject: [PATCH 160/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A0=E6=A0=B7?= =?UTF-8?q?=E6=9C=AC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/OfficeServiceImpl.java | 119 +++++++++++++----- .../datastore/dto/OfficeEvaluationDto.java | 10 ++ 2 files changed, 101 insertions(+), 28 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index a1f6d9978..c1426a0be 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -15,8 +15,9 @@ import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.dto.GaodeDto; +import com.mongodb.BasicDBObject; +import org.apache.commons.collections.CollectionUtils; import org.sothis.core.util.Closure; -import org.sothis.core.util.CollectionUtils; import org.sothis.core.util.Pager; import weiboclient4j.utils.StringUtils; @@ -362,36 +363,98 @@ public class OfficeServiceImpl implements OfficeService { if (StringUtils.isNotBlank(evaluation.getLocation())) { Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); - // 查询Seawater样本 - List seawaters; - SeawaterQuery query = new SeawaterQuery(); - query.setLat(lat); - query.setLng(lng); - query.setCat("office_rent"); - query.setRadius(3000); + // 查询附近5个写字楼基准价 + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); - Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); - Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setEstateType(TYPE_MAP.get(evaluation.getType())); - query.setLevel(LEVEL_MAP.get(evaluation.getLevel())); - query.setCityDisplay(evaluation.getCity()); - Pager pager = new Pager(); - pager.setStartRow(0); - pager.setPageSize(10); - query.setPager(pager); - query.setTable("latest_seawater"); - seawaters = seawaterService.findSeawatersByQuery(query); - // 如果同等级同类型没有查到,则放开 - if (CollectionUtils.isEmpty(seawaters)) { - query.setEstateType(null); - query.setLevel(null); - seawaters = seawaterService.findSeawatersByQuery(query); + List params = new ArrayList(5); + if (TYPE_MAP.get(evaluation.getType()) != null) { + params.add(new QueryParam("estate_type2", TYPE_MAP.get(evaluation.getType()))); } - if (CollectionUtils.isNotEmpty(seawaters)) { - return getOfficeEvaluationDtoWithFactor(seawaters, evaluation); + if (LEVEL_MAP.get(evaluation.getLevel()) != null) { + params.add(new QueryParam("bed_kind", LEVEL_MAP.get(evaluation.getLevel()))); } + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = officeRentStatDao.findAllByParams(params, sortParams); + if (CollectionUtils.isEmpty(infos)) { + // 去掉类型,重新查找 + params = new ArrayList(5); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = officeRentStatDao.findAllByParams(params, sortParams); + } + if (CollectionUtils.isNotEmpty(infos)) { + // 求均值 + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + Double totalPrice = 0D; + int count = 0; + for (OfficeRentStat officeRentStat : infos) { + if (officeRentStat.getAvgPrice() != null) { + totalPrice += officeRentStat.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getFloorDesc() != null) { + factor *= FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + officeEvaluationDto.setUnitPrice(avgPrice); + officeEvaluationDto.setOffices(infos); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + +// // 查询Seawater样本 +// List seawaters; +// SeawaterQuery query = new SeawaterQuery(); +// query.setLat(lat); +// query.setLng(lng); +// query.setCat("office_rent"); +// query.setRadius(3000); +// +// Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); +// Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); +// query.setStartDate(startDate); +// query.setEndDate(endDate); +// query.setEstateType(TYPE_MAP.get(evaluation.getType())); +// query.setLevel(LEVEL_MAP.get(evaluation.getLevel())); +// query.setCityDisplay(evaluation.getCity()); +// Pager pager = new Pager(); +// pager.setStartRow(0); +// pager.setPageSize(10); +// query.setPager(pager); +// query.setTable("latest_seawater"); +// seawaters = seawaterService.findSeawatersByQuery(query); +// // 如果同等级同类型没有查到,则放开 +// if (CollectionUtils.isEmpty(seawaters)) { +// query.setEstateType(null); +// query.setLevel(null); +// seawaters = seawaterService.findSeawatersByQuery(query); +// } +// if (CollectionUtils.isNotEmpty(seawaters)) { +// return getOfficeEvaluationDtoWithFactor(seawaters, evaluation); +// } } return null; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index b445eb392..db68aeac2 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -1,6 +1,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seawater.model.Seawater; import java.util.List; @@ -14,6 +15,7 @@ public class OfficeEvaluationDto extends Evaluation { private Double unitPrice; private List seawater; + private List offices; private String district; private String name; @@ -49,4 +51,12 @@ public class OfficeEvaluationDto extends Evaluation { public void setName(String name) { this.name = name; } + + public List getOffices() { + return offices; + } + + public void setOffices(List offices) { + this.offices = offices; + } } From 96c7f46656a5cdc55ebb5c2feed370e254d43758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 7 Mar 2025 17:00:11 +0800 Subject: [PATCH 161/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A0=E6=A0=B7?= =?UTF-8?q?=E6=9C=AC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/dal/mongo/model/OfficeRentStat.java | 10 ++++++++++ .../com/fangjia/open/controllers/OfficeController.java | 1 - .../fangjia/service/datastore/OfficeServiceImpl.java | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java index 1173752c8..4c173468d 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -16,6 +16,7 @@ public class OfficeRentStat implements MongoEntity { private Integer date; private Double avgPrice; private String name; + private Object location; @Id @GeneratedValue @@ -81,4 +82,13 @@ public class OfficeRentStat implements MongoEntity { public void setName(String name) { this.name = name; } + + @Column(name = "location") + public Object getLocation() { + return location; + } + + public void setLocation(Object location) { + this.location = location; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 2eb8b3d73..cc9a5522f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -281,7 +281,6 @@ public class OfficeController { districtPriceMap.put("city", evaluation.getCity()); districtPriceMap.put("district", evaluation.getRegion()); districtPriceMap.put("name", evaluation.getName()); - districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index c1426a0be..950f6711a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -360,6 +360,7 @@ public class OfficeServiceImpl implements OfficeService { } private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (StringUtils.isNotBlank(evaluation.getLocation())) { Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); @@ -387,7 +388,7 @@ public class OfficeServiceImpl implements OfficeService { List sortParams = new ArrayList(); sortParams.add(new SortParam("date", false)); - List infos = officeRentStatDao.findAllByParams(params, sortParams); + List infos = officeRentStatDao.findAllByParams(params, sortParams, 5); if (CollectionUtils.isEmpty(infos)) { // 去掉类型,重新查找 params = new ArrayList(5); @@ -398,7 +399,6 @@ public class OfficeServiceImpl implements OfficeService { } if (CollectionUtils.isNotEmpty(infos)) { // 求均值 - OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); Double totalPrice = 0D; int count = 0; for (OfficeRentStat officeRentStat : infos) { @@ -423,6 +423,7 @@ public class OfficeServiceImpl implements OfficeService { officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); + return officeEvaluationDto; } // // 查询Seawater样本 @@ -456,7 +457,7 @@ public class OfficeServiceImpl implements OfficeService { // return getOfficeEvaluationDtoWithFactor(seawaters, evaluation); // } } - return null; + return officeEvaluationDto; } private String getLocation(String city, String address) { From d9c0dce1dcbb336805a8cc221c10f984a6b2c672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 7 Mar 2025 17:15:23 +0800 Subject: [PATCH 162/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A0=E6=A0=B7?= =?UTF-8?q?=E6=9C=AC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/OfficeRentStat.java | 2 ++ .../open/controllers/OfficeController.java | 1 + .../service/datastore/OfficeServiceImpl.java | 36 ++----------------- .../datastore/dto/OfficeEvaluationDto.java | 10 +++--- 4 files changed, 10 insertions(+), 39 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java index 4c173468d..cc6084e23 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -1,6 +1,7 @@ package com.fangjia.dal.mongo.model; import com.fangjia.dal.MongoEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; import javax.persistence.*; @@ -16,6 +17,7 @@ public class OfficeRentStat implements MongoEntity { private Integer date; private Double avgPrice; private String name; + @JsonIgnore private Object location; @Id diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index cc9a5522f..443f116bb 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -282,6 +282,7 @@ public class OfficeController { districtPriceMap.put("district", evaluation.getRegion()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("refOffices", evaluation.getOffice()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 950f6711a..1d5339786 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -354,9 +354,8 @@ public class OfficeServiceImpl implements OfficeService { // 评估逻辑 String location = getLocation(evaluation.getCity(), evaluation.getAddress()); evaluation.setLocation(location); - OfficeEvaluationDto officeEvaluationDto = rentEvaluateByLocation(evaluation); - return officeEvaluationDto; + return rentEvaluateByLocation(evaluation); } private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { @@ -419,43 +418,12 @@ public class OfficeServiceImpl implements OfficeService { } Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); officeEvaluationDto.setUnitPrice(avgPrice); - officeEvaluationDto.setOffices(infos); + officeEvaluationDto.setOffice(infos); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); return officeEvaluationDto; } - -// // 查询Seawater样本 -// List seawaters; -// SeawaterQuery query = new SeawaterQuery(); -// query.setLat(lat); -// query.setLng(lng); -// query.setCat("office_rent"); -// query.setRadius(3000); -// -// Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); -// Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); -// query.setStartDate(startDate); -// query.setEndDate(endDate); -// query.setEstateType(TYPE_MAP.get(evaluation.getType())); -// query.setLevel(LEVEL_MAP.get(evaluation.getLevel())); -// query.setCityDisplay(evaluation.getCity()); -// Pager pager = new Pager(); -// pager.setStartRow(0); -// pager.setPageSize(10); -// query.setPager(pager); -// query.setTable("latest_seawater"); -// seawaters = seawaterService.findSeawatersByQuery(query); -// // 如果同等级同类型没有查到,则放开 -// if (CollectionUtils.isEmpty(seawaters)) { -// query.setEstateType(null); -// query.setLevel(null); -// seawaters = seawaterService.findSeawatersByQuery(query); -// } -// if (CollectionUtils.isNotEmpty(seawaters)) { -// return getOfficeEvaluationDtoWithFactor(seawaters, evaluation); -// } } return officeEvaluationDto; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index db68aeac2..b2d164110 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -15,7 +15,7 @@ public class OfficeEvaluationDto extends Evaluation { private Double unitPrice; private List seawater; - private List offices; + private List office; private String district; private String name; @@ -52,11 +52,11 @@ public class OfficeEvaluationDto extends Evaluation { this.name = name; } - public List getOffices() { - return offices; + public List getOffice() { + return office; } - public void setOffices(List offices) { - this.offices = offices; + public void setOffice(List office) { + this.office = office; } } From 68c9fb6399730b7cae10ce89425cb0dfeb189c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 7 Mar 2025 17:16:43 +0800 Subject: [PATCH 163/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A0=E6=A0=B7?= =?UTF-8?q?=E6=9C=AC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/open/controllers/OfficeController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 443f116bb..1b29ffc46 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -524,6 +524,7 @@ public class OfficeController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("refOffices", evaluation.getOffice()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { From 129b96e87307fbbc660c85ba5cd2c170fd17709f Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 7 Mar 2025 17:39:46 +0800 Subject: [PATCH 164/247] =?UTF-8?q?poi=E6=9F=A5=E8=AF=A2=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PoiController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java index f2cb3aa94..08c74dfef 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java @@ -287,7 +287,14 @@ public class PoiController { double lng = Double.parseDouble(lngStr); double lat = Double.parseDouble(latStr); Map> result = new HashMap>(); - List bankSmallType = Arrays.asList("银行", "中国人民银行", "国家开发银行", "中国进出口银行"); + List bankSmallType = Arrays.asList("银行", "中国人民银行", "国家开发银行", "中国进出口银行", + "中国银行", "中国工商银行", "中国建设银行", "中国农业银行", "交通银行", "招商银行", "华夏银行", + "中信银行", "中国民生银行", "中国光大银行", "上海银行", "上海浦东发展银行", "平安银行", "兴业银行", + "北京银行", "广发银行", "农村商业银行", "香港恒生银行", "东亚银行", "花旗银行", "渣打银行", "汇丰银行", + "荷兰银行", "美国运通银行", "瑞士友邦银行", "美国银行", "蒙特利尔银行", "纽约银行", "苏格兰皇家银行", "法国兴业银行", + "德意志银行", "日本三菱东京日联银行", "巴克莱银行", "摩根大通银行", "中国邮政储蓄银行", "香港星展银行", "南洋商业银行", + "上海商业银行", "永亨银行", "香港永隆银行", "创兴银行", "大新银行", "中信银行(国际)", "大众银行(香港)", + "北京农商银行", "上海农商银行", "广州农商银行", "深圳农村商业银行"); List busSmallType = Collections.singletonList("公交车站相关"); List hospitalSmallType = Arrays.asList("综合医院", "三级甲等医院", "专科医院"); List schoolSmallType = Arrays.asList("学校", "高等院校", "中学", "小学", "幼儿园"); From 24d5089c50cd73e9bd2aef9026db7acf363d5657 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 10 Mar 2025 11:13:18 +0800 Subject: [PATCH 165/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=BC=B0=E5=80=BC=E7=BB=93=E6=9E=9C=E5=8A=A0=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 2 +- .../service/datastore/OfficeServiceImpl.java | 15 ++++++++++++--- .../java/com/fangjia/service/util/GeoUtils.java | 1 + .../com/fangjia/service/util/dto/GaodeDto.java | 10 ++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 1b29ffc46..8a4a2d4f3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -279,7 +279,7 @@ public class OfficeController { Map districtPriceMap = new HashMap(); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("city", evaluation.getCity()); - districtPriceMap.put("district", evaluation.getRegion()); + districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("refOffices", evaluation.getOffice()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 1d5339786..9160da919 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -352,9 +352,14 @@ public class OfficeServiceImpl implements OfficeService { evaluation.setHeight(null); } // 评估逻辑 - String location = getLocation(evaluation.getCity(), evaluation.getAddress()); - evaluation.setLocation(location); - +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + }else { + evaluation.setLocation(""); + } + evaluation.setRegion(gaodeDto.getDistrict()); return rentEvaluateByLocation(evaluation); } @@ -435,6 +440,10 @@ public class OfficeServiceImpl implements OfficeService { } return ""; } + private GaodeDto getGaodeGeo(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + return gaodeDto; + } public List findOfficeRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + name + startDate + endDate, diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java index 20846e7f4..85d968763 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java @@ -48,6 +48,7 @@ public class GeoUtils { gaodeDto.setLevel(level); gaodeDto.setLng(lng); gaodeDto.setLat(lat); + gaodeDto.setDistrict(geocode.getString("district")); } } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java index 1fb150d78..9d0efe820 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java @@ -13,6 +13,8 @@ public class GaodeDto { private String level; + private String district; + public Double getLng() { return lng; } @@ -36,4 +38,12 @@ public class GaodeDto { public void setLevel(String level) { this.level = level; } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } } From 7a80757dd8c0a64cddc7cf288df0828ad954651d Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 10 Mar 2025 13:51:48 +0800 Subject: [PATCH 166/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=BC=B0=E5=80=BC=E7=BB=93=E6=9E=9C=E5=8A=A0=E7=BB=8F?= =?UTF-8?q?=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/OfficeController.java | 1 + .../java/com/fangjia/service/datastore/OfficeServiceImpl.java | 1 + .../com/fangjia/service/datastore/dto/OfficeEvaluationDto.java | 3 +++ 3 files changed, 5 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 8a4a2d4f3..981015511 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -283,6 +283,7 @@ public class OfficeController { districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("refOffices", evaluation.getOffice()); + districtPriceMap.put("location", evaluation.getLocation()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 9160da919..f4e16b4df 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -366,6 +366,7 @@ public class OfficeServiceImpl implements OfficeService { private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto.setLocation(evaluation.getLocation()); Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); // 查询附近5个写字楼基准价 diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index b2d164110..1ffb1ef09 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -15,11 +15,14 @@ public class OfficeEvaluationDto extends Evaluation { private Double unitPrice; private List seawater; + private List office; private String district; + private String name; + public Double getUnitPrice() { return unitPrice; } From 23cc7f2ae0df00e96bde8994dc30a981d21daca0 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 10 Mar 2025 18:02:31 +0800 Subject: [PATCH 167/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=BC=B0=E5=80=BC=E7=BB=93=E6=9E=9C=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=AE=80=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/datastore/OfficeServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index f4e16b4df..aedf7bddb 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -1,5 +1,6 @@ package com.fangjia.service.datastore; +import com.fangjia.core.RegionData; import com.fangjia.core.util.CacheUtils; import com.fangjia.core.util.DataUtil; import com.fangjia.core.util.DateUtil; @@ -356,10 +357,10 @@ public class OfficeServiceImpl implements OfficeService { GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); - }else { + } else { evaluation.setLocation(""); } - evaluation.setRegion(gaodeDto.getDistrict()); + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); return rentEvaluateByLocation(evaluation); } @@ -441,6 +442,7 @@ public class OfficeServiceImpl implements OfficeService { } return ""; } + private GaodeDto getGaodeGeo(String city, String address) { GaodeDto gaodeDto = GeoUtils.geo(city, address); return gaodeDto; From 04f884ed549448d6a0ba0950b2a3471ffb8b41da Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 11 Mar 2025 14:32:56 +0800 Subject: [PATCH 168/247] =?UTF-8?q?=E5=AF=B9=E5=85=AC=E6=B6=89=E5=86=9C?= =?UTF-8?q?=E5=8A=A0prefectureLevelOrAbove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 180d42aae..aa7564be2 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 @@ -812,7 +812,7 @@ public class AddrSvcController { } if (result.containsKey("verifyFlag")) { map.put("verifyFlag", result.getString("verifyFlag")); - }else{ + } else { basicModel.markNoData(); } if (result.containsKey("addrVerify")) { @@ -901,7 +901,7 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); - if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { basicModel.markNoData(); } basicModel.setResult(resultMap); @@ -985,8 +985,13 @@ public class AddrSvcController { resultMap.put("devDistrictName", villageResult.getDevDistrictName()); resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); + if (StringUtils.isNotBlank(villageResult.getDistrict()) && villageResult.getDistrict().endsWith("区")) { + resultMap.put("prefectureLevelOrAbove ", "是"); + }else { + resultMap.put("prefectureLevelOrAbove ", "否"); + } BasicModel basicModel = new BasicModel(200, "OK"); - if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { basicModel.markNoData(); } basicModel.setResult(resultMap); @@ -1131,7 +1136,7 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); - if (StringUtils.isBlank(resultMap.get("verifyFlag"))){ + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { basicModel.markNoData(); } basicModel.setResult(resultMap); From 318ab9241768c1492859009a1d69795c93e99671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 11 Mar 2025 15:26:48 +0800 Subject: [PATCH 169/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/BaseBatch.groovy | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy index 5a3ce647a..39edb1dfe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy @@ -1,6 +1,6 @@ package com.fangjia.script - +import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.* import com.fangjia.script.yinjihaun.util.DingDingMessageUtil import com.mongodb.BasicDBObject @@ -112,6 +112,18 @@ abstract class BaseBatch { } if(SystemUtils.IS_OS_LINUX){ sendDingDingMsg("2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c",msg) + + try { + Map params = new HashMap(); + params.put("phone", "13764369683"); + params.put("type", "taskFail"); + params.put("msg", batchName.substring(batchName.length() - 20, batchName.length())); + HttpRequest httpRequest = new HttpRequest(); + httpRequest.get("http://didata-cloud-server.fangjia.com/sms/send", params, "utf-8"); + } catch (Exception ex) { + + } + task.exception = msg.toString() } } From 43685a13691c428121b174e6e5547449baec9a20 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 12 Mar 2025 11:30:10 +0800 Subject: [PATCH 170/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E4=BC=B0?= =?UTF-8?q?=E5=80=BC=E6=8A=A5=E5=91=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 137 +++++++++++++- .../fangjia/open/model/ReportApplyModel.java | 174 ++++++++++++++++++ .../com/fangjia/open/util/FangJiaTongUrl.java | 30 +++ 3 files changed, 337 insertions(+), 4 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 981015511..46dbfc1b3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -13,11 +13,9 @@ import com.fangjia.open.dto.DistrictInfoDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.BasicModel; -import com.fangjia.open.model.PropertyEvaluationModel; -import com.fangjia.open.model.PropertySearchModel; -import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.model.*; import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; import com.fangjia.service.address.AddressParser; import com.fangjia.service.api.AddressMatchProxyService; import com.fangjia.service.datastore.DistrictService; @@ -543,6 +541,137 @@ public class OfficeController { } } + /** + * 申请估值报告 + * + * @param model 申请报告请求参数 + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8")); + } catch (Exception e) { + try { + json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空")); + } + return mav; + } + + /** + * 获取估值报告 + * + * @param caseId 估值报告ID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8")); + } catch (Exception e) { + try { + json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空")); + } + return mav; + } + private Integer getFloor(String roomNumber) { if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) { if (roomNumber.length() == 3) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java new file mode 100644 index 000000000..89cbcfbea --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java @@ -0,0 +1,174 @@ +package com.fangjia.open.model; + +public class ReportApplyModel extends FangjiaApiModel { + + /** + * 委托机构 + */ + private String client; + /** + * 标的物 + */ + private String subjectMatter; + /** + * 标的物所在城市 + */ + private String city; + /** + * 标的物地址 + */ + private String address; + /** + * 标的物区域 + */ + private String district; + /** + * 标的物小区名称 + */ + private String name; + /** + * 楼号 + */ + private String buildingNumber; + /** + * 室号 + */ + private String unitNumber; + /** + * 面积,单位:平米 + */ + private Float size; + /** + * 所在楼层 + */ + private Integer floor; + /** + * 总楼层 + */ + private Integer maxFloor; + /** + * 物业类型 取值为: 0=普通住宅(默认) 1=别墅 2=商住 + */ + private String propertyType; + /** + * 朝向,可选值有: 1=西南 2=东南 3=南(默认) 4=西北 5=东北 6=东 7=西 8=北 9=东西 10=南北 + */ + private String direction; + /** + * 装修情况,可选值有: 1=毛坯 2=简装(默认) 3=精装 4=豪装 + */ + private String decoration; + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getSubjectMatter() { + return subjectMatter; + } + + public void setSubjectMatter(String subjectMatter) { + this.subjectMatter = subjectMatter; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBuildingNumber() { + return buildingNumber; + } + + public void setBuildingNumber(String buildingNumber) { + this.buildingNumber = buildingNumber; + } + + public String getUnitNumber() { + return unitNumber; + } + + public void setUnitNumber(String unitNumber) { + this.unitNumber = unitNumber; + } + + public Float getSize() { + return size; + } + + public void setSize(Float size) { + this.size = size; + } + + public Integer getFloor() { + return floor; + } + + public void setFloor(Integer floor) { + this.floor = floor; + } + + public Integer getMaxFloor() { + return maxFloor; + } + + public void setMaxFloor(Integer maxFloor) { + this.maxFloor = maxFloor; + } + + public String getPropertyType() { + return propertyType; + } + + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDecoration() { + return decoration; + } + + public void setDecoration(String decoration) { + this.decoration = decoration; + } + +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java new file mode 100644 index 000000000..e77324bb6 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java @@ -0,0 +1,30 @@ +package com.fangjia.open.util; + +public class FangJiaTongUrl { + + /** + * 房价通后台服务token + */ + public static final String FANG_JIA_TONG_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhY2NvdW50Ijoib3BlbiIsImV4cCI6MTMxMzQxNTk0MTQ5MTkzLCJvcmdDb2RlIjoiMDAxLjAwMSIsInJvbGVzIjpbImFkbWluIl0sInVzZXJJZCI6IjE4OTkwMDc1OTc0MDY3NzMyNDgiLCJ1c2VybmFtZSI6Ik9QRU7osIPnlKjotKblj7cifQ.ImHYDRYqmrZ13Wtzx87IlUFkUCy-HGf07M4IuaSyXTfPjNjG7FT_zyceWC2V0iTjexwfLyrPAlJtVflNgIsJYQ"; + + /** + * 房价通后台服务UAT地址 + */ + public static final String FANG_JIA_TONG_URL_UAT = "https://api-uat.fangjia.com"; + + /** + * 房价通后台服务生产地址 + */ + public static final String FANG_JIA_TONG_URL_PROD = "https://api.fangjia.com"; + + /** + * 写字楼申请估值报告接口 + */ + public static final String ASSESS_PRICE_REPORT_APPLY = "/office/assessPriceReport/apply"; + + /** + * 写字楼获取估值报告接口 + */ + public static final String ASSESS_PRICE_REPORT_FETCH = "/office/assessPriceReport/fetch"; + +} From f1f00f88655243d2f21f2c3447f4c9ca9ad38f29 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 12 Mar 2025 12:50:37 +0800 Subject: [PATCH 171/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E4=BC=B0?= =?UTF-8?q?=E5=80=BC=E6=8A=A5=E5=91=8A=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 12 ++++++++---- .../com/fangjia/open/util/FangJiaTongUrl.java | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 46dbfc1b3..49b65382c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -607,10 +607,12 @@ public class OfficeController { headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); headers.put("Content-Type", "application/json"); try { - json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8")); + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); } catch (Exception e) { try { - json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8")); + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); } catch (Exception ex) { ex.printStackTrace(); } @@ -651,10 +653,12 @@ public class OfficeController { headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); headers.put("Content-Type", "application/json"); try { - json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8")); + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); } catch (Exception e) { try { - json = JSONObject.fromObject(request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8")); + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java index e77324bb6..aab318d75 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java @@ -1,5 +1,7 @@ package com.fangjia.open.util; +import org.apache.commons.lang.StringUtils; + public class FangJiaTongUrl { /** @@ -27,4 +29,20 @@ public class FangJiaTongUrl { */ public static final String ASSESS_PRICE_REPORT_FETCH = "/office/assessPriceReport/fetch"; + /** + * 处理调用接口回参中的特殊字符 + * @param str + * @return + */ + public static String replaceAll(String str){ + String replaceAll3 = null; + if(!StringUtils.isBlank(str)){ + String replaceAll = str.replaceAll("\\\\", ""); + System.out.println(replaceAll); + String replaceAll2 = replaceAll.replaceAll("\"[{]", "{"); + replaceAll3 = replaceAll2.replaceAll("[}]\"", "}"); + } + return replaceAll3; + } + } From b10556c3d37c853c12cfd57c04d8702493ca7af4 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 12 Mar 2025 15:26:03 +0800 Subject: [PATCH 172/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E4=BC=B0?= =?UTF-8?q?=E5=80=BC=E6=8A=A5=E5=91=8A=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/OfficeController.java | 3 +++ .../src/main/java/com/fangjia/open/util/FangJiaTongUrl.java | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 49b65382c..91d7f9a01 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -573,6 +573,9 @@ public class OfficeController { if (model.getCity().endsWith("市")) { model.setCity(model.getCity().replaceAll("市$", "")); } + if (model.getDistrict().endsWith("区")) { + model.setDistrict(model.getDistrict().replaceAll("区$", "")); + } if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); return mav; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java index aab318d75..47d8fa603 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java @@ -38,7 +38,6 @@ public class FangJiaTongUrl { String replaceAll3 = null; if(!StringUtils.isBlank(str)){ String replaceAll = str.replaceAll("\\\\", ""); - System.out.println(replaceAll); String replaceAll2 = replaceAll.replaceAll("\"[{]", "{"); replaceAll3 = replaceAll2.replaceAll("[}]\"", "}"); } From 129f1e9a56455205c1fd94ec4a254c7d86f2b19f Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 13 Mar 2025 13:27:04 +0800 Subject: [PATCH 173/247] =?UTF-8?q?=E5=95=86=E9=93=BA=E6=88=BF=E6=BA=90?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 12 +++ .../fangjia/dal/seawater/model/Seawater.java | 43 ++++++++++ .../open/controllers/HouseController.java | 79 ++----------------- 3 files changed, 62 insertions(+), 72 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 1f6270cab..8641e498f 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -380,6 +380,18 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i if (source.containsKey("business_range")) { seawater.setBusinessRange(source.getString("business_range")); } + if (source.containsKey("day_rent_price")) { + seawater.setDayUnitPrice(source.getDouble("day_rent_price")); + } + if (source.containsKey("pay_type")) { + seawater.setPayType(source.getString("pay_type")); + } + if (source.containsKey("rent_type")) { + seawater.setRentType(source.getString("rent_type")); + } + if (source.containsKey("business_status")) { + seawater.setBusinessStatus(source.getString("business_status")); + } try { seawater.setDistance((int) jsonList.get(i).getJSONArray("sort").getDouble(0)); } catch (Exception e) { diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index c553d2f46..b490c892c 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -96,6 +96,13 @@ public class Seawater implements SeawaterEntity { // 写字楼等级 private String level; + private Double dayUnitPrice; + + private String payType; + + private String rentType; + + private String businessStatus; @Id @@ -529,4 +536,40 @@ public class Seawater implements SeawaterEntity { public void setBusinessRange(String businessRange) { this.businessRange = businessRange; } + + @Column(name = "day_rent_price") + public Double getDayUnitPrice() { + return dayUnitPrice; + } + + public void setDayUnitPrice(Double dayUnitPrice) { + this.dayUnitPrice = dayUnitPrice; + } + + @Column(name = "pay_type") + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + @Column(name = "rent_type") + public String getRentType() { + return rentType; + } + + public void setRentType(String rentType) { + this.rentType = rentType; + } + + @Column(name = "business_status") + public String getBusinessStatus() { + return businessStatus; + } + + public void setBusinessStatus(String businessStatus) { + this.businessStatus = businessStatus; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index f8bfdcf10..5bdb146f0 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1039,9 +1039,13 @@ public class HouseController { seawater.setDirection(house.getDirection()); seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); - seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); - seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); - seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); +// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); +// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); +// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDayUnitPrice(house.getDayUnitPrice() == null || house.getDayUnitPrice() == 0 ? null : house.getDayUnitPrice()); + seawater.setRentType(house.getRentType()); + seawater.setPayType(house.getPayType()); + seawater.setBusinessStatus(house.getBusinessStatus()); seawater.setDecoration(house.getFitment()); if (house.getpDate() != null && house.getpDate() > 10000000) { String numberStr = String.valueOf(house.getpDate()); @@ -1072,75 +1076,6 @@ public class HouseController { houseList.add(seawater); } } -// } else { -// if ("sell".equals(cat)) { -// List houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); -// for (House house : houseByLocation) { -// Seawater seawater = new Seawater(); -// seawater.setId(house.getId()); -// seawater.setCity(house.getCity()); -// seawater.setDistrict(house.getRegion()); -// seawater.setAddress(house.getAddress()); -// seawater.setName(house.getDistrictName()); -// seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); -// seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); -// seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); -// seawater.setDirection(house.getDirection()); -// seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); -// seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); -// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); -// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); -// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); -// if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { -// seawater.setUnitPrice(house.getAvgPrice()); -// } else { -// if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { -// int price = (int) (house.getTotalPrice() / house.getArea()); -// seawater.setUnitPrice(price == 0 ? null : price); -// } -// } -// seawater.setDecoration(house.getFitment()); -// if (house.getPublishDate() != null) { -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); -// seawater.setPublishDate(sdf.format(house.getPublishDate())); -// } -// houseList.add(seawater); -// } -// } else if ("rent".equals(cat)) { -// List rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); -// for (RentHouse house : rentHouseByLocation) { -// Seawater seawater = new Seawater(); -// seawater.setId(house.getId()); -// seawater.setCity(house.getCity()); -// seawater.setDistrict(house.getRegion()); -// seawater.setAddress(house.getAddress()); -// seawater.setName(house.getDistrictName()); -// seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); -// seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); -// seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); -// seawater.setDirection(house.getDirection()); -// seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); -// seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); -// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); -// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); -// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); -// if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { -// seawater.setUnitPrice(house.getAvgPrice()); -// } else { -// if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) { -// int price = (int) (house.getTotalPrice() / house.getArea()); -// seawater.setUnitPrice(price == 0 ? null : price); -// } -// } -// seawater.setDecoration(house.getFitment()); -// if (house.getPublishDate() != null) { -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); -// seawater.setPublishDate(sdf.format(house.getPublishDate())); -// } -// houseList.add(seawater); -// } -// } -// } BasicModel basicModel = new BasicModel(200, "ok"); From 625ff40ecf669dca64f558ae18389c6f68cdad1e Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 13 Mar 2025 13:52:24 +0800 Subject: [PATCH 174/247] =?UTF-8?q?=E5=95=86=E9=93=BA=E6=88=BF=E6=BA=90?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/open/controllers/HouseController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 5bdb146f0..54f39bfaf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1046,6 +1046,7 @@ public class HouseController { seawater.setRentType(house.getRentType()); seawater.setPayType(house.getPayType()); seawater.setBusinessStatus(house.getBusinessStatus()); + seawater.setBlock(house.getBlock()); seawater.setDecoration(house.getFitment()); if (house.getpDate() != null && house.getpDate() > 10000000) { String numberStr = String.valueOf(house.getpDate()); From b335505d7f27b035f0cea35d85517929c394c6d6 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 17 Mar 2025 15:11:11 +0800 Subject: [PATCH 175/247] =?UTF-8?q?=E6=B6=89=E5=8F=B0=E6=9C=AA=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/gj/ccb/FileUtils.groovy | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy index 795297501..576869ecd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy @@ -104,6 +104,43 @@ class FileUtils { sb.setLength(0) } out.close(); + return sb.toString().getBytes(charset) + } + + static def createEncryptFile(fileName, outputStr, isAppend){ + OutputStream out = new FileOutputStream(fileName, isAppend); + out.write(outputStr.getBytes("utf-8")); + out.close(); + } + + + static def createFileStringByCustomSuffix(ret, fileName, charset, suffix, lineSuffix){ + File file = new File(fileName); +// if (file.exists()) { +// file.delete(); +// } + + if (!file.getParentFile().exists()) { + boolean result = file.getParentFile().mkdirs(); + if (!result) { + System.out.println("创建目录失败"); + } + } + def sb = new StringBuffer(); + def index = 0 + for(def row : ret){ + if(row){ + index++ + sb.append(StringUtils.join(row.toArray(), suffix)) + if(index Date: Mon, 17 Mar 2025 17:43:50 +0800 Subject: [PATCH 176/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=8E=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/district/DistrictDealSellRentRankBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy index 038134ea4..5b9e5d8b5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy @@ -47,7 +47,7 @@ class DistrictDealSellRentRankBatch extends BaseBatch { "图木舒克","五家渠","济源","仙桃","潜江","天门","景德镇", "神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水", "保亭","琼中","北屯","铁门关","双河","可克达拉" ] - cities = ["无锡"] +// cities = ["无锡"] println cities for(String city : cities) { List districts = findDistrictByCity(city) From 5880614ed1dbdec94aba988c3d2a57f5cea2b52f Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 17 Mar 2025 17:55:00 +0800 Subject: [PATCH 177/247] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/core/util/DataUtil.java | 60 +++++++++---------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java index c17210062..68961d219 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java @@ -1,12 +1,26 @@ package com.fangjia.core.util; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; +import com.hankcs.hanlp.HanLP; +import com.hankcs.hanlp.dictionary.py.Pinyin; +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import net.sf.json.JSONArray; +import net.sf.json.JSONNull; +import net.sf.json.JSONObject; +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sothis.core.util.CollectionUtils; + +import java.io.*; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -23,28 +37,6 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import com.hankcs.hanlp.HanLP; -import com.hankcs.hanlp.dictionary.py.Pinyin; -import net.sf.json.JSONArray; -import net.sf.json.JSONNull; -import net.sf.json.JSONObject; -import net.sourceforge.pinyin4j.PinyinHelper; -import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; -import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; -import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; -import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; - -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.lucene.queryParser.QueryParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sothis.core.util.CollectionUtils; - -import com.mongodb.BasicDBList; -import com.mongodb.BasicDBObject; - public class DataUtil { public static Pattern cellPhonePattern = Pattern.compile("^(1[23456789][0-9]{1})(-)?([0-9]{8})$");// 判断是否手机号码 private final static Logger LOGGER = LoggerFactory.getLogger(DataUtil.class); @@ -1040,10 +1032,11 @@ public class DataUtil { keyword = keyword.replace("\"", ""); keyword = keyword.replaceAll(SPACIAL_PATTERN, ""); keyword = keyword.replace("\\", " "); - keyword = QueryParser.escape(keyword.trim()).trim(); +// keyword = QueryParser.escape(keyword.trim()); keyword = DataUtil.toDBCcase(keyword.replace(";", " ")); keyword = keyword.replaceAll(SPACIAL_PATTERN, ""); - keyword = QueryParser.escape(keyword.trim()).trim(); +// keyword = QueryParser.escape(keyword.trim()).trim(); + keyword = keyword.trim(); for (String reservedWord : new String[] { "AND", "OR" }) { if (keyword.contains(reservedWord)) { keyword = keyword.replace(keyword, "\\" + keyword); @@ -1063,10 +1056,11 @@ public class DataUtil { s = s.replace("\"", ""); s = s.replaceAll(SPACIAL_PATTERN, ""); s = s.replace("\\", " "); - s = QueryParser.escape(s.trim()).trim(); +// s = QueryParser.escape(s.trim()).trim(); s = DataUtil.toDBCcase(s.replace(";", " ")); s = s.replaceAll(SPACIAL_PATTERN, ""); - s = QueryParser.escape(s.trim()).trim(); +// s = QueryParser.escape(s.trim()).trim(); + s = s.trim(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); From 366c4a04e616feebaaa65bab897d8654b16d4980 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 18 Mar 2025 16:58:16 +0800 Subject: [PATCH 178/247] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=9F=8E?= =?UTF-8?q?=E5=B8=82=EF=BC=8C=E5=8E=BB=E6=8E=89oracle=20236=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=EF=BC=8C=20oracle=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccbevaluation/CcbCommonUtils.groovy | 20 +++++++++---------- .../FjwBigdataDealBatch.groovy | 15 +++++++------- 2 files changed, 18 insertions(+), 17 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 624690a6e..d1696dd94 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 @@ -61,25 +61,25 @@ class CcbCommonUtils { def countStr = args[0] if(countStr=="344"){ citys = CcbCommonUtils.citys_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="92"){ citys = CcbCommonUtils.citys_92 - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="252"){ citys = CcbCommonUtils.citys_252 - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="all"){ citys = CcbCommonUtils.citys_fjw_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") } }else{ citys = CcbCommonUtils.citys_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") } println "运行城市数量:"+citys.size() return citys; 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 e4a76bd99..59b61a9e5 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 @@ -5,6 +5,7 @@ import com.fangjia.core.util.DataUtil 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.gj.ccb.CcbCodeUtils import com.fangjia.script.gj.district.SeaweedDataMatchProcess import com.fangjia.script.util.DateUtils @@ -25,7 +26,7 @@ import java.util.regex.Pattern @BatchOwner(Watcher.GaoJuan) class FjwBigdataDealBatch extends BaseBatch{ - def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -24, "yyyyMM")); + def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -12, "yyyyMM")); def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMMdd"), -1, "yyyyMMdd")); @@ -52,11 +53,11 @@ class FjwBigdataDealBatch extends BaseBatch{ def citys = CcbCommonUtils.getRunningCitys(["all"]) -// println "curDate:"+curDate -// def allCitys = CommonDatautils.findAllCity() -// for(def city : allCitys){ -// addDealPriceMatch(city); -// } + println "curDate:"+curDate + def allCitys = CommonDatautils.findAllCity() + for(def city : allCitys){ + addDealPriceMatch(city); + } def rows = [] def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] @@ -519,7 +520,7 @@ 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 endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20250131", "yyyyMMdd")) // def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd")) // def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240701", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) From fc7ed5430c3b945cf11eea0fa4ea3c4a29eb7468 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 18 Mar 2025 16:59:28 +0800 Subject: [PATCH 179/247] =?UTF-8?q?=E4=B8=B4=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/VillaHouseBatch.groovy | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy new file mode 100644 index 000000000..73571b916 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy @@ -0,0 +1,148 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ElasticUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBObject +import groovy.sql.Sql +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +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 VillaHouseBatch extends BaseBatch{ + + def pgsqlInstance236 = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", + "postgres", "postgres", "org.postgresql.Driver") + //235为房价网内部计算均价的库 + def sqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", + "postgres", "Goojia123456", "org.postgresql.Driver") + + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + runBatch(new VillaHouseBatch(), args) + } + + @Override + void process(Object args) { + + def dists = CcbCommonUtils.findAllDistrictByCity("上海", "district", ["city", "region", "name", "estate_type2"], "all") + def villaDists = findVillaDists(dists) + addVillaTypeFlag(villaDists) + println "运行完成" + } + + def findVillaDists(dists){ + def villaDists = [] + for(def d : dists){ + if(d.estate_type2 == "别墅"){ + villaDists << d + } + } + return villaDists + } + + def addVillaTypeFlag(def villaDists){ + for(def i=0;i + sellIds << r.gujia_sell_id + }) + return sellIds + } + + def findHouseInfo(sell_id, houseMap){ + def flag = findHouseDetail(sell_id) + if(flag){ + houseMap.put(sell_id, flag) + } + return houseMap + } + + def findHouseDetail(houseId){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("_id", houseId)) + def flag = null + + def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"] + def index = new Random().nextInt(5); + def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder); + if(houses){ + for (int k=0;k + def sql = "update base.bigdata_forsale set villa_type='${type}' where gujia_sell_id='${sell_id}'" + sqlInstance235.executeUpdate(sql) + } + + } +} From ede742baaf60f77af48bcd980182e06ec406fb04 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 18 Mar 2025 17:00:31 +0800 Subject: [PATCH 180/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/district/OfficeFieldAddBatch.groovy | 320 ++++++++++++++++++ .../fangjia/script/gj/es/OfficeStat.groovy | 254 ++++++++++++++ 2 files changed, 574 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy new file mode 100644 index 000000000..741193c36 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy @@ -0,0 +1,320 @@ +package com.fangjia.script.gj.district + +import com.fangjia.core.util.ExcelUtil +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.gj.FiledStrand +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 +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +/** + * 写字楼字段填充入库(自动入库) + */ +@BatchOwner(Watcher.GaoJuan) +class OfficeFieldAddBatch extends BaseBatch{ + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + + def sources = ["安居客app","办办网","房天下","中华写字楼", "点点租"] + + //type:租售类别 wall:外墙 +// def fieldsMap = ["elevators_count":"elevator_num","person_elevators_count":"elevator_num","goods_elevator_count":"elevator_num","block":"block", +// "estate_type2":"property_type","estate_company":"property_company","estate_charge":"property_fee","all_area":"area", +// "standard_area":"standard_area","sight":"open_area","build_area":"build_area","build_type":"build_type","total_floor":"total_floor", +// "finish_building_date":"complete_time","loop_line_info":"ring_location","standard_height":"floor_height", +// "virescence_percent":"green_rate","cubage_percent":"volume_rate","developer":"developer","fitment":"decoration","parking":"parking_cnt", +// "feature":"characteristic","description":"introduction","parking_fee":"car_fee","property_life":"property_life","bed_kind":"level", +// "lobby_height":"lobby_height","clear_height":"clear_height","foreign":"foreign","build_structure":"structure","address":"address", +// "lng":"location","open_date":"open_date","live_date":"live_date","real_use_percent":"room_rate","land_car_site":"land_car_site", +// "underground_car_site":"underground_car_site","land_floor":"land_floor","underground_floor":"underground_floor"] + + def fieldsMap = ["build_area":"build_area"] + +// "virescence_percent":"green_rate","cubage_percent":"volume_rate","estate_charge":"property_fee","finish_building_date":"complete_time", +// "bed_kind":"level","land_car_site":"land_car_site","underground_car_site":"underground_car_site","parking_fee":"car_fee", +// "elevators_count":"elevator_num","person_elevators_count":"elevator_num","goods_elevator_count":"elevator_num","clear_height":"clear_height", +// "foreign":"foreign","standard_area":"standard_area","foreign":"foreign","parking_fee":"car_fee","estate_company":"property_company","developer":"developer","all_area":"area", + + static main(args) { +// runBatch(new OfficeFieldAddBatch(), args) + + def task = new OfficeFieldAddBatch() +// task.fieldTempProcess() + task.deleteNotNormalOffice() + } + + @Override + void process(Object args) { + def citys = ["深圳"]//CommonDatautils.findAllCity() + def fields = fieldsMap.keySet() as List + def analysRets = [] + for(def c : citys){ + def totalCount = CommonDatautils.findAllDistrictCount("office", c) + + sources.each {source-> + def esRets = findAllEsDataByCity(c, source) + def updateRets = processFieldsFromMatch(c , esRets, source) + + def precentMap = fieldUpdate(totalCount, updateRets) + println c +" "+precentMap.toString() + updateDB(c, updateRets) + println "------------------------------------------------------------------------------" + + def analyRet = [] + analyRet << source + analyRet << c + fields.each{key-> + analyRet << precentMap.get(key) + } + analyRet << esRets.size() + analysRets << analyRet + } + } + println analysRets.toString() + } + + def processFieldsFromMatch(c,matchRets, source){ + def fields = fieldsMap.keySet() as List + fields << "city" + def fieldValueMap = [:] + for(def esOffice : matchRets){ +// if(esOffice.name!="东方建富时尚广场"){ +// continue +// } + def office = CommonDatautils.findNormalDistrict(esOffice.city, esOffice.region, esOffice.name, "office", fields) + if(!office){ +// println c+" "+esOffice.name+" 不存在" + continue + } + def newValues = strandField(c, office, esOffice, source) + if(newValues){ + println office._id.toString()+" "+newValues.toString() + fieldValueMap.put(office._id.toString(), newValues) + } + } + + return fieldValueMap; + } + +// ["loop_line_info":"ring_location","feature":"characteristic","description":"introduction","lng":"location","open_date":"open_date"] + def strandField( c, office, esOffice, source){ + def newValues = [:] + fieldsMap.each{seaweedfield,esField-> + def val = office.get(seaweedfield) + if(!val){ + def esVal = esOffice.get(esField) + if(esVal){ + def newVal = null + + if(seaweedfield == "estate_type2"){ + newVal = FiledStrand.processEstateType(esVal) + } + if(seaweedfield == "estate_charge"){ + newVal = FiledStrand.processEstateCharge(c, FiledStrand.getNumber(esVal), office.estate_type2) + if(newVal) { + newVal = newVal.toString() + } + } + if(seaweedfield == "build_date" || seaweedfield == "live_date"){ + newVal = FiledStrand.processFinishBuildingDate(esVal) + } + if(seaweedfield == "estate_company" || seaweedfield == "developer"){ + newVal = FiledStrand.processCompany(esVal) + } + if(seaweedfield =="virescence_percent"){ + newVal = FiledStrand.processVirescencePercent(esVal) + } + + if(seaweedfield == "loop_line_info"){ + newVal = FiledStrand.processLoopLine(esVal) + } + if(seaweedfield =="cubage_percent"){ + newVal = FiledStrand.processCubagePercent(esVal) + } + + if(seaweedfield =="all_area" || seaweedfield =="build_area" || seaweedfield=="sight"){ + newVal = FiledStrand.processArea(esVal.toString()) + if(newVal){ + newVal = newVal.toString() + } + } + + if(seaweedfield =="car_site_count" || seaweedfield =="land_car_site" || seaweedfield =="underground_car_site"){ + newVal = FiledStrand.processCarSite(esVal) + } + + if(seaweedfield =="property_life"){ + newVal = FiledStrand.processPropertyLife(esVal) + } + + if(seaweedfield =="address"){ + newVal = FiledStrand.processAddress(esVal, office.city) + } + if(seaweedfield =="block"){ + newVal = FiledStrand.processBlock(office.city, office.region, esVal) + } + + if(seaweedfield == "fitment"){ + newVal = FiledStrand.processFitment(esVal) + } + + if(seaweedfield == "build_type"){ + newVal = FiledStrand.processBuildType(esVal, "office") + } + if(seaweedfield == "build_structure"){ + newVal = FiledStrand.processBuildStructure(esVal) + } + if(seaweedfield == "bed_kind"){ + newVal = FiledStrand.processLevel(esVal) + } + + if(seaweedfield == "total_floor" || seaweedfield == "land_floor"){ + newVal = FiledStrand.processFloor(esVal) + } + + if(seaweedfield == "underground_floor"){ + newVal = FiledStrand.processUndergroundFloor(esVal) + } + + if(seaweedfield == "real_use_percent"){ + newVal = FiledStrand.processRealUsePercent(esVal) + } + if(seaweedfield == "parking_fee"){ + newVal = FiledStrand.processCarSiteRent(esVal) + println "[ ${source} ] old: "+esVal +" new:"+newVal + } + + if(seaweedfield == "elevators_count"){ + newVal = FiledStrand.processElevators(esVal) + } + if(seaweedfield == "person_elevators_count" && esVal.contains("客梯")){ + newVal = FiledStrand.processElevators(esVal.substring(esVal.indexOf("客梯"))) + } + + if(seaweedfield == "goods_elevator_count" && esVal.contains("货梯")){ + newVal = FiledStrand.processElevators(esVal.substring(esVal.indexOf("货梯"))) + } + + if(seaweedfield == "standard_height" || seaweedfield=="lobby_height" || seaweedfield=="clear_height"){ + newVal = FiledStrand.processStandardHeight(esVal) + } + + if(seaweedfield == "standard_area"){ + newVal = FiledStrand.processStandardArea(esVal.toString()) + } + + if(seaweedfield == "finish_building_date"){ + newVal = FiledStrand.processFinishBuildingDate(esVal) + } + if(seaweedfield == "foreign"){ + newVal = FiledStrand.processForeign(esVal) + } + + if(newVal){ + newValues.put(seaweedfield, newVal) + } + if(seaweedfield == "lng"){ + try{ + def locationMap = FiledStrand.processLngAndLat(esVal) + if(locationMap){ + newValues.put("lat", locationMap.lat) + newValues.put("lng", locationMap.lng) + newValues.put("lat2", locationMap.lat2) + newValues.put("lng2", locationMap.lng2) + } + }catch(Exception e){ + println esVal + } + } + } + } + } + return newValues; + } + + + def findAllEsDataByCity(city, source){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("source", source)) + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "office2", queryBuilder); + }catch(Exception e){ + datas = findAllEsDataByCity(city, source) + } + + return datas; + } + + def fieldUpdate(total,updateRets){ + + def countMap = [:] + + for(def rm : updateRets){ + def valMap = rm.value + fieldsMap.each{seaweedfield,esField-> + if(valMap.containsKey(seaweedfield)) { + if(countMap.containsKey(seaweedfield)) { + countMap.put(seaweedfield, countMap.get(seaweedfield) + 1) + }else{ + countMap.put(seaweedfield, 1) + } + } + } + } + + println countMap.toString() + def precentMap = [:] + fieldsMap.each() {key,skey-> + if(countMap.containsKey(key)) { + precentMap.put(key, DataHandleUtils.getDoubleRound(2, countMap.get(key)*100/total)) + }else { + precentMap.put(key, 0) + } + } + return precentMap; + } + + def updateDB(c, updateRets){ + + for(def rm : updateRets) { + def id = rm.key + def valMap = rm.value + + BasicDBObject udata = new BasicDBObject() + valMap.each {k,v-> + udata.put(k,v) + } + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(id)),new BasicDBObject('$set',udata)) + } + } + + + def fieldTempProcess(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\写字楼\\写字楼待处理地址.xlsx",{d-> + BasicDBObject udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("address", d['F']) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])),new BasicDBObject('$set',udata)) + }) + } + + def deleteNotNormalOffice(){ + ExcelUtils.modify("D:\\数据\\数据建设\\写字楼\\需删除写字楼.xlsx",{d-> + BasicDBObject udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("status", 1) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])),new BasicDBObject('$set',udata)) + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy new file mode 100644 index 000000000..eaae19e43 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy @@ -0,0 +1,254 @@ +package com.fangjia.script.gj.es + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils + +class OfficeStat { + static main(args) { + def task = new OfficeStat() +// task.run() +// task.sampleFieldPrecent() +// task.cityRun() + task.tempStat() + } + + def tempStat(){ + ExcelUtils.multiThreadingModify("D:\\数据\\写字楼\\写字楼租金统计.xlsx",{d-> + def cityObj = CommonDatautils.findAlCityDetail(d['A']) + if(cityObj){ + if(cityObj.new_city_grade==1000){ + d['P'] = "一线" + }else if(cityObj.new_city_grade==1500){ + d['P'] = "新一线" + }else if(cityObj.new_city_grade==2000){ + d['P'] = "二线" + }else if(cityObj.new_city_grade==3000){ + d['P'] = "三线" + }else if(cityObj.new_city_grade==4000){ + d['P'] = "四线" + }else if(cityObj.new_city_grade==5000){ + d['P'] = "五线" + } + } +// def count3s = [] +// if(d['C']>=3){ +// count3s << d['C'] +// } +// if(d['D']>=3 ){ +// count3s << d['D'] +// } +// if(d['E']>=3 ){ +// count3s << d['E'] +// } +// if(d['F']>=3 ){ +// count3s << d['F'] +// } +// if(d['G']>=3 ){ +// count3s << d['G'] +// } +// if(d['H']>=3 ){ +// count3s << d['H'] +// } +// if(d['I']>=3 ){ +// count3s << d['I'] +// } +// if(d['J']>=3 ){ +// count3s << d['J'] +// } +// if(d['K']>=3 ){ +// count3s << d['K'] +// } +// if(d['L']>=3 ){ +// count3s << d['L'] +// } +// if(d['M']>=3 ){ +// count3s << d['M'] +// } +// if(d['N']>=3 ){ +// count3s << d['N'] +// } +// d['O'] = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + },2) + } + + def sampleFieldPrecent(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["城市","区域","名称","级别","面积","最高楼","装修","单价(元/平米/天)","发布时间","总量"] + citys.each { c -> + def regionMap = CommonDatautils.getRegionsByCity(c) + def ret = sampleFieldStat(c, regionMap, "office_rent") + rets.addAll(ret) + } + ///home/goojia/gj + ExcelUtils.write("D:\\数据\\写字楼\\写字楼租金统计.xlsx", rets, "写字楼租金样本字段覆盖率") + } + def run(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["城市","区域","近1个月样本量","近2个月样本量","近3个月样本量","近4个月样本量","近5个月样本量","近6个月样本量","近7个月样本量","近8个月样本量","近9个月样本量","近10个月样本量","近11个月样本量","近12个月样本量","样本覆盖率(区域走势)" ] + citys.each{c-> + def regionMap = CommonDatautils.getRegionsByCity(c) + def ret = statHouse(c, regionMap, "office_rent") + rets.addAll(ret) + } + ExcelUtils.write("D:\\数据\\写字楼\\写字楼租金统计.xlsx", rets, "写字楼区域租金样本覆盖率") + } + + def cityRun(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["城市","区域","近1个月样本量","近2个月样本量","近3个月样本量","近4个月样本量","近5个月样本量","近6个月样本量","近7个月样本量","近8个月样本量","近9个月样本量","近10个月样本量","近11个月样本量","近12个月样本量","样本覆盖率(区域走势)" ] + citys.each{c-> + def ret = statCityHouse(c, "office_rent") + rets.addAll(ret) + } + ExcelUtils.write("D:\\数据\\写字楼\\写字楼租金统计.xlsx", rets, "写字楼城市租金样本覆盖率") + } + + def statHouse(city, regionMap, cat){ + def regions = regionMap.keySet() + def rows = [] + def months = [20250201, 20250101,20241201,20241101,20241001,20240901,20240801,20240701,20240601,20240501,20240401,20240301,20240201] + regions.each{region-> + def row = [] + row << city + row << region + + def count3s = [] + for(def i=1;i=3){ + count3s << count + } + } + def precent = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + row << precent + println row + rows << row + } + return rows + } + + def statCityHouse(city, cat){ + def months = [20250201, 20250101,20241201,20241101,20241001,20240901,20240801,20240701,20240601,20240501,20240401,20240301,20240201] + def row = [] + row << city + + def count3s = [] + for(def i=1;i=3){ + count3s << count + } + } + def precent = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + row << precent + println row + return row + } + + def sampleFieldStat(city, regionMap, cat){ + def regions = regionMap.keySet() + def rows = [] + regions.each{region-> + def results = findHouseByCat(city, region, cat, 20240201,20250201) + def row = [] + def total = results.size() + def nameCount = 0 + def levelCount = 0 + def heightCount = 0 + def areaCount = 0 + def priceCount = 0 + def dateCount = 0 + def fitmentCount = 0 + row << city + row << region + results.each{m-> + def name = m.get("name") + if(name){ + nameCount++ + } + + def level = m.get("level") + if(level){ + levelCount++ + } + + def height = m.get("height") + if(height){ + heightCount++ + } + + def fitment = m.get("fitment") + if(fitment){ + fitmentCount++ + } + + def area = m.get("area") + if(area){ + areaCount++ + } + def day_rent_price = m.get("day_rent_price") + if(day_rent_price){ + priceCount++ + } + + def p_date = m.get("p_date") + if(p_date){ + dateCount++ + } + } + if(total){ + row << DataHandleUtils.getDoubleRound(4, nameCount/total) + row << DataHandleUtils.getDoubleRound(4, levelCount/total) + row << DataHandleUtils.getDoubleRound(4, areaCount/total) + row << DataHandleUtils.getDoubleRound(4, heightCount/total) + row << DataHandleUtils.getDoubleRound(4, fitmentCount/total) + row << DataHandleUtils.getDoubleRound(4, priceCount/total) + row << DataHandleUtils.getDoubleRound(4, dateCount/total) + }else{ + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + } + + row << total + rows << row + println row + } + return rows + } + + + def findHouseCountByCat(def city, def region, def cat, def startDate, def endDate){ + + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} " + if(region){ + sql = sql + " and region='${region}'" + } + def total = 0 + ElasticUtils.executeSqlQuery(sql,{ data-> + total = data.c + }) + return total + } + + def findHouseByCat(def city, def region, def cat, def startDate, def endDate){ + + String sql = "select * from latest_seawater where cat='${cat}' and city='${city}' and region='${region}' and p_date >= ${startDate} and p_date<${endDate} " + def results =[] + ElasticUtils.executeSqlQuery(sql,{ data-> + results << ["level":data.level,"name":data.district_name,"day_rent_price":data.total_price,"height":data.height,"area":data.area,"p_date":data.p_date,"fitment":data.fitment] + }) + return results + } +} From 08ce3b2483f9b91786a80e086f36d55fb2d7ac54 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Wed, 19 Mar 2025 09:05:48 +0800 Subject: [PATCH 181/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 16 ++ .../gj/data_handle/AutoAddOfficeBatch.groovy | 166 ++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.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 82cffedbd..0d3647ee2 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 @@ -7,6 +7,7 @@ import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DataStore import com.fangjia.httpclient.UserAgents import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.newDistrict.InvokeHttpRequest import com.fangjia.script.util.* @@ -5544,4 +5545,19 @@ class CommonDatautils { return bk_business_coll.find(q).toList() } + + static def findOfficeByMap(city, small_type){ + + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("small_type", small_type)) + def rets = [] + def index= 0 + ElasticUtils89.executeQuery("192.168.0.89", "gaode_map_poi_2024", queryBuilder, { String id, Map map-> +// if(map.address && map.address.contains("五角场")){ + + index++ + rets << ["map_id":map.data_id,"province":map.province,"city":map.city, "district":map.district, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.lon, "lat":map.location.lat, "parent_id":map.parent] +// } + }) + return rets; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy new file mode 100644 index 000000000..7064d5eb2 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -0,0 +1,166 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.BaseBatch +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.ExcelUtils + +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 AutoAddOfficeBatch extends BaseBatch{ + + def fullCityMap = CommonDatautils.queryFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + runBatch(new AutoAddOfficeBatch(), args) + } + + @Override + void process(Object args) { + +// def pattern = /[A-Z]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|/ +// println "开放广场商务写字楼C栋".replaceAll(pattern, "") + + def citys = ["临沂"]//CommonDatautils.findAllCity() + for(def c : citys){ + def cityObj = fullCityMap.get(c) + if(cityObj){ + def officeMaps = CommonDatautils.findOfficeByMap(cityObj.city, "商务写字楼") + officeMaps = filterOffice(officeMaps) + def offices = matchOffice(officeMaps) + ExcelUtils.write("D:\\数据\\高德写字楼.xlsx", offices, "数据") + } + } + } + + def filterOffice(officeMaps){ + def offices = [] + def keys = [] + for(def o : officeMaps){ + println o.map_id + if(o.name.startsWith("写字楼") || o.name.startsWith("综合楼") || o.name.contains("销售") || o.name.startsWith("办公楼") || o.name.startsWith("公务楼") || o.name.startsWith("行政楼") || o.name.startsWith("商务办公楼") || o.name.contains("综合办公楼")){ + println "[ 过滤 ] "+o.city+" "+o.name + continue + } + if(o.name.contains("路写字楼")){ + println "[ 过滤 ] "+o.city+" "+o.name + continue + } + + def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|.|[A-Z]楼|[0-9]幢/ + o.name = o.name.replaceAll(pattern, "") + + def keyName = o.city +"#"+o.district+"#"+o.name + if(!keys.contains(keyName)){ + offices << o + keys << keyName + } + } + println "原:"+officeMaps.size() +" 新:"+offices.size() + return offices + } + + def matchOffice(offices){ + def totalCount = new AtomicLong() + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(offices.size()) + def total = offices.size() + def rets = new CopyOnWriteArrayList() + rets << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] + for(def i=0;i=1){ + office = rets[0] + } + }else{ + rets = CommonDatautils.findDistrictByAlias(simpleCity, simpleDistrict, nmd.name, "office") + if(rets && rets.size()>=1){ + office = rets[0] + }else{ + rets = CommonDatautils.findDistrictByAddress(simpleCity, simpleDistrict, nmd.name, "district") + if(rets && rets.size()>=1){ + office = rets[0] + } + } + } + if(office){ + office.match_way = "数据库" + } + return office + } + return null + } + + def matchApi(nmd){ + def address = nmd.city + if(nmd.district){ + address = address + nmd.district + } + address = address + nmd.name + def jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) + if(!jsonObject){ + if(DataUtil.isPreciseAddress(nmd.address)){ + address = nmd.city + if(nmd.district){ + address = address + nmd.district + } + address = address + nmd.address + jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) + } + } + if(jsonObject) { + def udata = [:] + udata.put("_id",jsonObject.get("id")) + udata.put("city",jsonObject.get("city")) + udata.put("region",jsonObject.get("district")) + udata.put("name",jsonObject.get("name")) + udata.put("match_type",jsonObject.get("propertyType")) + udata.put("match_credit",jsonObject.get("credit")) + udata.put("match_way", "接口") + return udata + } + return null + } +} From 4c57339a14f2a2fa7c13d48041727d6cf79a910b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 19 Mar 2025 09:11:05 +0800 Subject: [PATCH 182/247] update --- .../script/commData/CommonDatautils.groovy | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 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 82cffedbd..243df20ce 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 @@ -757,7 +757,10 @@ class CommonDatautils { DBObject q = new BasicDBObject(); q.put("city", city); - q.put("region", region); + if(region){ + q.put("region", region); + } + q.put("name", name); q.put("cat", cat) q.put("status", 0) @@ -788,7 +791,8 @@ class CommonDatautils { keys.put(field, 1); } } - def dbsour = DbUtils.seaweed.find(q, keys).batchSize(2000) + + def dbsour = SEAWEED_COLL.find(q, keys).batchSize(2000) // def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) def rets = [] for(def d : dbsour){ @@ -1133,6 +1137,26 @@ class CommonDatautils { return ret; } + public static def findNormalDistrict(String city, String region, String name, String cat, List fields){ + + DBObject q = new BasicDBObject(); + q.put("city", city); + q.put("cat", cat); + q.put("name", name); + if(region){ + q.put("region", region); + } + q.put("status",0) + + DBObject keys = new BasicDBObject(); + if(fields){ + for(def field : fields){ + keys.put(field, 1); + } + } + return SEAWEED_COLL.findOne(q, keys); + } + public static def findDistrictsByCityAndName(String city, String name, String cat){ DBObject q = new BasicDBObject(); q.put("city", city); @@ -4238,6 +4262,16 @@ class CommonDatautils { return map } + static def findThirdNetWorkOffices(city, region, name){ + String sql = "select * from office where city='${city}' and region='${region}' and name='${name}'" + def datas = [] + + ElasticUtils.executeSqlQuery(sql, { m-> + datas << m + }) + return datas + } + static def findThirdNetWorkOffice(){ String sql = "select city,region,name,address,location from office where city='烟台' or city='北京'" @@ -5173,6 +5207,46 @@ class CommonDatautils { } + + static def queryAllTown(fields){ + + def q = new BasicDBObject() + q.put("type","乡镇街道") + + def keys = new BasicDBObject() + for(def key : fields){ + keys.put(key,1) + } + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + def cityMap = [:] + for(def d : dbcursor){ + def townMap = cityMap.get(d.city) + if(!townMap){ + townMap = [:] + cityMap.put(d.city, townMap) + } + + def distName = null + if(d.mzb_district_name){ + distName = d.mzb_district_name + }else{ + distName = d.district + } + if(distName){ + def list = townMap.get(distName) + if(!list){ + list = [] + } + list << d + townMap.put(distName, list) + } + } +// println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss") + return cityMap + } + + + static def queryFullRegionTownByCity(city, fields){ def q = new BasicDBObject() From 06bef07b17808b62cae686b9135cf6de15151101 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 19 Mar 2025 16:00:40 +0800 Subject: [PATCH 183/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/bkoff/controllers/DataController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java index 7628d085f..3aae49c4d 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java @@ -1071,6 +1071,8 @@ public class DataController { map.put("divisible", "是否可分割"); map.put("landFloor","地上层数"); map.put("undergroundFloor","地下层数"); + map.put("rentPrice","租金价格"); + map.put("halfYearRentPrice","近半年租金价格"); return map; } From e1ecabc222ca1d1613646354c83b28d85a045b28 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Wed, 19 Mar 2025 17:32:18 +0800 Subject: [PATCH 184/247] =?UTF-8?q?=E5=9F=8E=E5=B8=82=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97=E6=A5=BC=E5=87=BA=E7=A7=9F?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E7=BB=9F=E8=AE=A1=E5=8F=8A=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E6=8D=A2=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dataAna/CityInfoAnaBatch.groovy | 271 ++++++++++-------- 1 file changed, 150 insertions(+), 121 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy index 8511662a1..004acafbe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy @@ -1,8 +1,18 @@ package com.fangjia.script.dataAna -import com.fangjia.script.ccbevaluation.CcbCommonUtils -import com.fangjia.script.commData.CommonDatautils +import com.fangjia.core.util.DateUtil +import com.fangjia.datastore.driver.DSCursor +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.Jms import com.fangjia.script.util.MongoUtils +import com.google.common.collect.Lists +import com.google.common.collect.Sets +import com.mongodb.* +import org.apache.commons.codec.digest.DigestUtils import java.text.DecimalFormat import java.util.concurrent.CountDownLatch @@ -10,30 +20,6 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.Semaphore -import org.apache.commons.codec.digest.DigestUtils -import org.bson.types.ObjectId - -import com.fangjia.core.util.DataUtil -import com.fangjia.core.util.DateUtil -import com.fangjia.datastore.driver.DSCollection -import com.fangjia.datastore.driver.DSCursor -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.util.DbUtils -import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.Jms -import com.google.common.collect.Lists -import com.google.common.collect.Sets -import com.mongodb.BasicDBList -import com.mongodb.BasicDBObject -import com.mongodb.Bytes -import com.mongodb.DBCollection -import com.mongodb.DBCursor -import com.mongodb.DBObject -import com.mongodb.Mongo - @BatchOwner(Watcher.LiXue) class CityInfoAnaBatch extends BaseBatch { @@ -53,8 +39,10 @@ class CityInfoAnaBatch extends BaseBatch { final static DBCollection LOUDONG_CONN = MongoUtils.getCollectionByName("fangjia_base", "loudong", MongoUtils.MongoDB_Domain_mongo); final static DBCollection fsDB = MongoUtils.getCollectionByName("fangjia_fs", "files", MongoUtils.MongoDB_Domain_fs_mongo, 27000); final static DBCollection FACILITY_CONN = MongoUtils.getCollectionByName("fangjia", "district_facilitys", MongoUtils.MongoDB_Domain_mongo) + final static DBCollection OFFICE_RENT_STAT_CONN = MongoUtils.getCollectionByName("fangjia_stat", "office_rent_stat", MongoUtils.MongoDB_Domain_mongo); static Jms jms = Jms.create('tcp://jms.db.fangjia.com:61616') - final static DSCollection SEAWEED = DbUtils.seaweed +// final static DSCollection SEAWEED = DbUtils.seaweed + static final DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) final static def CITYS = []; @@ -125,7 +113,7 @@ class CityInfoAnaBatch extends BaseBatch { SERVER_AREA_CONN.find(cityQuery).each { allCitys.put(it.display, it); } allCitys.each {k,v -> -// if(["南京"].contains(k.toString())){ +// if(["北京"].contains(k.toString())){ CITYS << k.toString(); // } } @@ -140,72 +128,47 @@ class CityInfoAnaBatch extends BaseBatch { // 城市小区数 def allCityDisCount = [:]; - LinkedHashMap facet = new LinkedHashMap(2); - facet.put("fields", ["city"]); - facet.put('limit', 500); - - DBObject disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'district'); - - DSCursor sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - List disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityDisCount.put(it.name, it.count.intValue()); - } + BasicDBObject match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "district")); + DBObject groupFields = new BasicDBObject(); + groupFields.put("_id", new BasicDBObject("city", '$city')) + groupFields.put("count", new BasicDBObject('$sum', 1)); + DBObject group = new BasicDBObject('$group', groupFields); + // 定义聚合管道,按 city 字段分组,并计算每个城市的数量 + AggregationOutput output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityDisCount.put(obj.get("city"), result.get("count")) } // 城市新盘数 def allCityNewDisCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'new_district'); - - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityNewDisCount.put(it.name, it.count.intValue()); - } + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "new_district")); + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityNewDisCount.put(obj.get("city"), result.get("count")) } // 城市写字楼数 def allCityOfficeCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'office'); + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "office")); - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityOfficeCount.put(it.name, it.count.intValue()); - } + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityOfficeCount.put(obj.get("city"), result.get("count")) } - // 城市商铺数 def allCityShopCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'shop'); + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "shop")); - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityShopCount.put(it.name, it.count.intValue()); - } + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityShopCount.put(obj.get("city"), result.get("count")) } + // 城市均价 def allCityStats = [:]; query = new BasicDBObject(); @@ -220,10 +183,10 @@ class CityInfoAnaBatch extends BaseBatch { doProcess(allCitys.get(it), weekend, laseWeekend, allHouseStats, allCityDisCount, allCityNewDisCount, allCityOfficeCount, allCityShopCount, allCityStats); } - //统计有楼栋的小区数和有房号的小区数 -// countDistrictsHasLoudong(allCitys, weekend) - //countDistrictsHasLoudongNew(allCitys, weekend) - +// //统计有楼栋的小区数和有房号的小区数 +//// countDistrictsHasLoudong(allCitys, weekend) +// //countDistrictsHasLoudongNew(allCitys, weekend) +// final CountDownLatch latch = new CountDownLatch(CITYS.size()) final Semaphore semaphore = new Semaphore(10) CITYS.each { @@ -239,13 +202,13 @@ class CityInfoAnaBatch extends BaseBatch { } finally { semaphore.release() latch.countDown() - } + } }; }) } latch.await() println "${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())}\t楼栋覆盖率统计完成" - + latch = new CountDownLatch(CITYS.size()) semaphore = new Semaphore(10) CITYS.each { @@ -267,12 +230,12 @@ class CityInfoAnaBatch extends BaseBatch { } latch.await() println "${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())}\t房号覆盖率统计完成" - - + + //71个城市的覆盖率统计 sendCountData(weekend) - - + + //最后统计之前因为太慢取消统计的本周估价次数 latch = new CountDownLatch(CITYS.size()) semaphore = new Semaphore(10) @@ -292,14 +255,14 @@ class CityInfoAnaBatch extends BaseBatch { query.put('city', cityName); query.put('c_date', new BasicDBObject('$gte', laseWeekend).append('$lte', weekend)); entity.put('evaluation_count', (int) EVALUATION_CONN.count(query)); - + if (entity.get('evaluation_count')) { entity.put('price_to_eva', DataUtil.roundDouble(entity.get('price_total_count'), entity.get('evaluation_count'))); } CITY_INFO_CONN.save(entity) println cityName+"本周估价次数统计完毕" } - + } catch (Exception e) { println e.getMessage() } finally { @@ -585,8 +548,8 @@ class CityInfoAnaBatch extends BaseBatch { print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} 小区完成]" -// if (allCityNewDisCount.get(cityName)) { -// def newDisCount = allCityNewDisCount.get(cityName); +// if (allCityNewDisCount.get(cityName)) { +// def newDisCount = allCityNewDisCount.get(cityName); // entity.put('new_district_detail', newDistrictDetail(newDisCount, cityName)); // } else { // entity.put('new_district_detail', [:]); @@ -604,23 +567,30 @@ class CityInfoAnaBatch extends BaseBatch { if (officePrices) { detail.put('price', roundDouble(officePrices.size(), officeCount)); } - - query = new BasicDBObject(); - query.put('city', cityName); - query.put('kind', '写字楼'); - query.put('weekend', weekend); - def officeRents = RENT_STAT_CONN.distinct("name", query); + + def officeRents = findOfficeRent(cityName) if (officeRents) { detail.put('rentPrice', roundDouble(officeRents.size(), officeCount)); } + + def halfYearofficeRentCount = findHalfYearOfficeRentCount(cityName) + if (halfYearofficeRentCount) { + detail.put('halfYearRentPrice', roundDouble(halfYearofficeRentCount, officeCount)); + } + entity.put('office_detail', detail); entity.put('existing_office_count', officeCount); } else { entity.put('office_detail', [:]); } - - print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} 写字楼完成]" + +// if(curInfo){ +// CITY_INFO_CONN.update(new BasicDBObject("_id", curInfo._id), new BasicDBObject('$set', entity)) +// print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} 写字楼完成]" +// } + + if (entity.get('official_population') && entity.get('district_avg_population')) { entity.put('prediction_district_count', (int) (entity.get('official_population') / entity.get('district_avg_population'))); @@ -628,12 +598,12 @@ class CityInfoAnaBatch extends BaseBatch { entity.put('district_coverage', roundDouble(entity.get('existing_district_count'), entity.get('prediction_district_count'))); } } - - + + if (allCityShopCount.get(cityName)) { def shopCount = allCityShopCount.get(cityName); def detail = shopDetail(shopCount, cityName); - + DBObject query = new BasicDBObject(); query.put('city', cityName); //query.put('estate_type', '商铺'); @@ -642,7 +612,7 @@ class CityInfoAnaBatch extends BaseBatch { if (shopPrices) { detail.put('price', roundDouble(shopPrices.size(), shopCount)); } - + query = new BasicDBObject(); query.put('city', cityName); query.put('kind', '商铺'); @@ -651,45 +621,41 @@ class CityInfoAnaBatch extends BaseBatch { if (shopRents) { detail.put('rentPrice', roundDouble(shopRents.size(), shopCount)); } - + entity.put('shop_detail', detail); entity.put('existing_shop_count', shopCount); }else { entity.put('shop_detail', [:]); } print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} 商铺完成]" - + def cityStat = allCityStats.get(cityName); if (cityStat) { entity.put('avg_price', cityStat.avg_price); } - + DBObject query = new BasicDBObject(); query.put('city', cityName); query.put('c_date', new BasicDBObject('$gte', lastWeekend).append('$lte', weekend)); //entity.put('evaluation_count', (int) EVALUATION_CONN.count(query));由于估价记录数据量大,查询慢,先去掉这个,最后面在用多线程统计 entity.put('price_total_count', (int) PRICE_JIUCUO_CONN.count(query)); - + query.put('price_lev', '偏高'); entity.put('price_high_count', (int) PRICE_JIUCUO_CONN.count(query)); - + query.put('price_lev', '偏低'); entity.put('price_low_count', (int) PRICE_JIUCUO_CONN.count(query)); - + /*if (entity.get('evaluation_count')) {由于估价记录数据量大,查询慢,先去掉这个,最后面在用多线程统计 entity.put('price_to_eva', roundDouble(entity.get('price_total_count'), entity.get('evaluation_count'))); }*/ - + if (entity.get('price_high_count')) { entity.put('low_to_high', roundDouble(entity.get('price_low_count'), entity.get('price_high_count'))); } - + print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} 估价完成]" - - - - - + // query = new BasicDBObject(); // query.put('city', cityName); // query.put('weekend', weekend); @@ -710,7 +676,7 @@ class CityInfoAnaBatch extends BaseBatch { // } // } // } -// +// // if (total > 0) { // BigDecimal bg = new BigDecimal(webZhunque * 1.0 / total); // entity.put('web_average', bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()); @@ -1284,7 +1250,7 @@ class CityInfoAnaBatch extends BaseBatch { fields.put(key, 1) } - DSCursor cur = SEAWEED.find(query, fields).batchSize(2000) + def cur = SEAWEED.find(query, fields).batchSize(2000) Iterator iter = cur.iterator() def countMap = [:] println cur.count() @@ -1335,7 +1301,7 @@ class CityInfoAnaBatch extends BaseBatch { fields.put(key, 1) } - DSCursor cur = SEAWEED.find(query, fields).batchSize(2000) + def cur = SEAWEED.find(query, fields).batchSize(2000) Iterator iter = cur.iterator() def countMap = [:] @@ -1546,6 +1512,69 @@ class CityInfoAnaBatch extends BaseBatch { } return true; } + + def findOfficeRent(cityName){ + def query = new BasicDBObject(); + query.put('city', cityName); +// query.put('kind', '写字楼'); +// query.put('weekend', weekend); +// def officeRents = RENT_STAT_CONN.distinct("name", query); +// if (officeRents) { +// detail.put('rentPrice', roundDouble(officeRents.size(), officeCount)); +// } + query.put('cat', 'office'); + def date1 = new Date() + date1.setDate(28) + if(new Date().getTime()> date1.getTime()){ + query.put('date', Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM"))); + }else{ + query.put('date', Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM"))); + } + def officeRents = OFFICE_RENT_STAT_CONN.distinct("name", query); + return officeRents + } + + def findHalfYearOfficeRentCount(cityName){ + + def date1 = new Date() + date1.setDate(28) + def months = [] + if(new Date().getTime()> date1.getTime()){ + for(def i=1;i<=6;i++){ + months << Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1*i, "yyyyMM")) + } + }else{ + for(def i=2;i<=7;i++){ + months << Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1*i, "yyyyMM")) + } + } + def map = [:] + for(def month : months){ + def query = new BasicDBObject(); + query.put('city', cityName); + query.put('cat', 'office'); + query.put('date', month); + def officeRents = OFFICE_RENT_STAT_CONN.distinct("name", query); + + officeRents.each{k-> + def count = map.get(k) + if(!count){ + map.put(k, 1) + }else{ + map.put(k, count + 1) + } + + } + } + def total = 0 + map.each{k,v-> + if(v==6){ + total ++ + } + } + + return total + } } From 962118c1614700402914c10db18c88174e1213b1 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Mar 2025 09:34:29 +0800 Subject: [PATCH 185/247] update --- .../gj/data_handle/AutoAddOfficeBatch.groovy | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 7064d5eb2..cfa15156b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -25,27 +25,35 @@ class AutoAddOfficeBatch extends BaseBatch{ @Override void process(Object args) { -// def pattern = /[A-Z]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|/ -// println "开放广场商务写字楼C栋".replaceAll(pattern, "") +// def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|[A-Z]楼|[0-9]幢/ +// def newName = "开放广场".replaceAll(pattern, "") +// println newName - def citys = ["临沂"]//CommonDatautils.findAllCity() + def citys = CommonDatautils.findAllCity() + def allAddOffices = [] + allAddOffices << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] for(def c : citys){ def cityObj = fullCityMap.get(c) if(cityObj){ def officeMaps = CommonDatautils.findOfficeByMap(cityObj.city, "商务写字楼") officeMaps = filterOffice(officeMaps) - def offices = matchOffice(officeMaps) - ExcelUtils.write("D:\\数据\\高德写字楼.xlsx", offices, "数据") + if(officeMaps){ + def offices = matchOffice(officeMaps) + allAddOffices.addAll(offices) + } } } + ExcelUtils.write("D:\\数据\\高德写字楼.xlsx", allAddOffices, "数据") } def filterOffice(officeMaps){ def offices = [] def keys = [] for(def o : officeMaps){ - println o.map_id - if(o.name.startsWith("写字楼") || o.name.startsWith("综合楼") || o.name.contains("销售") || o.name.startsWith("办公楼") || o.name.startsWith("公务楼") || o.name.startsWith("行政楼") || o.name.startsWith("商务办公楼") || o.name.contains("综合办公楼")){ + if(!o){ + continue + } + if(o.name.startsWith("写字楼") || o.name.startsWith("综合楼") || o.name.contains("销售") || o.name.startsWith("办公楼") || o.name.startsWith("公务楼") || o.name.startsWith("行政楼") || o.name.startsWith("商务办公楼") || o.name.startsWith("综合办公楼")){ println "[ 过滤 ] "+o.city+" "+o.name continue } @@ -54,9 +62,9 @@ class AutoAddOfficeBatch extends BaseBatch{ continue } - def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|.|[A-Z]楼|[0-9]幢/ - o.name = o.name.replaceAll(pattern, "") - + def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|[A-Z]楼|[0-9]幢/ + def newName = o.name.replaceAll(pattern, "") + o.name = newName def keyName = o.city +"#"+o.district+"#"+o.name if(!keys.contains(keyName)){ offices << o @@ -68,12 +76,12 @@ class AutoAddOfficeBatch extends BaseBatch{ } def matchOffice(offices){ - def totalCount = new AtomicLong() + def addCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(offices.size()) def total = offices.size() def rets = new CopyOnWriteArrayList() - rets << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] + for(def i=0;i Date: Thu, 20 Mar 2025 10:54:06 +0800 Subject: [PATCH 186/247] updadte --- .../gj/data_handle/TempExportData.groovy | 143 +++++++++++++++++- 1 file changed, 138 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy index d9d86dbf8..b5f4ceb7f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy @@ -1,7 +1,12 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -9,17 +14,79 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicLong +import java.util.regex.Pattern class TempExportData { - ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) - + ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + DBCollection qianzhan_coll = MongoUtils.getCollectionByName("crawl", "yuanqu_qianzhan_com_map", "192.168.0.206", 27020) static main(args) { def task = new TempExportData() // task.run() - def rets = task.fzHouseStat() - ExcelUtils.write("/home/goojia/gj/福州小区房源及第三方情况统计.xlsx", rets,"数据") - println "文件已生成" +// def rets = task.fzHouseStat() +// ExcelUtils.write("/home/goojia/gj/福州小区房源及第三方情况统计.xlsx", rets,"数据") +// println "文件已生成" +// exportDistShape() +// task.exportDistrictAlias() + task.exportOfficeHouseCount() + } + + def exportDistShape(){ + def task = new BasicDBObject() + } + + def exportDistrictAlias(){ + def citys = CommonDatautils.findAllCity() + def allRets = [] + allRets << ["Id","城市","区域","名称","地址","已删ID","已删区域","已删名称","已删地址","距离"] + + for (def city : citys) { + def dists = CommonDatautils.findAllDistricts(city, "district", ["city", "region", "name", "address", "alias", "lat","lng"]) + def rets = findDelDistBatch(dists) + allRets.addAll(rets) + } + ExcelUtils.write("D:\\数据\\数据建设\\小区\\融合存疑小区.xlsx",allRets, "小区") + } + + + def findDelDistBatch(dists){ + def rets = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + for(def i=0;i + total = data.c + }) + return total + } + + def findYuanQu(city, name){ + def q = new BasicDBObject("name", Pattern.compile("^${name}")) + def dbcursor = qianzhan_coll.find(q) + def obj = null + for(def d : dbcursor){ + if(d.city.contains(city)){ + obj = d + break; + } + } + return obj + } + + def exportOfficeHouseCount(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\写字楼\\待核实写字楼.xlsx",{d-> +// def obj = findYuanQu(d['B'], d['D']) +// if(obj){ +// d['T'] = "前瞻存在" +// } +// if(!d['T']){ +// def obj = findYuanQu(d['B'], d['D']) +// if(obj){ +// d['U'] = obj.name +// } +// } +// if(!d['T']) { +// def count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_sell") +// if (!count) { +// count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_rent") +// } +// d['S'] = count +// } + + if(!d['J']){ + def datas = CommonDatautils.findThirdNetWorkOffices(d['B'], d['C'], d['D']) + if(datas){ + def sources = [] + for(def o : datas){ + sources << o.source + } + if(sources){ + d['K'] = sources.join(",") + } + } + } + }) + } + } \ No newline at end of file From d8e781617c663862bd8e502471ee2eb85c8e5674 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 21 Mar 2025 16:51:14 +0800 Subject: [PATCH 187/247] =?UTF-8?q?=E8=80=81=E8=84=9A=E6=9C=AC=E6=9F=A5?= =?UTF-8?q?=E6=88=BF=E6=BA=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistrictDealSellRentRankBatch.groovy | 255 +++++++++++++----- 1 file changed, 187 insertions(+), 68 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy index 5b9e5d8b5..b670962db 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy @@ -1,6 +1,5 @@ package com.fangjia.script.district -import com.fangjia.core.util.DataUtil import com.fangjia.core.util.DateUtil import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCursor @@ -9,11 +8,20 @@ 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.util.ElasticUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject +import org.elasticsearch.index.query.BoolQueryBuilder +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong /** * Created by dxy on 2016/12/15. */ @@ -26,6 +34,10 @@ class DistrictDealSellRentRankBatch extends BaseBatch { private static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") private static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName("fangjia", "house_loudong", "mongo.db.fangjia.com") private static final DBCollection DISTRICT_ANALY_DATA_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_analy_data", "mongo.db.fangjia.com") + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(60) + // 最大重试次数 + private static final int MAX_TRY_COUNT = 5; + public void process(Object args) { def cities = [ @@ -47,7 +59,7 @@ class DistrictDealSellRentRankBatch extends BaseBatch { "图木舒克","五家渠","济源","仙桃","潜江","天门","景德镇", "神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水", "保亭","琼中","北屯","铁门关","双河","可克达拉" ] -// cities = ["无锡"] + cities = ["鹤岗"] println cities for(String city : cities) { List districts = findDistrictByCity(city) @@ -63,14 +75,14 @@ class DistrictDealSellRentRankBatch extends BaseBatch { for(DBObject district : districts) { String key = district.get("name").toString().trim() + "_" + district.get("region") + "_" + district.get("city") long sellCount = sellCountMap.get(key) ? sellCountMap.get(key) : 0 - if(district.get('alias')) { - for (String ali : district.get('alias')) { - if(ali) { - String skey = ali.toString().trim() + "_" + district.get("region") + "_" + district.get("city") - sellCount += (sellCountMap.get(skey) ? sellCountMap.get(skey) : 0) - } - } - } +// if(district.get('alias')) { +// for (String ali : district.get('alias')) { +// if(ali) { +// String skey = ali.toString().trim() + "_" + district.get("region") + "_" + district.get("city") +// sellCount += (sellCountMap.get(skey) ? sellCountMap.get(skey) : 0) +// } +// } +// } sellCountsList << (int)sellCount } sellCountsList = sellCountsList.unique() @@ -219,67 +231,74 @@ class DistrictDealSellRentRankBatch extends BaseBatch { } private def findDistrictHouseCount(String city, List districts, Date date) { - def regionDistrictMap = [:] - for(DBObject dbo : districts) { - def names = [] - String n = DataUtil.escapeSolr(dbo.get('name')) - if(n) { - names << n - } - if(dbo.get("alias")) { - for(String ali : dbo.get("alias")) { - ali = DataUtil.escapeSolr(ali) - if(ali) { - names << ali - } - } - } - String region = dbo.get('region') - if(!regionDistrictMap.containsKey(region)) { - regionDistrictMap.put(region, names) - }else { - def list = regionDistrictMap.get(region) - list.addAll(names) - regionDistrictMap.put(region, list) - } - } + def startDate = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(DateUtil.addMonthToDate(date, -1)),"yyyyMMdd") + def endDate = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(date),"yyyyMMdd") + Map monthMap = findAllCommHouse(city, districts, startDate.toInteger(), endDate.toInteger()) - Map halfMap = new HashMap(); - Map monthMap = new HashMap(); - for(String region : regionDistrictMap.keySet()) { - def nameGroups = [] - int len = 0 - def nameList = [] - for(String name : regionDistrictMap.get(region)) { - if(len >= 600 || nameList.size() >= 100) { - nameGroups << new ArrayList(nameList); - nameList.clear() - len = 0 - } - len += name.length() - nameList << name - } - if(nameList.size() > 0) { - nameGroups << new ArrayList(nameList); - } + def startDate2 = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(DateUtil.addMonthToDate(date, -6)),"yyyyMMdd") + Map halfMap = findAllCommHouse(city, districts, startDate2.toInteger(), endDate.toInteger()) - println city + "\t" + region + "\t" + regionDistrictMap.get(region).size() + "/" + nameGroups.size() + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()) - for(List names : nameGroups) { - def halfRegionResult = [:] - def monthRegionResult = [:] - try { - halfRegionResult = facetDistrictCount(city, region, names, date, 7) - monthRegionResult = facetDistrictCount(city, region, names, date, 2) - }catch (e) { - sleep(10 * 1000) - halfRegionResult = facetDistrictCount(city, region, names, date, 7) - monthRegionResult = facetDistrictCount(city, region, names, date, 2) - } - halfMap.putAll(halfRegionResult) - monthMap.putAll(monthRegionResult) - } - } +// def regionDistrictMap = [:] +// for(DBObject dbo : districts) { +// def names = [] +// String n = DataUtil.escapeSolr(dbo.get('name')) +// if(n) { +// names << n +// } +// if(dbo.get("alias")) { +// for(String ali : dbo.get("alias")) { +// ali = DataUtil.escapeSolr(ali) +// if(ali) { +// names << ali +// } +// } +// } +// +// String region = dbo.get('region') +// if(!regionDistrictMap.containsKey(region)) { +// regionDistrictMap.put(region, names) +// }else { +// def list = regionDistrictMap.get(region) +// list.addAll(names) +// regionDistrictMap.put(region, list) +// } +// } +// +// +// for(String region : regionDistrictMap.keySet()) { +// def nameGroups = [] +// int len = 0 +// def nameList = [] +// for(String name : regionDistrictMap.get(region)) { +// if(len >= 600 || nameList.size() >= 100) { +// nameGroups << new ArrayList(nameList); +// nameList.clear() +// len = 0 +// } +// len += name.length() +// nameList << name +// } +// if(nameList.size() > 0) { +// nameGroups << new ArrayList(nameList); +// } +// +// println city + "\t" + region + "\t" + regionDistrictMap.get(region).size() + "/" + nameGroups.size() + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()) +// for(List names : nameGroups) { +// def halfRegionResult = [:] +// def monthRegionResult = [:] +// try { +// halfRegionResult = facetDistrictCount(city, region, names, date, 7) +// monthRegionResult = facetDistrictCount(city, region, names, date, 2) +// }catch (e) { +// sleep(10 * 1000) +// halfRegionResult = facetDistrictCount(city, region, names, date, 7) +// monthRegionResult = facetDistrictCount(city, region, names, date, 2) +// } +// halfMap.putAll(halfRegionResult) +// monthMap.putAll(monthRegionResult) +// } +// } return [halfMap, monthMap]; } @@ -352,6 +371,106 @@ class DistrictDealSellRentRankBatch extends BaseBatch { return ret } + def findAllCommHouse(city, districts, startDate, endDate){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(districts.size()) + println city +" 小区量:"+districts.size() + + def retMap = new ConcurrentHashMap() + for(def i=0;i0){ + BoolQueryBuilder inBuilder = QueryBuilders.boolQuery(); + for(def s : alias){ + inBuilder.should(QueryBuilders.matchQuery("district_name", s)); + } + queryBuilder.must(inBuilder) + } + + def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"] + def index = new Random().nextInt(6); + + def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder); + return houses.size(); + } + + + static main(args) { runBatch(new DistrictDealSellRentRankBatch(), args) } From 732abc661edefa24b3e01ce05f8d774186cbf1c8 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 21 Mar 2025 17:02:20 +0800 Subject: [PATCH 188/247] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy index 6c8d9c9a8..5107646d1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy @@ -32,9 +32,9 @@ class CPDBAvgGrowthRateBatch extends BaseBatch { @Override public void process(Object args) { - println "开始统计cpdb抵押品库中平均增长率排名" - cpdb_price_coll.remove(new BasicDBObject("date", getBeforeMonth(-1))) - stat() +// println "开始统计cpdb抵押品库中平均增长率排名" +// cpdb_price_coll.remove(new BasicDBObject("date", getBeforeMonth(-1))) +// stat() } def stat() { @@ -46,7 +46,7 @@ class CPDBAvgGrowthRateBatch extends BaseBatch { def region = data.region def name = data.original_district_name if (city && region && name) { - JSONObject json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) + JSONObject json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) JSONObject json2 = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-2)) if (json == null) { json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) From 165724defbed6b80edd67534102f702bb4cfe53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 24 Mar 2025 10:10:05 +0800 Subject: [PATCH 189/247] =?UTF-8?q?=E6=97=A0=E7=94=A8=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy index f05096eb1..ca0e3b0b8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy @@ -24,9 +24,9 @@ class PriceIncreaesLevelBatch extends BaseBatch { static DBCollection pds_price_increaes_level_coll = MongoUtils.getCollectionByName("fangjia_stat", "pds.pds_price_increaes_level", "mongo.db.fangjia.com", 27017) static DBCollection cpdb_price_coll = MongoUtils.getCollectionByName("fangjia_stat", "pds.cpdb_price", "mongo.db.fangjia.com", 27017) - static main(args) { - runBatch(new PriceIncreaesLevelBatch(), args) - } +// static main(args) { +// runBatch(new PriceIncreaesLevelBatch(), args) +// } @Override public void process(Object args) { From e04f7c0f431eea99dbb2c168776f74e7912680f6 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 14:21:13 +0800 Subject: [PATCH 190/247] =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/zsbank/DistrictLevelBatch.groovy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 6c1344eb9..3e2bb2862 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -8,9 +8,8 @@ import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection - /** - * 娴欏晢鏈湴鍖栭儴缃插悓姝ヨ剼鏈� + * 浙商本地化部署同步脚本 */ @BatchOwner(Watcher.GaoJuan) class DistrictLevelBatch extends BaseBatch{ @@ -31,7 +30,7 @@ class DistrictLevelBatch extends BaseBatch{ def datas = addPriceData(dists, priceMap); datas = calcuteLevel(datas); saveOrUpdateDB(city, datas); - println city +" 妤肩洏璇勭骇鍚屾瀹屾垚" + println city +" 楼盘评级同步完成" } } From 8ae91d49f97c329e4ddf948362788f18e850ddc0 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 14:23:56 +0800 Subject: [PATCH 191/247] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 3e2bb2862..99ca37d49 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -30,7 +30,7 @@ class DistrictLevelBatch extends BaseBatch{ def datas = addPriceData(dists, priceMap); datas = calcuteLevel(datas); saveOrUpdateDB(city, datas); - println city +" 楼盘评级同步完成" + println city +" 楼盘评级同步完成!" } } From 4928af6da1b170544913c3e584fc107901a16d7d Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 15:03:15 +0800 Subject: [PATCH 192/247] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=B8=8D=E6=8C=89=E5=9F=8E=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/zsbank/DistrictLevelBatch.groovy | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 99ca37d49..5f8cd208e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -16,12 +16,21 @@ class DistrictLevelBatch extends BaseBatch{ public static final def ZS_MONGODB_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; public static final DBCollection ZS_LEVEL_CONN = MongoUtils.getCollectionByName2("fangjia", "district_analy", ZS_MONGODB_URL) + public static final zsDistLevelMap = [:] + public static final zsDistLevels = [] static main(args) { runBatch(new DistrictLevelBatch(), args); } @Override public void process(Object args) { + + def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject()) + for(def distLevel : zsDistLevelCursor){ + zsDistLevelMap.put(distLevel._id.toString(), distLevel) + zsDistLevels << distLevel + } + def citys = CommonDatautils.findAllCity(); def weekend = DateUtils.getFirstDayOfWeek(new Date()); for(def city : citys){ @@ -92,13 +101,7 @@ class DistrictLevelBatch extends BaseBatch{ } def saveOrUpdateDB(city, datas){ - def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject("city",city)) - def zsDistLevelMap = [:] - def zsDistLevels = [] - for(def distLevel : zsDistLevelCursor){ - zsDistLevelMap.put(distLevel._id.toString(), distLevel) - zsDistLevels << distLevel - } + def newDataMap = [:] def addDatas = [] for(def d : datas){ From 800fbae9bd6dd7ce00e71183c2c26fd7741883f6 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 15:27:09 +0800 Subject: [PATCH 193/247] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/zsbank/DistrictLevelBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 5f8cd208e..9b0e7c63e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -28,7 +28,7 @@ class DistrictLevelBatch extends BaseBatch{ def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject()) for(def distLevel : zsDistLevelCursor){ zsDistLevelMap.put(distLevel._id.toString(), distLevel) - zsDistLevels << distLevel + zsDistLevels << distLevel._id.toString() } def citys = CommonDatautils.findAllCity(); @@ -132,8 +132,8 @@ class DistrictLevelBatch extends BaseBatch{ ZS_LEVEL_CONN.insert(addDatas); } if(zsDistLevels.size()>0){ - for(def zs : zsDistLevels){ - def newData = newDataMap.get(zs._id.toString()); + for(def zs_id : zsDistLevels){ + def newData = newDataMap.get(zs_id.toString()); if(!newData){ def udata = new BasicDBObject() udata.put("status",1) From 95b98d079387642e67e6495c7fd1400500beebfe Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 15:41:27 +0800 Subject: [PATCH 194/247] =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/zsbank/DistrictLevelBatch.groovy | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 9b0e7c63e..43c2826da 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -17,7 +17,6 @@ class DistrictLevelBatch extends BaseBatch{ public static final def ZS_MONGODB_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; public static final DBCollection ZS_LEVEL_CONN = MongoUtils.getCollectionByName2("fangjia", "district_analy", ZS_MONGODB_URL) public static final zsDistLevelMap = [:] - public static final zsDistLevels = [] static main(args) { runBatch(new DistrictLevelBatch(), args); @@ -28,7 +27,6 @@ class DistrictLevelBatch extends BaseBatch{ def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject()) for(def distLevel : zsDistLevelCursor){ zsDistLevelMap.put(distLevel._id.toString(), distLevel) - zsDistLevels << distLevel._id.toString() } def citys = CommonDatautils.findAllCity(); @@ -101,6 +99,11 @@ class DistrictLevelBatch extends BaseBatch{ } def saveOrUpdateDB(city, datas){ + def zsDistLevels = [] + def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject("city",city)) + for(def distLevel : zsDistLevelCursor){ + zsDistLevels << distLevel._id.toString() + } def newDataMap = [:] def addDatas = [] @@ -138,7 +141,7 @@ class DistrictLevelBatch extends BaseBatch{ def udata = new BasicDBObject() udata.put("status",1) udata.put("update_date",new Date().getTime()) - ZS_LEVEL_CONN.update(new BasicDBObject("_id",zs._id), new BasicDBObject('$set',udata)) + ZS_LEVEL_CONN.update(new BasicDBObject("_id",zs_id), new BasicDBObject('$set',udata)) } } } From ab46e0819d693c4a2900c5a26692e4958986ec63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 24 Mar 2025 16:31:26 +0800 Subject: [PATCH 195/247] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E9=BD=90=E6=A2=81?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 aa7564be2..eea2463b2 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 @@ -516,7 +516,7 @@ public class AddrSvcController { } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 - if (result.containsKey("province") && ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province")))) { + if (result.containsKey("province") && ("中国".equals(result.getString("province")))) { //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 //我们 type :1 对私 2 对共 @@ -658,7 +658,8 @@ public class AddrSvcController { } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { +// if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + if (result.containsKey("province") && ("中国".equals(result.getString("province")))) { //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 //我们 type :1 对私 2 对共 @@ -1026,7 +1027,9 @@ public class AddrSvcController { } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { +// if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + // 齐梁不可用,屏蔽 + if (result.containsKey("province") && ("中国".equals(result.getString("province")))) { //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 @@ -1171,7 +1174,8 @@ public class AddrSvcController { } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { +// if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + if (result.containsKey("province") && ("中国".equals(result.getString("province")))) { //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 From 6391d59c1f6350f64efd10c3ff7ac5dc00e92719 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 24 Mar 2025 16:53:05 +0800 Subject: [PATCH 196/247] test --- .../groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 43c2826da..e1cddfa83 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -9,7 +9,7 @@ import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection /** - * 浙商本地化部署同步脚本 + * 浙商本地化部署同步脚本-逻辑修改 */ @BatchOwner(Watcher.GaoJuan) class DistrictLevelBatch extends BaseBatch{ From e0be7b111cc56f34d4ebba95726fb927d327531a Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 26 Mar 2025 13:54:50 +0800 Subject: [PATCH 197/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E5=9F=8E=E5=B8=82=E5=87=BA=E5=94=AE=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mongo/dao/office/OfficeSellStatDao.java | 9 ++ .../dao/office/OfficeSellStatDaoImpl.java | 8 + .../dal/mongo/model/OfficeSellStat.java | 138 ++++++++++++++++++ .../controllers/OfficeSellController.java | 83 +++++++++++ .../service/datastore/OfficeService.java | 12 ++ .../service/datastore/OfficeServiceImpl.java | 49 ++++++- 6 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java new file mode 100644 index 000000000..272f601d5 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.OfficeSellStat; + +public interface OfficeSellStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java new file mode 100644 index 000000000..8cf424796 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.OfficeSellStat; + +public class OfficeSellStatDaoImpl extends MongoDaoImpl implements OfficeSellStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java new file mode 100644 index 000000000..1453d3e67 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java @@ -0,0 +1,138 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.util.Date; + +@Entity +@Table(name = "fangjia_stat.office_sell_stat") +public class OfficeSellStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private Integer date; + private String district; + private String name; + private Double avgPrice; + private String estateType2; + private String bedKind; + @JsonIgnore + private Object location; + private Integer calcType; + private Date updatedDate; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "estate_type2") + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } + + @Column(name = "bed_kind") + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } + + @Column(name = "location") + public Object getLocation() { + return location; + } + + public void setLocation(Object location) { + this.location = location; + } + + + @Column(name = "calc_type") + public Integer getCalcType() { + return calcType; + } + + public void setCalcType(Integer calcType) { + this.calcType = calcType; + } + + @Column(name = "updated_date") + public Date getUpdatedDate() { + return updatedDate; + } + + public void setUpdatedDate(Date updatedDate) { + this.updatedDate = updatedDate; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java new file mode 100644 index 000000000..74e306c6d --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -0,0 +1,83 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.OfficeSellStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.service.datastore.OfficeService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.annotation.Param; + +import java.util.List; + +/** + * @author liuhongyang + * @since 2025/3/25 + */ +@Authority(role = Role.USER) +public class OfficeSellController { + + private static final Logger LOGGER = LoggerFactory.getLogger(OfficeSellController.class); + + private OfficeService officeService; + + /** + * 城市写字楼出售均价 + * + * @return + */ + public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List sellList = officeService.findOfficeSellStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(sellList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有写字楼均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(sellList)); + return mav; + } + + public void setOfficeService(OfficeService officeService) { + this.officeService = officeService; + } + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index fe0b77dfe..a899bbbad 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -2,6 +2,7 @@ package com.fangjia.service.datastore; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.datastore.dto.OfficeEvaluationDto; @@ -41,4 +42,15 @@ public interface OfficeService { * @return */ OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation); + + /** + * 城市写字楼出售均价 + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index aedf7bddb..19cfedbc9 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -8,8 +8,10 @@ import com.fangjia.dal.QueryParam; import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.SortParam; import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao; +import com.fangjia.dal.mongo.dao.office.OfficeSellStatDao; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.datastore.dto.OfficeEvaluationDto; @@ -34,7 +36,7 @@ public class OfficeServiceImpl implements OfficeService { private OfficeRentStatDao officeRentStatDao; private SeawaterService seawaterService; - + private OfficeSellStatDao officeSellStatDao; @Override public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) { @@ -488,6 +490,47 @@ public class OfficeServiceImpl implements OfficeService { return regionStats; } + @Override + public List findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findOfficeSellStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindOfficeSellStat(city, region, name, cat, startDate, endDate); + } + }); + } + + public List doFindOfficeSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List sellStatList = officeSellStatDao.findAllByParams(params, sortParams); + return sellStatList; + } + public void setSeawaterService(SeawaterService seawaterService) { this.seawaterService = seawaterService; } @@ -495,4 +538,8 @@ public class OfficeServiceImpl implements OfficeService { public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) { this.officeRentStatDao = officeRentStatDao; } + + public void setOfficeSellStatDao(OfficeSellStatDao officeSellStatDao) { + this.officeSellStatDao = officeSellStatDao; + } } From 7d8eb63873d6ac16461aaf5b034a9fb8b5153123 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 26 Mar 2025 15:12:12 +0800 Subject: [PATCH 198/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E5=87=BA=E5=94=AE=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/OfficeSellController.java | 115 +++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java index 74e306c6d..53ab53d21 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -31,7 +31,7 @@ public class OfficeSellController { private OfficeService officeService; /** - * 城市写字楼出售均价 + * 写字楼城市出售均价 * * @return */ @@ -76,6 +76,119 @@ public class OfficeSellController { return mav; } + /** + * 写字楼区域出售均价 + * + * @return + */ + public Object districtSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = officeService.findOfficeSellStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼出售均价走势 + * + * @return + */ + public Object officeSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = officeService.findOfficeSellStat(city, region, name, "office", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + public void setOfficeService(OfficeService officeService) { this.officeService = officeService; } From 75e954a14cc3b15424908e3388745b41d753af32 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Thu, 27 Mar 2025 11:10:41 +0800 Subject: [PATCH 199/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E5=87=BA=E5=94=AE=E4=BC=B0=E5=80=BC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/OfficeRentStat.java | 20 + .../controllers/OfficeSellController.java | 375 +++++++++++++++++- .../service/datastore/OfficeService.java | 17 + .../service/datastore/OfficeServiceImpl.java | 212 +++++++++- .../datastore/dto/OfficeEvaluationDto.java | 11 + 5 files changed, 629 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java index cc6084e23..046cf8604 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -19,6 +19,8 @@ public class OfficeRentStat implements MongoEntity { private String name; @JsonIgnore private Object location; + private String estateType2; + private String bedKind; @Id @GeneratedValue @@ -93,4 +95,22 @@ public class OfficeRentStat implements MongoEntity { public void setLocation(Object location) { this.location = location; } + + @Column(name = "estate_type2") + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } + + @Column(name = "bed_kind") + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java index 53ab53d21..00b0190b2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -1,23 +1,44 @@ package com.fangjia.open.controllers; import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; import com.fangjia.core.util.LoggerFactory; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeSellStat; +import com.fangjia.dal.seaweed.model.District; import com.fangjia.open.HttpCode; import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.service.api.AddressMatchProxyService; +import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.OfficeService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; +import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.annotation.Param; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; /** * @author liuhongyang @@ -27,8 +48,10 @@ import java.util.List; public class OfficeSellController { private static final Logger LOGGER = LoggerFactory.getLogger(OfficeSellController.class); - private OfficeService officeService; + private DistrictService districtService; + private OpenApiLogService openApiLogService; + private AddressMatchProxyService addressMatchProxyService; /** * 写字楼城市出售均价 @@ -189,8 +212,358 @@ public class OfficeSellController { return mav; } + /** + * 写字楼售价评估 + * + * @param model + * @param request + * @return + */ + public Object evaluateSellAction(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 || model.getCity().contains("全国") + || model.getDistrict().contains("全国")) { + 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(), "office"); + if (district == null) { + if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) { + district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office"); + } + 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)); + } + + } + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + + OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("refOffices", evaluation.getOfficeSell()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/evaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该写字楼的评估").markNoData()); + return mav; + } + } + + /** + * 写字楼售价地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + 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.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + 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(model.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)); + } + + } + } + + OfficeEvaluationDto evaluation = officeService.addressEvaluateSell(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("refOffices", evaluation.getOffice()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/addressEvaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + 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; + } + + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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.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 floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_office_evaluateSell"); + return evaluation; + } + public void setOfficeService(OfficeService officeService) { this.officeService = officeService; } + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { + this.addressMatchProxyService = addressMatchProxyService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index a899bbbad..643e5b0b5 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -53,4 +53,21 @@ public interface OfficeService { * @return */ List findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * 售价评估 + * + * @param district + * @param evaluation + * @return + */ + OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation); + + /** + * 售价地址维度评估 + * + * @param evaluation + * @return + */ + OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 19cfedbc9..2bd27df50 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -219,7 +219,100 @@ public class OfficeServiceImpl implements OfficeService { factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); } avgPrice = avgPrice * factor; - return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation); + return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_rent"); + } + + return null; + } + + public OfficeEvaluationDto calcSell(Evaluation evaluation) { + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + // 第二步:基准价*楼层系数*装修系数*朝向系数 + // 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("office_sell"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "低".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "高".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getOfficeEvaluationDto(selectedSeawaters, evaluation); + } + } + } + // 查找基准价 + List params = new ArrayList(); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // 获取上个月yyyyMM日期 + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // 第二步:基准价*楼层系数*装修系数*朝向系数 + OfficeSellStat officeSellStat = officeSellStatDao.findFirstByParams(params); + Double avgPrice = officeSellStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (floorDesc != null) { + factor *= FLOOR_FACTOR.get(floorDesc); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_sell"); } return null; @@ -232,12 +325,12 @@ public class OfficeServiceImpl implements OfficeService { * @param evaluation * @return */ - private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation) { + private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { SeawaterQuery query = new SeawaterQuery(); query.setRegion(evaluation.getRegion()); query.setStartPrice((int) (avgPrice * 30 * 0.9)); query.setEndPrice((int) (avgPrice * 30 * 1.1)); - query.setCat("office_rent"); + query.setCat(cat); query.setRadius(3000); Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); @@ -381,10 +474,10 @@ public class OfficeServiceImpl implements OfficeService { List params = new ArrayList(5); if (TYPE_MAP.get(evaluation.getType()) != null) { - params.add(new QueryParam("estate_type2", TYPE_MAP.get(evaluation.getType()))); + params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType()))); } if (LEVEL_MAP.get(evaluation.getLevel()) != null) { - params.add(new QueryParam("bed_kind", LEVEL_MAP.get(evaluation.getLevel()))); + params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel()))); } params.add(new QueryParam("cat", "office")); params.add(new QueryParam("location", geo)); @@ -437,6 +530,77 @@ public class OfficeServiceImpl implements OfficeService { return officeEvaluationDto; } + private OfficeEvaluationDto sellEvaluateByLocation(Evaluation evaluation) { + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // 查询附近5个写字楼基准价 + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); + + List params = new ArrayList(5); + if (TYPE_MAP.get(evaluation.getType()) != null) { + params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType()))); + } + if (LEVEL_MAP.get(evaluation.getLevel()) != null) { + params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel()))); + } + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = officeSellStatDao.findAllByParams(params, sortParams, 5); + if (CollectionUtils.isEmpty(infos)) { + // 去掉类型,重新查找 + params = new ArrayList(5); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = officeSellStatDao.findAllByParams(params, sortParams); + } + if (CollectionUtils.isNotEmpty(infos)) { + // 求均值 + Double totalPrice = 0D; + int count = 0; + for (OfficeSellStat officeSellStat : infos) { + if (officeSellStat.getAvgPrice() != null) { + totalPrice += officeSellStat.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getFloorDesc() != null) { + factor *= FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + officeEvaluationDto.setUnitPrice(avgPrice); + officeEvaluationDto.setOfficeSell(infos); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + return officeEvaluationDto; + } + } + return officeEvaluationDto; + } + private String getLocation(String city, String address) { GaodeDto gaodeDto = GeoUtils.geo(city, address); if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { @@ -500,6 +664,44 @@ public class OfficeServiceImpl implements OfficeService { }); } + @Override + public OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + OfficeEvaluationDto officeEvaluationDto = this.calcSell(evaluation); + // 如果从基价表中找不到,// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) { + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto = sellEvaluateByLocation(evaluation); + } else if (district != null && district.getLat() != null) { + evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); + officeEvaluationDto = sellEvaluateByLocation(evaluation); + } + } + + return officeEvaluationDto; + } + + @Override + public OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return sellEvaluateByLocation(evaluation); + } + public List doFindOfficeSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { if (startDate == null) { throw new IllegalArgumentException("开始日期不能为空"); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index 1ffb1ef09..8007a2221 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -2,6 +2,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.seawater.model.Seawater; import java.util.List; @@ -18,6 +19,8 @@ public class OfficeEvaluationDto extends Evaluation { private List office; + private List officeSell; + private String district; private String name; @@ -62,4 +65,12 @@ public class OfficeEvaluationDto extends Evaluation { public void setOffice(List office) { this.office = office; } + + public List getOfficeSell() { + return officeSell; + } + + public void setOfficeSell(List officeSell) { + this.officeSell = officeSell; + } } From 267d672c53829c26e6d22d1e5f8a4a2d64a39c18 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Thu, 27 Mar 2025 15:02:48 +0800 Subject: [PATCH 200/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=87=BA?= =?UTF-8?q?=E5=94=AE=E6=A0=B7=E6=9C=AC=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/OfficeServiceImpl.java | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 2bd27df50..26fda160e 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -186,7 +186,7 @@ public class OfficeServiceImpl implements OfficeService { selectedSeawaters.add(seawater); } if (selectedSeawaters.size() == 3) { - return getOfficeEvaluationDto(selectedSeawaters, evaluation); + return getOfficeEvaluationDto(selectedSeawaters, evaluation, "office_rent"); } } } @@ -279,7 +279,7 @@ public class OfficeServiceImpl implements OfficeService { selectedSeawaters.add(seawater); } if (selectedSeawaters.size() == 3) { - return getOfficeEvaluationDto(selectedSeawaters, evaluation); + return getOfficeEvaluationDto(selectedSeawaters, evaluation, "office_sell"); } } } @@ -328,8 +328,13 @@ public class OfficeServiceImpl implements OfficeService { private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { SeawaterQuery query = new SeawaterQuery(); query.setRegion(evaluation.getRegion()); - query.setStartPrice((int) (avgPrice * 30 * 0.9)); - query.setEndPrice((int) (avgPrice * 30 * 1.1)); + if ("office_rent".equals(cat)) { + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + } else { + query.setStartPrice((int) (avgPrice * 0.9)); + query.setEndPrice((int) (avgPrice * 1.1)); + } query.setCat(cat); query.setRadius(3000); @@ -345,7 +350,7 @@ public class OfficeServiceImpl implements OfficeService { query.setPager(pager); query.setTable("latest_seawater"); List seawaters = seawaterService.findSeawatersByQuery(query); - return getOfficeEvaluationDto(seawaters, evaluation); + return getOfficeEvaluationDto(seawaters, evaluation, cat); } /** @@ -418,25 +423,44 @@ public class OfficeServiceImpl implements OfficeService { * @param evaluation * @return */ - private static OfficeEvaluationDto getOfficeEvaluationDto(List seawaters, Evaluation evaluation) { + private static OfficeEvaluationDto getOfficeEvaluationDto(List seawaters, Evaluation evaluation, String cat) { Integer sum = 0; Double size = 0.0; - for (Seawater seawater : seawaters) { - if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { - sum += seawater.getTotalPrice(); - size += seawater.getArea(); + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + + if ("office_rent".equals(cat)) { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + } else { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); } } - OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); - if (size > 0) { - Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); - officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); - officeEvaluationDto.setCity(evaluation.getCity()); - officeEvaluationDto.setDistrict(evaluation.getRegion()); - officeEvaluationDto.setName(evaluation.getDistrictName()); - } + return officeEvaluationDto; } From 52ce2a236e8f1f489fc7ef323f86d50b80485601 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Mon, 31 Mar 2025 16:50:36 +0800 Subject: [PATCH 201/247] =?UTF-8?q?=E5=86=99=E5=AD=97=E6=A5=BC=E5=87=BA?= =?UTF-8?q?=E5=94=AEavg=5Fprice=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/dal/mongo/model/OfficeSellStat.java | 6 +++--- .../com/fangjia/service/datastore/OfficeServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java index 1453d3e67..c027e5345 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java @@ -17,7 +17,7 @@ public class OfficeSellStat implements MongoEntity { private Integer date; private String district; private String name; - private Double avgPrice; + private Integer avgPrice; private String estateType2; private String bedKind; @JsonIgnore @@ -82,11 +82,11 @@ public class OfficeSellStat implements MongoEntity { } @Column(name = "avg_price") - public Double getAvgPrice() { + public Integer getAvgPrice() { return avgPrice; } - public void setAvgPrice(Double avgPrice) { + public void setAvgPrice(Integer avgPrice) { this.avgPrice = avgPrice; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 26fda160e..b8f6cf578 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -299,7 +299,7 @@ public class OfficeServiceImpl implements OfficeService { // 第二步:基准价*楼层系数*装修系数*朝向系数 OfficeSellStat officeSellStat = officeSellStatDao.findFirstByParams(params); - Double avgPrice = officeSellStat.getAvgPrice(); + Double avgPrice = Double.valueOf(officeSellStat.getAvgPrice()); if (avgPrice != null) { Double factor = 1.0; if (evaluation.getFitment() != null) { From a84725962c9605df75712066588ca6b32798d948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 31 Mar 2025 18:22:55 +0800 Subject: [PATCH 202/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/weixin/WeiXinEvaluationController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 2607ac3dc..a98ea59a0 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -776,9 +776,11 @@ public class WeiXinEvaluationController { Integer tradeAvgPrice = dealPriceService.findDealPrices(model.getCityName(), model.getRegion(), model.getName(), DateUtil.getFirstDayOfMonth(new Date(), -6), DateUtil.getFirstDayOfMonth(new Date(), 0)); //columnX = "['成交均价(近半年)','房价网挂牌均价','搜房挂牌均价','安居客挂牌均价']"; dataMap.put("dealPrice", tradeAvgPrice); - dataMap.put("fjw", averageStatistics.getFangjiaPrice()); - dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); - dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + if (averageStatistics != null) { + dataMap.put("fjw", averageStatistics.getFangjiaPrice()); + dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); + dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + } } jsonMmodel.setJsonModel(dataMap); return jsonMmodel; From f8baadb0fea3aa858118e9dcad6f7ed0201d526e Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Tue, 1 Apr 2025 16:08:51 +0800 Subject: [PATCH 203/247] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 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 fa331f5f8..7c4c4ab00 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 @@ -2601,9 +2601,10 @@ public class PropertyController { int total = Integer.valueOf(rankDesc[1]); UniversalDto dto = new UniversalDto(); dto.append("relativeRank", DataUtil.roundDouble(((total - rank) / (double) total) * 100, 2)); - + dto.append("rank", districtAnalyData.getCityRank()); if (null != districtAnalyData.getRegionRank()) { dto.append("regionRelativeRank", DataUtil.roundDouble(((districtAnalyData.getRegionRankTotal() - districtAnalyData.getRegionRank()) / (double) districtAnalyData.getRegionRankTotal()) * 100, 2)); + dto.append("regionRank", districtAnalyData.getRegionRank()); } mav.setModel(BasicModel.buildOKModel().setResult(dto)); } else { From ca998a84442c0de6fd13040fccafda2d08b4c8c0 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Tue, 1 Apr 2025 22:09:18 +0800 Subject: [PATCH 204/247] update --- .../script/ccbevaluation/AddSzDealData.groovy | 2 +- .../script/commData/CommonDatautils.groovy | 3 +- .../gj/data_handle/AutoAddOfficeBatch.groovy | 85 ++++++++++++++ .../script/gj/data_handle/MinglujiData.groovy | 4 +- .../gj/data_handle/RegionStandardBatch.groovy | 64 ++++++++-- .../gj/data_handle/TempExportData.groovy | 24 ++-- .../fangjia/script/gj/data_handle/Test.groovy | 105 ++++++++--------- .../gj/data_handle/TownMiddleProcess.groovy | 111 ++++++++++++++++-- .../gj/data_handle/TownStandardBatch.groovy | 8 +- .../gj/district/FangjiaClientUtils.groovy | 9 +- .../script/gj/location/RegionPoint.groovy | 97 ++++++++++++--- .../script/gj/xiamen/SeaweedDataSynch.groovy | 10 +- 12 files changed, 403 insertions(+), 119 deletions(-) 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 dfd784e71..de2216df9 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 @@ -8,7 +8,7 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年11月深圳二手房成交.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\2025年02月深圳二手房成交.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/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index e6e2d944b..33b711d5d 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 @@ -5094,10 +5094,11 @@ class CommonDatautils { def keys = new BasicDBObject() keys.put("street",1) keys.put("alias",1) + keys.put("shape",1) def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(2000).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) def retMap = [:] for(def d : dbcursor){ - retMap.put(d.street, d.alias) + retMap.put(d.street, d) } return retMap diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index cfa15156b..727e3cafc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -5,7 +5,11 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.DbUtils 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 @@ -17,6 +21,7 @@ class AutoAddOfficeBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameByCity() public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) static main(args) { runBatch(new AutoAddOfficeBatch(), args) @@ -29,6 +34,16 @@ class AutoAddOfficeBatch extends BaseBatch{ // def newName = "开放广场".replaceAll(pattern, "") // println newName +// findAddOfficeDatas() //查找需要新增的写字楼数据 + +// checkInBaiduMapOffice()//查寻在百度地图上有的写字楼数据 + + addOffice()//新增写字楼 + + + } + + def findAddOfficeDatas(){ def citys = CommonDatautils.findAllCity() def allAddOffices = [] allAddOffices << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] @@ -46,6 +61,19 @@ class AutoAddOfficeBatch extends BaseBatch{ ExcelUtils.write("D:\\数据\\高德写字楼.xlsx", allAddOffices, "数据") } + def checkInBaiduMapOffice(){ + ExcelUtils.multiThreadingModify("D:\\数据\\高德写字楼1.xlsx",{d-> + if(!d['L']){ + def obj = findBaiduDatas(d['C'], d['D'], d['E']) + if(obj){ + d['L'] = "百度存在" + d['M'] = obj.std_tag.toString() + } + } + + },0) + } + def filterOffice(officeMaps){ def offices = [] def keys = [] @@ -171,4 +199,61 @@ class AutoAddOfficeBatch extends BaseBatch{ } return null } + + def findBaiduDatas(city, district, name){ + def q = new BasicDBObject() + q.put("city", city) + q.put("district", district) + q.put("name", name) +// q.put('std_tag', '房地产;住宅区') + def obj = BAIDU_POI_COLL.findOne(q) + return obj; + } + + def addOffice(){ + ExcelUtils.modify("D:\\数据\\高德待入库写字楼.xlsx",{d-> + if(d['L']!='人工删除'){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + if(city && region){ + def locationstr = d['G'].toString()+","+d['H'].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr, 1) + def udata = new BasicDBObject() + if(bdpoint){ + udata.put("lng2", (bdpoint[0]*10000000000).longValue()) + udata.put("lat2", (bdpoint[1]*10000000000).longValue()) + } + + udata.put("city", city) + udata.put("region", region) + udata.put("name", d['E']) + udata.put("address", d['I']) + udata.put("cat", "office") + udata.put("status", 0) + udata.put("c_date",new Date()) + udata.put("m_date",new Date()) + udata.put("lng", (d['G'].toString().toDouble()*10000000000).longValue()) + udata.put("lat", (d['H'].toString().toDouble()*10000000000).longValue()) + + def estate_type = null + if(d['M'] && d['M'].contains("园区")){ + estate_type = "创意园区" + } + + if(!estate_type && d['E'].contains("创意")){ + estate_type = "创意园区" + } + if(estate_type){ + udata.put("estate_type2", estate_type) + } + + def markMap = [:] + markMap.put("data_source", "机器入库") + udata.put("mark_map", markMap) + DbUtils.seaweed.save(udata) + println d['E'] +" "+udata._id.toString() + } + } + }) + } } 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 1c94475bc..2cc1b9057 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 @@ -5,10 +5,8 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -import com.rabbitmq.client.impl.AMQImpl import java.util.regex.Pattern - /** * 名录集 */ @@ -31,7 +29,7 @@ class MinglujiData { } def run(){ - def prov = "河北省" + def prov = "省" def city = "石家庄市" // exportDatas(city) // matchDev(prov, city) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy index abce57fe0..34f1b2c1d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy @@ -4,9 +4,12 @@ import com.fangjia.core.RegionData import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils +import org.bson.types.ObjectId import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions @@ -32,11 +35,14 @@ class RegionStandardBatch extends BaseBatch{ @Override void process(Object args) { // seaweedRegionStandard() - poiRegionStandard() +// poiRegionStandard() + //通过乡镇街道修改区域 如:东莞市 +// updateRegionByTown() + } def seaweedRegionStandard(){ - seaweedRegionStandardByCat("district") + seaweedRegionStandardByCat("office") } def poiRegionStandard(){ @@ -93,7 +99,7 @@ class RegionStandardBatch extends BaseBatch{ def seaweedRegionStandardByCat(cat){ - def citys = CommonDatautils.findAllCity() + def citys = ["伊春"]//CommonDatautils.findAllCity() for(def city : citys){ def rMap = regionMap.get(city) @@ -148,8 +154,12 @@ class RegionStandardBatch extends BaseBatch{ def streetMap = CommonDatautils.queryAllStreetNameByCity(fullCityName) if(streetMap){ set = streetMap.keySet() - def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name"]) + def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name","lng","lat"]) + println city +" "+ districts.size() + def index = 0 for(def d : districts){ + index ++ + println index +" "+ d.region if(set.contains(d.region)){ continue } @@ -157,8 +167,12 @@ class RegionStandardBatch extends BaseBatch{ def updateRegion = null def flag = null for(def key : set){ - def alias = streetMap.get(key) - if((alias && alias.contains(d.region)) || (!alias && key.contains(d.region))){ + def obj = streetMap.get(key) + def alias = null + if(obj && obj.alias){ + alias = obj.alias + } + if((alias && alias.contains(d.region)) || (!alias && key==d.region)){ def newRegion = RegionData.formatRegion(d.city, key) if(newRegion!=d.region){ updateRegion = newRegion @@ -166,13 +180,26 @@ class RegionStandardBatch extends BaseBatch{ flag = "pass" break; } + + if(obj.shape){ + def inAreaFlag = InsidePolygon.isInArea(d.lng/10000000000.0, d.lat/10000000000.0, InsidePolygon.createPoint4(obj.shape.coordinates)) + if(inAreaFlag){ + def newRegion = obj.street + newRegion = RegionData.formatRegion(d.city, newRegion) + if(newRegion!=d.region){ + updateRegion = newRegion + } + flag = "pass" + break; + } + } } if(updateRegion){ def udata = new BasicDBObject() udata.put("region", updateRegion) udata.put("m_date", new Date()) println d.city +" "+d.region+" "+d.name +" 区域修改为:"+updateRegion -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) }else{ if(flag!="pass"){ def udata = new BasicDBObject() @@ -402,4 +429,27 @@ class RegionStandardBatch extends BaseBatch{ return rets; } + def updateRegionByTown(){ + ExcelUtils.modify("d:\\数据\\城市与区域相同写字楼.xlsx",{d-> + def town = RegionData.formatRegion(d['B'], d['F']) + if(town){ + + def obj = CommonDatautils.findDistrict(d['B'], town, d['E'], "office") + if(!obj){ + def udata = new BasicDBObject() + udata.put("region", town) + udata.put("m_date", new Date()) + println d['F']+" "+" 区域修改为:" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + }else{ + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("status", 1) + println d['F']+" "+" 删除:" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + } + + } + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy index b5f4ceb7f..c3d0bf761 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.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.util.ElasticUtils import com.fangjia.script.util.ExcelUtils @@ -219,34 +220,41 @@ class TempExportData { } def exportOfficeHouseCount(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\写字楼\\待核实写字楼.xlsx",{d-> + ExcelUtils.multiThreadingModify("D:\\数据\\高德写字楼-房源第三方验证.xlsx",{d-> // def obj = findYuanQu(d['B'], d['D']) // if(obj){ // d['T'] = "前瞻存在" // } // if(!d['T']){ -// def obj = findYuanQu(d['B'], d['D']) +// def city = RegionData.formatCity(d['C']) +// def obj = findYuanQu(city, d['E']) // if(obj){ +// d['T'] = "前瞻存在" // d['U'] = obj.name // } // } // if(!d['T']) { -// def count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_sell") +// def city = RegionData.formatCity(d['C']) +// def region = RegionData.formatRegion(city, d['D']) +// +// def count = findHouseCountByCat(city, region, d['E'], "office_sell") // if (!count) { -// count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_rent") +// count = findHouseCountByCat(city, region, d['E'], "office_rent") // } -// d['S'] = count +// d['T'] = count // } - if(!d['J']){ - def datas = CommonDatautils.findThirdNetWorkOffices(d['B'], d['C'], d['D']) + if(!d['T']){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + def datas = CommonDatautils.findThirdNetWorkOffices(city, region, d['E']) if(datas){ def sources = [] for(def o : datas){ sources << o.source } if(sources){ - d['K'] = sources.join(",") + d['V'] = sources.join(",") } } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy index 3f08229ce..1d22f4cc3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy @@ -1,58 +1,57 @@ package com.fangjia.script.gj.data_handle -import com.fangjia.script.commData.CommonDatautils -import com.fangjia.script.util.DateUtils -import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.MongoUtils -import com.mongodb.BasicDBObject -import com.mongodb.DBCollection -import org.apache.commons.lang.math.RandomUtils - -def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; -DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) - - -def city = "昌江" -ExcelUtils.modify("D:\\数据\\海南\\海南省城市均价.xlsx",{d-> - def date = d['B'] - def start = DateUtils.getFirstDayOfMonth(date) - def end = DateUtils.getLastDayOfMonth(date) - def weekends = DateUtils.getWeekendBetweenDates(start, end) - for(def weekend : weekends){ - def avg_price = d['I'] - def val = random(-200,200) - def new_price = (int)(avg_price*val/10000 + avg_price) - def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) - def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) - - def o = new BasicDBObject() - o.put("avg_price", new_price) - o.put("c_date" , new Date()) - o.put("city", city) - o.put("m_date" , new Date()) - o.put("weekend", weekend) - o.put("cat","城市") - o.put("moving_average" , (int)avg_price) - if(!last_price){ - o.put("weekend_markup" , 0) - }else{ - def weekend_markup = (int)((new_price-last_price)*100/last_price) - o.put("weekend_markup" , weekend_markup) - } - - def q = new BasicDBObject("cat", "城市").append("city", city).append("weekend", weekend) - REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) - } -},1) - - -public static final int random(int i1, int i2) { - int max = Math.max(i1, i2); - int min = Math.min(i1, i2); - return min + RandomUtils.nextInt(max - min + 1); -} - - +import org.bson.types.ObjectId +ObjectId objectId = new ObjectId("659c9ae92ae7732fd7d54e40"); +Date creationDate = objectId.getDate(); +System.out.println(creationDate); +//def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; +//DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) +// +// +//def city = "昌江" +//ExcelUtils.modify("D:\\数据\\海南\\海南省城市均价.xlsx",{d-> +// def date = d['B'] +// def start = DateUtils.getFirstDayOfMonth(date) +// def end = DateUtils.getLastDayOfMonth(date) +// def weekends = DateUtils.getWeekendBetweenDates(start, end) +// for(def weekend : weekends){ +// def avg_price = d['I'] +// def val = random(-200,200) +// def new_price = (int)(avg_price*val/10000 + avg_price) +// def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) +// def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) +// +// def o = new BasicDBObject() +// o.put("avg_price", new_price) +// o.put("c_date" , new Date()) +// o.put("city", city) +// o.put("m_date" , new Date()) +// o.put("weekend", weekend) +// o.put("cat","城市") +// o.put("moving_average" , (int)avg_price) +// if(!last_price){ +// o.put("weekend_markup" , 0) +// }else{ +// def weekend_markup = (int)((new_price-last_price)*100/last_price) +// o.put("weekend_markup" , weekend_markup) +// } +// +// def q = new BasicDBObject("cat", "城市").append("city", city).append("weekend", weekend) +// REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) +// } +//},1) +// +// +//public static final int random(int i1, int i2) { +// int max = Math.max(i1, i2); +// int min = Math.min(i1, i2); +// return min + RandomUtils.nextInt(max - min + 1); +//} +// +// +// +// +// diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy index 4ecd49ed0..68ca7a765 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy @@ -3,23 +3,22 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.core.util.GeocodeUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.util.BaiduMapUtils -import com.fangjia.script.util.DataUtil import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import com.mongodb.DBObject -import com.mongodb.client.AggregateIterable -import org.bson.Document +import net.sf.json.JSONObject import org.bson.types.ObjectId import java.util.regex.Pattern - /** * 乡镇街道中间表 * 包含市,区,乡镇街道别名,来源 统计局community表 @@ -45,6 +44,8 @@ class TownMiddleProcess { DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + static DBCollection POLYLINECOLL2025 = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") + def fullCityMap = CommonDatautils.queryFullNameCity() static main(args) { @@ -95,7 +96,11 @@ class TownMiddleProcess { // addTownCenter()//百度接口添加中心点 // checkCenterInTownRang()//检测乡镇街道中心点是否在围栏中 - addSpecialCityTownAlias() +// addSpecialCityTownAlias() + +// updateNewRegionPoyline()//更新新的区域围栏 + + updateMappingPolyline() } @@ -451,16 +456,16 @@ class TownMiddleProcess { for(def d : dbcursor){ datas << d if (datas.size() >= 2000) { -// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); - ADMINISTRATIVE_MAPPING_43base_COLL.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_43base_COLL.insert(datas) + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) datas.clear(); } } @@ -681,7 +686,7 @@ class TownMiddleProcess { } def regionPolyline(){ - def dbcursor = REGIONPOLYLINE_COLL.find(new BasicDBObject("level","district")) + def dbcursor = POLYLINECOLL2025.find(new BasicDBObject("level","district")) def map = [:] for(def d : dbcursor){ def resultMap = [:] @@ -1356,4 +1361,90 @@ class TownMiddleProcess { keys.put("street", 1) return ADMINISTRATIVE_MAPPING_COLL.find(q, keys).toList() } + + def updateNewRegionPoyline(){ + + def regionPolylineMap = regionPolyline() + def q = new BasicDBObject() + q.put("type","区域") +// q.put("city", "苏州市") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + for(def d : dbcursor){ + def shapeData = regionPolylineMap.get(d.city+"|@|"+d.district) + println d.city+" "+d.district + if(shapeData){ + println "新围栏数:"+shapeData.shape.coordinates.size() + } + + if(d.shape){ + println "旧围栏数:"+d.shape.coordinates.size() + } + + if(d.shape && shapeData && shapeData.shape!=d.shape){ + def udata = new BasicDBObject() + udata.shape = shapeData.shape + udata.location = shapeData.location + udata.m_date = new Date() + ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// if(shapeData && d.shape && shapeData.shape.type=="polygon" && d.shape.type=="polygon"){ +// double area = com.fangjia.script.util.GeoHelper.calculateArea(shapeData.shape.coordinates[0]) +// double area1 = com.fangjia.script.util.GeoHelper.calculateArea(d.shape.coordinates[0]) +// if(Math.abs(area1-area)>=1){ +// println "新:"+area +// println "旧:"+area1 +// def udata = new BasicDBObject() +// udata.shape = shapeData.shape +// udata.location = shapeData.location +// //DMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// } +// } + } + } + } + + def updateMappingPolyline(){ + def q = new BasicDBObject() + q.put("type","区域") + q.put("shape.type","polygon") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + for(def d : dbcursor){ + updateAdministrativeMapping(d._id.toString(), d.shape) + } + } + + + def updateAdministrativeMapping(def id, def shape){ + 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.shape = params.newshape", + "params":{ + "newshape":{ + "type":"${shape.type}", + "coordinates":${shape.coordinates} + } + } + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + println(response) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 69c368290..92c0cda41 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -3,7 +3,6 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 -import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.BaiduMapUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils @@ -25,7 +24,6 @@ import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong - /** * 区域标准化 * 1.小区库乡镇街道标准化,包含小区,商铺,写字楼 @@ -52,9 +50,9 @@ class TownStandardBatch extends BaseBatch{ } def TownStandard(){ -// townStandardByCat("office") + townStandardByCat("office") // townStandardByPoi() - addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 +// addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 // updateTownData() } def townStandardByCat(def cat){ @@ -537,7 +535,7 @@ class TownStandardBatch extends BaseBatch{ // //通过调取地图api接口获取乡镇街道 // if(!saveObj.township){ -// def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) + def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) // if(gaodeMap && gaodeMap.addressComponent) { // def addressComponent = gaodeMap.addressComponent // if(addressComponent){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 35179b3d9..102e4666e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -1,16 +1,9 @@ package com.fangjia.script.gj.district import com.fangjia.core.util.HttpRequest -import com.fangjia.script.addrepo.InvokeHttpRequest -import com.fangjia.script.statistics.poi.AmapPoi -import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.temp.shenjian.util.HttpUtils -import com.fangjia.script.util.HttpRequestUtil -import com.mongodb.DBObject import net.sf.json.JSONArray import net.sf.json.JSONObject -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang.StringUtils class FangjiaClientUtils { @@ -336,7 +329,7 @@ class FangjiaClientUtils { try { address = address.replace("{","") // def url = "http://192.168.0.19:31080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") - def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") + def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=true&addressAssessment=false" if(city){ url = url +"&city="+URLEncoder.encode(city,"UTF-8") } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy index e80dd9c35..030658e63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy @@ -5,6 +5,7 @@ import com.fangjia.core.RegionData import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject import org.apache.commons.lang.math.RandomUtils @@ -17,8 +18,9 @@ import java.util.regex.Pattern */ class RegionPointCrawl { - static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") + static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") static DBCollection GAODECITYCODECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "gaode_city_code") + static DBCollection OLD_POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") static main(args) { def task = new RegionPointCrawl(); @@ -26,16 +28,19 @@ class RegionPointCrawl { //4个直辖市 北京市、上海市、天津市、重庆市 //5个自治区 "内蒙古自治区","广西壮族自治区","西藏自治区","宁夏回族自治区","新疆维吾尔自治区" // def provinces = ["河北省", "山西省","吉林省","辽宁省", "黑龙江省", "陕西省", "甘肃省", "青海省", "山东省", "福建省", "浙江省", "台湾省", "河南省", "湖北省", "湖南省", "江西省", "江苏省", "安徽省", "广东省", "海南省", "四川省", "贵州省", "云南省"] - def provinces = ["甘肃省"] - def index = 0 - for(def p : provinces){ - index ++ - println index +"/"+provinces.size() +" "+p - task.crawlCityAndDistrictCode(p); - println "城市 区域 code 完成" - task.run(p); - println "区域围栏 完成" - } + //已跑:甘肃省,河北省,山西省,"吉林省","辽宁省", "黑龙江省", "陕西省", "青海省", "山东省", "福建省", "浙江省", "台湾省", "河南省", "湖北省", "湖南省", "江西省", "江苏省", "安徽省", "广东省", "海南省", "四川省", "贵州省","云南省" +// def provinces = ["北京市","上海市","天津市","重庆市" ] +// def index = 0 +// for(def p : provinces){ +// index ++ +// println index +"/"+provinces.size() +" "+p +// task.crawlCityAndDistrictCode(p); +// println "城市 区域 code 完成" +// task.run(p); +// println "区域围栏 完成" +// } + + task.statSame() } @@ -47,7 +52,10 @@ class RegionPointCrawl { def cityCodes = findCityCode(pro); if(cityCodes){ for(def cityMap : cityCodes){ - def codeMap = findAllDistrictCode(cityMap.city_code); + def codeMap = findAllDistrictCode(cityMap.city_code, "district"); +// if(!codeMap){ +// codeMap = findAllDistrictCode(cityMap.city_code, "street"); +// } def index = 0 for(def m : codeMap){ index ++ @@ -93,7 +101,7 @@ class RegionPointCrawl { def saveGaoDeRegionCode(province, cityName,districts){ if(districts){ for(def dist : districts){ - if(dist.level=="district" || cityName=="东莞市"){ + if(dist.level=="district" || dist.level=="street" ){ saveGaoDeCityRegionCode(province, dist.name, dist.citycode, dist.adcode, dist.center, dist.level); } } @@ -125,10 +133,10 @@ class RegionPointCrawl { return new BasicDBObject("$regex", pattern); } - def findAllDistrictCode(def citycode){ + def findAllDistrictCode(def citycode, def level){ def q = new BasicDBObject() q.put("city_code", citycode) - q.put("level", "district") + q.put("level", level) def dbcursor = GAODECITYCODECOLL.find(q) def rets = [] for(def d : dbcursor){ @@ -149,6 +157,7 @@ class RegionPointCrawl { def o = GAODECITYCODECOLL.findOne(q) if(!o){ + println name +" "+adcode+" 新增" q.put("c_date", new Date()) q.put("center", center) GAODECITYCODECOLL.save(q); @@ -233,4 +242,62 @@ class RegionPointCrawl { def count = RandomUtils.nextInt(KeyList.size()) return KeyList.get(count); } + + def statSame(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject()).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + + def index = 0 + for(def d : dbcursor){ + index++ + def q = new BasicDBObject() + q.put("city",d.city) + q.put("region", d.region) + def obj = OLD_POLYLINECOLL.findOne(q) + if(obj){ + if(obj.polyline!=d.polyline){ + println index +" "+ d.city +" "+d.region+" 2次区域不同" + } + }else{ + println index +" "+ d.city +" "+d.region+" 没有此区域" + } + } + } + + + def regionPolyline(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject("level","district")) + def map = [:] + for(def d : dbcursor){ + def resultMap = [:] + resultMap.type = "polygon" + def arrs = d.polyline.split("\\|") + def rets = [] + for(def s : arrs){ + def points = s.split(";") + def pointList = [] + for(def pointStr : points){ + def pointArr = pointStr.split(",") + pointList << [pointArr[0].toString().toDouble(), pointArr[1].toString().toDouble()] + } + rets << pointList + } + resultMap.coordinates = rets + if(rets.size()>1) { + resultMap.type = "MultiPolygon" + } + println d.city+" "+d.region+" "+rets.size() + + def udata = new BasicDBObject() + udata.put("shape", resultMap) + def center = d.center + if(center){ + def pointArrs = center.split(",") + udata.put("location", ["lon":pointArrs[0].toString().toDouble(), "lat":pointArrs[1].toString().toDouble()]) + } + + def fullCity = fullCityMap.get(d.city) + map.put(fullCity.city+"|@|"+d.region, udata) + } + return map; + } } 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 41ccc9e38..d92ceef54 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 @@ -3,15 +3,10 @@ package com.fangjia.script.gj.xiamen import com.fangjia.core.util.GeoUtils import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils -import com.fangjia.script.util.DateUtil -import com.fangjia.script.util.DateUtils -import com.fangjia.script.util.DbUtils -import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.MongoUtils -import com.fangjia.script.util.ProvinceData +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.* import com.mongodb.BasicDBObject import com.mongodb.DBCollection -import com.rabbitmq.client.AMQP import org.bson.types.ObjectId import java.util.concurrent.CopyOnWriteArrayList @@ -19,7 +14,6 @@ import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong -import com.fangjia.script.common.DataHandleUtils class SeaweedDataSynch extends BaseBatch{ From a094b9ead81c231d5cfa5fc4c7170ce4070ce1df Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 2 Apr 2025 09:45:32 +0800 Subject: [PATCH 205/247] update --- .../script/ccbevaluation/AddSzDealData.groovy | 2 +- .../fangjia/script/ccbevaluation/Test.groovy | 11 +- .../script/commData/CommonDatautils.groovy | 14 +- .../script/gj/FangjiatongUserStat.groovy | 61 +++- .../com/fangjia/script/gj/FiledStrand.groovy | 179 ++++++++-- .../gj/data_handle/AddDevShapeData.groovy | 206 ++++++++++- .../gj/data_handle/AddrAlaisProcess.groovy | 114 ++++-- .../data_handle/AutoAddDistrictBatch.groovy | 42 ++- .../gj/data_handle/AutoAddOfficeBatch.groovy | 84 ++++- .../gj/data_handle/DevUpdateTestBatch.groovy | 4 +- .../script/gj/data_handle/MinglujiData.groovy | 8 +- .../gj/data_handle/RegionStandardBatch.groovy | 4 +- .../gj/data_handle/TownMiddleProcess.groovy | 12 +- .../gj/data_handle/TownStandardBatch.groovy | 329 +++++++++++++----- .../data_handle/TownshipStrandUpdate.groovy | 74 +++- .../gj/district/FangjiaClientUtils.groovy | 4 +- .../gj/district/OfficeFieldCleanBatch.groovy | 205 +++++++++-- .../script/gj/es/EsMonthHouseStat.groovy | 2 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 46 ++- .../script/gj/village/govLocation.groovy | 2 +- .../script/gj/xiamen/SeaweedDataSynch.groovy | 92 ++++- 21 files changed, 1264 insertions(+), 231 deletions(-) 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 dfd784e71..4b9781f02 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 @@ -8,7 +8,7 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年11月深圳二手房成交.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2025年01月深圳二手房成交的.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 3ccdc43ef..ce47aa8db 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 @@ -1353,13 +1353,14 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){ //},0) -def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20241025人工指导价.xlsx" +def fileName = "D:\\数据\\建行\\房产估值\\指导价\\更新人工指导价_0314.xlsx" ExcelUtils.multiThreadingModify(fileName, { d -> - def dist = CommonDatautils.findDistrictById(d['J']) + def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ - d['A'] = dist.city - d['B'] = dist.region - d['C'] = dist.name + d['C'] = dist.city + d['D'] = dist.region + d['E'] = dist.name + d['F'] = dist.status } }) 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 e6e2d944b..952f3eccd 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 @@ -262,7 +262,7 @@ class CommonDatautils { q.put("status", 0); q.put("cat", cat); q.put("city", city); -// q.put("name","托斯卡纳庄园") +// q.put("name","新泾三村") DBObject keys = new BasicDBObject(); if(fields){ @@ -821,7 +821,9 @@ class CommonDatautils { def dbsour = SEAWEED_COLL.find(q, keys).batchSize(5000) def rets = [] for(def d : dbsour){ - rets << d + if(!d.township){ + rets << d + } } return rets; } @@ -4717,6 +4719,14 @@ class CommonDatautils { } + + static def httpSaveData89(def newUrl,def params){ + def header = [:] + header.put("Authorization","Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString()) + doPost(newUrl,header, params, true, "utf-8") + } + + static def doPost(def targetUrl, def headers, def params, def isJson, def charset){ StringBuilder buffer = new StringBuilder(); try{ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy index 3932cc7d9..29f729c63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj +import com.fangjia.script.common.DataHandleUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection; @@ -12,12 +13,13 @@ import com.fangjia.script.util.ExcelUtils; class FangjiatongUserStat { public static final DBCollection FJT_USER_COLL = MongoUtils.getCollectionByName("fangjiatong_log", "utm_gif_log", "222.73.242.42", 52002) - static final def onLineSqlInstance = Sql.newInstance("jdbc:mysql://222.73.242.42:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); + static final def onLineSqlInstance = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); public static void main(String[] args) { def task = new FangjiatongUserStat(); - task.run(); +// task.run(); + task.stat() } def run(){ @@ -60,4 +62,59 @@ class FangjiatongUserStat { return ret; } + def stat(){ + def users = findUses(12) + def months = ["2019-01-01","2019-02-01","2019-03-01","2019-04-01","2019-05-01","2019-06-01","2019-07-01","2019-08-01","2019-09-01","2019-10-01","2019-11-01","2019-12-01","2020-01-01"] + def rets = [] + def header = ["用户id","支行名称", "备注名称"] + months.each{m-> + header << m.substring(0, 7) + } + rets << header + for(def m : users){ + def ret = [] + ret << m.user_id + ret << m.name + ret << m.org_name + for(def i=1;i=5000 && v<=10000000){ + if(v>=1000 && v<=10000000){ return v.toString().toDouble().toInteger() } } @@ -288,11 +285,25 @@ class FiledStrand { return null } + + + static def processLobbyHeight(height){ + if(height){ + def v = getValue(height) + if(v>=2.4 && v<=30){ + return v.toString() + } + } + return null + } + static def processElevators(elevators){ if(elevators){ def v = getValue(elevators) - if(v>0 && v<=100){ - return v.toString() + if(v instanceof Integer){ + if(v>0 && v<=100){ + return v.toString() + } } } return null @@ -317,24 +328,34 @@ class FiledStrand { static def processStandardArea(area){ if(area){ - area = area.toString().replace(",",",").replace("㎡", "").replace("m", "").replace("/","") - area = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(area).replaceAll(""); - return area + def v = getValue(area) + if(v>=500 && v<=20000){ + return v.toString().toDouble().toInteger() + } } return null } static def processCarSiteRent(rent){ if(rent){ - def v = getNumberRange(rent) - if(v){ - if(v=="0"){ + if(["-","0元/月","无","不详","未知","待查","免费元/月","/","0","*","待确认","undefined元/月","0元","0元每月","未知元/月","0.00元/月","未定","暂定","测算中","无元/月","未定元/月","另议元/月","面议元/月","面议元/月","有元/月","暂时未确定","0元(无停车位)"," 元/月"].contains(rent)){ + return null + }else if(rent.contains("暂无") || rent.contains("车位不归") || rent.contains("待定") || rent.contains("暂定") || rent.contains("暂完善") || rent.contains("待审批") || rent.contains("不详") || rent.contains("未定价格") || rent.contains("中国电信") || rent.contains("面谈")){ + return null + }else{ + rent = rent.replace("元/月","元/月").replace(",","").replace("#","").replace(".00","") + if(rent.toString().length()>100){ return null - }else{ - return v.toString() } + if(rent instanceof Double && rent.toDouble()<100){ + return null + } + + if(rent instanceof Integer && rent.toInteger()<100){ + return null + } + return rent } - return null } return null } @@ -382,7 +403,7 @@ class FiledStrand { static def processCarSite(car_site_count){ def v = getValue(car_site_count.toString()); if(v){ - if(v>5 && v<=100000){ + if(v>5 && v<=10000){ try { return v.toString().toInteger(); }catch(Exception e){ @@ -533,12 +554,82 @@ class FiledStrand { return null } + static def processLevel(val){ + def level = null + if (val) { + if(val.contains("超甲") || val.contains("5A") || val.contains("6A") || val.contains("顶级")){ + level = "超甲级" + }else if(val.indexOf("甲")>-1 || val.contains("A")){ + level = "甲级" + }else if(val.indexOf("乙")>-1 || val.contains("B")){ + level = "乙级"; + }else if(val.indexOf("丙")>-1 || val.contains("C")){ + level = "丙级"; + } + } + return level + } + + + static def processLoopLine(val){ + def line = null + if (val) { + if(!val.contains("暂") && !val.contains("无")){ + if(val.indexOf("环")>-1){ + line = val + } + } + } + return line + } + + static def processForeign(val){ + def foreign = null + if (val) { + if(val.indexOf("是")>-1){ + foreign = "是" + }else if(val.indexOf("否")>-1){ + foreign = "否"; + } + } + return foreign + } + + static def processRegister(val){ + def register = null + if (val) { + if(val.contains("不可以注册") || val.contains("不能注册")){ + register = "否"; + }else if(val.contains("可以注册")){ + register = "是" + }else if(val.indexOf("是")>-1){ + register = "是" + }else if(val.indexOf("否")>-1){ + register = "否"; + } + } + return register + } + + static def processFitment(val){ + def fitment = null + if(val){ + if(val.indexOf("精装")>-1){ + fitment = "精装" + }else if(val.indexOf("简单")>-1 || val.indexOf("简装")>-1 || val.indexOf("一般")>-1 || val.indexOf("普通")>-1){ + fitment = "简装"; + }else if(val.indexOf("毛坯")>-1){ + fitment = "毛坯"; + } + } + return fitment + } static def processLngAndLat(val) { - if (val) { + if (val && val!="null") { def map = [:] - def lng = DataHandleUtils.getDoubleRound(6, val.x) - def lat = DataHandleUtils.getDoubleRound(6, val.y) + def lng = DataHandleUtils.getDoubleRound(6, val.lon) + def lat = DataHandleUtils.getDoubleRound(6, val.lat) Long gd_lat = lat * 10000000000L Long gd_lng = lng * 10000000000L map.lat = gd_lat @@ -618,7 +709,8 @@ class FiledStrand { if(cubage_percent){ def v = getValue(cubage_percent) if(v){ - if(v>=0.3 && v<=10){ + v = DataHandleUtils.getDoubleRound(2, v.toString().toDouble()) + if(v>=0.3 && v<=20){ return v.toString() } } @@ -644,7 +736,7 @@ class FiledStrand { static def processVirescencePercent(virescence_percent){ if(virescence_percent){ def v = getValue(virescence_percent) - if(v && v>15 && v<=70){ + if(v && v>=10 && v<=70){ return v.toString() } } @@ -788,6 +880,20 @@ class FiledStrand { return null } + static def processUndergroundFloor(floor){ + def v = getValue(floor.toString()); + if(v){ + if(v>=1 && v<=5){ + try { + return v.toString(); + }catch(Exception e){ + println e.getMessage() + } + } + } + return null + } + static def processRealUsePercent(percent){ def v = getValue(percent.toString()); if(v){ @@ -834,15 +940,40 @@ class FiledStrand { static def processCompany(val){ if(val){ - if(val.length()>20){ + if(val.length()>20 || val.length()<4){ return null }else{ - if(val.contains("暂无")){ + if(["#NA","*"].contains(val)){ + return null + } + if(val.contains("暂无") || val.contains("暂定")){ + return null + } + if(val.contains("未知") || val.contains("不祥")){ + return null + } + if(val.contains("待定") || val.contains("待详情")){ + return null + } + if(val.contains("尚未公开")){ + return null + } + if(val.contains("在线咨询")){ + return null + } + + if(val.contains("平米") || val.contains("元平月")){ return null } if(val == "无"){ return null } + if(val == "-"){ + return null + } + if(val == "--"){ + return null + } if(val.isNumber()){ return null } @@ -863,7 +994,7 @@ class FiledStrand { if (pattern.matcher(val).matches()) { return null } - return val + return val.replace("*","").replace("*","") } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy index 4df41ffc4..19934afd6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy @@ -3,7 +3,11 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.core.util.ExcelUtil import com.fangjia.core.util.GeoUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.looplineinfo.InPolygon import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils @@ -13,6 +17,7 @@ import groovy.json.JsonSlurper import groovy.io.FileType import org.bson.types.ObjectId +import java.awt.geom.Point2D import java.util.regex.Pattern class AddDevShapeData { @@ -22,22 +27,175 @@ class AddDevShapeData { public static final def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; DBCollection dev_mapping_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + def devAreaMap = [:] + def fullCityMap = CommonDatautils.queryFullNameCity() + def results = new HashSet() + def existList = new HashSet() static main(args) { def task = new AddDevShapeData(); task.run() // task.streetInfo() +// task.addStreetToMapping()//通过乡镇街道的点是否都在开发区围栏中,判断是否将此乡镇加入映射表中 } + def addStreetToMapping(){ + def citys = CommonDatautils.findAllCity() + for(def city : citys){ + def data = fullCityMap.get(city) + def fullCityName = null + if(data){ + fullCityName = data.city + } + def devShapes = findDevShapeByCity(fullCityName) + if(devShapes){ + def streetShapes = findStreetShapeByCity(fullCityName) + addDevStreetToMapping(fullCityName,streetShapes, devShapes) + } + } + + results.each {s-> + println s + } + existList.each{s-> + println s + } + + println " 新增映射乡镇:"+results.size()+" 已存在乡镇:"+existList.size() + + } + + def addDevStreetToMapping(city,streetShapes, devShapes){ + def addCount = 0 + def existsCount = 0 + + + for(def streetObj : streetShapes){ + + def coordinates = streetObj.shape.coordinates + for(def pointList : coordinates){ + def objList = findDevInStreetRange(streetObj, pointList, devShapes) + if(objList){ + for(def obj : objList){ + def existsFlag = isExistStreetByDevName(obj.name, streetObj.street) + if(existsFlag){ + existsCount++ + existList << "[存在] "+obj.name+" "+ streetObj.street + }else{ + addCount++ + results << "[新增] "+obj.name+"#"+ streetObj.street + if(!streetObj.street){ + println streetObj + } + } + } + } + } + } + + + } + + def findDevInStreetRange(streetObj,pointList, devShapes){ + def devList = [] + def minDis =200 + for(def devObj : devShapes){ + def flagList = [] + def distances = [] + for(def pointArr : pointList){ +// def flag = InsidePolygon.isInArea(pointArr[0].toString().toDouble(), pointArr[1].toString().toDouble(), InsidePolygon.createPoint4(devObj.shape.coordinates)) + Point2D.Double point = new Point2D.Double(DataHandleUtils.getDoubleRound(6,pointArr[0].toString().toDouble()), DataHandleUtils.getDoubleRound(6, pointArr[1].toString().toDouble())); + def flag = InPolygon.isInArea(point, InPolygon.createPoint(devObj.shape.coordinates)) + flagList << flag + if(!flag){ + distances << findNearestDistances(pointArr, devObj.shape.coordinates) + } + } + + def trueCount = statResult(flagList) + def pre = trueCount*100/flagList.size() + println streetObj.district+" "+streetObj.street +" "+devObj.name +" "+flagList.size()+" "+pre+"%" + if(pre>=100){ + devList << devObj + } +// else{ +// if(distances && pre>=50){ +// def minCount = 0 +// for(def d : distances){ +// if(d <= minDis){ +// minCount++ +// } +// } +// def simlarPointPre = minCount*100/distances.size() +// if(simlarPointPre>=90){ +// devList << devObj +// } +// println "不在多边型范围内的点,距离小于${minDis}米有:"+minCount+" 占比:"+simlarPointPre +// } +// } + } + + return devList + } + + def findNearestDistances(pointArr, coordinates){ + def minDis = Integer.MAX_VALUE + for(def pointlist : coordinates){ + for(def devPoint : pointlist){ + def distance = GeoUtils.calculateDistance(pointArr[0], pointArr[1], devPoint[0], devPoint[1]) + if(distance < minDis){ + minDis = distance + } + } + } + return minDis + } + + def statResult(rows){ + def count = 0 + for(def s : rows){ + if(s){ + count++ + } + } + return count + } + + def findStreetShapeByCity(city){ + def list = [] + def dbcurosr = administrative_mapping_coll.find(new BasicDBObject("city", city).append("type", "乡镇街道").append("shape", new BasicDBObject('$exists', true))) + for(def d : dbcurosr){ + list << d + } + return list + } + def findDevShapeByCity(city){ + def list = [] + def dbcurosr = DEVELOPMENT_ZONE_43_COLL.find(new BasicDBObject("city", city).append('shape', new BasicDBObject('$exists',true))) + for(def d : dbcurosr){ + list << d + } + return list + } + + def isExistStreetByDevName(devName, street){ + def list = dev_mapping_CONN.find(new BasicDBObject("name", devName).append("type","乡镇街道").append("township",street)).toList() + if(list){ + return true + } + } + + def run(){ - def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\111开发区\\' + def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\218\\' def dir = new File(directoryPath) if (dir.isDirectory()) { -// dir.eachFileRecurse(FileType.FILES) { file -> -// process(file.absolutePath) -// } - addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") + dir.eachFileRecurse(FileType.FILES) { file -> + process(file.absolutePath) + } +// addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") } else { println "The specified path is not a directory." } @@ -46,7 +204,7 @@ class AddDevShapeData { def addDevInfo(file){ ExcelUtils.multiThreadingModify(file, {d-> // if(!d['I']){ - def name = d['D'] + def name = d['E'] def q = new BasicDBObject() q.put('_id',new ObjectId(d['A'])) def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) @@ -57,18 +215,28 @@ class AddDevShapeData { if(obj.operate_result){ d['I'] = obj.operate_result } - if(obj.m_date){ - d['P'] = DateUtils.formatDateByPattern(obj.m_date, "yyyy-MM-dd") + if(obj.shape){ + d['T'] = "有" } +// if(obj.m_date){ +// d['P'] = DateUtils.formatDateByPattern(obj.m_date, "yyyy-MM-dd") +// } + +// if(devAreaMap){ +// devAreaMap.each {k,v-> +// if(obj.name && k && obj.name.contains(k)){ +// d['M'] = v.area_info +// d['N'] = v.count +// d['O'] = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") +// } +// } +// +// }else{ +// println name+" 空值" +// } } // } - devAreaMap.each {k,v-> - if(name.contains(k)){ - d['M'] = v.area_info - d['N'] = v.count - d['O'] = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") - } - } + }) } @@ -101,7 +269,7 @@ class AddDevShapeData { DEVELOPMENT_ZONE_43_COLL.save(obj) }else{ udata.put("shape", resultMap) - udata.put("m_date", new Date()) +// udata.put("m_date", new Date()) udata.put("bd_shape",bd_resultMap) udata.put("operate_result" , "已处理") udata.put("operator", "外包") @@ -124,11 +292,11 @@ class AddDevShapeData { def coordinates = features[0].geometry.coordinates def index = 0 - println name +" 有 "+coordinates.size()+" 块" + println file.toString()+" "+name +" 有 "+coordinates.size()+" 块" areaMap.count = coordinates.size() def areas = [] - if(name.contains("泉州经济技术开发区")){ +// if(name.contains("江苏常熟综合保税区")){ for(def pointList : coordinates){ index ++ def gaode_coordinates = [] @@ -171,7 +339,7 @@ class AddDevShapeData { } areaMap.area_info = areas.join("\n") - } +// } }else{ println file +" 有多个" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy index 62d1f299e..c7bcaf957 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -4,43 +4,104 @@ import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils 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 AddrAlaisProcess { + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) + def fullCityMap = CommonDatautils.queryFullNameCity() + static main(args) { def task = new AddrAlaisProcess() // task.run() task.nineApi() +// task.createResult() +// task.mergeResult() } + + def mergeResult(){ + def rets = ExcelUtils.read("D:\\数据\\数据建设\\小区\\ai-结果-0221.xlsx",0,1) + def retMap = [:] + for(def r : rets){ + def num = r['B'].toString().toDouble().toInteger() + def list = retMap.get(num) + if(!list){ + list = new HashSet() + retMap.put(num, list) + } + if(r['C']){ + list << r['C'] + } + + } + def fileName = "D:\\数据\\数据建设\\小区\\小区别名-待定.xlsx" + ExcelUtils.modify(fileName,{d-> + def num = d['A'].toString().toDouble().toInteger() + def aiList = retMap.get(num) + if(aiList){ + d['K'] = aiList.join(",") + } + }) + } + + def createResult(){ + def fileName = "D:\\数据\\数据建设\\小区\\小区别名-待定.xlsx" + def results = [] +// results << ["ID", "城市", "地址"] + ExcelUtils.modify(fileName,{d-> + def str = d['C'] + def addressList = str.split(",") + for(def addr : addressList){ + results << [d['A'].toString().toDouble().toInteger(), d['B'], addr] + } + }) + println results.size() + FileUtils.batchCreateFileByCustomSuffix(results, "D:\\数据\\数据建设\\小区\\ai-待支行.bat", null, "utf-8", false, " ",""); + } + + def nineApi(){ def fileName = "/home/goojia/gj/district/addr_alias.xlsx" if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化-测试.xlsx" + fileName = "D:\\数据\\数据建设\\写字楼\\写字楼待处理地址.xlsx" } ExcelUtils.multiThreadingModify(fileName, {d-> - def addrMap = nineAddrSplit(d['B'], d['E']) + def obj = CommonDatautils.findDistrictById(d['A']) +// def addrMap = nineAddrSplit(obj.city, d['B']) def addrList = [] - if(addrMap && addrMap.address){ - d['G'] = addrMap.city - d['H'] = addrMap.address - addrList << addrMap.address - } - if(d['F']){ - def addrs = d['F'].split(",") - def addr_alias = [] - for(def addr : addrs){ - def map = nineAddrSplit(d['B'], addr) - if(map && map.address && DataHandleUtils.isStandardRoad(map.address)){ - if(!addrList.contains(map.address)){ - addrList << map.address - addr_alias << map.address - } - } - } - d['I'] = addr_alias.join(",") - } +// if(addrMap && addrMap.address){ +// d['C'] = addrMap.road +// d['D'] = addrMap.road_num +// } + if(d['C']){ + def data = fullCityMap.get(obj.city) + if(data){ + def roadObj = findBaiduDatas( data.city, d['C']) + if(roadObj){ + d['E'] = "百度存在" + } + } + } +// if(d['F']){ +// def addrs = d['F'].split(",") +// def addr_alias = [] +// for(def addr : addrs){ +// def map = nineAddrSplit(d['B'], addr) +// if(map && map.address && DataHandleUtils.isStandardRoad(map.address)){ +// if(!addrList.contains(map.address)){ +// addrList << map.address +// addr_alias << map.address +// } +// } +// } +// d['I'] = addr_alias.join(",") +// } }) } @@ -67,9 +128,11 @@ class AddrAlaisProcess { } if (jsonObject.get("street") && jsonObject.get("street") != "null") { address = jsonObject.get("street") + map.road = address } if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { address = address + jsonObject.get("streetNumber") + map.road_num = jsonObject.get("streetNumber") } map.address = address } @@ -95,4 +158,13 @@ class AddrAlaisProcess { // ExcelUtils.write("D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.xlsx", rows, "小区") FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.bat", null, "utf-8", false, "#",""); } + + def findBaiduDatas(city, name){ + def q = new BasicDBObject() + q.put("city", city) + q.put("name", name) + q.put('std_tag', Pattern.compile('^道路')) + def obj = BAIDU_POI_COLL.findOne(q) + return obj; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy index 9d223e038..9d4bc3bb9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy @@ -4,6 +4,7 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.CosineSimilarAlgorithm import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils @@ -30,7 +31,10 @@ class AutoAddDistrictBatch extends BaseBatch{ def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() static main(args) { - runBatch(new AutoAddDistrictBatch(), args) +// runBatch(new AutoAddDistrictBatch(), args) + + def task = new AutoAddDistrictBatch(); + task.checkMap() } @Override @@ -52,7 +56,6 @@ class AutoAddDistrictBatch extends BaseBatch{ } ExcelUtils.write(fileName, list, "待入库数据") - check(fileName) } @@ -159,10 +162,10 @@ class AutoAddDistrictBatch extends BaseBatch{ } def findGaoDeDatas(city, region, name){ - String sql = "select name,type from amap_poi_detail where cityname='${city}' and adname='${region}' and MATCH(name, '${name}')" + String sql = "select name,type from amap_poi_2024 where cityname='${city}' and adname='${region}' and MATCH(name, '${name}')" def obj = null ElasticUtils.executeSqlQuery(sql,{ d-> - if(d.name == name && d.type.contains("住宅") ){ //&& d.shape + if(d.name == name){ //&& d.shape obj = d } }) @@ -255,8 +258,37 @@ class AutoAddDistrictBatch extends BaseBatch{ q.put("city", city) q.put("district", district) q.put("name", name) - q.put('std_tag', '房地产;住宅区') +// q.put('std_tag', '房地产;住宅区') def obj = BAIDU_POI_COLL.findOne(q) return obj; } + + + def checkMap(){ + ExcelUtils.modify("D:\\数据\\数据建设\\写字楼\\写字楼存在性判断-test.xlsx",{d-> + + def gaode_obj = findGaodeCount(d['B'], d['C'], d['D']) + if(gaode_obj){ + d['H'] = "是" + d['I'] = gaode_obj.type + }else{ + def baidu_obj = findBaiduCount(d['B'], d['C'], d['D']) + if(baidu_obj){ + d['E'] = "是" + d['F'] = baidu_obj.std_tag + } + } + +// def baidu_obj1 = findBaiduCount(d['B'], d['G'], d['H']) +// if(baidu_obj1){ +// d['M'] = "是" +// } +// def gaode_obj1 = findGaodeCount(d['B'], d['G'], d['H']) +// if(gaode_obj1){ +// d['N'] = "是" +// } +// def score = CosineSimilarAlgorithm.getSimilarityRatio(d['D'], d['H']); +// d['O'] = score + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index cfa15156b..38c7d1c16 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -4,10 +4,13 @@ import com.fangjia.core.RegionData import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.CosineSimilarAlgorithm import com.fangjia.script.util.DataUtil import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors @@ -16,19 +19,18 @@ import java.util.concurrent.atomic.AtomicLong class AutoAddOfficeBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) static main(args) { - runBatch(new AutoAddOfficeBatch(), args) +// runBatch(new AutoAddOfficeBatch(), args) + + def task = new AutoAddOfficeBatch() + task.repeatOffice() } @Override void process(Object args) { -// def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|[A-Z]楼|[0-9]幢/ -// def newName = "开放广场".replaceAll(pattern, "") -// println newName - def citys = CommonDatautils.findAllCity() def allAddOffices = [] allAddOffices << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] @@ -39,6 +41,7 @@ class AutoAddOfficeBatch extends BaseBatch{ officeMaps = filterOffice(officeMaps) if(officeMaps){ def offices = matchOffice(officeMaps) + allAddOffices.addAll(offices) } } @@ -171,4 +174,73 @@ class AutoAddOfficeBatch extends BaseBatch{ } return null } + + def repeatOffice(){ + def citys = CommonDatautils.findAllCity() + def allrets = [] + allrets << ["ID","城市","区域","名称","地址","可疑ID","可疑城市","可疑区域","可疑名称","可疑地址","相似度","距离"] + for(def c : citys){ + def offices = CommonDatautils.findAllDistricts(c, "office", ["city","region","name","address", "lat", "lng"]) + def rets = checkRepeatOfficeBatch(offices) + println c +" "+offices.size() + allrets.addAll(rets) + } + ExcelUtils.write("D:\\数据\\写字楼\\重复可疑写字楼1.xlsx", allrets, "数据") + } + + def checkRepeatOfficeBatch(offices){ + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(offices.size()) + def total = offices.size() + def rets = new CopyOnWriteArrayList() + def sets = new CopyOnWriteArraySet() + for(def i=0;imaxScore){ + maxScore = nameScore+addrScore + maxObj = o2 + } + } + } + def distance = -1000 + if(o1.lat && maxObj && maxObj.lat){ + distance = GeoHelper.GetDistance(o1.lat/10000000000.0, o1.lng/10000000000.0, maxObj.lat/10000000000.0, maxObj.lng/10000000000.0) + } + if(maxObj){ + maxObj.distance = distance + maxObj.score = maxScore + return maxObj + } + return null + } } 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 50ec412b8..671266e38 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 @@ -33,8 +33,8 @@ class DevUpdateTestBatch { static main(args) { def task = new DevUpdateTestBatch() def path = "D:\\数据\\数据建设\\开发区\\开发区-园区.xlsx"//开发区-园区.xlsx -// task.addDev(path) - task.addDevAddress(path) + task.addDev(path) +// task.addDevAddress(path) // // task.updateHasGov("新疆维吾尔自治区","喀什地区","麦盖提县", "麦盖提镇", "是") 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 1c94475bc..01b7a0338 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 @@ -31,12 +31,12 @@ class MinglujiData { } def run(){ - def prov = "河北省" - def city = "石家庄市" -// exportDatas(city) + def prov = "江苏省" + def city = "无锡" + exportDatas(city) // matchDev(prov, city) // matchCommunity(city) - fiveLevelSplit(city) +// fiveLevelSplit(city) // nineLevelSplit(city) // tempMatchDev(prov) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy index abce57fe0..9608aee85 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy @@ -31,8 +31,8 @@ class RegionStandardBatch extends BaseBatch{ @Override void process(Object args) { -// seaweedRegionStandard() - poiRegionStandard() + seaweedRegionStandard() +// poiRegionStandard() } def seaweedRegionStandard(){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy index 4ecd49ed0..f799e6651 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy @@ -64,7 +64,7 @@ class TownMiddleProcess { //修改乡镇街道别名 // updateTownAlias() //中间表同步到100 -// synchTown() + synchTown() //添加地级市标志 // addCityFlag() // addPinyin() @@ -95,7 +95,7 @@ class TownMiddleProcess { // addTownCenter()//百度接口添加中心点 // checkCenterInTownRang()//检测乡镇街道中心点是否在围栏中 - addSpecialCityTownAlias() +// addSpecialCityTownAlias() } @@ -451,16 +451,16 @@ class TownMiddleProcess { for(def d : dbcursor){ datas << d if (datas.size() >= 2000) { -// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); - ADMINISTRATIVE_MAPPING_43base_COLL.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_43base_COLL.insert(datas) + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) datas.clear(); } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 69c368290..0d458ec18 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -1,15 +1,21 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.RegionData +import com.fangjia.core.util.HttpRequest import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.lixue.util.DBUtils import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.BaiduMapUtils +import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject +import net.sf.json.JSONObject import org.apache.commons.io.FileUtils +import org.bson.types.ObjectId import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse import org.elasticsearch.action.index.IndexRequest @@ -52,14 +58,17 @@ class TownStandardBatch extends BaseBatch{ } def TownStandard(){ -// townStandardByCat("office") + townStandardByCat("office") // townStandardByPoi() - addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 +// addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 +// standardTown() // updateTownData() + + } def townStandardByCat(def cat){ //"三明","龙岩","南平","漳州","福州","厦门","泉州","莆田","宁德", - def citys = ["重庆","龙岩","南平","漳州","福州","厦门","泉州","莆田","三明","宁德"]//CommonDatautils.findAllCity() + def citys = ["天津"]//CommonDatautils.findAllCity() for(def city : citys){ def data = fullCityMap.get(city) @@ -70,10 +79,10 @@ class TownStandardBatch extends BaseBatch{ def mzbRegionMap = CommonDatautils.queryMzbRegion(fullCityName) def shortRegionNameMap = CommonDatautils.getRegionShortName(fullCityName) - def townMap = CommonDatautils.queryTownByCity(fullCityName, ["city","district", "street", "alias"], mzbRegionMap) + def townMap = CommonDatautils.queryTownByCity(fullCityName, ["city","district", "street", "alias","shape"], mzbRegionMap) if(townMap){ def regionSet = townMap.keySet() - if(regionSet.size()>1){ + if(regionSet.size()>=1){ haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap) }else{ println city +" 无区域" @@ -139,11 +148,12 @@ class TownStandardBatch extends BaseBatch{ def haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap){ def results = [] if(fullCityName){ - def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name", "township"]) + def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name", "township","lng","lat"]) for(def d : districts){ - if(d.township){ - def towns = null - def updateTown = null + + def towns = null + def updateTown = null + if(d.region){ for(def m : townMap){ def fullRegionName = shortRegionNameMap.get(d.region) if(m.key == fullRegionName){ @@ -151,41 +161,51 @@ class TownStandardBatch extends BaseBatch{ break } } + } + if(!towns){ + towns = townMap.get(fullCityName) + } - def opt = true - if(towns){ - for(def town : towns){ - def townAlias = [] - if(town.alias){ - townAlias = town.alias - } - townAlias << town.street - if(townAlias.contains(d.township)){ - if(d.township!=town.street){ - updateTown = town.street - }else{ - opt = false - } - break - } + def opt = true + if(towns){ + for(def town : towns){ + def townAlias = [] + if(town.alias){ + townAlias = town.alias } - } - if(opt){ - if(updateTown){ - def udata = new BasicDBObject() - udata.put("township", updateTown) - udata.put("m_date", new Date()) - println d.city +" "+d.region+" "+d.name+" "+d.township +" 乡镇修改为:"+updateTown -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + townAlias << town.street + if(townAlias.contains(d.township)){ + if(d.township!=town.street){ + updateTown = town.street + }else{ + opt = false + } + break }else{ - def udata = new BasicDBObject() - udata.put("township", "") - udata.put("m_date", new Date()) - println d.city +" "+d.region+" "+d.name+" "+d.township +" 乡镇修改为:空值" -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + if(town.shape){ + def flag = InsidePolygon.isInArea(d.lng/10000000000.0, d.lat/10000000000.0, InsidePolygon.createPoint4(town.shape.coordinates)) + if(flag){ + updateTown = town.street + break + } + } } } - + } + if(opt){ + if(updateTown){ + def udata = new BasicDBObject() + udata.put("township", updateTown) + udata.put("m_date", new Date()) + println d.city +" "+d.region+" "+d.name+" "+d.township +" 乡镇修改为:"+updateTown + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + }else{ + def udata = new BasicDBObject() + udata.put("township", "") + udata.put("m_date", new Date()) + println d.city +" "+d.region+" "+d.name+" "+d.township +" 乡镇修改为:空值" + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + } } } } @@ -365,6 +385,33 @@ class TownStandardBatch extends BaseBatch{ return rets; } + def readCSV3(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + if(arrs.size()>=11 && arrs[10]=="是" && arrs[6]!=arrs[7]){ + def o = new BasicDBObject() + try{ + o.put("id", arrs[0]) + o.put("township", arrs[7]) + o.put("city", arrs[2]) + o.put("old_district", arrs[3]) + o.put("new_district", arrs[8]) + rets << o + }catch(Exception e){ + println arrs + } + } + + } + index++ + } + return rets; + } + def readCSV2(filename){ def lines = FileUtils.readLines(new File(filename)) def rets = []; @@ -380,10 +427,11 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - if(arrs.size()<=7){ - o.put("data_source","") - }else{ - o.put("data_source", arrs[7]) + o.put("data_source", arrs[7]) + if(arrs.size()>=9){ + o.put("township", arrs[8]) + o.put("new_district", arrs[9]) + o.put("town_source", arrs[10]) } rets << o }catch(Exception e){ @@ -395,43 +443,13 @@ class TownStandardBatch extends BaseBatch{ return rets; } - def readCSV3(filename){ - def lines = FileUtils.readLines(new File(filename)) - def rets = []; - def index = 0 - for(line in lines) { - if(line && index>=1){ - String[] arrs = line.split(",") - if(arrs.size()>=10 && arrs[7] && arrs[9]=="同区域"){ - def o = new BasicDBObject() - try{ - o.put("id", arrs[0]) - o.put("township", arrs[7]) - if(arrs.size()>=9 && arrs[8]){ - o.put("district", arrs[8]) - } - if(arrs.size()>=10 && arrs[9]){ - o.put("way", arrs[9]) - } - rets << o - }catch(Exception e){ - println arrs - } - } - - } - index++ - } - return rets; - } - def addTownByTownShape(){ def i = 0 def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式", "标准乡镇"] - while(i<50){ + while(i<=50){ def fileName = "/home/goojia/gj/new_poi/input/map/no_township_${i}.csv" if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\原始\\no_township_${i}.csv" + fileName = "D:\\数据\\数据建设\\乡镇街道\\no_township_${i}.csv" } File file=new File(fileName); if(file.exists()) { @@ -451,19 +469,53 @@ class TownStandardBatch extends BaseBatch{ } } + + def standardTown(){ + def i = 49 + def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式", "标准乡镇"] + + def cityTownMap = CommonDatautils.queryAllTown(["city", "district", "mzb_district_name", "street", "alias"]) + while(i<=50){ + def fileName = "/home/goojia/gj/new_poi/input/map/no_township_result_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图\\no_township_result_${i}.csv" + } + File file=new File(fileName); + if(file.exists()) { + def rets = readCSV2(fileName) + println i +" "+ rets.size() + def rows = addTownshipBatch2(rets, cityTownMap) + if (CommonDatautils.isWindow()) { + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图-验证乡镇\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + }else{ + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + } + println fileName +" 运行完成" + }else{ + println fileName +" 不存在" + } + i++ + } + } + def addTownshipBatch(def rets){ def results = new CopyOnWriteArrayList() def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(rets.size()) for(def i=0;i= 1) { @@ -476,6 +528,46 @@ class TownStandardBatch extends BaseBatch{ } finally { latch.countDown() } +// } +// }); + } + latch.await() + return results + } + + + def addTownshipBatch2(def rets, def cityTownMap){ + def results = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + for(def i=0;i= 1) { + if(townMap.size()>=1){ + r.strand_town = isStandTown(townMap, r.new_district, r.township) + } + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } } }); } @@ -610,20 +702,21 @@ class TownStandardBatch extends BaseBatch{ } def updateTownData(){ - def i = 0 + def i = 49 while(i<50) { def fileName = "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv" if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv" + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图-验证乡镇\\no_township_result_${i}.csv" } File file = new File(fileName); if (file.exists()) { def rets = readCSV3(fileName) println file.getAbsoluteFile().getName() +" "+(rets.size()*100/200000)+"%"+" "+rets.size() -// if(rets){ -// updateToEs(rets) -// } - + if(rets){ +// updateToEs(rets)//不能用这种方法修改,否则其它字段都将丢失 +// updateToEs2(rets) + updateDistTownship(rets) + } } i++ } @@ -677,4 +770,72 @@ class TownStandardBatch extends BaseBatch{ println "结束时间 "+new Date() } + def updateToEs2(rows) { + for (int i = 0; i < rows.size(); i++) { + def map = rows[i] + updateMapPoi(map.id, map.township) + } + } + + + def updateMapPoi(def id, def township){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/map_poi_2024/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.township='${township}'", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + + def updateDistTownship(rets){ + for(def m : rets){ + + def obj = CommonDatautils.findDistrictById(m.id) + if(obj.township != m.township){ + def udata = new BasicDBObject() + udata.put("township", m.township) + if(!m.new_district.contains(m.old_district)){ + def lists = CommonDatautils.findAllDistrictByName(obj.city, null, obj.name, obj.cat) + if(lists.size()<2){ + continue + } + def region = RegionData.formatRegion(m.city, m.new_district) + if(region){ + def dbo = CommonDatautils.findDistrict(m.city, region, obj.name, obj.cat) + if(dbo){ + udata.put("status", 1) + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(m.id)), new BasicDBObject('$set', udata)) + println "删除 "+m.city +" "+obj.name+" "+m.id+" "+obj.cat + continue + }else{ + udata.put("region", region) + } + } + } + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(m.id)), 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 bbe074507..da5899b14 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,6 +1,7 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData +import com.fangjia.core.util.HttpRequest import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.CosineSimilarAlgorithm @@ -11,6 +12,7 @@ import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl +import net.sf.json.JSONObject import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -38,8 +40,8 @@ class TownshipStrandUpdate { static main(args) { def task = new TownshipStrandUpdate() - task.process() - task.updateTown() +// task.process() +// task.updateTown() // task.stat() // task.updateDiffRegionTown() @@ -49,6 +51,9 @@ class TownshipStrandUpdate { // task.updateDevMapping() // println new Date().getTime() // task.updateSpecCityTown() + + + task.updateTownshipAlias() } @@ -629,4 +634,69 @@ class TownshipStrandUpdate { } } + + + def updateTownshipAlias(){ + def fileName = "D:\\数据\\数据建设\\乡镇街道\\20250219--乡镇街道添加别名.xlsx" + ExcelUtils.modify(fileName,{d-> + def q = new BasicDBObject("type","乡镇街道").append("city", d["A"]).append("district",d["B"]).append("street",d["C"]) + def list = ADMINISTRATIVE_MAPPING_COLL.find(q).toList() + def newAlias = d['D'] + if(list.size()==0){ + list = q.put("street", d['D']) + newAlias = d['C'] + list = ADMINISTRATIVE_MAPPING_COLL.find(q).toList() + } + if(list && list.size()==1){ + def obj = list[0] + def alias = obj.alias + if(!alias){ + alias = [] + } + if(!alias.contains(newAlias)){ + alias << newAlias + } + if(alias){ + def udata = new BasicDBObject() + udata.put("alias", alias) + udata.put("m_date", new Date()) + udata.put("operator","陈杰") + ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",obj._id), new BasicDBObject('$set',udata)) + } + +// updateStreetAlias(obj._id.toString(), alias.join("','")) + }else{ + println d["C"] +" "+ d["D"] + } + }) + } + + + def updateStreetAlias(def id, def alias){ + 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.alias=['${alias}']", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 35179b3d9..b69e526a4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -336,7 +336,7 @@ class FangjiaClientUtils { try { address = address.replace("{","") // def url = "http://192.168.0.19:31080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") - def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") + def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=true&addressAssessment=false" if(city){ url = url +"&city="+URLEncoder.encode(city,"UTF-8") } @@ -354,7 +354,7 @@ class FangjiaClientUtils { def jsonObj = null def content = null def url = null - address = address.replace("{","") + address = address.toString().replace("{","") int retryCount = 0 while (retryCount < 3) { url = "http://192.168.0.93:8080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true&fields=dev_confi" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy index f17e815dc..1be279a43 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy @@ -74,11 +74,11 @@ class OfficeFieldCleanBatch extends BaseBatch{ // addBlock() // addFieldValue() -// updateErrorField() + updateErrorField() // export() // test() // addOffice() - fileAddBlock() +// fileAddBlock() } def export(){ @@ -134,33 +134,196 @@ class OfficeFieldCleanBatch extends BaseBatch{ } def updateErrorField(){ -// def offices = CommonDatautils.findAllDistrict("office", ["city","estate_charge","addr_alias","property_life", "total_floor","finish_building_date","real_use_percent", "land_car_site", "underground_car_site","parking_fee"]) - def offices = CommonDatautils.findAllDistricts("上海","office", ["city","estate_charge","addr_alias","property_life", "total_floor","finish_building_date","real_use_percent", "land_car_site", "underground_car_site","parking_fee"]) + def offices = CommonDatautils.findAllDistrict("office", ["underground_car_site"]) +// def offices = CommonDatautils.findAllDistricts("上海","office", ["build_area"]) def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(offices.size()) for(def i=0;i60 || val < 0.35){ -//// println val -// udata.put("estate_charge", null) -//// } -// } + if(udata){ udata.put("m_date", new Date()) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy index e07ac0739..1b4bd8a80 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy @@ -27,7 +27,7 @@ class EsMonthHouseStat { // task.statDistHouse() // task.statRent() - task.statOfficeHouse() +// task.statOfficeHouse() } def statRent(){ 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 5cd666999..2e27e41cc 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 @@ -40,16 +40,58 @@ class AddPriceTest { def run(){ def filePath = "D:\\数据\\价格\\惠州.xlsx" // addGXDPrice(filePath) - addCcbPrice(filePath) +// addCcbPrice(filePath) // addThirdPrice(filePath) // addFjwPrice(filePath) // exportPkPrice() // addRegion() // addTradePrice(filePath) - + addThirdSamplePrice("D:\\数据\\建行\\房产估值\\指导价\\级联、国信达价格导入_0313.xlsx") } + def addThirdSamplePrice(filePath){ + ExcelUtils.modify(filePath,{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + def o = new BasicDBObject() + o.put("city" , dist.city) + o.put("region" , dist.region) + o.put("district_name" , dist.name) + o.put("isGuidancePrice" , 0) + o.put("category", "district") + o.put("c_date" , new Date()) + o.put("user_name" , "房价网") + + if(d['B']){ + o.put("price", d['B'].toString().toDouble().toInteger()) + o.put("source", "JL") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + if(d['C']){ + o.put("price", d['C'].toString().toDouble().toInteger()) + o.put("source", "GXD") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + + if(d['D']){ + o.put("price", d['D'].toString().toDouble().toInteger()) + o.put("source", "FXT") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + }) + } + + + def addTradePrice(filePath){ ExcelUtils.multiThreadingModify(filePath, { d -> if(d['Y']){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy index 980d2863d..8aa7b2d42 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy @@ -19,7 +19,7 @@ DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "commun //def s = getTownshipInfo("118.702988,39.740979") def filePath = "D:\\数据\\涉农\\县政府(最终).xlsx" ExcelUtils.modify(filePath, { row -> - if(!row['I'] && row['I']=='宝应县'){ + if(!row['I'] && row['I']=='建瓯市'){ def rets = EsSearchUtils.findPois(row['B'], row['C'], row['C']+"人民政府") if(rets){ def obj = findOneByName(rets, row['C']+"人民政府") 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 41ccc9e38..b5f10fe8d 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 @@ -1,18 +1,23 @@ package com.fangjia.script.gj.xiamen import com.fangjia.core.util.GeoUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.util.DateUtil 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.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.AMQP +import net.sf.json.JSONObject import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -23,7 +28,7 @@ import com.fangjia.script.common.DataHandleUtils class SeaweedDataSynch extends BaseBatch{ - static def targetUrl = "http://192.168.0.12:9200/seaweed/" + static def targetUrl = "http://192.168.0.89:9200/seaweed/" public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; @@ -132,17 +137,44 @@ class SeaweedDataSynch extends BaseBatch{ mcaDistMap = CommonDatautils.queryDistNameCityByMapping() // priceMap = findAllDistrictSellPrice() - def citys = CommonDatautils.findAllCity().reverse() + def citys = ["潮州"]//CommonDatautils.findAllCity() def index = 0 for(def c : citys){ index++ - updating(c, "district") + + def dists = updating(c, "district") + updateEs(c, dists) + + updating(c, "office") updating(c, "shop") + println index +" "+ c + " 完成" } } + def updateEs(city, dists){ + def data = fullCityMap.get(city) + def distEsDatas = findEsSeaweedDatas(data.city) + def resultMap = [:] + for(def d : dists){ + def esObj = distEsDatas.get(d._id.toString()) + def map = [:] + d.each {k,v-> + if(k!="_id"){ + def esVal = esObj.get(k) + if(v!=esVal){ + map.put(k, v) + } + } + } + if(map){ + resultMap.put(d._id.toString(), map) + } + } + return resultMap + } + def updating(city, cat){ def dists = CommonDatautils.findAllDistrictsFromMg(city, cat, ["city","region","name","address","block","mapping_alias","addr_alias","cat","estate_type2","status","township","lng","lat","build_type","household_count","committee","estate_charge","car_site_count","property_life","house_property","build_area","all_area","build_structure","developer","estate_company","cubage_percent","virescence_percent","loudong_count","schools","main_type","main_type_area","create_year"]) def rets = new CopyOnWriteArrayList() @@ -154,15 +186,13 @@ class SeaweedDataSynch extends BaseBatch{ void run() { try{ totalCount.addAndGet(1) - def map = createData(dist) - //往100 上同步 updateData(map) - - //往12 es上同步 -// def newUrl = targetUrl +"_doc/"+map.id -// CommonDatautils.httpSaveData(newUrl, map) + rets << map +// //往89 es上同步 +// def newUrl = targetUrl +"_doc/"+map._id +// CommonDatautils.httpSaveData89(newUrl, map) println city +" "+cat +" "+totalCount.get() +"/"+dists.size()+" "+dist.name+" "+map._id } catch (Exception e) { @@ -178,6 +208,33 @@ class SeaweedDataSynch extends BaseBatch{ return rets; } + def updateMapPoi(def id, def township){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/seaweed/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.township='${township}'", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + def updateData(map){ def udata = new BasicDBObject() map.each{k,v-> @@ -196,14 +253,14 @@ class SeaweedDataSynch extends BaseBatch{ if(province){ map.province = ProvinceData.getFullProvince(province) } - map.fangjia_province = province +// map.fangjia_province = province def data = fullCityMap.get(dist.city) if(data){ map.city = data.city area_code = data.mca_city_code } - map.fangjia_city = dist.city +// map.fangjia_city = dist.city def distData = mcaDistMap.get(dist.city+"#"+dist.region) if(distData){ @@ -213,9 +270,8 @@ class SeaweedDataSynch extends BaseBatch{ // map.region = dist.region println dist.city +" "+dist.region+" 民政部中没有找到相应的区域全称" } - map.area_code = area_code - - map.fangjia_region = dist.region +// map.area_code = area_code +// map.fangjia_region = dist.region map.name = dist.name @@ -390,6 +446,14 @@ class SeaweedDataSynch extends BaseBatch{ DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(row['A'])), new BasicDBObject('$set', udata)) } }) + } + def findEsSeaweedDatas(city){ + def map = new HashMap() + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) + ElasticUtils89.executeQuery("192.168.0.89", "seaweed", queryBuilder, { String id, doc-> + map.put(id, doc) + }) + return map; } } From 0b9aa8bed093510da28232658e45d169a7f7a46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 2 Apr 2025 13:39:31 +0800 Subject: [PATCH 206/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=98=89=E7=A7=AF=E9=95=87=E9=A1=BA?= =?UTF-8?q?=E6=B3=BD=E7=BF=A0=E5=B1=8F=E6=B9=BE22=E5=B9=A21=E5=8D=95?= =?UTF-8?q?=E5=85=831203=E6=88=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 40afe3fe6..d455751e1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -1,9 +1,8 @@ package com.fangjia.open.controllers; import com.fangjia.core.util.*; -import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.common.DistrictKey; -import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.mongo.model.ApiUserCfg; import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.Evaluation; @@ -17,7 +16,10 @@ import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.*; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.HouseInfomationModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.CommonUtils; import com.fangjia.open.ws.query.SampleQuery; @@ -26,13 +28,20 @@ import com.fangjia.service.api.ApiUserCfgService; import com.fangjia.service.bo.Collateral; import com.fangjia.service.bo.DistrictStatBo; import com.fangjia.service.bo.Sample; -import com.fangjia.service.datastore.*; +import com.fangjia.service.datastore.CzbankSampleService; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.datastore.OpenApiLogService; import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; -import com.fangjia.service.district.*; +import com.fangjia.service.district.DistrictFacilitysService; +import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.mongo.bkoff.LoudongService; import com.fangjia.service.mongo.fangjia.*; -import com.fangjia.service.open.*; +import com.fangjia.service.open.ApiUserAuthorityService; +import com.fangjia.service.open.EvaluateFactorService; +import com.fangjia.service.open.EvaluateRatioService; +import com.fangjia.service.open.FangjiaOfficialAreaService; import com.fangjia.service.web.AddressService; import net.sf.json.JSONObject; import org.apache.commons.lang.ArrayUtils; @@ -248,7 +257,7 @@ public class ComprehensiveQueryController { communityAvgPriceParams.put("category", "district"); communityAvgPriceParams.put("useMap", "true"); communityAvgPriceParams.put("suggestName", String.valueOf(model.getName())); - communityAvgPriceParams.put("preciseLevel", "strict"); +// communityAvgPriceParams.put("preciseLevel", "strict"); communityAvgPriceParams.put("propertyType", model.getPropertyType()); communityAvgPriceParams.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"); JSONObject matchResponse = null; From f76d5cce48317ef3d7c3b243742c4e4beb81e0ec Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 2 Apr 2025 15:20:11 +0800 Subject: [PATCH 207/247] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E8=A1=8C?= =?UTF-8?q?=E6=94=BF=E5=8C=BA=E5=88=92=E6=94=B9=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 47 ++++++++++++------- .../open/AdministrativeMappingService.java | 8 +++- .../AdministrativeMappingServiceImpl.java | 42 +++++++++++++++-- 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index d455751e1..f2037adbc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -38,10 +38,7 @@ import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.mongo.bkoff.LoudongService; import com.fangjia.service.mongo.fangjia.*; -import com.fangjia.service.open.ApiUserAuthorityService; -import com.fangjia.service.open.EvaluateFactorService; -import com.fangjia.service.open.EvaluateRatioService; -import com.fangjia.service.open.FangjiaOfficialAreaService; +import com.fangjia.service.open.*; import com.fangjia.service.web.AddressService; import net.sf.json.JSONObject; import org.apache.commons.lang.ArrayUtils; @@ -99,6 +96,8 @@ public class ComprehensiveQueryController { private EvaluateRatioService evaluateRatioService; + private AdministrativeMappingService administrativeMappingService; + private static final int EVALUATE_SHOW_DETAIL = 1; private static final Map PROPERTY_TYPES = new HashMap() { { @@ -235,19 +234,22 @@ public class ComprehensiveQueryController { } String cityStr = model.getCity(); - if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) { - AdministrativeDivision administrativeDivision = administrativeDivisionService.findcityByCode(cityStr); - if (administrativeDivision == null) { + String districtStr = model.getDistrict(); + String cityShort = ""; + if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+") && StringUtils.isBlank(districtStr)) { + cityShort = administrativeMappingService.findCityShortByCityCode(cityStr); + if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); return mav; } - String city = administrativeDivision.getCityShort(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); + } else if (districtStr.matches("\\d+")) { + cityShort = administrativeMappingService.findDistrictShortByDistrictCode(cityStr, districtStr); + if (StringUtils.isBlank(cityShort)) { + mav.setModel(BasicModel.buildBadRequestModel("区县代码错误")); return mav; } - model.setCity(city); } + model.setCity(cityShort); HttpRequest httpRequest = new HttpRequest(); JSONObject json = null; @@ -264,9 +266,11 @@ public class ComprehensiveQueryController { try { matchResponse = httpRequest.getJsonContent("http://open.fangjia.com/address/match", communityAvgPriceParams, "UTF-8"); // matchResponse = httpRequest.getJsonContent("http://192.168.0.19:31080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8"); - } catch (HttpRequestException e) { + } catch ( + HttpRequestException e) { } + // 去掉经纬度解析 // if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) { // //加上高德获取经纬度 和 根据经纬度估值 @@ -302,12 +306,14 @@ public class ComprehensiveQueryController { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); return mav; } + String id = matchResponse.getJSONObject("result").getString("id"); District district = districtService.findById(id); if (district == null) { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); return mav; } + MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, matchResponse.getJSONObject("result")); DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(district)); if (null != statBo) { @@ -359,7 +365,8 @@ public class ComprehensiveQueryController { propertyEvaluationModel.setName(district.getName()); try { evaluateAction(propertyEvaluationModel, httpServletRequest, houseValueInformation, mav); - } catch (IllegalAccessException e) { + } catch ( + IllegalAccessException e) { } // 价格下调10% @@ -379,17 +386,19 @@ public class ComprehensiveQueryController { sampleQuery.setStrctureArea(model.getSize()); sampleQuery.setAddress(model.getAddress()); -// RestfulModelAndView houseCaseMav = new RestfulModelAndView(); + // RestfulModelAndView houseCaseMav = new RestfulModelAndView(); List querys = null; try { querys = convertSampileQueryToBean(district, sampleQuery); - } catch (Exception e) { + } catch ( + Exception e) { mav.setModel(BasicModel.buildBadRequestModel(e.getMessage())); return mav; } if (null == sampleQuery.getMax()) { sampleQuery.setMax(10); } + // 此处慢 long start = System.currentTimeMillis(); List collaterals = czbankSampleService.findSampleForBse(querys, sampleQuery.getMax()); @@ -441,7 +450,9 @@ public class ComprehensiveQueryController { } // 将周边POI数据放到结果集 houseValueInformation.setSurroundingPoi(facilitys); - mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); + mav.setModel(BasicModel.buildOKModel(). + + setResult(houseValueInformation)); return mav; } @@ -1397,5 +1408,9 @@ public class ComprehensiveQueryController { public void setAdministrativeDivisionService(AdministrativeDivisionService administrativeDivisionService) { this.administrativeDivisionService = administrativeDivisionService; } + + public void setAdministrativeMappingService(AdministrativeMappingService administrativeMappingService) { + this.administrativeMappingService = administrativeMappingService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java index a0fc680e1..3c26ea411 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java @@ -12,8 +12,12 @@ import java.util.List; public interface AdministrativeMappingService { + public String findCityCodeByCityShort(String cityShort); - public String findCityCodeByCityShort(String cityShort); - public String findCityByCityShort(String cityShort) ; + public String findCityByCityShort(String cityShort); + + public String findCityShortByCityCode(String cityCode); + + public String findDistrictShortByDistrictCode(String cityCode,String districtCode); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java index 521b1e5ef..7b7cbbeed 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java @@ -67,7 +67,7 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe )); - public String findCityCodeByCityShort(String cityShort) { + public String findCityCodeByCityShort(String cityShort) { ArrayList params = new ArrayList(); params.add(new QueryParam("cityShort", cityShort)); params.add(new QueryParam("type", "城市")); @@ -78,7 +78,7 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe return null; } - public String findCityByCityShort(String cityShort) { + public String findCityByCityShort(String cityShort) { if (CITY_SHORT.contains(cityShort)) { ArrayList params = new ArrayList(); params.add(new QueryParam("cityShort", cityShort)); @@ -91,7 +91,43 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe return cityShort; } - public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { + @Override + public String findCityShortByCityCode(String cityCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("type", "城市")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + @Override + public String findDistrictShortByDistrictCode(String cityCode, String districtCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("mzbDistrictCode", districtCode)); + params.add(new QueryParam("type", "区域")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + + public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { this.administrativeMappingDao = administrativeMappingDao; } } From f0f55c67a6b01c94b342673c6328933723650d3e Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 2 Apr 2025 15:40:43 +0800 Subject: [PATCH 208/247] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E8=A1=8C?= =?UTF-8?q?=E6=94=BF=E5=8C=BA=E5=88=92=E6=94=B9=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index f2037adbc..e0d0fddff 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -235,14 +235,14 @@ public class ComprehensiveQueryController { String cityStr = model.getCity(); String districtStr = model.getDistrict(); - String cityShort = ""; + String cityShort = model.getCity(); if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+") && StringUtils.isBlank(districtStr)) { cityShort = administrativeMappingService.findCityShortByCityCode(cityStr); if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); return mav; } - } else if (districtStr.matches("\\d+")) { + } else if (StringUtils.isNotBlank(districtStr) && districtStr.matches("\\d+")) { cityShort = administrativeMappingService.findDistrictShortByDistrictCode(cityStr, districtStr); if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("区县代码错误")); From dfc885ce3810b3cc624622ec49809951fe79d4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 3 Apr 2025 17:34:22 +0800 Subject: [PATCH 209/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/PropertyController.java | 6 +++++- 1 file changed, 5 insertions(+), 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 7c4c4ab00..57f2da122 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 @@ -2443,7 +2443,11 @@ public class PropertyController { item.put("city", districtStat.getCity()); item.put("district", districtStat.getRegion()); item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvg_price_2b()); + if (districtStat.getAvg_price_2b() != null) { + item.put("avgPrice", districtStat.getAvg_price_2b()); + } else { + item.put("avgPrice", districtStat.getAvgPrice()); + } if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); } else { From a6ec66ceea0ec0fed77f228211fe3841bff45cf2 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:43:15 +0800 Subject: [PATCH 210/247] =?UTF-8?q?es=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/util/ElasticUtils.groovy | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy index 6aba12207..a611fedc8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy @@ -1,5 +1,8 @@ package com.fangjia.script.util +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import net.sf.json.JSONObject import org.apache.http.HttpHost import org.apache.http.auth.AuthScope import org.apache.http.auth.UsernamePasswordCredentials @@ -17,11 +20,13 @@ 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.action.support.WriteRequest 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.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.search.Scroll import org.elasticsearch.search.SearchHit @@ -262,4 +267,68 @@ class ElasticUtils { client.close() return results; } + + static def modify(id, 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", id).source(map, XContentType.JSON)); + if (request.numberOfActions() > 100) { + 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" + } + } + 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" + } + } + } + + static def delete(id, host, indexName){ + def header = [:] + if(host && host == "192.168.0.89"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + }else if(host && host == "192.168.0.52"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString() + } + String seawaterUrl = "http://${host}:9200/${indexName}/_delete_by_query" + def body = """ + { + "query": { + "bool": { + "must": [ + { + "match": { + "id": "${id}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + println(res) + } + } From d9a4f8de07bd1f6b1058e7280915eb74e2ff4f0f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:43:51 +0800 Subject: [PATCH 211/247] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/SynchDevDataBatch.groovy | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy new file mode 100644 index 000000000..dc96e2246 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy @@ -0,0 +1,119 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap + +/** + * 将43上的开发区同步到mongo-100, es-89, es-52 + */ +class SynchDevDataBatch extends BaseBatch{ + + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection development_zone_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL) + + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + static main(args) { + runBatch(new SynchDevDataBatch(), args); + } + + @Override + public void process(Object args) { + def devMap = synchDevTo100() +// synchDevToEs(devMap) +// synchDevEs(devMap, "192.168.0.89") + synchDevEs(devMap, "192.168.0.52") + } + + def synchDevTo100(){ + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find() + def rets = [] + def devMap = [:] + for(def r : dbcursor){ + rets << r + devMap.put(r._id.toString(), r) + } + //删除旧的,再同步新的 + development_zone_CONN.remove(new BasicDBObject()) + development_zone_CONN.insert(rets) + return devMap; + } + + def synchDevToEs(devMap){ +// def esDevs = findEsDevDatas() +// def ids = [] +// for(def dev : devDatas){ +// ids << dev._id.toString() +// def esObj = esDevs.get(dev._id.toString()) +// def updateValMap = [:] +// if(esObj){ +// dev.each{k,v-> +// if(k!="id" && k!="_id"){ +// def val = dev.get(k) +// if(val!=v){ +// updateValMap.put(k,val) +// } +// } +// } +// } +// if(!esObj || (esObj && updateValMap)){ +// ElasticUtils.modify(dev._id.toString(), dev, "192.168.0.89", "development_zone") +// ElasticUtils.modify(dev._id.toString(), dev, "192.168.0.52", "development_zone") +// } +// } +// +// def esDelIds = [] +// esDevs.each{id,map-> +// if(!ids.contains(id)){ +// ElasticUtils.delete(id, "192.168.0.89", "development_zone") +// ElasticUtils.delete(id, "192.168.0.52", "development_zone") +// esDelIds << id +// } +// } +// println "Es删除开发区数量:"+esDelIds.size() + } + + + def synchDevEs(devMap, host){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery() + + ElasticUtils89.executeQuery(host, "development_zone", queryBuilder, { String id, doc-> + def mongoObj = devMap.get(id) + def updateFieldCount = 0 + mongoObj.each{k,v-> + if(!["id","_id" ,"build_date" ,"create_time","bd_shape","img_url","operator","operate_result","m_date","township","block"].contains(k)){ + def val = doc.get(k) + if(val!=v){ + println doc.name +" 修改 "+k+" "+ v+" "+id +// updateValMap.put(k,val) + updateFieldCount++ + doc.put(k,v) + } + } + } + if(mongoObj && updateFieldCount){ + //进行修改 + return true + }else{ + if(!mongoObj){ + println "删除:"+id +" "+doc.name + ElasticUtils.delete(id, host, "development_zone") + return false + } + } + }) + } + + + + + +} From 076e72419925a658c4781bf9c636d6c602efb84f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:45:15 +0800 Subject: [PATCH 212/247] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5100=2089=2052?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/xiamen/SeaweedDataSynch.groovy | 208 +++++++++++++++--- 1 file changed, 182 insertions(+), 26 deletions(-) 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 b5f10fe8d..65bbe11f6 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 @@ -4,6 +4,7 @@ import com.fangjia.core.util.GeoUtils import com.fangjia.core.util.HttpRequest import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils + import com.fangjia.script.util.DateUtil import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils @@ -15,7 +16,19 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.AMQP import net.sf.json.JSONObject + +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.* +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + import org.bson.types.ObjectId +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 import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders @@ -24,15 +37,17 @@ import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong -import com.fangjia.script.common.DataHandleUtils +/** + * 同步小区,商铺,写字楼到89,52上 + */ class SeaweedDataSynch extends BaseBatch{ static def targetUrl = "http://192.168.0.89:9200/seaweed/" public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; - DBCollection SEAWEED_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed", MONGO100_URL) + DBCollection SEAWEED_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_dishu", MONGO100_URL) DBCollection administrative_division_100_CONN = MongoUtils.getCollectionByName2("fangjia", "administrative_division_2023", MONGO100_URL) DBCollection administrative_division_2022_CONN = MongoUtils.getCollectionByName2("fangjia", "administrative_division", MONGO100_URL) @@ -136,43 +151,103 @@ class SeaweedDataSynch extends BaseBatch{ fullCityMap = CommonDatautils.queryFullNameCity() mcaDistMap = CommonDatautils.queryDistNameCityByMapping() -// priceMap = findAllDistrictSellPrice() - def citys = ["潮州"]//CommonDatautils.findAllCity() + priceMap = findAllDistrictSellPrice() + def citys = ["福州"]//CommonDatautils.findAllCity() def index = 0 for(def c : citys){ index++ def dists = updating(c, "district") - updateEs(c, dists) +// updateEs(c, dists, "district", "192.168.0.89") + updateEs(c, dists, "district", "192.168.0.52") +// def offices = updating(c, "office") +// updateEs(c, offices, "office", "192.168.0.89") +// updateEs(c, offices, "office", "192.168.0.52") - updating(c, "office") - updating(c, "shop") +// def shops = updating(c, "shop") +// updateEs(c, shops, "shop", "192.168.0.89") +// updateEs(c, offices, "shop", "192.168.0.52") println index +" "+ c + " 完成" } } - def updateEs(city, dists){ + def updateEs(city, dists, cat, host){ def data = fullCityMap.get(city) - def distEsDatas = findEsSeaweedDatas(data.city) - def resultMap = [:] - for(def d : dists){ - def esObj = distEsDatas.get(d._id.toString()) - def map = [:] - d.each {k,v-> - if(k!="_id"){ - def esVal = esObj.get(k) - if(v!=esVal){ - map.put(k, v) + def distEsDatas = findEsSeaweedDatas(data.city, cat, host) + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + def updateDatas = new CopyOnWriteArrayList() + def ids = new CopyOnWriteArrayList() + //更新89Es + for(def i=0;i + if(!ids.contains(id)){ + delEsData(id, host, "seaweed") + esDelIds << id } } - return resultMap + println "Es 删除 ${cat}类型:"+esDelIds.size() + //将100 mongodb中非正常小区删除 + def mongoIds = findMongoDbDatas(cat, data.city) + + mongoIds.each{id-> + if(!ids.contains(id)){ + SEAWEED_CONN.remove(new BasicDBObject("_id", new ObjectId(id))) + } + } + + } + + def updatingEs(d, esObj, host){ + def map = [:] + def diffMap = [:] + d.each {k,v-> + if(v && k!="_id"){ + map.put(k, v) + } + if(esObj && k!="_id"){ + def esVal = esObj.get(k) + if(esVal!=v){ + diffMap.put(k,v) + } + } + } + if(!esObj || (esObj && diffMap)){ + map.put("id", d._id.toString()) + return map + } + return null } def updating(city, cat){ @@ -392,7 +467,7 @@ class SeaweedDataSynch extends BaseBatch{ map.avg_price = dataMap.avg_price } } - + map.status = 0 // map.update_date = org.apache.commons.httpclient.util.DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss").replace(" ","T") return map } @@ -448,12 +523,93 @@ class SeaweedDataSynch extends BaseBatch{ }) } - def findEsSeaweedDatas(city){ + def findEsSeaweedDatas(city, cat, host){ def map = new HashMap() - QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) - ElasticUtils89.executeQuery("192.168.0.89", "seaweed", queryBuilder, { String id, doc-> + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("category", cat)) + ElasticUtils89.executeQuery(host, "seaweed", queryBuilder, { String id, doc-> map.put(id, doc) }) return map; } + + def updateSeaweedEs(updateDatas, 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) + } + + updateDatas.each{map-> + request.add(new IndexRequest(indexName, "_doc", map.id).source(map, XContentType.JSON)); + if (request.numberOfActions() >= 100) { + 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 "+host + } + request = new BulkRequest(); + } + } + + 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 "+host + } + } + } + + def delEsData(id, host, indexName){ + def header = [:] + if(host && host == "192.168.0.89"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + }else if(host && host == "192.168.0.52"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString() + } + String seawaterUrl = "http://${host}:9200/${indexName}/_delete_by_query" + def body = """ + { + "query": { + "bool": { + "must": [ + { + "match": { + "id": "${id}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + println(res) + } + + def findMongoDbDatas(cat, city){ + def q = new BasicDBObject("category", cat).append("city", city) + def keys = new BasicDBObject() + keys.put("_id",1) + def dbcursor = SEAWEED_CONN.find(q, keys) + def mongoIds = [] + for(def d : dbcursor){ + mongoIds << d._id.toString() + } + return mongoIds + } + + } From 961887256046b35527533450bb7d6376497eaffd Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:45:55 +0800 Subject: [PATCH 213/247] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=8C=BA=E5=9B=B4?= =?UTF-8?q?=E6=A0=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/AddDevShapeData.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy index 19934afd6..a2d1c56b8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy @@ -189,13 +189,13 @@ class AddDevShapeData { def run(){ - def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\218\\' + def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\临时-没付费\\' def dir = new File(directoryPath) if (dir.isDirectory()) { dir.eachFileRecurse(FileType.FILES) { file -> process(file.absolutePath) } -// addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") + addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") } else { println "The specified path is not a directory." } From 780f1dccb135797f93d5560b14d2d98fe1b9507c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:47:28 +0800 Subject: [PATCH 214/247] =?UTF-8?q?=E6=8C=87=E5=AE=9Ahost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/xiamen/ElasticUtils89.groovy | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) 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 index a401bf480..b1b772b92 100644 --- 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 @@ -99,6 +99,29 @@ class ElasticUtils89 { return new RestHighLevelClient(builder) } + static RestHighLevelClient getClientOther(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", "goojia123456"));// + httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + return httpAsyncClientBuilder; + } + }) + return new RestHighLevelClient(builder) + } + static RestHighLevelClient getClient89(String host) { RestClientBuilder builder = RestClient.builder(new HttpHost(host, 9200, "http")); @@ -174,7 +197,12 @@ class ElasticUtils89 { static executeQuery(String host, String indexName, QueryBuilder qb, Closure closure){ - RestHighLevelClient client = getClient(host) + RestHighLevelClient client = null + if(host == "192.168.0.89"){ + client = getClient(host); + }else if(host == "192.168.0.52"){ + client = getClientOther(host); + } BulkProcessor bulkProcessor = createBulkProcessor(host, client) final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(60L)) SearchRequest searchRequest = new SearchRequest(indexName); @@ -190,10 +218,11 @@ class ElasticUtils89 { 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() { +// executorService.submit(new Runnable() { +// @Override +// void run() { try{ + if(closure.getMaximumNumberOfParameters() == 1){ def update = closure.call(hit.getSourceAsMap()) if(update){ @@ -208,8 +237,8 @@ class ElasticUtils89 { }catch (Exception e){ e.printStackTrace() } - } - }) +// } +// }) } SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); From 0a99a465d0d3861e9316775af143060f04d7ca2c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 14:48:29 +0800 Subject: [PATCH 215/247] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/location/RegionPoint.groovy | 97 ++++++++++++++++--- 1 file changed, 82 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy index e80dd9c35..030658e63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy @@ -5,6 +5,7 @@ import com.fangjia.core.RegionData import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject import org.apache.commons.lang.math.RandomUtils @@ -17,8 +18,9 @@ import java.util.regex.Pattern */ class RegionPointCrawl { - static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") + static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") static DBCollection GAODECITYCODECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "gaode_city_code") + static DBCollection OLD_POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") static main(args) { def task = new RegionPointCrawl(); @@ -26,16 +28,19 @@ class RegionPointCrawl { //4个直辖市 北京市、上海市、天津市、重庆市 //5个自治区 "内蒙古自治区","广西壮族自治区","西藏自治区","宁夏回族自治区","新疆维吾尔自治区" // def provinces = ["河北省", "山西省","吉林省","辽宁省", "黑龙江省", "陕西省", "甘肃省", "青海省", "山东省", "福建省", "浙江省", "台湾省", "河南省", "湖北省", "湖南省", "江西省", "江苏省", "安徽省", "广东省", "海南省", "四川省", "贵州省", "云南省"] - def provinces = ["甘肃省"] - def index = 0 - for(def p : provinces){ - index ++ - println index +"/"+provinces.size() +" "+p - task.crawlCityAndDistrictCode(p); - println "城市 区域 code 完成" - task.run(p); - println "区域围栏 完成" - } + //已跑:甘肃省,河北省,山西省,"吉林省","辽宁省", "黑龙江省", "陕西省", "青海省", "山东省", "福建省", "浙江省", "台湾省", "河南省", "湖北省", "湖南省", "江西省", "江苏省", "安徽省", "广东省", "海南省", "四川省", "贵州省","云南省" +// def provinces = ["北京市","上海市","天津市","重庆市" ] +// def index = 0 +// for(def p : provinces){ +// index ++ +// println index +"/"+provinces.size() +" "+p +// task.crawlCityAndDistrictCode(p); +// println "城市 区域 code 完成" +// task.run(p); +// println "区域围栏 完成" +// } + + task.statSame() } @@ -47,7 +52,10 @@ class RegionPointCrawl { def cityCodes = findCityCode(pro); if(cityCodes){ for(def cityMap : cityCodes){ - def codeMap = findAllDistrictCode(cityMap.city_code); + def codeMap = findAllDistrictCode(cityMap.city_code, "district"); +// if(!codeMap){ +// codeMap = findAllDistrictCode(cityMap.city_code, "street"); +// } def index = 0 for(def m : codeMap){ index ++ @@ -93,7 +101,7 @@ class RegionPointCrawl { def saveGaoDeRegionCode(province, cityName,districts){ if(districts){ for(def dist : districts){ - if(dist.level=="district" || cityName=="东莞市"){ + if(dist.level=="district" || dist.level=="street" ){ saveGaoDeCityRegionCode(province, dist.name, dist.citycode, dist.adcode, dist.center, dist.level); } } @@ -125,10 +133,10 @@ class RegionPointCrawl { return new BasicDBObject("$regex", pattern); } - def findAllDistrictCode(def citycode){ + def findAllDistrictCode(def citycode, def level){ def q = new BasicDBObject() q.put("city_code", citycode) - q.put("level", "district") + q.put("level", level) def dbcursor = GAODECITYCODECOLL.find(q) def rets = [] for(def d : dbcursor){ @@ -149,6 +157,7 @@ class RegionPointCrawl { def o = GAODECITYCODECOLL.findOne(q) if(!o){ + println name +" "+adcode+" 新增" q.put("c_date", new Date()) q.put("center", center) GAODECITYCODECOLL.save(q); @@ -233,4 +242,62 @@ class RegionPointCrawl { def count = RandomUtils.nextInt(KeyList.size()) return KeyList.get(count); } + + def statSame(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject()).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + + def index = 0 + for(def d : dbcursor){ + index++ + def q = new BasicDBObject() + q.put("city",d.city) + q.put("region", d.region) + def obj = OLD_POLYLINECOLL.findOne(q) + if(obj){ + if(obj.polyline!=d.polyline){ + println index +" "+ d.city +" "+d.region+" 2次区域不同" + } + }else{ + println index +" "+ d.city +" "+d.region+" 没有此区域" + } + } + } + + + def regionPolyline(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject("level","district")) + def map = [:] + for(def d : dbcursor){ + def resultMap = [:] + resultMap.type = "polygon" + def arrs = d.polyline.split("\\|") + def rets = [] + for(def s : arrs){ + def points = s.split(";") + def pointList = [] + for(def pointStr : points){ + def pointArr = pointStr.split(",") + pointList << [pointArr[0].toString().toDouble(), pointArr[1].toString().toDouble()] + } + rets << pointList + } + resultMap.coordinates = rets + if(rets.size()>1) { + resultMap.type = "MultiPolygon" + } + println d.city+" "+d.region+" "+rets.size() + + def udata = new BasicDBObject() + udata.put("shape", resultMap) + def center = d.center + if(center){ + def pointArrs = center.split(",") + udata.put("location", ["lon":pointArrs[0].toString().toDouble(), "lat":pointArrs[1].toString().toDouble()]) + } + + def fullCity = fullCityMap.get(d.city) + map.put(fullCity.city+"|@|"+d.region, udata) + } + return map; + } } From f0548b3fe0dff94fca6cf45cdc7b90c5b5374dda Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 15:15:02 +0800 Subject: [PATCH 216/247] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=88=AB=E5=90=8D?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 88 ++++++++++++++----- 1 file changed, 64 insertions(+), 24 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy index c7bcaf957..6483d1b7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -18,11 +18,45 @@ class AddrAlaisProcess { static main(args) { def task = new AddrAlaisProcess() // task.run() +// task.splitDist() +// task.addAddr() task.nineApi() // task.createResult() // task.mergeResult() } + def splitDist(){ + def rows = ExcelUtils.read("D:\\数据\\数据建设\\小区\\全量小区地址及地址别名.xlsx",0,1) + println "原始总计:"+rows.size() + def rets = [] + for(def d : rows){ + def addr = d['F'] + if(d['G']){ + addr = addr +","+d['G'] + } + + def addrs = addr.split(",") + for(def s : addrs){ + rets << [d['A'], d['B'], d['C'], d['D'], d['E'], s] + } + } + println "总计:"+rets.size() + FileUtils.batchCreateFileByCustomSuffix(rets, "D:\\数据\\数据建设\\小区\\有地址小区地址标准化(一行一个地址).bat", null, "utf-8", false, " ",""); + } + + def addAddr(){ + def fileName = "D:\\数据\\数据建设\\小区\\无地址小区.xlsx" + ExcelUtils.multiThreadingModify(fileName,{d-> + def dist = CommonDatautils.findDistrictById(d['B']) + if(dist){ +// d['F'] = dist.address + if(dist.addr_alias){ + d['G'] = dist.addr_alias.join(",") + } + } + }) + } + def mergeResult(){ def rets = ExcelUtils.read("D:\\数据\\数据建设\\小区\\ai-结果-0221.xlsx",0,1) @@ -66,28 +100,31 @@ class AddrAlaisProcess { def nineApi(){ - def fileName = "/home/goojia/gj/district/addr_alias.xlsx" - if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\数据建设\\写字楼\\写字楼待处理地址.xlsx" - } - ExcelUtils.multiThreadingModify(fileName, {d-> - def obj = CommonDatautils.findDistrictById(d['A']) -// def addrMap = nineAddrSplit(obj.city, d['B']) - def addrList = [] -// if(addrMap && addrMap.address){ -// d['C'] = addrMap.road -// d['D'] = addrMap.road_num -// } - if(d['C']){ - def data = fullCityMap.get(obj.city) - if(data){ - def roadObj = findBaiduDatas( data.city, d['C']) - if(roadObj){ - d['E'] = "百度存在" - } - } - } + def i = 0; + while(i<20) { + def fileName = "/home/goojia/gj/district/dist_addr_${i}.xlsx" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\小区\\dist_addr_0.xlsx" + } + File file=new File(fileName); + if(file.exists()){ + ExcelUtils.multiThreadingModify(fileName, {d-> + def addrMap = nineAddrSplit(d['D'], d['G']) + def addrList = [] + if(addrMap && addrMap.address){ + d['H'] = addrMap.road + d['I'] = addrMap.road_num + } + if(d['H']){ + def data = fullCityMap.get(d['D']) + if(data){ + def roadObj = findBaiduDatas( data.city, d['H']) + if(roadObj){ + d['J'] = "百度存在" + } + } + } // if(d['F']){ // def addrs = d['F'].split(",") // def addr_alias = [] @@ -102,7 +139,10 @@ class AddrAlaisProcess { // } // d['I'] = addr_alias.join(",") // } - }) + }) + println fileName +" 完成 " + } + } } @@ -148,7 +188,7 @@ class AddrAlaisProcess { def num = 0 for(def d : districts){ num++ - def row = [num, d.city, d.region, d.name, d.address] + def row = [num, d._id.toString(), d.city, d.region, d.name, d.address] if(d.addr_alias){ row << d.addr_alias.join(",") } @@ -156,7 +196,7 @@ class AddrAlaisProcess { } } // ExcelUtils.write("D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.xlsx", rows, "小区") - FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.bat", null, "utf-8", false, "#",""); + FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化-20250402.bat", null, "utf-8", false, "#",""); } def findBaiduDatas(city, name){ From d73ee6e1ead0af2ff1e63de53070b38f41632911 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 16:05:51 +0800 Subject: [PATCH 217/247] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SynchAdministrativeMappingDataBatch.groovy | 83 +++++++++++++++++++ .../gj/data_handle/SynchDevDataBatch.groovy | 3 +- 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy new file mode 100644 index 000000000..333ad1ef8 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -0,0 +1,83 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +class SynchAdministrativeMappingDataBatch extends BaseBatch{ + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection ADMINISTRATIVE_MAPPING_COLL_100 = MongoUtils.getCollectionByName2("fangjia", "administrative_mapping", MONGO100_URL) + + DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + + static main(args) { + runBatch(new SynchAdministrativeMappingDataBatch(), args); + } + + @Override + public void process(Object args) { + def retMap = synchAdminiMappingTo100() + synchToEs(retMap, "192.168.0.89") +// synchToEs(retMap, "192.168.0.52") + } + + def synchAdminiMappingTo100(){ + //删除旧的,再同步新的 + ADMINISTRATIVE_MAPPING_COLL_100.remove(new BasicDBObject()) + + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(new BasicDBObject()).batchSize(1000) + def datas = [] + def retMap = [:] + for(def d : dbcursor){ + datas << d + retMap.put(d._id.toString(), d) + if (datas.size() >= 2000) { + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + println datas.size() + datas.clear(); + } + } + + if (datas.size() >= 0) { + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + datas.clear(); + } + + return retMap; + } + + def synchToEs(devMap, host){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery() + + ElasticUtils89.executeQuery(host, "administrative_mapping", queryBuilder, { String id, doc-> + def mongoObj = devMap.get(id) + def updateFieldCount = 0 + mongoObj.each{k,v-> + if(!["id","_id"].contains(k)){ + def val = doc.get(k) + if(val!=v){ + println doc.name +" 修改 "+k+" "+ v+" "+id +// updateValMap.put(k,val) + updateFieldCount++ + doc.put(k,v) + } + } + } + if(mongoObj && updateFieldCount){ + //进行修改 + return true + }else{ + if(!mongoObj){ + println "删除:"+id +" "+doc.name + ElasticUtils.delete(id, host, "administrative_mapping") + return false + } + } + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy index dc96e2246..893da6125 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy @@ -28,8 +28,7 @@ class SynchDevDataBatch extends BaseBatch{ @Override public void process(Object args) { def devMap = synchDevTo100() -// synchDevToEs(devMap) -// synchDevEs(devMap, "192.168.0.89") + synchDevEs(devMap, "192.168.0.89") synchDevEs(devMap, "192.168.0.52") } From bfc789349bab98c5683c4fdde1763ce9bad3edac Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 16:31:59 +0800 Subject: [PATCH 218/247] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_handle/SynchAdministrativeMappingDataBatch.groovy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy index 333ad1ef8..5b09c47a3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -38,7 +38,6 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ retMap.put(d._id.toString(), d) if (datas.size() >= 2000) { ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); - println datas.size() datas.clear(); } } @@ -58,10 +57,10 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ def mongoObj = devMap.get(id) def updateFieldCount = 0 mongoObj.each{k,v-> - if(!["id","_id"].contains(k)){ + if(!["id","_id","c_date","m_date","polyline_source","operator"].contains(k)){ def val = doc.get(k) if(val!=v){ - println doc.name +" 修改 "+k+" "+ v+" "+id + println doc.name +" 修改 "+id // updateValMap.put(k,val) updateFieldCount++ doc.put(k,v) From 5d76a0222ae8f77bfb599270e38182d0895fa746 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 8 Apr 2025 16:36:30 +0800 Subject: [PATCH 219/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 1 + .../script/gj/xiamen/SeaweedDataSynch.groovy | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy index 6483d1b7d..45d1c598a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -142,6 +142,7 @@ class AddrAlaisProcess { }) println fileName +" 完成 " } + i++ } } 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 65bbe11f6..0955b9921 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 @@ -152,22 +152,22 @@ class SeaweedDataSynch extends BaseBatch{ mcaDistMap = CommonDatautils.queryDistNameCityByMapping() priceMap = findAllDistrictSellPrice() - def citys = ["福州"]//CommonDatautils.findAllCity() + def citys = CommonDatautils.findAllCity() def index = 0 for(def c : citys){ index++ def dists = updating(c, "district") -// updateEs(c, dists, "district", "192.168.0.89") + updateEs(c, dists, "district", "192.168.0.89") updateEs(c, dists, "district", "192.168.0.52") -// def offices = updating(c, "office") -// updateEs(c, offices, "office", "192.168.0.89") -// updateEs(c, offices, "office", "192.168.0.52") + def offices = updating(c, "office") + updateEs(c, offices, "office", "192.168.0.89") + updateEs(c, offices, "office", "192.168.0.52") -// def shops = updating(c, "shop") -// updateEs(c, shops, "shop", "192.168.0.89") -// updateEs(c, offices, "shop", "192.168.0.52") + def shops = updating(c, "shop") + updateEs(c, shops, "shop", "192.168.0.89") + updateEs(c, offices, "shop", "192.168.0.52") println index +" "+ c + " 完成" } From d1a821af0cf1a06ada7d2a854e8ca8db78e8da5d Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 9 Apr 2025 09:52:54 +0800 Subject: [PATCH 220/247] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SynchAdministrativeMappingDataBatch.groovy | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy index 5b09c47a3..00b912a8c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -9,6 +9,8 @@ import com.mongodb.DBCollection import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders +import java.util.concurrent.CopyOnWriteArrayList + class SynchAdministrativeMappingDataBatch extends BaseBatch{ def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; DBCollection ADMINISTRATIVE_MAPPING_COLL_100 = MongoUtils.getCollectionByName2("fangjia", "administrative_mapping", MONGO100_URL) @@ -50,20 +52,25 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ return retMap; } - def synchToEs(devMap, host){ + def synchToEs(retMap, host){ QueryBuilder queryBuilder = QueryBuilders.boolQuery() + def oldIds = new CopyOnWriteArrayList() + ElasticUtils89.executeQuery(host, "administrative_mapping", queryBuilder, { String id, doc-> - def mongoObj = devMap.get(id) + oldIds << id + def mongoObj = retMap.get(id) def updateFieldCount = 0 mongoObj.each{k,v-> - if(!["id","_id","c_date","m_date","polyline_source","operator"].contains(k)){ + if(!["id","_id","c_date","m_date","polyline_source","operator","city_simple_pinyin","prefecture_level_city"].contains(k)){ def val = doc.get(k) if(val!=v){ - println doc.name +" 修改 "+id // updateValMap.put(k,val) - updateFieldCount++ - doc.put(k,v) + if(v.type!="MultiPolygon"){ + println k +" 修改 "+id + updateFieldCount++ + doc.put(k,v) + } } } } @@ -78,5 +85,22 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ } } }) + + + def addEsDatas = [] + retMap.each{id,map-> + if(!oldIds.contains(id)){ + println "需新增:"+id + map.remove("c_date") + map.remove("m_date") + map.remove("polyline_source") + map.remove("operator") + addEsDatas << map + } + } + if(addEsDatas){ + ElasticUtils89.updateEs(addEsDatas, host, "administrative_mapping") + } + } } From 781731edcbaea395b308e8fb09db9475b2c4f845 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 9 Apr 2025 16:20:26 +0800 Subject: [PATCH 221/247] =?UTF-8?q?=E6=B1=9F=E5=8D=97=E8=A1=8C=E6=88=BF?= =?UTF-8?q?=E6=BA=90=E4=BB=B7=E6=A0=BC=E6=94=B9=E4=B8=BA=E5=B7=AE30%?= =?UTF-8?q?=EF=BC=8C=E4=BB=8EES=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 3 + .../datastore/CzbankSampleServiceImpl.java | 69 ++++++++++++++----- .../com/fangjia/service/util/CommonUtils.java | 41 +++++++++++ 3 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 8641e498f..04379c299 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -329,6 +329,9 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i } catch (Exception e) { seawater.setpDate(0); } + if (source.containsKey("publish_date")){ + seawater.setPublishDate(source.getString("publish_date")); + } if (source.containsKey("url")) { seawater.setUrl(source.getString("url")); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index f6177cfca..8cdd9018a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -1,9 +1,8 @@ package com.fangjia.service.datastore; import com.fangjia.core.util.*; -import com.fangjia.dal.QueryParam; -import com.fangjia.dal.SortParam; -import com.fangjia.dal.SrQuery; +import com.fangjia.dal.*; +import com.fangjia.dal.seawater.dao.SeawaterDao; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.datastore.dao.HouseDao; import com.fangjia.dal.datastore.model.House; @@ -14,6 +13,7 @@ import com.fangjia.dal.mongo.model.DistrictStat; import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; import com.fangjia.dal.mongo.model.bkoff.DealPrice; import com.fangjia.dal.mongo.model.bkoff.Loudong; +import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.address.mode.ProvinceData; import com.fangjia.service.bo.Collateral; @@ -24,12 +24,15 @@ import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; import com.fangjia.service.datastore.bean.ShopCollateralSampleQueryBean; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.open.FangjiaOfficialAreaService; +import com.fangjia.service.util.CommonUtil; +import com.fangjia.service.util.CommonUtils; import org.apache.commons.lang.StringUtils; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.TermQuery; import org.apache.solr.client.solrj.util.ClientUtils; +import org.sothis.core.util.Pager; import java.math.BigDecimal; import java.util.*; @@ -59,6 +62,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { private DistrictSellStatService districtSellStatService; private FangjiaOfficialAreaService fangjiaOfficialAreaService; private LoudongDao loudongDao; + private SeawaterDao seawaterDao; @Override @@ -227,7 +231,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List querySamples = new ArrayList(); District hasHouseDist = districtService.findDistrictHasHouseFlag(district);//查询是否是有房源的小区 - if(hasHouseDist != null){ + if (hasHouseDist != null) { List keys = new ArrayList(); String key = district.getName() + "_" + district.getRegion() + "_" + district.getCity(); // 修改 @@ -269,7 +273,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List arroundKeys = new ArrayList(); for (District d : districts) { d = districtService.findById(d.getId()); - if(district.getName().equals(d.getName())){ + if (district.getName().equals(d.getName())) { continue; } @@ -531,8 +535,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { if (!map.containsKey(districtName)) { List sampleWrappers = new ArrayList(); sampleWrappers.add(sample); - map.put(districtName,sampleWrappers); - }else { + map.put(districtName, sampleWrappers); + } else { map.get(districtName).add(sample); } } @@ -540,9 +544,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { for (Map.Entry> entry : map.entrySet()) { //每个小区取5个样本 - if (entry.getValue().size()>=5){ - querySamples.addAll(entry.getValue().subList(0,5)); - }else { + if (entry.getValue().size() >= 5) { + querySamples.addAll(entry.getValue().subList(0, 5)); + } else { // 不超过五个,全部放入 querySamples.addAll(entry.getValue()); } @@ -659,7 +663,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { querySamples.addAll(samples); if (querySamples.size() < max + 10) { - // 查询成交补充 TODO + // 查询成交补充 TODO List dealPriceQuery = new ArrayList(); dealPriceQuery.add(new QueryParam("city", district.getCity())); dealPriceQuery.add(new QueryParam("region", district.getRegion())); @@ -1126,18 +1130,22 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { /** * 江南行查找小区样本(优先使用贝壳链家) * - * @param estateType 用户查询物业类型 + * @param estateType 用户查询物业类型 * @param startDate * @return */ - private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat,double area) { - + private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat, double area) { + //改为从ES 查房源 + ArrayList districtNames = new ArrayList(); BooleanQuery nameQuery = new BooleanQuery(); int c = 0; for (String namekey : keys) { if (StringUtils.isNotBlank(namekey)) { namekey = ClientUtils.escapeQueryChars(namekey); + if (namekey.contains("_")) { + districtNames.add(namekey.split("_")[0]); + } c++; nameQuery.add(new TermQuery(new Term("districtname_key", namekey)), BooleanClause.Occur.SHOULD); } @@ -1149,15 +1157,19 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseQuery = new ArrayList(); houseQuery.add(new QueryParam("city", district.getCity())); houseQuery.add(new QueryParam("region", district.getRegion())); + SeawaterQuery seawaterQuery = new SeawaterQuery(); if (districtStat != null && districtStat.getAvgPrice() > 0) { int avgPrice = districtStat.getAvgPrice(); - houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.5)));//0.85 - houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.5)));//1.15 + // 价格范围调整为上下浮动30% + seawaterQuery.setStartPrice((int) (avgPrice * 0.7)); + seawaterQuery.setEndPrice((int) (avgPrice * 1.3)); + houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.7))); + houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.3))); } houseQuery.add(new QueryParam("area", QueryParam.LESS_THAN_EQUAL_OPERATOR, area + 30)); houseQuery.add(new QueryParam("area", QueryParam.GREATER_THAN_EQUAL_OPERATOR, area - 30)); - if (nameQuery.clauses().isEmpty()){ + if (nameQuery.clauses().isEmpty()) { return samples; } BooleanQuery srQuery = new BooleanQuery(); @@ -1169,7 +1181,24 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseSortParams = new ArrayList(); houseSortParams.add(new SortParam("publishDate", false)); - List houses = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); + + seawaterQuery.setCityDisplay(district.getCity()); + seawaterQuery.setDistrictAlias(names); + seawaterQuery.setRegion(district.getRegion()); + seawaterQuery.setDistrictName(district.getName()); + seawaterQuery.setStartArea(area - 30); + seawaterQuery.setEndArea(area + 30); + seawaterQuery.setSortField("p_date"); + seawaterQuery.setOrder(false); + Pager pager = new Pager(0, 200); + pager.setPageSize(200); + seawaterQuery.setTable("latest_seawater"); + seawaterQuery.setPager(pager); + seawaterQuery.setCat("sell"); + List seawaters = seawaterDao.findSeawatersByQuery(seawaterQuery); + List houses = CommonUtils.transformListV(House.class, seawaters); + +// List houses1 = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); int height = 0; int maxFloor = 0; boolean allSampleHasHeight = true; @@ -1730,4 +1759,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; } + + public void setSeawaterDao(SeawaterDao seawaterDao) { + this.seawaterDao = seawaterDao; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java new file mode 100644 index 000000000..d19f8eda2 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java @@ -0,0 +1,41 @@ +package com.fangjia.service.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +/** + * 通用实体与DTO互相转换工具类 + * + * @author shenjian + * @date 2021/06/16 + */ +public class CommonUtils { + public static T transformV(Class targetClass, Object source) { + if (source == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(source); + return JSONObject.parseObject(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } + + public static List transformListV(Class targetClass, List listSource) { + if (listSource == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(listSource); + return JSONArray.parseArray(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } +} \ No newline at end of file From 31cd461b8aec77ddbb99912e983621f6701e2522 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 9 Apr 2025 17:44:28 +0800 Subject: [PATCH 222/247] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SynchAdministrativeMappingDataBatch.groovy | 30 +++++++++------- .../gj/data_handle/SynchDevDataBatch.groovy | 36 +++++++++++++++---- .../script/gj/xiamen/SeaweedDataSynch.groovy | 2 -- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy index 00b912a8c..ddb9616bd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -1,11 +1,13 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.BaseBatch +import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import org.bson.types.ObjectId import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders @@ -23,12 +25,15 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ @Override public void process(Object args) { + def indexName = "administrative_mapping" def retMap = synchAdminiMappingTo100() - synchToEs(retMap, "192.168.0.89") -// synchToEs(retMap, "192.168.0.52") + synchToEs(retMap, "192.168.0.89", indexName) + synchToEs(retMap, "192.168.0.52", indexName) + println(" 运行完成") + } - def synchAdminiMappingTo100(){ + def synchAdminiMappingTo100(city){ //删除旧的,再同步新的 ADMINISTRATIVE_MAPPING_COLL_100.remove(new BasicDBObject()) @@ -52,12 +57,11 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ return retMap; } - def synchToEs(retMap, host){ + def synchToEs(retMap, host, indexName){ QueryBuilder queryBuilder = QueryBuilders.boolQuery() - def oldIds = new CopyOnWriteArrayList() - ElasticUtils89.executeQuery(host, "administrative_mapping", queryBuilder, { String id, doc-> + ElasticUtils89.queryUpdate(host, indexName, queryBuilder, { String id, doc-> oldIds << id def mongoObj = retMap.get(id) def updateFieldCount = 0 @@ -65,8 +69,7 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ if(!["id","_id","c_date","m_date","polyline_source","operator","city_simple_pinyin","prefecture_level_city"].contains(k)){ def val = doc.get(k) if(val!=v){ -// updateValMap.put(k,val) - if(v.type!="MultiPolygon"){ + if(k!="shape" || (k=="shape" && v.type!="MultiPolygon")){ println k +" 修改 "+id updateFieldCount++ doc.put(k,v) @@ -80,14 +83,14 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ }else{ if(!mongoObj){ println "删除:"+id +" "+doc.name - ElasticUtils.delete(id, host, "administrative_mapping") + ElasticUtils.delete(id, host, indexName) return false } } }) - def addEsDatas = [] + def addEsDatasMap = [:] retMap.each{id,map-> if(!oldIds.contains(id)){ println "需新增:"+id @@ -95,11 +98,12 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ map.remove("m_date") map.remove("polyline_source") map.remove("operator") - addEsDatas << map + map.remove("_id") + addEsDatasMap.put(id, map) } } - if(addEsDatas){ - ElasticUtils89.updateEs(addEsDatas, host, "administrative_mapping") + if(addEsDatasMap){ + ElasticUtils89.updateEs(addEsDatasMap, host, indexName) } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy index 893da6125..ea5a16f8e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy @@ -10,6 +10,7 @@ import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList /** * 将43上的开发区同步到mongo-100, es-89, es-52 @@ -27,9 +28,10 @@ class SynchDevDataBatch extends BaseBatch{ @Override public void process(Object args) { + def indexName = "development_zone" def devMap = synchDevTo100() - synchDevEs(devMap, "192.168.0.89") - synchDevEs(devMap, "192.168.0.52") + synchDevEs(devMap, "192.168.0.89", indexName) + synchDevEs(devMap, "192.168.0.52", indexName) } def synchDevTo100(){ @@ -81,10 +83,12 @@ class SynchDevDataBatch extends BaseBatch{ } - def synchDevEs(devMap, host){ + def synchDevEs(devMap, host, indexName){ QueryBuilder queryBuilder = QueryBuilders.boolQuery() + def oldIds = new CopyOnWriteArrayList() - ElasticUtils89.executeQuery(host, "development_zone", queryBuilder, { String id, doc-> + ElasticUtils89.executeQuery(host, indexName, queryBuilder, { String id, doc-> + oldIds << id def mongoObj = devMap.get(id) def updateFieldCount = 0 mongoObj.each{k,v-> @@ -92,7 +96,6 @@ class SynchDevDataBatch extends BaseBatch{ def val = doc.get(k) if(val!=v){ println doc.name +" 修改 "+k+" "+ v+" "+id -// updateValMap.put(k,val) updateFieldCount++ doc.put(k,v) } @@ -104,11 +107,32 @@ class SynchDevDataBatch extends BaseBatch{ }else{ if(!mongoObj){ println "删除:"+id +" "+doc.name - ElasticUtils.delete(id, host, "development_zone") + ElasticUtils.delete(id, host, indexName) return false } } }) + + def addEsDatasMap = [:] + devMap.each{id,map-> + if(!oldIds.contains(id)){ + println "需新增:"+id + map.remove("create_time") + map.remove("build_date") + map.remove("bd_shape") + map.remove("img_url") + map.remove("operator") + map.remove("operate_result") + map.remove("m_date") + map.remove("township") + map.remove("block") + map.remove("_id") + addEsDatasMap.put(id, map) + } + } + if(addEsDatasMap){ + ElasticUtils89.updateEs(addEsDatasMap, host, indexName) + } } 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 0955b9921..6f07d1516 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 @@ -78,8 +78,6 @@ class SeaweedDataSynch extends BaseBatch{ @Override public void process(Object args) { - - run() // println "全国district, shop, office同步完成" //民政部编码上传 From 1a09839cd310d7c4bb14b501a10c6e4d7e6d7755 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 9 Apr 2025 17:57:28 +0800 Subject: [PATCH 223/247] =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/xiamen/ElasticUtils89.groovy | 143 +++++++++++++++++- 1 file changed, 137 insertions(+), 6 deletions(-) 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 index b1b772b92..dd2c2e5e1 100644 --- 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 @@ -1,5 +1,6 @@ package com.fangjia.script.gj.xiamen +import com.fangjia.script.util.ElasticUtils import org.apache.http.HttpHost import org.apache.http.auth.AuthScope import org.apache.http.auth.UsernamePasswordCredentials @@ -7,8 +8,10 @@ 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.apache.solr.client.solrj.request.UpdateRequest import org.elasticsearch.action.ActionListener import org.elasticsearch.action.bulk.BackoffPolicy +import org.elasticsearch.action.bulk.BulkItemResponse import org.elasticsearch.action.bulk.BulkProcessor import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse @@ -17,11 +20,13 @@ 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.action.support.WriteRequest 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.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.search.Scroll import org.elasticsearch.search.SearchHit @@ -160,8 +165,17 @@ class ElasticUtils89 { } @Override - void afterBulk(long executionId, BulkRequest request, - BulkResponse response) { + public void afterBulk(long executionId, BulkRequest request, BulkResponse response) { + if (response.hasFailures()) { + for (BulkItemResponse itemResponse : response.getItems()) { + if (itemResponse.isFailed()) { + // 处理失败项 + String failureMessage = itemResponse.getFailureMessage(); + println failureMessage + // 日志记录、告警或重试 + } + } + } } @Override @@ -205,6 +219,7 @@ class ElasticUtils89 { } 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(); @@ -221,7 +236,7 @@ class ElasticUtils89 { // executorService.submit(new Runnable() { // @Override // void run() { - try{ +// try{ if(closure.getMaximumNumberOfParameters() == 1){ def update = closure.call(hit.getSourceAsMap()) @@ -232,14 +247,16 @@ class ElasticUtils89 { 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() - } +// }catch (Exception e){ +// e.printStackTrace() +// } // } // }) } + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); @@ -256,6 +273,120 @@ class ElasticUtils89 { client.close() } + static queryUpdate(String host, String indexName, QueryBuilder qb, Closure closure){ + RestHighLevelClient client = null + if(host == "192.168.0.89"){ + client = getClient(host); + }else if(host == "192.168.0.52"){ + client = getClientOther(host); + } + BulkProcessor bulkProcessor = createBulkProcessor(host, client) + + final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(30)) + // 2. 初始化滚动查询 + 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[] hits = searchResponse.getHits().getHits(); + + // 3. 批量操作容器 + BulkRequest bulkRequest = new BulkRequest(); + + // 4. 处理滚动结果 + while (hits.length > 0){ + for (SearchHit hit : hits) { + // 示例修改逻辑:当满足条件时更新文档 + if(closure.getMaximumNumberOfParameters() == 2){ + def update = closure.call(hit.getId(), hit.getSourceAsMap()) + if(update){ + bulkRequest.add(new IndexRequest(indexName).id(hit.getId()).source(hit.getSourceAsMap())) + } + } + // 批量提交控制 + if (bulkRequest.numberOfActions() >= 1) { + bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + System.err.println("批量操作部分失败: " + bulkResponse.buildFailureMessage()); + // 这里可以添加重试逻辑 + } + bulkRequest = new BulkRequest(); // 重置容器 + } + } + + // 5. 获取下一批滚动结果 + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId).scroll(TimeValue.timeValueMinutes(5)); + searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); + scrollId = searchResponse.getScrollId(); + hits = searchResponse.getHits().getHits(); + } + + // 6. 提交剩余批量操作 + if (bulkRequest.numberOfActions() > 0) { + BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + System.err.println("批量操作部分失败: " + bulkResponse.buildFailureMessage()); + } + } + + // 7. 清理滚动上下文 + ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); + clearScrollRequest.addScrollId(scrollId); + client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); + + bulkProcessor.close() + bulkProcessor.awaitClose(1, TimeUnit.DAYS) + client.close() + } + + + static updateEs(addEsDatasMap, 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) + } + + addEsDatasMap.each{id, map-> + request.add(new IndexRequest(indexName, "_doc", id).source(map, XContentType.JSON)); + if (request.numberOfActions() >= 100) { + 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 "+host + } + request = new BulkRequest(); + } + } + + 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 "+host + } + } + } + + + static def executeSimpleQuery(String host, String indexName, QueryBuilder qb, includes){ From f2f9a02e788b59f240a0cc31e81871036af5d4f0 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 10 Apr 2025 14:20:51 +0800 Subject: [PATCH 224/247] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6f07d1516..9ff38507e 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 @@ -165,9 +165,9 @@ class SeaweedDataSynch extends BaseBatch{ def shops = updating(c, "shop") updateEs(c, shops, "shop", "192.168.0.89") - updateEs(c, offices, "shop", "192.168.0.52") + updateEs(c, shops, "shop", "192.168.0.52") - println index +" "+ c + " 完成" + println index +" "+ c + " 完成 "+new Date().toString() } } From 4ec26e53538216adada339a6cbadb6deeba669c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 10 Apr 2025 13:59:58 +0800 Subject: [PATCH 225/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E9=93=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/dao/shop/ShopRentStatDao.java | 9 + .../mongo/dao/shop/ShopRentStatDaoImpl.java | 8 + .../dal/mongo/dao/shop/ShopSellStatDao.java | 9 + .../mongo/dao/shop/ShopSellStatDaoImpl.java | 8 + .../fangjia/dal/mongo/model/ShopRentStat.java | 84 +++ .../fangjia/dal/mongo/model/ShopSellStat.java | 84 +++ .../open/controllers/ShopController.java | 614 ++++++++++++++++++ .../service/datastore/AiShopService.java | 49 ++ .../service/datastore/AiShopServiceImpl.java | 553 ++++++++++++++++ .../service/datastore/ShopService.java | 4 +- .../datastore/dto/ShopEvaluationDto.java | 54 ++ .../service/datastore/dto/ShopRentDto.java | 32 + 12 files changed, 1506 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java new file mode 100644 index 000000000..a03b21129 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public interface ShopRentStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java new file mode 100644 index 000000000..e1f611b37 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public class ShopRentStatDaoImpl extends MongoDaoImpl implements ShopRentStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java new file mode 100644 index 000000000..2fec3b1d9 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public interface ShopSellStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java new file mode 100644 index 000000000..c233ba1db --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public class ShopSellStatDaoImpl extends MongoDaoImpl implements ShopSellStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java new file mode 100644 index 000000000..510e8e392 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_rent_stat") +public class ShopRentStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java new file mode 100644 index 000000000..8745031ce --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_sell_stat") +public class ShopSellStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java new file mode 100644 index 000000000..3afc679c3 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * 商铺出租服务类 + * + * @author shenjian + * @since 2025/4/10 + */ +@Authority(role = Role.USER) +public class ShopController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * 城市出租均价 + * + * @return + */ + public Object cityRentAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 区域出租均价 + * + * @return + */ + public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼均价走势 + * + * @return + */ + public Object shopRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼楼租金地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + 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.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + 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; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateRent(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + /** + * 申请估值报告 + * + * @param model 申请报告请求参数 + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (model.getDistrict().endsWith("区")) { + model.setDistrict(model.getDistrict().replaceAll("区$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空")); + } + return mav; + } + + /** + * 获取估值报告 + * + * @param caseId 估值报告ID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空")); + } + return mav; + } + + 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; + } + + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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.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 floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_shop_evaluateRent"); + return evaluation; + } + + 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", "活动中心"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java new file mode 100644 index 000000000..efe2d3287 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java @@ -0,0 +1,49 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; + +import java.util.List; + +public interface AiShopService { + + /** + * 租金均价 + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * 租金地址维度评估 + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateRent(Evaluation evaluation); + + /** + * 城市写字楼出售均价 + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * 售价地址维度评估 + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateSell(Evaluation evaluation); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java new file mode 100644 index 000000000..5c7edbcff --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -0,0 +1,553 @@ +package com.fangjia.service.datastore; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SeawaterQuery; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.shop.ShopRentStatDao; +import com.fangjia.dal.mongo.dao.shop.ShopSellStatDao; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import com.fangjia.service.mongo.fangjia.SeawaterService; +import com.fangjia.service.util.GeoUtils; +import com.fangjia.service.util.dto.GaodeDto; +import com.mongodb.BasicDBObject; +import org.apache.commons.collections.CollectionUtils; +import org.sothis.core.util.Closure; +import org.sothis.core.util.Pager; +import weiboclient4j.utils.StringUtils; + +import java.util.*; + +public class AiShopServiceImpl implements AiShopService { + + private ShopRentStatDao shopRentStatDao; + private SeawaterService seawaterService; + private ShopSellStatDao shopSellStatDao; + + + // 所在楼层 +// 总楼层 + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "毛坯"); + put("2", "简装"); + put("3", "精装"); + put("4", "豪装"); + } + }; + + private static final Map DIRECTION_MAP = 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 FITMENT_FACTOR = new HashMap() { + { + put("毛坯", 0.9983); + put("简装", 1.0); + put("精装", 1.0153); + put("豪装", 1.0199); + } + }; + private static final Map DIRECTION_FACTOR = new HashMap() { + { + put("东", 1.0040); + put("东北", 1.0048); + put("东南", 1.0121); + put("东西", 1.0003); + put("北", 0.9999); + put("南", 1.0000); + put("南北", 1.0080); + put("西", 1.0060); + put("西北", 1.0099); + put("西南", 1.0103); + } + }; + + public ShopEvaluationDto calcRent(Evaluation evaluation) { + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + // 第二步:基准价*楼层系数*装修系数*朝向系数 + // 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("shop_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "低".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "高".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getShopEvaluationDto(selectedSeawaters, evaluation, "shop_rent"); + } + } + } + // 查找基准价 + List params = new ArrayList(); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // 获取上个月yyyyMM日期 + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // 第二步:基准价*楼层系数*装修系数*朝向系数 + ShopRentStat shopRentStat = shopRentStatDao.findFirstByParams(params); + Double avgPrice = shopRentStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getShopEvaluationDtoWithAvgPrice(avgPrice, evaluation, "shop_rent"); + } + + return null; + } + + /** + * 根据均价查询样本 + * + * @param avgPrice + * @param evaluation + * @return + */ + private ShopEvaluationDto getShopEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + if ("shop_rent".equals(cat)) { + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + } else { + query.setStartPrice((int) (avgPrice * 0.9)); + query.setEndPrice((int) (avgPrice * 1.1)); + } + query.setCat(cat); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + return getShopEvaluationDto(seawaters, evaluation, cat); + } + + /** + * 基准价*楼层系数*装修系数*朝向系数 + * + * @param seawaters + * @param evaluation + * @return + */ + private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { + Double sum = 0.0; + Double size = 0.0; + + String fitment = FITMENT_MAP.get(evaluation.getFitment()); + String direction = DIRECTION_MAP.get(evaluation.getDirection()); + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + Double price = Double.valueOf(seawater.getTotalPrice()); + // 装修 + if (seawater.getFitment() != null) { + try { + price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); + } catch (Exception ex) { + + } + } + // 朝向 + if (seawater.getDirection() != null) { + try { + price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); + } catch (Exception ex) { + + } + } + + sum += price; + size += seawater.getArea(); + } + } + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + return shopEvaluationDto; + } + + /** + * 纯样本查询结果估值 + * + * @param seawaters + * @param evaluation + * @return + */ + private static ShopEvaluationDto getShopEvaluationDto(List seawaters, Evaluation evaluation, String cat) { + Integer sum = 0; + Double size = 0.0; + + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + + if ("shop_rent".equals(cat)) { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } else { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } + + return shopEvaluationDto; + } + + + @Override + public ShopEvaluationDto addressEvaluateRent(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return rentEvaluateByLocation(evaluation); + } + + @Override + public List findShopSellStat(String city, String region, String name, String cat, Integer startDate, Integer endDate) { + return Collections.emptyList(); + } + + private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_rent"); + query.setRadius(1000); + // 查询近一年样本 + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + if (CollectionUtils.isNotEmpty(shops)) { + // 求均值 + Double totalPrice = 0D; + int count = 0; + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + shopEvaluationDto.setUnitPrice(avgPrice); + shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private ShopEvaluationDto sellEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // 查询附近5个写字楼基准价 + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); + + List params = new ArrayList(5); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = shopSellStatDao.findAllByParams(params, sortParams, 5); + if (CollectionUtils.isEmpty(infos)) { + // 去掉类型,重新查找 + params = new ArrayList(5); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = shopSellStatDao.findAllByParams(params, sortParams); + } + if (CollectionUtils.isNotEmpty(infos)) { + // 求均值 + Double totalPrice = 0D; + int count = 0; + for (ShopSellStat shopSellStat : infos) { + if (shopSellStat.getAvgPrice() != null) { + totalPrice += shopSellStat.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + shopEvaluationDto.setUnitPrice(avgPrice); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private String getLocation(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + return gaodeDto.getLng() + "," + gaodeDto.getLat(); + } + return ""; + } + + private GaodeDto getGaodeGeo(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + return gaodeDto; + } + + public List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); + } + }); + } + + public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List regionStats = shopRentStatDao.findAllByParams(params, sortParams); + return regionStats; + } + + @Override + public ShopEvaluationDto addressEvaluateSell(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return sellEvaluateByLocation(evaluation); + } + + public List doFindShopSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List sellStatList = shopSellStatDao.findAllByParams(params, sortParams); + return sellStatList; + } + + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } + + public void setShopRentStatDao(ShopRentStatDao shopRentStatDao) { + this.shopRentStatDao = shopRentStatDao; + } + + public void setShopSellStatDao(ShopSellStatDao shopSellStatDao) { + this.shopSellStatDao = shopSellStatDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java index e66e53e25..7665fd814 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java @@ -1,11 +1,11 @@ package com.fangjia.service.datastore; -import java.util.List; - import com.fangjia.dal.QueryParam; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.seaweed.model.Shop; +import java.util.List; + public interface ShopService { List findByKeyword(String city, String keyword); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java new file mode 100644 index 000000000..60432aa1f --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java @@ -0,0 +1,54 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + + private String name; + + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java new file mode 100644 index 000000000..02e2379f4 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +} From a40f591a9a3b79ee940e1c50841f53920a1f559d Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 10 Apr 2025 18:37:45 +0800 Subject: [PATCH 226/247] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy | 1 + 1 file changed, 1 insertion(+) 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 9ff38507e..7bd1a3cdb 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 @@ -243,6 +243,7 @@ class SeaweedDataSynch extends BaseBatch{ } if(!esObj || (esObj && diffMap)){ map.put("id", d._id.toString()) + map.put("status", 0) //因为判断是否有值,0会返回false,所在这里设置默认值,在89和52上的都是有效数据 return map } return null From d7fbf345d8355cd521691cdba064577404a04341 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 13:10:09 +0800 Subject: [PATCH 227/247] update --- .../gj/data_handle/AutoAddOfficeBatch.groovy | 441 +++++++++++++++--- 1 file changed, 373 insertions(+), 68 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 38c7d1c16..5338abf79 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -2,12 +2,18 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData import com.fangjia.script.BaseBatch +import com.fangjia.script.ccbevaluation.CcbCommonUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.util.CosineSimilarAlgorithm import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.GeoHelper +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import groovy.sql.Sql import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CopyOnWriteArraySet @@ -16,30 +22,47 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong -class AutoAddOfficeBatch extends BaseBatch{ +class AutoAddOfficeBatch extends BaseBatch { - def fullCityMap = CommonDatautils.queryFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) + def fullCityMap = CommonDatautils.queryFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206", 27020) + + //235为房价网内部计算均价的库 + def pgsqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", + "postgres", "Goojia123456", "org.postgresql.Driver") static main(args) { // runBatch(new AutoAddOfficeBatch(), args) def task = new AutoAddOfficeBatch() - task.repeatOffice() +// task.repeatOffice() + task.repeatDist() } @Override void process(Object args) { +// def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|[A-Z]楼|[0-9]幢/ +// def newName = "开放广场".replaceAll(pattern, "") +// println newName +// findAddOfficeDatas() //查找需要新增的写字楼数据 +// checkInBaiduMapOffice()//查寻在百度地图上有的写字楼数据 +// addOffice()//新增写字楼 + + + } + + def findAddOfficeDatas() { def citys = CommonDatautils.findAllCity() def allAddOffices = [] - allAddOffices << ["地图ID","省","市","区","写字楼名称","地址","经度","纬度","匹配城市","匹配区域","匹配名称","匹配方式"] - for(def c : citys){ + allAddOffices << ["地图ID", "省", "市", "区", "写字楼名称", "地址", "经度", "纬度", "匹配城市", "匹配区域", "匹配名称", "匹配方式"] + for (def c : citys) { def cityObj = fullCityMap.get(c) - if(cityObj){ + if (cityObj) { def officeMaps = CommonDatautils.findOfficeByMap(cityObj.city, "商务写字楼") officeMaps = filterOffice(officeMaps) - if(officeMaps){ + if (officeMaps) { def offices = matchOffice(officeMaps) allAddOffices.addAll(offices) @@ -49,59 +72,72 @@ class AutoAddOfficeBatch extends BaseBatch{ ExcelUtils.write("D:\\数据\\高德写字楼.xlsx", allAddOffices, "数据") } - def filterOffice(officeMaps){ + def checkInBaiduMapOffice() { + ExcelUtils.multiThreadingModify("D:\\数据\\高德写字楼1.xlsx", { d -> + if (!d['L']) { + def obj = findBaiduDatas(d['C'], d['D'], d['E']) + if (obj) { + d['L'] = "百度存在" + d['M'] = obj.std_tag.toString() + } + } + + }, 0) + } + + def filterOffice(officeMaps) { def offices = [] def keys = [] - for(def o : officeMaps){ - if(!o){ + for (def o : officeMaps) { + if (!o) { continue } - if(o.name.startsWith("写字楼") || o.name.startsWith("综合楼") || o.name.contains("销售") || o.name.startsWith("办公楼") || o.name.startsWith("公务楼") || o.name.startsWith("行政楼") || o.name.startsWith("商务办公楼") || o.name.startsWith("综合办公楼")){ - println "[ 过滤 ] "+o.city+" "+o.name + if (o.name.startsWith("写字楼") || o.name.startsWith("综合楼") || o.name.contains("销售") || o.name.startsWith("办公楼") || o.name.startsWith("公务楼") || o.name.startsWith("行政楼") || o.name.startsWith("商务办公楼") || o.name.startsWith("综合办公楼")) { + println "[ 过滤 ] " + o.city + " " + o.name continue } - if(o.name.contains("路写字楼")){ - println "[ 过滤 ] "+o.city+" "+o.name + if (o.name.contains("路写字楼")) { + println "[ 过滤 ] " + o.city + " " + o.name continue } def pattern = /[A-Z0-9]座|[0-9a-z]栋|[A-Z]栋|·|\(建设中\)|[0-9]号楼|\(装修中\)|[A-Z]楼|[0-9]幢/ def newName = o.name.replaceAll(pattern, "") o.name = newName - def keyName = o.city +"#"+o.district+"#"+o.name - if(!keys.contains(keyName)){ + def keyName = o.city + "#" + o.district + "#" + o.name + if (!keys.contains(keyName)) { offices << o keys << keyName } } - println "原:"+officeMaps.size() +" 新:"+offices.size() + println "原:" + officeMaps.size() + " 新:" + offices.size() return offices } - def matchOffice(offices){ + def matchOffice(offices) { def addCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(offices.size()) def total = offices.size() def rets = new CopyOnWriteArrayList() - for(def i=0;i=1){ + if (rets) { + if (rets.size() >= 1) { office = rets[0] } - }else{ + } else { rets = CommonDatautils.findDistrictByAlias(simpleCity, simpleDistrict, nmd.name, "office") - if(rets && rets.size()>=1){ + if (rets && rets.size() >= 1) { office = rets[0] - }else{ + } else { rets = CommonDatautils.findDistrictByAddress(simpleCity, simpleDistrict, nmd.name, "district") - if(rets && rets.size()>=1){ + if (rets && rets.size() >= 1) { office = rets[0] } } } - if(office){ + if (office) { office.match_way = "数据库" } return office @@ -144,65 +180,147 @@ class AutoAddOfficeBatch extends BaseBatch{ return null } - def matchApi(nmd){ + def matchApi(nmd) { def address = nmd.city - if(nmd.district){ + if (nmd.district) { address = address + nmd.district } address = address + nmd.name def jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) - if(!jsonObject){ - if(DataUtil.isPreciseAddress(nmd.address)){ + if (!jsonObject) { + if (DataUtil.isPreciseAddress(nmd.address)) { address = nmd.city - if(nmd.district){ + if (nmd.district) { address = address + nmd.district } address = address + nmd.address jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) } } - if(jsonObject) { - def udata = [:] - udata.put("_id",jsonObject.get("id")) - udata.put("city",jsonObject.get("city")) - udata.put("region",jsonObject.get("district")) - udata.put("name",jsonObject.get("name")) - udata.put("match_type",jsonObject.get("propertyType")) - udata.put("match_credit",jsonObject.get("credit")) + if (jsonObject) { + def udata = [:] + udata.put("_id", jsonObject.get("id")) + udata.put("city", jsonObject.get("city")) + udata.put("region", jsonObject.get("district")) + udata.put("name", jsonObject.get("name")) + udata.put("match_type", jsonObject.get("propertyType")) + udata.put("match_credit", jsonObject.get("credit")) udata.put("match_way", "接口") return udata } return null } - def repeatOffice(){ + def repeatOffice() { def citys = CommonDatautils.findAllCity() def allrets = [] - allrets << ["ID","城市","区域","名称","地址","可疑ID","可疑城市","可疑区域","可疑名称","可疑地址","相似度","距离"] - for(def c : citys){ - def offices = CommonDatautils.findAllDistricts(c, "office", ["city","region","name","address", "lat", "lng"]) + allrets << ["ID", "城市", "区域", "名称", "地址", "可疑ID", "可疑城市", "可疑区域", "可疑名称", "可疑地址", "相似度", "距离"] + for (def c : citys) { + def offices = CommonDatautils.findAllDistricts(c, "office", ["city", "region", "name", "address", "lat", "lng"]) def rets = checkRepeatOfficeBatch(offices) - println c +" "+offices.size() + println c + " " + offices.size() allrets.addAll(rets) } ExcelUtils.write("D:\\数据\\写字楼\\重复可疑写字楼1.xlsx", allrets, "数据") } - def checkRepeatOfficeBatch(offices){ + def repeatDist(){ + def citys = CommonDatautils.findAllCity() + def allrets = [] + allrets << [ "城市", "区域", "名称", "别名","计算方式","地址","名称相似度","地址相似度","总相似度"] + for (def c : citys) { + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"]) + def rets = checkRepeatDistrictBatch(c, districts) + println c + " " + districts.size() + allrets.addAll(rets) + println c +" 支行完成 "+rets.size() + } + ExcelUtils.write("/home/goojia/gj/重复可疑小区1.xlsx", allrets, "数据") + } + + def checkRepeatDistrictBatch(city,districts) { + def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + def cityId = cityCodeDataMap.get(city) + + def fjwPriceMap = findNewFjwAvgPriceList(cityId, 202502) + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(districts.size()) + def total = districts.size() + def rets = new CopyOnWriteArrayList() + def sets = new CopyOnWriteArraySet() + for (def i = 0; i < total; i++) { + final def o1 = districts[i] +// fixedThreadPool.execute(new Runnable() { +// void run() { + try { + addCount.addAndGet(1) +// if(!o1.name.contains("四公司")){ +// continue +// } + if(!sets.contains(o1._id.toString())){ + def similarRets = findListSimilar(o1, districts) + if (similarRets) { + def newPriceMap1 = fjwPriceMap.get(o1._id.toString()) + def new_price1 = null + if(newPriceMap1){ + new_price1 = newPriceMap1.calc_type + } + def ailas_str1 = "" + if(o1.alias){ + ailas_str1 = o1.alias.join(",") + } + def rows = [] + for(def similar : similarRets){ + if (!sets.contains(similar._id.toString())) { + sets.add(similar._id.toString()) + def ailas_str = "" + if(similar.alias){ + ailas_str = similar.alias.join(",") + } + def newPriceMap = fjwPriceMap.get(o1._id.toString()) + def new_price = null + if(newPriceMap){ + new_price = newPriceMap.calc_type + } + rows << [ similar.city, similar.region, similar.name, ailas_str,new_price, similar.address, similar.nameScore, similar.addrScore, similar.score] +// rets << [ similar.city, similar.region, similar.name, ailas_str,new_price, similar.address, similar.nameScore, similar.addrScore, similar.score] + } + } + if(rows){ + sets.add(o1._id.toString()) + rets << [ o1.city, o1.region, o1.name, ailas_str1,new_price1, o1.address, "主", "主", "主"] + rets.addAll(rows) + } + + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } +// } +// }); + } +// latch.await() + return rets + } + + def checkRepeatOfficeBatch(offices) { def addCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(offices.size()) def total = offices.size() def rets = new CopyOnWriteArrayList() def sets = new CopyOnWriteArraySet() - for(def i=0;i o2.name.length()){ + str = o1.name.replace(o2.name, "") + }else{ + str = o2.name.replace(o1.name, "") + } + if (nameScore > 0.6 && ["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { + o2.nameScore = nameScore + o2.addrScore = addrScore + o2.score = nameScore + rets << o2 + ids << o2._id.toString() + def maxObj = findMaxSimilar(ids, o2, datas) + while(maxObj){ + maxObj.nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(maxObj.name, o1.name); + if(o1.address && maxObj.address){ + maxObj.addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, o2.address); + } + maxObj.score = maxObj.nameScore + rets << maxObj + ids << maxObj._id.toString() + maxObj = findMaxSimilar(ids, maxObj, datas) + } + } + } + } + + rets.sort{a,b-> + def a1 = a.score + def b1 = b.score + return b1.compareTo(a1) + } + + if (rets.size()>2) { + return rets[0..2] + } + return rets + } + + def findMaxSimilar(ids, o1, datas){ + def maxObj = null + def maxScore = -1000 + for (def o2 : datas) { + if (o1._id.toString() != o2._id.toString() && o1.region==o2.region && !ids.contains(o2._id.toString())) { + def name1 = o1.name//.replace("小区","").replace("别墅","") + def name2 = o2.name//.replace("小区","").replace("别墅","") + def nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(name1, name2); + def addrScore = null + if(o1.address && o2.address){ + addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, o2.address); + } + def str = null + if(o1.name.length() > o2.name.length()){ + str = o1.name.replace(o2.name, "") + }else{ + str = o2.name.replace(o1.name, "") + } + if (nameScore > 0.6 && nameScore>maxScore && ["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { + maxObj = o2 + o2.nameScore = nameScore + o2.addrScore = addrScore + o2.score = nameScore + } + } + } + + return maxObj + } + + def findOneSimilarOffice(o1, offices) { def maxScore = 0 def maxObj = null - for(def o2 : offices){ - if(o1._id.toString()!=o2._id.toString()){ + for (def o2 : offices) { + if (o1._id.toString() != o2._id.toString()) { double nameScore = CosineSimilarAlgorithm.getSimilarity(o1.name, o2.name); - double addrScore = CosineSimilarAlgorithm.getSimilarity(o1.address,o2.address); - if(nameScore+addrScore>maxScore){ - maxScore = nameScore+addrScore + double addrScore = CosineSimilarAlgorithm.getSimilarity(o1.address, o2.address); + if (nameScore + addrScore > maxScore) { + maxScore = nameScore + addrScore maxObj = o2 } } } def distance = -1000 - if(o1.lat && maxObj && maxObj.lat){ - distance = GeoHelper.GetDistance(o1.lat/10000000000.0, o1.lng/10000000000.0, maxObj.lat/10000000000.0, maxObj.lng/10000000000.0) + if (o1.lat && maxObj && maxObj.lat) { + distance = GeoHelper.GetDistance(o1.lat / 10000000000.0, o1.lng / 10000000000.0, maxObj.lat / 10000000000.0, maxObj.lng / 10000000000.0) } - if(maxObj){ + if (maxObj) { maxObj.distance = distance maxObj.score = maxScore return maxObj } return null } + + + def findBaiduDatas(city, district, name){ + def q = new BasicDBObject() + q.put("city", city) + q.put("district", district) + q.put("name", name) +// q.put('std_tag', '房地产;住宅区') + def obj = BAIDU_POI_COLL.findOne(q) + return obj; + } + + def addOffice(){ + ExcelUtils.modify("D:\\数据\\高德待入库写字楼.xlsx",{d-> + if(d['L']!='人工删除'){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + if(city && region){ + def locationstr = d['G'].toString()+","+d['H'].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr, 1) + def udata = new BasicDBObject() + if(bdpoint){ + udata.put("lng2", (bdpoint[0]*10000000000).longValue()) + udata.put("lat2", (bdpoint[1]*10000000000).longValue()) + } + + udata.put("city", city) + udata.put("region", region) + udata.put("name", d['E']) + udata.put("address", d['I']) + udata.put("cat", "office") + udata.put("status", 0) + udata.put("c_date",new Date()) + udata.put("m_date",new Date()) + udata.put("lng", (d['G'].toString().toDouble()*10000000000).longValue()) + udata.put("lat", (d['H'].toString().toDouble()*10000000000).longValue()) + + def estate_type = null + if(d['M'] && d['M'].contains("园区")){ + estate_type = "创意园区" + } + + if(!estate_type && d['E'].contains("创意")){ + estate_type = "创意园区" + } + if(estate_type){ + udata.put("estate_type2", estate_type) + } + + def markMap = [:] + markMap.put("data_source", "机器入库") + udata.put("mark_map", markMap) + DbUtils.seaweed.save(udata) + println d['E'] +" "+udata._id.toString() + } + } + }) + } + + + def findNewFjwAvgPrice(def commid, def cityid){ + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" + def map = [:] + pgsqlInstance235.eachRow(sql, { r -> + map.avg_price = r.gujia_bds_clc_avprc + map.type = r.gujia_bds_clmtd + map.month = r.gujiabds_clc_yrmo_val + map.credit_value = r.gujia_bds_cfdc_dgr + if(r.gujia_bds_clmtd == 1){ + map.calc_type = "人工估值" + }else if(r.gujia_bds_clmtd == 2){ + map.calc_type = "样本计算" + }else if(r.gujia_bds_clmtd == 3){ + map.calc_type = "神经网络" + } + }) + return map + } + + def findNewFjwAvgPriceList(def cityid, date){ + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr,gujia_bds_id from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujiabds_clc_yrmo_val=${date}" + def retMap = [:] + pgsqlInstance235.eachRow(sql, { r -> + def map = [:] + map.avg_price = r.gujia_bds_clc_avprc + map.type = r.gujia_bds_clmtd + map.month = r.gujiabds_clc_yrmo_val + map.credit_value = r.gujia_bds_cfdc_dgr + if(r.gujia_bds_clmtd == 1){ + map.calc_type = "人工估值" + }else if(r.gujia_bds_clmtd == 2){ + map.calc_type = "样本计算" + }else if(r.gujia_bds_clmtd == 3){ + map.calc_type = "神经网络" + } + retMap.put(r.gujia_bds_id, map) + }) + return retMap + } + } From b958ae87a39c98bc202781cb452c359783b1d554 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 13:25:39 +0800 Subject: [PATCH 228/247] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/groovy/com/fangjia/script/util/MongoUtils.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy index 54d093d7e..3ecfd9680 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy @@ -57,7 +57,7 @@ class MongoUtils { static def collectionMap = [:] static def loudongCollectionMap = [:] - static def getCollectionByName(db, name, domainUrl, port = 27017) { + static def getCollectionByName(db, name, domainUrl, port = 28017) { if ((domainUrl == MongoDB_IP_43 || domainUrl == MongoDB_IP_136 || domainUrl == MongoDB_Domain_offline_fangjia || domainUrl == MongoDB_IP_85 || domainUrl == MongoDB_Domain_mongo) && port == 28017) { return com.fangjia.core.util.MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, db, name) From 78e0f3c202eb9c3f903aa8ffbb1124543eadfaf1 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 14:02:02 +0800 Subject: [PATCH 229/247] =?UTF-8?q?43=E6=94=B9=E4=B8=BA=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-script/pom.xml | 12 ++ ...ickHouseDistrictStatMarkupCalcBatch.groovy | 2 +- .../ana/DistrictStatMarkupCalcBatch.groovy | 2 +- .../script/ccbevaluation/AddSzDealData.groovy | 4 +- .../ccbevaluation/AddThirdPriceSample.groovy | 2 +- .../ccbevaluation/BigdataDealBatch.groovy | 2 +- .../ccbevaluation/DistrictDelete.groovy | 2 +- .../ccbevaluation/ThirdPartyPriceBatch.groovy | 2 +- .../script/ccbevaluation/TradeStatLog.groovy | 2 +- .../ccbevaluation/data/ExcelDataTest.groovy | 8 +- .../data/MatchDealPriceRegion.groovy | 2 +- .../chongqing/BlankEvaluationBatch.groovy | 2 +- .../script/chongqing/FumingTest.groovy | 2 +- .../script/chongqing/HailanTest.groovy | 2 +- .../fangjia/script/chongqing/PocStat.groovy | 2 +- .../script/chongqing/RuiFenPocTest.groovy | 2 +- .../script/commData/CommonDatautils.groovy | 2 +- ...FewerHouseDistrictCrawlCommandBatch.groovy | 2 +- .../fangjia/script/crawl/Test_weilei.groovy | 2 +- .../DistrictTradeHouseStatBatch.groovy | 4 +- .../dealPrice/SynchDealPriceToEs.groovy | 2 +- .../fangjiatong/AbcEvaluationRowsBatch.groovy | 2 +- .../fuzhou/DistrictInfoExportBatch.groovy | 2 +- .../script/fuzhou/FzDataResultStat.groovy | 2 +- .../com/fangjia/script/fuzhou/Test.groovy | 2 +- .../com/fangjia/script/fuzhou/Test1.groovy | 2 +- .../fuzhou/ThirdPriceExportBatch.groovy | 2 +- .../fangjia/script/fuzhou/ThirdTest.groovy | 2 +- .../script/fuzhou/TradeExportBatch.groovy | 2 +- .../com/fangjia/script/gj/CzBankStat.groovy | 2 +- .../fangjia/script/gj/DealPriceProcess.groovy | 2 +- .../script/gj/DistrictDetailBatch.groovy | 2 +- .../com/fangjia/script/gj/EsHouseStat.groovy | 2 +- .../com/fangjia/script/gj/FZDataExport.groovy | 4 +- .../script/gj/FZHouseEvaluation.groovy | 2 +- .../com/fangjia/script/gj/FjwUserStat.groovy | 2 +- .../script/gj/HouseLouDongMatchBatch.groovy | 2 +- .../fangjia/script/gj/LandDetailCrawl.groovy | 2 +- .../com/fangjia/script/gj/LogStat.groovy | 4 +- .../script/gj/NoHouseDistrictStatBatch.groovy | 4 +- .../script/gj/PingAnAddressLevalTest.groovy | 2 +- .../com/fangjia/script/gj/QinLingStat.groovy | 2 +- .../com/fangjia/script/gj/QinLingStat1.groovy | 2 +- .../script/gj/RegionBlockSetting.groovy | 2 +- .../script/gj/SynchDistrictStatBatch.groovy | 4 +- .../fangjia/script/gj/UpdateThirdPrice.groovy | 2 +- .../gj/apiLog/ApiUserCountAnalyBatch.groovy | 2 +- .../script/gj/ccb/CcbCityPriceStat.groovy | 2 +- .../script/gj/chongqin/PocTest2023.groovy | 2 +- .../chongqingblank/DistrictSelectHouse.groovy | 2 +- .../script/gj/chongqingblank/TestPrice.groovy | 4 +- .../script/gj/city/CityStatExport.groovy | 2 +- .../script/gj/commStat/CityStat.groovy | 2 +- .../script/gj/commStat/DataStatTest.groovy | 6 +- .../gj/data/BestDistrictPriceExport.groovy | 2 +- .../script/gj/data_handle/MinglujiData.groovy | 3 +- .../gj/data_handle/RegionStandardBatch.groovy | 63 ++++++++++- .../gj/data_handle/RegionUpdateBatch.groovy | 2 +- .../gj/data_handle/TempExportData.groovy | 24 ++-- .../fangjia/script/gj/data_handle/Test.groovy | 105 +++++++++--------- .../gj/data_handle/TownMiddleProcess.groovy | 103 ++++++++++++++++- .../gj/data_handle/TownStandardBatch.groovy | 3 +- .../gj/district/FangjiaClientUtils.groovy | 7 -- .../script/gj/district/PricePkTest.groovy | 2 +- .../script/gj/es/EsMonthHouseStat.groovy | 2 +- .../FjwBigdataDealBatch.groovy | 2 +- .../FjwThirdPartyPriceBatch.groovy | 2 +- .../guangfa/GuangfaBlankSelectDistrict.groovy | 2 +- .../gj/paimai/BeiKeCrawlByChrome.groovy | 4 +- .../script/gj/paimai/ExportPaimai.groovy | 2 +- .../gj/paimai/LianjiaCrawlByChrome.groovy | 4 +- .../script/gj/paimai/PaimaiDataSend.groovy | 2 +- .../script/gj/paimai/PaimaiTest.groovy | 2 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 4 +- .../script/gj/test/ExportToDealPrice.groovy | 4 +- .../fangjia/script/gj/test/FzBlankTest.groovy | 2 +- .../gj/test/JiangShuBlankDataStat.groovy | 2 +- .../script/gj/test/TestArroundPrice.groovy | 2 +- .../script/gj/township/StreetProcess.groovy | 2 +- .../gj/xiamen/NetworkDistanceBatch.groovy | 4 +- .../grade/ConsumptionRatingBatch.groovy | 4 +- .../script/jms/aliyun/AliyunSmsClient.groovy | 2 +- .../HousingTransactionExportBatch.groovy | 2 +- .../fangjia/script/loudong/CqfdcMatch.groovy | 2 +- .../script/majintao/GaodePOI2Baidu.groovy | 4 +- .../sync/CommunityHouseSampleBatch.groovy | 14 +-- .../DistrictStatClickhouseSyncBatch.groovy | 2 +- .../shenjian/DealPriceDetailExport.groovy | 4 +- .../script/temp/shenjian/PPE15Export.groovy | 4 +- .../temp/shenjian/PPE15ExportTest.groovy | 4 +- .../script/temp/shenjian/RentExport.groovy | 2 +- .../temp/shenjian/TotalTestExport.groovy | 4 +- .../shenjian/ValueRateCityInfoExport.groovy | 4 +- .../business/BusinessDianpingExport.groovy | 2 +- .../cqrcb/AroundExportByNewWay.groovy | 2 +- .../shenjian/cqrcb/AroundFormatExport.groovy | 2 +- .../temp/shenjian/cqrcb/ImportSchool.groovy | 2 +- .../shenjian/cqrcb/MarkUnNeedExport.groovy | 2 +- .../shenjian/cqrcb/MoveArroundTemp.groovy | 2 +- .../script/temp/shenjian/cqrcb/POIRule.groovy | 2 +- .../script/temp/shenjian/cqrcb/SavePoi.groovy | 2 +- .../temp/shenjian/cqrcb/SeaweedExport.groovy | 4 +- .../temp/shenjian/crawl/58/Seed58.groovy | 2 +- .../temp/shenjian/poi/CommitteeGeoHash.groovy | 2 +- .../temp/shenjian/poi/CommitteeLatLng.groovy | 2 +- .../temp/shenjian/poi/GetCodeFromExcel.groovy | 2 +- .../shenjian/poi/GetTownshipFromExcel.groovy | 2 +- .../temp/shenjian/util/CityUtils.groovy | 2 +- .../temp/shenjian/util/SeaweedUtils.groovy | 2 +- .../script/thirdPriceCrawl/DataStat.groovy | 2 +- .../thirdPriceCrawl/TestDistrict.groovy | 2 +- .../ThirdDataToGatherBatch.groovy | 2 +- .../script/trade/TradeDealPriceStat.groovy | 2 +- .../script/util/CosineSimilarAlgorithm.groovy | 94 +++++++++++++++- .../script/weilei/Daily/20181123.groovy | 2 +- .../script/weilei/Daily/20190115.groovy | 2 +- .../script/weilei/Daily/20190121.groovy | 2 +- .../com/fangjia/script/weilei/Test.groovy | 4 +- .../script/wenyan/address/Test1.groovy | 2 +- .../script/wenyan/temp/CityHousePrice.groovy | 2 +- .../script/wenyan/temp/DealPrice.groovy | 2 +- .../temp/DistrictStatRepeatRemover.groovy | 4 +- .../fangjia/script/wenyan/temp/Test13.groovy | 2 +- .../fangjia/script/wenyan/temp/Test14.groovy | 2 +- .../fangjia/script/wenyan/temp/Trend.groovy | 2 +- .../fangjia/script/wenyan/temp/XingYe.groovy | 2 +- .../script/yinjihaun/DealPriceStat.groovy | 2 +- .../yinjihaun/price/DistrictRateStat.groovy | 2 +- .../yinjihaun/price/QinLingStat1.groovy | 2 +- 129 files changed, 480 insertions(+), 240 deletions(-) diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml index 2b61cb696..ee869ba86 100644 --- a/projects/fangjia-script/pom.xml +++ b/projects/fangjia-script/pom.xml @@ -543,6 +543,18 @@ 1.18.2 + + org.apache.commons + commons-text + 1.9 + + + + com.hankcs.hanlp.restful + hanlp-restful + 0.0.12 + + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy index 1f2b994d6..bf662b6ea 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy @@ -21,7 +21,7 @@ import java.sql.DriverManager @BatchOwner(Watcher.WangWenYan) class ClickHouseDistrictStatMarkupCalcBatch extends BaseBatch { - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo", 27017) static void main(String[] args) { runBatch(new ClickHouseDistrictStatMarkupCalcBatch(), args) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy index 099982429..32afa22f9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy @@ -18,7 +18,7 @@ import com.mongodb.DBCollection @BatchOwner(Watcher.WangWenYan) class DistrictStatMarkupCalcBatch extends BaseBatch { - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) Date oneYearAgo = DateUtil.add(new Date(), Calendar.MONTH, -1) 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 4b9781f02..d96e0da05 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 @@ -8,8 +8,10 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ + def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2025年01月深圳二手房成交的.xlsx", 0, 1) -def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + +def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) //没有成交时间,随机生成 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 index d3df8510d..195dc1183 100644 --- 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 @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicLong */ class AddThirdPriceSample { - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection NO_PRICE_DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia_crawl", "deal_price_all", "mongo.db.fangjia.com") 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 f6baf3541..77f92137f 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 @@ -43,7 +43,7 @@ class BigdataDealBatch extends BaseBatch{ DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy index eaef4e568..a7681d9f0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy @@ -45,7 +45,7 @@ class DistrictDelete { def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new DistrictDelete() 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 ffd743d5c..b17f2aae6 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 @@ -27,7 +27,7 @@ class ThirdPartyPriceBatch extends BaseBatch { def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 // def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07", 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 c2caf475f..73c6676eb 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 @@ -36,7 +36,7 @@ class TradeStatLog { 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") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy index be649cf9d..f23121d0c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy @@ -18,10 +18,10 @@ import com.mongodb.QueryOperators import groovy.sql.Sql -DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") -DBCollection CITY_STAT = MongoUtils.getCollectionByName("fangjia_stat", "city_stat", "192.168.0.43") -DBCollection CITY_INFO = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", "192.168.0.43") -DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") +DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") +DBCollection CITY_STAT = MongoUtils.getCollectionByName("fangjia_stat", "city_stat", "mongo.db.fangjia.com") +DBCollection CITY_INFO = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", "mongo.db.fangjia.com") +DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy index 167fda35a..903a4b107 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy @@ -12,7 +12,7 @@ class MatchDealPriceRegion { static DBCollection collection = MongoUtils.getCollectionByName("fangjia_craw", "third_party_price", "192.168.0.235", 27018) - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy index e45fc62c6..06213a708 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy @@ -21,7 +21,7 @@ import org.apache.lucene.queryparser.classic.QueryParser */ class EvaluationBatch { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy index 66f7dd391..7f992095b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy @@ -18,7 +18,7 @@ class FumingTest { def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -3, "yyyyMM")) //202302 def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", "postgres", "postgres", "org.postgresql.Driver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy index 25560ff03..55cf2b8dd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy @@ -38,7 +38,7 @@ class HailanTest { } static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(80) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy index 42aedde30..3d8bc3152 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicLong class PocStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection HOUSE_LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", lineUrl) public static final DBCollection LOUDONG_LINE_COLL = MongoUtils.getCollectionByName2("fangjia_base", "loudong", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy index 2d862b119..c067c7694 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy @@ -15,7 +15,7 @@ class RuiFenPocTest { def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -3, "yyyyMM")) //202302 def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", "postgres", "postgres", "org.postgresql.Driver") 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 952f3eccd..17a82f2fc 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 @@ -99,7 +99,7 @@ class CommonDatautils { } public static final DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "community", "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009") - public static final DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + public static final DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com", 28017) public static final DBCollection OPERATION_LOG_COLL = MongoUtils.getCollectionByName("fangjia", "operation_log", "mongo.db.fangjia.com") public static final DBCollection STATS_INDEX_COLL = MongoUtils.getCollectionByName("fangjia_stat", "stats_index", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy index 86ebec035..34d890e67 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy @@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils class FewerHouseDistrictCrawlCommandBatch extends BaseBatch { private static final DBCollection ARTEMIS_COLL = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "mongo.db.fangjia.com") - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") static void main(String[] args) { runBatch(new FewerHouseDistrictCrawlCommandBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy index 68c1dc184..d569dba6d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy @@ -15,7 +15,7 @@ import org.bson.types.ObjectId //new FewerHouseDistrictCrawlCommandBatch().process(null); //return; // -//DBCollection col_43_artemis_message = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "192.168.0.43", 27017); +//DBCollection col_43_artemis_message = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "mongo.db.fangjia.com", 27017); //DBCursor cursor_artemis_message = col_43_artemis_message.find(new BasicDBObject("status", 0)); //int count = 0; //while(cursor_artemis_message.hasNext()){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy index 590386984..6f6512322 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy @@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit @BatchOwner(Watcher.GaoJuan) class DistrictTradeHouseStatBatch extends BaseBatch{ - public static DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") - public static DBCollection DISTRICT_TRADE_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_trade_stat", "192.168.0.43") + public static DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") + public static DBCollection DISTRICT_TRADE_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_trade_stat", "mongo.db.fangjia.com") static main(args) { runBatch(new DistrictTradeHouseStatBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index dba4650b9..e85220e8e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -23,7 +23,7 @@ import org.elasticsearch.common.xcontent.XContentType */ @BatchOwner(Watcher.GaoJuan) class SynchDealPriceToEs extends BaseBatch{ - static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static main(args) { runBatch(new SynchDealPriceToEs(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy index f1f8918e6..459c68770 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy @@ -20,7 +20,7 @@ class AbcEvaluationRowsBatch extends BaseBatch{ static final def fjtSqlInstance = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy index 377a7a6c0..d49b696f3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy @@ -29,7 +29,7 @@ class DistrictInfoExportBatch extends BaseBatch{ def charset = "GBK" - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl) public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName2("business", "fz_district", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy index 585e7bc0b..d049deab9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy @@ -23,7 +23,7 @@ class FzDataResultStat { public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName2("business", "fz_district", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy index b0ce64f12..2fc6f160d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy @@ -16,7 +16,7 @@ import net.sf.json.JSONObject import org.apache.commons.io.FileUtils import org.bson.types.ObjectId -DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") import com.fangjia.core.util.HttpRequest diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy index f96bf753a..f391d5dad 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy @@ -169,7 +169,7 @@ DingDingMessageUtil.sendTextMessage(access_token, s) // // //def count(name, sDate){ -// DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +// DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") // def q = new BasicDBObject() // q.put("city","福州") // q.put("s_date", sDate) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy index 11d76c586..fb6631ba3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy @@ -21,7 +21,7 @@ class ThirdPriceExportBatch extends BaseBatch{ def sDate= Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy index 22604b2ec..57b9f852c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy @@ -16,7 +16,7 @@ import java.util.concurrent.CountDownLatch class ThirdTest { - DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy index cd6252fb6..94efbb6df 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy @@ -25,7 +25,7 @@ class TradeExportBatch extends BaseBatch{ def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static def districtMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy index a7ba664d1..599ef8f1e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy @@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger class CzBankStat { public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("business", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("business", "average_statistics", "mongo.db.fangjia.com") def static final DBCollection CZLOG = MongoUtils.getCollectionByName("fangjia_log", "cz_log2", "192.168.0.136") static main(args) { def task = new CzBankStat(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy index 493c42d8c..c6ce91e86 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy @@ -16,7 +16,7 @@ import org.apache.commons.lang.StringUtils import java.util.regex.Pattern class DealPriceProcess { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") def total = 0 static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy index a38cf6268..8fccafde8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy @@ -17,7 +17,7 @@ import java.util.concurrent.Executors class DistrictDetailBatch { - public static DBCollection DISTRICT_DETAIL_COLL = MongoUtils.getCollectionByName("fangjia_youfang", "district_detail", "192.168.0.43") + public static DBCollection DISTRICT_DETAIL_COLL = MongoUtils.getCollectionByName("fangjia_youfang", "district_detail", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy index da0c07889..9d7c97533 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy @@ -40,7 +40,7 @@ class EsHouseStat { dataSource.setProperties(connectionProperties) } - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) public static void main(String[] args){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy index 6c33b2553..423764526 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy @@ -16,8 +16,8 @@ import java.sql.ResultSet class FZDataExport { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static EsDataSource dataSource = new EsDataSource() private static final String address = "jdbc:es://http://seawater.es.db.fangjia.com:9200/timezone=UTC&page.size=250&connect.timeout=120s&network.timeout=120s&page.timeout=120s" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy index 11123e02b..6e5a99f52 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy @@ -8,7 +8,7 @@ import com.mongodb.DBCollection class FZHouseEvaluation { - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) def regionMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy index 5f73a32b9..a941d08e9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy @@ -8,7 +8,7 @@ import com.mongodb.DBCollection class FjwUserStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection USER_COLL = MongoUtils.getCollectionByName2("fangjia_coresite", "user", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy index 1ffbaa246..a337263f9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy @@ -18,7 +18,7 @@ import org.bson.Document; import org.bson.conversions.Bson; class HouseLouDongMatch { - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy index 29bd4df02..e153f90b6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy @@ -22,7 +22,7 @@ class LandDetailCrawl { DBCollection LAND_COLL = MongoUtils.getCollectionByName("fangjia_crawl", "land_deal_price1", "192.168.0.235", 27018) - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection FJT_LAND_COLL = MongoUtils.getCollectionByName2("business", "land_distinct", lineUrl) public static final DBCollection OFF_FJT_LAND_COLL = MongoUtils.getCollectionByName2("business", "land_distinct", offlineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy index 7c62d7229..b99f162e1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy @@ -14,10 +14,10 @@ import org.apache.lucene.queryparser.classic.QueryParser class LogStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def static final DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new LogStat() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy index 276235d1d..7f1f0b25b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy @@ -21,8 +21,8 @@ import java.util.concurrent.Executors @BatchOwner(Watcher.GaoJuan) class NoHouseDistrictStatBatch extends BaseBatch{ - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; -// public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; +// public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", dbUrl) public static final DBCollection AVERAGER_CONFIG_COLL = MongoUtils.getCollectionByName2("fangjia", "averager_config", dbUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy index 77c705569..e0e481909 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy @@ -13,7 +13,7 @@ class PingAnAddressLevalTest { String token = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; - DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "192.168.0.43") + DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "mongo.db.fangjia.com") static main(args) { def task = new PingAnAddressLevalTest() task.run(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy index 30c9481ef..62ae568e5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy @@ -329,7 +329,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy index 67e127805..eb85734e0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy @@ -343,7 +343,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy index 92b2a9409..937c82184 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy @@ -6,7 +6,7 @@ import com.mongodb.DBCollection class RegionBlockSetting { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection REGION_BLOCK_COLL = MongoUtils.getCollectionByName2("fangjia", "region_block", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy index 1cd14588a..d0f6320d7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy @@ -17,8 +17,8 @@ import com.mongodb.DBObject class SynchDistrictStatBatch extends BaseBatch{ - //public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + //public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy index b9147952a..2b7e1049e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicLong class UpdateThirdPrice { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def static final DBCollection AVERAGE_STATISTICS_OFFLINE = CrawalDBUtil.getAverage_statistics_col(); public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy index 16063d88b..4ca121052 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy @@ -14,7 +14,7 @@ import groovy.sql.Sql class ApiUserCountAnalyBatch extends BaseBatch{ static final dbFangjia = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/fangjia?autoReconnect=true&characterEncoding=utf-8&autoReconnect=true", "sa", "G00jia", "com.mysql.jdbc.Driver"); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection AUTHORITY_COLL = MongoUtils.getCollectionByName2("fangjia", "authority.api_user_authority", lineUrl) DBCollection VISIT_COLL = MongoUtils.getCollectionByName2("business", "api_visit_count", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy index 19709dd22..7ea251213 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy @@ -10,7 +10,7 @@ import com.mongodb.DBCollection class CcbCityPriceStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqin/PocTest2023.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqin/PocTest2023.groovy index 27ea14198..08e1d9fb5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqin/PocTest2023.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqin/PocTest2023.groovy @@ -20,7 +20,7 @@ import com.mongodb.DBCollection */ class PocTest2023 { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) public static final DBCollection DISTRICT_ANALY_DATA_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_analy_data", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/DistrictSelectHouse.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/DistrictSelectHouse.groovy index ddcfd51fc..d0e32b227 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/DistrictSelectHouse.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/DistrictSelectHouse.groovy @@ -15,7 +15,7 @@ import org.apache.commons.lang.math.RandomUtils class DistrictSelectHouse { DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new DistrictSelectHouse(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/TestPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/TestPrice.groovy index e252654d5..952d0033a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/TestPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/chongqingblank/TestPrice.groovy @@ -9,8 +9,8 @@ import com.mongodb.QueryOperators class TestPrice { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy index 7ecf720df..26b2fa122 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/city/CityStatExport.groovy @@ -17,7 +17,7 @@ import org.elasticsearch.index.query.QueryBuilders class CityStatExport { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", dbUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/CityStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/CityStat.groovy index fad0c6bd1..0ddc8afec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/CityStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/CityStat.groovy @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicLong class CityStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", lineUrl) public static final DBCollection BAD_CASE_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "bad_case", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/DataStatTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/DataStatTest.groovy index bd2f0760b..aadcddc6e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/DataStatTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/commStat/DataStatTest.groovy @@ -21,13 +21,13 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong -def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; +def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) ExecutorService fixedThreadPool = Executors.newFixedThreadPool(40) -DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") -DBCollection region_stat_coll = MongoUtils.getCollectionByName("fangjia", "region_stat", "192.168.0.43") +DBCollection region_stat_coll = MongoUtils.getCollectionByName("fangjia", "region_stat", "mongo.db.fangjia.com") DBCollection mca_administrative_division_coll = MongoUtils.getCollectionByName("crawl", "mca_administrative_division_2022", "192.168.0.206", 27020) //def citys = ["乌鲁木齐","昌吉","阿克苏","伊犁","喀什"] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data/BestDistrictPriceExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data/BestDistrictPriceExport.groovy index 607d63378..69fe7a5be 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data/BestDistrictPriceExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data/BestDistrictPriceExport.groovy @@ -11,7 +11,7 @@ import com.mongodb.QueryOperators class BestDistrictPriceExport { DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new BestDistrictPriceExport(); 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 01b7a0338..99b05841f 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 @@ -5,10 +5,8 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -import com.rabbitmq.client.impl.AMQImpl import java.util.regex.Pattern - /** * 名录集 */ @@ -34,6 +32,7 @@ class MinglujiData { def prov = "江苏省" def city = "无锡" exportDatas(city) +// exportDatas(city) // matchDev(prov, city) // matchCommunity(city) // fiveLevelSplit(city) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy index 9608aee85..e6a6feaa8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy @@ -4,9 +4,12 @@ import com.fangjia.core.RegionData import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils +import org.bson.types.ObjectId import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions @@ -33,10 +36,14 @@ class RegionStandardBatch extends BaseBatch{ void process(Object args) { seaweedRegionStandard() // poiRegionStandard() +// seaweedRegionStandard() +// poiRegionStandard() + //通过乡镇街道修改区域 如:东莞市 +// updateRegionByTown() } def seaweedRegionStandard(){ - seaweedRegionStandardByCat("district") + seaweedRegionStandardByCat("office") } def poiRegionStandard(){ @@ -93,7 +100,7 @@ class RegionStandardBatch extends BaseBatch{ def seaweedRegionStandardByCat(cat){ - def citys = CommonDatautils.findAllCity() + def citys = ["伊春"]//CommonDatautils.findAllCity() for(def city : citys){ def rMap = regionMap.get(city) @@ -148,8 +155,12 @@ class RegionStandardBatch extends BaseBatch{ def streetMap = CommonDatautils.queryAllStreetNameByCity(fullCityName) if(streetMap){ set = streetMap.keySet() - def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name"]) + def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name","lng","lat"]) + println city +" "+ districts.size() + def index = 0 for(def d : districts){ + index ++ + println index +" "+ d.region if(set.contains(d.region)){ continue } @@ -157,8 +168,12 @@ class RegionStandardBatch extends BaseBatch{ def updateRegion = null def flag = null for(def key : set){ - def alias = streetMap.get(key) - if((alias && alias.contains(d.region)) || (!alias && key.contains(d.region))){ + def obj = streetMap.get(key) + def alias = null + if(obj && obj.alias){ + alias = obj.alias + } + if((alias && alias.contains(d.region)) || (!alias && key==d.region)){ def newRegion = RegionData.formatRegion(d.city, key) if(newRegion!=d.region){ updateRegion = newRegion @@ -166,13 +181,26 @@ class RegionStandardBatch extends BaseBatch{ flag = "pass" break; } + + if(obj.shape){ + def inAreaFlag = InsidePolygon.isInArea(d.lng/10000000000.0, d.lat/10000000000.0, InsidePolygon.createPoint4(obj.shape.coordinates)) + if(inAreaFlag){ + def newRegion = obj.street + newRegion = RegionData.formatRegion(d.city, newRegion) + if(newRegion!=d.region){ + updateRegion = newRegion + } + flag = "pass" + break; + } + } } if(updateRegion){ def udata = new BasicDBObject() udata.put("region", updateRegion) udata.put("m_date", new Date()) println d.city +" "+d.region+" "+d.name +" 区域修改为:"+updateRegion -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) }else{ if(flag!="pass"){ def udata = new BasicDBObject() @@ -402,4 +430,27 @@ class RegionStandardBatch extends BaseBatch{ return rets; } + def updateRegionByTown(){ + ExcelUtils.modify("d:\\数据\\城市与区域相同写字楼.xlsx",{d-> + def town = RegionData.formatRegion(d['B'], d['F']) + if(town){ + + def obj = CommonDatautils.findDistrict(d['B'], town, d['E'], "office") + if(!obj){ + def udata = new BasicDBObject() + udata.put("region", town) + udata.put("m_date", new Date()) + println d['F']+" "+" 区域修改为:" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + }else{ + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("status", 1) + println d['F']+" "+" 删除:" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + } + + } + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy index 6fce88fa6..748447212 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy @@ -16,7 +16,7 @@ class RegionUpdateBatch { public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new RegionUpdateBatch() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy index b5f4ceb7f..c3d0bf761 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.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.util.ElasticUtils import com.fangjia.script.util.ExcelUtils @@ -219,34 +220,41 @@ class TempExportData { } def exportOfficeHouseCount(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\写字楼\\待核实写字楼.xlsx",{d-> + ExcelUtils.multiThreadingModify("D:\\数据\\高德写字楼-房源第三方验证.xlsx",{d-> // def obj = findYuanQu(d['B'], d['D']) // if(obj){ // d['T'] = "前瞻存在" // } // if(!d['T']){ -// def obj = findYuanQu(d['B'], d['D']) +// def city = RegionData.formatCity(d['C']) +// def obj = findYuanQu(city, d['E']) // if(obj){ +// d['T'] = "前瞻存在" // d['U'] = obj.name // } // } // if(!d['T']) { -// def count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_sell") +// def city = RegionData.formatCity(d['C']) +// def region = RegionData.formatRegion(city, d['D']) +// +// def count = findHouseCountByCat(city, region, d['E'], "office_sell") // if (!count) { -// count = findHouseCountByCat(d['B'], d['C'], d['D'], "office_rent") +// count = findHouseCountByCat(city, region, d['E'], "office_rent") // } -// d['S'] = count +// d['T'] = count // } - if(!d['J']){ - def datas = CommonDatautils.findThirdNetWorkOffices(d['B'], d['C'], d['D']) + if(!d['T']){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + def datas = CommonDatautils.findThirdNetWorkOffices(city, region, d['E']) if(datas){ def sources = [] for(def o : datas){ sources << o.source } if(sources){ - d['K'] = sources.join(",") + d['V'] = sources.join(",") } } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy index 3f08229ce..1d22f4cc3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy @@ -1,58 +1,57 @@ package com.fangjia.script.gj.data_handle -import com.fangjia.script.commData.CommonDatautils -import com.fangjia.script.util.DateUtils -import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.MongoUtils -import com.mongodb.BasicDBObject -import com.mongodb.DBCollection -import org.apache.commons.lang.math.RandomUtils - -def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; -DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) - - -def city = "昌江" -ExcelUtils.modify("D:\\数据\\海南\\海南省城市均价.xlsx",{d-> - def date = d['B'] - def start = DateUtils.getFirstDayOfMonth(date) - def end = DateUtils.getLastDayOfMonth(date) - def weekends = DateUtils.getWeekendBetweenDates(start, end) - for(def weekend : weekends){ - def avg_price = d['I'] - def val = random(-200,200) - def new_price = (int)(avg_price*val/10000 + avg_price) - def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) - def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) - - def o = new BasicDBObject() - o.put("avg_price", new_price) - o.put("c_date" , new Date()) - o.put("city", city) - o.put("m_date" , new Date()) - o.put("weekend", weekend) - o.put("cat","城市") - o.put("moving_average" , (int)avg_price) - if(!last_price){ - o.put("weekend_markup" , 0) - }else{ - def weekend_markup = (int)((new_price-last_price)*100/last_price) - o.put("weekend_markup" , weekend_markup) - } - - def q = new BasicDBObject("cat", "城市").append("city", city).append("weekend", weekend) - REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) - } -},1) - - -public static final int random(int i1, int i2) { - int max = Math.max(i1, i2); - int min = Math.min(i1, i2); - return min + RandomUtils.nextInt(max - min + 1); -} - - +import org.bson.types.ObjectId +ObjectId objectId = new ObjectId("659c9ae92ae7732fd7d54e40"); +Date creationDate = objectId.getDate(); +System.out.println(creationDate); +//def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; +//DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) +// +// +//def city = "昌江" +//ExcelUtils.modify("D:\\数据\\海南\\海南省城市均价.xlsx",{d-> +// def date = d['B'] +// def start = DateUtils.getFirstDayOfMonth(date) +// def end = DateUtils.getLastDayOfMonth(date) +// def weekends = DateUtils.getWeekendBetweenDates(start, end) +// for(def weekend : weekends){ +// def avg_price = d['I'] +// def val = random(-200,200) +// def new_price = (int)(avg_price*val/10000 + avg_price) +// def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) +// def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) +// +// def o = new BasicDBObject() +// o.put("avg_price", new_price) +// o.put("c_date" , new Date()) +// o.put("city", city) +// o.put("m_date" , new Date()) +// o.put("weekend", weekend) +// o.put("cat","城市") +// o.put("moving_average" , (int)avg_price) +// if(!last_price){ +// o.put("weekend_markup" , 0) +// }else{ +// def weekend_markup = (int)((new_price-last_price)*100/last_price) +// o.put("weekend_markup" , weekend_markup) +// } +// +// def q = new BasicDBObject("cat", "城市").append("city", city).append("weekend", weekend) +// REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) +// } +//},1) +// +// +//public static final int random(int i1, int i2) { +// int max = Math.max(i1, i2); +// int min = Math.min(i1, i2); +// return min + RandomUtils.nextInt(max - min + 1); +//} +// +// +// +// +// diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy index f799e6651..31105176e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy @@ -3,23 +3,22 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.core.util.GeocodeUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.util.BaiduMapUtils -import com.fangjia.script.util.DataUtil import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import com.mongodb.DBObject -import com.mongodb.client.AggregateIterable -import org.bson.Document +import net.sf.json.JSONObject import org.bson.types.ObjectId import java.util.regex.Pattern - /** * 乡镇街道中间表 * 包含市,区,乡镇街道别名,来源 统计局community表 @@ -45,6 +44,8 @@ class TownMiddleProcess { DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + static DBCollection POLYLINECOLL2025 = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") + def fullCityMap = CommonDatautils.queryFullNameCity() static main(args) { @@ -96,6 +97,12 @@ class TownMiddleProcess { // checkCenterInTownRang()//检测乡镇街道中心点是否在围栏中 // addSpecialCityTownAlias() + + +// updateNewRegionPoyline()//更新新的区域围栏 + + updateMappingPolyline() + } @@ -681,7 +688,7 @@ class TownMiddleProcess { } def regionPolyline(){ - def dbcursor = REGIONPOLYLINE_COLL.find(new BasicDBObject("level","district")) + def dbcursor = POLYLINECOLL2025.find(new BasicDBObject("level","district")) def map = [:] for(def d : dbcursor){ def resultMap = [:] @@ -1356,4 +1363,90 @@ class TownMiddleProcess { keys.put("street", 1) return ADMINISTRATIVE_MAPPING_COLL.find(q, keys).toList() } + + def updateNewRegionPoyline(){ + + def regionPolylineMap = regionPolyline() + def q = new BasicDBObject() + q.put("type","区域") +// q.put("city", "苏州市") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + for(def d : dbcursor){ + def shapeData = regionPolylineMap.get(d.city+"|@|"+d.district) + println d.city+" "+d.district + if(shapeData){ + println "新围栏数:"+shapeData.shape.coordinates.size() + } + + if(d.shape){ + println "旧围栏数:"+d.shape.coordinates.size() + } + + if(d.shape && shapeData && shapeData.shape!=d.shape){ + def udata = new BasicDBObject() + udata.shape = shapeData.shape + udata.location = shapeData.location + udata.m_date = new Date() + ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// if(shapeData && d.shape && shapeData.shape.type=="polygon" && d.shape.type=="polygon"){ +// double area = com.fangjia.script.util.GeoHelper.calculateArea(shapeData.shape.coordinates[0]) +// double area1 = com.fangjia.script.util.GeoHelper.calculateArea(d.shape.coordinates[0]) +// if(Math.abs(area1-area)>=1){ +// println "新:"+area +// println "旧:"+area1 +// def udata = new BasicDBObject() +// udata.shape = shapeData.shape +// udata.location = shapeData.location +// //DMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// } +// } + } + } + } + + def updateMappingPolyline(){ + def q = new BasicDBObject() + q.put("type","区域") + q.put("shape.type","polygon") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + for(def d : dbcursor){ + updateAdministrativeMapping(d._id.toString(), d.shape) + } + } + + + def updateAdministrativeMapping(def id, def shape){ + 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.shape = params.newshape", + "params":{ + "newshape":{ + "type":"${shape.type}", + "coordinates":${shape.coordinates} + } + } + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + println(response) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 0d458ec18..3797a3924 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -31,7 +31,6 @@ import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong - /** * 区域标准化 * 1.小区库乡镇街道标准化,包含小区,商铺,写字楼 @@ -629,7 +628,7 @@ class TownStandardBatch extends BaseBatch{ // //通过调取地图api接口获取乡镇街道 // if(!saveObj.township){ -// def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) + def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) // if(gaodeMap && gaodeMap.addressComponent) { // def addressComponent = gaodeMap.addressComponent // if(addressComponent){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index b69e526a4..fd1066677 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -1,16 +1,9 @@ package com.fangjia.script.gj.district import com.fangjia.core.util.HttpRequest -import com.fangjia.script.addrepo.InvokeHttpRequest -import com.fangjia.script.statistics.poi.AmapPoi -import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.temp.shenjian.util.HttpUtils -import com.fangjia.script.util.HttpRequestUtil -import com.mongodb.DBObject import net.sf.json.JSONArray import net.sf.json.JSONObject -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang.StringUtils class FangjiaClientUtils { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy index 975d618ee..beabc5fd2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy @@ -9,7 +9,7 @@ import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; +def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def city = "常州" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy index 1b4bd8a80..d5d3956e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy @@ -14,7 +14,7 @@ import org.apache.lucene.queryparser.classic.QueryParser class EsMonthHouseStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) 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 59b61a9e5..f37ffa535 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 @@ -38,7 +38,7 @@ class FjwBigdataDealBatch extends BaseBatch{ DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", 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 892ebfea5..c5f33716f 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 @@ -29,7 +29,7 @@ class FjwThirdPartyPriceBatch extends BaseBatch { def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 // def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07", diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy index 7a00efd46..da8902cab 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy @@ -27,7 +27,7 @@ class GuangfaBlankSelectDistrict { public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection youda_esfhouse_coll = MongoUtils.getCollectionByName2("business", "res_esfdealprice", offlineUrl) - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new GuangfaBlankSelectDistrict(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy index 2003db863..62474f6c5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong public class BeiKeCrawlByChrome { def DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def startMonth = DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyy-MM"), -1, "yyyy-MM") WebDriver driver = null; @@ -118,7 +118,7 @@ public class BeiKeCrawlByChrome { } def crawlData(driver, citys){ - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def runedCitys = FileUtils.readTxt("d:\\数据\\成交抓取\\贝壳已抓城市.txt") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy index a458ccd56..b994d31e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy @@ -15,7 +15,7 @@ import java.util.regex.Pattern class ExportPaimai { - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy index ec1ad4acd..1730f28b7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong public class LianjiaCrawlByChrome { def DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def startMonth = DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyy-MM"), -1, "yyyy-MM") WebDriver driver = null; @@ -189,7 +189,7 @@ public class LianjiaCrawlByChrome { } def crawlData(driver, cityList){ - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def runedCitys = FileUtils.readTxt("d:\\数据\\成交抓取\\链家已抓城市.txt") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy index cf4bed800..f457e323e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy @@ -28,7 +28,7 @@ class PaimaiDataSend { DBCollection jd_coll = MongoUtils.getCollectionByName("fangjia_crawl", "fapai_jd_detail", "192.168.0.235", 27018) DBCollection rmfysszc_coll = MongoUtils.getCollectionByName("fangjia_crawl", "fapai_rmfysszc_detail", "192.168.0.235", 27018) - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy index 52add2e69..36ee62699 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy @@ -26,7 +26,7 @@ class PaimaiTest { DBCollection paimaiResultColl = MongoUtils.getCollectionByAuth20190102("fangjia", "pai_mai") - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) 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 2e27e41cc..9eaa268fc 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 @@ -30,7 +30,7 @@ class AddPriceTest { def pgsqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection confirm_price_date = MongoUtils.getCollectionByName("fangjia", "confirm_price_data", "mongo.db.fangjia.com") static main(args) { @@ -230,6 +230,8 @@ class AddPriceTest { if(newPriceMap){ d['G'] = newPriceMap.avg_price d['H'] = newPriceMap.month + d['H'] = map.calc_type +// d['AM'] = map.credit_value } } }) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy index d4440f329..4633e64b4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy @@ -13,8 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger class ExportToDealPrice { - DBCollection DEAL_PRICE_MATCH_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price_match", "192.168.0.43") - DBCollection DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + DBCollection DEAL_PRICE_MATCH_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price_match", "mongo.db.fangjia.com") + DBCollection DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") DBCollection TRADE_MATCH_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "trade_match_price", "192.168.0.136") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy index 976e008ba..5a8f83a8f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy @@ -14,7 +14,7 @@ import java.util.regex.Pattern class FzBlankTest { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy index 838fcbd20..63543c6b5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy @@ -20,7 +20,7 @@ import java.util.regex.Pattern class JiangShuBlankDataStat { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new JiangShuBlankDataStat() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy index d7b18e371..531870d89 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy @@ -12,7 +12,7 @@ import com.mongodb.DBCollection class TestArroundPrice { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_DATA_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_analy_data", lineUrl) public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy index 967fa21ce..d7e5fe6fe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicLong class StreetProcess { - final DBCollection TOWNSHIP = MongoUtils.getCollectionByName("fangjia", "township", "192.168.0.43") + final DBCollection TOWNSHIP = MongoUtils.getCollectionByName("fangjia", "township", "mongo.db.fangjia.com") public static final def MONGODB_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; public static final DBCollection TOWNSHIP100 = MongoUtils.getCollectionByName2("fangjia", "township", MONGODB_URL) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy index bf848d990..627c30884 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy @@ -27,9 +27,9 @@ class NetworkDistanceBatch extends BaseBatch{ public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) - final DBCollection NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network", "192.168.0.43") + final DBCollection NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network", "mongo.db.fangjia.com") - final DBCollection MAP_NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network_map", "192.168.0.43") + final DBCollection MAP_NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network_map", "mongo.db.fangjia.com") static main(args) { runBatch(new NetworkDistanceBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy index 4dc7c2384..43fd17c7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy @@ -20,10 +20,10 @@ import java.util.regex.Pattern class ConsumptionRatingBatch extends BaseBatch { def weekend = DateUtil.truncateDay(DateUtil.getFirstDayOfWeek(new Date())) public static - final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") public static - final DBCollection CONSUMPTION_GRADE_COLL = MongoUtils.getCollectionByName("fangjia_stat", "consumption_grade", "192.168.0.85") + final DBCollection CONSUMPTION_GRADE_COLL = MongoUtils.getCollectionByName("fangjia_stat", "consumption_grade", "mongo.db.fangjia.com") final DBCollection AMAP_POI_New_COLL = MongoUtils.getCollectionByName("m_dianping", "dianping_9", "114.80.150.196", 27777) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy index 05435c508..ededaa1db 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy @@ -52,7 +52,7 @@ class AliyunSmsClient { } public static void main(String[] args) { - sendSms("13916076378", "SMS_135220034", '{"code":12345}') + sendSms("15021384995", "SMS_482915107", '{"code":12345}') } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy index 586237d04..e99c9b8c4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy @@ -30,7 +30,7 @@ import java.sql.SQLException class HousingTransactionExportBatch extends BaseBatch { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static DBCollection _db_esf_transaction = MongoUtils.getCollectionByName("vip_site", "esf_transaction", "192.168.0.235", 27018); static MongoCollection PAI_MAI = Mongo3Utils.getDbCollection(Constants.FANGJIA_MONGO_URI, "fangjia_crawl", "pai_mai") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy index 2a231a42c..22f0a1f93 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy @@ -23,7 +23,7 @@ import java.util.regex.Pattern class CqfdcMatch { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection HOUSE_LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", lineUrl) static DBCollection loudongFdcConn = MongoUtils.getCollectionByName("fangjia_crawl", "loudong_cqfdc", "192.168.0.235", 27018) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy index 9bd28e7fd..e557d8799 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy @@ -53,8 +53,8 @@ def pcmap = [:] provinceList.remove("广西省") provinceList.add("广西壮族自治区") -DSCollection seabird = new DataStore("192.168.0.43", 28017).getCollection("fangjia_base.baidu_place_poi2") -DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "192.168.0.43", 28017) +DSCollection seabird = new DataStore("mongo.db.fangjia.com", 28017).getCollection("fangjia_base.baidu_place_poi2") +DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "mongo.db.fangjia.com", 28017) //def type3Not = ["学校内部设施", "进港", "出港", "候船室", "住宿服务相关"] // //def type2Not = ["学校", "专科医院", "综合医院", "诊所", "银行", "自动提款机", "便民商店/便利店", "家电电子卖场", "超级市场", "商场", "美容美发店", "地铁站", "港口码头", "住宿服务"] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy index f5c0a94c6..5bfa86aee 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy @@ -16,9 +16,9 @@ import com.mongodb.DBCollection //@BatchOwner(Watcher.MaJinTao) class CommunityHouseSampleBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) - DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) - DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) + DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) + DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "mongo.db.fangjia.com", 28017) DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird") static void main(String[] args) { @@ -160,13 +160,13 @@ import com.mongodb.DBCollection @BatchOwner(Watcher.MaJinTao) class CommunityHouseSampleBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) - DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) + DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) - DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017) + DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "mongo.db.fangjia.com", 28017) -// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "192.168.0.43", 28017) +// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "1mongo.db.fangjia.com", 28017) DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy index 5ba702a2e..cb11ad4c7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy @@ -16,7 +16,7 @@ import java.sql.Statement @BatchOwner(Watcher.WangWenYan) class DistrictStatClickhouseSyncBatch extends BaseBatch{ - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) static void main(String[] args) { runBatch(new DistrictStatClickhouseSyncBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy index 9f532247a..63cf10b20 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy @@ -19,9 +19,9 @@ import java.util.concurrent.* class DealPriceDetailExport { // 小区均价集合 - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) // 小区成交集合 - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43", 28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com", 28017) static final Map retMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(10) static ExecutorService districtExecutorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy index fb9b88402..2e0d4181a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicInteger class PPE15Export { // 小区均价集合 - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // 小区成交集合 - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) static ExecutorService districtExecutorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy index 40a866be1..41d8a59b2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicInteger class PPE15ExportTest { // 小区均价集合 - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // 小区成交集合 - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy index dbcf2139f..00b5638de 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy @@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class RentExport { - static DBCollection collection = MongoUtils.getCollectionByName("fangjia", "district_stat_rent", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia", "district_stat_rent", "mongo.db.fangjia.com",28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static Map retMap = new ConcurrentHashMap() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy index b0e7a120e..316e602cf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy @@ -20,9 +20,9 @@ import java.util.concurrent.CountDownLatch class TotalTestExport { // 小区均价集合 - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // 小区成交集合 - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() // 在此更改时间 static final def TRADE_DATE_START = "2020-03-28" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy index 82f000f52..c39dbc23d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy @@ -20,9 +20,9 @@ import java.util.concurrent.CountDownLatch class ValueRateCityInfoExport { // 小区均价集合 - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // 小区成交集合 - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() // 在此更改时间 static final def TRADE_DATE_START = "2020-03-28" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy index 3f03c1c01..76d9104bd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy @@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils class BusinessDianpingExport { static DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "business", "192.168.0.235", 27018) - static DBCollection cityCollection = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityCollection = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static void main(String[] args) { def cityCodes = ["320500","610100","340100"]; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy index 3bffc1300..be6b759e2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class AroundExportByNewWay { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static def resultMap = new ConcurrentHashMap() static def unMatchedMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy index 89b1c7b3c..2e5f11e3e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class AroundFormatExport { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static def resultMap = new ConcurrentHashMap() static def unMatchedMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy index b8f0452ee..242dd4c63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBObject */ class ImportSchool { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List> data = ExcelUtils.read("F:\\数据\\重庆农商行\\重庆学校_0902.xlsx", 1) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy index 9ce164947..4c4cfcffc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy @@ -16,7 +16,7 @@ import sun.swing.BakedArrayList */ class MarkUnNeedExport { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List> data = ExcelUtils.read("F:\\数据\\重庆农商行\\周边补充.xlsx", 1) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy index c641a4fc8..cceebeef6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger class MoveArroundTemp { static DBCollection conn = MongoUtils.getCollectionByName("seeddb_dev", "arround_temp", "192.168.0.235", 27018) - static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy index 1c907e236..02fda673e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy @@ -16,7 +16,7 @@ import java.util.regex.Pattern */ class POIRule { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy index 40c42f36a..496be8386 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger class SavePoi { static DBCollection conn = MongoUtils.getCollectionByName("seeddb_dev", "arround_temp", "192.168.0.235", 27018) - static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) //3km范围内地铁站、公交站、银行、医院、商场、学校等名称及距离信息 static def types = "150500|1507|090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211|1601|0601|141200|141201|141202|141203|141204" static def radius = 3000 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy index 9817c00cb..854052b17 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy @@ -27,9 +27,9 @@ import java.util.concurrent.Executors */ class SeaweedExport { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) - static final DBCollection seaweed = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) + static final DBCollection seaweed = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) static def map = new ConcurrentHashMap() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy index 79bf00e9a..0dab33e51 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy @@ -15,7 +15,7 @@ import com.mongodb.DBObject class Seaweed58 { static DBCollection districtSeedsConn = MongoUtils.getCollectionByName("seeddb", "district_seeds", "192.168.0.235", 27018) - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List list = cityMapConn.distinct("fangjia_city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy index 53b0679f0..60e5e17ce 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy @@ -18,7 +18,7 @@ import java.util.concurrent.Executors */ class CommitteeGeoHash { - static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) + static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy index db1f5a13d..d83e43625 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy @@ -20,7 +20,7 @@ import java.util.concurrent.Executors */ class CommitteeLatLng { - static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) + static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(10) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy index f466ed3be..b190fbd0b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBObject import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang.StringUtils -final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) +final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) /** * 获取省市区编码 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy index c8481a44a..4a12ce369 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBObject import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang.StringUtils -final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) +final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) /** * 获取国家标准居委街道 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy index 2949d3803..c73026057 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBCollection */ class CityUtils { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static listCitySet() { List list = cityMapConn.distinct("fangjia_city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy index c17285a78..d843c3034 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy @@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap */ class SeaweedUtils { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static def map = new ConcurrentHashMap() static getRegionByCode(def district_code) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy index 42972bc05..b0bde2dcf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy @@ -15,7 +15,7 @@ import org.apache.commons.codec.binary.Base64; class DataStat { def static final thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new DataStat(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy index aa6e24350..195136215 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy @@ -12,7 +12,7 @@ import java.util.regex.Pattern class Test { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43")//192.168.0.85 + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com")//192.168.0.85 def static final fieldMap = [ "房估估":"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", 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 d1fb7dc6f..f903f3172 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 @@ -27,7 +27,7 @@ class ThirdDataToGatherBatch extends BaseBatch{ def static final DBCollection AVERAGE_STATISTICS_OFFLINE = CrawalDBUtil.getAverage_statistics_col(); //MongoUtils.getMongoDBByAuth().getCollection("average_statistics") // def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com",38888) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43")//192.168.0.85 + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com")//192.168.0.85 def static final fieldMap = [ "房估估":"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", diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy index 67858c081..e2e874695 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy @@ -12,7 +12,7 @@ import java.sql.ResultSet class TradeDealPriceStat { - DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static def districtMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy index 3f12f1b79..300c1ea6b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy @@ -1,12 +1,28 @@ package com.fangjia.script.util +import com.hankcs.hanlp.restful.HanLPClient +import org.apache.commons.text.similarity.* +import org.apache.commons.text.similarity.JaroWinklerSimilarity + class CosineSimilarAlgorithm { + public static void main(String[] args){ - println CosineSimilarAlgorithm.getSimilarity("兰坪路301弄","兰坪路301弄12支弄,兰坪路301弄22支"); - println CosineSimilarAlgorithm.getSimilarity("兰坪路301弄12支弄,兰坪路301弄22支","兰坪路301弄"); - println CosineSimilarAlgorithm.getSimilarityRatio("江川路291号","江川路291弄") - println CosineSimilarAlgorithm.getSimilarityRatio("江川路291号","江川路290号"); + + def address1 = "市建四公司宿舍" + def address2 = "市建四公司小区" + + println "余弦相似:"+CosineSimilarAlgorithm.getSimilarity(address1, address2);//余弦相似 + println "编辑距离:"+CosineSimilarAlgorithm.levenshteinSimilarity(address1, address2);//编辑距离 + println "Jaro-Winkler 相似度:"+CosineSimilarAlgorithm.jaroWinklerSimilarity(address1, address2)//Jaro-Winkler 相似度 + println "综合相似:"+CosineSimilarAlgorithm.calculateSimilarity(address1, address2);//综合相似 + println "jaccard:"+CosineSimilarAlgorithm.jaccardSimilarity(address1, address2); + println "jaccard:"+CosineSimilarAlgorithm.jaccardSimilarity2(address1, address2); + +// def customTokenizer = { text -> text.split(" ").toSet() } +// +// def score2 = jaccardSimilarity(address1, address2, customTokenizer) +// println "按词语分割的Jaccard相似度: ${(score2 * 100).round(2)}%" } @@ -160,7 +176,73 @@ class CosineSimilarAlgorithm { public static float getSimilarityRatio(String str, String target) { return 1 - (float)compare(str, target)/Math.max(str.length(), target.length()); } - - + // 计算 Levenshtein 相似度 (基于编辑距离) + static def levenshteinSimilarity(String s1, String s2) { + def maxLength = Math.max(s1.size(), s2.size()) + if (maxLength == 0) return 1.0 + def lev = new LevenshteinDistance() + return 1 - (lev.apply(s1, s2) / maxLength) + } + + // 计算 Jaro-Winkler 相似度 + static def jaroWinklerSimilarity(String s1, String s2) { + def jw = new JaroWinklerSimilarity() + jw.apply(s1, s2) + } + + static def jaccardSimilarity(String str1, String str2, Closure tokenizer = null) { + // 默认分词逻辑:按字符分割为集合 + if (tokenizer == null) { + tokenizer = { text -> text.chars.collect { it as String } as Set } + } + + def set1 = tokenizer(str1) + def set2 = tokenizer(str2) + + // 处理空集合情况 + if (set1.isEmpty() && set2.isEmpty()) return 1.0 + if (set1.isEmpty() || set2.isEmpty()) return 0.0 + + def intersection = set1.intersect(set2).size() + def union = set1.size() + set2.size() - intersection + intersection / union as Double + } + + +// 综合相似度 (可调整权重) + static def calculateSimilarity(String s1, String s2) { + def levScore = levenshteinSimilarity(s1, s2) + def jwScore = jaroWinklerSimilarity(s1, s2) + // 加权平均 (Levenshtein 占40%, Jaro-Winkler 占60%) + (levScore * 0.4 + jwScore * 0.6).round(2) + } + + + static def jaccardSimilarity2(str1, str2) { + // 将字符串转换为字符集合 + def set1 = str1.chars.toSet() + def set2 = str2.chars.toSet() + + // 计算交集和并集 + def intersection = set1.intersect(set2).size() + def union = set1.size() + set2.size() - intersection + + // 计算Jaccard相似度 + def similarity = (double) intersection / union + + return similarity + } + + static def jaccardByChineseSegmentation(String str1, String str2) { + // 中文分词(需要HanLP依赖) + HanLPClient HanLP = new HanLPClient("https://www.hanlp.com/api", null); + def seg1 = HanLP.segment(str1).collect { it.word }.toSet() + def seg2 = HanLP.segment(str2).collect { it.word }.toSet() + + def intersection = seg1.intersect(seg2).size() + def union = seg1.size() + seg2.size() - intersection + + return union == 0 ? 0 : (double) intersection / union + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy index 0519c71eb..6012d1cb0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy @@ -8,7 +8,7 @@ import com.mongodb.BasicDBObject import com.mongodb.Bytes import com.mongodb.DBCollection -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia", "district_stat", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia", "district_stat", "mongo.db.fangjia.com") def query =new BasicDBObject(); query.put('weekend', DateUtils.parseFromTightYYYYMMDD("2018-11-18")); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy index a77707ae6..2a6223d63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy @@ -11,7 +11,7 @@ import com.mongodb.DBCursor import com.mongodb.DBObject import org.apache.commons.lang.StringUtils -DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat", "192.168.0.43", 28017); +DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat", "mongo.db.fangjia.com", 28017); DBObject q = new BasicDBObject("city": "西宁"); q.put("date", 201812); //q.put("date", new BasicDBObject('gt', 201806).append('lte', 201812)); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy index 8c8aa0990..6158704c7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy @@ -13,7 +13,7 @@ import org.apache.commons.lang.StringUtils List> detailRows = new ArrayList>(); detailRows.add(["城市", "区域", "小区名", "可性度"]); -DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017); +DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017); DBObject q = new BasicDBObject(); //new BasicDBObject('city', new BasicDBObject('$in', ["常州", "苏州", "淮安"])) q.put("city", "淮安"); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy index 772e91d06..050ba67fb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy @@ -27,7 +27,7 @@ for (int i = 0; i < FangGuGuCrawl.accountUsers.size(); i++) { } return 1; -DBCollection col_district_stat_1 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43"); +DBCollection col_district_stat_1 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com"); DBCollection col_district_stat_2 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.136", 27018); DBCollection col_district_stat_18 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.18", 28018); DBCursor cursor = col_district_stat_1.find().sort(new BasicDBObject("weekend", -1)).batchSize(2000).addOption(Bytes.QUERYOPTION_NOTIMEOUT); @@ -76,7 +76,7 @@ println "End - " + count; //return; // // -//DBCollection col_guiding_price = MongoUtils.getCollectionByName("fangjia", "guiding_price", "192.168.0.43", 27017); +//DBCollection col_guiding_price = MongoUtils.getCollectionByName("fangjia", "guiding_price", "mongo.db.fangjia.com", 27017); // //DBCursor cursor = col_guiding_price.find(new BasicDBObject('$where' , "this.name == this.guiding_person")); //while(cursor.hasNext()){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy index e67e057e5..47325a59c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy @@ -12,7 +12,7 @@ import java.sql.Connection import java.sql.ResultSet import java.sql.Statement -//final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +//final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") //def key = [] //int i =0 //DIST_STAT_COLL.find(new BasicDBObject("weekend", DateUtil.parseDate("20180826", "yyyyMMdd"))).batchSize(1000).each {def dbo-> diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy index b260aa415..f1563a0bb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy @@ -4,7 +4,7 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def data = ExcelUtils.read("D:\\Users\\wenyan\\Desktop\\城市评估均价对比.xlsx", 1) long total = 0 int count = 0 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy index d2ba9610a..9ee9d0379 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy @@ -20,7 +20,7 @@ import java.sql.Statement //Class.forName("ru.yandex.clickhouse.ClickHouseDriver"); //Connection connection = DriverManager.getConnection("jdbc:clickhouse://192.168.0.19:8123?max_memory_usage=50000000000") -//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") //DbUtils.multiThreadingExecuteQueryOnSeaweed(DbUtils.buildSeaweedQuery("上海"),{BasicDBObject district-> // def estate_type = "小区" // if(district.estate_type2.toString().contains("别墅")){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy index 75b6728d1..f86633ef6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy @@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong // //def removeRepeatDistrictStat(city, region, name, estate_type){ -// DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +// DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") // List stats = DISTRICT_STAT.find(new BasicDBObject("city", city).append("region", region).append("district_name", name).append("estate_type",estate_type)).toList() // def map = [:] // stats.each {BasicDBObject stat-> @@ -60,7 +60,7 @@ import java.util.concurrent.atomic.AtomicLong //}) -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") def keys = new BasicDBObject() keys.city = 1 keys.region = 1 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy index 7961e4d15..4ac5450d7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy @@ -12,7 +12,7 @@ import com.mongodb.DBCollection import net.sf.json.JSONArray import net.sf.json.JSONObject -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat_new", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat_new", "mongo.db.fangjia.com") def trend(city, region, name, weekend, estate_type) { def cmd = new BasicDBObject() cmd.city = city diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy index 1c7fa0a2c..bcfff62f7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy @@ -11,7 +11,7 @@ import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject -//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) +//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) //def int count =0 //ExcelUtils.multiThreadingModify("D:\\涨跌幅较大小区.xlsx",{ List item-> // def query = new BasicDBObject() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy index 016d99b3d..af9993be3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy @@ -10,7 +10,7 @@ import com.mongodb.Bytes import com.mongodb.DBCollection //def cities = ["北京", "上海", "广州","深圳","杭州","南京","武汉","成都","西安","长沙","南昌","贵阳","三亚"] -//DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") +//DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") //cities.each {def city-> // def one = GUIDING_PRICE.find(new BasicDBObject("city", city)).sort(new BasicDBObject("trade_date", 1)).limit(0)[0] // println(city + "\t" + ((Date)one.trade_date).format("yyyy")) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy index 2ebfa4262..41c5483ab 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy @@ -12,7 +12,7 @@ import java.sql.Connection import java.sql.ResultSet import java.sql.Statement -DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "192.168.0.43") +DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "mongo.db.fangjia.com") def String hasElevator(BasicDBObject seaweed){ EsDataSource dataSource = new EsDataSource() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy index e53eec2b6..d0a3a74c2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBCollection */ class DealPriceStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection deal_price_coll = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy index 5236cc675..db03ae997 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy @@ -330,7 +330,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy index 8b49db263..7e9558e4a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy @@ -344,7 +344,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file From 1c61cc3b76e988e6163eb63517d4fc53e2ba4db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 14 Apr 2025 16:05:41 +0800 Subject: [PATCH 230/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E9=93=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=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/ShopSellStat.java | 6 +- .../open/controllers/ShopSellController.java | 614 ++++++++++++++++++ .../service/datastore/AiShopServiceImpl.java | 69 +- 3 files changed, 648 insertions(+), 41 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java index 8745031ce..97c6c4623 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java @@ -14,7 +14,7 @@ public class ShopSellStat implements MongoEntity { private String city; private String district; private Integer date; - private Double avgPrice; + private Integer avgPrice; private String name; @Id @@ -65,11 +65,11 @@ public class ShopSellStat implements MongoEntity { } @Column(name = "avg_price") - public Double getAvgPrice() { + public Integer getAvgPrice() { return avgPrice; } - public void setAvgPrice(Double avgPrice) { + public void setAvgPrice(Integer avgPrice) { this.avgPrice = avgPrice; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java new file mode 100644 index 000000000..9aae9fb84 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * 商铺出售服务类 + * + * @author shenjian + * @since 2025/4/14 + */ +@Authority(role = Role.USER) +public class ShopSellController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * 城市出租均价 + * + * @return + */ + public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 区域出租均价 + * + * @return + */ + public Object districtSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼均价走势 + * + * @return + */ + public Object shopSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼楼租金地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + 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.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + 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; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateSell(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + /** + * 申请估值报告 + * + * @param model 申请报告请求参数 + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (model.getDistrict().endsWith("区")) { + model.setDistrict(model.getDistrict().replaceAll("区$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空")); + } + return mav; + } + + /** + * 获取估值报告 + * + * @param caseId 估值报告ID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空")); + } + return mav; + } + + 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; + } + + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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.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 floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_shop_evaluateRent"); + return evaluation; + } + + 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", "活动中心"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 5c7edbcff..6b65b649a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -17,7 +17,6 @@ import com.fangjia.service.datastore.dto.ShopEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.dto.GaodeDto; -import com.mongodb.BasicDBObject; import org.apache.commons.collections.CollectionUtils; import org.sothis.core.util.Closure; import org.sothis.core.util.Pager; @@ -322,8 +321,13 @@ public class AiShopServiceImpl implements AiShopService { } @Override - public List findShopSellStat(String city, String region, String name, String cat, Integer startDate, Integer endDate) { - return Collections.emptyList(); + public List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindShopSellStat(city, region, name, cat, startDate, endDate); + } + }); } private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { @@ -382,40 +386,28 @@ public class AiShopServiceImpl implements AiShopService { shopEvaluationDto.setLocation(evaluation.getLocation()); Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); - // 查询附近5个写字楼基准价 - BasicDBObject geo = new BasicDBObject(); - BasicDBObject nearQuery = new BasicDBObject(); - nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); - nearQuery.append("$maxDistance", 3000); - geo.append("$near", nearQuery); - - List params = new ArrayList(5); - params.add(new QueryParam("cat", "shop")); - params.add(new QueryParam("location", geo)); - - String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); - params.add(new QueryParam("date", Integer.parseInt(date))); - - // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - - List infos = shopSellStatDao.findAllByParams(params, sortParams, 5); - if (CollectionUtils.isEmpty(infos)) { - // 去掉类型,重新查找 - params = new ArrayList(5); - params.add(new QueryParam("cat", "shop")); - params.add(new QueryParam("location", geo)); - params.add(new QueryParam("date", Integer.parseInt(date))); - infos = shopSellStatDao.findAllByParams(params, sortParams); - } - if (CollectionUtils.isNotEmpty(infos)) { + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_sell"); + query.setRadius(1000); + // 查询近一年样本 + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; int count = 0; - for (ShopSellStat shopSellStat : infos) { - if (shopSellStat.getAvgPrice() != null) { - totalPrice += shopSellStat.getAvgPrice(); + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getAvgPrice(); count += 1; } } @@ -426,8 +418,9 @@ public class AiShopServiceImpl implements AiShopService { if (evaluation.getDirection() != null) { factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); } - Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); - shopEvaluationDto.setUnitPrice(avgPrice); + int avgPrice = (int) (totalPrice / count * factor); + shopEvaluationDto.setUnitPrice((double) avgPrice); + shopEvaluationDto.setSeawater(shops); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -454,12 +447,12 @@ public class AiShopServiceImpl implements AiShopService { return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { public List execute(String input) { - return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); + return doFindShopRentStat(city, region, name, cat, startDate, endDate); } }); } - public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + public List doFindShopRentStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { if (startDate == null) { throw new IllegalArgumentException("开始日期不能为空"); } From 8c1195ecf31f42ffd084f5518f5b2ee190736a7c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 17:22:23 +0800 Subject: [PATCH 231/247] update bug --- .../fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 5338abf79..929913e95 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -361,7 +361,7 @@ class AutoAddOfficeBatch extends BaseBatch { }else{ str = o2.name.replace(o1.name, "") } - if (nameScore > 0.6 && ["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { + if (nameScore > 0.6 && !["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { o2.nameScore = nameScore o2.addrScore = addrScore o2.score = nameScore @@ -412,7 +412,7 @@ class AutoAddOfficeBatch extends BaseBatch { }else{ str = o2.name.replace(o1.name, "") } - if (nameScore > 0.6 && nameScore>maxScore && ["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { + if (nameScore > 0.6 && nameScore>maxScore && !["一期","二期","三期","四期","五期","六期","七期","八期","九期","十期","东区","西区","南区","北区","A区","B区","C区","D区"].contains(str)) { maxObj = o2 o2.nameScore = nameScore o2.addrScore = addrScore From e3439517f0a1fad1f3e0f3b6aa5865d2022db12c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 17:30:00 +0800 Subject: [PATCH 232/247] update --- .../com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 929913e95..2875529ba 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -371,7 +371,7 @@ class AutoAddOfficeBatch extends BaseBatch { while(maxObj){ maxObj.nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(maxObj.name, o1.name); if(o1.address && maxObj.address){ - maxObj.addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, o2.address); + maxObj.addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, maxObj.address); } maxObj.score = maxObj.nameScore rets << maxObj From b361dbae19e74c9ab2c881c4a26dc6f54f98ef26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 14 Apr 2025 17:50:00 +0800 Subject: [PATCH 233/247] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 234 ++++++++++++++++-- 1 file changed, 214 insertions(+), 20 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 5928f1294..97e1a2ade 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -1,25 +1,23 @@ package com.fangjia.service.api; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; - -import net.sf.json.JSONArray; -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -import com.fangjia.core.util.GeoUtils; -import com.fangjia.core.util.HttpRequest; -import com.fangjia.core.util.HttpRequestException; -import com.fangjia.core.util.JsonUtils; +import com.fangjia.core.util.*; +import com.fangjia.dal.mongo.open.model.WaitCrawlKeywords; +import com.fangjia.service.address.AddressParserService; +import com.fangjia.service.address.AddressParserUtil; +import com.fangjia.service.address.mode.*; import com.fangjia.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchDistrictResult; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.mongo.bkoff.HouseLoudongService; +import com.fangjia.service.open.WaitCrawlKeywordsService; +import com.fangjia.service.sql.FjtEvaluationService; +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.util.*; /** * Created by wenyan on 2016/1/15. @@ -28,17 +26,97 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public static final int MIN_TIMEOUT = 1000 * 2; private final static String TOKEN = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; + private AddressParserService addressParserService; - public AddressMatchProxyServiceImpl(String apiHost) { + private HouseLoudongService houseLoudongService; + private FjtEvaluationService fjtEvaluationService; + private EvaluationService evaluationService; + private WaitCrawlKeywordsService waitCrawlKeywordsService; + + public AddressMatchProxyServiceImpl(String apiHost) { super(apiHost); } + private String realMatch(Map paramsMap) { + String address = paramsMap.get("address").toString(); + address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替 + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city")) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict")) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName")) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + if (paramsMap.containsKey("province")) { + params.setProvince(paramsMap.get("province").toString()); + } + if (paramsMap.containsKey("useMap")) { + params.setUseMap((Boolean) paramsMap.get("useMap")); + } + if (paramsMap.containsKey("debugName")) { + params.setDebugName(paramsMap.get("debugName").toString()); + } + if (paramsMap.containsKey("propertyType")) { + params.setPropertyType(paramsMap.get("propertyType").toString()); + } + long start = System.currentTimeMillis(); + Building building = addressParserService.parser(params); + long end = System.currentTimeMillis(); + if (end - start > 200) { + LOGGER.warn("匹配parser耗时:\t" + (end - start) + "ms"); + } + if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) { + verify(building); + } + JSONObject mav = new JSONObject(); + mav.put("viewType", "rest"); + mav.put("viewParam", new JSONObject().put("contentType", "application/json;charset=UTF-8")); + + JSONObject baseModel = new JSONObject(); + mav.put("model", baseModel); + + Map result = convertBuildingToMap(building); + if (paramsMap.containsKey("token") && !TOKEN.equals(paramsMap.get("token"))) { + submitFetchTask(building); + result.remove("precise"); + result.remove("searchAddress"); + result.remove("map"); + } + + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", result); + + return mav.toString(); + } + @Override public String parser(Map params) { params.put("token", TOKEN); long start = System.currentTimeMillis(); try { - String result = this.invoke("address/realMatch", params, "UTF-8"); + String result = realMatch(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -429,5 +507,121 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } - + + Map convertBuildingToMap(Building building) { + Map result = new LinkedHashMap(); + if (building != null) { + result.put("id", building.getId()); + result.put("credit", building.getCredit()); + result.put("precise", building.getPrecise()); + result.put("province", building.getProvince()); + result.put("city", building.getCity()); + result.put("district", building.getDistrict()); + result.put("name", building.getName()); + result.put("suggestName", building.getSuggestName()); + result.put("map", building.getMap()); + result.put("propertyType", building.getPropertyType()); + result.put("township", building.getTownship()); + result.put("suggestAddress", building.getSuggestAddress()); + if ("district".equals(building.getCategory())) { + result.put("category", "property"); + } else { + result.put("category", building.getCategory()); + } + result.put("address", building.getAddress()); + result.put("block", building.getBlock()); + result.put("lng", building.getLng()); + result.put("lat", building.getLat()); + result.put("alias", building.getAlias()); + result.put("searchAddress", building.getSearchAddress()); + } + return result; + } + + private void submitFetchTask(Building building) { + if (building.getPrecise() == -1) { + List keywords = new ArrayList(); + Address address = building.getSearchAddress(); + if (StringUtils.isNotBlank(address.getKeywords()) && address.getKeywords().length() > 2) { + keywords.add(address.getKeywords()); + } else if (address.getOrgAddress().length() > 2 && address.getOrgAddress().length() < 10) {// 一般小区名不会超过10个字 + keywords.add(address.getOrgAddress()); + } + if (address.isStandardAddress()) { + if (address.getStreetNumbers() != null) { + for (String b : address.getStreetNumbers()) { + keywords.add(address.getStreet() + b); + } + } else { + keywords.add(address.getStreet()); + } + } + keywords = DataUtil.uniqueList(keywords); + for (String k : keywords) { + WaitCrawlKeywords waitCrawlKeywords = new WaitCrawlKeywords(); + waitCrawlKeywords.setCity(address.getCity()); + waitCrawlKeywords.setDateCreated(new Date()); + waitCrawlKeywords.setRead(0); + waitCrawlKeywords.setKeywords(k); + waitCrawlKeywordsService.save(waitCrawlKeywords); + } + } + } + + private void verify(Building building) { + String city = building.getCity(); + String region = building.getDistrict(); + String name = null; + if (building.getPrecise() > -1) { + name = building.getName(); + } else { + name = building.getSearchAddress().getOrgKeywords(); + } + if (StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) { + String buildingNumber = AddressParserUtil + .standardizeBuildingNumber(building.getSearchAddress().getOrgBuildingNumber()); + if (buildingNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, buildingNumber, null, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, buildingNumber, + null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, buildingNumber, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } + } + + String roomNumber = AddressParserUtil.standardizeRoomNumber(building.getSearchAddress().getOrgRoomNumber()); + if (roomNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, null, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, null, + roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } + } + } + } + + public void setHouseLoudongService(HouseLoudongService houseLoudongService) { + this.houseLoudongService = houseLoudongService; + } + + public void setFjtEvaluationService(FjtEvaluationService fjtEvaluationService) { + this.fjtEvaluationService = fjtEvaluationService; + } + + public void setEvaluationService(EvaluationService evaluationService) { + this.evaluationService = evaluationService; + } + + public void setAddressParserService(AddressParserService addressParserService) { + this.addressParserService = addressParserService; + } + + public void setWaitCrawlKeywordsService(WaitCrawlKeywordsService waitCrawlKeywordsService) { + this.waitCrawlKeywordsService = waitCrawlKeywordsService; + } } From ac344c87666b2e03f358d1e6f6217277f1c599a8 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 14 Apr 2025 18:17:35 +0800 Subject: [PATCH 234/247] =?UTF-8?q?=E6=A8=A1=E7=89=88code=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy index 2009547e1..b6418a792 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy @@ -310,7 +310,7 @@ class SMSOutgoingListener extends BaseBatch { if(StringUtils.isNotBlank(checkCode)){ JSONObject con = new JSONObject() con.put("code", checkCode); - return AliyunSmsClient.sendSms(mobile, "SMS_482955117", con.toString()) + return AliyunSmsClient.sendSms(mobile, "SMS_483345375", con.toString()) } } int resCode = SingletonClient.getClient().sendSMS([mobile] as String[],content, 5) From 02928401be1c5330d357548e75be4aeb84123d0e Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 15 Apr 2025 08:55:24 +0800 Subject: [PATCH 235/247] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/AutoAddOfficeBatch.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 2875529ba..90b4020e0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -228,12 +228,17 @@ class AutoAddOfficeBatch extends BaseBatch { def citys = CommonDatautils.findAllCity() def allrets = [] allrets << [ "城市", "区域", "名称", "别名","计算方式","地址","名称相似度","地址相似度","总相似度"] + def index = 0 for (def c : citys) { + index++ + if(index>4){ + continue + } def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"]) def rets = checkRepeatDistrictBatch(c, districts) println c + " " + districts.size() allrets.addAll(rets) - println c +" 支行完成 "+rets.size() + println "${index}"+ c +" 运A行完成 "+rets.size() } ExcelUtils.write("/home/goojia/gj/重复可疑小区1.xlsx", allrets, "数据") } From 9f5a53c49a45faef628fb0c90b53d985a510d31c Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 15 Apr 2025 10:23:17 +0800 Subject: [PATCH 236/247] =?UTF-8?q?=E6=88=BF=E6=BA=90=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E6=9F=A5=E8=87=AA=E8=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 54f39bfaf..6eec08f4b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -900,6 +900,13 @@ public class HouseController { List type2 = Arrays.asList("1", "0"); RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); + String city = model.getCity(); + String region = model.getRegion(); + String districtName = model.getName(); + if (StringUtils.isNotBlank(districtName) && (StringUtils.isBlank(city) || StringUtils.isBlank(region))) { + mav.setModel(BasicModel.buildBadRequestModel("city,region,name为一组参数")); + return mav; + } if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())) { mav.setModel(BasicModel.buildBadRequestModel("参数(locationType)有误")); return mav; @@ -984,22 +991,25 @@ public class HouseController { cat = "shop_sell"; } } - List houses = null; + List houses = new ArrayList(); + List houseSelf = new ArrayList(); + List houseAround =new ArrayList(); List houseList = new ArrayList(); // if (cat.contains("_")) { // 商铺,写字楼有经纬度,直接查 SeawaterQuery query = new SeawaterQuery(); - query.setLat(lat); - query.setLng(lng); + // 先用名字查自身的样本 + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(districtName); query.setCat(cat); - query.setRadius(model.getRadius()); query.setStartDate(model.getStartTime()); query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { query.setStartArea(model.getSize() * 0.9); query.setEndArea(model.getSize() * 1.1); } - query.setCityDisplay(model.getCity()); Pager pager = new Pager(); pager.setStartRow(0); if (model.getPageSize() != null && model.getPageSize() > 0) { @@ -1009,8 +1019,28 @@ public class HouseController { } query.setPager(pager); query.setTable("latest_seawater"); - houses = seawaterDao.findSeawatersByQuery(query); + houseSelf = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseSelf); + // 如果自身样本数不够,再查周边 + if (houseSelf != null && houseSelf.size() < pager.getPageSize()){ + query.setRegion(null); + query.setDistrictName(null); + query.setLat(lat); + query.setLng(lng); + query.setRadius(model.getRadius()); + houseAround = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseAround); + } if (houses != null && !houses.isEmpty()) { + Set seenIds = new HashSet(); + Iterator iterator = houses.iterator(); + while (iterator.hasNext()) { + Seawater s = iterator.next(); + if (!seenIds.add(s.getId())) { + // 如果已经存在,则从列表中移除 + iterator.remove(); + } + } for (Seawater house : houses) { Seawater seawater = new Seawater(); seawater.setId(house.getId()); From f254494fe72fe4758db22caf0e0cc1b0d6456108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:23:41 +0800 Subject: [PATCH 237/247] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/AddressMatchProxyServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 97e1a2ade..65e43b8b6 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -72,7 +72,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme params.setProvince(paramsMap.get("province").toString()); } if (paramsMap.containsKey("useMap")) { - params.setUseMap((Boolean) paramsMap.get("useMap")); + params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true); } if (paramsMap.containsKey("debugName")) { params.setDebugName(paramsMap.get("debugName").toString()); @@ -89,12 +89,8 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) { verify(building); } - JSONObject mav = new JSONObject(); - mav.put("viewType", "rest"); - mav.put("viewParam", new JSONObject().put("contentType", "application/json;charset=UTF-8")); JSONObject baseModel = new JSONObject(); - mav.put("model", baseModel); Map result = convertBuildingToMap(building); if (paramsMap.containsKey("token") && !TOKEN.equals(paramsMap.get("token"))) { @@ -108,7 +104,8 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme baseModel.put("msg", "ok"); baseModel.put("result", result); - return mav.toString(); + + return baseModel.toString(); } @Override From 8fa4d3565972db2df58b021581f20b239c95b0c1 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 15 Apr 2025 10:30:58 +0800 Subject: [PATCH 238/247] =?UTF-8?q?=E6=88=BF=E6=BA=90=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E6=8C=89=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E5=80=92?= =?UTF-8?q?=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/open/controllers/HouseController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 6eec08f4b..cc49ec68a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1018,6 +1018,8 @@ public class HouseController { pager.setPageSize(5); } query.setPager(pager); + query.setSortField("p_date"); + query.setOrder(false); query.setTable("latest_seawater"); houseSelf = seawaterDao.findSeawatersByQuery(query); houses.addAll(houseSelf); From eb782694ad0108943e1fc773dd9327c62da98743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:49:43 +0800 Subject: [PATCH 239/247] =?UTF-8?q?=E6=94=B9=E9=80=A0realMatchAll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 93 ++++++++++++++++--- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 65e43b8b6..f4df5ff9a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -108,6 +108,55 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return baseModel.toString(); } + public String realMatchAll(Map paramsMap) { + String address = paramsMap.get("address").toString();; + address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替 + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city")) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict")) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName")) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + + if (paramsMap.containsKey("province")) { + params.setProvince(paramsMap.get("province").toString()); + } + AddressParseResult addressParseResult = addressParserService.parserAll(params); + List buildings = addressParseResult.getBuildings(); + List> buildingObjs = new ArrayList>(buildings.size()); + for (Building building : buildings) { + buildingObjs.add(convertBuildingToMap(building)); + } + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", buildingObjs); + return baseModel.toString(); + } + @Override public String parser(Map params) { params.put("token", TOKEN); @@ -129,7 +178,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public String parserAll(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realMatchAll", params, "UTF-8"); + String result = realMatchAll(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -508,29 +557,49 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme Map convertBuildingToMap(Building building) { Map result = new LinkedHashMap(); if (building != null) { - result.put("id", building.getId()); + if (StringUtils.isNotBlank(building.getId())) { + result.put("id", building.getId()); + } result.put("credit", building.getCredit()); result.put("precise", building.getPrecise()); result.put("province", building.getProvince()); result.put("city", building.getCity()); result.put("district", building.getDistrict()); result.put("name", building.getName()); - result.put("suggestName", building.getSuggestName()); - result.put("map", building.getMap()); + if (StringUtils.isNotBlank(building.getSuggestName())) { + result.put("suggestName", building.getSuggestName()); + } + if (StringUtils.isNotBlank(building.getMap())) { + result.put("map", building.getMap()); + } result.put("propertyType", building.getPropertyType()); - result.put("township", building.getTownship()); - result.put("suggestAddress", building.getSuggestAddress()); + if (StringUtils.isNotBlank(building.getTownship())) { + result.put("township", building.getTownship()); + } + if (StringUtils.isNotBlank(building.getSuggestAddress())) { + result.put("suggestAddress", building.getSuggestAddress()); + } if ("district".equals(building.getCategory())) { result.put("category", "property"); } else { result.put("category", building.getCategory()); } - result.put("address", building.getAddress()); - result.put("block", building.getBlock()); - result.put("lng", building.getLng()); - result.put("lat", building.getLat()); - result.put("alias", building.getAlias()); - result.put("searchAddress", building.getSearchAddress()); + if (StringUtils.isNotBlank(building.getAddress())) { + result.put("address", building.getAddress()); + } + if (StringUtils.isNotBlank(building.getBlock())) { + result.put("block", building.getBlock()); + } + if (building.getLng() != null && building.getLat() != null) { + result.put("lng", building.getLng()); + result.put("lat", building.getLat()); + } + if (building.getAlias() != null) { + result.put("alias", building.getAlias()); + } + if (building.getSearchAddress() != null) { + result.put("searchAddress", building.getSearchAddress()); + } } return result; } From 9b5038e9e06028a16ab27f156ab1f244d869a13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:55:40 +0800 Subject: [PATCH 240/247] =?UTF-8?q?=E6=94=B9=E9=80=A0=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 201 +++++++++++++++++- .../com/fangjia/service/dto/UniversalDto.java | 23 ++ 2 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index f4df5ff9a..6ece14e03 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -9,6 +9,7 @@ import com.fangjia.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchDistrictResult; import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.dto.UniversalDto; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.open.WaitCrawlKeywordsService; import com.fangjia.service.sql.FjtEvaluationService; @@ -186,11 +187,25 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String cleanCache(final Map paramsMap) { + + new Thread() { + @Override + public void run() { + addressParserService.clearCache((String) paramsMap.get("city")); + } + }.start(); + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "开始刷新缓存"); + return baseModel.toString(); + } + @Override public String cacheFlush(Map params){ params.put("token", TOKEN); try { - String result = this.invoke("address/cleanCache", params, "UTF-8"); + String result = cleanCache(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -198,11 +213,85 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realStandard(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Match); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { + matchParams.setProvince(paramsMap.get("province").toString()); + } + + matchParams.setUseAliyunApi(false); + matchParams.setContainsLocation("false".equals(paramsMap.get("containsLocation")) ? false : true); + Building building = addressParserService.standard(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + if (StringUtils.isBlank(building.getSuggestName())) { + if (StringUtils.isNotBlank(address.getParsedPropertyName())) { + dto.append("name", address.getParsedPropertyName()); + } else if (StringUtils.isNotBlank(address.getOrgKeywords())) { + dto.append("name", address.getOrgKeywords()); + } + } else { + dto.append("name", building.getSuggestName()); + } + if (StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())) { + String addr = building.getAddress(); + String street = AddressParserUtil.extractStreet(addr); + if (street != null) { + dto.append("street", street); + if (addr.length() != street.length()) { + dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr)); + } + } else if (StringUtils.isNotBlank(building.getStreet())) { + dto.append("street", building.getStreet()); + if (StringUtils.isNotBlank(building.getStreetno())) { + dto.append("streetNumber", building.getStreetno()); + } + } + } + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("floor", address.getFloor()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + if (matchParams.isContainsLocation()) { + dto.append("lat", building.getLat()); + dto.append("lng", building.getLng()); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String standard(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realStandard", params, "UTF-8"); + String result = realStandard(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -210,6 +299,48 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realCertificateAction(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + dto.append("name", building.getSuggestName()); + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + dto.append("certified", address.getCertified()); + dto.append("floor", address.getFloor()); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String certificate(Map params) { params.put("token", TOKEN); @@ -222,11 +353,75 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realAuth(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity((String) paramsMap.get("city")); + } + matchParams.setAddress((String) paramsMap.get("address")); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setUseMap(true); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + if (StringUtils.isNotBlank(address.getProvince())) { + dto.append("province", address.getProvince()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("city", address.getCity()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("district", address.getDistrict()); + } + if (StringUtils.isNotBlank(address.getDevelopmentZone())) { + dto.append("developmentZone", address.getDevelopmentZone()); + } + if (StringUtils.isNotBlank(address.getTownship())) { + dto.append("township", address.getTownship()); + } + if (StringUtils.isNotBlank(address.getStreet())) { + dto.append("street", address.getStreet()); + } + if (StringUtils.isNotBlank(address.getStreetNumber())) { + dto.append("streetNumber", address.getStreetNumber()); + } + if (StringUtils.isNotBlank(address.getBuildingNumber())) { + dto.append("buildingNumber", address.getBuildingNumber()); + } + if (StringUtils.isNotBlank(address.getUnitNumber())) { + dto.append("unitNumber", address.getUnitNumber()); + } + if (StringUtils.isNotBlank(address.getRoomNumber())) { + dto.append("roomNumber", address.getRoomNumber()); + } + if (StringUtils.isNotBlank(address.getFormattedAddress())) { + dto.append("formattedAddress", address.getFormattedAddress()); + } + List certified = address.getCertified(); + if (certified.contains("roomNumber")) { + dto.append("authLevel", "A"); + } else if (certified.contains("buildingNumber")) { + dto.append("authLevel", "B"); + } else { + dto.append("authLevel", "C"); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String auth(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realAuth", params, "UTF-8"); + String result = realAuth(params); return result; } catch (JSONException e) { LOGGER.error("", e); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java new file mode 100644 index 000000000..01fbb1490 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java @@ -0,0 +1,23 @@ +package com.fangjia.service.dto; + +import java.util.LinkedHashMap; + +/** + * 通用Dto,减少Dto的创建 + * @author 王文艳 + * @create 2016-10-08 + **/ +public class UniversalDto extends LinkedHashMap { + + + public static UniversalDto newDto(){ + return new UniversalDto(); + } + + public UniversalDto append(String key, Object value){ + this.put(key, value); + return this; + } + + +} From 1d6dbd0db3a3b5e8ae75376e23d242f9158d8ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 13:45:28 +0800 Subject: [PATCH 241/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/model/SeawaterDto.java | 96 +++++++++++++++++++ .../open/controllers/OfficeController.java | 2 - .../controllers/OfficeSellController.java | 2 - .../service/datastore/OfficeServiceImpl.java | 62 ++++++++++-- .../datastore/dto/OfficeEvaluationDto.java | 31 +----- 5 files changed, 155 insertions(+), 38 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java new file mode 100644 index 000000000..408097537 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -0,0 +1,96 @@ +package com.fangjia.dal.seawater.model; + +public class SeawaterDto { + + private String city; + private String district; + private String name; + private String fitment; + private Double area; + private Double unitPrice; + private String publishDate; + private String floorInfo; + + private String estateType; + private String bedKind; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFitment() { + return fitment; + } + + public void setFitment(String fitment) { + this.fitment = fitment; + } + + public Double getArea() { + return area; + } + + public void setArea(Double area) { + this.area = area; + } + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public String getPublishDate() { + return publishDate; + } + + public void setPublishDate(String publishDate) { + this.publishDate = publishDate; + } + + public String getFloorInfo() { + return floorInfo; + } + + public void setFloorInfo(String floorInfo) { + this.floorInfo = floorInfo; + } + + public String getEstateType() { + return estateType; + } + + public void setEstateType(String estateType) { + this.estateType = estateType; + } + + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 91d7f9a01..1a8370a0c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -280,7 +280,6 @@ public class OfficeController { districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); districtPriceMap.put("location", evaluation.getLocation()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); @@ -523,7 +522,6 @@ public class OfficeController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java index 00b0190b2..340914d13 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -288,7 +288,6 @@ public class OfficeSellController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOfficeSell()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { @@ -366,7 +365,6 @@ public class OfficeSellController { districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); districtPriceMap.put("location", evaluation.getLocation()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index b8f6cf578..5b46682f0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; @@ -366,6 +367,7 @@ public class OfficeServiceImpl implements OfficeService { String fitment = FITMENT_MAP.get(evaluation.getFitment()); String direction = DIRECTION_MAP.get(evaluation.getDirection()); + List seawaterDtoList = new ArrayList(); for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { Double price = Double.valueOf(seawater.getTotalPrice()); @@ -403,12 +405,14 @@ public class OfficeServiceImpl implements OfficeService { sum += price; size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, null); + seawaterDtoList.add(seawaterDto); } OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -429,17 +433,20 @@ public class OfficeServiceImpl implements OfficeService { OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + List seawaterList = new ArrayList(); if ("office_rent".equals(cat)) { for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -450,11 +457,13 @@ public class OfficeServiceImpl implements OfficeService { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { - Double unitPrice = DataUtil.roundDouble(sum / size, 2); + Double unitPrice = DataUtil.roundDouble(sum / size, 0); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -464,6 +473,25 @@ public class OfficeServiceImpl implements OfficeService { return officeEvaluationDto; } + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); + } + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; + } + @Override public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { @@ -514,6 +542,7 @@ public class OfficeServiceImpl implements OfficeService { sortParams.add(new SortParam("date", false)); List infos = officeRentStatDao.findAllByParams(params, sortParams, 5); + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isEmpty(infos)) { // 去掉类型,重新查找 params = new ArrayList(5); @@ -531,6 +560,15 @@ public class OfficeServiceImpl implements OfficeService { totalPrice += officeRentStat.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeRentStat.getCity()); + seawaterDto.setDistrict(officeRentStat.getDistrict()); + seawaterDto.setName(officeRentStat.getName()); + seawaterDto.setUnitPrice(officeRentStat.getAvgPrice()); + seawaterDto.setPublishDate(String.valueOf(officeRentStat.getDate())); + seawaterDto.setEstateType(officeRentStat.getEstateType2()); + seawaterDto.setBedKind(officeRentStat.getBedKind()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -544,7 +582,7 @@ public class OfficeServiceImpl implements OfficeService { } Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); officeEvaluationDto.setUnitPrice(avgPrice); - officeEvaluationDto.setOffice(infos); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -593,6 +631,7 @@ public class OfficeServiceImpl implements OfficeService { params.add(new QueryParam("date", Integer.parseInt(date))); infos = officeSellStatDao.findAllByParams(params, sortParams); } + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(infos)) { // 求均值 Double totalPrice = 0D; @@ -602,6 +641,15 @@ public class OfficeServiceImpl implements OfficeService { totalPrice += officeSellStat.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeSellStat.getCity()); + seawaterDto.setDistrict(officeSellStat.getDistrict()); + seawaterDto.setName(officeSellStat.getName()); + seawaterDto.setUnitPrice(officeSellStat.getAvgPrice().doubleValue()); + seawaterDto.setPublishDate(String.valueOf(officeSellStat.getDate())); + seawaterDto.setEstateType(officeSellStat.getEstateType2()); + seawaterDto.setBedKind(officeSellStat.getBedKind()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -613,9 +661,9 @@ public class OfficeServiceImpl implements OfficeService { if (evaluation.getDirection() != null) { factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); } - Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 0); officeEvaluationDto.setUnitPrice(avgPrice); - officeEvaluationDto.setOfficeSell(infos); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index 8007a2221..0752ee8e3 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -1,9 +1,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; -import com.fangjia.dal.mongo.model.OfficeRentStat; -import com.fangjia.dal.mongo.model.OfficeSellStat; -import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import java.util.List; @@ -15,17 +13,12 @@ public class OfficeEvaluationDto extends Evaluation { private Double unitPrice; - private List seawater; - - private List office; - - private List officeSell; + private List seawater; private String district; private String name; - public Double getUnitPrice() { return unitPrice; } @@ -34,11 +27,11 @@ public class OfficeEvaluationDto extends Evaluation { this.unitPrice = unitPrice; } - public List getSeawater() { + public List getSeawater() { return seawater; } - public void setSeawater(List seawater) { + public void setSeawater(List seawater) { this.seawater = seawater; } @@ -57,20 +50,4 @@ public class OfficeEvaluationDto extends Evaluation { public void setName(String name) { this.name = name; } - - public List getOffice() { - return office; - } - - public void setOffice(List office) { - this.office = office; - } - - public List getOfficeSell() { - return officeSell; - } - - public void setOfficeSell(List officeSell) { - this.officeSell = officeSell; - } } From d1bc59c23df577116e2df2c3ecb55c21971a3b51 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 15 Apr 2025 17:45:16 +0800 Subject: [PATCH 242/247] =?UTF-8?q?=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/AutoAddOfficeBatch.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy index 90b4020e0..5f8062242 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -231,7 +231,7 @@ class AutoAddOfficeBatch extends BaseBatch { def index = 0 for (def c : citys) { index++ - if(index>4){ + if(["宁波","无锡","青岛"].contains(c)){ continue } def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"]) @@ -239,8 +239,15 @@ class AutoAddOfficeBatch extends BaseBatch { println c + " " + districts.size() allrets.addAll(rets) println "${index}"+ c +" 运A行完成 "+rets.size() + + if (CommonDatautils.isWindow()) { + ExcelUtils.write("D://数据//小区/重复可疑小区-${c}.xlsx", allrets, "数据") + }else{ + ExcelUtils.write("/home/goojia/gj/重复可疑小区-${c}.xlsx", allrets, "数据") + } } - ExcelUtils.write("/home/goojia/gj/重复可疑小区1.xlsx", allrets, "数据") + + } def checkRepeatDistrictBatch(city,districts) { From 5584cfc175fc2a7914b2adda7428957ee992a3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 09:45:53 +0800 Subject: [PATCH 243/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=BC=B0=E5=80=BCBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/AddressMatchProxyServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 6ece14e03..ce98de284 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -57,28 +57,28 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme preciseLevel = PreciseLevel.STRICT; } MatchParams params = new MatchParams(); - if (paramsMap.containsKey("city")) { + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { params.setCity(paramsMap.get("city").toString()); } - if (paramsMap.containsKey("suggestDistrict")) { + if (paramsMap.containsKey("suggestDistrict") && paramsMap.get("suggestDistrict") != null) { params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); } - if (paramsMap.containsKey("suggestName")) { + if (paramsMap.containsKey("suggestName") && paramsMap.get("suggestName") != null) { params.setSuggestName(paramsMap.get("suggestName").toString()); } params.setAddress(address); params.setBuildingType(buildingType); params.setPreciseLevel(preciseLevel); - if (paramsMap.containsKey("province")) { + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { params.setProvince(paramsMap.get("province").toString()); } - if (paramsMap.containsKey("useMap")) { + if (paramsMap.containsKey("useMap") && paramsMap.get("useMap") != null) { params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true); } - if (paramsMap.containsKey("debugName")) { + if (paramsMap.containsKey("debugName") && paramsMap.get("debugName") != null) { params.setDebugName(paramsMap.get("debugName").toString()); } - if (paramsMap.containsKey("propertyType")) { + if (paramsMap.containsKey("propertyType") && paramsMap.get("propertyType") != null) { params.setPropertyType(paramsMap.get("propertyType").toString()); } long start = System.currentTimeMillis(); From c666be742edad3343d1df67dd198a6f6749bbb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 10:08:26 +0800 Subject: [PATCH 244/247] =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=96=B0=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FangjiaOpenExceptionHandler.java | 13 +++++-------- .../interceptors/AuthenticationInterceptor.java | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 7848e9b25..cf8cf4e7c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -1,18 +1,15 @@ package com.fangjia.open.exceptionhander; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - import com.fangjia.core.util.DingDingMessageUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.ExceptionHandler; + +import javax.servlet.ServletException; +import java.io.IOException; import java.net.Inet4Address; +import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; @@ -26,7 +23,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { ActionContext context = ActionContext.getContext(); String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!"); } catch (Exception e1) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index c04cab406..98784a878 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -109,9 +109,9 @@ public class AuthenticationInterceptor implements Interceptor { } } catch (Exception e) { String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { - DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication error!"); + DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication 错误!"); } catch (Exception e1) { e1.printStackTrace(); } From 980ae8d254094e06927b8ca603aacdd60ee3746e Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 16 Apr 2025 10:36:03 +0800 Subject: [PATCH 245/247] =?UTF-8?q?=E8=80=81=E8=84=9A=E6=9C=AC=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=AB=AF=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy | 2 +- .../IndividuateEvaAndRegisterTimeStatistical.groovy | 6 +++--- .../com/fangjia/script/index/SeaweedReIndexBatch.groovy | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy index fdc1746c9..25296b2a6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy @@ -35,7 +35,7 @@ class DatabaseStatWatcherBatch extends BaseBatch { def yesterday = DateUtil.add(today, -1) for(def host : hosts){ - Mongo mongo = new Mongo(new MongoURI("mongodb://${host}")) + Mongo mongo = new Mongo(new MongoURI("mongodb://developer:G00IDCDEV12385@${host}:28017")) for(def databaseName : mongo.getDatabaseNames()){ if(NOT_WATCH_DBS.contains(databaseName)){ continue diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy index bd24b9fc6..dcf8bd62f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy @@ -40,10 +40,10 @@ import groovy.sql.Sql @BatchOwner(Watcher.Hubingliang) class IndividuateEvaAndRegisterTimeStatistical extends BaseBatch{ final static def mongoDomain = "mongo.db.fangjia.com" - public static final DBCollection EVALUATION_TIME = MongoUtils.getCollectionByName("fangjia", "evaluation", "mongo.db.fangjia.com", 27017) - public static final DBCollection REGISTER_EVALUATION = MongoUtils.getCollectionByName("fangjia_base", "register_evaluation", "mongo.db.fangjia.com", 27017) + public static final DBCollection EVALUATION_TIME = MongoUtils.getCollectionByName("fangjia", "evaluation", "mongo.db.fangjia.com", 28017) + public static final DBCollection REGISTER_EVALUATION = MongoUtils.getCollectionByName("fangjia_base", "register_evaluation", "mongo.db.fangjia.com", 28017) - public static final DBCollection USER_COLL = MongoUtils.getCollectionByName("fangjia_coresite", "user", "mongo.db.fangjia.com", 27017) + public static final DBCollection USER_COLL = MongoUtils.getCollectionByName("fangjia_coresite", "user", "mongo.db.fangjia.com", 28017) static main(args) { def s = System.currentTimeMillis() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy index 84d62abc6..a015638cf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy @@ -16,7 +16,7 @@ import com.mongodb.DBCollection class SeaweedReIndexBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 27017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) static main(args) { println "==================== start reIndex seaweed district " + DateUtils.formatToTightYYYYMMDDhhmmss(new Date()) + " ==============================" From e78f569e882ce48527f481e0585885cce31f8081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 14:36:46 +0800 Subject: [PATCH 246/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E9=93=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=8E=E5=86=99=E5=AD=97=E6=A5=BC=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/AiShopServiceImpl.java | 91 ++++++++----------- .../datastore/dto/ShopEvaluationDto.java | 8 +- 2 files changed, 44 insertions(+), 55 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 6b65b649a..3c167db91 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.ShopRentStat; import com.fangjia.dal.mongo.model.ShopSellStat; import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import com.fangjia.service.datastore.dto.ShopEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; @@ -204,53 +205,23 @@ public class AiShopServiceImpl implements AiShopService { return getShopEvaluationDto(seawaters, evaluation, cat); } - /** - * 基准价*楼层系数*装修系数*朝向系数 - * - * @param seawaters - * @param evaluation - * @return - */ - private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { - Double sum = 0.0; - Double size = 0.0; - - String fitment = FITMENT_MAP.get(evaluation.getFitment()); - String direction = DIRECTION_MAP.get(evaluation.getDirection()); - for (Seawater seawater : seawaters) { - if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { - Double price = Double.valueOf(seawater.getTotalPrice()); - // 装修 - if (seawater.getFitment() != null) { - try { - price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); - } catch (Exception ex) { - - } - } - // 朝向 - if (seawater.getDirection() != null) { - try { - price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); - } catch (Exception ex) { - - } - } - - sum += price; - size += seawater.getArea(); - } + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); } - ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); - if (size > 0) { - Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); - shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); - shopEvaluationDto.setCity(evaluation.getCity()); - shopEvaluationDto.setDistrict(evaluation.getRegion()); - shopEvaluationDto.setName(evaluation.getDistrictName()); - } - return shopEvaluationDto; + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; } /** @@ -266,17 +237,20 @@ public class AiShopServiceImpl implements AiShopService { ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + List seawaterList = new ArrayList(); if ("shop_rent".equals(cat)) { for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setSeawater(seawaterList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -287,11 +261,13 @@ public class AiShopServiceImpl implements AiShopService { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size, 2); shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setSeawater(seawaterList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -351,15 +327,24 @@ public class AiShopServiceImpl implements AiShopService { query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; int count = 0; for (Seawater seawater : shops) { if (seawater.getAvgPrice() != null) { - totalPrice += seawater.getAvgPrice(); + totalPrice += seawater.getDayUnitPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getDistrict()); + seawaterDto.setName(seawater.getName()); + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + seawaterDto.setPublishDate(String.valueOf(seawater.getPublishDate())); + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -370,7 +355,7 @@ public class AiShopServiceImpl implements AiShopService { } Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); shopEvaluationDto.setUnitPrice(avgPrice); - shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setSeawater(seawaterDtoList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -401,6 +386,8 @@ public class AiShopServiceImpl implements AiShopService { query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); + + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; @@ -410,6 +397,8 @@ public class AiShopServiceImpl implements AiShopService { totalPrice += seawater.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_sell"); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -420,7 +409,7 @@ public class AiShopServiceImpl implements AiShopService { } int avgPrice = (int) (totalPrice / count * factor); shopEvaluationDto.setUnitPrice((double) avgPrice); - shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setSeawater(seawaterDtoList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java index 60432aa1f..14f9def80 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java @@ -1,7 +1,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; -import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import java.util.List; @@ -13,7 +13,7 @@ public class ShopEvaluationDto extends Evaluation { private Double unitPrice; - private List seawater; + private List seawater; private String district; @@ -28,11 +28,11 @@ public class ShopEvaluationDto extends Evaluation { this.unitPrice = unitPrice; } - public List getSeawater() { + public List getSeawater() { return seawater; } - public void setSeawater(List seawater) { + public void setSeawater(List seawater) { this.seawater = seawater; } From feb6543188efbc427662a8473d76c47afa8328a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 14:42:31 +0800 Subject: [PATCH 247/247] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E9=93=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=8E=E5=86=99=E5=AD=97=E6=A5=BC=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/service/datastore/AiShopServiceImpl.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 3c167db91..0998d0437 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -209,7 +209,7 @@ public class AiShopServiceImpl implements AiShopService { SeawaterDto seawaterDto = new SeawaterDto(); seawaterDto.setCity(seawater.getCity()); seawaterDto.setDistrict(seawater.getRegion()); - seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setName(seawater.getName()); seawaterDto.setArea(seawater.getArea()); seawaterDto.setFitment(seawater.getFitment()); if (cat != null && cat.contains("rent")) { @@ -337,13 +337,7 @@ public class AiShopServiceImpl implements AiShopService { totalPrice += seawater.getDayUnitPrice(); count += 1; } - SeawaterDto seawaterDto = new SeawaterDto(); - seawaterDto.setCity(seawater.getCity()); - seawaterDto.setDistrict(seawater.getDistrict()); - seawaterDto.setName(seawater.getName()); - seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); - seawaterDto.setPublishDate(String.valueOf(seawater.getPublishDate())); - seawaterDto.setEstateType(seawater.getEstateType()); + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_rent"); seawaterDtoList.add(seawaterDto); } Double factor = 1.0;