新增写字楼估值估值接口
This commit is contained in:
-4
@@ -2,10 +2,6 @@ package com.fangjia.dal.mongo.dao.office;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface OfficeRentStatDao extends MongoDao<OfficeRentStat> {
|
||||
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package com.fangjia.dal.mongo.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "fangjia.evaluation")
|
||||
public class Evaluation implements MongoEntity {
|
||||
@@ -128,6 +121,7 @@ public class Evaluation implements MongoEntity {
|
||||
//我查查状态字段
|
||||
private int statusCha;
|
||||
|
||||
private Double unitPrice;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "_id")
|
||||
@@ -180,6 +174,7 @@ public class Evaluation implements MongoEntity {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
|
||||
public void setTotalPrice(Integer totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
@@ -995,4 +990,12 @@ public class Evaluation implements MongoEntity {
|
||||
this.statusCha = statusCha;
|
||||
}
|
||||
|
||||
@Column(name = "unit_price")
|
||||
public Double getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Double unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
}
|
||||
|
||||
+384
-2
@@ -1,23 +1,43 @@
|
||||
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.OfficeRentStat;
|
||||
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 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 shenjian
|
||||
@@ -30,6 +50,12 @@ public class OfficeController {
|
||||
|
||||
private OfficeService officeService;
|
||||
|
||||
private DistrictService districtService;
|
||||
|
||||
private AddressMatchProxyService addressMatchProxyService;
|
||||
|
||||
private OpenApiLogService openApiLogService;
|
||||
|
||||
/**
|
||||
* 城市出租均价
|
||||
*
|
||||
@@ -89,6 +115,10 @@ public class OfficeController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city不能为null"));
|
||||
return mav;
|
||||
}
|
||||
if (StringUtils.isBlank(district)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("district不能为null"));
|
||||
return mav;
|
||||
}
|
||||
if (!RegionData.isCity(city)) {
|
||||
String formatCity = RegionData.formatCity(city);
|
||||
if (StringUtils.isNotBlank(formatCity)) {
|
||||
@@ -103,6 +133,11 @@ public class OfficeController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city非法"));
|
||||
return mav;
|
||||
}
|
||||
String region = RegionData.formatRegion(city, district);
|
||||
if (!RegionData.isRegion(city, region)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (startDate == null || endDate == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null"));
|
||||
@@ -113,17 +148,364 @@ public class OfficeController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
List<OfficeRentStat> regionStats = officeService.findOfficeRentStat(city, district, startDate, endDate);
|
||||
List<OfficeRentStat> regionStats = officeService.findOfficeRentStat(city, region, startDate, endDate);
|
||||
|
||||
if (CollectionUtils.isEmpty(regionStats)) {
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据"));
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据"));
|
||||
return mav;
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(regionStats));
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写字楼楼租金地址估值
|
||||
*
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object addressEvaluateRentAction(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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Evaluation 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());
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
|
||||
try {
|
||||
if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
|
||||
openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/addressEvaluateRent");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return mav;
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData());
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 写字楼租金评估
|
||||
*
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object evaluateRentAction(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(), "district");
|
||||
}
|
||||
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());
|
||||
|
||||
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>();
|
||||
districtPriceMap.put("city", district.getCity());
|
||||
districtPriceMap.put("district", district.getRegion());
|
||||
districtPriceMap.put("name", district.getName());
|
||||
districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
|
||||
try {
|
||||
if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
|
||||
openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/evaluateRent");
|
||||
}
|
||||
} 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.setCity(model.getCity());
|
||||
evaluation.setRegion(model.getRegion());
|
||||
evaluation.setDistrictName(model.getName());
|
||||
evaluation.setAddress(model.getAddress());
|
||||
evaluation.setDirection(DIRECTION.get(model.getDirection()));
|
||||
evaluation.setFitment(EVALUATION_MODEL_FITMENT.get(FITMENT.get(StringUtils.isNotBlank(model.getDecoration()) ?
|
||||
model.getDecoration() : model.getFitment())));
|
||||
evaluation.setNoise(NOISE.get(model.getNoise()));
|
||||
evaluation.setEstateType(PROPERTY_TYPES.get(model.getPropertyType()));
|
||||
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 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_evaluateRent");
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
private static final Map<String, String> FACILITIES = new HashMap<String, String>() {
|
||||
{
|
||||
put("0", "健身房");
|
||||
put("1", "游泳池");
|
||||
put("2", "会所");
|
||||
put("3", "网球场");
|
||||
put("4", "球场");
|
||||
put("5", "棋牌室");
|
||||
put("6", "停车场");
|
||||
put("7", "图书馆");
|
||||
put("8", "活动中心");
|
||||
}
|
||||
};
|
||||
|
||||
public void setOpenApiLogService(OpenApiLogService openApiLogService) {
|
||||
this.openApiLogService = openApiLogService;
|
||||
}
|
||||
|
||||
public void setOfficeService(OfficeService officeService) {
|
||||
this.officeService = officeService;
|
||||
}
|
||||
|
||||
public void setDistrictService(DistrictService districtService) {
|
||||
this.districtService = districtService;
|
||||
}
|
||||
|
||||
public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) {
|
||||
this.addressMatchProxyService = addressMatchProxyService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.fangjia.open.util;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
//¹«ÓÃ
|
||||
public class CommonUtils {
|
||||
|
||||
|
||||
//¶ÔÏóתmap
|
||||
public static Map<String, Object> convertToMap(Object obj) {
|
||||
try {
|
||||
if (obj instanceof Map) {
|
||||
return (Map)obj;
|
||||
return (Map) obj;
|
||||
}
|
||||
Map<String, Object> returnMap = BeanUtils.describe(obj);
|
||||
returnMap.remove("class");
|
||||
@@ -26,4 +29,19 @@ public class CommonUtils {
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public static String convertToString(String[] strs) {
|
||||
if (ArrayUtils.isNotEmpty(strs)) {
|
||||
StringBuffer ret = new StringBuffer();
|
||||
for (String str : strs) {
|
||||
if (StringUtils.isEmpty(ret.toString())) {
|
||||
ret.append(str);
|
||||
} else {
|
||||
ret.append(",").append(str);
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -1,6 +1,8 @@
|
||||
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 java.util.List;
|
||||
|
||||
@@ -12,6 +14,8 @@ public interface OfficeService {
|
||||
|
||||
|
||||
/**
|
||||
* 租金均价
|
||||
*
|
||||
* @param city
|
||||
* @param region
|
||||
* @param startDate
|
||||
@@ -20,4 +24,20 @@ public interface OfficeService {
|
||||
*/
|
||||
List<OfficeRentStat> findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate);
|
||||
|
||||
/**
|
||||
* 租金评估
|
||||
*
|
||||
* @param district
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
Evaluation evaluateRent(District district, Evaluation evaluation);
|
||||
|
||||
/**
|
||||
* 租金地址维度评估
|
||||
*
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
Evaluation addressEvaluateRent(Evaluation evaluation);
|
||||
}
|
||||
|
||||
+28
@@ -4,13 +4,17 @@ import com.fangjia.core.util.CacheUtils;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
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.seaweed.model.District;
|
||||
import org.sothis.core.util.Closure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 写字楼相关服务类
|
||||
*
|
||||
* @author shenjian
|
||||
* @since 2025/1/21
|
||||
*/
|
||||
@@ -18,6 +22,30 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
private OfficeRentStatDao officeRentStatDao;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Evaluation evaluateRent(District district, Evaluation evaluation) {
|
||||
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
// 评估逻辑
|
||||
evaluation.setUnitPrice(3.04);
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Evaluation addressEvaluateRent(Evaluation evaluation) {
|
||||
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
// 评估逻辑
|
||||
evaluation.setUnitPrice(3.05);
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
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>() {
|
||||
|
||||
Reference in New Issue
Block a user