优化写字楼估值

This commit is contained in:
沈健
2025-04-15 13:45:28 +08:00
parent 10f2288149
commit 1d6dbd0db3
5 changed files with 155 additions and 38 deletions
@@ -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;
}
}
@@ -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 {
@@ -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));
@@ -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<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
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<SeawaterDto> seawaterList = new ArrayList<SeawaterDto>();
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<OfficeRentStat> infos = officeRentStatDao.findAllByParams(params, sortParams, 5);
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
if (CollectionUtils.isEmpty(infos)) {
// 去掉类型,重新查找
params = new ArrayList<QueryParam>(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<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
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());
@@ -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> seawater;
private List<OfficeRentStat> office;
private List<OfficeSellStat> officeSell;
private List<SeawaterDto> 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<Seawater> getSeawater() {
public List<SeawaterDto> getSeawater() {
return seawater;
}
public void setSeawater(List<Seawater> seawater) {
public void setSeawater(List<SeawaterDto> seawater) {
this.seawater = seawater;
}
@@ -57,20 +50,4 @@ public class OfficeEvaluationDto extends Evaluation {
public void setName(String name) {
this.name = name;
}
public List<OfficeRentStat> getOffice() {
return office;
}
public void setOffice(List<OfficeRentStat> office) {
this.office = office;
}
public List<OfficeSellStat> getOfficeSell() {
return officeSell;
}
public void setOfficeSell(List<OfficeSellStat> officeSell) {
this.officeSell = officeSell;
}
}