Merge remote-tracking branch 'origin/master'
This commit is contained in:
+9
-2
@@ -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<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
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<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
@@ -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 {
|
||||
|
||||
+3
-2
@@ -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);
|
||||
}
|
||||
|
||||
+24
-15
@@ -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<Seawater> seawaters, Evaluation evaluation) {
|
||||
public OfficeEvaluationDto calcRent(List<Seawater> 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;
|
||||
|
||||
+52
@@ -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;
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user