新增湖北征信定制接口
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.fangjia.dal.mongo.dao.bkoff;
|
||||
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
|
||||
public interface DealSampleDao extends MongoDao<DealSample> {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.fangjia.dal.mongo.dao.bkoff;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
|
||||
|
||||
public class DealSampleDaoImpl extends MongoDaoImpl<DealSample> implements DealSampleDao{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.fangjia.dal.mongo.model.bkoff;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "business.deal_sample")
|
||||
public class DealSample implements MongoEntity {
|
||||
private String id;
|
||||
private String city;
|
||||
private String district;
|
||||
private String name;
|
||||
private Number unitPrice;
|
||||
private Integer totalPrice;
|
||||
private Double size;
|
||||
private String type;
|
||||
private Integer floor;
|
||||
private Date caseDate;
|
||||
private String decoration;
|
||||
private String direction;//³¯Ïò
|
||||
private Integer maxFloor;
|
||||
private Integer room;
|
||||
private Integer hall;
|
||||
private Integer yearMonth;
|
||||
private String cat;
|
||||
private Object location;
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Column(name = "district")
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
@Column(name = "name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Column(name = "unitPrice")
|
||||
public Number getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Number unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
@Column(name = "totalPrice")
|
||||
public Integer getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(Integer totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
@Column(name = "size")
|
||||
public Double getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Column(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Column(name = "floor")
|
||||
public Integer getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
public void setFloor(Integer floor) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
@Column(name = "caseDate")
|
||||
public Date getCaseDate() {
|
||||
return caseDate;
|
||||
}
|
||||
|
||||
public void setCaseDate(Date caseDate) {
|
||||
this.caseDate = caseDate;
|
||||
}
|
||||
|
||||
@Column(name = "decoration")
|
||||
public String getDecoration() {
|
||||
return decoration;
|
||||
}
|
||||
|
||||
public void setDecoration(String decoration) {
|
||||
this.decoration = decoration;
|
||||
}
|
||||
|
||||
@Column(name = "direction")
|
||||
public String getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(String direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Column(name = "maxFloor")
|
||||
public Integer getMaxFloor() {
|
||||
return maxFloor;
|
||||
}
|
||||
|
||||
public void setMaxFloor(Integer maxFloor) {
|
||||
this.maxFloor = maxFloor;
|
||||
}
|
||||
|
||||
@Column(name = "room")
|
||||
public Integer getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(Integer room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
@Column(name = "hall")
|
||||
public Integer getHall() {
|
||||
return hall;
|
||||
}
|
||||
|
||||
public void setHall(Integer hall) {
|
||||
this.hall = hall;
|
||||
}
|
||||
|
||||
@Column(name = "yearMonth")
|
||||
public Integer getYearMonth() {
|
||||
return yearMonth;
|
||||
}
|
||||
|
||||
public void setYearMonth(Integer yearMonth) {
|
||||
this.yearMonth = yearMonth;
|
||||
}
|
||||
|
||||
@Column(name = "cat")
|
||||
public String getCat() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public void setCat(String cat) {
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
@Column(name = "location")
|
||||
public Object getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Object location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "_id", unique = true, nullable = false)
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
+5
@@ -1,6 +1,7 @@
|
||||
package com.fangjia.open.controllers;
|
||||
|
||||
import com.fangjia.core.util.*;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
import com.fangjia.open.dto.BusinessCaseDto;
|
||||
import com.fangjia.open.interceptors.AuthenticationBean;
|
||||
@@ -11,6 +12,7 @@ import com.fangjia.open.model.BasicModel;
|
||||
import com.fangjia.open.model.CommercialModel;
|
||||
import com.fangjia.open.model.RestfulModelAndView;
|
||||
import com.fangjia.service.api.ApiUserCfgService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -78,6 +80,7 @@ public class CommercialController {
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPSELL_EVALUATE);
|
||||
if (json != null) {
|
||||
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
|
||||
if (json.containsKey("case")) {
|
||||
@@ -370,4 +373,6 @@ public class CommercialController {
|
||||
public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) {
|
||||
this.apiUserCfgService = apiUserCfgService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+190
@@ -7,6 +7,7 @@ import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
import com.fangjia.dal.seawater.model.SeawaterDto;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.open.HttpCode;
|
||||
@@ -27,12 +28,15 @@ import com.fangjia.service.datastore.FieldFilterService;
|
||||
import com.fangjia.service.datastore.OfficeService;
|
||||
import com.fangjia.service.datastore.OpenApiLogService;
|
||||
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
|
||||
import com.fangjia.service.mongo.fangjia.DealSampleService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
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.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.sothis.core.util.Pager;
|
||||
import org.sothis.web.mvc.ActionContext;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
|
||||
@@ -63,6 +67,8 @@ public class OfficeController {
|
||||
private AddressParser addressParser;
|
||||
private FieldFilterService fieldFilterService;
|
||||
private ApiUserCfgService apiUserCfgService;
|
||||
private ServerAreaService serverAreaService;
|
||||
private DealSampleService dealSampleService;
|
||||
|
||||
/**
|
||||
* 城市出租均价
|
||||
@@ -767,6 +773,13 @@ public class OfficeController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
if(district.getCity()!=null){
|
||||
ServerArea serverArea = serverAreaService.findByDisplay(district.getCity());
|
||||
if(serverArea!=null && serverArea.getNewCityGrade()>=3000){
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("当前仅支持一、二线城市,暂不支持您选择的城市"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
model.setRegion(district.getRegion());
|
||||
model.setDistrictName(district.getName());
|
||||
@@ -787,6 +800,121 @@ public class OfficeController {
|
||||
}
|
||||
|
||||
|
||||
public Object rentSampleAction(PropertyEvaluationModel model, HttpServletRequest request) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
|
||||
if (StringUtils.isBlank(model.getCity()) || model.getSize()<=0) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,面积为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
|
||||
return mav;
|
||||
}
|
||||
/* 先到CPDB库中查找写字楼 */
|
||||
District district = null;
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())) {
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office");
|
||||
}
|
||||
|
||||
if (district == null && (StringUtils.isNotBlank(model.getName()) || StringUtils.isNotBlank(model.getAddress()))) {
|
||||
JSONObject resultObject = null;
|
||||
if(StringUtils.isNotBlank(model.getAddress())){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getAddress(), "office", false);
|
||||
}else if(StringUtils.isNotBlank(model.getName())){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName(), "office", false);
|
||||
}
|
||||
if(resultObject != null){
|
||||
String id = (String) resultObject.get("id");
|
||||
district = districtService.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (district == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
model.setName(district.getName());
|
||||
|
||||
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(district.getCity()!=null){
|
||||
ServerArea serverArea = serverAreaService.findByDisplay(district.getCity());
|
||||
if(serverArea!=null && serverArea.getNewCityGrade()>=3000){
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("当前仅支持一、二线城市,暂不支持您选择的城市"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
model.setRegion(district.getRegion());
|
||||
model.setDistrictName(district.getName());
|
||||
|
||||
OfficeEvaluationDto evaluation = officeService.evaluateRent(district, buildEvaluation(model, request));
|
||||
Double minPrice = null;
|
||||
Double maxPrice = null;
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
if (model.getPageSize() != null) {
|
||||
if(model.getPageSize() <=50){
|
||||
pager.setPageSize(model.getPageSize());
|
||||
}else{
|
||||
pager.setPageSize(50);
|
||||
}
|
||||
} else {
|
||||
pager.setPageSize(5);
|
||||
}
|
||||
|
||||
if(model.getMinPrice() == null){
|
||||
if(evaluation != null) {
|
||||
minPrice = evaluation.getUnitPrice() - evaluation.getUnitPrice() * 0.1;
|
||||
maxPrice = evaluation.getUnitPrice() + evaluation.getUnitPrice().intValue() * 0.1;
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null && model.getMinPrice()>0){
|
||||
minPrice = model.getMinPrice().doubleValue();
|
||||
}
|
||||
if(model.getMaxPrice() != null && model.getMaxPrice()>0){
|
||||
maxPrice = model.getMaxPrice().doubleValue();
|
||||
}
|
||||
}
|
||||
|
||||
Double lng = district.getLng()/10000000000.0;
|
||||
Double lat = district.getLat()/10000000000.0;
|
||||
List<DealSample> houseSelf = dealSampleService.querySampleByLocation(lng, lat, DataUtil.getDoubleRound(2, minPrice), DataUtil.getDoubleRound(2, maxPrice), "office_rent", pager.getPageSize());
|
||||
List<BusinessCaseDto> createBusiness = createSample(houseSelf, "office_rent", district, ratio, lng, lat);
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
|
||||
if(createBusiness!=null && createBusiness.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
// mav.setModel(BasicModel.buildOKModel().markNoData());
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Integer getFloor(String roomNumber) {
|
||||
if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) {
|
||||
if (roomNumber.length() == 3) {
|
||||
@@ -1039,6 +1167,60 @@ public class OfficeController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private List<BusinessCaseDto> createSample(List<DealSample> seawaterDtos, String cat, District district, Double ratio, Double lng, Double lat){
|
||||
if(seawaterDtos != null && seawaterDtos.size()>0){
|
||||
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
|
||||
for(DealSample house : seawaterDtos){
|
||||
BusinessCaseDto dto = new BusinessCaseDto();
|
||||
dto.setCity(house.getCity());
|
||||
dto.setDistrict(house.getDistrict());
|
||||
dto.setName(house.getName());
|
||||
|
||||
if(ratio != null){
|
||||
Integer totalPrice = (int) (house.getTotalPrice()*ratio);
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = totalPrice/(house.getSize()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
Integer avgPrie = (int)(totalPrice/house.getSize());
|
||||
dto.setUnitPrice(avgPrie);
|
||||
}
|
||||
dto.setTotalPrice(totalPrice);
|
||||
}else{
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getSize()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(house.getType())){
|
||||
dto.setType(house.getType());
|
||||
}
|
||||
|
||||
Map<String, Double> locationMap = (Map) house.getLocation();
|
||||
double distance = GeoUtils.calculateDistance(locationMap.get("lon"), locationMap.get("lat"), lng, lat);
|
||||
dto.setDistance((int)distance);
|
||||
|
||||
dto.setSize(house.getSize());
|
||||
if (house.getYearMonth() != null && house.getYearMonth() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getYearMonth());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
dto.setCaseDate(formattedDate);
|
||||
}
|
||||
dtos.add(dto);
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOpenApiLogService(OpenApiLogService openApiLogService) {
|
||||
this.openApiLogService = openApiLogService;
|
||||
@@ -1067,4 +1249,12 @@ public class OfficeController {
|
||||
public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) {
|
||||
this.apiUserCfgService = apiUserCfgService;
|
||||
}
|
||||
|
||||
public void setServerAreaService(ServerAreaService serverAreaService) {
|
||||
this.serverAreaService = serverAreaService;
|
||||
}
|
||||
|
||||
public void setDealSampleService(DealSampleService dealSampleService) {
|
||||
this.dealSampleService = dealSampleService;
|
||||
}
|
||||
}
|
||||
|
||||
+215
@@ -10,6 +10,8 @@ import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.mongo.model.OfficeSellStat;
|
||||
import com.fangjia.dal.mongo.model.SqmetreRent;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
import com.fangjia.dal.seawater.model.SeawaterDto;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.open.HttpCode;
|
||||
@@ -28,12 +30,15 @@ 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 com.fangjia.service.mongo.fangjia.DealSampleService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import net.sf.json.JSONArray;
|
||||
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.core.util.Pager;
|
||||
import org.sothis.web.mvc.ActionContext;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
|
||||
@@ -57,6 +62,8 @@ public class OfficeSellController {
|
||||
private OpenApiLogService openApiLogService;
|
||||
private AddressMatchProxyService addressMatchProxyService;
|
||||
private ApiUserCfgService apiUserCfgService;
|
||||
private ServerAreaService serverAreaService;
|
||||
private DealSampleService dealSampleService;
|
||||
/**
|
||||
* 写字楼城市出售均价
|
||||
*
|
||||
@@ -284,6 +291,15 @@ public class OfficeSellController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
if(district.getCity()!=null){
|
||||
ServerArea serverArea = serverAreaService.findByDisplay(district.getCity());
|
||||
if(serverArea!=null && serverArea.getNewCityGrade()>=3000){
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("当前仅支持一、二线城市,暂不支持您选择的城市"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (model.getFloor() == null) {
|
||||
JSONObject structureOb = addressMatchProxyService.addressStructure(district.getCity(), model.getAddress());
|
||||
if (structureOb != null) {
|
||||
@@ -486,6 +502,15 @@ public class OfficeSellController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if(district.getCity()!=null){
|
||||
ServerArea serverArea = serverAreaService.findByDisplay(district.getCity());
|
||||
if(serverArea!=null && serverArea.getNewCityGrade()>=3000){
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("当前仅支持一、二线城市,暂不支持您选择的城市"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
model.setRegion(district.getRegion());
|
||||
model.setDistrictName(district.getName());
|
||||
OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request));
|
||||
@@ -504,6 +529,132 @@ public class OfficeSellController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 湖北征信定制写字楼案例接口
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object sellSampleAction(PropertyEvaluationModel model, HttpServletRequest request) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
|
||||
if (StringUtils.isBlank(model.getCity()) || model.getSize()<=0) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,面积为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
/* 先到CPDB库中查找写字楼 */
|
||||
District district = null;
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())) {
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office");
|
||||
}
|
||||
if (district == null) {
|
||||
if (StringUtils.isNotBlank(model.getDistrict()) && (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity()))) {
|
||||
district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (district == null && (StringUtils.isNotBlank(model.getName()) || StringUtils.isNotBlank(model.getAddress()))) {
|
||||
JSONObject resultObject = null;
|
||||
if(StringUtils.isNotBlank(model.getAddress())){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getAddress(), "office", false);
|
||||
}else if(StringUtils.isNotBlank(model.getName())){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName(), "office", false);
|
||||
}
|
||||
if(resultObject != null){
|
||||
String id = (String) resultObject.get("id");
|
||||
district = districtService.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (district == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在"));
|
||||
return mav;
|
||||
}
|
||||
model.setName(district.getName());
|
||||
|
||||
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(district.getCity()!=null){
|
||||
ServerArea serverArea = serverAreaService.findByDisplay(district.getCity());
|
||||
if(serverArea!=null && serverArea.getNewCityGrade()>=3000){
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("当前仅支持一、二线城市,暂不支持您选择的城市"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
model.setRegion(district.getRegion());
|
||||
model.setDistrictName(district.getName());
|
||||
OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request));
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
if (model.getPageSize() != null) {
|
||||
if(model.getPageSize() <=50){
|
||||
pager.setPageSize(model.getPageSize());
|
||||
}else{
|
||||
pager.setPageSize(50);
|
||||
}
|
||||
} else {
|
||||
pager.setPageSize(5);
|
||||
}
|
||||
|
||||
if(model.getMinPrice() == null){
|
||||
if(evaluation != null) {
|
||||
int minPrice = (int) (evaluation.getUnitPrice().intValue() - evaluation.getUnitPrice() * 0.1);
|
||||
model.setMinPrice(minPrice);
|
||||
|
||||
int maxPrice = (int) (evaluation.getUnitPrice() + evaluation.getUnitPrice().intValue() * 0.1);
|
||||
model.setMaxPrice(maxPrice);
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null && model.getMinPrice()>0){
|
||||
model.setMinPrice(model.getMinPrice());
|
||||
}
|
||||
if(model.getMaxPrice() != null && model.getMaxPrice()>0){
|
||||
model.setMaxPrice(model.getMaxPrice());
|
||||
}
|
||||
}
|
||||
|
||||
Double lng = district.getLng()/10000000000.0;
|
||||
Double lat = district.getLat()/10000000000.0;
|
||||
List<DealSample> houseSelf = dealSampleService.querySampleByLocation(lng, lat, model.getMinPrice(), model.getMaxPrice(), "office_sell", pager.getPageSize());
|
||||
List<BusinessCaseDto> createBusiness = createSample(houseSelf, "office_sell", district, ratio, lng, lat);
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
|
||||
if(createBusiness !=null && createBusiness.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
// mav.setModel(BasicModel.buildOKModel().markNoData());
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Integer getFloor(String roomNumber) {
|
||||
if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) {
|
||||
if (roomNumber.length() == 3) {
|
||||
@@ -731,6 +882,62 @@ public class OfficeSellController {
|
||||
}
|
||||
|
||||
|
||||
private List<BusinessCaseDto> createSample(List<DealSample> seawaterDtos, String cat, District district, Double ratio, Double lng, Double lat){
|
||||
if(seawaterDtos != null && seawaterDtos.size()>0){
|
||||
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
|
||||
for(DealSample house : seawaterDtos){
|
||||
BusinessCaseDto dto = new BusinessCaseDto();
|
||||
dto.setCity(house.getCity());
|
||||
dto.setDistrict(house.getDistrict());
|
||||
dto.setName(house.getName());
|
||||
|
||||
if(ratio != null){
|
||||
Integer totalPrice = (int) (house.getTotalPrice()*ratio);
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = totalPrice/(house.getSize()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
Integer avgPrie = (int)(totalPrice/house.getSize());
|
||||
dto.setUnitPrice(avgPrie);
|
||||
}
|
||||
dto.setTotalPrice(totalPrice);
|
||||
}else{
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getSize()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(house.getType())){
|
||||
dto.setType(house.getType());
|
||||
}
|
||||
|
||||
Map<String, Double> locationMap = (Map) house.getLocation();
|
||||
double distance = GeoUtils.calculateDistance(locationMap.get("lon"), locationMap.get("lat"), lng, lat);
|
||||
dto.setDistance((int)distance);
|
||||
|
||||
dto.setSize(house.getSize());
|
||||
if (house.getYearMonth() != null && house.getYearMonth() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getYearMonth());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
dto.setCaseDate(formattedDate);
|
||||
}
|
||||
dtos.add(dto);
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Double getUserPriceRatio(HttpServletRequest request){
|
||||
Double ratio = null;
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
@@ -765,4 +972,12 @@ public class OfficeSellController {
|
||||
public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) {
|
||||
this.apiUserCfgService = apiUserCfgService;
|
||||
}
|
||||
|
||||
public void setServerAreaService(ServerAreaService serverAreaService) {
|
||||
this.serverAreaService = serverAreaService;
|
||||
}
|
||||
|
||||
public void setDealSampleService(DealSampleService dealSampleService) {
|
||||
this.dealSampleService = dealSampleService;
|
||||
}
|
||||
}
|
||||
|
||||
+202
-6
@@ -25,6 +25,8 @@ import com.fangjia.core.util.*;
|
||||
import com.fangjia.dal.*;
|
||||
import com.fangjia.dal.mongo.dao.AliasFangDao;
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.dal.mongo.model.bkoff.*;
|
||||
import com.fangjia.dal.mongo.model.bkoff.HouseLoudong;
|
||||
import com.fangjia.dal.mongo.open.model.CommunityBasePrice;
|
||||
import com.fangjia.dal.mongo.open.model.CommunityPoi;
|
||||
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
|
||||
@@ -66,10 +68,6 @@ import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.common.ServerAreaData;
|
||||
import com.fangjia.dal.datastore.model.House;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
|
||||
import com.fangjia.dal.mongo.model.bkoff.HouseAuction;
|
||||
import com.fangjia.dal.mongo.model.bkoff.HouseLoudong;
|
||||
import com.fangjia.dal.mongo.model.bkoff.Loudong;
|
||||
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.dal.sql.model.ApiUser;
|
||||
@@ -179,6 +177,7 @@ public class PropertyController {
|
||||
private CommunityBasePriceService communityBasePriceService;
|
||||
private EvaluateFactorService evaluateFactorService;
|
||||
|
||||
|
||||
private FileDao fileDao = FileDao.getInstance();
|
||||
private static final int DEFAULT_PAGE_SIZE = 20;
|
||||
private static final int DEFAULT_HOUSE_COUNT = 5;
|
||||
@@ -195,6 +194,7 @@ public class PropertyController {
|
||||
private RentDealPriceService rentDealPriceService;
|
||||
private EvaluateRatioService evaluateRatioService;
|
||||
private AliasFangService aliasFangService;
|
||||
private DealSampleService dealSampleService;
|
||||
|
||||
private static final int EVALUATE_SHOW_DETAIL = 1;
|
||||
private static final Map<String, String> PROPERTY_TYPES = new HashMap<String, String>() {
|
||||
@@ -6245,10 +6245,10 @@ public class PropertyController {
|
||||
model.setMaxPrice(maxPrice);
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null && model.getMinPrice()>0){
|
||||
if(model.getMinPrice() != null ){
|
||||
model.setMinPrice(model.getMinPrice());
|
||||
}
|
||||
if(model.getMaxPrice() != null && model.getMaxPrice()>0){
|
||||
if(model.getMaxPrice() != null ){
|
||||
model.setMaxPrice(model.getMaxPrice());
|
||||
}
|
||||
}
|
||||
@@ -6385,6 +6385,12 @@ public class PropertyController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 公用案例接口
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object rentCaseAction(PropertyEvaluationModel model, HttpServletRequest request){
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
@@ -6580,6 +6586,116 @@ public class PropertyController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 湖北征信定制接口
|
||||
* @param model
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Object rentSampleAction(PropertyEvaluationModel model, HttpServletRequest request){
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
|
||||
if (StringUtils.isBlank(model.getCity())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
District district = null;
|
||||
String estateType = null;
|
||||
if(StringUtils.isNotBlank(model.getPropertyType())){
|
||||
if(model.getPropertyType().equals("0")){
|
||||
estateType = "普通住宅";
|
||||
}else if(model.getPropertyType().equals("1")){
|
||||
estateType = "别墅";
|
||||
}else if(model.getPropertyType().equals("2")){
|
||||
estateType = "商住";
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())){
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
|
||||
}
|
||||
|
||||
if (district == null && (StringUtils.isNotBlank(model.getName()) || StringUtils.isNotBlank(model.getAddress()))) {
|
||||
JSONObject resultObject = null;
|
||||
if(StringUtils.isNotBlank(model.getAddress())){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getAddress(), "property", false);
|
||||
}else if(StringUtils.isNotBlank(model.getName())){
|
||||
if(estateType !=null && estateType.equals("别墅") && !model.getName().contains("别墅")){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName()+"别墅", "property", false);
|
||||
}else{
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName(), "property", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(resultObject != null){
|
||||
String id = (String) resultObject.get("id");
|
||||
district = districtService.findById(id);
|
||||
}
|
||||
}
|
||||
if(district == null && StringUtils.isBlank(model.getLocation())){
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(null));
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
List<HouseCaseDto> caseDtos = new ArrayList<HouseCaseDto>();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
if (model.getPageSize() != null) {
|
||||
if(model.getPageSize() <=50){
|
||||
pager.setPageSize(model.getPageSize());
|
||||
}else{
|
||||
pager.setPageSize(50);
|
||||
}
|
||||
} else {
|
||||
pager.setPageSize(5);
|
||||
}
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
Double minPrice = null;
|
||||
Double maxPrice = null;
|
||||
|
||||
if(district != null){
|
||||
if(model.getMinPrice() == null){
|
||||
SqmetreRent rent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), "district");
|
||||
|
||||
if(rent != null) {
|
||||
double avgPrice = DataUtil.getRound(2, rent.getAvgPrice().intValue()/30);
|
||||
minPrice = avgPrice - avgPrice * 0.1;
|
||||
maxPrice = avgPrice + avgPrice * 0.1;
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null){
|
||||
minPrice = Double.valueOf(model.getMinPrice());
|
||||
}
|
||||
if(model.getMaxPrice() != null){
|
||||
maxPrice = Double.valueOf(model.getMaxPrice());
|
||||
}
|
||||
}
|
||||
|
||||
if(caseDtos.size() < pager.getPageSize()){
|
||||
List<DealSample> houseSelf = dealSampleService.querySampleByLocation(district.getLng()/10000000000.0, district.getLat()/10000000000.0, minPrice, maxPrice, "rent", pager.getPageSize());
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseSample(caseDtos, houseSelf, model.getShowSource(), ratio, district.getLng()/10000000000.0, district.getLat()/10000000000.0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
if(caseDtos!=null && caseDtos.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<HouseCaseDto> createDealHouseCase(List<HouseCaseDto> caseDtos, List<DealPrice> dealPrices,int distance, Integer showSource){
|
||||
@@ -6617,6 +6733,82 @@ public class PropertyController {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<HouseCaseDto> createHouseSample(List<HouseCaseDto> caseDtos, List<DealSample> houses, Integer showSource, Double ratio, Double lng, Double lat){
|
||||
if (houses != null && !houses.isEmpty()) {
|
||||
Set<String> seenIds = new HashSet<String>();
|
||||
Iterator<DealSample> iterator = houses.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
DealSample s = iterator.next();
|
||||
if (!seenIds.add(s.getId())) {
|
||||
// 如果已经存在,则从列表中移除
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for(HouseCaseDto dto : caseDtos){
|
||||
ids.add(dto.getId());
|
||||
}
|
||||
for (DealSample house : houses) {
|
||||
if(!ids.contains(house.getId())){
|
||||
HouseCaseDto caseDto = new HouseCaseDto();
|
||||
caseDto.setId(house.getId());
|
||||
caseDto.setCity(house.getCity());
|
||||
caseDto.setDistrict(house.getDistrict());
|
||||
caseDto.setName(house.getName());
|
||||
caseDto.setSize(house.getSize() == null || house.getSize() == 0 ? null : house.getSize());
|
||||
|
||||
if(house.getTotalPrice()!=null){
|
||||
if(ratio!=null){
|
||||
Integer totalPrice = new BigDecimal(house.getTotalPrice() * ratio).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
caseDto.setTotalPrice(totalPrice);
|
||||
if(house.getCat().equals("sell")){
|
||||
caseDto.setUnitPrice(new BigDecimal(totalPrice/house.getSize()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
|
||||
}else if(house.getCat().equals("rent")){
|
||||
// Double dayPrice = house.getTotalPrice()/(30*house.getArea());
|
||||
Double dayPrice = totalPrice/(30*house.getSize());
|
||||
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}
|
||||
}else{
|
||||
caseDto.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
if(house.getCat().equals("sell")){
|
||||
caseDto.setUnitPrice(house.getUnitPrice());
|
||||
}else if(house.getCat().equals("rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(30*house.getSize());
|
||||
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}
|
||||
}
|
||||
}
|
||||
caseDto.setDirection(house.getDirection());
|
||||
caseDto.setDecoration(house.getDecoration());
|
||||
caseDto.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
|
||||
caseDto.setMaxFloor(house.getMaxFloor());
|
||||
caseDto.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom().toString());
|
||||
caseDto.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall().toString());
|
||||
|
||||
if (house.getYearMonth() != null && house.getYearMonth() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getYearMonth());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
caseDto.setCaseDate(formattedDate);
|
||||
}
|
||||
|
||||
Map<String, Double> locationMap = (Map) house.getLocation();
|
||||
double distance = GeoUtils.calculateDistance(locationMap.get("lon"), locationMap.get("lat"), lng, lat);
|
||||
caseDto.setDistance((int)distance);
|
||||
if(showSource!=null && showSource==1){
|
||||
caseDto.setSource("成交");
|
||||
}
|
||||
caseDtos.add(caseDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return caseDtos;
|
||||
}
|
||||
|
||||
|
||||
private List<HouseCaseDto> createHouseCase(List<HouseCaseDto> caseDtos, List<Seawater> houses, Integer showSource, Double ratio){
|
||||
if (houses != null && !houses.isEmpty()) {
|
||||
@@ -6899,4 +7091,8 @@ public class PropertyController {
|
||||
public void setAliasFangService(AliasFangService aliasFangService) {
|
||||
this.aliasFangService = aliasFangService;
|
||||
}
|
||||
|
||||
public void setDealSampleService(DealSampleService dealSampleService) {
|
||||
this.dealSampleService = dealSampleService;
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
import scala.math.Numeric;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DealSampleService {
|
||||
List<DealSample> querySampleByLocation(Double lng, Double lat, Number minPrice, Number maxPrice, String cat, int pageSize);
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import com.fangjia.core.util.DateUtil;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.bkoff.DealSampleDao;
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealSample;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import scala.math.Numeric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class DealSampleServiceImpl implements DealSampleService{
|
||||
|
||||
private DealSampleDao dealSampleDao;
|
||||
|
||||
public DealSampleDao getDealSampleDao() {
|
||||
return dealSampleDao;
|
||||
}
|
||||
|
||||
public void setDealSampleDao(DealSampleDao dealSampleDao) {
|
||||
this.dealSampleDao = dealSampleDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DealSample> querySampleByLocation(Double lng, Double lat, Number minPrice, Number maxPrice, String cat, int pageSize) {
|
||||
if(lng!=null && lat!=null){
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
BasicDBObject geo = new BasicDBObject();
|
||||
BasicDBObject nearQuery = new BasicDBObject();
|
||||
// nearQuery.append("$geometry", new double[]{lng, lat});
|
||||
nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat}));
|
||||
nearQuery.append("$maxDistance", 3000);
|
||||
geo.append("$near", nearQuery);
|
||||
|
||||
params.add(new QueryParam("cat", cat));
|
||||
params.add(new QueryParam("location", geo));
|
||||
|
||||
Date date = DateUtil.truncateDay(DateUtil.addMonthToDate(new Date(), -12));
|
||||
params.add(new QueryParam("caseDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, date));
|
||||
|
||||
if(minPrice != null){
|
||||
params.add(new QueryParam("unitPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, minPrice));
|
||||
}
|
||||
if(maxPrice != null){
|
||||
params.add(new QueryParam("unitPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, maxPrice));
|
||||
}
|
||||
|
||||
// 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据
|
||||
// List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
// sortParams.add(new SortParam("caseDate", false));
|
||||
|
||||
List<DealSample> samples = dealSampleDao.findAllByParams(params, pageSize);
|
||||
return samples;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user