From 0b9aa8bed093510da28232658e45d169a7f7a46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 2 Apr 2025 13:39:31 +0800 Subject: [PATCH 001/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=98=89=E7=A7=AF=E9=95=87=E9=A1=BA?= =?UTF-8?q?=E6=B3=BD=E7=BF=A0=E5=B1=8F=E6=B9=BE22=E5=B9=A21=E5=8D=95?= =?UTF-8?q?=E5=85=831203=E6=88=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 40afe3fe6..d455751e1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -1,9 +1,8 @@ package com.fangjia.open.controllers; import com.fangjia.core.util.*; -import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.common.DistrictKey; -import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.mongo.model.ApiUserCfg; import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.Evaluation; @@ -17,7 +16,10 @@ import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.*; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.HouseInfomationModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.CommonUtils; import com.fangjia.open.ws.query.SampleQuery; @@ -26,13 +28,20 @@ import com.fangjia.service.api.ApiUserCfgService; import com.fangjia.service.bo.Collateral; import com.fangjia.service.bo.DistrictStatBo; import com.fangjia.service.bo.Sample; -import com.fangjia.service.datastore.*; +import com.fangjia.service.datastore.CzbankSampleService; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.datastore.OpenApiLogService; import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; -import com.fangjia.service.district.*; +import com.fangjia.service.district.DistrictFacilitysService; +import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.mongo.bkoff.LoudongService; import com.fangjia.service.mongo.fangjia.*; -import com.fangjia.service.open.*; +import com.fangjia.service.open.ApiUserAuthorityService; +import com.fangjia.service.open.EvaluateFactorService; +import com.fangjia.service.open.EvaluateRatioService; +import com.fangjia.service.open.FangjiaOfficialAreaService; import com.fangjia.service.web.AddressService; import net.sf.json.JSONObject; import org.apache.commons.lang.ArrayUtils; @@ -248,7 +257,7 @@ public class ComprehensiveQueryController { communityAvgPriceParams.put("category", "district"); communityAvgPriceParams.put("useMap", "true"); communityAvgPriceParams.put("suggestName", String.valueOf(model.getName())); - communityAvgPriceParams.put("preciseLevel", "strict"); +// communityAvgPriceParams.put("preciseLevel", "strict"); communityAvgPriceParams.put("propertyType", model.getPropertyType()); communityAvgPriceParams.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"); JSONObject matchResponse = null; From f76d5cce48317ef3d7c3b243742c4e4beb81e0ec Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 2 Apr 2025 15:20:11 +0800 Subject: [PATCH 002/121] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E8=A1=8C?= =?UTF-8?q?=E6=94=BF=E5=8C=BA=E5=88=92=E6=94=B9=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 47 ++++++++++++------- .../open/AdministrativeMappingService.java | 8 +++- .../AdministrativeMappingServiceImpl.java | 42 +++++++++++++++-- 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index d455751e1..f2037adbc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -38,10 +38,7 @@ import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.mongo.bkoff.LoudongService; import com.fangjia.service.mongo.fangjia.*; -import com.fangjia.service.open.ApiUserAuthorityService; -import com.fangjia.service.open.EvaluateFactorService; -import com.fangjia.service.open.EvaluateRatioService; -import com.fangjia.service.open.FangjiaOfficialAreaService; +import com.fangjia.service.open.*; import com.fangjia.service.web.AddressService; import net.sf.json.JSONObject; import org.apache.commons.lang.ArrayUtils; @@ -99,6 +96,8 @@ public class ComprehensiveQueryController { private EvaluateRatioService evaluateRatioService; + private AdministrativeMappingService administrativeMappingService; + private static final int EVALUATE_SHOW_DETAIL = 1; private static final Map PROPERTY_TYPES = new HashMap() { { @@ -235,19 +234,22 @@ public class ComprehensiveQueryController { } String cityStr = model.getCity(); - if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) { - AdministrativeDivision administrativeDivision = administrativeDivisionService.findcityByCode(cityStr); - if (administrativeDivision == null) { + String districtStr = model.getDistrict(); + String cityShort = ""; + if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+") && StringUtils.isBlank(districtStr)) { + cityShort = administrativeMappingService.findCityShortByCityCode(cityStr); + if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); return mav; } - String city = administrativeDivision.getCityShort(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); + } else if (districtStr.matches("\\d+")) { + cityShort = administrativeMappingService.findDistrictShortByDistrictCode(cityStr, districtStr); + if (StringUtils.isBlank(cityShort)) { + mav.setModel(BasicModel.buildBadRequestModel("区县代码错误")); return mav; } - model.setCity(city); } + model.setCity(cityShort); HttpRequest httpRequest = new HttpRequest(); JSONObject json = null; @@ -264,9 +266,11 @@ public class ComprehensiveQueryController { try { matchResponse = httpRequest.getJsonContent("http://open.fangjia.com/address/match", communityAvgPriceParams, "UTF-8"); // matchResponse = httpRequest.getJsonContent("http://192.168.0.19:31080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8"); - } catch (HttpRequestException e) { + } catch ( + HttpRequestException e) { } + // 去掉经纬度解析 // if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) { // //加上高德获取经纬度 和 根据经纬度估值 @@ -302,12 +306,14 @@ public class ComprehensiveQueryController { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); return mav; } + String id = matchResponse.getJSONObject("result").getString("id"); District district = districtService.findById(id); if (district == null) { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); return mav; } + MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, matchResponse.getJSONObject("result")); DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(district)); if (null != statBo) { @@ -359,7 +365,8 @@ public class ComprehensiveQueryController { propertyEvaluationModel.setName(district.getName()); try { evaluateAction(propertyEvaluationModel, httpServletRequest, houseValueInformation, mav); - } catch (IllegalAccessException e) { + } catch ( + IllegalAccessException e) { } // 价格下调10% @@ -379,17 +386,19 @@ public class ComprehensiveQueryController { sampleQuery.setStrctureArea(model.getSize()); sampleQuery.setAddress(model.getAddress()); -// RestfulModelAndView houseCaseMav = new RestfulModelAndView(); + // RestfulModelAndView houseCaseMav = new RestfulModelAndView(); List querys = null; try { querys = convertSampileQueryToBean(district, sampleQuery); - } catch (Exception e) { + } catch ( + Exception e) { mav.setModel(BasicModel.buildBadRequestModel(e.getMessage())); return mav; } if (null == sampleQuery.getMax()) { sampleQuery.setMax(10); } + // 此处慢 long start = System.currentTimeMillis(); List collaterals = czbankSampleService.findSampleForBse(querys, sampleQuery.getMax()); @@ -441,7 +450,9 @@ public class ComprehensiveQueryController { } // 将周边POI数据放到结果集 houseValueInformation.setSurroundingPoi(facilitys); - mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); + mav.setModel(BasicModel.buildOKModel(). + + setResult(houseValueInformation)); return mav; } @@ -1397,5 +1408,9 @@ public class ComprehensiveQueryController { public void setAdministrativeDivisionService(AdministrativeDivisionService administrativeDivisionService) { this.administrativeDivisionService = administrativeDivisionService; } + + public void setAdministrativeMappingService(AdministrativeMappingService administrativeMappingService) { + this.administrativeMappingService = administrativeMappingService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java index a0fc680e1..3c26ea411 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java @@ -12,8 +12,12 @@ import java.util.List; public interface AdministrativeMappingService { + public String findCityCodeByCityShort(String cityShort); - public String findCityCodeByCityShort(String cityShort); - public String findCityByCityShort(String cityShort) ; + public String findCityByCityShort(String cityShort); + + public String findCityShortByCityCode(String cityCode); + + public String findDistrictShortByDistrictCode(String cityCode,String districtCode); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java index 521b1e5ef..7b7cbbeed 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java @@ -67,7 +67,7 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe )); - public String findCityCodeByCityShort(String cityShort) { + public String findCityCodeByCityShort(String cityShort) { ArrayList params = new ArrayList(); params.add(new QueryParam("cityShort", cityShort)); params.add(new QueryParam("type", "城市")); @@ -78,7 +78,7 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe return null; } - public String findCityByCityShort(String cityShort) { + public String findCityByCityShort(String cityShort) { if (CITY_SHORT.contains(cityShort)) { ArrayList params = new ArrayList(); params.add(new QueryParam("cityShort", cityShort)); @@ -91,7 +91,43 @@ public class AdministrativeMappingServiceImpl implements AdministrativeMappingSe return cityShort; } - public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { + @Override + public String findCityShortByCityCode(String cityCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("type", "城市")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + @Override + public String findDistrictShortByDistrictCode(String cityCode, String districtCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("mzbDistrictCode", districtCode)); + params.add(new QueryParam("type", "区域")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + + public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { this.administrativeMappingDao = administrativeMappingDao; } } From f0f55c67a6b01c94b342673c6328933723650d3e Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 2 Apr 2025 15:40:43 +0800 Subject: [PATCH 003/121] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E8=A1=8C?= =?UTF-8?q?=E6=94=BF=E5=8C=BA=E5=88=92=E6=94=B9=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index f2037adbc..e0d0fddff 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -235,14 +235,14 @@ public class ComprehensiveQueryController { String cityStr = model.getCity(); String districtStr = model.getDistrict(); - String cityShort = ""; + String cityShort = model.getCity(); if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+") && StringUtils.isBlank(districtStr)) { cityShort = administrativeMappingService.findCityShortByCityCode(cityStr); if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("城市代码错误")); return mav; } - } else if (districtStr.matches("\\d+")) { + } else if (StringUtils.isNotBlank(districtStr) && districtStr.matches("\\d+")) { cityShort = administrativeMappingService.findDistrictShortByDistrictCode(cityStr, districtStr); if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("区县代码错误")); From dfc885ce3810b3cc624622ec49809951fe79d4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 3 Apr 2025 17:34:22 +0800 Subject: [PATCH 004/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/PropertyController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 7c4c4ab00..57f2da122 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -2443,7 +2443,11 @@ public class PropertyController { item.put("city", districtStat.getCity()); item.put("district", districtStat.getRegion()); item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvg_price_2b()); + if (districtStat.getAvg_price_2b() != null) { + item.put("avgPrice", districtStat.getAvg_price_2b()); + } else { + item.put("avgPrice", districtStat.getAvgPrice()); + } if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); } else { From 781731edcbaea395b308e8fb09db9475b2c4f845 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 9 Apr 2025 16:20:26 +0800 Subject: [PATCH 005/121] =?UTF-8?q?=E6=B1=9F=E5=8D=97=E8=A1=8C=E6=88=BF?= =?UTF-8?q?=E6=BA=90=E4=BB=B7=E6=A0=BC=E6=94=B9=E4=B8=BA=E5=B7=AE30%?= =?UTF-8?q?=EF=BC=8C=E4=BB=8EES=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 3 + .../datastore/CzbankSampleServiceImpl.java | 69 ++++++++++++++----- .../com/fangjia/service/util/CommonUtils.java | 41 +++++++++++ 3 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 8641e498f..04379c299 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -329,6 +329,9 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i } catch (Exception e) { seawater.setpDate(0); } + if (source.containsKey("publish_date")){ + seawater.setPublishDate(source.getString("publish_date")); + } if (source.containsKey("url")) { seawater.setUrl(source.getString("url")); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index f6177cfca..8cdd9018a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -1,9 +1,8 @@ package com.fangjia.service.datastore; import com.fangjia.core.util.*; -import com.fangjia.dal.QueryParam; -import com.fangjia.dal.SortParam; -import com.fangjia.dal.SrQuery; +import com.fangjia.dal.*; +import com.fangjia.dal.seawater.dao.SeawaterDao; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.datastore.dao.HouseDao; import com.fangjia.dal.datastore.model.House; @@ -14,6 +13,7 @@ import com.fangjia.dal.mongo.model.DistrictStat; import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; import com.fangjia.dal.mongo.model.bkoff.DealPrice; import com.fangjia.dal.mongo.model.bkoff.Loudong; +import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.address.mode.ProvinceData; import com.fangjia.service.bo.Collateral; @@ -24,12 +24,15 @@ import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; import com.fangjia.service.datastore.bean.ShopCollateralSampleQueryBean; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.open.FangjiaOfficialAreaService; +import com.fangjia.service.util.CommonUtil; +import com.fangjia.service.util.CommonUtils; import org.apache.commons.lang.StringUtils; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.TermQuery; import org.apache.solr.client.solrj.util.ClientUtils; +import org.sothis.core.util.Pager; import java.math.BigDecimal; import java.util.*; @@ -59,6 +62,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { private DistrictSellStatService districtSellStatService; private FangjiaOfficialAreaService fangjiaOfficialAreaService; private LoudongDao loudongDao; + private SeawaterDao seawaterDao; @Override @@ -227,7 +231,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List querySamples = new ArrayList(); District hasHouseDist = districtService.findDistrictHasHouseFlag(district);//查询是否是有房源的小区 - if(hasHouseDist != null){ + if (hasHouseDist != null) { List keys = new ArrayList(); String key = district.getName() + "_" + district.getRegion() + "_" + district.getCity(); // 修改 @@ -269,7 +273,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List arroundKeys = new ArrayList(); for (District d : districts) { d = districtService.findById(d.getId()); - if(district.getName().equals(d.getName())){ + if (district.getName().equals(d.getName())) { continue; } @@ -531,8 +535,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { if (!map.containsKey(districtName)) { List sampleWrappers = new ArrayList(); sampleWrappers.add(sample); - map.put(districtName,sampleWrappers); - }else { + map.put(districtName, sampleWrappers); + } else { map.get(districtName).add(sample); } } @@ -540,9 +544,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { for (Map.Entry> entry : map.entrySet()) { //每个小区取5个样本 - if (entry.getValue().size()>=5){ - querySamples.addAll(entry.getValue().subList(0,5)); - }else { + if (entry.getValue().size() >= 5) { + querySamples.addAll(entry.getValue().subList(0, 5)); + } else { // 不超过五个,全部放入 querySamples.addAll(entry.getValue()); } @@ -659,7 +663,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { querySamples.addAll(samples); if (querySamples.size() < max + 10) { - // 查询成交补充 TODO + // 查询成交补充 TODO List dealPriceQuery = new ArrayList(); dealPriceQuery.add(new QueryParam("city", district.getCity())); dealPriceQuery.add(new QueryParam("region", district.getRegion())); @@ -1126,18 +1130,22 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { /** * 江南行查找小区样本(优先使用贝壳链家) * - * @param estateType 用户查询物业类型 + * @param estateType 用户查询物业类型 * @param startDate * @return */ - private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat,double area) { - + private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat, double area) { + //改为从ES 查房源 + ArrayList districtNames = new ArrayList(); BooleanQuery nameQuery = new BooleanQuery(); int c = 0; for (String namekey : keys) { if (StringUtils.isNotBlank(namekey)) { namekey = ClientUtils.escapeQueryChars(namekey); + if (namekey.contains("_")) { + districtNames.add(namekey.split("_")[0]); + } c++; nameQuery.add(new TermQuery(new Term("districtname_key", namekey)), BooleanClause.Occur.SHOULD); } @@ -1149,15 +1157,19 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseQuery = new ArrayList(); houseQuery.add(new QueryParam("city", district.getCity())); houseQuery.add(new QueryParam("region", district.getRegion())); + SeawaterQuery seawaterQuery = new SeawaterQuery(); if (districtStat != null && districtStat.getAvgPrice() > 0) { int avgPrice = districtStat.getAvgPrice(); - houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.5)));//0.85 - houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.5)));//1.15 + // 价格范围调整为上下浮动30% + seawaterQuery.setStartPrice((int) (avgPrice * 0.7)); + seawaterQuery.setEndPrice((int) (avgPrice * 1.3)); + houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.7))); + houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.3))); } houseQuery.add(new QueryParam("area", QueryParam.LESS_THAN_EQUAL_OPERATOR, area + 30)); houseQuery.add(new QueryParam("area", QueryParam.GREATER_THAN_EQUAL_OPERATOR, area - 30)); - if (nameQuery.clauses().isEmpty()){ + if (nameQuery.clauses().isEmpty()) { return samples; } BooleanQuery srQuery = new BooleanQuery(); @@ -1169,7 +1181,24 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseSortParams = new ArrayList(); houseSortParams.add(new SortParam("publishDate", false)); - List houses = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); + + seawaterQuery.setCityDisplay(district.getCity()); + seawaterQuery.setDistrictAlias(names); + seawaterQuery.setRegion(district.getRegion()); + seawaterQuery.setDistrictName(district.getName()); + seawaterQuery.setStartArea(area - 30); + seawaterQuery.setEndArea(area + 30); + seawaterQuery.setSortField("p_date"); + seawaterQuery.setOrder(false); + Pager pager = new Pager(0, 200); + pager.setPageSize(200); + seawaterQuery.setTable("latest_seawater"); + seawaterQuery.setPager(pager); + seawaterQuery.setCat("sell"); + List seawaters = seawaterDao.findSeawatersByQuery(seawaterQuery); + List houses = CommonUtils.transformListV(House.class, seawaters); + +// List houses1 = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); int height = 0; int maxFloor = 0; boolean allSampleHasHeight = true; @@ -1730,4 +1759,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; } + + public void setSeawaterDao(SeawaterDao seawaterDao) { + this.seawaterDao = seawaterDao; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java new file mode 100644 index 000000000..d19f8eda2 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java @@ -0,0 +1,41 @@ +package com.fangjia.service.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +/** + * 通用实体与DTO互相转换工具类 + * + * @author shenjian + * @date 2021/06/16 + */ +public class CommonUtils { + public static T transformV(Class targetClass, Object source) { + if (source == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(source); + return JSONObject.parseObject(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } + + public static List transformListV(Class targetClass, List listSource) { + if (listSource == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(listSource); + return JSONArray.parseArray(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } +} \ No newline at end of file From 4ec26e53538216adada339a6cbadb6deeba669c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 10 Apr 2025 13:59:58 +0800 Subject: [PATCH 006/121] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E9=93=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/dao/shop/ShopRentStatDao.java | 9 + .../mongo/dao/shop/ShopRentStatDaoImpl.java | 8 + .../dal/mongo/dao/shop/ShopSellStatDao.java | 9 + .../mongo/dao/shop/ShopSellStatDaoImpl.java | 8 + .../fangjia/dal/mongo/model/ShopRentStat.java | 84 +++ .../fangjia/dal/mongo/model/ShopSellStat.java | 84 +++ .../open/controllers/ShopController.java | 614 ++++++++++++++++++ .../service/datastore/AiShopService.java | 49 ++ .../service/datastore/AiShopServiceImpl.java | 553 ++++++++++++++++ .../service/datastore/ShopService.java | 4 +- .../datastore/dto/ShopEvaluationDto.java | 54 ++ .../service/datastore/dto/ShopRentDto.java | 32 + 12 files changed, 1506 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java new file mode 100644 index 000000000..a03b21129 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public interface ShopRentStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java new file mode 100644 index 000000000..e1f611b37 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public class ShopRentStatDaoImpl extends MongoDaoImpl implements ShopRentStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java new file mode 100644 index 000000000..2fec3b1d9 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public interface ShopSellStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java new file mode 100644 index 000000000..c233ba1db --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public class ShopSellStatDaoImpl extends MongoDaoImpl implements ShopSellStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java new file mode 100644 index 000000000..510e8e392 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_rent_stat") +public class ShopRentStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java new file mode 100644 index 000000000..8745031ce --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_sell_stat") +public class ShopSellStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java new file mode 100644 index 000000000..3afc679c3 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * 商铺出租服务类 + * + * @author shenjian + * @since 2025/4/10 + */ +@Authority(role = Role.USER) +public class ShopController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * 城市出租均价 + * + * @return + */ + public Object cityRentAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 区域出租均价 + * + * @return + */ + public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼均价走势 + * + * @return + */ + public Object shopRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼楼租金地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateRent(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + /** + * 申请估值报告 + * + * @param model 申请报告请求参数 + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (model.getDistrict().endsWith("区")) { + model.setDistrict(model.getDistrict().replaceAll("区$", "")); + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空")); + } + return mav; + } + + /** + * 获取估值报告 + * + * @param caseId 估值报告ID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空")); + } + return mav; + } + + private Integer getFloor(String roomNumber) { + if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) { + if (roomNumber.length() == 3) { + return Integer.valueOf(roomNumber.substring(0, 1)); + } else if (roomNumber.length() == 4) { + return Integer.valueOf(roomNumber.substring(0, 2)); + } else { + return null; + } + } + return null; + } + + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + evaluation.setSight(SIGHT.get(model.getView())); + evaluation.setAtticArea(model.getAtticSize()); + evaluation.setTerraceArea(model.getOuterSize()); + evaluation.setBasementArea(model.getBasementSize()); + evaluation.setGardenArea(model.getGardenSize()); + String worryFacility = model.getNegativeFactor(); + evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility)); + evaluation.setCreationDate(new Date()); + evaluation.setModificationDate(new Date()); + evaluation.setClientNo(model.getClientNo()); + if (0 != model.getAge()) { + evaluation.setAge(model.getAge()); + } + evaluation.setArea(model.getSize()); + if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { + evaluation.setBuildQuality(convertToString(model.getBuildQuality())); + } + if (StringUtils.isNotBlank(model.getBuildType())) { + evaluation.setBuildType(model.getBuildType()); + } + if (StringUtils.isNotBlank(model.getCarport())) { + evaluation.setCarport(model.getCarport()); + } + if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) { + evaluation.setFitmentAge(model.getDecorationAge()); + } + evaluation.setCarportPrice(model.getCarportPrice()); + evaluation.setCity(model.getCity()); + evaluation.setDistrictName(model.getName()); + if (model.getDecorationCost() != null && model.getDecorationCost() > 0) { + evaluation.setFitmentCharge(model.getDecorationCost()); + } + if (0 != model.getHall()) { + evaluation.setHall(model.getHall()); + } + if (null != model.getFloor()) { + evaluation.setFloor(model.getFloor()); + } + if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) { + evaluation.setHeight(model.getMaxFloor()); + } + if (StringUtils.isNotBlank(model.getBuildingNumber())) { + evaluation.setHouseNum(model.getBuildingNumber()); + } + if (StringUtils.isNotBlank(model.getHouseProperty())) { + evaluation.setHouseProperty(model.getHouseProperty()); + } + if (StringUtils.isNotBlank(model.getInsidepos())) { + evaluation.setInsidepos(model.getInsidepos()); + } + if (StringUtils.isNotBlank(model.getLightingVentilation())) { + evaluation.setLightingVentilation(model.getLightingVentilation()); + } + + if (StringUtils.isNotBlank(model.getOtherFactor())) { + evaluation.setOtherFactor(model.getOtherFactor()); + } + evaluation.setRegion(model.getDistrict()); + if (null != model.getRoom()) { + evaluation.setRoom(model.getRoom()); + } + if (StringUtils.isNotBlank(model.getRoomNumber())) { + evaluation.setRoomNum(model.getRoomNumber()); + } + if (StringUtils.isNotBlank(model.getSideset())) { + evaluation.setSideset(model.getSideset()); + } + if (0 != model.getToilet()) { + evaluation.setToilet(model.getToilet()); + } + if (model.getFacilities() != null) { + String facilities = model.getFacilities(); + String[] fs = facilities.split(","); + for (int i = 0; i < fs.length; i++) { + fs[i] = FACILITIES.get(fs[i]); + } + evaluation.setFacilities(convertToString(fs)); + } + + if (StringUtils.isNotBlank(model.getFacade())) { + evaluation.setFacade(model.getFacade()); + } + if (StringUtils.isNotBlank(model.getTraffice())) { + evaluation.setTraffice(model.getTraffice()); + } + if (StringUtils.isNotBlank(model.getShape())) { + evaluation.setShape(model.getShape()); + } + if (StringUtils.isNotBlank(model.getObstacle())) { + evaluation.setObstacle(model.getObstacle()); + } + if (StringUtils.isNotBlank(model.getIndustry())) { + evaluation.setIndustry(model.getIndustry()); + } + if (StringUtils.isNotBlank(model.getSupportDevice())) { + evaluation.setSupportDevice(model.getSupportDevice()); + } + if (StringUtils.isNotBlank(model.getLeftPosition())) { + evaluation.setLeftPosition(model.getLeftPosition()); + } + if (StringUtils.isNotBlank(model.getShopType())) { + evaluation.setShopType(model.getShopType()); + } + if (StringUtils.isNotBlank(model.getShopUnique())) { + evaluation.setShopUnique(model.getShopUnique()); + } + if (StringUtils.isNotBlank(model.getLocation())) { + evaluation.setLocation(model.getLocation()); + } + if (model.isNewDistrict()) { + evaluation.setNewDistrict(model.isNewDistrict()); + } + String floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } + String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest()); + evaluation.setIp(ip); + AuthenticationBean authenticationBean = (AuthenticationBean) request + .getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (authenticationBean != null && authenticationBean.apiUser != null) { + evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId())); + } + evaluation.setSource("api_shop_evaluateRent"); + return evaluation; + } + + private static final Map FACILITIES = new HashMap() { + { + put("0", "健身房"); + put("1", "游泳池"); + put("2", "会所"); + put("3", "网球场"); + put("4", "球场"); + put("5", "棋牌室"); + put("6", "停车场"); + put("7", "图书馆"); + put("8", "活动中心"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java new file mode 100644 index 000000000..efe2d3287 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java @@ -0,0 +1,49 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; + +import java.util.List; + +public interface AiShopService { + + /** + * 租金均价 + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * 租金地址维度评估 + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateRent(Evaluation evaluation); + + /** + * 城市写字楼出售均价 + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * 售价地址维度评估 + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateSell(Evaluation evaluation); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java new file mode 100644 index 000000000..5c7edbcff --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -0,0 +1,553 @@ +package com.fangjia.service.datastore; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SeawaterQuery; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.shop.ShopRentStatDao; +import com.fangjia.dal.mongo.dao.shop.ShopSellStatDao; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import com.fangjia.service.mongo.fangjia.SeawaterService; +import com.fangjia.service.util.GeoUtils; +import com.fangjia.service.util.dto.GaodeDto; +import com.mongodb.BasicDBObject; +import org.apache.commons.collections.CollectionUtils; +import org.sothis.core.util.Closure; +import org.sothis.core.util.Pager; +import weiboclient4j.utils.StringUtils; + +import java.util.*; + +public class AiShopServiceImpl implements AiShopService { + + private ShopRentStatDao shopRentStatDao; + private SeawaterService seawaterService; + private ShopSellStatDao shopSellStatDao; + + + // 所在楼层 +// 总楼层 + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "毛坯"); + put("2", "简装"); + put("3", "精装"); + put("4", "豪装"); + } + }; + + private static final Map DIRECTION_MAP = new HashMap() { + { + put("1", "西南"); + put("2", "东南"); + put("3", "南"); + put("4", "西北"); + put("5", "东北"); + put("6", "东"); + put("7", "西"); + put("8", "北"); + put("9", "东西"); + put("10", "南北"); + } + }; + private static final Map FITMENT_FACTOR = new HashMap() { + { + put("毛坯", 0.9983); + put("简装", 1.0); + put("精装", 1.0153); + put("豪装", 1.0199); + } + }; + private static final Map DIRECTION_FACTOR = new HashMap() { + { + put("东", 1.0040); + put("东北", 1.0048); + put("东南", 1.0121); + put("东西", 1.0003); + put("北", 0.9999); + put("南", 1.0000); + put("南北", 1.0080); + put("西", 1.0060); + put("西北", 1.0099); + put("西南", 1.0103); + } + }; + + public ShopEvaluationDto calcRent(Evaluation evaluation) { + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + // 第二步:基准价*楼层系数*装修系数*朝向系数 + // 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数 + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果 + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("shop_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "低".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "高".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getShopEvaluationDto(selectedSeawaters, evaluation, "shop_rent"); + } + } + } + // 查找基准价 + List params = new ArrayList(); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // 获取上个月yyyyMM日期 + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // 第二步:基准价*楼层系数*装修系数*朝向系数 + ShopRentStat shopRentStat = shopRentStatDao.findFirstByParams(params); + Double avgPrice = shopRentStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getShopEvaluationDtoWithAvgPrice(avgPrice, evaluation, "shop_rent"); + } + + return null; + } + + /** + * 根据均价查询样本 + * + * @param avgPrice + * @param evaluation + * @return + */ + private ShopEvaluationDto getShopEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + if ("shop_rent".equals(cat)) { + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + } else { + query.setStartPrice((int) (avgPrice * 0.9)); + query.setEndPrice((int) (avgPrice * 1.1)); + } + query.setCat(cat); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + return getShopEvaluationDto(seawaters, evaluation, cat); + } + + /** + * 基准价*楼层系数*装修系数*朝向系数 + * + * @param seawaters + * @param evaluation + * @return + */ + private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { + Double sum = 0.0; + Double size = 0.0; + + String fitment = FITMENT_MAP.get(evaluation.getFitment()); + String direction = DIRECTION_MAP.get(evaluation.getDirection()); + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + Double price = Double.valueOf(seawater.getTotalPrice()); + // 装修 + if (seawater.getFitment() != null) { + try { + price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); + } catch (Exception ex) { + + } + } + // 朝向 + if (seawater.getDirection() != null) { + try { + price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); + } catch (Exception ex) { + + } + } + + sum += price; + size += seawater.getArea(); + } + } + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + return shopEvaluationDto; + } + + /** + * 纯样本查询结果估值 + * + * @param seawaters + * @param evaluation + * @return + */ + private static ShopEvaluationDto getShopEvaluationDto(List seawaters, Evaluation evaluation, String cat) { + Integer sum = 0; + Double size = 0.0; + + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + + if ("shop_rent".equals(cat)) { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } else { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } + + return shopEvaluationDto; + } + + + @Override + public ShopEvaluationDto addressEvaluateRent(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return rentEvaluateByLocation(evaluation); + } + + @Override + public List findShopSellStat(String city, String region, String name, String cat, Integer startDate, Integer endDate) { + return Collections.emptyList(); + } + + private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_rent"); + query.setRadius(1000); + // 查询近一年样本 + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + if (CollectionUtils.isNotEmpty(shops)) { + // 求均值 + Double totalPrice = 0D; + int count = 0; + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + shopEvaluationDto.setUnitPrice(avgPrice); + shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private ShopEvaluationDto sellEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // 查询附近5个写字楼基准价 + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); + + List params = new ArrayList(5); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = shopSellStatDao.findAllByParams(params, sortParams, 5); + if (CollectionUtils.isEmpty(infos)) { + // 去掉类型,重新查找 + params = new ArrayList(5); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = shopSellStatDao.findAllByParams(params, sortParams); + } + if (CollectionUtils.isNotEmpty(infos)) { + // 求均值 + Double totalPrice = 0D; + int count = 0; + for (ShopSellStat shopSellStat : infos) { + if (shopSellStat.getAvgPrice() != null) { + totalPrice += shopSellStat.getAvgPrice(); + count += 1; + } + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + shopEvaluationDto.setUnitPrice(avgPrice); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private String getLocation(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + return gaodeDto.getLng() + "," + gaodeDto.getLat(); + } + return ""; + } + + private GaodeDto getGaodeGeo(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + return gaodeDto; + } + + public List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); + } + }); + } + + public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List regionStats = shopRentStatDao.findAllByParams(params, sortParams); + return regionStats; + } + + @Override + public ShopEvaluationDto addressEvaluateSell(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // 评估逻辑 +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return sellEvaluateByLocation(evaluation); + } + + public List doFindShopSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("开始日期不能为空"); + } + if (endDate == null) { + throw new IllegalArgumentException("结束日期不能为空"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat不能为空"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List sellStatList = shopSellStatDao.findAllByParams(params, sortParams); + return sellStatList; + } + + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } + + public void setShopRentStatDao(ShopRentStatDao shopRentStatDao) { + this.shopRentStatDao = shopRentStatDao; + } + + public void setShopSellStatDao(ShopSellStatDao shopSellStatDao) { + this.shopSellStatDao = shopSellStatDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java index e66e53e25..7665fd814 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java @@ -1,11 +1,11 @@ package com.fangjia.service.datastore; -import java.util.List; - import com.fangjia.dal.QueryParam; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.seaweed.model.Shop; +import java.util.List; + public interface ShopService { List findByKeyword(String city, String keyword); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java new file mode 100644 index 000000000..60432aa1f --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java @@ -0,0 +1,54 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + + private String name; + + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java new file mode 100644 index 000000000..02e2379f4 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +} From 1c61cc3b76e988e6163eb63517d4fc53e2ba4db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 14 Apr 2025 16:05:41 +0800 Subject: [PATCH 007/121] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E9=93=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/mongo/model/ShopSellStat.java | 6 +- .../open/controllers/ShopSellController.java | 614 ++++++++++++++++++ .../service/datastore/AiShopServiceImpl.java | 69 +- 3 files changed, 648 insertions(+), 41 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java index 8745031ce..97c6c4623 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java @@ -14,7 +14,7 @@ public class ShopSellStat implements MongoEntity { private String city; private String district; private Integer date; - private Double avgPrice; + private Integer avgPrice; private String name; @Id @@ -65,11 +65,11 @@ public class ShopSellStat implements MongoEntity { } @Column(name = "avg_price") - public Double getAvgPrice() { + public Integer getAvgPrice() { return avgPrice; } - public void setAvgPrice(Double avgPrice) { + public void setAvgPrice(Integer avgPrice) { this.avgPrice = avgPrice; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java new file mode 100644 index 000000000..9aae9fb84 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * 商铺出售服务类 + * + * @author shenjian + * @since 2025/4/14 + */ +@Authority(role = Role.USER) +public class ShopSellController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * 城市出租均价 + * + * @return + */ + public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 区域出租均价 + * + * @return + */ + public Object districtSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼均价走势 + * + * @return + */ + public Object shopSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district不能为null")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city非法")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该写字楼没有均价数据")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * 写字楼楼租金地址估值 + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + + if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) { + mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法")); + return mav; + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateSell(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData()); + return mav; + } + } + + /** + * 申请估值报告 + * + * @param model 申请报告请求参数 + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (model.getDistrict().endsWith("区")) { + model.setDistrict(model.getDistrict().replaceAll("区$", "")); + } + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空")); + } + return mav; + } + + /** + * 获取估值报告 + * + * @param caseId 估值报告ID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空")); + } + return mav; + } + + private Integer getFloor(String roomNumber) { + if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) { + if (roomNumber.length() == 3) { + return Integer.valueOf(roomNumber.substring(0, 1)); + } else if (roomNumber.length() == 4) { + return Integer.valueOf(roomNumber.substring(0, 2)); + } else { + return null; + } + } + return null; + } + + /** + * 通过EvaluationModel组装Evaluation实体 + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + evaluation.setSight(SIGHT.get(model.getView())); + evaluation.setAtticArea(model.getAtticSize()); + evaluation.setTerraceArea(model.getOuterSize()); + evaluation.setBasementArea(model.getBasementSize()); + evaluation.setGardenArea(model.getGardenSize()); + String worryFacility = model.getNegativeFactor(); + evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility)); + evaluation.setCreationDate(new Date()); + evaluation.setModificationDate(new Date()); + evaluation.setClientNo(model.getClientNo()); + if (0 != model.getAge()) { + evaluation.setAge(model.getAge()); + } + evaluation.setArea(model.getSize()); + if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { + evaluation.setBuildQuality(convertToString(model.getBuildQuality())); + } + if (StringUtils.isNotBlank(model.getBuildType())) { + evaluation.setBuildType(model.getBuildType()); + } + if (StringUtils.isNotBlank(model.getCarport())) { + evaluation.setCarport(model.getCarport()); + } + if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) { + evaluation.setFitmentAge(model.getDecorationAge()); + } + evaluation.setCarportPrice(model.getCarportPrice()); + evaluation.setCity(model.getCity()); + evaluation.setDistrictName(model.getName()); + if (model.getDecorationCost() != null && model.getDecorationCost() > 0) { + evaluation.setFitmentCharge(model.getDecorationCost()); + } + if (0 != model.getHall()) { + evaluation.setHall(model.getHall()); + } + if (null != model.getFloor()) { + evaluation.setFloor(model.getFloor()); + } + if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) { + evaluation.setHeight(model.getMaxFloor()); + } + if (StringUtils.isNotBlank(model.getBuildingNumber())) { + evaluation.setHouseNum(model.getBuildingNumber()); + } + if (StringUtils.isNotBlank(model.getHouseProperty())) { + evaluation.setHouseProperty(model.getHouseProperty()); + } + if (StringUtils.isNotBlank(model.getInsidepos())) { + evaluation.setInsidepos(model.getInsidepos()); + } + if (StringUtils.isNotBlank(model.getLightingVentilation())) { + evaluation.setLightingVentilation(model.getLightingVentilation()); + } + + if (StringUtils.isNotBlank(model.getOtherFactor())) { + evaluation.setOtherFactor(model.getOtherFactor()); + } + evaluation.setRegion(model.getDistrict()); + if (null != model.getRoom()) { + evaluation.setRoom(model.getRoom()); + } + if (StringUtils.isNotBlank(model.getRoomNumber())) { + evaluation.setRoomNum(model.getRoomNumber()); + } + if (StringUtils.isNotBlank(model.getSideset())) { + evaluation.setSideset(model.getSideset()); + } + if (0 != model.getToilet()) { + evaluation.setToilet(model.getToilet()); + } + if (model.getFacilities() != null) { + String facilities = model.getFacilities(); + String[] fs = facilities.split(","); + for (int i = 0; i < fs.length; i++) { + fs[i] = FACILITIES.get(fs[i]); + } + evaluation.setFacilities(convertToString(fs)); + } + + if (StringUtils.isNotBlank(model.getFacade())) { + evaluation.setFacade(model.getFacade()); + } + if (StringUtils.isNotBlank(model.getTraffice())) { + evaluation.setTraffice(model.getTraffice()); + } + if (StringUtils.isNotBlank(model.getShape())) { + evaluation.setShape(model.getShape()); + } + if (StringUtils.isNotBlank(model.getObstacle())) { + evaluation.setObstacle(model.getObstacle()); + } + if (StringUtils.isNotBlank(model.getIndustry())) { + evaluation.setIndustry(model.getIndustry()); + } + if (StringUtils.isNotBlank(model.getSupportDevice())) { + evaluation.setSupportDevice(model.getSupportDevice()); + } + if (StringUtils.isNotBlank(model.getLeftPosition())) { + evaluation.setLeftPosition(model.getLeftPosition()); + } + if (StringUtils.isNotBlank(model.getShopType())) { + evaluation.setShopType(model.getShopType()); + } + if (StringUtils.isNotBlank(model.getShopUnique())) { + evaluation.setShopUnique(model.getShopUnique()); + } + if (StringUtils.isNotBlank(model.getLocation())) { + evaluation.setLocation(model.getLocation()); + } + if (model.isNewDistrict()) { + evaluation.setNewDistrict(model.isNewDistrict()); + } + String floorDesc = "中"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "低"; + } else if (floorInfo > 0.66) { + floorDesc = "高"; + } + evaluation.setFloorDesc(floorDesc); + } + String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest()); + evaluation.setIp(ip); + AuthenticationBean authenticationBean = (AuthenticationBean) request + .getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (authenticationBean != null && authenticationBean.apiUser != null) { + evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId())); + } + evaluation.setSource("api_shop_evaluateRent"); + return evaluation; + } + + private static final Map FACILITIES = new HashMap() { + { + put("0", "健身房"); + put("1", "游泳池"); + put("2", "会所"); + put("3", "网球场"); + put("4", "球场"); + put("5", "棋牌室"); + put("6", "停车场"); + put("7", "图书馆"); + put("8", "活动中心"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 5c7edbcff..6b65b649a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -17,7 +17,6 @@ import com.fangjia.service.datastore.dto.ShopEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.dto.GaodeDto; -import com.mongodb.BasicDBObject; import org.apache.commons.collections.CollectionUtils; import org.sothis.core.util.Closure; import org.sothis.core.util.Pager; @@ -322,8 +321,13 @@ public class AiShopServiceImpl implements AiShopService { } @Override - public List findShopSellStat(String city, String region, String name, String cat, Integer startDate, Integer endDate) { - return Collections.emptyList(); + public List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindShopSellStat(city, region, name, cat, startDate, endDate); + } + }); } private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { @@ -382,40 +386,28 @@ public class AiShopServiceImpl implements AiShopService { shopEvaluationDto.setLocation(evaluation.getLocation()); Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); - // 查询附近5个写字楼基准价 - BasicDBObject geo = new BasicDBObject(); - BasicDBObject nearQuery = new BasicDBObject(); - nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); - nearQuery.append("$maxDistance", 3000); - geo.append("$near", nearQuery); - - List params = new ArrayList(5); - params.add(new QueryParam("cat", "shop")); - params.add(new QueryParam("location", geo)); - - String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); - params.add(new QueryParam("date", Integer.parseInt(date))); - - // 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据 - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - - List infos = shopSellStatDao.findAllByParams(params, sortParams, 5); - if (CollectionUtils.isEmpty(infos)) { - // 去掉类型,重新查找 - params = new ArrayList(5); - params.add(new QueryParam("cat", "shop")); - params.add(new QueryParam("location", geo)); - params.add(new QueryParam("date", Integer.parseInt(date))); - infos = shopSellStatDao.findAllByParams(params, sortParams); - } - if (CollectionUtils.isNotEmpty(infos)) { + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_sell"); + query.setRadius(1000); + // 查询近一年样本 + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; int count = 0; - for (ShopSellStat shopSellStat : infos) { - if (shopSellStat.getAvgPrice() != null) { - totalPrice += shopSellStat.getAvgPrice(); + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getAvgPrice(); count += 1; } } @@ -426,8 +418,9 @@ public class AiShopServiceImpl implements AiShopService { if (evaluation.getDirection() != null) { factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); } - Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); - shopEvaluationDto.setUnitPrice(avgPrice); + int avgPrice = (int) (totalPrice / count * factor); + shopEvaluationDto.setUnitPrice((double) avgPrice); + shopEvaluationDto.setSeawater(shops); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -454,12 +447,12 @@ public class AiShopServiceImpl implements AiShopService { return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { public List execute(String input) { - return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); + return doFindShopRentStat(city, region, name, cat, startDate, endDate); } }); } - public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + public List doFindShopRentStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { if (startDate == null) { throw new IllegalArgumentException("开始日期不能为空"); } From b361dbae19e74c9ab2c881c4a26dc6f54f98ef26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 14 Apr 2025 17:50:00 +0800 Subject: [PATCH 008/121] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 234 ++++++++++++++++-- 1 file changed, 214 insertions(+), 20 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 5928f1294..97e1a2ade 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -1,25 +1,23 @@ package com.fangjia.service.api; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; - -import net.sf.json.JSONArray; -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -import com.fangjia.core.util.GeoUtils; -import com.fangjia.core.util.HttpRequest; -import com.fangjia.core.util.HttpRequestException; -import com.fangjia.core.util.JsonUtils; +import com.fangjia.core.util.*; +import com.fangjia.dal.mongo.open.model.WaitCrawlKeywords; +import com.fangjia.service.address.AddressParserService; +import com.fangjia.service.address.AddressParserUtil; +import com.fangjia.service.address.mode.*; import com.fangjia.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchDistrictResult; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.mongo.bkoff.HouseLoudongService; +import com.fangjia.service.open.WaitCrawlKeywordsService; +import com.fangjia.service.sql.FjtEvaluationService; +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.util.*; /** * Created by wenyan on 2016/1/15. @@ -28,17 +26,97 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public static final int MIN_TIMEOUT = 1000 * 2; private final static String TOKEN = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; + private AddressParserService addressParserService; - public AddressMatchProxyServiceImpl(String apiHost) { + private HouseLoudongService houseLoudongService; + private FjtEvaluationService fjtEvaluationService; + private EvaluationService evaluationService; + private WaitCrawlKeywordsService waitCrawlKeywordsService; + + public AddressMatchProxyServiceImpl(String apiHost) { super(apiHost); } + private String realMatch(Map paramsMap) { + String address = paramsMap.get("address").toString(); + address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替 + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city")) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict")) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName")) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + if (paramsMap.containsKey("province")) { + params.setProvince(paramsMap.get("province").toString()); + } + if (paramsMap.containsKey("useMap")) { + params.setUseMap((Boolean) paramsMap.get("useMap")); + } + if (paramsMap.containsKey("debugName")) { + params.setDebugName(paramsMap.get("debugName").toString()); + } + if (paramsMap.containsKey("propertyType")) { + params.setPropertyType(paramsMap.get("propertyType").toString()); + } + long start = System.currentTimeMillis(); + Building building = addressParserService.parser(params); + long end = System.currentTimeMillis(); + if (end - start > 200) { + LOGGER.warn("匹配parser耗时:\t" + (end - start) + "ms"); + } + if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) { + verify(building); + } + JSONObject mav = new JSONObject(); + mav.put("viewType", "rest"); + mav.put("viewParam", new JSONObject().put("contentType", "application/json;charset=UTF-8")); + + JSONObject baseModel = new JSONObject(); + mav.put("model", baseModel); + + Map result = convertBuildingToMap(building); + if (paramsMap.containsKey("token") && !TOKEN.equals(paramsMap.get("token"))) { + submitFetchTask(building); + result.remove("precise"); + result.remove("searchAddress"); + result.remove("map"); + } + + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", result); + + return mav.toString(); + } + @Override public String parser(Map params) { params.put("token", TOKEN); long start = System.currentTimeMillis(); try { - String result = this.invoke("address/realMatch", params, "UTF-8"); + String result = realMatch(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -429,5 +507,121 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } - + + Map convertBuildingToMap(Building building) { + Map result = new LinkedHashMap(); + if (building != null) { + result.put("id", building.getId()); + result.put("credit", building.getCredit()); + result.put("precise", building.getPrecise()); + result.put("province", building.getProvince()); + result.put("city", building.getCity()); + result.put("district", building.getDistrict()); + result.put("name", building.getName()); + result.put("suggestName", building.getSuggestName()); + result.put("map", building.getMap()); + result.put("propertyType", building.getPropertyType()); + result.put("township", building.getTownship()); + result.put("suggestAddress", building.getSuggestAddress()); + if ("district".equals(building.getCategory())) { + result.put("category", "property"); + } else { + result.put("category", building.getCategory()); + } + result.put("address", building.getAddress()); + result.put("block", building.getBlock()); + result.put("lng", building.getLng()); + result.put("lat", building.getLat()); + result.put("alias", building.getAlias()); + result.put("searchAddress", building.getSearchAddress()); + } + return result; + } + + private void submitFetchTask(Building building) { + if (building.getPrecise() == -1) { + List keywords = new ArrayList(); + Address address = building.getSearchAddress(); + if (StringUtils.isNotBlank(address.getKeywords()) && address.getKeywords().length() > 2) { + keywords.add(address.getKeywords()); + } else if (address.getOrgAddress().length() > 2 && address.getOrgAddress().length() < 10) {// 一般小区名不会超过10个字 + keywords.add(address.getOrgAddress()); + } + if (address.isStandardAddress()) { + if (address.getStreetNumbers() != null) { + for (String b : address.getStreetNumbers()) { + keywords.add(address.getStreet() + b); + } + } else { + keywords.add(address.getStreet()); + } + } + keywords = DataUtil.uniqueList(keywords); + for (String k : keywords) { + WaitCrawlKeywords waitCrawlKeywords = new WaitCrawlKeywords(); + waitCrawlKeywords.setCity(address.getCity()); + waitCrawlKeywords.setDateCreated(new Date()); + waitCrawlKeywords.setRead(0); + waitCrawlKeywords.setKeywords(k); + waitCrawlKeywordsService.save(waitCrawlKeywords); + } + } + } + + private void verify(Building building) { + String city = building.getCity(); + String region = building.getDistrict(); + String name = null; + if (building.getPrecise() > -1) { + name = building.getName(); + } else { + name = building.getSearchAddress().getOrgKeywords(); + } + if (StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) { + String buildingNumber = AddressParserUtil + .standardizeBuildingNumber(building.getSearchAddress().getOrgBuildingNumber()); + if (buildingNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, buildingNumber, null, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, buildingNumber, + null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, buildingNumber, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } + } + + String roomNumber = AddressParserUtil.standardizeRoomNumber(building.getSearchAddress().getOrgRoomNumber()); + if (roomNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, null, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, null, + roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } + } + } + } + + public void setHouseLoudongService(HouseLoudongService houseLoudongService) { + this.houseLoudongService = houseLoudongService; + } + + public void setFjtEvaluationService(FjtEvaluationService fjtEvaluationService) { + this.fjtEvaluationService = fjtEvaluationService; + } + + public void setEvaluationService(EvaluationService evaluationService) { + this.evaluationService = evaluationService; + } + + public void setAddressParserService(AddressParserService addressParserService) { + this.addressParserService = addressParserService; + } + + public void setWaitCrawlKeywordsService(WaitCrawlKeywordsService waitCrawlKeywordsService) { + this.waitCrawlKeywordsService = waitCrawlKeywordsService; + } } From 9f5a53c49a45faef628fb0c90b53d985a510d31c Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 15 Apr 2025 10:23:17 +0800 Subject: [PATCH 009/121] =?UTF-8?q?=E6=88=BF=E6=BA=90=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E6=9F=A5=E8=87=AA=E8=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 54f39bfaf..6eec08f4b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -900,6 +900,13 @@ public class HouseController { List type2 = Arrays.asList("1", "0"); RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); + String city = model.getCity(); + String region = model.getRegion(); + String districtName = model.getName(); + if (StringUtils.isNotBlank(districtName) && (StringUtils.isBlank(city) || StringUtils.isBlank(region))) { + mav.setModel(BasicModel.buildBadRequestModel("city,region,name为一组参数")); + return mav; + } if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())) { mav.setModel(BasicModel.buildBadRequestModel("参数(locationType)有误")); return mav; @@ -984,22 +991,25 @@ public class HouseController { cat = "shop_sell"; } } - List houses = null; + List houses = new ArrayList(); + List houseSelf = new ArrayList(); + List houseAround =new ArrayList(); List houseList = new ArrayList(); // if (cat.contains("_")) { // 商铺,写字楼有经纬度,直接查 SeawaterQuery query = new SeawaterQuery(); - query.setLat(lat); - query.setLng(lng); + // 先用名字查自身的样本 + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(districtName); query.setCat(cat); - query.setRadius(model.getRadius()); query.setStartDate(model.getStartTime()); query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { query.setStartArea(model.getSize() * 0.9); query.setEndArea(model.getSize() * 1.1); } - query.setCityDisplay(model.getCity()); Pager pager = new Pager(); pager.setStartRow(0); if (model.getPageSize() != null && model.getPageSize() > 0) { @@ -1009,8 +1019,28 @@ public class HouseController { } query.setPager(pager); query.setTable("latest_seawater"); - houses = seawaterDao.findSeawatersByQuery(query); + houseSelf = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseSelf); + // 如果自身样本数不够,再查周边 + if (houseSelf != null && houseSelf.size() < pager.getPageSize()){ + query.setRegion(null); + query.setDistrictName(null); + query.setLat(lat); + query.setLng(lng); + query.setRadius(model.getRadius()); + houseAround = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseAround); + } if (houses != null && !houses.isEmpty()) { + Set seenIds = new HashSet(); + Iterator iterator = houses.iterator(); + while (iterator.hasNext()) { + Seawater s = iterator.next(); + if (!seenIds.add(s.getId())) { + // 如果已经存在,则从列表中移除 + iterator.remove(); + } + } for (Seawater house : houses) { Seawater seawater = new Seawater(); seawater.setId(house.getId()); From f254494fe72fe4758db22caf0e0cc1b0d6456108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:23:41 +0800 Subject: [PATCH 010/121] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/AddressMatchProxyServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 97e1a2ade..65e43b8b6 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -72,7 +72,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme params.setProvince(paramsMap.get("province").toString()); } if (paramsMap.containsKey("useMap")) { - params.setUseMap((Boolean) paramsMap.get("useMap")); + params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true); } if (paramsMap.containsKey("debugName")) { params.setDebugName(paramsMap.get("debugName").toString()); @@ -89,12 +89,8 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) { verify(building); } - JSONObject mav = new JSONObject(); - mav.put("viewType", "rest"); - mav.put("viewParam", new JSONObject().put("contentType", "application/json;charset=UTF-8")); JSONObject baseModel = new JSONObject(); - mav.put("model", baseModel); Map result = convertBuildingToMap(building); if (paramsMap.containsKey("token") && !TOKEN.equals(paramsMap.get("token"))) { @@ -108,7 +104,8 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme baseModel.put("msg", "ok"); baseModel.put("result", result); - return mav.toString(); + + return baseModel.toString(); } @Override From 8fa4d3565972db2df58b021581f20b239c95b0c1 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 15 Apr 2025 10:30:58 +0800 Subject: [PATCH 011/121] =?UTF-8?q?=E6=88=BF=E6=BA=90=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E6=8C=89=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E5=80=92?= =?UTF-8?q?=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/open/controllers/HouseController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 6eec08f4b..cc49ec68a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1018,6 +1018,8 @@ public class HouseController { pager.setPageSize(5); } query.setPager(pager); + query.setSortField("p_date"); + query.setOrder(false); query.setTable("latest_seawater"); houseSelf = seawaterDao.findSeawatersByQuery(query); houses.addAll(houseSelf); From eb782694ad0108943e1fc773dd9327c62da98743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:49:43 +0800 Subject: [PATCH 012/121] =?UTF-8?q?=E6=94=B9=E9=80=A0realMatchAll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 93 ++++++++++++++++--- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 65e43b8b6..f4df5ff9a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -108,6 +108,55 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return baseModel.toString(); } + public String realMatchAll(Map paramsMap) { + String address = paramsMap.get("address").toString();; + address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替 + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city")) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict")) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName")) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + + if (paramsMap.containsKey("province")) { + params.setProvince(paramsMap.get("province").toString()); + } + AddressParseResult addressParseResult = addressParserService.parserAll(params); + List buildings = addressParseResult.getBuildings(); + List> buildingObjs = new ArrayList>(buildings.size()); + for (Building building : buildings) { + buildingObjs.add(convertBuildingToMap(building)); + } + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", buildingObjs); + return baseModel.toString(); + } + @Override public String parser(Map params) { params.put("token", TOKEN); @@ -129,7 +178,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public String parserAll(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realMatchAll", params, "UTF-8"); + String result = realMatchAll(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -508,29 +557,49 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme Map convertBuildingToMap(Building building) { Map result = new LinkedHashMap(); if (building != null) { - result.put("id", building.getId()); + if (StringUtils.isNotBlank(building.getId())) { + result.put("id", building.getId()); + } result.put("credit", building.getCredit()); result.put("precise", building.getPrecise()); result.put("province", building.getProvince()); result.put("city", building.getCity()); result.put("district", building.getDistrict()); result.put("name", building.getName()); - result.put("suggestName", building.getSuggestName()); - result.put("map", building.getMap()); + if (StringUtils.isNotBlank(building.getSuggestName())) { + result.put("suggestName", building.getSuggestName()); + } + if (StringUtils.isNotBlank(building.getMap())) { + result.put("map", building.getMap()); + } result.put("propertyType", building.getPropertyType()); - result.put("township", building.getTownship()); - result.put("suggestAddress", building.getSuggestAddress()); + if (StringUtils.isNotBlank(building.getTownship())) { + result.put("township", building.getTownship()); + } + if (StringUtils.isNotBlank(building.getSuggestAddress())) { + result.put("suggestAddress", building.getSuggestAddress()); + } if ("district".equals(building.getCategory())) { result.put("category", "property"); } else { result.put("category", building.getCategory()); } - result.put("address", building.getAddress()); - result.put("block", building.getBlock()); - result.put("lng", building.getLng()); - result.put("lat", building.getLat()); - result.put("alias", building.getAlias()); - result.put("searchAddress", building.getSearchAddress()); + if (StringUtils.isNotBlank(building.getAddress())) { + result.put("address", building.getAddress()); + } + if (StringUtils.isNotBlank(building.getBlock())) { + result.put("block", building.getBlock()); + } + if (building.getLng() != null && building.getLat() != null) { + result.put("lng", building.getLng()); + result.put("lat", building.getLat()); + } + if (building.getAlias() != null) { + result.put("alias", building.getAlias()); + } + if (building.getSearchAddress() != null) { + result.put("searchAddress", building.getSearchAddress()); + } } return result; } From 9b5038e9e06028a16ab27f156ab1f244d869a13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 10:55:40 +0800 Subject: [PATCH 013/121] =?UTF-8?q?=E6=94=B9=E9=80=A0=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/AddressMatchProxyServiceImpl.java | 201 +++++++++++++++++- .../com/fangjia/service/dto/UniversalDto.java | 23 ++ 2 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index f4df5ff9a..6ece14e03 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -9,6 +9,7 @@ import com.fangjia.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchDistrictResult; import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.dto.UniversalDto; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.open.WaitCrawlKeywordsService; import com.fangjia.service.sql.FjtEvaluationService; @@ -186,11 +187,25 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String cleanCache(final Map paramsMap) { + + new Thread() { + @Override + public void run() { + addressParserService.clearCache((String) paramsMap.get("city")); + } + }.start(); + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "开始刷新缓存"); + return baseModel.toString(); + } + @Override public String cacheFlush(Map params){ params.put("token", TOKEN); try { - String result = this.invoke("address/cleanCache", params, "UTF-8"); + String result = cleanCache(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -198,11 +213,85 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realStandard(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Match); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { + matchParams.setProvince(paramsMap.get("province").toString()); + } + + matchParams.setUseAliyunApi(false); + matchParams.setContainsLocation("false".equals(paramsMap.get("containsLocation")) ? false : true); + Building building = addressParserService.standard(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + if (StringUtils.isBlank(building.getSuggestName())) { + if (StringUtils.isNotBlank(address.getParsedPropertyName())) { + dto.append("name", address.getParsedPropertyName()); + } else if (StringUtils.isNotBlank(address.getOrgKeywords())) { + dto.append("name", address.getOrgKeywords()); + } + } else { + dto.append("name", building.getSuggestName()); + } + if (StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())) { + String addr = building.getAddress(); + String street = AddressParserUtil.extractStreet(addr); + if (street != null) { + dto.append("street", street); + if (addr.length() != street.length()) { + dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr)); + } + } else if (StringUtils.isNotBlank(building.getStreet())) { + dto.append("street", building.getStreet()); + if (StringUtils.isNotBlank(building.getStreetno())) { + dto.append("streetNumber", building.getStreetno()); + } + } + } + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("floor", address.getFloor()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + if (matchParams.isContainsLocation()) { + dto.append("lat", building.getLat()); + dto.append("lng", building.getLng()); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String standard(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realStandard", params, "UTF-8"); + String result = realStandard(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -210,6 +299,48 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realCertificateAction(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + dto.append("name", building.getSuggestName()); + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + dto.append("certified", address.getCertified()); + dto.append("floor", address.getFloor()); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String certificate(Map params) { params.put("token", TOKEN); @@ -222,11 +353,75 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realAuth(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "地址不能为空"); + return baseModel.toString(); + } + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity((String) paramsMap.get("city")); + } + matchParams.setAddress((String) paramsMap.get("address")); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setUseMap(true); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + if (StringUtils.isNotBlank(address.getProvince())) { + dto.append("province", address.getProvince()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("city", address.getCity()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("district", address.getDistrict()); + } + if (StringUtils.isNotBlank(address.getDevelopmentZone())) { + dto.append("developmentZone", address.getDevelopmentZone()); + } + if (StringUtils.isNotBlank(address.getTownship())) { + dto.append("township", address.getTownship()); + } + if (StringUtils.isNotBlank(address.getStreet())) { + dto.append("street", address.getStreet()); + } + if (StringUtils.isNotBlank(address.getStreetNumber())) { + dto.append("streetNumber", address.getStreetNumber()); + } + if (StringUtils.isNotBlank(address.getBuildingNumber())) { + dto.append("buildingNumber", address.getBuildingNumber()); + } + if (StringUtils.isNotBlank(address.getUnitNumber())) { + dto.append("unitNumber", address.getUnitNumber()); + } + if (StringUtils.isNotBlank(address.getRoomNumber())) { + dto.append("roomNumber", address.getRoomNumber()); + } + if (StringUtils.isNotBlank(address.getFormattedAddress())) { + dto.append("formattedAddress", address.getFormattedAddress()); + } + List certified = address.getCertified(); + if (certified.contains("roomNumber")) { + dto.append("authLevel", "A"); + } else if (certified.contains("buildingNumber")) { + dto.append("authLevel", "B"); + } else { + dto.append("authLevel", "C"); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String auth(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realAuth", params, "UTF-8"); + String result = realAuth(params); return result; } catch (JSONException e) { LOGGER.error("", e); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java new file mode 100644 index 000000000..01fbb1490 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java @@ -0,0 +1,23 @@ +package com.fangjia.service.dto; + +import java.util.LinkedHashMap; + +/** + * 通用Dto,减少Dto的创建 + * @author 王文艳 + * @create 2016-10-08 + **/ +public class UniversalDto extends LinkedHashMap { + + + public static UniversalDto newDto(){ + return new UniversalDto(); + } + + public UniversalDto append(String key, Object value){ + this.put(key, value); + return this; + } + + +} From 1d6dbd0db3a3b5e8ae75376e23d242f9158d8ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 15 Apr 2025 13:45:28 +0800 Subject: [PATCH 014/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=A5=BC=E4=BC=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/model/SeawaterDto.java | 96 +++++++++++++++++++ .../open/controllers/OfficeController.java | 2 - .../controllers/OfficeSellController.java | 2 - .../service/datastore/OfficeServiceImpl.java | 62 ++++++++++-- .../datastore/dto/OfficeEvaluationDto.java | 31 +----- 5 files changed, 155 insertions(+), 38 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java new file mode 100644 index 000000000..408097537 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -0,0 +1,96 @@ +package com.fangjia.dal.seawater.model; + +public class SeawaterDto { + + private String city; + private String district; + private String name; + private String fitment; + private Double area; + private Double unitPrice; + private String publishDate; + private String floorInfo; + + private String estateType; + private String bedKind; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFitment() { + return fitment; + } + + public void setFitment(String fitment) { + this.fitment = fitment; + } + + public Double getArea() { + return area; + } + + public void setArea(Double area) { + this.area = area; + } + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public String getPublishDate() { + return publishDate; + } + + public void setPublishDate(String publishDate) { + this.publishDate = publishDate; + } + + public String getFloorInfo() { + return floorInfo; + } + + public void setFloorInfo(String floorInfo) { + this.floorInfo = floorInfo; + } + + public String getEstateType() { + return estateType; + } + + public void setEstateType(String estateType) { + this.estateType = estateType; + } + + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index 91d7f9a01..1a8370a0c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -280,7 +280,6 @@ public class OfficeController { districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); districtPriceMap.put("location", evaluation.getLocation()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); @@ -523,7 +522,6 @@ public class OfficeController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java index 00b0190b2..340914d13 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -288,7 +288,6 @@ public class OfficeSellController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOfficeSell()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { @@ -366,7 +365,6 @@ public class OfficeSellController { districtPriceMap.put("district", evaluation.getDistrict()); districtPriceMap.put("name", evaluation.getName()); districtPriceMap.put("samples", evaluation.getSeawater()); - districtPriceMap.put("refOffices", evaluation.getOffice()); districtPriceMap.put("location", evaluation.getLocation()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index b8f6cf578..5b46682f0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.mongo.model.OfficeSellStat; import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; @@ -366,6 +367,7 @@ public class OfficeServiceImpl implements OfficeService { String fitment = FITMENT_MAP.get(evaluation.getFitment()); String direction = DIRECTION_MAP.get(evaluation.getDirection()); + List seawaterDtoList = new ArrayList(); for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { Double price = Double.valueOf(seawater.getTotalPrice()); @@ -403,12 +405,14 @@ public class OfficeServiceImpl implements OfficeService { sum += price; size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, null); + seawaterDtoList.add(seawaterDto); } OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -429,17 +433,20 @@ public class OfficeServiceImpl implements OfficeService { OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + List seawaterList = new ArrayList(); if ("office_rent".equals(cat)) { for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -450,11 +457,13 @@ public class OfficeServiceImpl implements OfficeService { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { - Double unitPrice = DataUtil.roundDouble(sum / size, 2); + Double unitPrice = DataUtil.roundDouble(sum / size, 0); officeEvaluationDto.setUnitPrice(unitPrice); - officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setSeawater(seawaterList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -464,6 +473,25 @@ public class OfficeServiceImpl implements OfficeService { return officeEvaluationDto; } + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); + } + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; + } + @Override public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { @@ -514,6 +542,7 @@ public class OfficeServiceImpl implements OfficeService { sortParams.add(new SortParam("date", false)); List infos = officeRentStatDao.findAllByParams(params, sortParams, 5); + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isEmpty(infos)) { // 去掉类型,重新查找 params = new ArrayList(5); @@ -531,6 +560,15 @@ public class OfficeServiceImpl implements OfficeService { totalPrice += officeRentStat.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeRentStat.getCity()); + seawaterDto.setDistrict(officeRentStat.getDistrict()); + seawaterDto.setName(officeRentStat.getName()); + seawaterDto.setUnitPrice(officeRentStat.getAvgPrice()); + seawaterDto.setPublishDate(String.valueOf(officeRentStat.getDate())); + seawaterDto.setEstateType(officeRentStat.getEstateType2()); + seawaterDto.setBedKind(officeRentStat.getBedKind()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -544,7 +582,7 @@ public class OfficeServiceImpl implements OfficeService { } Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); officeEvaluationDto.setUnitPrice(avgPrice); - officeEvaluationDto.setOffice(infos); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); @@ -593,6 +631,7 @@ public class OfficeServiceImpl implements OfficeService { params.add(new QueryParam("date", Integer.parseInt(date))); infos = officeSellStatDao.findAllByParams(params, sortParams); } + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(infos)) { // 求均值 Double totalPrice = 0D; @@ -602,6 +641,15 @@ public class OfficeServiceImpl implements OfficeService { totalPrice += officeSellStat.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeSellStat.getCity()); + seawaterDto.setDistrict(officeSellStat.getDistrict()); + seawaterDto.setName(officeSellStat.getName()); + seawaterDto.setUnitPrice(officeSellStat.getAvgPrice().doubleValue()); + seawaterDto.setPublishDate(String.valueOf(officeSellStat.getDate())); + seawaterDto.setEstateType(officeSellStat.getEstateType2()); + seawaterDto.setBedKind(officeSellStat.getBedKind()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -613,9 +661,9 @@ public class OfficeServiceImpl implements OfficeService { if (evaluation.getDirection() != null) { factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); } - Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 0); officeEvaluationDto.setUnitPrice(avgPrice); - officeEvaluationDto.setOfficeSell(infos); + officeEvaluationDto.setSeawater(seawaterDtoList); officeEvaluationDto.setCity(evaluation.getCity()); officeEvaluationDto.setDistrict(evaluation.getRegion()); officeEvaluationDto.setName(evaluation.getDistrictName()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java index 8007a2221..0752ee8e3 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -1,9 +1,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; -import com.fangjia.dal.mongo.model.OfficeRentStat; -import com.fangjia.dal.mongo.model.OfficeSellStat; -import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import java.util.List; @@ -15,17 +13,12 @@ public class OfficeEvaluationDto extends Evaluation { private Double unitPrice; - private List seawater; - - private List office; - - private List officeSell; + private List seawater; private String district; private String name; - public Double getUnitPrice() { return unitPrice; } @@ -34,11 +27,11 @@ public class OfficeEvaluationDto extends Evaluation { this.unitPrice = unitPrice; } - public List getSeawater() { + public List getSeawater() { return seawater; } - public void setSeawater(List seawater) { + public void setSeawater(List seawater) { this.seawater = seawater; } @@ -57,20 +50,4 @@ public class OfficeEvaluationDto extends Evaluation { public void setName(String name) { this.name = name; } - - public List getOffice() { - return office; - } - - public void setOffice(List office) { - this.office = office; - } - - public List getOfficeSell() { - return officeSell; - } - - public void setOfficeSell(List officeSell) { - this.officeSell = officeSell; - } } From 5584cfc175fc2a7914b2adda7428957ee992a3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 09:45:53 +0800 Subject: [PATCH 015/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=BC=B0=E5=80=BCBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/AddressMatchProxyServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 6ece14e03..ce98de284 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -57,28 +57,28 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme preciseLevel = PreciseLevel.STRICT; } MatchParams params = new MatchParams(); - if (paramsMap.containsKey("city")) { + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { params.setCity(paramsMap.get("city").toString()); } - if (paramsMap.containsKey("suggestDistrict")) { + if (paramsMap.containsKey("suggestDistrict") && paramsMap.get("suggestDistrict") != null) { params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); } - if (paramsMap.containsKey("suggestName")) { + if (paramsMap.containsKey("suggestName") && paramsMap.get("suggestName") != null) { params.setSuggestName(paramsMap.get("suggestName").toString()); } params.setAddress(address); params.setBuildingType(buildingType); params.setPreciseLevel(preciseLevel); - if (paramsMap.containsKey("province")) { + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { params.setProvince(paramsMap.get("province").toString()); } - if (paramsMap.containsKey("useMap")) { + if (paramsMap.containsKey("useMap") && paramsMap.get("useMap") != null) { params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true); } - if (paramsMap.containsKey("debugName")) { + if (paramsMap.containsKey("debugName") && paramsMap.get("debugName") != null) { params.setDebugName(paramsMap.get("debugName").toString()); } - if (paramsMap.containsKey("propertyType")) { + if (paramsMap.containsKey("propertyType") && paramsMap.get("propertyType") != null) { params.setPropertyType(paramsMap.get("propertyType").toString()); } long start = System.currentTimeMillis(); From c666be742edad3343d1df67dd198a6f6749bbb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 10:08:26 +0800 Subject: [PATCH 016/121] =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=96=B0=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FangjiaOpenExceptionHandler.java | 13 +++++-------- .../interceptors/AuthenticationInterceptor.java | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 7848e9b25..cf8cf4e7c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -1,18 +1,15 @@ package com.fangjia.open.exceptionhander; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - import com.fangjia.core.util.DingDingMessageUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.ExceptionHandler; + +import javax.servlet.ServletException; +import java.io.IOException; import java.net.Inet4Address; +import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; @@ -26,7 +23,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { ActionContext context = ActionContext.getContext(); String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!"); } catch (Exception e1) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index c04cab406..98784a878 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -109,9 +109,9 @@ public class AuthenticationInterceptor implements Interceptor { } } catch (Exception e) { String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { - DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication error!"); + DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication 错误!"); } catch (Exception e1) { e1.printStackTrace(); } From e78f569e882ce48527f481e0585885cce31f8081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 14:36:46 +0800 Subject: [PATCH 017/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E9=93=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=8E=E5=86=99=E5=AD=97=E6=A5=BC=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/AiShopServiceImpl.java | 91 ++++++++----------- .../datastore/dto/ShopEvaluationDto.java | 8 +- 2 files changed, 44 insertions(+), 55 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 6b65b649a..3c167db91 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.ShopRentStat; import com.fangjia.dal.mongo.model.ShopSellStat; import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import com.fangjia.service.datastore.dto.ShopEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; @@ -204,53 +205,23 @@ public class AiShopServiceImpl implements AiShopService { return getShopEvaluationDto(seawaters, evaluation, cat); } - /** - * 基准价*楼层系数*装修系数*朝向系数 - * - * @param seawaters - * @param evaluation - * @return - */ - private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { - Double sum = 0.0; - Double size = 0.0; - - String fitment = FITMENT_MAP.get(evaluation.getFitment()); - String direction = DIRECTION_MAP.get(evaluation.getDirection()); - for (Seawater seawater : seawaters) { - if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { - Double price = Double.valueOf(seawater.getTotalPrice()); - // 装修 - if (seawater.getFitment() != null) { - try { - price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); - } catch (Exception ex) { - - } - } - // 朝向 - if (seawater.getDirection() != null) { - try { - price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); - } catch (Exception ex) { - - } - } - - sum += price; - size += seawater.getArea(); - } + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); } - ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); - if (size > 0) { - Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); - shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); - shopEvaluationDto.setCity(evaluation.getCity()); - shopEvaluationDto.setDistrict(evaluation.getRegion()); - shopEvaluationDto.setName(evaluation.getDistrictName()); - } - return shopEvaluationDto; + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; } /** @@ -266,17 +237,20 @@ public class AiShopServiceImpl implements AiShopService { ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + List seawaterList = new ArrayList(); if ("shop_rent".equals(cat)) { for (Seawater seawater : seawaters) { if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setSeawater(seawaterList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -287,11 +261,13 @@ public class AiShopServiceImpl implements AiShopService { sum += seawater.getTotalPrice(); size += seawater.getArea(); } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); } if (size > 0) { Double unitPrice = DataUtil.roundDouble(sum / size, 2); shopEvaluationDto.setUnitPrice(unitPrice); - shopEvaluationDto.setSeawater(seawaters); + shopEvaluationDto.setSeawater(seawaterList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -351,15 +327,24 @@ public class AiShopServiceImpl implements AiShopService { query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; int count = 0; for (Seawater seawater : shops) { if (seawater.getAvgPrice() != null) { - totalPrice += seawater.getAvgPrice(); + totalPrice += seawater.getDayUnitPrice(); count += 1; } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getDistrict()); + seawaterDto.setName(seawater.getName()); + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + seawaterDto.setPublishDate(String.valueOf(seawater.getPublishDate())); + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -370,7 +355,7 @@ public class AiShopServiceImpl implements AiShopService { } Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); shopEvaluationDto.setUnitPrice(avgPrice); - shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setSeawater(seawaterDtoList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); @@ -401,6 +386,8 @@ public class AiShopServiceImpl implements AiShopService { query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); + + List seawaterDtoList = new ArrayList(); if (CollectionUtils.isNotEmpty(shops)) { // 求均值 Double totalPrice = 0D; @@ -410,6 +397,8 @@ public class AiShopServiceImpl implements AiShopService { totalPrice += seawater.getAvgPrice(); count += 1; } + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_sell"); + seawaterDtoList.add(seawaterDto); } Double factor = 1.0; if (evaluation.getFitment() != null) { @@ -420,7 +409,7 @@ public class AiShopServiceImpl implements AiShopService { } int avgPrice = (int) (totalPrice / count * factor); shopEvaluationDto.setUnitPrice((double) avgPrice); - shopEvaluationDto.setSeawater(shops); + shopEvaluationDto.setSeawater(seawaterDtoList); shopEvaluationDto.setCity(evaluation.getCity()); shopEvaluationDto.setDistrict(evaluation.getRegion()); shopEvaluationDto.setName(evaluation.getDistrictName()); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java index 60432aa1f..14f9def80 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java @@ -1,7 +1,7 @@ package com.fangjia.service.datastore.dto; import com.fangjia.dal.mongo.model.Evaluation; -import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; import java.util.List; @@ -13,7 +13,7 @@ public class ShopEvaluationDto extends Evaluation { private Double unitPrice; - private List seawater; + private List seawater; private String district; @@ -28,11 +28,11 @@ public class ShopEvaluationDto extends Evaluation { this.unitPrice = unitPrice; } - public List getSeawater() { + public List getSeawater() { return seawater; } - public void setSeawater(List seawater) { + public void setSeawater(List seawater) { this.seawater = seawater; } From feb6543188efbc427662a8473d76c47afa8328a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 16 Apr 2025 14:42:31 +0800 Subject: [PATCH 018/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E9=93=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=8E=E5=86=99=E5=AD=97=E6=A5=BC=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/service/datastore/AiShopServiceImpl.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 3c167db91..0998d0437 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -209,7 +209,7 @@ public class AiShopServiceImpl implements AiShopService { SeawaterDto seawaterDto = new SeawaterDto(); seawaterDto.setCity(seawater.getCity()); seawaterDto.setDistrict(seawater.getRegion()); - seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setName(seawater.getName()); seawaterDto.setArea(seawater.getArea()); seawaterDto.setFitment(seawater.getFitment()); if (cat != null && cat.contains("rent")) { @@ -337,13 +337,7 @@ public class AiShopServiceImpl implements AiShopService { totalPrice += seawater.getDayUnitPrice(); count += 1; } - SeawaterDto seawaterDto = new SeawaterDto(); - seawaterDto.setCity(seawater.getCity()); - seawaterDto.setDistrict(seawater.getDistrict()); - seawaterDto.setName(seawater.getName()); - seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); - seawaterDto.setPublishDate(String.valueOf(seawater.getPublishDate())); - seawaterDto.setEstateType(seawater.getEstateType()); + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_rent"); seawaterDtoList.add(seawaterDto); } Double factor = 1.0; From fe8564d120dcb365dd4d3b9699f8b7ff6a4bfacd Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Wed, 16 Apr 2025 18:32:20 +0800 Subject: [PATCH 019/121] =?UTF-8?q?=E4=BF=AE=E6=94=B9MongoDB=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/core/util/MongoUtils.java | 3 + .../com/fangjia/open/controllers/Test.java | 190 ------------------ .../InsertMonitorCalcCommandBatch.groovy | 13 +- .../index/AutocompleteDataUpdaterBatch.groovy | 2 - .../fangjia/script/util/CommonUtils.groovy | 2 +- .../fangjia/script/util/ServerAreaMap.groovy | 3 +- .../fangjia/script/wenyan/ScriptFour.groovy | 27 ++- .../com/fangjia/script/wenyan/WeiXin.groovy | 59 +----- 8 files changed, 33 insertions(+), 266 deletions(-) delete mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/controllers/Test.java diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/MongoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/MongoUtils.java index 344695ec0..1181f3e63 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/MongoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/MongoUtils.java @@ -78,4 +78,7 @@ public class MongoUtils { } return conn; } + + + } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/Test.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/Test.java deleted file mode 100644 index e03484f3e..000000000 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/Test.java +++ /dev/null @@ -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 map = senRequest("江苏省泰州市靖江市通江路37号", "1"); -// System.out.println(map); -// -// } -// -// private static Map senRequest(String address, String type) throws IOException { -// String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; -// String proxyHost = "tunnel2.qg.net"; -// int proxyPort = 14186; -// final String proxyUsername = "113BBC06"; -// final String proxyPassword = "3B2FBD05B0AF"; -// String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; -// String authKey = proxyUsername; -// String password = proxyPassword; -// String auth = authKey + ":" + password; -// String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); -// -// 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 dataMap = new HashMap(); -// -// // 获取各个值并放入 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; -// } -//} -// diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/averager/InsertMonitorCalcCommandBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/averager/InsertMonitorCalcCommandBatch.groovy index 6535775fb..1ae1b4767 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/averager/InsertMonitorCalcCommandBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/averager/InsertMonitorCalcCommandBatch.groovy @@ -2,6 +2,7 @@ package com.fangjia.script.averager import com.fangjia.core.util.DataUtil import com.fangjia.core.util.DateUtil +import com.fangjia.core.util.MongoUtils import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DataStore @@ -9,14 +10,11 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher import com.fangjia.script.cover.EmailTemplate -import com.fangjia.script.jms.QueueRedirectConsumer import com.fangjia.script.util.Jms -import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ServerAreaMap import com.google.common.collect.MapDifference import com.google.common.collect.Maps import com.mongodb.* -import org.bson.Document 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 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 REGION_STAT_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia').getCollection('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 REGION_STAT_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_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 def WORKER_MACHINE_IPS = ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1","fangjia-priceanalysis-2"] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/AutocompleteDataUpdaterBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/AutocompleteDataUpdaterBatch.groovy index 59365a6a6..dc27d88f4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/AutocompleteDataUpdaterBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/AutocompleteDataUpdaterBatch.groovy @@ -64,8 +64,6 @@ class AutocompleteDataUpdaterBatch extends BaseBatch { DSCursor cur = SEAWEED_COLL.find(q, fields).batchSize(2000) Iterator iter = cur.iterator() int i = 0 - - Map keywordMap = new HashMap() while(iter.hasNext()) { i++ if(i % 100 == 0) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy index ac9704830..fd4d3a323 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy @@ -245,7 +245,7 @@ public class CommonUtils { data.put("remark", 'week') data.put("c_date", new Date()) 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) }else{ data.put("ip", ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1"][new Random().nextInt(2)]) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ServerAreaMap.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ServerAreaMap.groovy index ae9d1fcc2..649a85f95 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ServerAreaMap.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ServerAreaMap.groovy @@ -4,6 +4,7 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBCursor import com.mongodb.DBObject +import com.fangjia.core.util.MongoUtils /** * Created by dxy on 2015/9/14. @@ -43,7 +44,7 @@ public class ServerAreaMap { } 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; if(q != null) { cur = collection.find(q) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/ScriptFour.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/ScriptFour.groovy index 2c873d35b..a6a0cbaa4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/ScriptFour.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/ScriptFour.groovy @@ -1,14 +1,19 @@ package com.fangjia.script.wenyan -import com.fangjia.core.RegionData -import com.fangjia.script.util.ElasticUtils -def citys = ["北京", "唐山", "天津", "秦皇岛", "石家庄", "包头", "太原", "丹东", "呼和浩特", "锦州", "沈阳", "吉林", "大连", "牡丹江", "长春", "无锡", "哈尔滨", "扬州", "上海", "徐州", "南京", "温州", "杭州", "金华", "宁波", "蚌埠", "合肥", "安庆", "福州", "泉州", "厦门", "九江", "南昌", "赣州", "济南", "烟台", "青岛", "济宁", "郑州", "洛阳", "武汉", "平顶山", "长沙", "宜昌", "广州", "襄阳", "深圳", "岳阳", "南宁", "常德", "海口", "惠州", "重庆", "湛江", "成都", "韶关", "贵阳", "桂林", "昆明", "北海", "西安", "三亚", "兰州", "泸州", "西宁", "南充", "银川", "遵义", "乌鲁木齐", "大理", "北京", "上海", "广州", "深圳", "重庆", "郑州", "长沙", "西安", "成都", "东莞", "佛山", "杭州", "合肥", "南京", "青岛", "沈阳", "苏州", "天津", "武汉", "珠海", "中山", "长春", "扬州", "烟台", "徐州", "无锡", "温州", "太原", "台州", "石家庄", "绍兴", "厦门", "泉州", "宁波", "南通", "南宁", "南昌", "兰州", "常州", "大连", "福州", "贵阳", "哈尔滨", "海口", "惠州", "济南", "嘉兴", "金华", "昆明", "遵义", "淄博", "株洲", "镇江", "肇庆", "漳州", "湛江", "岳阳", "银川", "宜昌", "盐城", "芜湖", "乌鲁木齐", "唐山", "泰州", "汕头", "三亚", "清远", "秦皇岛", "马鞍山", "洛阳", "柳州", "连云港", "廊坊", "九江", "吉林", "淮安", "湖州", "呼和浩特", "沧州", "保定", "安庆", "张家口", "西宁", "日照", "拉萨", "锦州", "大同", "常德", "北海", "文昌", "陵水", "保亭"] -citys.unique() -citys.each { def city -> - if (RegionData.isCity(city)) { - ElasticUtils.executeSqlQuery("select count(*) as count from seawater where p_date > 20210407 and city='${city}'", { - println("$city\t${it.count}") - }) - } -} \ No newline at end of file +import org.apache.commons.mail.SimpleEmail + +import javax.mail.internet.MimeUtility + +EMAIL_SERVER = "smtp.exmail.qq.com" +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(); \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/WeiXin.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/WeiXin.groovy index cd8c7f970..6ad14d4d6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/WeiXin.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/WeiXin.groovy @@ -1,62 +1,11 @@ package com.fangjia.script.wenyan -import com.fangjia.core.util.DateUtil -import com.fangjia.core.util.Mongo3Utils +import com.fangjia.script.util.CommonUtils import com.fangjia.script.util.DbUtils 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 GUIDING_PRICE = Mongo3Utils.getDbCollection("fangjia", "guiding_price") -// -//Mongo3Utils.getDbCollection("fangjia", "confirm_price_data").find(new BasicDBObject("isGuidancePrice", 0)).each { Document doc-> -// 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 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}") +ExcelUtils.read("C:\\Users\\goojia\\Downloads\\财力评级测试模板.xlsx",1).each { + def one = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(it['B'], it['C'], it['D'])) + println("${one.lng/10000000000},${one.lat/10000000000}") } - - - From 47aa262f137e758869c19599b730e1b157258192 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Thu, 17 Apr 2025 10:17:19 +0800 Subject: [PATCH 020/121] =?UTF-8?q?=E5=95=86=E9=93=BA=E6=A0=B7=E6=9C=AC?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/dal/seawater/model/SeawaterDto.java | 10 ++++++++++ .../fangjia/service/datastore/AiShopServiceImpl.java | 1 + 2 files changed, 11 insertions(+) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java index 408097537..f133f21e7 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -14,6 +14,8 @@ public class SeawaterDto { private String estateType; private String bedKind; + private String address; + public String getCity() { return city; } @@ -93,4 +95,12 @@ public class SeawaterDto { public void setBedKind(String bedKind) { this.bedKind = bedKind; } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 0998d0437..e363f4337 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -221,6 +221,7 @@ public class AiShopServiceImpl implements AiShopService { seawaterDto.setBedKind(seawater.getLevel()); seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); seawaterDto.setFloorInfo(seawater.getFloorInfo()); + seawaterDto.setAddress(seawater.getAddress()); return seawaterDto; } From f0adaa105092f053f00b7e6080c83c6005b0b98a Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 17 Apr 2025 10:29:04 +0800 Subject: [PATCH 021/121] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E6=8A=A5=E9=94=99=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fangjia/core/util/DataUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java index 68961d219..ffaeaceaf 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java @@ -1036,6 +1036,7 @@ public class DataUtil { keyword = DataUtil.toDBCcase(keyword.replace(";", " ")); keyword = keyword.replaceAll(SPACIAL_PATTERN, ""); // keyword = QueryParser.escape(keyword.trim()).trim(); + keyword = keyword.replace("\"", ""); keyword = keyword.trim(); for (String reservedWord : new String[] { "AND", "OR" }) { if (keyword.contains(reservedWord)) { From 375ae01b65f36ea957a2f596bd8d5613421d05bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 17 Apr 2025 14:43:01 +0800 Subject: [PATCH 022/121] =?UTF-8?q?'=E4=BC=98=E5=8C=96=E9=83=A8=E7=BD=B2'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deliverables/k8s/fangjia-open.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deliverables/k8s/fangjia-open.yaml b/deliverables/k8s/fangjia-open.yaml index 09660e137..b05a98219 100644 --- a/deliverables/k8s/fangjia-open.yaml +++ b/deliverables/k8s/fangjia-open.yaml @@ -21,6 +21,15 @@ spec: project: fangjia-open app: fangjia spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: NotIn + values: + - "sha-216" imagePullSecrets: - name: nexus-registry-secret containers: From 9582a20d3933cda8f50b803f6afa720d534aac07 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 17 Apr 2025 15:10:13 +0800 Subject: [PATCH 023/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=88=BF=E6=BA=90BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/HouseController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index cc49ec68a..945ab4e5b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -993,7 +993,7 @@ public class HouseController { } List houses = new ArrayList(); List houseSelf = new ArrayList(); - List houseAround =new ArrayList(); + List houseAround = new ArrayList(); List houseList = new ArrayList(); // if (cat.contains("_")) { // 商铺,写字楼有经纬度,直接查 @@ -1021,10 +1021,12 @@ public class HouseController { query.setSortField("p_date"); query.setOrder(false); query.setTable("latest_seawater"); - houseSelf = seawaterDao.findSeawatersByQuery(query); - houses.addAll(houseSelf); + if (StringUtils.isNotBlank(city) && StringUtils.isNotBlank(region) && StringUtils.isNotBlank(districtName)) { + houseSelf = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseSelf); + } // 如果自身样本数不够,再查周边 - if (houseSelf != null && houseSelf.size() < pager.getPageSize()){ + if (houseSelf != null && houseSelf.size() < pager.getPageSize()) { query.setRegion(null); query.setDistrictName(null); query.setLat(lat); From 7aaf4a86a39c35bf47770e530d71e847233b406e Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 21 Apr 2025 15:02:59 +0800 Subject: [PATCH 024/121] =?UTF-8?q?=E5=8C=97=E4=BA=A4=E6=89=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 2 +- .../java/com/fangjia/open/model/HouseInfomationModel.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index e0d0fddff..52ee0ac44 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -223,7 +223,7 @@ public class ComprehensiveQueryController { HouseValueInformationDto houseValueInformation = new HouseValueInformationDto(); RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(String.valueOf(model.getSize()))) { + if (StringUtils.isBlank(model.getAddress()) || model.getSize() == null) { mav.setModel(BasicModel.buildBadRequestModel("地址(address),面积(size)为必填字段")); return mav; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseInfomationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseInfomationModel.java index 52cbca930..22e0b8ec4 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseInfomationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseInfomationModel.java @@ -58,7 +58,7 @@ public class HouseInfomationModel extends FangjiaApiModel { /** * 面积 */ - private double size; + private Double size; /** * 所在楼层 @@ -402,11 +402,11 @@ public class HouseInfomationModel extends FangjiaApiModel { this.roomNumber = roomNumber; } - public double getSize() { + public Double getSize() { return size; } - public void setSize(double size) { + public void setSize(Double size) { this.size = size; } From 7479a31196a9cd1e9170a26ea2cd95b43233c880 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Mon, 21 Apr 2025 16:02:09 +0800 Subject: [PATCH 025/121] =?UTF-8?q?=E4=BF=AE=E6=94=B9MongoDB=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/spring-dal-datastore.xml | 8 ++++---- .../src/main/resources/spring-dal-mongo.xml | 16 ++++++++-------- .../datastore/CzbankSampleServiceImpl.java | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml b/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml index 66296c0eb..a86e1ae67 100644 --- a/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml +++ b/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/projects/fangjia-open/src/main/resources/spring-dal-mongo.xml b/projects/fangjia-open/src/main/resources/spring-dal-mongo.xml index fcbbb77ee..6a863efeb 100644 --- a/projects/fangjia-open/src/main/resources/spring-dal-mongo.xml +++ b/projects/fangjia-open/src/main/resources/spring-dal-mongo.xml @@ -66,12 +66,12 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index 8cdd9018a..30b3d436c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -1760,7 +1760,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; } - public void setSeawaterDao(SeawaterDao seawaterDao) { - this.seawaterDao = seawaterDao; - } +// public void setSeawaterDao(SeawaterDao seawaterDao) { +// this.seawaterDao = seawaterDao; +// } } From b7693172a4325201875022566c660f64647efb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 21 Apr 2025 16:08:26 +0800 Subject: [PATCH 026/121] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/FilesController.java | 3 ++- .../java/com/fangjia/open/model/FilesModel.java | 12 ++++++++++++ .../main/java/com/fangjia/open/util/FileDao.java | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FilesController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FilesController.java index 69844d85b..885fc5381 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FilesController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FilesController.java @@ -71,7 +71,8 @@ public class FilesController { if(StringUtils.isNotBlank(model.getFilename())){ filename = model.getFilename(); } - GridFSInputFile gridFSInputFile = fileDao.saveToGridFs(file.getInputStream(), filename, contentType); + String type = model.getType(); + GridFSInputFile gridFSInputFile = fileDao.saveToGridFs(file.getInputStream(), filename, contentType, type); UniversalDto dto = UniversalDto.newDto(); if(OpenConfig.getConfig().isProductionEnvironment()){ dto.append("link", "http://static.fangjia.com/stc/files/" + gridFSInputFile.get("_id").toString()); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/FilesModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/FilesModel.java index 50bd904cd..30908c9dd 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/FilesModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/FilesModel.java @@ -7,6 +7,10 @@ public class FilesModel extends FangjiaApiModel { private MultipartFile file; private String contentType; private String filename; + /** + * 文件类型 + */ + private String type; public MultipartFile getFile() { return file; @@ -31,4 +35,12 @@ public class FilesModel extends FangjiaApiModel { public void setFilename(String filename) { this.filename = filename; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java index be6fa3e75..76cc1dbbf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java @@ -8,6 +8,7 @@ import com.mongodb.gridfs.GridFS; import com.mongodb.gridfs.GridFSDBFile; import com.mongodb.gridfs.GridFSInputFile; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; import org.bson.types.ObjectId; import java.io.InputStream; @@ -70,6 +71,18 @@ public class FileDao { return fsInputFile; } + public GridFSInputFile saveToGridFs(InputStream inputStream, String filename, String contentType, String type){ + GridFSInputFile fsInputFile = gridFs.createFile(inputStream, filename); + fsInputFile.put("contentType", contentType); + if (StringUtils.isNotBlank(type)){ + fsInputFile.put("type", type); + } else { + fsInputFile.put("type", "default"); + } + fsInputFile.save(); + return fsInputFile; + } + public GridFSDBFile findByIdInGridFS(String id){ return gridFs.findOne(new ObjectId(id)); } From 711d09991b4f1fa5e71a323b489d6dcff36c08e0 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 21 Apr 2025 17:08:29 +0800 Subject: [PATCH 027/121] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=8A=A0=E8=B4=9D=E5=A3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/WeiXinEvaluationController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index a98ea59a0..c12665d2e 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -780,6 +780,7 @@ public class WeiXinEvaluationController { dataMap.put("fjw", averageStatistics.getFangjiaPrice()); dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + dataMap.put("beike", averageStatistics.getBeikeEsfPrice()); } } jsonMmodel.setJsonModel(dataMap); From aedef2144b217d5adf58742ba001fe4dbc188b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 21 Apr 2025 17:20:55 +0800 Subject: [PATCH 028/121] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fangjia/open/util/FileDao.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java index 76cc1dbbf..ffa12eaf4 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java @@ -75,9 +75,9 @@ public class FileDao { GridFSInputFile fsInputFile = gridFs.createFile(inputStream, filename); fsInputFile.put("contentType", contentType); if (StringUtils.isNotBlank(type)){ - fsInputFile.put("type", type); + fsInputFile.put("t", type); } else { - fsInputFile.put("type", "default"); + fsInputFile.put("t", "default"); } fsInputFile.save(); return fsInputFile; From e4474b48e7fcdac7ed44c04baa3434e4c229c232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 21 Apr 2025 18:22:16 +0800 Subject: [PATCH 029/121] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=A9=E7=95=A5?= =?UTF-8?q?=E5=9B=BE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/stc/FileDao.java | 4 +-- .../main/java/com/fangjia/stc2/FileDao.java | 4 +-- .../java/com/fangjia/stc2/GridFsServlet.java | 28 ++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-static/src/main/java/com/fangjia/stc/FileDao.java b/projects/fangjia-static/src/main/java/com/fangjia/stc/FileDao.java index 473952d9b..64b1e911f 100644 --- a/projects/fangjia-static/src/main/java/com/fangjia/stc/FileDao.java +++ b/projects/fangjia-static/src/main/java/com/fangjia/stc/FileDao.java @@ -55,9 +55,9 @@ public class FileDao { FIELDS.put("content_type", 1); FIELDS.put("a_date", 1); try { - Mongo mongo = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27017)); + Mongo mongo = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27000)); db = mongo.getDB("fangjia_fs"); - mongo = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27017)); + mongo = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27000)); cappedFsDb = mongo.getDB("fangjia_fs"); } catch (Exception e) { diff --git a/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java b/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java index 9b22b5672..b2d32638b 100644 --- a/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java +++ b/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java @@ -37,9 +37,9 @@ public class FileDao { IMPORTANT_CATEGORY = Arrays.asList(System.getProperty("fangjia.important.category", "district,shop,office,avatar,flash,user_house,upload,news,attachment").split(",")); try { - filesCollection = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27017)).getDB("fangjia").getCollection("files"); + filesCollection = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27000)).getDB("fangjia").getCollection("files"); gridFs = new GridFS(filesCollection.getDB(), "fangjia"); - cappedCollection = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27017)).getDB("fangjia_fs").getCollection("files_capped"); + cappedCollection = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27000)).getDB("fangjia_fs").getCollection("files_capped"); } catch (Exception e) { e.printStackTrace(); } diff --git a/projects/fangjia-static/src/main/java/com/fangjia/stc2/GridFsServlet.java b/projects/fangjia-static/src/main/java/com/fangjia/stc2/GridFsServlet.java index a1ad4f1ea..1f33fefb0 100644 --- a/projects/fangjia-static/src/main/java/com/fangjia/stc2/GridFsServlet.java +++ b/projects/fangjia-static/src/main/java/com/fangjia/stc2/GridFsServlet.java @@ -1,17 +1,22 @@ package com.fangjia.stc2; +import java.awt.*; +import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Date; +import java.util.zip.GZIPOutputStream; +import javax.imageio.ImageIO; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +68,28 @@ public class GridFsServlet extends HttpServlet { resp.getOutputStream().flush();*/ OutputStream out = resp.getOutputStream(); try { - gridFSDBFile.writeTo(out); + // 压缩返回流 + String size = req.getParameter("size"); + // 如果有size参数(如"100x90"),则进行图片尺寸调整 + if (StringUtils.isNotBlank(size)) { + // 1. 解析尺寸参数(格式如 "100x90") + String[] dimensions = size.split("\\*"); + int width = Integer.parseInt(dimensions[0]); + int height = Integer.parseInt(dimensions[1]); + + // 2. 将GridFS文件读入内存作为BufferedImage + BufferedImage originalImage = ImageIO.read(gridFSDBFile.getInputStream()); + + // 3. 创建缩放后的图片 + BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g = resizedImage.createGraphics(); + g.drawImage(originalImage.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null); + g.dispose(); + // 5. 输出调整后的图片 + ImageIO.write(resizedImage, "JPEG", out); // 根据实际格式调整 + } else { + gridFSDBFile.writeTo(out); + } } catch (Exception e) { logger.error("", e); } finally { From 1e7807f99d489df8d9491c23f43a988e478c78bd Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Wed, 23 Apr 2025 15:44:38 +0800 Subject: [PATCH 030/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/DistrictController.java | 34 ++++++------------- .../index/DistrictTriggerServiceImpl.java | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index 17ab2c4b2..e2b80dddd 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -1,10 +1,12 @@ package com.fangjia.open.controllers.weixin; -import com.fangjia.core.util.*; +import com.fangjia.core.util.CacheUtils; import com.fangjia.core.util.CacheUtils.CachePolicyEnum; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; +import com.fangjia.core.util.GeocodeUtils; import com.fangjia.dal.QueryParam; import com.fangjia.dal.SdQuery; -import com.fangjia.dal.SrQuery; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.mongo.model.SeaweedImages; import com.fangjia.dal.seaweed.model.District; @@ -12,7 +14,6 @@ import com.fangjia.dal.sql.model.FjtUsers; import com.fangjia.open.compatible.model.JsonModel; import com.fangjia.open.model.weixin.DistrictModel; import com.fangjia.open.model.weixin.DistrictSearchModel; -import com.fangjia.open.util.BHBankUtils; import com.fangjia.service.api.AutoCompleteBo; import com.fangjia.service.bo.DistrictStatBo; import com.fangjia.service.bo.DistrictStatRentBo; @@ -24,21 +25,16 @@ import com.fangjia.service.sql.FjtUsersService; import com.fangjia.service.sql.UserCityService; import com.fangjia.service.user.UsersInfoService; import com.fangjia.service.util.CookieUtils; -import com.google.common.collect.Lists; - -import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.TermQuery; import org.sothis.web.mvc.annotation.Param; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; public class DistrictController { @@ -114,17 +110,7 @@ public class DistrictController { params.add(new QueryParam("city", city)); params.add(new QueryParam("category", cat)); params.add(new QueryParam("visible", 0)); - - - BooleanQuery srQuery1 = new BooleanQuery(); - BooleanQuery nameQuery = new BooleanQuery(); - // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); - nameQuery.add(new TermQuery(new Term("keyword", keyword)), BooleanClause.Occur.SHOULD); - //nameQuery.add(new TermQuery(new Term("keyword_cjk", keyword)), BooleanClause.Occur.SHOULD);//这个重要,因seaweed不支持模糊搜索,当输入"中远两"需用此进行搜索 - srQuery1.add(nameQuery, BooleanClause.Occur.SHOULD); + params.add(new QueryParam("$srByStr", String.format("keyword:%s^6.0 OR keyword_cjk:%s", keyword, keyword))); if (lat != null && lng != null && lat != 0 && lng != 0) { Map geo = GeocodeUtils.geoconvBaiduToGoogle(lng, lat); SdQuery sdQuery = new SdQuery(); @@ -133,7 +119,7 @@ public class DistrictController { sdQuery.setDistance("500"); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); } - params.add(new QueryParam("$sr", new SrQuery(srQuery1))); + List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias", "id", "alias"}); List ret = new ArrayList(districts.size()); for (District district : districts) { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/index/DistrictTriggerServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/index/DistrictTriggerServiceImpl.java index 9abc4273b..c2e754a0e 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/index/DistrictTriggerServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/index/DistrictTriggerServiceImpl.java @@ -183,7 +183,7 @@ public class DistrictTriggerServiceImpl implements TriggerService { (String)object.get("address"), (List)newObj.get("alias"), (List)newObj.get("addr_alias"), - addressNum, block + addressNum, null ) ); From 0dc83b9be116f7077e6f543968746bbd3230031e Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Wed, 23 Apr 2025 15:54:15 +0800 Subject: [PATCH 031/121] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E9=93=BA?= =?UTF-8?q?=E7=A7=9F=E9=87=91=E8=B5=B0=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/dal/seawater/model/SeawaterDto.java | 10 ++++++++++ .../fangjia/service/datastore/AiShopServiceImpl.java | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java index f133f21e7..e01d2e515 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -16,6 +16,8 @@ public class SeawaterDto { private String address; + private String districtName; + public String getCity() { return city; } @@ -103,4 +105,12 @@ public class SeawaterDto { public void setAddress(String address) { this.address = address; } + + public String getDistrictName() { + return districtName; + } + + public void setDistrictName(String districtName) { + this.districtName = districtName; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index e363f4337..245dcfccd 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -222,6 +222,7 @@ public class AiShopServiceImpl implements AiShopService { seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); seawaterDto.setFloorInfo(seawater.getFloorInfo()); seawaterDto.setAddress(seawater.getAddress()); + seawaterDto.setDistrictName(seawater.getDistrictName()); return seawaterDto; } @@ -299,7 +300,7 @@ public class AiShopServiceImpl implements AiShopService { @Override public List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { - return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + return CacheUtils.getValue(this.getClass(), "findShopSellStat", city + region + name + startDate + endDate, CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { public List execute(String input) { return doFindShopSellStat(city, region, name, cat, startDate, endDate); From 9c05483326154d80c822c359e47be4446b45d720 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Wed, 23 Apr 2025 17:07:18 +0800 Subject: [PATCH 032/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dseawater=E5=81=9C?= =?UTF-8?q?=E6=9C=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/spring-dal-datastore.xml | 1 - .../src/main/java/com/fangjia/dal/SeawaterDaoImpl.java | 6 +++--- .../fangjia-open/src/main/resources/spring-dal-mongo.xml | 7 +++---- .../fangjia/service/datastore/CzbankSampleServiceImpl.java | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml b/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml index a86e1ae67..838f88047 100644 --- a/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml +++ b/projects/fangjia-bkoff/src/main/resources/spring-dal-datastore.xml @@ -34,7 +34,6 @@ - - - - - + + + \ No newline at end of file diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index 30b3d436c..8cdd9018a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -1760,7 +1760,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; } -// public void setSeawaterDao(SeawaterDao seawaterDao) { -// this.seawaterDao = seawaterDao; -// } + public void setSeawaterDao(SeawaterDao seawaterDao) { + this.seawaterDao = seawaterDao; + } } From e084b669a17b2c66b94c60e557fbfa65758d70d8 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 25 Apr 2025 16:38:39 +0800 Subject: [PATCH 033/121] =?UTF-8?q?ApiInvokeStatistics=E4=BF=AE=E6=94=B9mo?= =?UTF-8?q?ngo=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy index d0c89f4fc..5040d77a8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy @@ -25,7 +25,7 @@ import com.mongodb.DBObject class ApiInvokeStatistics extends BaseBatch{ final static def mongoDomain = "mongo.db.fangjia.com" public static final DBCollection OPEN_URI_LOG = com.fangjia.core.util.MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI,"business", "open_uri_log") - public static final DBCollection OPEN_URI_LOG_COUNT = MongoUtils.getCollectionByName("business", "api_invoke_statistical", "mongo.db.fangjia.com", 27017) + public static final DBCollection OPEN_URI_LOG_COUNT = MongoUtils.getCollectionByName("business", "api_invoke_statistical", "mongo.db.fangjia.com", 28017) static final dbFangjia = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/fangjia?autoReconnect=true&characterEncoding=utf-8&autoReconnect=true", "sa", "G00jia", "com.mysql.jdbc.Driver"); static main(args) { def s = System.currentTimeMillis() From cf10901ed6dc1cae7e54a764ed1cb1b22ec5b389 Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Sun, 27 Apr 2025 09:48:06 +0800 Subject: [PATCH 034/121] =?UTF-8?q?=E5=95=86=E9=93=BA=E6=A0=B7=E6=9C=AC?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=B010=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/service/datastore/AiShopServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 245dcfccd..0bf6cf150 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -325,7 +325,7 @@ public class AiShopServiceImpl implements AiShopService { query.setCityDisplay(evaluation.getCity()); Pager pager = new Pager(); pager.setStartRow(0); - pager.setPageSize(5); + pager.setPageSize(10); query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); @@ -378,7 +378,7 @@ public class AiShopServiceImpl implements AiShopService { query.setCityDisplay(evaluation.getCity()); Pager pager = new Pager(); pager.setStartRow(0); - pager.setPageSize(5); + pager.setPageSize(10); query.setPager(pager); query.setTable("latest_seawater"); List shops = seawaterService.findSeawatersByQuery(query); From 8c175743e8f519df335925316dab5bba7e1a89d0 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Sun, 27 Apr 2025 13:39:31 +0800 Subject: [PATCH 035/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=A8=E6=97=A5?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../district/DistrictStatServiceImpl.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) 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 6065c2063..389638fa6 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 @@ -1604,9 +1604,13 @@ public class DistrictStatServiceImpl implements DistrictStatService { if (startDate == null) { throw new IllegalArgumentException("开始日期不能为空"); + }else { + startDate = DateUtil.truncateDay(startDate); } if (endDate == null) { throw new IllegalArgumentException("结束日期不能为空"); + }else { + endDate = DateUtil.truncateDay(endDate); } if (StringUtils.isBlank(periodModel)) { periodModel = "weekly"; @@ -1642,7 +1646,6 @@ public class DistrictStatServiceImpl implements DistrictStatService { sortParams.add(new SortParam("weekend", true)); List dss = this.districtStatDao.findAllByParams(params, sortParams); if (null == dss || dss.isEmpty()) {// 如果没有在小区均价表中查到均价数据,通过城市的价格计算小区均价 - List cityQueryParams = new ArrayList(); cityQueryParams.add(new QueryParam("city", city)); cityQueryParams.add(new QueryParam("region", region)); @@ -1708,15 +1711,35 @@ public class DistrictStatServiceImpl implements DistrictStatService { } List timeSeries = generateTimeSeries(weekendDates.get(0), endDate, periodModel); - Map statMap = new HashMap(); - for (DistrictStat districtStat : dss) { if (timeSeries.contains(districtStat.getWeekend())) { statMap.put(districtStat.getWeekend(), districtStat); } } - + if("monthly".equals(periodModel)){ + Date firstWeekendOfMonth = DateUtil.getFirstWeekendOfMonth(endDate); + List stats = districtStatService.findDistrictStat(new DistrictKey(city, region, name), null , firstWeekendOfMonth, endDate); + if(stats.isEmpty()){ + Date sunDay = DateUtil.getFirstDayOfWeek(endDate); + if(!timeSeries.contains(sunDay)){ + timeSeries.add(sunDay); + } + }else{ + if(DateUtil.isSunday(endDate)){ + timeSeries.remove(endDate); + }else{ + timeSeries.remove(DateUtil.getLastSunday(endDate)); + } + for(int i = stats.size()-1; i >= 0; i--){ + if (!timeSeries.contains(stats.get(i).getWeekend())){ + statMap.put(stats.get(i).getWeekend(), stats.get(i)); + timeSeries.add(stats.get(i).getWeekend()); + } + break; + } + } + } for (Date time : timeSeries) { if (!statMap.containsKey(time)) { DistrictStat districtStat = new DistrictStat(); @@ -1772,10 +1795,6 @@ public class DistrictStatServiceImpl implements DistrictStatService { monthlyDates.add(date); } } - Date sunDay = DateUtil.getFirstDayOfWeek(endDate); - if (!monthlyDates.contains(sunDay)) { - monthlyDates.add(sunDay); - } return monthlyDates; } else { throw new IllegalArgumentException("非法的计算周期"); From 971a05e29ebecf6221576b43e38d5ff8894e6269 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Sun, 27 Apr 2025 14:21:51 +0800 Subject: [PATCH 036/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=A8=E6=97=A5?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fangjia/core/util/DateUtil.java | 11 ++++++++++- .../fangjia/open/controllers/PropertyController.java | 3 +++ .../service/district/DistrictStatServiceImpl.java | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DateUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DateUtil.java index 9c0993ae0..27657a036 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DateUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DateUtil.java @@ -1556,8 +1556,17 @@ public class DateUtil { return c.getTime(); } + /** + * 增加日期的天数 + * 此方法用于给定一个日期后,增加指定数量的天数 + * + * @param date 原始日期 + * @param amount 要增加的天数,正数表示未来日期,负数表示过去日期 + * @return 增加天数后的日期 + */ public static Date add(Date date,int amount){ - return add(date,Calendar.DATE,amount); + // 调用另一个重载的add方法,将Calendar.DATE作为参数,表示按天数增加 + return add(date,Calendar.DATE,amount); } public static String addMonth(Date date, int month){ diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 57f2da122..380683b01 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -759,6 +759,9 @@ public class PropertyController { //int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); // 返回2B价格,小程序用,其他也改为2B int avgPrice = districtStatService.findLatestDistrictAvgPrice2B(new DistrictKey(district), null); + if(avgPrice == 0){ + avgPrice = districtStatService.findLatestDistrictAvgPrice2B(new DistrictKey(district), DateUtil.add(new Date(), -7)); + } if (avgPrice != 0) { districtInfoDto.setAvgPrice(avgPrice); } 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 389638fa6..dc1b65d9e 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 @@ -1527,7 +1527,12 @@ public class DistrictStatServiceImpl implements DistrictStatService { @Override public int findLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend) { if (weekend == null) { - weekend = DateUtil.getFirstDayOfWeek(new Date()); + Date now = DateUtil.truncateDay(new Date()); + if(!DateUtil.isSunday(now)){ + weekend = DateUtil.getFirstDayOfWeek(now); + }else{ + weekend = now; + } } String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_2B_" + DateUtil.formatToYYMMDD(weekend); Object obj = CacheUtils.getValue(this.getClass(), cacheKey); From 824fe3eb4115a65ae107a82d18738fec140a592b Mon Sep 17 00:00:00 2001 From: majintao Date: Sun, 27 Apr 2025 14:26:03 +0800 Subject: [PATCH 037/121] =?UTF-8?q?ApiInvokeStatistics=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy index 5040d77a8..8a5ea5aaa 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy @@ -43,7 +43,7 @@ class ApiInvokeStatistics extends BaseBatch{ def getYestodayLog(Date today,Date yestoday){ //Date today = getToday(); //Date yestoday = getNextDay(today) - BasicDBObject query= new BasicDBObject("c_date", new BasicDBObject('$gt',yestoday).append('$lt', today)) + BasicDBObject query= new BasicDBObject("c_date", new BasicDBObject('$gte',yestoday).append('$lt', today)) DBCursor dbc=OPEN_URI_LOG.find(query).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) def results = [:] int c = 0 From 2b1af16abcd08db648bb536a326841c68c0ace9a Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Sun, 27 Apr 2025 14:34:56 +0800 Subject: [PATCH 038/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=A8=E6=97=A5?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/district/DistrictStatServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index dc1b65d9e..315eb3e04 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 @@ -384,7 +384,8 @@ public class DistrictStatServiceImpl implements DistrictStatService { * 获取指定时间段日期的小区均价 * * @param districtKey - * @param date + * @param startDate + * @param endDate * @return */ public List findDistrictStatRangDate(DistrictKey districtKey, Date startDate,Date endDate) { From 0aabc43b237319dd8c2076bcb50c5ce83e959cc1 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Sun, 27 Apr 2025 14:57:10 +0800 Subject: [PATCH 039/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=A8=E6=97=A5?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/district/DistrictStatServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 315eb3e04..8fe89a497 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 @@ -1547,7 +1547,7 @@ public class DistrictStatServiceImpl implements DistrictStatService { public Integer doFindLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend){ - DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); + DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey, weekend); if (statBo != null && statBo.getDefaultDistrictStat() != null) { if (statBo.getDefaultDistrictStat().getAvg_price_2b() != null && statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { return statBo.getDefaultDistrictStat().getAvg_price_2b(); From cd9dc41da6749bf2ae965eb2651e494d0ef89ad5 Mon Sep 17 00:00:00 2001 From: majintao Date: Sun, 27 Apr 2025 15:32:49 +0800 Subject: [PATCH 040/121] =?UTF-8?q?BaseBatch=E8=84=9A=E6=9C=AC=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/BaseBatch.groovy | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy index 39edb1dfe..9293f2bac 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy @@ -96,7 +96,7 @@ abstract class BaseBatch { exception = true e.printStackTrace() __jms.monitor(batchName, '', extraData, e) - def msg = "脚本发生异常 BatchName:${batchName}\t" + def msg = "脚本发生异常错误 BatchName:${batchName}\t" def batchOwner = getBatchOwner(batch) if(batchOwner && batchOwner.size() > 0){ def owner = null @@ -110,8 +110,9 @@ abstract class BaseBatch { if(e){ msg += "\tException:" + e.getClass().name } - if(SystemUtils.IS_OS_LINUX){ - sendDingDingMsg("2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c",msg) + def phoneNum = getBatchPhones(batch) + if(true){ + sendDingDingMsg("ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4",msg, phoneNum) try { Map params = new HashMap(); @@ -174,6 +175,27 @@ abstract class BaseBatch { return ret } + static def getBatchPhones(BaseBatch bb) { + def phones = [] + try { + BatchOwner annotation = AnnotationUtils.findAnnotation(bb.getClass(), BatchOwner.class) + if (annotation) { + annotation.value().each { + def map = it.toMap() + if (map?.mobile) { + phones << map.mobile + } + } + } else { + bb.logWarn('!!!请使用' + BatchOwner.class.getName() + '注解标明本Batch的拥有者!!!') + } + } catch (Exception e) { + bb.logWarn('!!!解析BatchOwner失败!!!', e) + } + return phones[0] ? phones[0] : "" + } + + static def getBatchDescribe(BaseBatch bb){ try { BatchOwner annotation = AnnotationUtils.findAnnotation(bb.getClass(), BatchOwner.class) @@ -217,8 +239,8 @@ abstract class BaseBatch { __jms.sendDingMsg(mobile, msg) } - def static sendDingDingMsg(String token, String msg){ - DingDingMessageUtil.sendTextMessage(token, msg); + def static sendDingDingMsg(String token, String msg, String phoneNum){ + DingDingMessageUtil.sendTextMessageAndAt(token, msg, phoneNum); } // def static getProp(String key){ From f2efc4b4707353861788be4f10ea03cbc505b710 Mon Sep 17 00:00:00 2001 From: majintao Date: Sun, 27 Apr 2025 15:33:48 +0800 Subject: [PATCH 041/121] =?UTF-8?q?BaseBatch=E8=84=9A=E6=9C=AC=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/groovy/com/fangjia/script/BaseBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy index 9293f2bac..baf3e6040 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy @@ -111,7 +111,7 @@ abstract class BaseBatch { msg += "\tException:" + e.getClass().name } def phoneNum = getBatchPhones(batch) - if(true){ + if(SystemUtils.IS_OS_LINUX){ sendDingDingMsg("ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4",msg, phoneNum) try { From 94c645b49110e2829e8a5caa8c4e9aa73dbeb33c Mon Sep 17 00:00:00 2001 From: majintao Date: Sun, 27 Apr 2025 17:58:59 +0800 Subject: [PATCH 042/121] =?UTF-8?q?=E5=AE=8C=E5=96=84ApiInvokeStatistics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hubingliang/ApiInvokeStatistics.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy index 8a5ea5aaa..17112f274 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/ApiInvokeStatistics.groovy @@ -43,8 +43,13 @@ class ApiInvokeStatistics extends BaseBatch{ def getYestodayLog(Date today,Date yestoday){ //Date today = getToday(); //Date yestoday = getNextDay(today) + def deleteQuery = new BasicDBObject("statistical_date", yestoday) + OPEN_URI_LOG_COUNT.remove(deleteQuery) + println "已删除 ${yestoday.format('yyyy-MM-dd')} 的旧统计数据" BasicDBObject query= new BasicDBObject("c_date", new BasicDBObject('$gte',yestoday).append('$lt', today)) - DBCursor dbc=OPEN_URI_LOG.find(query).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) +// DBCursor dbc=OPEN_URI_LOG.find(query).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + DBCursor dbc = OPEN_URI_LOG.find(query, new BasicDBObject("res_map", 0)).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + def results = [:] int c = 0 dbc.each {BasicDBObject log-> @@ -103,11 +108,12 @@ class ApiInvokeStatistics extends BaseBatch{ obj.append("total_time",total_time) obj.append("statistical_date",yestoday) obj.append("user_name",companyName) - DBObject qu = new BasicDBObject(); - qu.append("user_id", userIDStr); - qu.append("request_uri", uri); - qu.append("statistical_date", yestoday) - OPEN_URI_LOG_COUNT.update(qu, new BasicDBObject('$set', obj), true, true); +// DBObject qu = new BasicDBObject(); +// qu.append("user_id", userIDStr); +// qu.append("request_uri", uri); +// qu.append("statistical_date", yestoday) +// OPEN_URI_LOG_COUNT.update(qu, new BasicDBObject('$set', obj), true, true); + OPEN_URI_LOG_COUNT.insert(obj) } From 0ac1d7d16d6b5cece4b70eb5f4dea2184e02f0df Mon Sep 17 00:00:00 2001 From: liuhongyang Date: Mon, 28 Apr 2025 16:43:23 +0800 Subject: [PATCH 043/121] =?UTF-8?q?=E5=95=86=E9=93=BA=E6=A0=B7=E6=9C=AC?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/dal/SeawaterQuery.java | 9 ++++++ .../fangjia/dal/mongo/model/Evaluation.java | 26 ++++++++++++++++ .../dal/seawater/dao/SeawaterDaoImpl.java | 29 ++++++++++++++++++ .../fangjia/dal/seawater/model/Seawater.java | 21 +++++++++++++ .../dal/seawater/model/SeawaterDto.java | 30 +++++++++++++++++++ .../open/controllers/ShopController.java | 9 ++++++ .../open/controllers/ShopSellController.java | 9 ++++++ .../open/model/PropertyEvaluationModel.java | 10 +++++++ .../service/datastore/AiShopServiceImpl.java | 27 +++++++++++++++-- 9 files changed, 168 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java index 7ce356ffa..ae31c98dc 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java @@ -38,6 +38,7 @@ public class SeawaterQuery { private Integer radius; private String level; + private List tags; public String getId() { return id; @@ -278,4 +279,12 @@ public class SeawaterQuery { public void setLevel(String level) { this.level = level; } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java index 7c8dd0ca2..91ccf87fc 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java @@ -146,6 +146,14 @@ public class Evaluation implements MongoEntity { * 楼层描述 */ private String floorDesc; + /** + * 查询范围 + */ + private Integer radius; + /** + * 商铺标签 + */ + private String tags; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -1066,4 +1074,22 @@ public class Evaluation implements MongoEntity { public void setFloorDesc(String floorDesc) { this.floorDesc = floorDesc; } + + @Transient + public Integer getRadius() { + return radius; + } + + public void setRadius(Integer radius) { + this.radius = radius; + } + + @Transient + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 04379c299..b2724fdf4 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -395,6 +395,24 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i if (source.containsKey("business_status")) { seawater.setBusinessStatus(source.getString("business_status")); } + if (source.containsKey("tags")) { + List tagsList = new ArrayList(); + JSONArray jsonArray = source.getJSONArray("tags"); + int size = jsonArray.size(); + for (int n = 0; n < size; n++) { + tagsList.add(jsonArray.getString(n)); + } + seawater.setTags(StringUtils.join(tagsList, ",")); + } + if (source.containsKey("image_urls")) { + List imageList = new ArrayList(); + JSONArray jsonArray = source.getJSONArray("image_urls"); + int size = jsonArray.size(); + for (int n = 0; n < size; n++) { + imageList.add(jsonArray.getString(n)); + } + seawater.setImageUrls(StringUtils.join(imageList, ",")); + } try { seawater.setDistance((int) jsonList.get(i).getJSONArray("sort").getDouble(0)); } catch (Exception e) { @@ -780,6 +798,17 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i jsonList.add(temp); } + if (query.getTags() != null && query.getTags().size() > 0) { + Set tagsList = new LinkedHashSet(query.getTags()); + for (String tag : tagsList) { + JSONObject param = new JSONObject(); + param.put("tags", tag); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + } + queryJson.put("must", jsonList); ArrayList filterList = new ArrayList(); if (filter.size() > 0) { diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index b490c892c..db70eae13 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -104,6 +104,9 @@ public class Seawater implements SeawaterEntity { private String businessStatus; + private String tags; + + private String imageUrls; @Id @Column(name = "_id") @@ -572,4 +575,22 @@ public class Seawater implements SeawaterEntity { public void setBusinessStatus(String businessStatus) { this.businessStatus = businessStatus; } + + @Column(name = "tags") + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } + + @Column(name = "image_urls") + public String getImageUrls() { + return imageUrls; + } + + public void setImageUrls(String imageUrls) { + this.imageUrls = imageUrls; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java index e01d2e515..736f8cdc4 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -18,6 +18,12 @@ public class SeawaterDto { private String districtName; + private String tags; + + private String imageUrls; + + private String location; + public String getCity() { return city; } @@ -113,4 +119,28 @@ public class SeawaterDto { public void setDistrictName(String districtName) { this.districtName = districtName; } + + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } + + public String getImageUrls() { + return imageUrls; + } + + public void setImageUrls(String imageUrls) { + this.imageUrls = imageUrls; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java index 3afc679c3..b47a09194 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java @@ -467,6 +467,15 @@ public class ShopController { evaluation.setAge(model.getAge()); } evaluation.setArea(model.getSize()); + if (model.getRadius() != null) { + evaluation.setRadius(model.getRadius()); + } + if (StringUtils.isNotBlank(model.getTags())) { + evaluation.setTags(model.getTags()); + } + if (StringUtils.isNotBlank(model.getEstateType())) { + evaluation.setEstateType(model.getEstateType()); + } if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { evaluation.setBuildQuality(convertToString(model.getBuildQuality())); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java index 9aae9fb84..085f24b0c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java @@ -467,6 +467,15 @@ public class ShopSellController { evaluation.setAge(model.getAge()); } evaluation.setArea(model.getSize()); + if (model.getRadius() != null) { + evaluation.setRadius(model.getRadius()); + } + if (StringUtils.isNotBlank(model.getTags())) { + evaluation.setTags(model.getTags()); + } + if (StringUtils.isNotBlank(model.getEstateType())) { + evaluation.setEstateType(model.getEstateType()); + } if (ArrayUtils.isNotEmpty(model.getBuildQuality())) { evaluation.setBuildQuality(convertToString(model.getBuildQuality())); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java index feb2119bd..c7e564225 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java @@ -292,6 +292,8 @@ public class PropertyEvaluationModel extends FangjiaApiModel { private Integer level; private Integer type; + private String tags; + public void setDecorationAge(int decorationAge) { this.decorationAge = decorationAge; } @@ -942,4 +944,12 @@ public class PropertyEvaluationModel extends FangjiaApiModel { public void setType(Integer type) { this.type = type; } + + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java index 0bf6cf150..5fd208ab3 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -223,6 +223,9 @@ public class AiShopServiceImpl implements AiShopService { seawaterDto.setFloorInfo(seawater.getFloorInfo()); seawaterDto.setAddress(seawater.getAddress()); seawaterDto.setDistrictName(seawater.getDistrictName()); + seawaterDto.setTags(seawater.getTags()); + seawaterDto.setImageUrls(seawater.getImageUrls()); + seawaterDto.setLocation(seawater.getLocation()); return seawaterDto; } @@ -318,7 +321,17 @@ public class AiShopServiceImpl implements AiShopService { query.setLat(lat); query.setLng(lng); query.setCat("shop_rent"); - query.setRadius(1000); + if (evaluation.getRadius() != null && evaluation.getRadius() > 0) { + query.setRadius(evaluation.getRadius()); + } else { + query.setRadius(1000); + } + if (StringUtils.isNotBlank(evaluation.getEstateType())) { + query.setEstateType(evaluation.getEstateType()); + } + if (StringUtils.isNotBlank(evaluation.getTags())) { + query.setTags(Arrays.asList(evaluation.getTags().split(","))); + } // 查询近一年样本 query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); @@ -371,7 +384,17 @@ public class AiShopServiceImpl implements AiShopService { query.setLat(lat); query.setLng(lng); query.setCat("shop_sell"); - query.setRadius(1000); + if (evaluation.getRadius() != null && evaluation.getRadius() > 0) { + query.setRadius(evaluation.getRadius()); + } else { + query.setRadius(1000); + } + if (StringUtils.isNotBlank(evaluation.getEstateType())) { + query.setEstateType(evaluation.getEstateType()); + } + if (StringUtils.isNotBlank(evaluation.getTags())) { + query.setTags(Arrays.asList(evaluation.getTags().split(","))); + } // 查询近一年样本 query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); From 4cd6e509d985ed62f5e4f22d2509949d680f74d5 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 29 Apr 2025 14:24:43 +0800 Subject: [PATCH 044/121] =?UTF-8?q?autoComplete=E5=BA=94=E6=80=A5=E8=A7=A3?= =?UTF-8?q?=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 380683b01..e6886f115 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -4079,6 +4079,8 @@ public class PropertyController { if (StringUtils.isNotBlank(model.getFilter())) { type = model.getFilter(); } + //应急解决 + model.setUseSeaweed("true"); //强行启用小区库 if ("true".equals(model.getUseSeaweed())) { if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 100) { From 1f24269bfe416cd55d64c6f53b9772b32c33f43b Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 29 Apr 2025 14:48:35 +0800 Subject: [PATCH 045/121] =?UTF-8?q?=E5=8E=BB=E9=99=A4autoComplete=E5=BA=94?= =?UTF-8?q?=E6=80=A5=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index e6886f115..380683b01 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -4079,8 +4079,6 @@ public class PropertyController { if (StringUtils.isNotBlank(model.getFilter())) { type = model.getFilter(); } - //应急解决 - model.setUseSeaweed("true"); //强行启用小区库 if ("true".equals(model.getUseSeaweed())) { if (model.getMax() == null || model.getMax() < 1 || model.getMax() > 100) { From cc571c460d49000d56e87696a0bbf27615643c93 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 7 May 2025 16:31:11 +0800 Subject: [PATCH 046/121] =?UTF-8?q?=E9=AB=98=E5=BE=B7=E9=80=86=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 380683b01..586c407b6 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -1653,7 +1653,7 @@ public class PropertyController { if (district == null) { //加上高德获取经纬度 和 根据经纬度估值 Map map = GeoUtils.parserByGaode(model.getCity(), model.getAddress()); - if (map.containsKey("level") && GAODE_LEVEL.contains(map.get("level")) + if (map != null && map.containsKey("level") && GAODE_LEVEL.contains(map.get("level")) && map.containsKey("lng") && map.containsKey("lat")) { String location = map.get("lng") + "," + map.get("lat"); HttpRequest httpRequest = new HttpRequest(); From fb2809d165f8fbeacbffa6686afc216a3c852e88 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 May 2025 13:52:33 +0800 Subject: [PATCH 047/121] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/wenyan/guojun.groovy | 49 ++----------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/guojun.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/guojun.groovy index e837ce0ba..717a8d81f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/guojun.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/guojun.groovy @@ -2,49 +2,10 @@ package com.fangjia.script.wenyan import com.fangjia.core.ProvinceData import com.fangjia.core.RegionData -import com.fangjia.core.util.DateUtil -import com.fangjia.core.util.Mongo3Utils -import com.fangjia.script.util.CommonUtils -import com.fangjia.script.util.DbUtils -import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils -import com.mongodb.BasicDBObject -import org.bson.Document -import org.elasticsearch.action.get.GetRequest -import org.elasticsearch.action.get.GetResponse -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.RestHighLevelClient +fullCityMap = CommonDatautils.queryFullNameCity() -////def data = [] -////data << ["ID","城市","区域","名称","地址", "财力评级"] -//RestHighLevelClient client = ElasticUtils.getClient89("192.168.0.89") -//district_analy_data_client = Mongo3Utils.getDbCollection("fangjia_stat", "district_analy_data") -//level_map = ["1": "S", "2": "A", "3": "B", "4": "C", "5": "D"] -//level_maps = new HashMap<>() -//for(def key in level_map.keySet()){ -// level_maps.put(level_map[key], key) -//} -//ExcelUtils.modify("C:\\Users\\goojia\\Desktop\\财力评级-厦门.xlsx",{List item-> -//// GetResponse response = client.get(new GetRequest("community_summary", item["A"] as String), RequestOptions.DEFAULT) -//// def query = new Document("city", item['B'].toString().replace("市", "")) -//// query.append("region", item['C'].replace("区", "")) -//// query.append("district_name", item["D"]) -//// def stat = district_analy_data_client.find(query).first() -//// println(query) -//// item["F"] = response.getSourceAsMap()?.consumption_rating -//// item["G"] = stat?.community_rating -// item["G"] = level_maps.get(item["G"], null) -//// println(item) -//}) -//System.exit(0) -////for (def region in ["思明", "翔安", "湖里"]) { -//// DbUtils.seaweed.find(new BasicDBObject("city", "厦门").append("region", region).append("cat", "district").append("status", 0)).each { BasicDBObject dbo -> -//// println("${dbo._id.toString()}\t${dbo.city}市\t${dbo.region}区\t${dbo.name}\t${dbo.address}") -//// } -////} - -ExcelUtils.read("C:\\Users\\goojia\\Desktop\\海南省城市均价.xlsx",1).each {List item-> - def yearMonth = DateUtil.formatByPattern(item[0], "yyyyMM").toInteger() - - println(item) -} \ No newline at end of file +ExcelUtils.multiThreadingModify("C:\\Users\\goojia\\Desktop\\区域楼盘评级.xlsx",{List item-> + item["E"] = ProvinceData.getDisplay(item[0]) + print(item) +}) \ No newline at end of file From cf1b288949b7dbf92861436a9106b4a923326178 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 12 May 2025 10:48:57 +0800 Subject: [PATCH 048/121] =?UTF-8?q?/house/shopSimilar=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastore/CzbankSampleServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index 8cdd9018a..406afdada 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -187,7 +187,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { BooleanQuery nameQuery = new BooleanQuery(); int c = 0; for (String n : names) { - if (StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(n)) { if (name.indexOf("(") > -1 || name.indexOf(")") > -1 || name.indexOf("(") > -1 || name.indexOf(")") > -1 | name.indexOf("[") > -1 || name.indexOf("]") > -1 || name.indexOf("-") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf(":") > -1) { @@ -200,9 +200,11 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { break; } } - BooleanQuery srQuery = new BooleanQuery(); - srQuery.add(nameQuery, BooleanClause.Occur.MUST); - houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery))); + if (!nameQuery.clauses().isEmpty()) { + BooleanQuery srQuery = new BooleanQuery(); + srQuery.add(nameQuery, BooleanClause.Occur.MUST); + houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery))); + } List houseSortParams = new ArrayList(); houseSortParams.add(new SortParam("publishDate", false)); houseQuery.add(new QueryParam("category", "shop_sell")); From 852e62208a39e05d1158abf08cc5ec4ca201f96d Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 4 Jun 2025 15:06:30 +0800 Subject: [PATCH 049/121] =?UTF-8?q?=E9=92=89=E9=92=89=E5=8F=91=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8A=A0@?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yinjihaun/util/DingDingMessageUtil.groovy | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy index 39b9e53d2..9bb1b003a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy @@ -30,6 +30,28 @@ class DingDingMessageUtil { } } + static void sendTextMessageAndAt(String access_token, String msg, String atMobile) throws Exception { + HttpRequest request = new HttpRequest(); + HttpPost httppost = new HttpPost("https://oapi.dingtalk.com/robot/send?access_token=" + access_token); + httppost.addHeader("Content-Type", "application/json; charset=utf-8"); + + // 创建消息体,只包含一个手机号 + String textMsg = "{ " + + "\"msgtype\": \"text\", " + + "\"text\": {\"content\": \"" + msg + "\"}, " + + "\"at\": {\"atMobiles\": [\"" + atMobile + "\"]}" + // 只 @ 一个手机号 + "}"; + + StringEntity se = new StringEntity(textMsg, "utf-8"); + httppost.setEntity(se); + HttpResponse response = request.getHttpClient().execute(httppost); + + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + String result = EntityUtils.toString(response.getEntity(), "utf-8"); + System.out.println("消息发送结果:" + result); + } + } + static void sendMarkdownMessage(String access_token, String title, String msg){ HttpRequest request = new HttpRequest() JSONObject requestBody = new JSONObject() From 7082095b3e600d895a63f94c91757f001dd3f6fe Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 6 Jun 2025 14:34:29 +0800 Subject: [PATCH 050/121] =?UTF-8?q?=E6=88=BF=E6=BA=90=E5=8A=A0=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/HouseController.java | 4 ++++ .../java/com/fangjia/open/model/HouseSearchModel.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 945ab4e5b..cb41460ae 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java @@ -1017,6 +1017,10 @@ public class HouseController { } else { pager.setPageSize(5); } + if (model.getPrice() != null) { + query.setStartPrice((int) (model.getPrice() * 0.9)); + query.setEndPrice((int) (model.getPrice() * 1.1)); + } query.setPager(pager); query.setSortField("p_date"); query.setOrder(false); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index 39fefbbdc..dc5b5eae0 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -29,6 +29,8 @@ public class HouseSearchModel extends SearchModel { private String cat; private Integer pageSize; + + private Double price; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -209,4 +211,12 @@ public class HouseSearchModel extends SearchModel { public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } } From 38904ea2e0b50dba4c156cd0d39519e85ab64720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 12 Jun 2025 10:17:25 +0800 Subject: [PATCH 051/121] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCity=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/weixin/DistrictController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index e2b80dddd..74e1af29d 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -107,7 +107,9 @@ public class DistrictController { } List params = new ArrayList(); - params.add(new QueryParam("city", city)); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } params.add(new QueryParam("category", cat)); params.add(new QueryParam("visible", 0)); params.add(new QueryParam("$srByStr", String.format("keyword:%s^6.0 OR keyword_cjk:%s", keyword, keyword))); From bc11a352c21337b8daf233e6c6b02631a6ae2ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 13 Jun 2025 09:54:39 +0800 Subject: [PATCH 052/121] =?UTF-8?q?=E6=8B=86=E5=BC=80=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E5=8C=BA=E5=9F=9Fstat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coresite/controllers/TrendController.java | 50 ++++++--- .../fangjia/coresite/model/TrendModel.java | 9 ++ .../main/webapp/yinLianEvaluation/index.ftl | 8 +- .../fangjia/service/bo/CitySellStatBo.java | 101 +++++++++++++++++ .../fangjia/service/bo/RegionSellStatBo.java | 104 ++++++++++++++++++ .../datastore/CitySellStatService.java | 11 ++ .../datastore/CitySellStatServiceImpl.java | 42 +++++-- .../service/datastore/RegionSellService.java | 14 +++ .../mongo/fangjia/RegionSellStatService.java | 5 - .../fangjia/RegionSellStatServiceImpl.java | 49 --------- 10 files changed, 314 insertions(+), 79 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java index 6351025d3..9d83f1f56 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java @@ -14,8 +14,11 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import com.fangjia.core.City; import com.fangjia.coresite.model.*; +import com.fangjia.dal.mongo.model.*; import com.fangjia.service.bo.*; +import com.fangjia.service.datastore.*; import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; @@ -39,21 +42,9 @@ import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.datastore.model.News; import com.fangjia.dal.mongo.fangjia.model.ServerArea; -import com.fangjia.dal.mongo.model.CityTradeStat; -import com.fangjia.dal.mongo.model.DistrictNewPrice; -import com.fangjia.dal.mongo.model.DistrictSellStat; -import com.fangjia.dal.mongo.model.DistrictStat; -import com.fangjia.dal.mongo.model.DistrictTradeStat; -import com.fangjia.dal.mongo.model.RegionBlock; -import com.fangjia.dal.mongo.model.RegionStat; import com.fangjia.dal.seaweed.model.District; -import com.fangjia.service.datastore.DistrictSellStatService; -import com.fangjia.service.datastore.DistrictService; -import com.fangjia.service.datastore.HouseService; -import com.fangjia.service.datastore.RegionStatService; import com.fangjia.service.datastore.bean.HousePicEnum; import com.fangjia.service.datastore.bean.HouseQueryBean; -import com.fangjia.service.datastore.EvaluationService; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.district.TradeStatService; import com.fangjia.service.fsh.DistrictNewPriceService; @@ -82,6 +73,8 @@ public class TrendController { private static int QUARTER_WEEK = 13; private final static Logger LOGGER = LoggerFactory.getLogger(TrendController.class); + private CitySellStatService citySellStatService; + public Object trendChartAction(TrendModel model, HttpServletRequest request) { TrendView trendView = TrendViewFactory.getInstance().create(model); if (trendView != null) { @@ -189,8 +182,8 @@ public class TrendController { model.setRegion(trendView.getRegion()); } else if (trendView.getType().equals(ViewType.city)) { //RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), null, null); - RegionStatBo regionStat = getNearestRegionStat(trendView.getCityName(), null, null); - model.setRegionStatBo(regionStat); + CitySellStatBo citySellStat = getNearestCitySellStat(trendView.getCityName()); + model.setCitySellStatBo(citySellStat); } @@ -826,6 +819,32 @@ public class TrendController { seriesOptions.addAll(data); } } + private CitySellStatBo getNearestCitySellStat(String city) { + CitySellStatBo ret = null; + List citySellStats = null; + Integer startDate = Integer.valueOf(DateUtil.formatToTightYYYYMMDD(DateUtils.addMonths(new Date(), -3))); + citySellStats = citySellStatService.findNearCityStat(city, startDate, 2); + if(citySellStats!=null && citySellStats.size()>0){ + CitySellStatBo bo = new CitySellStatBo(); + if(citySellStats.size()==2){ + bo.setAvgPrice(citySellStats.get(0).getAvgPrice()); + bo.setLastTimeAvgPrice(citySellStats.get(1).getAvgPrice()); + int monthMarkup = (citySellStats.get(0).getAvgPrice()-citySellStats.get(1).getAvgPrice())*10000/citySellStats.get(1).getAvgPrice(); + bo.setMonthMarkup(monthMarkup); + + }else{ + bo.setAvgPrice(citySellStats.get(0).getAvgPrice()); + } + + CitySellStat rs = citySellStatService.findStartStat(city); + if(rs!=null){ + bo.setStartDate(rs.getDate()); + } + return bo; + } + return null; + } + private RegionStatBo getNearestRegionStat(String city, String region, String block){ RegionStatBo ret = null; @@ -1284,4 +1303,7 @@ public class TrendController { this.evaluationService = evaluationService; } + public void setCitySellStatService(CitySellStatService citySellStatService) { + this.citySellStatService = citySellStatService; + } } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java index 0f6a0fde9..5119348ea 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java @@ -31,6 +31,7 @@ public class TrendModel extends BaseModel implements TrendViewModel { private String trendDesc; private DistrictStatBo districtStatBo; private RegionStatBo regionStatBo; + private CitySellStatBo citySellStatBo; private String affectKeyword; private int chartWidth; private int chartHeight; @@ -330,4 +331,12 @@ public class TrendModel extends BaseModel implements TrendViewModel { public void setCityStatInfoBos(List cityStatInfoBos) { this.cityStatInfoBos = cityStatInfoBos; } + + public CitySellStatBo getCitySellStatBo() { + return citySellStatBo; + } + + public void setCitySellStatBo(CitySellStatBo citySellStatBo) { + this.citySellStatBo = citySellStatBo; + } } diff --git a/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl b/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl index e9b882a94..7b54d3b4c 100644 --- a/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl @@ -103,12 +103,12 @@
<#if districtStatBo?? || regionStatBo??> <#if districtStatBo??> -
<#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
-
<#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
+
<#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
+
<#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
${(districtStatBo.districtStat.weekendMarkup/100)?string('0.00')}%
<#elseif regionStatBo??> -
${regionStatBo.lastTimeAvgPrice!}
-
${regionStatBo.avgPrice!}
+
${regionStatBo.lastTimeAvgPrice!}
+
${regionStatBo.avgPrice!}
${(regionStatBo.weekendMarkup/100)?string('0.00')}%
diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java new file mode 100644 index 000000000..5c5121057 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java @@ -0,0 +1,101 @@ +package com.fangjia.service.bo; + +import java.io.Serializable; +import java.util.Date; + +public class CitySellStatBo implements Serializable { + private static final long serialVersionUID = -5310665233447971693L; + private String city; + private String region; + private String block; + private int avgPrice; + private int weekendMarkup; + // 年同比涨跌 + private Integer yearMarkup; + // 月环比涨跌 + private Integer monthMarkup; + private int month; + + private int lastTimeAvgPrice; + private Integer startDate; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } + + public int getWeekendMarkup() { + return weekendMarkup; + } + + public void setWeekendMarkup(int weekendMarkup) { + this.weekendMarkup = weekendMarkup; + } + + public Integer getYearMarkup() { + return yearMarkup; + } + + public void setYearMarkup(Integer yearMarkup) { + this.yearMarkup = yearMarkup; + } + + public Integer getMonthMarkup() { + return monthMarkup; + } + + public void setMonthMarkup(Integer monthMarkup) { + this.monthMarkup = monthMarkup; + } + + public int getMonth() { + return month; + } + + public void setMonth(int month) { + this.month = month; + } + + public int getLastTimeAvgPrice() { + return lastTimeAvgPrice; + } + + public void setLastTimeAvgPrice(int lastTimeAvgPrice) { + this.lastTimeAvgPrice = lastTimeAvgPrice; + } + + public Integer getStartDate() { + return startDate; + } + + public void setStartDate(Integer startDate) { + this.startDate = startDate; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java new file mode 100644 index 000000000..1f6e9a520 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java @@ -0,0 +1,104 @@ +package com.fangjia.service.bo; + +import java.io.Serializable; +import java.util.Date; + +public class RegionSellStatBo implements Serializable { + private static final long serialVersionUID = -5310665233447971693L; + private String city; + private String region; + private String block; + private int avgPrice; + private int weekendMarkup; + // 年同比涨跌 + private Integer yearMarkup; + // 月环比涨跌 + private Integer monthMarkup; + private int month; + + private int lastTimeAvgPrice; + private Integer startDate; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } + + public int getWeekendMarkup() { + return weekendMarkup; + } + + public void setWeekendMarkup(int weekendMarkup) { + this.weekendMarkup = weekendMarkup; + } + + public Integer getYearMarkup() { + return yearMarkup; + } + + public void setYearMarkup(Integer yearMarkup) { + this.yearMarkup = yearMarkup; + } + + public Integer getMonthMarkup() { + return monthMarkup; + } + + public void setMonthMarkup(Integer monthMarkup) { + this.monthMarkup = monthMarkup; + } + + public int getMonth() { + return month; + } + + public void setMonth(int month) { + this.month = month; + } + + public int getLastTimeAvgPrice() { + return lastTimeAvgPrice; + } + + public void setLastTimeAvgPrice(int lastTimeAvgPrice) { + this.lastTimeAvgPrice = lastTimeAvgPrice; + } + + public Integer getStartDate() { + return startDate; + } + + public void setStartDate(Integer startDate) { + this.startDate = startDate; + } + + + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java index 08a2582de..79350a49c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java @@ -2,7 +2,9 @@ package com.fangjia.service.datastore; import com.fangjia.dal.mongo.model.CitySellStat; import com.fangjia.dal.mongo.model.DistrictSellStat; +import com.fangjia.dal.mongo.model.RegionStat; +import java.util.Date; import java.util.List; /** @@ -32,4 +34,13 @@ public interface CitySellStatService { * @return */ CitySellStat findCitySellStatByCity(String city); + + List findNearCityStat(String city, Integer startDate, int count); + + /** + * 查询均价开始的最早时间 + * @param city + * @return + */ + CitySellStat findStartStat(String city); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java index 8e329b935..d754808d9 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java @@ -1,12 +1,6 @@ package com.fangjia.service.datastore; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import com.fangjia.core.util.CacheUtils; import com.fangjia.core.util.DateUtil; @@ -16,9 +10,11 @@ import com.fangjia.dal.SortParam; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.mongo.dao.CitySellStatDao; import com.fangjia.dal.mongo.model.CitySellStat; +import com.fangjia.dal.mongo.model.RegionStat; import com.fangjia.service.bo.DistrictStatBo; import com.google.common.collect.ImmutableList; +import org.apache.commons.lang.StringUtils; import org.sothis.core.util.Closure; /** @@ -108,4 +104,36 @@ public class CitySellStatServiceImpl implements CitySellStatService { }); } + @Override + public List findNearCityStat(final String city, final Integer startDate, final int count) { + return CacheUtils.getValue(this.getClass(), "findNearRegionStat",city+"_"+startDate, CachePolicyEnum.LONG, + new Closure, String>() { + @Override + public List execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + + List s = new ArrayList(); + s.add(new SortParam("date", false)); + return citySellStatDao.findAllByParams(q, s, count); + } + }); + } + + @Override + public CitySellStat findStartStat(final String city) { + return CacheUtils.getValue(this.getClass(), "findStartStat",city, CachePolicyEnum.LONG, + new Closure() { + @Override + public CitySellStat execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + + List s = new ArrayList(); + s.add(new SortParam("date", true)); + return citySellStatDao.findFirstByParams(q, s); + } + }); + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java new file mode 100644 index 000000000..80f2e360b --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java @@ -0,0 +1,14 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.RegionStat; +import com.fangjia.service.bo.AvgUpdateBo; +import com.fangjia.service.bo.RegionStatBo; +import org.sothis.core.util.Pager; + +import java.util.Date; +import java.util.List; + +public interface RegionSellService { + + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java index 8033d7603..43cb2b886 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java @@ -5,10 +5,5 @@ import java.util.List; import com.fangjia.dal.mongo.model.RegionSellStat; public interface RegionSellStatService { - - RegionSellStat findNewestRegionPrice(); - - List findAllRegionPriceByCity(String city, Integer date, String sortField, Boolean sortWay); - RegionSellStat findNewestRegionPrice(String city, String region); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java index 082b5e520..78ab9ee5f 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java @@ -11,55 +11,6 @@ import com.fangjia.dal.mongo.dao.RegionSellStatDao; import com.fangjia.dal.mongo.model.RegionSellStat; public class RegionSellStatServiceImpl implements RegionSellStatService { - - private RegionSellStatDao regionSellStatDao; - public RegionSellStatDao getRegionSellStatDao() { - return regionSellStatDao; - } - - public void setRegionSellStatDao(RegionSellStatDao regionSellStatDao) { - this.regionSellStatDao = regionSellStatDao; - } - - @Override - public RegionSellStat findNewestRegionPrice() { - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - return regionSellStatDao.findFirstByParams(null, sortParams); - } - - @Override - public List findAllRegionPriceByCity(String city, - Integer date, String sortField, Boolean sortWay) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("date", date)); - - List sortParams = new ArrayList(); - if(StringUtils.isNotBlank(sortField)){ - sortParams.add(new SortParam(sortField, sortWay)); - }else{ - sortParams.add(new SortParam("mom", false)); - } - - - return regionSellStatDao.findAllByParams(params, sortParams); - } - - @Override - public RegionSellStat findNewestRegionPrice(String city, String region) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("region", region)); - - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - return regionSellStatDao.findFirstByParams(params, sortParams); - } - - - - } From 1cb32f7ef8d292140a090bb838aae09b413825b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 13 Jun 2025 10:58:11 +0800 Subject: [PATCH 053/121] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=9D=BF=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E9=80=A0=E5=9F=8E=E5=B8=82=E5=9D=87=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coresite/controllers/TrendController.java | 31 +++++++++++------ .../src/main/webapp/trend/trend.ftl | 34 +++++++++++-------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java index 9d83f1f56..c57c15dbb 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java @@ -669,6 +669,7 @@ public class TrendController { private List buildStatJson(String city, String region, String block, int weeks) { List regionStatList = null; + List citySellStatList = null; Map oprions = new HashMap(); Date currentDate = new Date(); if (city != null && region != null && block != null) { @@ -678,22 +679,30 @@ public class TrendController { regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks); oprions.put("name", region); } else if (city != null) { - regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks); + //regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks); + int month = weeks / 4; + citySellStatList = citySellStatService.getAllWithMonths(city, month); oprions.put("name", city); } List ret = new ArrayList(); - if (regionStatList == null) { - return null; - } - JSONArray splineJa = new JSONArray(); - for (RegionStat re : regionStatList) { - JSONArray ja = new JSONArray(); - ja.put(DateUtil.getBeforeDay(re.getWeekend(), -1).getTime()); - ja.put(re.getAvgPrice()); - splineJa.put(ja); + if (CollectionUtils.isNotEmpty(regionStatList)) { + for (RegionStat re : regionStatList) { + JSONArray ja = new JSONArray(); + ja.put(DateUtil.getBeforeDay(re.getWeekend(), -1).getTime()); + ja.put(re.getAvgPrice()); + splineJa.put(ja); + } + } else if (CollectionUtils.isNotEmpty(citySellStatList)) { + for (int i = citySellStatList.size() - 1; i >= 0; i--) { + CitySellStat re = citySellStatList.get(i); + JSONArray ja = new JSONArray(); + ja.put(DateUtil.getBeforeDay(DateUtil.parseDate(re.getDate().toString(), "yyyyMM"), -1).getTime()); + ja.put(re.getAvgPrice()); + splineJa.put(ja); + } } if (splineJa.length() > 0) { @@ -822,7 +831,7 @@ public class TrendController { private CitySellStatBo getNearestCitySellStat(String city) { CitySellStatBo ret = null; List citySellStats = null; - Integer startDate = Integer.valueOf(DateUtil.formatToTightYYYYMMDD(DateUtils.addMonths(new Date(), -3))); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtils.addMonths(new Date(), -3), "yyyyMM")); citySellStats = citySellStatService.findNearCityStat(city, startDate, 2); if(citySellStats!=null && citySellStats.size()>0){ CitySellStatBo bo = new CitySellStatBo(); diff --git a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl index c3fbbf0d3..7ba92620a 100644 --- a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl +++ b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl @@ -113,12 +113,16 @@
- <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo??> <#if count??>
${count!}
<#if districtStatBo??>
<#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
<#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
${(districtStatBo.districtStat.weekendMarkup/100)?string('0.00')}%
+ <#elseif citySellStatBo??> +
${citySellStatBo.lastTimeAvgPrice!}
+
${citySellStatBo.avgPrice!}
+
${(citySellStatBo.monthMarkup/100)?string('0.00')}%
<#elseif regionStatBo??>
${regionStatBo.lastTimeAvgPrice!}
${regionStatBo.avgPrice!}
@@ -145,21 +149,21 @@
- <#if blockItems?? && blockItems?size gt 0> - <#if block??>${block!}<#else>鏉垮潡 - - - +<#-- <#if blockItems?? && blockItems?size gt 0>--> +<#-- <#if block??>${block!}<#else>鏉垮潡--> +<#-- --> +<#-- --> +<#-- -->
- <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo??>