Merge remote-tracking branch 'origin/master'

This commit is contained in:
majintao
2025-04-17 10:29:24 +08:00
23 changed files with 760 additions and 400 deletions
@@ -78,4 +78,7 @@ public class MongoUtils {
} }
return conn; return conn;
} }
} }
@@ -0,0 +1,106 @@
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;
private String address;
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;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
@@ -280,7 +280,6 @@ public class OfficeController {
districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("district", evaluation.getDistrict());
districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("name", evaluation.getName());
districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("refOffices", evaluation.getOffice());
districtPriceMap.put("location", evaluation.getLocation()); districtPriceMap.put("location", evaluation.getLocation());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
@@ -523,7 +522,6 @@ public class OfficeController {
districtPriceMap.put("name", district.getName()); districtPriceMap.put("name", district.getName());
districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("refOffices", evaluation.getOffice());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
try { try {
@@ -288,7 +288,6 @@ public class OfficeSellController {
districtPriceMap.put("name", district.getName()); districtPriceMap.put("name", district.getName());
districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("refOffices", evaluation.getOfficeSell());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
try { try {
@@ -366,7 +365,6 @@ public class OfficeSellController {
districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("district", evaluation.getDistrict());
districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("name", evaluation.getName());
districtPriceMap.put("samples", evaluation.getSeawater()); districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("refOffices", evaluation.getOffice());
districtPriceMap.put("location", evaluation.getLocation()); districtPriceMap.put("location", evaluation.getLocation());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
@@ -1,190 +0,0 @@
//package com.fangjia.open.controllers;
//
//import com.google.gson.Gson;
//import com.google.gson.JsonArray;
//import com.google.gson.JsonObject;
//import org.apache.http.HttpEntity;
//import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.ContentType;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.util.EntityUtils;
//import sun.misc.BASE64Encoder;
//
//import java.io.IOException;
//import java.net.Authenticator;
//import java.net.InetSocketAddress;
//import java.net.PasswordAuthentication;
//import java.net.Proxy;
//import java.nio.charset.Charset;
//import java.nio.charset.StandardCharsets;
//import java.util.Base64;
//import java.util.HashMap;
//import java.util.Map;
//
////public class Test {
//// public static void main(String[] args) throws IOException {
//// // 目标URL
//// 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";
////
//// // 设置请求的JSON数据
//// String address = "江苏省扬州市宝应县安宜镇宝应大道88号";
//// String type = "1";
//// String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}";
////
//// // 设置HTTP基本认证
//// String authKey = proxyUsername;
//// String password = proxyPassword;
//// String auth = authKey + ":" + password;
//// String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8")));
////
//// // 创建HTTP客户端
//// CloseableHttpClient httpClient = HttpClients.createDefault();
//// HttpPost httpPost = new HttpPost(targetURL);
////
//// // 设置代理
//// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
////
//// // 设置代理认证
//// 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);
////
//// // 发送POST请求
//// CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
////
//// // 获取响应
//// HttpEntity responseEntity = httpResponse.getEntity();
//// String responseString = EntityUtils.toString(responseEntity);
//// System.out.println(responseString);
////
//// // 关闭连接
//// httpResponse.close();
//// httpClient.close();
//// }
////}
//
//public class Test {
// public static void main(String[] args) throws IOException {
// Map<String, String> map = senRequest("江苏省泰州市靖江市通江路37号", "1");
// System.out.println(map);
//
// }
//
// private static Map<String, String> 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")));
//
// CloseableHttpClient httpClient = HttpClients.createDefault();
// HttpPost httpPost = new HttpPost(targetURL);
// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
// 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<String, String> dataMap = new HashMap<String, String>();
//
// // 获取各个值并放入 Map
// dataMap.put("code", jsonObject.get("code").getAsString());
// dataMap.put("msg", jsonObject.get("msg").getAsString());
// JsonObject data = jsonObject.getAsJsonObject("data");
// 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("village", 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("villageCode", data.get("villageCode").getAsString());
// dataMap.put("areaCode", data.get("areaCode").getAsString());
// dataMap.put("farmer", data.get("farmer").getAsString());
// dataMap.put("isGovt", 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("devName",jsonObject1.get("indusParkName").getAsString());
// dataMap.put("devLevel",jsonObject1.get("indusParkLevel").getAsString());
// }
//
// httpResponse.close();
// return dataMap;
// } else {
// System.err.println("重试次数已用完,请求失败。");
// }
//
// httpClient.close();
// return null;
// }
//}
//
@@ -1,18 +1,15 @@
package com.fangjia.open.exceptionhander; 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 com.fangjia.core.util.DingDingMessageUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.ActionContext;
import org.sothis.web.mvc.ExceptionHandler; import org.sothis.web.mvc.ExceptionHandler;
import javax.servlet.ServletException;
import java.io.IOException;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.util.Enumeration; import java.util.Enumeration;
@@ -26,7 +23,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler {
ActionContext context = ActionContext.getContext(); ActionContext context = ActionContext.getContext();
String ip = getLocalHostIP(); String ip = getLocalHostIP();
String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4";
try { try {
DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!"); DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!");
} catch (Exception e1) { } catch (Exception e1) {
@@ -109,9 +109,9 @@ public class AuthenticationInterceptor implements Interceptor {
} }
} catch (Exception e) { } catch (Exception e) {
String ip = getLocalHostIP(); String ip = getLocalHostIP();
String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4";
try { try {
DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication error!"); DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication 错误!");
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
@@ -35,7 +35,7 @@ class DatabaseStatWatcherBatch extends BaseBatch {
def yesterday = DateUtil.add(today, -1) def yesterday = DateUtil.add(today, -1)
for(def host : hosts){ 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()){ for(def databaseName : mongo.getDatabaseNames()){
if(NOT_WATCH_DBS.contains(databaseName)){ if(NOT_WATCH_DBS.contains(databaseName)){
continue continue
@@ -2,6 +2,7 @@ package com.fangjia.script.averager
import com.fangjia.core.util.DataUtil import com.fangjia.core.util.DataUtil
import com.fangjia.core.util.DateUtil import com.fangjia.core.util.DateUtil
import com.fangjia.core.util.MongoUtils
import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DSCursor
import com.fangjia.datastore.driver.DataStore import com.fangjia.datastore.driver.DataStore
@@ -9,14 +10,11 @@ import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher import com.fangjia.script.Watcher
import com.fangjia.script.cover.EmailTemplate import com.fangjia.script.cover.EmailTemplate
import com.fangjia.script.jms.QueueRedirectConsumer
import com.fangjia.script.util.Jms import com.fangjia.script.util.Jms
import com.fangjia.script.util.MongoUtils
import com.fangjia.script.util.ServerAreaMap import com.fangjia.script.util.ServerAreaMap
import com.google.common.collect.MapDifference import com.google.common.collect.MapDifference
import com.google.common.collect.Maps import com.google.common.collect.Maps
import com.mongodb.* import com.mongodb.*
import org.bson.Document
import org.bson.types.ObjectId import org.bson.types.ObjectId
/** /**
@@ -29,10 +27,13 @@ class InsertMonitorCalcCommandBatch extends BaseBatch {
public static final DSCollection SEAWEED_COLL = new DataStore("seaweed.db.fangjia.com", 27007).getCollection("fangjia.seaweed") public static final DSCollection SEAWEED_COLL = new DataStore("seaweed.db.fangjia.com", 27007).getCollection("fangjia.seaweed")
public final static DBCollection REGION_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia').getCollection('region_block')
public final static DBCollection COMMAND_COLL = new Mongo("log.mongo.db.fangjia.com", 52002).getDB('fangjia_log').getCollection('calc_command') public final static DBCollection COMMAND_COLL = new Mongo("log.mongo.db.fangjia.com", 52002).getDB('fangjia_log').getCollection('calc_command')
public final static DBCollection REGION_STAT_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia').getCollection('region_stat') public final static DBCollection REGION_STAT_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_stat')
public final static DBCollection DISTRICT_STAT_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia_stat').getCollection('district_stat') public final static DBCollection DISTRICT_STAT_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia_stat', 'district_stat')
public final static DBCollection REGION_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_block')
public final static DBCollection DISTRICT_STAT_206_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.206",27020) public final static DBCollection DISTRICT_STAT_206_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.206",27020)
public final static def WORKER_MACHINE_IPS = ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1","fangjia-priceanalysis-2"] public final static def WORKER_MACHINE_IPS = ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1","fangjia-priceanalysis-2"]
@@ -231,7 +231,7 @@ class AutoAddOfficeBatch extends BaseBatch {
def index = 0 def index = 0
for (def c : citys) { for (def c : citys) {
index++ index++
if(index>4){ if(["宁波","无锡","青岛"].contains(c)){
continue continue
} }
def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"]) def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"])
@@ -239,8 +239,15 @@ class AutoAddOfficeBatch extends BaseBatch {
println c + " " + districts.size() println c + " " + districts.size()
allrets.addAll(rets) allrets.addAll(rets)
println "${index}"+ c +" 运A行完成 "+rets.size() 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) { def checkRepeatDistrictBatch(city,districts) {
@@ -40,10 +40,10 @@ import groovy.sql.Sql
@BatchOwner(Watcher.Hubingliang) @BatchOwner(Watcher.Hubingliang)
class IndividuateEvaAndRegisterTimeStatistical extends BaseBatch{ class IndividuateEvaAndRegisterTimeStatistical extends BaseBatch{
final static def mongoDomain = "mongo.db.fangjia.com" 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 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", 27017) 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) { static main(args) {
def s = System.currentTimeMillis() def s = System.currentTimeMillis()
@@ -64,8 +64,6 @@ class AutocompleteDataUpdaterBatch extends BaseBatch {
DSCursor cur = SEAWEED_COLL.find(q, fields).batchSize(2000) DSCursor cur = SEAWEED_COLL.find(q, fields).batchSize(2000)
Iterator<DBObject> iter = cur.iterator() Iterator<DBObject> iter = cur.iterator()
int i = 0 int i = 0
Map<String, String> keywordMap = new HashMap<String, String>()
while(iter.hasNext()) { while(iter.hasNext()) {
i++ i++
if(i % 100 == 0) { if(i % 100 == 0) {
@@ -16,7 +16,7 @@ import com.mongodb.DBCollection
class SeaweedReIndexBatch extends BaseBatch { 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) { static main(args) {
println "==================== start reIndex seaweed district " + DateUtils.formatToTightYYYYMMDDhhmmss(new Date()) + " ==============================" println "==================== start reIndex seaweed district " + DateUtils.formatToTightYYYYMMDDhhmmss(new Date()) + " =============================="
@@ -245,7 +245,7 @@ public class CommonUtils {
data.put("remark", 'week') data.put("remark", 'week')
data.put("c_date", new Date()) data.put("c_date", new Date())
if(isTest){ if(isTest){
data.put("ip", "192.168.0.231") data.put("ip", "192.168.10.29")
COMMAND_COLL.update(cmd, new BasicDBObject('$set', data), true, false) COMMAND_COLL.update(cmd, new BasicDBObject('$set', data), true, false)
}else{ }else{
data.put("ip", ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1"][new Random().nextInt(2)]) data.put("ip", ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1"][new Random().nextInt(2)])
@@ -4,6 +4,7 @@ import com.mongodb.BasicDBObject
import com.mongodb.DBCollection import com.mongodb.DBCollection
import com.mongodb.DBCursor import com.mongodb.DBCursor
import com.mongodb.DBObject import com.mongodb.DBObject
import com.fangjia.core.util.MongoUtils
/** /**
* Created by dxy on 2015/9/14. * Created by dxy on 2015/9/14.
@@ -43,7 +44,7 @@ public class ServerAreaMap {
} }
private static def findServerAreas(host, port, q, sq) { private static def findServerAreas(host, port, q, sq) {
DBCollection collection = MongoUtils.getCollectionByName("fangjia", "server_area", host, port); DBCollection collection = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, "fangjia", "server_area");
DBCursor cur = null; DBCursor cur = null;
if(q != null) { if(q != null) {
cur = collection.find(q) cur = collection.find(q)
@@ -1,14 +1,19 @@
package com.fangjia.script.wenyan package com.fangjia.script.wenyan
import com.fangjia.core.RegionData
import com.fangjia.script.util.ElasticUtils
def citys = ["北京", "唐山", "天津", "秦皇岛", "石家庄", "包头", "太原", "丹东", "呼和浩特", "锦州", "沈阳", "吉林", "大连", "牡丹江", "长春", "无锡", "哈尔滨", "扬州", "上海", "徐州", "南京", "温州", "杭州", "金华", "宁波", "蚌埠", "合肥", "安庆", "福州", "泉州", "厦门", "九江", "南昌", "赣州", "济南", "烟台", "青岛", "济宁", "郑州", "洛阳", "武汉", "平顶山", "长沙", "宜昌", "广州", "襄阳", "深圳", "岳阳", "南宁", "常德", "海口", "惠州", "重庆", "湛江", "成都", "韶关", "贵阳", "桂林", "昆明", "北海", "西安", "三亚", "兰州", "泸州", "西宁", "南充", "银川", "遵义", "乌鲁木齐", "大理", "北京", "上海", "广州", "深圳", "重庆", "郑州", "长沙", "西安", "成都", "东莞", "佛山", "杭州", "合肥", "南京", "青岛", "沈阳", "苏州", "天津", "武汉", "珠海", "中山", "长春", "扬州", "烟台", "徐州", "无锡", "温州", "太原", "台州", "石家庄", "绍兴", "厦门", "泉州", "宁波", "南通", "南宁", "南昌", "兰州", "常州", "大连", "福州", "贵阳", "哈尔滨", "海口", "惠州", "济南", "嘉兴", "金华", "昆明", "遵义", "淄博", "株洲", "镇江", "肇庆", "漳州", "湛江", "岳阳", "银川", "宜昌", "盐城", "芜湖", "乌鲁木齐", "唐山", "泰州", "汕头", "三亚", "清远", "秦皇岛", "马鞍山", "洛阳", "柳州", "连云港", "廊坊", "九江", "吉林", "淮安", "湖州", "呼和浩特", "沧州", "保定", "安庆", "张家口", "西宁", "日照", "拉萨", "锦州", "大同", "常德", "北海", "文昌", "陵水", "保亭"] import org.apache.commons.mail.SimpleEmail
citys.unique()
citys.each { def city -> import javax.mail.internet.MimeUtility
if (RegionData.isCity(city)) {
ElasticUtils.executeSqlQuery("select count(*) as count from seawater where p_date > 20210407 and city='${city}'", { EMAIL_SERVER = "smtp.exmail.qq.com"
println("$city\t${it.count}") SimpleEmail email = new SimpleEmail();
}) email.setSSL(true);
} email.setHostName(EMAIL_SERVER);
} email.setSslSmtpPort("465");
email.setCharset("GBK")
email.setAuthentication("service@fangjia.com", "iXWzdL69CnzxksaE");
email.addTo("wangwenyan@fangjia.com");
email.setFrom("service@fangjia.com", MimeUtility.encodeText("房价网大数据中心"), "utf-8");//发送方
email.setSubject("标题");
email.setContent("你好", "text/html");
email.send();
@@ -1,62 +1,11 @@
package com.fangjia.script.wenyan package com.fangjia.script.wenyan
import com.fangjia.core.util.DateUtil import com.fangjia.script.util.CommonUtils
import com.fangjia.core.util.Mongo3Utils
import com.fangjia.script.util.DbUtils import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.OpenApiClient
import com.mongodb.BasicDBObject
import com.mongodb.client.MongoCollection
import net.sf.json.JSONObject
import org.apache.http.NameValuePair
import org.apache.http.client.config.CookieSpecs
import org.apache.http.client.config.RequestConfig
import org.apache.http.client.methods.CloseableHttpResponse
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.utils.URLEncodedUtils
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
import org.apache.http.message.BasicNameValuePair
import org.apache.http.util.EntityUtils
import org.bson.Document
//com.mongodb.client.MongoCollection<Document> GUIDING_PRICE = Mongo3Utils.getDbCollection("fangjia", "guiding_price") ExcelUtils.read("C:\\Users\\goojia\\Downloads\\꼿제팀섬꿎桿친겼.xlsx",1).each {
// def one = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(it['B'], it['C'], it['D']))
//Mongo3Utils.getDbCollection("fangjia", "confirm_price_data").find(new BasicDBObject("isGuidancePrice", 0)).each { Document doc-> println("${one.lng/10000000000},${one.lat/10000000000}")
// Document item = new Document()
// item.put("guiding_type", 0)
// item.put("city", doc.city)
// item.put("region", doc.region)
// item.put("name", doc.district_name)
// item.put("guiding_person", doc.user_name)
// item.put("category", "district")
// item.put("guiding_value", doc.price)
// item.put("guiding_date", doc.c_date)
// item.put("house_type", 0)
// item.put("estate_type", DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(doc.city, doc.region, doc.district_name))?.estate_type2)
// item.put("c_date", new Date())
// GUIDING_PRICE.insertOne(item)
// println(item)
//}
def keys = []
ExcelUtils.read("D:\\Users\\wenyan\\Desktop\\ͶƱ½á¹ûÃ÷ϸ(1).xlsx").each {List item->
keys << "${item['A']}_${item['B']}_${item["C"]}".toString()
println(item)
}
MongoCollection<Document> FANGJIA_STAT = Mongo3Utils.getDbCollection("fangjia_stat", "district_stat")
def creditMap = [:]
FANGJIA_STAT.find(new Document("weekend", DateUtil.parseDate("20200322", "yyyyMMdd"))).each {Document d->
def key ="${d.city}_${d.region}_${d.district_name}".toString()
if(!keys.contains(key)){
Double credit = (int)(d.credit * 10)
creditMap[credit] = creditMap.get(credit, 0) + 1
}
}
creditMap.each {def key, value->
println("${key}\t${value}")
} }
@@ -1,25 +1,24 @@
package com.fangjia.service.api; package com.fangjia.service.api;
import java.util.ArrayList; import com.fangjia.core.util.*;
import java.util.Collections; import com.fangjia.dal.mongo.open.model.WaitCrawlKeywords;
import java.util.Comparator; import com.fangjia.service.address.AddressParserService;
import java.util.HashMap; import com.fangjia.service.address.AddressParserUtil;
import java.util.List; import com.fangjia.service.address.mode.*;
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.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.CheckMatchDistrictCorrectParam;
import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchAddressScore;
import com.fangjia.service.bo.MatchDistrictResult; 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;
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. * Created by wenyan on 2016/1/15.
@@ -28,17 +27,143 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
public static final int MIN_TIMEOUT = 1000 * 2; public static final int MIN_TIMEOUT = 1000 * 2;
private final static String TOKEN = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; 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); super(apiHost);
} }
private String realMatch(Map<String, Object> 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") && paramsMap.get("city") != null) {
params.setCity(paramsMap.get("city").toString());
}
if (paramsMap.containsKey("suggestDistrict") && paramsMap.get("suggestDistrict") != null) {
params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString());
}
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") && paramsMap.get("province") != null) {
params.setProvince(paramsMap.get("province").toString());
}
if (paramsMap.containsKey("useMap") && paramsMap.get("useMap") != null) {
params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true);
}
if (paramsMap.containsKey("debugName") && paramsMap.get("debugName") != null) {
params.setDebugName(paramsMap.get("debugName").toString());
}
if (paramsMap.containsKey("propertyType") && paramsMap.get("propertyType") != null) {
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 baseModel = new JSONObject();
Map<String, Object> 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 baseModel.toString();
}
public String realMatchAll(Map<String, Object> 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<Building> buildings = addressParseResult.getBuildings();
List<Map<String, Object>> buildingObjs = new ArrayList<Map<String, Object>>(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 @Override
public String parser(Map<String, Object> params) { public String parser(Map<String, Object> params) {
params.put("token", TOKEN); params.put("token", TOKEN);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
try { try {
String result = this.invoke("address/realMatch", params, "UTF-8"); String result = realMatch(params);
return result; return result;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.error("", e); LOGGER.error("", e);
@@ -54,7 +179,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
public String parserAll(Map<String, Object> params) { public String parserAll(Map<String, Object> params) {
params.put("token", TOKEN); params.put("token", TOKEN);
try { try {
String result = this.invoke("address/realMatchAll", params, "UTF-8"); String result = realMatchAll(params);
return result; return result;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.error("", e); LOGGER.error("", e);
@@ -62,11 +187,25 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
return null; return null;
} }
public String cleanCache(final Map<String, Object> 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 @Override
public String cacheFlush(Map<String, Object> params){ public String cacheFlush(Map<String, Object> params){
params.put("token", TOKEN); params.put("token", TOKEN);
try { try {
String result = this.invoke("address/cleanCache", params, "UTF-8"); String result = cleanCache(params);
return result; return result;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.error("", e); LOGGER.error("", e);
@@ -74,11 +213,85 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
return null; return null;
} }
public String realStandard(Map<String, Object> 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 @Override
public String standard(Map<String, Object> params) { public String standard(Map<String, Object> params) {
params.put("token", TOKEN); params.put("token", TOKEN);
try { try {
String result = this.invoke("address/realStandard", params, "UTF-8"); String result = realStandard(params);
return result; return result;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.error("", e); LOGGER.error("", e);
@@ -86,6 +299,48 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
return null; return null;
} }
public String realCertificateAction(Map<String, Object> 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 @Override
public String certificate(Map<String, Object> params) { public String certificate(Map<String, Object> params) {
params.put("token", TOKEN); params.put("token", TOKEN);
@@ -98,11 +353,75 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
return null; return null;
} }
public String realAuth(Map<String, Object> 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<String> 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 @Override
public String auth(Map<String, Object> params) { public String auth(Map<String, Object> params) {
params.put("token", TOKEN); params.put("token", TOKEN);
try { try {
String result = this.invoke("address/realAuth", params, "UTF-8"); String result = realAuth(params);
return result; return result;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.error("", e); LOGGER.error("", e);
@@ -430,4 +749,140 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
} }
Map<String, Object> convertBuildingToMap(Building building) {
Map<String, Object> result = new LinkedHashMap<String, Object>();
if (building != null) {
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());
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());
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());
}
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;
}
private void submitFetchTask(Building building) {
if (building.getPrecise() == -1) {
List<String> keywords = new ArrayList<String>();
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;
}
} }
@@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.ShopRentStat; import com.fangjia.dal.mongo.model.ShopRentStat;
import com.fangjia.dal.mongo.model.ShopSellStat; import com.fangjia.dal.mongo.model.ShopSellStat;
import com.fangjia.dal.seawater.model.Seawater; 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.datastore.dto.ShopEvaluationDto;
import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.mongo.fangjia.SeawaterService;
import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.GeoUtils;
@@ -204,53 +205,24 @@ public class AiShopServiceImpl implements AiShopService {
return getShopEvaluationDto(seawaters, evaluation, cat); return getShopEvaluationDto(seawaters, evaluation, cat);
} }
/** private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) {
* 基准价*楼层系数*装修系数*朝向系数 SeawaterDto seawaterDto = new SeawaterDto();
* seawaterDto.setCity(seawater.getCity());
* @param seawaters seawaterDto.setDistrict(seawater.getRegion());
* @param evaluation seawaterDto.setName(seawater.getName());
* @return seawaterDto.setArea(seawater.getArea());
*/ seawaterDto.setFitment(seawater.getFitment());
private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List<Seawater> seawaters, Evaluation evaluation) { if (cat != null && cat.contains("rent")) {
Double sum = 0.0; seawaterDto.setUnitPrice(seawater.getDayUnitPrice());
Double size = 0.0; } else {
seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue());
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(); seawaterDto.setEstateType(seawater.getEstateType());
if (size > 0) { seawaterDto.setBedKind(seawater.getLevel());
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); seawaterDto.setPublishDate(String.valueOf(seawater.getpDate()));
shopEvaluationDto.setUnitPrice(unitPrice); seawaterDto.setFloorInfo(seawater.getFloorInfo());
shopEvaluationDto.setSeawater(seawaters); seawaterDto.setAddress(seawater.getAddress());
shopEvaluationDto.setCity(evaluation.getCity()); return seawaterDto;
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
}
return shopEvaluationDto;
} }
/** /**
@@ -266,17 +238,20 @@ public class AiShopServiceImpl implements AiShopService {
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
List<SeawaterDto> seawaterList = new ArrayList<SeawaterDto>();
if ("shop_rent".equals(cat)) { if ("shop_rent".equals(cat)) {
for (Seawater seawater : seawaters) { for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
sum += seawater.getTotalPrice(); sum += seawater.getTotalPrice();
size += seawater.getArea(); size += seawater.getArea();
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
seawaterList.add(seawaterDto);
} }
if (size > 0) { if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
shopEvaluationDto.setUnitPrice(unitPrice); shopEvaluationDto.setUnitPrice(unitPrice);
shopEvaluationDto.setSeawater(seawaters); shopEvaluationDto.setSeawater(seawaterList);
shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName()); shopEvaluationDto.setName(evaluation.getDistrictName());
@@ -287,11 +262,13 @@ public class AiShopServiceImpl implements AiShopService {
sum += seawater.getTotalPrice(); sum += seawater.getTotalPrice();
size += seawater.getArea(); size += seawater.getArea();
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
seawaterList.add(seawaterDto);
} }
if (size > 0) { if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size, 2); Double unitPrice = DataUtil.roundDouble(sum / size, 2);
shopEvaluationDto.setUnitPrice(unitPrice); shopEvaluationDto.setUnitPrice(unitPrice);
shopEvaluationDto.setSeawater(seawaters); shopEvaluationDto.setSeawater(seawaterList);
shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName()); shopEvaluationDto.setName(evaluation.getDistrictName());
@@ -351,15 +328,18 @@ public class AiShopServiceImpl implements AiShopService {
query.setPager(pager); query.setPager(pager);
query.setTable("latest_seawater"); query.setTable("latest_seawater");
List<Seawater> shops = seawaterService.findSeawatersByQuery(query); List<Seawater> shops = seawaterService.findSeawatersByQuery(query);
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
if (CollectionUtils.isNotEmpty(shops)) { if (CollectionUtils.isNotEmpty(shops)) {
// 求均值 // 求均值
Double totalPrice = 0D; Double totalPrice = 0D;
int count = 0; int count = 0;
for (Seawater seawater : shops) { for (Seawater seawater : shops) {
if (seawater.getAvgPrice() != null) { if (seawater.getAvgPrice() != null) {
totalPrice += seawater.getAvgPrice(); totalPrice += seawater.getDayUnitPrice();
count += 1; count += 1;
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_rent");
seawaterDtoList.add(seawaterDto);
} }
Double factor = 1.0; Double factor = 1.0;
if (evaluation.getFitment() != null) { if (evaluation.getFitment() != null) {
@@ -370,7 +350,7 @@ public class AiShopServiceImpl implements AiShopService {
} }
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
shopEvaluationDto.setUnitPrice(avgPrice); shopEvaluationDto.setUnitPrice(avgPrice);
shopEvaluationDto.setSeawater(shops); shopEvaluationDto.setSeawater(seawaterDtoList);
shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName()); shopEvaluationDto.setName(evaluation.getDistrictName());
@@ -401,6 +381,8 @@ public class AiShopServiceImpl implements AiShopService {
query.setPager(pager); query.setPager(pager);
query.setTable("latest_seawater"); query.setTable("latest_seawater");
List<Seawater> shops = seawaterService.findSeawatersByQuery(query); List<Seawater> shops = seawaterService.findSeawatersByQuery(query);
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
if (CollectionUtils.isNotEmpty(shops)) { if (CollectionUtils.isNotEmpty(shops)) {
// 求均值 // 求均值
Double totalPrice = 0D; Double totalPrice = 0D;
@@ -410,6 +392,8 @@ public class AiShopServiceImpl implements AiShopService {
totalPrice += seawater.getAvgPrice(); totalPrice += seawater.getAvgPrice();
count += 1; count += 1;
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_sell");
seawaterDtoList.add(seawaterDto);
} }
Double factor = 1.0; Double factor = 1.0;
if (evaluation.getFitment() != null) { if (evaluation.getFitment() != null) {
@@ -420,7 +404,7 @@ public class AiShopServiceImpl implements AiShopService {
} }
int avgPrice = (int) (totalPrice / count * factor); int avgPrice = (int) (totalPrice / count * factor);
shopEvaluationDto.setUnitPrice((double) avgPrice); shopEvaluationDto.setUnitPrice((double) avgPrice);
shopEvaluationDto.setSeawater(shops); shopEvaluationDto.setSeawater(seawaterDtoList);
shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName()); shopEvaluationDto.setName(evaluation.getDistrictName());
@@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.mongo.model.OfficeRentStat;
import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.mongo.model.OfficeSellStat;
import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.dal.seawater.model.SeawaterDto;
import com.fangjia.dal.seaweed.model.District; import com.fangjia.dal.seaweed.model.District;
import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.mongo.fangjia.SeawaterService;
@@ -366,6 +367,7 @@ public class OfficeServiceImpl implements OfficeService {
String fitment = FITMENT_MAP.get(evaluation.getFitment()); String fitment = FITMENT_MAP.get(evaluation.getFitment());
String direction = DIRECTION_MAP.get(evaluation.getDirection()); String direction = DIRECTION_MAP.get(evaluation.getDirection());
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
for (Seawater seawater : seawaters) { for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { 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()); Double price = Double.valueOf(seawater.getTotalPrice());
@@ -403,12 +405,14 @@ public class OfficeServiceImpl implements OfficeService {
sum += price; sum += price;
size += seawater.getArea(); size += seawater.getArea();
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, null);
seawaterDtoList.add(seawaterDto);
} }
OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto();
if (size > 0) { if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
officeEvaluationDto.setUnitPrice(unitPrice); officeEvaluationDto.setUnitPrice(unitPrice);
officeEvaluationDto.setSeawater(seawaters); officeEvaluationDto.setSeawater(seawaterDtoList);
officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setCity(evaluation.getCity());
officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setDistrict(evaluation.getRegion());
officeEvaluationDto.setName(evaluation.getDistrictName()); officeEvaluationDto.setName(evaluation.getDistrictName());
@@ -429,17 +433,20 @@ public class OfficeServiceImpl implements OfficeService {
OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto();
List<SeawaterDto> seawaterList = new ArrayList<SeawaterDto>();
if ("office_rent".equals(cat)) { if ("office_rent".equals(cat)) {
for (Seawater seawater : seawaters) { for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
sum += seawater.getTotalPrice(); sum += seawater.getTotalPrice();
size += seawater.getArea(); size += seawater.getArea();
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
seawaterList.add(seawaterDto);
} }
if (size > 0) { if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
officeEvaluationDto.setUnitPrice(unitPrice); officeEvaluationDto.setUnitPrice(unitPrice);
officeEvaluationDto.setSeawater(seawaters); officeEvaluationDto.setSeawater(seawaterList);
officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setCity(evaluation.getCity());
officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setDistrict(evaluation.getRegion());
officeEvaluationDto.setName(evaluation.getDistrictName()); officeEvaluationDto.setName(evaluation.getDistrictName());
@@ -450,11 +457,13 @@ public class OfficeServiceImpl implements OfficeService {
sum += seawater.getTotalPrice(); sum += seawater.getTotalPrice();
size += seawater.getArea(); size += seawater.getArea();
} }
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
seawaterList.add(seawaterDto);
} }
if (size > 0) { if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size, 2); Double unitPrice = DataUtil.roundDouble(sum / size, 0);
officeEvaluationDto.setUnitPrice(unitPrice); officeEvaluationDto.setUnitPrice(unitPrice);
officeEvaluationDto.setSeawater(seawaters); officeEvaluationDto.setSeawater(seawaterList);
officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setCity(evaluation.getCity());
officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setDistrict(evaluation.getRegion());
officeEvaluationDto.setName(evaluation.getDistrictName()); officeEvaluationDto.setName(evaluation.getDistrictName());
@@ -464,6 +473,25 @@ public class OfficeServiceImpl implements OfficeService {
return officeEvaluationDto; 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 @Override
public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) {
@@ -514,6 +542,7 @@ public class OfficeServiceImpl implements OfficeService {
sortParams.add(new SortParam("date", false)); sortParams.add(new SortParam("date", false));
List<OfficeRentStat> infos = officeRentStatDao.findAllByParams(params, sortParams, 5); List<OfficeRentStat> infos = officeRentStatDao.findAllByParams(params, sortParams, 5);
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
if (CollectionUtils.isEmpty(infos)) { if (CollectionUtils.isEmpty(infos)) {
// 去掉类型,重新查找 // 去掉类型,重新查找
params = new ArrayList<QueryParam>(5); params = new ArrayList<QueryParam>(5);
@@ -531,6 +560,15 @@ public class OfficeServiceImpl implements OfficeService {
totalPrice += officeRentStat.getAvgPrice(); totalPrice += officeRentStat.getAvgPrice();
count += 1; 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; Double factor = 1.0;
if (evaluation.getFitment() != null) { if (evaluation.getFitment() != null) {
@@ -544,7 +582,7 @@ public class OfficeServiceImpl implements OfficeService {
} }
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
officeEvaluationDto.setUnitPrice(avgPrice); officeEvaluationDto.setUnitPrice(avgPrice);
officeEvaluationDto.setOffice(infos); officeEvaluationDto.setSeawater(seawaterDtoList);
officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setCity(evaluation.getCity());
officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setDistrict(evaluation.getRegion());
officeEvaluationDto.setName(evaluation.getDistrictName()); officeEvaluationDto.setName(evaluation.getDistrictName());
@@ -593,6 +631,7 @@ public class OfficeServiceImpl implements OfficeService {
params.add(new QueryParam("date", Integer.parseInt(date))); params.add(new QueryParam("date", Integer.parseInt(date)));
infos = officeSellStatDao.findAllByParams(params, sortParams); infos = officeSellStatDao.findAllByParams(params, sortParams);
} }
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
if (CollectionUtils.isNotEmpty(infos)) { if (CollectionUtils.isNotEmpty(infos)) {
// 求均值 // 求均值
Double totalPrice = 0D; Double totalPrice = 0D;
@@ -602,6 +641,15 @@ public class OfficeServiceImpl implements OfficeService {
totalPrice += officeSellStat.getAvgPrice(); totalPrice += officeSellStat.getAvgPrice();
count += 1; 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; Double factor = 1.0;
if (evaluation.getFitment() != null) { if (evaluation.getFitment() != null) {
@@ -613,9 +661,9 @@ public class OfficeServiceImpl implements OfficeService {
if (evaluation.getDirection() != null) { if (evaluation.getDirection() != null) {
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); 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.setUnitPrice(avgPrice);
officeEvaluationDto.setOfficeSell(infos); officeEvaluationDto.setSeawater(seawaterDtoList);
officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setCity(evaluation.getCity());
officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setDistrict(evaluation.getRegion());
officeEvaluationDto.setName(evaluation.getDistrictName()); officeEvaluationDto.setName(evaluation.getDistrictName());
@@ -1,9 +1,7 @@
package com.fangjia.service.datastore.dto; package com.fangjia.service.datastore.dto;
import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seawater.model.SeawaterDto;
import com.fangjia.dal.mongo.model.OfficeSellStat;
import com.fangjia.dal.seawater.model.Seawater;
import java.util.List; import java.util.List;
@@ -15,17 +13,12 @@ public class OfficeEvaluationDto extends Evaluation {
private Double unitPrice; private Double unitPrice;
private List<Seawater> seawater; private List<SeawaterDto> seawater;
private List<OfficeRentStat> office;
private List<OfficeSellStat> officeSell;
private String district; private String district;
private String name; private String name;
public Double getUnitPrice() { public Double getUnitPrice() {
return unitPrice; return unitPrice;
} }
@@ -34,11 +27,11 @@ public class OfficeEvaluationDto extends Evaluation {
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
} }
public List<Seawater> getSeawater() { public List<SeawaterDto> getSeawater() {
return seawater; return seawater;
} }
public void setSeawater(List<Seawater> seawater) { public void setSeawater(List<SeawaterDto> seawater) {
this.seawater = seawater; this.seawater = seawater;
} }
@@ -57,20 +50,4 @@ public class OfficeEvaluationDto extends Evaluation {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public List<OfficeRentStat> getOffice() {
return office;
}
public void setOffice(List<OfficeRentStat> office) {
this.office = office;
}
public List<OfficeSellStat> getOfficeSell() {
return officeSell;
}
public void setOfficeSell(List<OfficeSellStat> officeSell) {
this.officeSell = officeSell;
}
} }
@@ -1,7 +1,7 @@
package com.fangjia.service.datastore.dto; package com.fangjia.service.datastore.dto;
import com.fangjia.dal.mongo.model.Evaluation; 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; import java.util.List;
@@ -13,7 +13,7 @@ public class ShopEvaluationDto extends Evaluation {
private Double unitPrice; private Double unitPrice;
private List<Seawater> seawater; private List<SeawaterDto> seawater;
private String district; private String district;
@@ -28,11 +28,11 @@ public class ShopEvaluationDto extends Evaluation {
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
} }
public List<Seawater> getSeawater() { public List<SeawaterDto> getSeawater() {
return seawater; return seawater;
} }
public void setSeawater(List<Seawater> seawater) { public void setSeawater(List<SeawaterDto> seawater) {
this.seawater = seawater; this.seawater = seawater;
} }
@@ -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;
}
}