新增写字楼城市出售查询接口
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
package com.fangjia.dal.mongo.dao.office;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.model.OfficeSellStat;
|
||||
|
||||
public interface OfficeSellStatDao extends MongoDao<OfficeSellStat> {
|
||||
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.fangjia.dal.mongo.dao.office;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.OfficeSellStat;
|
||||
|
||||
public class OfficeSellStatDaoImpl extends MongoDaoImpl<OfficeSellStat> implements OfficeSellStatDao {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.fangjia.dal.mongo.model;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "fangjia_stat.office_sell_stat")
|
||||
public class OfficeSellStat implements MongoEntity {
|
||||
private static final long serialVersionUID = 4425229045088250573L;
|
||||
|
||||
private String id;
|
||||
private String cat;
|
||||
private String city;
|
||||
private Integer date;
|
||||
private String district;
|
||||
private String name;
|
||||
private Double avgPrice;
|
||||
private String estateType2;
|
||||
private String bedKind;
|
||||
@JsonIgnore
|
||||
private Object location;
|
||||
private Integer calcType;
|
||||
private Date updatedDate;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "_id", unique = true, nullable = false)
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "cat")
|
||||
public String getCat() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public void setCat(String cat) {
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Column(name = "date")
|
||||
public Integer getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Integer date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
@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 = "avg_price")
|
||||
public Double getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(Double avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Column(name = "location")
|
||||
public Object getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Object location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "calc_type")
|
||||
public Integer getCalcType() {
|
||||
return calcType;
|
||||
}
|
||||
|
||||
public void setCalcType(Integer calcType) {
|
||||
this.calcType = calcType;
|
||||
}
|
||||
|
||||
@Column(name = "updated_date")
|
||||
public Date getUpdatedDate() {
|
||||
return updatedDate;
|
||||
}
|
||||
|
||||
public void setUpdatedDate(Date updatedDate) {
|
||||
this.updatedDate = updatedDate;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.fangjia.open.controllers;
|
||||
|
||||
import com.fangjia.core.RegionData;
|
||||
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.OfficeSellStat;
|
||||
import com.fangjia.open.HttpCode;
|
||||
import com.fangjia.open.OpenHttpCodeEnum;
|
||||
import com.fangjia.open.interceptors.Authority;
|
||||
import com.fangjia.open.interceptors.Role;
|
||||
import com.fangjia.open.model.BasicModel;
|
||||
import com.fangjia.open.model.RestfulModelAndView;
|
||||
import com.fangjia.service.datastore.OfficeService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liuhongyang
|
||||
* @since 2025/3/25
|
||||
*/
|
||||
@Authority(role = Role.USER)
|
||||
public class OfficeSellController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OfficeSellController.class);
|
||||
|
||||
private OfficeService officeService;
|
||||
|
||||
/**
|
||||
* 城市写字楼出售均价
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (StringUtils.isBlank(city)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city不能为null"));
|
||||
return mav;
|
||||
}
|
||||
if (!RegionData.isCity(city)) {
|
||||
String formatCity = RegionData.formatCity(city);
|
||||
if (StringUtils.isNotBlank(formatCity)) {
|
||||
city = formatCity;
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city非法"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
ServerArea serverArea = ServerAreaData.getServerAreaByCity(city);
|
||||
if (null == serverArea) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city非法"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (startDate == null || endDate == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("startDate或endDate不能为null"));
|
||||
return mav;
|
||||
}
|
||||
if (startDate > endDate) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
List<OfficeSellStat> sellList = officeService.findOfficeSellStat(city, null, null, "city", startDate, endDate);
|
||||
|
||||
if (CollectionUtils.isEmpty(sellList)) {
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有写字楼均价数据"));
|
||||
return mav;
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(sellList));
|
||||
return mav;
|
||||
}
|
||||
|
||||
public void setOfficeService(OfficeService officeService) {
|
||||
this.officeService = officeService;
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -2,6 +2,7 @@ package com.fangjia.service.datastore;
|
||||
|
||||
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.seaweed.model.District;
|
||||
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
|
||||
|
||||
@@ -41,4 +42,15 @@ public interface OfficeService {
|
||||
* @return
|
||||
*/
|
||||
OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation);
|
||||
|
||||
/**
|
||||
* 城市写字楼出售均价
|
||||
*
|
||||
* @param city
|
||||
* @param region
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<OfficeSellStat> findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate);
|
||||
}
|
||||
|
||||
+48
-1
@@ -8,8 +8,10 @@ import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SeawaterQuery;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao;
|
||||
import com.fangjia.dal.mongo.dao.office.OfficeSellStatDao;
|
||||
import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
import com.fangjia.dal.mongo.model.OfficeSellStat;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
|
||||
@@ -34,7 +36,7 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
private OfficeRentStatDao officeRentStatDao;
|
||||
private SeawaterService seawaterService;
|
||||
|
||||
private OfficeSellStatDao officeSellStatDao;
|
||||
|
||||
@Override
|
||||
public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) {
|
||||
@@ -488,6 +490,47 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
return regionStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OfficeSellStat> findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) {
|
||||
return CacheUtils.getValue(this.getClass(), "findOfficeSellStat", city + region + name + startDate + endDate,
|
||||
CacheUtils.CachePolicyEnum.MIDDLE, new Closure<List<OfficeSellStat>, String>() {
|
||||
public List<OfficeSellStat> execute(String input) {
|
||||
return doFindOfficeSellStat(city, region, name, cat, startDate, endDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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("开始日期不能为空");
|
||||
}
|
||||
if (endDate == null) {
|
||||
throw new IllegalArgumentException("结束日期不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(cat)) {
|
||||
throw new IllegalArgumentException("cat不能为空");
|
||||
}
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
params.add(new QueryParam("district", region));
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
params.add(new QueryParam("name", name));
|
||||
}
|
||||
params.add(new QueryParam("cat", cat));
|
||||
|
||||
if (startDate != null) {
|
||||
params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
|
||||
}
|
||||
if (endDate != null) {
|
||||
params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate));
|
||||
}
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", true));
|
||||
List<OfficeSellStat> sellStatList = officeSellStatDao.findAllByParams(params, sortParams);
|
||||
return sellStatList;
|
||||
}
|
||||
|
||||
public void setSeawaterService(SeawaterService seawaterService) {
|
||||
this.seawaterService = seawaterService;
|
||||
}
|
||||
@@ -495,4 +538,8 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) {
|
||||
this.officeRentStatDao = officeRentStatDao;
|
||||
}
|
||||
|
||||
public void setOfficeSellStatDao(OfficeSellStatDao officeSellStatDao) {
|
||||
this.officeSellStatDao = officeSellStatDao;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user