diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 795b2c552..1fa130129 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -5,7 +5,9 @@
"Bash(pandoc:*)",
"Bash(python ooxml/scripts/unpack.py:*)",
"Bash(npm install:*)",
- "Bash(node generate_doc.js:*)"
+ "Bash(node generate_doc.js:*)",
+ "Bash(xargs grep:*)",
+ "Bash(node:*)"
]
}
}
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/opentest/EfundInterfaceTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/opentest/EfundInterfaceTest.groovy
index 538b1cd1e..a538bed6c 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/opentest/EfundInterfaceTest.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/opentest/EfundInterfaceTest.groovy
@@ -45,7 +45,7 @@ try {
// 3. 修改表头,添加结果列
allData[0] = ["序号", "城市", "地址", "返回城市", "返回区域", "返回街道","返回道路","返回门牌号",
"小区名称", "物业类型", "匹配级别", "匹配置信度",
- "参考价格", "典型总价", "更新时间", "耗时(ms)", "异常信息"]
+ "参考价格", "典型总价", "更新时间", "耗时(ms)", "异常信息", "周边一公里住宅均价"]
// 4. 为每一行数据添加空的结果列
for (int i = 1; i < allData.size(); i++) {
@@ -103,6 +103,7 @@ try {
row[14] = result.optString("update_time", "")
row[15] = duration
row[16] = "" // 无异常
+ row[17] = result.optString("typical_total_price", "")
} else {
// 接口返回异常
row[15] = duration
diff --git a/projects/fangjia-service/pom.xml b/projects/fangjia-service/pom.xml
index 1b688ac2d..b1f53895d 100644
--- a/projects/fangjia-service/pom.xml
+++ b/projects/fangjia-service/pom.xml
@@ -239,5 +239,10 @@
kafka_2.13
3.4.0
+
+ com.aliyun
+ aliyun-java-sdk-address-purification
+ 1.0.1
+
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 27089094c..f249b5ba0 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
@@ -1858,6 +1858,7 @@ public class DistrictStatServiceImpl implements DistrictStatService {
if (StringUtils.isNotBlank(name)) {
params.add(new QueryParam("districtName", name));
}
+ params.add(new QueryParam("estateType", QueryParam.IN_OPERATOR, Arrays.asList("小区", "别墅")));
if (null != weekend) {
params.add(new QueryParam("weekend", DateUtil.getThisSunday(weekend)));
}
diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/efund/EfundMatchServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/efund/EfundMatchServiceImpl.java
index 62a489d63..031487c08 100644
--- a/projects/fangjia-service/src/main/java/com/fangjia/service/efund/EfundMatchServiceImpl.java
+++ b/projects/fangjia-service/src/main/java/com/fangjia/service/efund/EfundMatchServiceImpl.java
@@ -1,12 +1,22 @@
package com.fangjia.service.efund;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.address_purification.model.v20191118.GetAddressGeocodeRequest;
+import com.aliyuncs.address_purification.model.v20191118.GetAddressGeocodeResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.profile.DefaultProfile;
import com.fangjia.core.ProvinceData;
import com.fangjia.core.RegionData;
import com.fangjia.core.util.DateUtil;
import com.fangjia.core.util.HttpRequest;
import com.fangjia.core.util.HttpRequestException;
+import com.fangjia.dal.QueryParam;
+import com.fangjia.dal.SortParam;
import com.fangjia.dal.common.DistrictKey;
+import com.fangjia.dal.mongo.dao.office.OfficeSellStatDao;
import com.fangjia.dal.mongo.model.DistrictStat;
+import com.fangjia.dal.mongo.model.OfficeSellStat;
import com.fangjia.dal.mongo.model.RegionSellStat;
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
import com.fangjia.dal.seaweed.model.District;
@@ -18,13 +28,9 @@ import com.fangjia.service.mongo.fangjia.DealPriceService;
import com.fangjia.service.mongo.fangjia.RegionSellStatService;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
-
-import java.math.BigDecimal;
+import org.apache.log4j.Logger;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* E基金地址匹配服务实现
@@ -32,11 +38,16 @@ import java.util.Map;
*/
public class EfundMatchServiceImpl implements EfundMatchService {
+ private static final Logger logger = Logger.getLogger(EfundMatchServiceImpl.class);
private AddressMatchProxyService addressMatchProxyService;
private DistrictStatService districtStatService;
private DealPriceService dealPriceService;
private DistrictService districtService;
private RegionSellStatService regionSellStatService;
+ private OfficeSellStatDao officeSellStatDao;
+
+ private static final DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAIdaj4eSO79gzz", "xw6EsvqydZ9HC6zAvIB3ruQqVHynxf");
+ private static final IAcsClient client = new DefaultAcsClient(profile);
@Override
public UniversalDto matchAddress(String address, String city) {
@@ -92,7 +103,7 @@ public class EfundMatchServiceImpl implements EfundMatchService {
result.append("property_type", "住宅");
result.append("match_level", "小区级");
// 查询小区房价和数据更新时间
- DistrictStat latestStat = districtStatService.findOneDistrictStatsSort(districtCity, districtRegion, districtName, null);
+ DistrictStat latestStat = districtStatService.findOneDistrictStatsSort(districtCity, districtRegion, districtName, DateUtil.getFirstDayOfWeek(new Date()));
if (latestStat != null) {
// 优先使用avg_price_2b,如果为空再使用avgPrice
Integer avgPrice = null;
@@ -120,16 +131,18 @@ public class EfundMatchServiceImpl implements EfundMatchService {
}
}
}else if(district != null && district.getCategory().equals("office")){
- // 写字楼,不输出房价
+ // 写字楼,查询最新月份单价
result.append("property_type", "写字楼");
result.append("match_level", "建筑级");
- }else {
- result.append("match_level", "建筑级");
- result.append("property_type", category);
- if(category.contains("住宅")){
- result.append("match_level", "小区级");
- result.append("property_type", "住宅");
- String location = matchResult.getString("lng") + "," + matchResult.getString("lat");
+ OfficeSellStat officeStat = findLatestOfficeSellStat(district.getCity(),district.getRegion(), district.getName());
+ if (officeStat != null && officeStat.getAvgPrice() != null && officeStat.getAvgPrice() > 0) {
+ result.append("reference_price", officeStat.getAvgPrice());
+ if (officeStat.getDate() != null) {
+ result.append("update_time", DateUtil.formatByPattern(DateUtil.parseDate(officeStat.getDate().toString(), "yyyyMM"), "yyyy-MM-dd"));
+ }
+ }
+ if(!result.containsKey("reference_price")){
+ String location = district.getLng()/100000000000.0 + "," + district.getLat()/100000000000.0;
HttpRequest httpRequest = new HttpRequest();
JSONObject json = null;
Map param = new HashMap();
@@ -138,17 +151,74 @@ public class EfundMatchServiceImpl implements EfundMatchService {
try {
json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
- result.put("reference_price", json.getInt("unitPrice"));
+ result.put("residential 1km _price", json.getInt("unitPrice"));
result.append("update_time", DateUtil.formatByPattern(DateUtil.getFirstDayOfWeek(new Date()), "yyyy-MM-dd"));
}
} catch (HttpRequestException e) {
throw new RuntimeException(e);
}
}
+
+ }else {
+ result.append("match_level", "建筑级");
+ result.append("property_type", category);
+ String location = matchResult.getString("lng") + "," + matchResult.getString("lat");
+ HttpRequest httpRequest = new HttpRequest();
+ JSONObject json = null;
+ Map param = new HashMap();
+ param.put("location", location);
+ param.put("area", "100");
+ try {
+ json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
+ if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
+ result.put("residential_1km_price", json.getInt("unitPrice"));
+ result.append("update_time", DateUtil.formatByPattern(DateUtil.getFirstDayOfWeek(new Date()), "yyyy-MM-dd"));
+ }
+ } catch (HttpRequestException e) {
+ throw new RuntimeException(e);
+ }
+ if(category.contains("住宅")){
+ result.append("match_level", "小区级");
+ result.append("property_type", "住宅");
+ if(result.containsKey("residential_1km_price")){
+ result.put("reference_price", result.get("residential_1km_price"));
+ result.remove("residential_1km_price");
+ }
+ }
}
return result;
}
+ /**
+ * 获取经纬度工具类
+ * {
+ * "wgs84":"120.02099798073618,30.281364166381348",
+ * "level":"roadno",
+ * "gcj02":"120.025746,30.278984"
+ * }
+ * @param city 城市
+ * @param address 地址
+ * @return
+ */
+ public static com.alibaba.fastjson.JSONObject getAddressGeocode(String city, String address) {
+ GetAddressGeocodeRequest request = new GetAddressGeocodeRequest();
+ request.setAppKey("68czunztrb1o");
+ request.setServiceCode("addrp");
+ request.setText(address);
+ request.setDefaultCity(city);
+ GetAddressGeocodeResponse response = null;
+ try {
+ response = client.getAcsResponse(request);
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response.getData());
+ if(jsonObject.containsKey("offline_geocode")){
+ return jsonObject.getJSONObject("offline_geocode");
+ }
+ } catch (ClientException e) {
+ logger.error("通用经纬度查询异常:", e);
+ }
+ return null;
+ }
+
/**
* 查找典型总价:成交单价最接近参考均价的成交记录的总价
* @param districtKey 小区Key
@@ -261,23 +331,22 @@ public class EfundMatchServiceImpl implements EfundMatchService {
}else if(StringUtils.isNotBlank(structCity)){
result.append("match_level", "城市级");
}
- // 格式化城市和区域为简称
- String formattedCity = RegionData.formatCity(structCity);
- String formattedRegion = RegionData.formatRegion(formattedCity, structDistrict);
-
- // 查询区域价格
- if (StringUtils.isNotBlank(formattedCity) && StringUtils.isNotBlank(formattedRegion)) {
- RegionSellStat regionSellStat = regionSellStatService.findNewestRegionPrice(formattedCity, formattedRegion);
- if (regionSellStat != null && regionSellStat.getAvgPrice() != null && regionSellStat.getAvgPrice() > 0) {
- result.append("reference_price", regionSellStat.getAvgPrice());
-
- // 数据更新时间
- if (regionSellStat.getUpdateDate() != null) {
- result.append("update_time", DateUtil.formatByPattern(DateUtil.parseDate(regionSellStat.getDate().toString(),"yyyyMM"), "yyyy-MM-dd"));
+ com.alibaba.fastjson.JSONObject json = getAddressGeocode(city, address);
+ if(json != null && json.containsKey("gcj02")){
+ HttpRequest httpRequest = new HttpRequest();
+ Map param = new HashMap();
+ param.put("location", json.getString("gcj02"));
+ param.put("area", "100");
+ try {
+ JSONObject avmJson = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
+ if (avmJson.containsKey("msg") && "成功".equals(avmJson.getString("msg"))) {
+ result.put("residential_1km_price", avmJson.getInt("unitPrice"));
+ result.append("update_time", DateUtil.formatByPattern(DateUtil.getFirstDayOfWeek(new Date()), "yyyy-MM-dd"));
}
+ } catch (HttpRequestException e) {
+ throw new RuntimeException(e);
}
}
-
return result;
} catch (Exception e) {
@@ -305,4 +374,36 @@ public class EfundMatchServiceImpl implements EfundMatchService {
public void setRegionSellStatService(RegionSellStatService regionSellStatService) {
this.regionSellStatService = regionSellStatService;
}
+
+ public void setOfficeSellStatDao(OfficeSellStatDao officeSellStatDao) {
+ this.officeSellStatDao = officeSellStatDao;
+ }
+
+ /**
+ * 查询写字楼最新月份的统计单价
+ * @param city 城市
+ * @param district 区域
+ * @param name 写字楼名称
+ * @return 最新月份的OfficeSellStat,未找到时返回null
+ */
+ private OfficeSellStat findLatestOfficeSellStat(String city, String district, String name) {
+ if (officeSellStatDao == null || StringUtils.isBlank(city) || StringUtils.isBlank(name)) {
+ return null;
+ }
+ try {
+ List params = new ArrayList();
+ params.add(new QueryParam("city", city));
+ params.add(new QueryParam("district", district));
+ params.add(new QueryParam("name", name));
+ List sortParams = new ArrayList();
+ sortParams.add(new SortParam("date", false));
+ List stats = officeSellStatDao.findAllByParams(params, sortParams, 1);
+ if (stats != null && !stats.isEmpty()) {
+ return stats.get(0);
+ }
+ } catch (Exception e) {
+ // 查询失败不影响主流程
+ }
+ return null;
+ }
}