Merge remote-tracking branch 'origin/master'

This commit is contained in:
majintao
2025-02-19 17:14:09 +08:00
5 changed files with 120 additions and 19 deletions
@@ -22,6 +22,7 @@ import com.fangjia.service.api.AddressMatchProxyService;
import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.DistrictService;
import com.fangjia.service.datastore.OfficeService; import com.fangjia.service.datastore.OfficeService;
import com.fangjia.service.datastore.OpenApiLogService; import com.fangjia.service.datastore.OpenApiLogService;
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils; 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) { if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>(); Map<String, Object> districtPriceMap = new HashMap<String, Object>();
districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); 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)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
try { try {
@@ -299,7 +305,7 @@ public class OfficeController {
model.setRegion(district.getRegion()); model.setRegion(district.getRegion());
model.setDistrictName(district.getName()); 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) { if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>(); Map<String, Object> districtPriceMap = new HashMap<String, Object>();
@@ -307,6 +313,7 @@ public class OfficeController {
districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("district", district.getRegion());
districtPriceMap.put("name", district.getName()); districtPriceMap.put("name", district.getName());
districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
districtPriceMap.put("samples", evaluation.getSeawater());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
try { try {
@@ -3,6 +3,7 @@ package com.fangjia.service.datastore;
import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.mongo.model.OfficeRentStat;
import com.fangjia.dal.seaweed.model.District; import com.fangjia.dal.seaweed.model.District;
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
import java.util.List; import java.util.List;
@@ -31,7 +32,7 @@ public interface OfficeService {
* @param evaluation * @param evaluation
* @return * @return
*/ */
Evaluation evaluateRent(District district, Evaluation evaluation); OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation);
/** /**
* 租金地址维度评估 * 租金地址维度评估
@@ -39,5 +40,5 @@ public interface OfficeService {
* @param evaluation * @param evaluation
* @return * @return
*/ */
Evaluation addressEvaluateRent(Evaluation evaluation); OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation);
} }
@@ -11,6 +11,7 @@ import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeRentStat; import com.fangjia.dal.mongo.model.OfficeRentStat;
import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.dal.seaweed.model.District; import com.fangjia.dal.seaweed.model.District;
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
import com.fangjia.service.mongo.fangjia.SeawaterService; import com.fangjia.service.mongo.fangjia.SeawaterService;
import com.fangjia.service.util.GeoUtils; import com.fangjia.service.util.GeoUtils;
import com.fangjia.service.util.dto.GaodeDto; import com.fangjia.service.util.dto.GaodeDto;
@@ -35,7 +36,7 @@ public class OfficeServiceImpl implements OfficeService {
@Override @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()) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
evaluation.setFloor(null); evaluation.setFloor(null);
evaluation.setHeight(null); evaluation.setHeight(null);
@@ -76,19 +77,19 @@ public class OfficeServiceImpl implements OfficeService {
query.setEndArea(null); query.setEndArea(null);
seawaters = seawaterService.findSeawatersByQuery(query); seawaters = seawaterService.findSeawatersByQuery(query);
} }
OfficeEvaluationDto officeEvaluationDto = null;
if (seawaters.size() > 0) { if (seawaters.size() > 0) {
unitPrice = this.calcRent(seawaters, evaluation); officeEvaluationDto = this.calcRent(seawaters, evaluation);
} else { } else {
if (StringUtils.isNotBlank(evaluation.getLocation())) { if (StringUtils.isNotBlank(evaluation.getLocation())) {
unitPrice = rentEvaluateByLocation(evaluation); officeEvaluationDto = rentEvaluateByLocation(evaluation);
} else if (district != null && district.getLat() != null) { } else if (district != null && district.getLat() != null) {
evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10));
unitPrice = rentEvaluateByLocation(evaluation); officeEvaluationDto = rentEvaluateByLocation(evaluation);
} }
} }
// 评估逻辑
evaluation.setUnitPrice(unitPrice); return officeEvaluationDto;
return evaluation;
} }
// 所在楼层 // 所在楼层
@@ -116,7 +117,7 @@ public class OfficeServiceImpl implements OfficeService {
put(4, "综合体"); put(4, "综合体");
} }
}; };
public Double calcRent(List<Seawater> seawaters, Evaluation evaluation) { public OfficeEvaluationDto calcRent(List<Seawater> seawaters, Evaluation evaluation) {
// 计算平均值 // 计算平均值
Double sum = 0.0; Double sum = 0.0;
Double size = 0.0; Double size = 0.0;
@@ -242,14 +243,20 @@ public class OfficeServiceImpl implements OfficeService {
size += seawater.getArea(); size += seawater.getArea();
} }
} }
OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto();
if (size > 0) { if (size > 0) {
unitPrice = DataUtil.roundDouble(sum / size / 30 * factor, 2); 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 @Override
public Evaluation addressEvaluateRent(Evaluation evaluation) { public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) {
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
evaluation.setFloor(null); evaluation.setFloor(null);
evaluation.setHeight(null); evaluation.setHeight(null);
@@ -257,12 +264,12 @@ public class OfficeServiceImpl implements OfficeService {
// 评估逻辑 // 评估逻辑
String location = getLocation(evaluation.getCity(), evaluation.getAddress()); String location = getLocation(evaluation.getCity(), evaluation.getAddress());
evaluation.setLocation(location); evaluation.setLocation(location);
Double unitPrice = rentEvaluateByLocation(evaluation); OfficeEvaluationDto officeEvaluationDto = rentEvaluateByLocation(evaluation);
evaluation.setUnitPrice(unitPrice);
return evaluation; return officeEvaluationDto;
} }
private Double rentEvaluateByLocation(Evaluation evaluation) { private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) {
if (StringUtils.isNotBlank(evaluation.getLocation())) { if (StringUtils.isNotBlank(evaluation.getLocation())) {
Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]);
Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]);
@@ -300,8 +307,10 @@ public class OfficeServiceImpl implements OfficeService {
query.setRadius(3000); query.setRadius(3000);
seawaters = seawaterService.findSeawatersByQuery(query); seawaters = seawaterService.findSeawatersByQuery(query);
} }
OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto();
if (CollectionUtils.isNotEmpty(seawaters)) { if (CollectionUtils.isNotEmpty(seawaters)) {
return calcRent(seawaters, evaluation); officeEvaluationDto = calcRent(seawaters, evaluation);
return officeEvaluationDto;
} }
} }
return null; return null;
@@ -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> seawater;
private String district;
private String name;
public Double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Double unitPrice) {
this.unitPrice = unitPrice;
}
public List<Seawater> getSeawater() {
return seawater;
}
public void setSeawater(List<Seawater> 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;
}
}
@@ -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> seawater;
public Double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Double unitPrice) {
this.unitPrice = unitPrice;
}
public List<Seawater> getSeawater() {
return seawater;
}
public void setSeawater(List<Seawater> seawater) {
this.seawater = seawater;
}
}