新增写字楼估值估值接口
This commit is contained in:
@@ -300,7 +300,6 @@ public class OfficeController {
|
||||
model.setDistrictName(district.getName());
|
||||
|
||||
Evaluation evaluation = officeService.evaluateRent(district, buildEvaluation(model, request));
|
||||
Double cityPriceCredit = null;
|
||||
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
|
||||
+72
-2
@@ -1,15 +1,23 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
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.office.OfficeRentStatDao;
|
||||
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.mongo.fangjia.SeawaterService;
|
||||
import org.sothis.core.util.Closure;
|
||||
import org.sothis.core.util.Pager;
|
||||
import weiboclient4j.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,6 +29,7 @@ import java.util.List;
|
||||
public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
private OfficeRentStatDao officeRentStatDao;
|
||||
private SeawaterService seawaterService;
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +39,54 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
String city = district.getCity();
|
||||
String region = district.getRegion();
|
||||
String name = district.getName();
|
||||
List<String> alias = district.getAlias();
|
||||
Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd"));
|
||||
Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
|
||||
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setCat("office_rent");
|
||||
query.setCityDisplay(city);
|
||||
if (StringUtils.isNotBlank(region)) {
|
||||
query.setRegion(region);
|
||||
}
|
||||
query.setStartDate(startDate);
|
||||
query.setEndDate(endDate);
|
||||
query.setDistrictName(name);
|
||||
query.setDistrictAlias(alias);
|
||||
// if (evaluation.getArea() != null && evaluation.getArea() != 0) {
|
||||
// query.setStartArea(evaluation.getArea() * 0.9);
|
||||
// query.setEndArea(evaluation.getArea() * 1.1);
|
||||
// }
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
pager.setPageSize(100);
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
List<Seawater> seawaters = seawaterService.findSeawatersByQuery(query);
|
||||
//List<Seawater> seawaters = seawaterService.findSeawatersByQuery("office_rent", city, region, name, alias, startDate, endDate);
|
||||
// 有样本
|
||||
Double unitPrice = null;
|
||||
if (seawaters.size() > 0) {
|
||||
// 计算平均值
|
||||
Double sum = 0.0;
|
||||
Double size = 0.0;
|
||||
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) {
|
||||
unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
|
||||
}
|
||||
} else if (StringUtils.isNotBlank(evaluation.getLocation())) {
|
||||
unitPrice = rentEvaluateByLocation(evaluation);
|
||||
}
|
||||
// 评估逻辑
|
||||
evaluation.setUnitPrice(3.04);
|
||||
evaluation.setUnitPrice(unitPrice);
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
@@ -42,10 +97,21 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
// 评估逻辑
|
||||
evaluation.setUnitPrice(3.05);
|
||||
String location = getLocation(evaluation.getAddress());
|
||||
evaluation.setLocation(location);
|
||||
Double unitPrice = rentEvaluateByLocation(evaluation);
|
||||
evaluation.setUnitPrice(unitPrice);
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
private Double rentEvaluateByLocation(Evaluation evaluation) {
|
||||
return 3.04;
|
||||
}
|
||||
|
||||
private String getLocation(String address) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<OfficeRentStat> findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) {
|
||||
return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate,
|
||||
CacheUtils.CachePolicyEnum.MIDDLE, new Closure<List<OfficeRentStat>, String>() {
|
||||
@@ -79,6 +145,10 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
return regionStats;
|
||||
}
|
||||
|
||||
public void setSeawaterService(SeawaterService seawaterService) {
|
||||
this.seawaterService = seawaterService;
|
||||
}
|
||||
|
||||
public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) {
|
||||
this.officeRentStatDao = officeRentStatDao;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user