From 07f1b9a868056a7f53b8930276ee24c99d17671f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 19 Feb 2025 11:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=AD=97=E6=A5=BC?= =?UTF-8?q?=E4=BC=B0=E5=80=BC=E6=A0=B7=E6=9C=AC=E5=87=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/OfficeController.java | 11 +++- .../service/datastore/OfficeService.java | 5 +- .../service/datastore/OfficeServiceImpl.java | 39 ++++++++------ .../datastore/dto/OfficeEvaluationDto.java | 52 +++++++++++++++++++ .../service/datastore/dto/OfficeRentDto.java | 32 ++++++++++++ 5 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java index c5d5b9f95..d60ec8ae1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -22,6 +22,7 @@ import com.fangjia.service.api.AddressMatchProxyService; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.OfficeService; import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ArrayUtils; @@ -209,11 +210,16 @@ public class OfficeController { } } - Evaluation evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); + OfficeEvaluationDto evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { Map districtPriceMap = new HashMap(); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getRegion()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { @@ -299,7 +305,7 @@ public class OfficeController { model.setRegion(district.getRegion()); model.setDistrictName(district.getName()); - Evaluation evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); + OfficeEvaluationDto evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { Map districtPriceMap = new HashMap(); @@ -307,6 +313,7 @@ public class OfficeController { districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); try { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java index a3276a571..96ced5b18 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -3,6 +3,7 @@ package com.fangjia.service.datastore; import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import java.util.List; @@ -31,7 +32,7 @@ public interface OfficeService { * @param evaluation * @return */ - Evaluation evaluateRent(District district, Evaluation evaluation); + OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation); /** * 租金地址维度评估 @@ -39,5 +40,5 @@ public interface OfficeService { * @param evaluation * @return */ - Evaluation addressEvaluateRent(Evaluation evaluation); + OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java index 3c4cdac72..393456e10 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -11,6 +11,7 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.dto.GaodeDto; @@ -35,7 +36,7 @@ public class OfficeServiceImpl implements OfficeService { @Override - public Evaluation evaluateRent(District district, Evaluation evaluation) { + public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { evaluation.setFloor(null); evaluation.setHeight(null); @@ -76,19 +77,19 @@ public class OfficeServiceImpl implements OfficeService { query.setEndArea(null); seawaters = seawaterService.findSeawatersByQuery(query); } + OfficeEvaluationDto officeEvaluationDto = null; if (seawaters.size() > 0) { - unitPrice = this.calcRent(seawaters, evaluation); + officeEvaluationDto = this.calcRent(seawaters, evaluation); } else { if (StringUtils.isNotBlank(evaluation.getLocation())) { - unitPrice = rentEvaluateByLocation(evaluation); + officeEvaluationDto = rentEvaluateByLocation(evaluation); } else if (district != null && district.getLat() != null) { evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); - unitPrice = rentEvaluateByLocation(evaluation); + officeEvaluationDto = rentEvaluateByLocation(evaluation); } } - // 评估逻辑 - evaluation.setUnitPrice(unitPrice); - return evaluation; + + return officeEvaluationDto; } // 所在楼层 @@ -116,7 +117,7 @@ public class OfficeServiceImpl implements OfficeService { put(4, "综合体"); } }; - public Double calcRent(List seawaters, Evaluation evaluation) { + public OfficeEvaluationDto calcRent(List seawaters, Evaluation evaluation) { // 计算平均值 Double sum = 0.0; Double size = 0.0; @@ -242,14 +243,20 @@ public class OfficeServiceImpl implements OfficeService { size += seawater.getArea(); } } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (size > 0) { unitPrice = DataUtil.roundDouble(sum / size / 30 * factor, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaters); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); } - return unitPrice ; + return officeEvaluationDto; } @Override - public Evaluation addressEvaluateRent(Evaluation evaluation) { + public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { evaluation.setFloor(null); evaluation.setHeight(null); @@ -257,12 +264,12 @@ public class OfficeServiceImpl implements OfficeService { // 评估逻辑 String location = getLocation(evaluation.getCity(), evaluation.getAddress()); evaluation.setLocation(location); - Double unitPrice = rentEvaluateByLocation(evaluation); - evaluation.setUnitPrice(unitPrice); - return evaluation; + OfficeEvaluationDto officeEvaluationDto = rentEvaluateByLocation(evaluation); + + return officeEvaluationDto; } - private Double rentEvaluateByLocation(Evaluation evaluation) { + private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { if (StringUtils.isNotBlank(evaluation.getLocation())) { Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); @@ -300,8 +307,10 @@ public class OfficeServiceImpl implements OfficeService { query.setRadius(3000); seawaters = seawaterService.findSeawatersByQuery(query); } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); if (CollectionUtils.isNotEmpty(seawaters)) { - return calcRent(seawaters, evaluation); + officeEvaluationDto = calcRent(seawaters, evaluation); + return officeEvaluationDto; } } return null; diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java new file mode 100644 index 000000000..b445eb392 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -0,0 +1,52 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + private String name; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java new file mode 100644 index 000000000..262858055 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +}