From e993a2d0bce4f5d3f47838c95ecfd42c2ff4bfd8 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Fri, 1 Mar 2024 10:25:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E4=BB=B7=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/wenyan/Test3.groovy | 109 ++++++++---------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/Test3.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/Test3.groovy index d2ba9d116..f4430e6a9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/Test3.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/Test3.groovy @@ -1,7 +1,16 @@ +import com.fangjia.core.RegionData +import com.fangjia.core.util.GeoUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.core.util.Mongo3Utils +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.util.CommonUtils +import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils +import com.mongodb.BasicDBObject import com.mongodb.client.MongoCollection +import net.sf.json.JSONObject import org.bson.Document +import org.bson.types.ObjectId import org.elasticsearch.xpack.sql.jdbc.EsDataSource import java.sql.Connection @@ -11,67 +20,43 @@ import java.util.function.Consumer import static com.mongodb.client.model.Filters.and import static com.mongodb.client.model.Filters.eq +//REGION_CONN = MongoUtils.getCollectionByName("fangjia", "region_block", MongoUtils.MongoDB_Domain_mongo, MongoUtils.MongoDB_Port_28017); +//TOWNSHIP_CONN = MongoUtils.getCollectionByName("fangjia", "township", MongoUtils.MongoDB_Domain_mongo, MongoUtils.MongoDB_Port_28017); +//TOWNSHIP_CONN.find().each {BasicDBObject township-> +// township.area_station = township.central +// township.removeField("central") +// TOWNSHIP_CONN.save(township) +// +//} +//REGION_CONN.find(new BasicDBObject("category", "region")).each {BasicDBObject regionBlock-> +// def lng = regionBlock.lng/10000000000l +// def lat = regionBlock.lat/10000000000l +// HttpRequest request = new HttpRequest() +// JSONObject resp = request.getJsonContent("http://localhost:8080/FangJiaAddressService/geocode/township", ['location':"$lng,$lat".toString()], "UTF-8") +// if(resp.result){ +// TOWNSHIP_CONN.update(new BasicDBObject("_id", new ObjectId(resp.result.id)), new BasicDBObject('$set', new BasicDBObject('central', 1))) +// println(resp.result) +// } +//} -def cityList = ["上海", "广州", "北京", "深圳", "成都", "杭州", "重庆", "武汉", "西安", "天津"] -def roots = ["lianjia.com", "zhuge.com", "fang.com", "anjuke.com", "58.com", "soufy.cn"] -MongoCollection DISTRICT_STAT = Mongo3Utils.getDbCollection("fangjia", "district_stat_rent") -MongoCollection DEAL_PRICE = Mongo3Utils.getDbCollection("fangjia", "deal_price") -def data = [["城市", "区域", "小区名", "版块", "装修", "朝向", "室", "厅", "卫", '标题', '总价', '面积', '单价', '发布时间', '来源']] -cityList.each { def city -> - def statMap = [:] - DISTRICT_STAT.find(and(eq("city", city), eq("end_month_date", Date.parse("yyyyMMdd", "20190228")))).forEach(new Consumer() { - @Override - void accept(Document t) { - def key = "${t.city}_${t.region}_${t.district_name}_${t.house_type}".toString() - statMap[key] = t.avg_price - } - }) - roots.each { def root -> - EsDataSource dataSource = new EsDataSource(); - String address = "jdbc:es://http://192.168.0.206:9200/timezone=UTC&page.size=250&connect.timeout=120s&network.timeout=120s&page.timeout=120s" - dataSource.setUrl(address) - Properties connectionProperties = new Properties() - connectionProperties.put("user", "developer") - connectionProperties.put("password", "5e8edd851d2fdfbd7415232c67367cc3") - dataSource.setProperties(connectionProperties) - Connection connection = dataSource.getConnection() - Statement statement = connection.createStatement() - ResultSet rs = statement.executeQuery("""select * from "seawater-2019" where city='${city}' and cat = 'rent' order by p_date""") - int count = 0 - while (rs.next()) { - String region = rs.getString("region") - String district_name = rs.getString("district_name") - int room = rs.getInt("room") - def key = "${city}_${region}_${district_name}_${room}".toString() - if (!statMap.containsKey(key)) { - continue - } - int total_price = rs.getInt("total_price") - double area = rs.getDouble("area") - int avg_price = (int) (total_price / area) - if (total_price * 1.3 || total_price < statMap[key] * 0.7) { - continue - } - String block = rs.getString("block") - String name = rs.getString("name") - String fitment = rs.getString("fitment") - String direction = rs.getString("direction") - int hall = rs.getInt("hall") - int toilet = rs.getInt("toilet") - int p_date = rs.getInt("p_date") - if (!block || !name || !fitment || !direction || room == 0 || hall == 0 || toilet == 0) { - continue - } - println(rs.getString('url')) - def item = [city, region, district_name, block, fitment, direction, room, hall, toilet, name, total_price, area, avg_price, p_date, root] - println(item) - data << item - count++ - if(count > 10){ - break - } - } - } -} -ExcelUtils.write("D:\\建设银行\\租金样本.xlsx", data, "结果") \ No newline at end of file +//CommonUtils.findAllCity().each {def city-> +// DbUtils.multiThreadingExecuteQueryOnSeaweed(DbUtils.buildSeaweedQuery(city, null, null, "district"),{BasicDBObject office-> +// if(!office.township){ +// def lng = office.lng/10000000000l +// def lat = office.lat/10000000000l +// HttpRequest request = new HttpRequest() +// JSONObject resp = request.getJsonContent("http://localhost:8080/FangJiaAddressService/geocode/township", ['location':"$lng,$lat".toString()], "UTF-8") +// if(resp.result){ +// println(office._id.toString() + "\t" + office.township + "\t-->\t" + resp.result.streetName) +// DbUtils.seaweed.update(new BasicDBObject("_id", office._id), new BasicDBObject('$set', new BasicDBObject('township', resp.result.streetName))) +// } +// } +// }) +//} +ExcelUtils.multiThreadingModify("C:\\Users\\goojia\\Desktop\\地图查询数据导出-添加经纬度-兴趣点.xlsx",{List item-> + def lng = item["AB"].toString().split(",")[0].toDouble() + def lat = item["AB"].toString().split(",")[1].toDouble() + item["AD"] = GeoUtils.calculateDistance(121.526672,31.142637,lng, lat) + println(item) +}) \ No newline at end of file From 51189231edb137921d5170abe2c4339cff9570dc Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Fri, 1 Mar 2024 11:34:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96Trigger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/index/SellTriggerServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/index/SellTriggerServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/index/SellTriggerServiceImpl.java index af7d6be61..1f7ab6869 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/index/SellTriggerServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/index/SellTriggerServiceImpl.java @@ -165,8 +165,11 @@ public class SellTriggerServiceImpl implements TriggerService { newObj.put("districtname_key", district.getName() + "_" + newObj.get("region") + "_" + object.get("city")); newObj.put("district_name", district.getName()); } + }else{ + if(object.containsField("city") && object.containsField("district_name") && object.containsField("region")){ + newObj.put("districtname_key", object.get("district_name") + "_" + object.get("region") + "_" + object.get("city")); + } } - // newObj.put("if_school", 0); // if (districtSchoolMap != null && districtSchoolMap.containsKey(districtKey)) { // List skList = districtSchoolMap.get(districtKey); From 3c487b12495eae103d050cd09820927390eeae5c Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Tue, 5 Mar 2024 15:10:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E6=9C=AC?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/district/DistrictHouseBatch.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy index fa3d57a71..a66decde6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy @@ -3,6 +3,7 @@ package com.fangjia.script.district import com.fangjia.script.util.MongoUtils import com.mongodb.DBCursor +import org.apache.commons.lang3.StringUtils import java.util.List @@ -55,6 +56,15 @@ class DistrictHouseBatch extends BaseBatch { String key = district.get("name").toString().trim() + "_" + district.get("region") + "_" + district.get("city") long sellCount = sellCountMap.get(key) ? sellCountMap.get(key) : 0 long rentCount = rentCountMap.get(key) ? rentCountMap.get(key) : 0 + if(district.alias != null){ + for(String alia: district.alias){ + if(StringUtils.isNotBlank(alia)){ + key = alia.trim() + "_" + district.get("region") + "_" + district.get("city") + sellCount = sellCount + (sellCountMap.get(key)? sellCountMap.get(key) : 0) + rentCount = rentCount + (rentCountMap.get(key)? rentCountMap.get(key) : 0) + } + } + } saveToDistrictHouse(district.get('city'), district.get("region"), district.get("name"), sellCount, rentCount, sn) } @@ -109,6 +119,7 @@ class DistrictHouseBatch extends BaseBatch { fields.put("city", 1) fields.put("region", 1) fields.put("name", 1) + fields.put("alias", 1) def ret = [] From def60cbc6dff23982420816d558f633c11f4c48b Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Tue, 5 Mar 2024 15:26:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E4=BB=B7=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/district/DistrictHouseBatch.groovy | 11 +++-------- .../com/fangjia/script/wenyan/test/Test1.groovy | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy index dbc92b4dd..fea372b37 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictHouseBatch.groovy @@ -69,7 +69,7 @@ class DistrictHouseBatch extends BaseBatch { for(DBObject district : districts) { def names = [] names << district.name - if(district.alias && districts.size()>0){ + if(district.alias && district.alias.size()>0){ for(def name : district.alias){ if(!names.contains(name)){ names << name @@ -81,14 +81,9 @@ class DistrictHouseBatch extends BaseBatch { long rentCount = 0 for(def name : names){ String key = name.toString().trim() + "_" + district.get("region") + "_" + district.get("city") - if(!sellCount){ - sellCount = sellCountMap.get(key) ? sellCountMap.get(key) : 0 - } - if(!rentCount){ - rentCount = rentCountMap.get(key) ? rentCountMap.get(key) : 0 - } + sellCount = sellCount + (sellCountMap.get(key) ? sellCountMap.get(key) : 0) + rentCount = rentCount + (rentCountMap.get(key) ? rentCountMap.get(key) : 0) } - saveToDistrictHouse(district.get('city'), district.get("region"), district.get("name"), sellCount, rentCount, sn) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/test/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/test/Test1.groovy index e6c27c934..ce4d04b65 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/test/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/test/Test1.groovy @@ -5,7 +5,11 @@ import com.fangjia.datastore.driver.DataStore import com.fangjia.script.util.DbUtils import com.mongodb.BasicDBObject -DSCollection seabird = new DataStore("192.168.0.38", 27007).getCollection("fangjia.seaweed") -seabird.find(DbUtils.buildSeaweedQuery("常州", "溧阳", "吾悦广场").append("if_sell", 1)).each { - println(it) +//、DSCollection seabird = new DataStore("192.168.0.38", 27007).getCollection("fangjia.seaweed") +//seabird.find(DbUtils.buildSeaweedQuery("常州", "溧阳", "吾悦广场").append("if_sell", 1)).each { +// println(it) +//} +long l = 0 +if(!l){ + println(l) } \ No newline at end of file