新增写字楼出售估值接口
This commit is contained in:
@@ -19,6 +19,8 @@ public class OfficeRentStat implements MongoEntity {
|
||||
private String name;
|
||||
@JsonIgnore
|
||||
private Object location;
|
||||
private String estateType2;
|
||||
private String bedKind;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@@ -93,4 +95,22 @@ public class OfficeRentStat implements MongoEntity {
|
||||
public void setLocation(Object location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Column(name = "estate_type2")
|
||||
public String getEstateType2() {
|
||||
return estateType2;
|
||||
}
|
||||
|
||||
public void setEstateType2(String estateType2) {
|
||||
this.estateType2 = estateType2;
|
||||
}
|
||||
|
||||
@Column(name = "bed_kind")
|
||||
public String getBedKind() {
|
||||
return bedKind;
|
||||
}
|
||||
|
||||
public void setBedKind(String bedKind) {
|
||||
this.bedKind = bedKind;
|
||||
}
|
||||
}
|
||||
|
||||
+374
-1
@@ -1,23 +1,44 @@
|
||||
package com.fangjia.open.controllers;
|
||||
|
||||
import com.fangjia.core.RegionData;
|
||||
import com.fangjia.core.util.AnalyticsUtil;
|
||||
import com.fangjia.core.util.DataUtil;
|
||||
import com.fangjia.core.util.LoggerFactory;
|
||||
import com.fangjia.dal.common.ServerAreaData;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.mongo.model.OfficeSellStat;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.open.HttpCode;
|
||||
import com.fangjia.open.OpenHttpCodeEnum;
|
||||
import com.fangjia.open.interceptors.AuthenticationBean;
|
||||
import com.fangjia.open.interceptors.Authority;
|
||||
import com.fangjia.open.interceptors.Role;
|
||||
import com.fangjia.open.model.BasicModel;
|
||||
import com.fangjia.open.model.PropertyEvaluationModel;
|
||||
import com.fangjia.open.model.RestfulModelAndView;
|
||||
import com.fangjia.open.util.CommonUtils;
|
||||
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;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.sothis.web.mvc.ActionContext;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fangjia.open.util.CommonUtils.convertToString;
|
||||
import static com.fangjia.open.util.EvaluationFactorUtil.*;
|
||||
|
||||
/**
|
||||
* @author liuhongyang
|
||||
@@ -27,8 +48,10 @@ import java.util.List;
|
||||
public class OfficeSellController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OfficeSellController.class);
|
||||
|
||||
private OfficeService officeService;
|
||||
private DistrictService districtService;
|
||||
private OpenApiLogService openApiLogService;
|
||||
private AddressMatchProxyService addressMatchProxyService;
|
||||
|
||||
/**
|
||||
* 写字楼城市出售均价
|
||||
@@ -189,8 +212,358 @@ public class OfficeSellController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写字楼售价评估
|
||||
*
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object evaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
|
||||
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("全国")
|
||||
|| model.getDistrict().contains("全国")) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,写字楼名,面积(size)为必填项"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getCity().endsWith("市")) {
|
||||
model.setCity(model.getCity().replaceAll("市$", ""));
|
||||
}
|
||||
/* 先到CPDB库中查找写字楼 */
|
||||
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office");
|
||||
if (district == null) {
|
||||
if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) {
|
||||
district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office");
|
||||
}
|
||||
if (district == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
model.setName(district.getName());
|
||||
|
||||
if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (model.getFloor() == null) {
|
||||
JSONObject structureOb = addressMatchProxyService.addressStructure(district.getCity(), model.getAddress());
|
||||
if (structureOb != null) {
|
||||
if (structureOb.containsKey("buildingNumber")) {
|
||||
model.setBuildingNumber(structureOb.getString("buildingNumber"));
|
||||
}
|
||||
|
||||
if (structureOb.containsKey("roomNumber")) {
|
||||
String roomNumber = structureOb.getString("roomNumber");
|
||||
model.setFloor(getFloor(roomNumber));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
model.setRegion(district.getRegion());
|
||||
model.setDistrictName(district.getName());
|
||||
|
||||
OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request));
|
||||
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
districtPriceMap.put("city", district.getCity());
|
||||
districtPriceMap.put("district", district.getRegion());
|
||||
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 {
|
||||
if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
|
||||
openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/evaluateSell");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return mav;
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该写字楼的评估").markNoData());
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写字楼售价地址估值
|
||||
*
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getCity().endsWith("市")) {
|
||||
model.setCity(model.getCity().replaceAll("市$", ""));
|
||||
}
|
||||
|
||||
if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (model.getFloor() == null) {
|
||||
JSONObject structureOb = addressMatchProxyService.addressStructure(model.getCity(), model.getAddress());
|
||||
if (structureOb != null) {
|
||||
if (structureOb.containsKey("buildingNumber")) {
|
||||
model.setBuildingNumber(structureOb.getString("buildingNumber"));
|
||||
}
|
||||
|
||||
if (structureOb.containsKey("roomNumber")) {
|
||||
String roomNumber = structureOb.getString("roomNumber");
|
||||
model.setFloor(getFloor(roomNumber));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
OfficeEvaluationDto evaluation = officeService.addressEvaluateSell(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.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));
|
||||
try {
|
||||
if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
|
||||
openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/addressEvaluateSell");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return mav;
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData());
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getFloor(String roomNumber) {
|
||||
if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) {
|
||||
if (roomNumber.length() == 3) {
|
||||
return Integer.valueOf(roomNumber.substring(0, 1));
|
||||
} else if (roomNumber.length() == 4) {
|
||||
return Integer.valueOf(roomNumber.substring(0, 2));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过EvaluationModel组装Evaluation实体
|
||||
*
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) {
|
||||
Evaluation evaluation = new Evaluation();
|
||||
evaluation.setLevel(model.getLevel());
|
||||
evaluation.setFitment(model.getFitment());
|
||||
evaluation.setType(model.getType());
|
||||
|
||||
evaluation.setCity(model.getCity());
|
||||
evaluation.setRegion(model.getRegion());
|
||||
evaluation.setDistrictName(model.getName());
|
||||
evaluation.setAddress(model.getAddress());
|
||||
evaluation.setDirection(model.getDirection());
|
||||
evaluation.setNoise(NOISE.get(model.getNoise()));
|
||||
evaluation.setType(model.getType());
|
||||
evaluation.setSight(SIGHT.get(model.getView()));
|
||||
evaluation.setAtticArea(model.getAtticSize());
|
||||
evaluation.setTerraceArea(model.getOuterSize());
|
||||
evaluation.setBasementArea(model.getBasementSize());
|
||||
evaluation.setGardenArea(model.getGardenSize());
|
||||
String worryFacility = model.getNegativeFactor();
|
||||
evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility));
|
||||
evaluation.setCreationDate(new Date());
|
||||
evaluation.setModificationDate(new Date());
|
||||
evaluation.setClientNo(model.getClientNo());
|
||||
if (0 != model.getAge()) {
|
||||
evaluation.setAge(model.getAge());
|
||||
}
|
||||
evaluation.setArea(model.getSize());
|
||||
if (ArrayUtils.isNotEmpty(model.getBuildQuality())) {
|
||||
evaluation.setBuildQuality(convertToString(model.getBuildQuality()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getBuildType())) {
|
||||
evaluation.setBuildType(model.getBuildType());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getCarport())) {
|
||||
evaluation.setCarport(model.getCarport());
|
||||
}
|
||||
if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) {
|
||||
evaluation.setFitmentAge(model.getDecorationAge());
|
||||
}
|
||||
evaluation.setCarportPrice(model.getCarportPrice());
|
||||
evaluation.setCity(model.getCity());
|
||||
evaluation.setDistrictName(model.getName());
|
||||
if (model.getDecorationCost() != null && model.getDecorationCost() > 0) {
|
||||
evaluation.setFitmentCharge(model.getDecorationCost());
|
||||
}
|
||||
if (0 != model.getHall()) {
|
||||
evaluation.setHall(model.getHall());
|
||||
}
|
||||
if (null != model.getFloor()) {
|
||||
evaluation.setFloor(model.getFloor());
|
||||
}
|
||||
if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) {
|
||||
evaluation.setHeight(model.getMaxFloor());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getBuildingNumber())) {
|
||||
evaluation.setHouseNum(model.getBuildingNumber());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getHouseProperty())) {
|
||||
evaluation.setHouseProperty(model.getHouseProperty());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getInsidepos())) {
|
||||
evaluation.setInsidepos(model.getInsidepos());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getLightingVentilation())) {
|
||||
evaluation.setLightingVentilation(model.getLightingVentilation());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(model.getOtherFactor())) {
|
||||
evaluation.setOtherFactor(model.getOtherFactor());
|
||||
}
|
||||
evaluation.setRegion(model.getDistrict());
|
||||
if (null != model.getRoom()) {
|
||||
evaluation.setRoom(model.getRoom());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getRoomNumber())) {
|
||||
evaluation.setRoomNum(model.getRoomNumber());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getSideset())) {
|
||||
evaluation.setSideset(model.getSideset());
|
||||
}
|
||||
if (0 != model.getToilet()) {
|
||||
evaluation.setToilet(model.getToilet());
|
||||
}
|
||||
if (model.getFacilities() != null) {
|
||||
String facilities = model.getFacilities();
|
||||
String[] fs = facilities.split(",");
|
||||
for (int i = 0; i < fs.length; i++) {
|
||||
fs[i] = FACILITIES.get(fs[i]);
|
||||
}
|
||||
evaluation.setFacilities(convertToString(fs));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(model.getFacade())) {
|
||||
evaluation.setFacade(model.getFacade());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getTraffice())) {
|
||||
evaluation.setTraffice(model.getTraffice());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getShape())) {
|
||||
evaluation.setShape(model.getShape());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getObstacle())) {
|
||||
evaluation.setObstacle(model.getObstacle());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getIndustry())) {
|
||||
evaluation.setIndustry(model.getIndustry());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getSupportDevice())) {
|
||||
evaluation.setSupportDevice(model.getSupportDevice());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getLeftPosition())) {
|
||||
evaluation.setLeftPosition(model.getLeftPosition());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getShopType())) {
|
||||
evaluation.setShopType(model.getShopType());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getShopUnique())) {
|
||||
evaluation.setShopUnique(model.getShopUnique());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getLocation())) {
|
||||
evaluation.setLocation(model.getLocation());
|
||||
}
|
||||
if (model.isNewDistrict()) {
|
||||
evaluation.setNewDistrict(model.isNewDistrict());
|
||||
}
|
||||
String floorDesc = "中";
|
||||
if (evaluation.getFloor() != null && evaluation.getHeight() != null) {
|
||||
Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight();
|
||||
if (floorInfo <= 0.33) {
|
||||
floorDesc = "低";
|
||||
} else if (floorInfo > 0.66) {
|
||||
floorDesc = "高";
|
||||
}
|
||||
evaluation.setFloorDesc(floorDesc);
|
||||
}
|
||||
String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest());
|
||||
evaluation.setIp(ip);
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId()));
|
||||
}
|
||||
evaluation.setSource("api_office_evaluateSell");
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
public void setOfficeService(OfficeService officeService) {
|
||||
this.officeService = officeService;
|
||||
}
|
||||
|
||||
public void setDistrictService(DistrictService districtService) {
|
||||
this.districtService = districtService;
|
||||
}
|
||||
|
||||
public void setOpenApiLogService(OpenApiLogService openApiLogService) {
|
||||
this.openApiLogService = openApiLogService;
|
||||
}
|
||||
|
||||
public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) {
|
||||
this.addressMatchProxyService = addressMatchProxyService;
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -53,4 +53,21 @@ public interface OfficeService {
|
||||
* @return
|
||||
*/
|
||||
List<OfficeSellStat> findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate);
|
||||
|
||||
/**
|
||||
* 售价评估
|
||||
*
|
||||
* @param district
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation);
|
||||
|
||||
/**
|
||||
* 售价地址维度评估
|
||||
*
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation);
|
||||
}
|
||||
|
||||
+207
-5
@@ -219,7 +219,100 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
|
||||
}
|
||||
avgPrice = avgPrice * factor;
|
||||
return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation);
|
||||
return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_rent");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public OfficeEvaluationDto calcSell(Evaluation evaluation) {
|
||||
// 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果
|
||||
// 第二步:基准价*楼层系数*装修系数*朝向系数
|
||||
// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数
|
||||
String floorDesc = evaluation.getFloorDesc();
|
||||
List<Seawater> selectedSeawaters = new ArrayList<Seawater>();
|
||||
// 第一步:按写字楼同楼层、装修、朝向选取3个,计算平均值作为结果
|
||||
List<Seawater> seawaters;
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setRegion(evaluation.getRegion());
|
||||
query.setDistrictName(evaluation.getDistrictName());
|
||||
query.setFitment(FITMENT_MAP.get(evaluation.getFitment()));
|
||||
query.setDirection(DIRECTION_MAP.get(evaluation.getDirection()));
|
||||
query.setCat("office_sell");
|
||||
query.setRadius(3000);
|
||||
|
||||
Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd"));
|
||||
Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
|
||||
query.setStartDate(startDate);
|
||||
query.setEndDate(endDate);
|
||||
|
||||
query.setCityDisplay(evaluation.getCity());
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
pager.setPageSize(100);
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
seawaters = seawaterService.findSeawatersByQuery(query);
|
||||
if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) {
|
||||
for (Seawater seawater : seawaters) {
|
||||
boolean sameFloorDesc = false;
|
||||
|
||||
if (seawater.getFloorInfo() != null && floorDesc != null) {
|
||||
if (seawater.getFloorInfo().contains(floorDesc)) {
|
||||
sameFloorDesc = true;
|
||||
} else {
|
||||
try {
|
||||
Integer floor = Integer.parseInt(seawater.getFloorInfo());
|
||||
if (floor <= 6 && "低".equals(floorDesc)) {
|
||||
sameFloorDesc = true;
|
||||
} else if (floor > 6 && floor <= 15 && "中".equals(floorDesc)) {
|
||||
sameFloorDesc = true;
|
||||
} else if (floor > 15 && "高".equals(floorDesc)) {
|
||||
sameFloorDesc = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sameFloorDesc) {
|
||||
selectedSeawaters.add(seawater);
|
||||
}
|
||||
if (selectedSeawaters.size() == 3) {
|
||||
return getOfficeEvaluationDto(selectedSeawaters, evaluation);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 查找基准价
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("cat", "office"));
|
||||
params.add(new QueryParam("city", evaluation.getCity()));
|
||||
params.add(new QueryParam("district", evaluation.getRegion()));
|
||||
params.add(new QueryParam("name", evaluation.getDistrictName()));
|
||||
// 获取上个月yyyyMM日期
|
||||
String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM");
|
||||
params.add(new QueryParam("date", Integer.parseInt(date)));
|
||||
|
||||
// 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", false));
|
||||
|
||||
// 第二步:基准价*楼层系数*装修系数*朝向系数
|
||||
OfficeSellStat officeSellStat = officeSellStatDao.findFirstByParams(params);
|
||||
Double avgPrice = officeSellStat.getAvgPrice();
|
||||
if (avgPrice != null) {
|
||||
Double factor = 1.0;
|
||||
if (evaluation.getFitment() != null) {
|
||||
factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment()));
|
||||
}
|
||||
if (floorDesc != null) {
|
||||
factor *= FLOOR_FACTOR.get(floorDesc);
|
||||
}
|
||||
if (evaluation.getDirection() != null) {
|
||||
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
|
||||
}
|
||||
avgPrice = avgPrice * factor;
|
||||
return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_sell");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -232,12 +325,12 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation) {
|
||||
private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) {
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setRegion(evaluation.getRegion());
|
||||
query.setStartPrice((int) (avgPrice * 30 * 0.9));
|
||||
query.setEndPrice((int) (avgPrice * 30 * 1.1));
|
||||
query.setCat("office_rent");
|
||||
query.setCat(cat);
|
||||
query.setRadius(3000);
|
||||
|
||||
Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd"));
|
||||
@@ -381,10 +474,10 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>(5);
|
||||
if (TYPE_MAP.get(evaluation.getType()) != null) {
|
||||
params.add(new QueryParam("estate_type2", TYPE_MAP.get(evaluation.getType())));
|
||||
params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType())));
|
||||
}
|
||||
if (LEVEL_MAP.get(evaluation.getLevel()) != null) {
|
||||
params.add(new QueryParam("bed_kind", LEVEL_MAP.get(evaluation.getLevel())));
|
||||
params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel())));
|
||||
}
|
||||
params.add(new QueryParam("cat", "office"));
|
||||
params.add(new QueryParam("location", geo));
|
||||
@@ -437,6 +530,77 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
return officeEvaluationDto;
|
||||
}
|
||||
|
||||
private OfficeEvaluationDto sellEvaluateByLocation(Evaluation evaluation) {
|
||||
OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto();
|
||||
if (StringUtils.isNotBlank(evaluation.getLocation())) {
|
||||
officeEvaluationDto.setLocation(evaluation.getLocation());
|
||||
Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]);
|
||||
Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]);
|
||||
// 查询附近5个写字楼基准价
|
||||
BasicDBObject geo = new BasicDBObject();
|
||||
BasicDBObject nearQuery = new BasicDBObject();
|
||||
nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat}));
|
||||
nearQuery.append("$maxDistance", 3000);
|
||||
geo.append("$near", nearQuery);
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>(5);
|
||||
if (TYPE_MAP.get(evaluation.getType()) != null) {
|
||||
params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType())));
|
||||
}
|
||||
if (LEVEL_MAP.get(evaluation.getLevel()) != null) {
|
||||
params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel())));
|
||||
}
|
||||
params.add(new QueryParam("cat", "office"));
|
||||
params.add(new QueryParam("location", geo));
|
||||
|
||||
String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM");
|
||||
params.add(new QueryParam("date", Integer.parseInt(date)));
|
||||
|
||||
// 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", false));
|
||||
|
||||
List<OfficeSellStat> infos = officeSellStatDao.findAllByParams(params, sortParams, 5);
|
||||
if (CollectionUtils.isEmpty(infos)) {
|
||||
// 去掉类型,重新查找
|
||||
params = new ArrayList<QueryParam>(5);
|
||||
params.add(new QueryParam("cat", "office"));
|
||||
params.add(new QueryParam("location", geo));
|
||||
params.add(new QueryParam("date", Integer.parseInt(date)));
|
||||
infos = officeSellStatDao.findAllByParams(params, sortParams);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(infos)) {
|
||||
// 求均值
|
||||
Double totalPrice = 0D;
|
||||
int count = 0;
|
||||
for (OfficeSellStat officeSellStat : infos) {
|
||||
if (officeSellStat.getAvgPrice() != null) {
|
||||
totalPrice += officeSellStat.getAvgPrice();
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
Double factor = 1.0;
|
||||
if (evaluation.getFitment() != null) {
|
||||
factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment()));
|
||||
}
|
||||
if (evaluation.getFloorDesc() != null) {
|
||||
factor *= FLOOR_FACTOR.get(evaluation.getFloorDesc());
|
||||
}
|
||||
if (evaluation.getDirection() != null) {
|
||||
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
|
||||
}
|
||||
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
|
||||
officeEvaluationDto.setUnitPrice(avgPrice);
|
||||
officeEvaluationDto.setOfficeSell(infos);
|
||||
officeEvaluationDto.setCity(evaluation.getCity());
|
||||
officeEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
officeEvaluationDto.setName(evaluation.getDistrictName());
|
||||
return officeEvaluationDto;
|
||||
}
|
||||
}
|
||||
return officeEvaluationDto;
|
||||
}
|
||||
|
||||
private String getLocation(String city, String address) {
|
||||
GaodeDto gaodeDto = GeoUtils.geo(city, address);
|
||||
if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) {
|
||||
@@ -500,6 +664,44 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation) {
|
||||
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
OfficeEvaluationDto officeEvaluationDto = this.calcSell(evaluation);
|
||||
// 如果从基价表中找不到,// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数
|
||||
if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) {
|
||||
if (StringUtils.isNotBlank(evaluation.getLocation())) {
|
||||
officeEvaluationDto = sellEvaluateByLocation(evaluation);
|
||||
} else if (district != null && district.getLat() != null) {
|
||||
evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10));
|
||||
officeEvaluationDto = sellEvaluateByLocation(evaluation);
|
||||
}
|
||||
}
|
||||
|
||||
return officeEvaluationDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation) {
|
||||
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
// 评估逻辑
|
||||
// String location = getLocation(evaluation.getCity(), evaluation.getAddress());
|
||||
GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress());
|
||||
if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) {
|
||||
evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat());
|
||||
} else {
|
||||
evaluation.setLocation("");
|
||||
}
|
||||
evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict()));
|
||||
return sellEvaluateByLocation(evaluation);
|
||||
}
|
||||
|
||||
public List<OfficeSellStat> doFindOfficeSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) {
|
||||
if (startDate == null) {
|
||||
throw new IllegalArgumentException("开始日期不能为空");
|
||||
|
||||
+11
@@ -2,6 +2,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 java.util.List;
|
||||
@@ -18,6 +19,8 @@ public class OfficeEvaluationDto extends Evaluation {
|
||||
|
||||
private List<OfficeRentStat> office;
|
||||
|
||||
private List<OfficeSellStat> officeSell;
|
||||
|
||||
private String district;
|
||||
|
||||
private String name;
|
||||
@@ -62,4 +65,12 @@ public class OfficeEvaluationDto extends Evaluation {
|
||||
public void setOffice(List<OfficeRentStat> office) {
|
||||
this.office = office;
|
||||
}
|
||||
|
||||
public List<OfficeSellStat> getOfficeSell() {
|
||||
return officeSell;
|
||||
}
|
||||
|
||||
public void setOfficeSell(List<OfficeSellStat> officeSell) {
|
||||
this.officeSell = officeSell;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user