新增商铺相关接口

This commit is contained in:
沈健
2025-04-10 13:59:58 +08:00
parent 78da212ae0
commit 4ec26e5353
12 changed files with 1506 additions and 2 deletions
@@ -0,0 +1,9 @@
package com.fangjia.dal.mongo.dao.shop;
import com.fangjia.dal.MongoDao;
import com.fangjia.dal.mongo.model.ShopRentStat;
public interface ShopRentStatDao extends MongoDao<ShopRentStat> {
}
@@ -0,0 +1,8 @@
package com.fangjia.dal.mongo.dao.shop;
import com.fangjia.dal.MongoDaoImpl;
import com.fangjia.dal.mongo.model.ShopRentStat;
public class ShopRentStatDaoImpl extends MongoDaoImpl<ShopRentStat> implements ShopRentStatDao {
}
@@ -0,0 +1,9 @@
package com.fangjia.dal.mongo.dao.shop;
import com.fangjia.dal.MongoDao;
import com.fangjia.dal.mongo.model.ShopSellStat;
public interface ShopSellStatDao extends MongoDao<ShopSellStat> {
}
@@ -0,0 +1,8 @@
package com.fangjia.dal.mongo.dao.shop;
import com.fangjia.dal.MongoDaoImpl;
import com.fangjia.dal.mongo.model.ShopSellStat;
public class ShopSellStatDaoImpl extends MongoDaoImpl<ShopSellStat> implements ShopSellStatDao {
}
@@ -0,0 +1,84 @@
package com.fangjia.dal.mongo.model;
import com.fangjia.dal.MongoEntity;
import javax.persistence.*;
@Entity
@Table(name = "fangjia_stat.shop_rent_stat")
public class ShopRentStat implements MongoEntity {
private static final long serialVersionUID = 4425229045088250573L;
private String id;
private String cat;
private String city;
private String district;
private Integer date;
private Double avgPrice;
private String name;
@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 = "district")
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
@Column(name = "date")
public Integer getDate() {
return date;
}
public void setDate(Integer date) {
this.date = date;
}
@Column(name = "avg_price")
public Double getAvgPrice() {
return avgPrice;
}
public void setAvgPrice(Double avgPrice) {
this.avgPrice = avgPrice;
}
@Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,84 @@
package com.fangjia.dal.mongo.model;
import com.fangjia.dal.MongoEntity;
import javax.persistence.*;
@Entity
@Table(name = "fangjia_stat.shop_sell_stat")
public class ShopSellStat implements MongoEntity {
private static final long serialVersionUID = 4425229045088250573L;
private String id;
private String cat;
private String city;
private String district;
private Integer date;
private Double avgPrice;
private String name;
@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 = "district")
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
@Column(name = "date")
public Integer getDate() {
return date;
}
public void setDate(Integer date) {
this.date = date;
}
@Column(name = "avg_price")
public Double getAvgPrice() {
return avgPrice;
}
public void setAvgPrice(Double avgPrice) {
this.avgPrice = avgPrice;
}
@Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,614 @@
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.HttpRequest;
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.ShopRentStat;
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.ReportApplyModel;
import com.fangjia.open.model.RestfulModelAndView;
import com.fangjia.open.util.CommonUtils;
import com.fangjia.open.util.FangJiaTongUrl;
import com.fangjia.service.address.AddressParser;
import com.fangjia.service.datastore.FieldFilterService;
import com.fangjia.service.datastore.AiShopService;
import com.fangjia.service.datastore.OpenApiLogService;
import com.fangjia.service.datastore.dto.ShopEvaluationDto;
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
* @since 2025/4/10
*/
@Authority(role = Role.USER)
public class ShopController {
private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class);
private AiShopService aiShopService;
private OpenApiLogService openApiLogService;
private AddressParser addressParser;
private FieldFilterService fieldFilterService;
/**
* 城市出租均价
*
* @return
*/
public Object cityRentAction(@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<ShopRentStat> regionStats = aiShopService.findShopRentStat(city, null, null, "city", startDate, endDate);
if (CollectionUtils.isEmpty(regionStats)) {
mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据"));
return mav;
}
mav.setModel(BasicModel.buildOKModel().setResult(regionStats));
return mav;
}
/**
* 区域出租均价
*
* @return
*/
public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district,
@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 (StringUtils.isBlank(district)) {
mav.setModel(BasicModel.buildBadRequestModel("district不能为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;
}
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"));
return mav;
}
if (startDate > endDate) {
mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate"));
return mav;
}
List<ShopRentStat> regionStats = aiShopService.findShopRentStat(city, region, null, "district", startDate, endDate);
if (CollectionUtils.isEmpty(regionStats)) {
mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该区域没有均价数据"));
return mav;
}
mav.setModel(BasicModel.buildOKModel().setResult(regionStats));
return mav;
}
/**
* 写字楼均价走势
*
* @return
*/
public Object shopRentAction(@Param(name = "city") String city, @Param(name = "district") String district,
@Param(name = "name") String name, @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 (StringUtils.isBlank(district)) {
mav.setModel(BasicModel.buildBadRequestModel("district不能为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;
}
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"));
return mav;
}
if (startDate > endDate) {
mav.setModel(BasicModel.buildBadRequestModel("startDate不能大于endDate"));
return mav;
}
List<ShopRentStat> regionStats = aiShopService.findShopRentStat(city, region, name, "shop", startDate, endDate);
if (CollectionUtils.isEmpty(regionStats)) {
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;
}
ShopEvaluationDto evaluation = aiShopService.addressEvaluateRent(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("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, "/shop/addressEvaluateRent");
}
} catch (Exception e) {
e.printStackTrace();
}
return mav;
} else {
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该地址写字楼的评估").markNoData());
return mav;
}
}
/**
* 申请估值报告
*
* @param model 申请报告请求参数
* @return
*/
public Object assessPriceReportApplyAction(ReportApplyModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
if (StringUtils.isBlank(model.getClient())) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:委托机构为必填项"));
return mav;
}
if (StringUtils.isBlank(model.getSubjectMatter())) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:标的物为必填项"));
return mav;
}
if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("全国")) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项且不能为全国"));
return mav;
}
if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("全国")) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域为必填项且不能为全国"));
return mav;
}
if (model.getSize() == null || model.getSize() <= 0 ) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:面积(size)为必填项且大于0"));
return mav;
}
if (model.getCity().endsWith("市")) {
model.setCity(model.getCity().replaceAll("市$", ""));
}
if (model.getDistrict().endsWith("区")) {
model.setDistrict(model.getDistrict().replaceAll("区$", ""));
}
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;
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("client", model.getClient());
params.put("subjectMatter", model.getSubjectMatter());
params.put("city", model.getCity());
params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null);
params.put("district", model.getDistrict());
params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null);
params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null);
params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null);
params.put("size", String.valueOf(model.getSize()));
params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null);
params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null);
params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0");
params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3");
params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2");
JSONObject jsonObject = JSONObject.fromObject(params);
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN);
headers.put("Content-Type", "application/json");
try {
String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8");
json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret));
} catch (Exception e) {
try {
String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8");
json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
if (json.getInt("code") == 200 && json.containsKey("data")) {
HashMap<String, String> result = new HashMap<String, String>();
result.put("caseId", String.valueOf(json.get("data")));
mav.setModel(BasicModel.buildOKModel().setResult(result));
} else {
mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:" + json.getString("message")));
}
} else {
mav.setModel(BasicModel.buildBadRequestModel("申请估值报告失败:调用申请报告接口返回为空"));
}
return mav;
}
/**
* 获取估值报告
*
* @param caseId 估值报告ID
* @return
*/
public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
if (StringUtils.isBlank(caseId)) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:估值报告业务编号为必填项"));
return mav;
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("caseId", caseId);
JSONObject jsonObject = JSONObject.fromObject(params);
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN);
headers.put("Content-Type", "application/json");
try {
String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8");
json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret));
} catch (Exception e) {
try {
String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8");
json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
if (json.getInt("code") == 200 && json.containsKey("data")) {
JSONObject resultJson = json.getJSONObject("data");
mav.setModel(BasicModel.buildOKModel().setResult(resultJson));
} else {
mav.setModel(BasicModel.buildBadRequestModel("获取估值报告失败:" + json.getString("message")));
}
} else {
mav.setModel(BasicModel.buildBadRequestModel("申请报告失败:调用获取估值报告接口返回为空"));
}
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_shop_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 setFieldFilterService(FieldFilterService fieldFilterService) {
this.fieldFilterService = fieldFilterService;
}
public void setAiShopService(AiShopService aiShopService) {
this.aiShopService = aiShopService;
}
}
@@ -0,0 +1,49 @@
package com.fangjia.service.datastore;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.ShopRentStat;
import com.fangjia.dal.mongo.model.ShopSellStat;
import com.fangjia.service.datastore.dto.ShopEvaluationDto;
import java.util.List;
public interface AiShopService {
/**
* 租金均价
*
* @param city
* @param region
* @param startDate
* @param endDate
* @return
*/
List<ShopRentStat> findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate);
/**
* 租金地址维度评估
*
* @param evaluation
* @return
*/
ShopEvaluationDto addressEvaluateRent(Evaluation evaluation);
/**
* 城市写字楼出售均价
*
* @param city
* @param region
* @param startDate
* @param endDate
* @return
*/
List<ShopSellStat> findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate);
/**
* 售价地址维度评估
*
* @param evaluation
* @return
*/
ShopEvaluationDto addressEvaluateSell(Evaluation evaluation);
}
@@ -0,0 +1,553 @@
package com.fangjia.service.datastore;
import com.fangjia.core.RegionData;
import com.fangjia.core.util.CacheUtils;
import com.fangjia.core.util.DataUtil;
import com.fangjia.core.util.DateUtil;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.SeawaterQuery;
import com.fangjia.dal.SortParam;
import com.fangjia.dal.mongo.dao.shop.ShopRentStatDao;
import com.fangjia.dal.mongo.dao.shop.ShopSellStatDao;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.ShopRentStat;
import com.fangjia.dal.mongo.model.ShopSellStat;
import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.service.datastore.dto.ShopEvaluationDto;
import com.fangjia.service.mongo.fangjia.SeawaterService;
import com.fangjia.service.util.GeoUtils;
import com.fangjia.service.util.dto.GaodeDto;
import com.mongodb.BasicDBObject;
import org.apache.commons.collections.CollectionUtils;
import org.sothis.core.util.Closure;
import org.sothis.core.util.Pager;
import weiboclient4j.utils.StringUtils;
import java.util.*;
public class AiShopServiceImpl implements AiShopService {
private ShopRentStatDao shopRentStatDao;
private SeawaterService seawaterService;
private ShopSellStatDao shopSellStatDao;
// 所在楼层
// 总楼层
private static final Map<String, String> FITMENT_MAP = new HashMap<String, String>() {
{
put("1", "毛坯");
put("2", "简装");
put("3", "精装");
put("4", "豪装");
}
};
private static final Map<String, String> DIRECTION_MAP = new HashMap<String, String>() {
{
put("1", "西南");
put("2", "东南");
put("3", "南");
put("4", "西北");
put("5", "东北");
put("6", "东");
put("7", "西");
put("8", "北");
put("9", "东西");
put("10", "南北");
}
};
private static final Map<String, Double> FITMENT_FACTOR = new HashMap<String, Double>() {
{
put("毛坯", 0.9983);
put("简装", 1.0);
put("精装", 1.0153);
put("豪装", 1.0199);
}
};
private static final Map<String, Double> DIRECTION_FACTOR = new HashMap<String, Double>() {
{
put("东", 1.0040);
put("东北", 1.0048);
put("东南", 1.0121);
put("东西", 1.0003);
put("北", 0.9999);
put("南", 1.0000);
put("南北", 1.0080);
put("西", 1.0060);
put("西北", 1.0099);
put("西南", 1.0103);
}
};
public ShopEvaluationDto calcRent(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("shop_rent");
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 getShopEvaluationDto(selectedSeawaters, evaluation, "shop_rent");
}
}
}
// 查找基准价
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("cat", "shop"));
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));
// 第二步:基准价*楼层系数*装修系数*朝向系数
ShopRentStat shopRentStat = shopRentStatDao.findFirstByParams(params);
Double avgPrice = shopRentStat.getAvgPrice();
if (avgPrice != null) {
Double factor = 1.0;
if (evaluation.getFitment() != null) {
factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment()));
}
if (evaluation.getDirection() != null) {
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
}
avgPrice = avgPrice * factor;
return getShopEvaluationDtoWithAvgPrice(avgPrice, evaluation, "shop_rent");
}
return null;
}
/**
* 根据均价查询样本
*
* @param avgPrice
* @param evaluation
* @return
*/
private ShopEvaluationDto getShopEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) {
SeawaterQuery query = new SeawaterQuery();
query.setRegion(evaluation.getRegion());
if ("shop_rent".equals(cat)) {
query.setStartPrice((int) (avgPrice * 30 * 0.9));
query.setEndPrice((int) (avgPrice * 30 * 1.1));
} else {
query.setStartPrice((int) (avgPrice * 0.9));
query.setEndPrice((int) (avgPrice * 1.1));
}
query.setCat(cat);
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(5);
query.setPager(pager);
query.setTable("latest_seawater");
List<Seawater> seawaters = seawaterService.findSeawatersByQuery(query);
return getShopEvaluationDto(seawaters, evaluation, cat);
}
/**
* 基准价*楼层系数*装修系数*朝向系数
*
* @param seawaters
* @param evaluation
* @return
*/
private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List<Seawater> seawaters, Evaluation evaluation) {
Double sum = 0.0;
Double size = 0.0;
String fitment = FITMENT_MAP.get(evaluation.getFitment());
String direction = DIRECTION_MAP.get(evaluation.getDirection());
for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
Double price = Double.valueOf(seawater.getTotalPrice());
// 装修
if (seawater.getFitment() != null) {
try {
price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment);
} catch (Exception ex) {
}
}
// 朝向
if (seawater.getDirection() != null) {
try {
price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction);
} catch (Exception ex) {
}
}
sum += price;
size += seawater.getArea();
}
}
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
shopEvaluationDto.setUnitPrice(unitPrice);
shopEvaluationDto.setSeawater(seawaters);
shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
}
return shopEvaluationDto;
}
/**
* 纯样本查询结果估值
*
* @param seawaters
* @param evaluation
* @return
*/
private static ShopEvaluationDto getShopEvaluationDto(List<Seawater> seawaters, Evaluation evaluation, String cat) {
Integer sum = 0;
Double size = 0.0;
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
if ("shop_rent".equals(cat)) {
for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
sum += seawater.getTotalPrice();
size += seawater.getArea();
}
}
if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
shopEvaluationDto.setUnitPrice(unitPrice);
shopEvaluationDto.setSeawater(seawaters);
shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
}
} else {
for (Seawater seawater : seawaters) {
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) {
sum += seawater.getTotalPrice();
size += seawater.getArea();
}
}
if (size > 0) {
Double unitPrice = DataUtil.roundDouble(sum / size, 2);
shopEvaluationDto.setUnitPrice(unitPrice);
shopEvaluationDto.setSeawater(seawaters);
shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
}
}
return shopEvaluationDto;
}
@Override
public ShopEvaluationDto addressEvaluateRent(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 rentEvaluateByLocation(evaluation);
}
@Override
public List<ShopSellStat> findShopSellStat(String city, String region, String name, String cat, Integer startDate, Integer endDate) {
return Collections.emptyList();
}
private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) {
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
if (StringUtils.isNotBlank(evaluation.getLocation())) {
shopEvaluationDto.setLocation(evaluation.getLocation());
Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]);
Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]);
SeawaterQuery query = new SeawaterQuery();
query.setLat(lat);
query.setLng(lng);
query.setCat("shop_rent");
query.setRadius(1000);
// 查询近一年样本
query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")));
query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd")));
query.setCityDisplay(evaluation.getCity());
Pager pager = new Pager();
pager.setStartRow(0);
pager.setPageSize(5);
query.setPager(pager);
query.setTable("latest_seawater");
List<Seawater> shops = seawaterService.findSeawatersByQuery(query);
if (CollectionUtils.isNotEmpty(shops)) {
// 求均值
Double totalPrice = 0D;
int count = 0;
for (Seawater seawater : shops) {
if (seawater.getAvgPrice() != null) {
totalPrice += seawater.getAvgPrice();
count += 1;
}
}
Double factor = 1.0;
if (evaluation.getFitment() != null) {
factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment()));
}
if (evaluation.getDirection() != null) {
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
}
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
shopEvaluationDto.setUnitPrice(avgPrice);
shopEvaluationDto.setSeawater(shops);
shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
return shopEvaluationDto;
}
}
return shopEvaluationDto;
}
private ShopEvaluationDto sellEvaluateByLocation(Evaluation evaluation) {
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
if (StringUtils.isNotBlank(evaluation.getLocation())) {
shopEvaluationDto.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);
params.add(new QueryParam("cat", "shop"));
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<ShopSellStat> infos = shopSellStatDao.findAllByParams(params, sortParams, 5);
if (CollectionUtils.isEmpty(infos)) {
// 去掉类型,重新查找
params = new ArrayList<QueryParam>(5);
params.add(new QueryParam("cat", "shop"));
params.add(new QueryParam("location", geo));
params.add(new QueryParam("date", Integer.parseInt(date)));
infos = shopSellStatDao.findAllByParams(params, sortParams);
}
if (CollectionUtils.isNotEmpty(infos)) {
// 求均值
Double totalPrice = 0D;
int count = 0;
for (ShopSellStat shopSellStat : infos) {
if (shopSellStat.getAvgPrice() != null) {
totalPrice += shopSellStat.getAvgPrice();
count += 1;
}
}
Double factor = 1.0;
if (evaluation.getFitment() != null) {
factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment()));
}
if (evaluation.getDirection() != null) {
factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection()));
}
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
shopEvaluationDto.setUnitPrice(avgPrice);
shopEvaluationDto.setCity(evaluation.getCity());
shopEvaluationDto.setDistrict(evaluation.getRegion());
shopEvaluationDto.setName(evaluation.getDistrictName());
return shopEvaluationDto;
}
}
return shopEvaluationDto;
}
private String getLocation(String city, String address) {
GaodeDto gaodeDto = GeoUtils.geo(city, address);
if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) {
return gaodeDto.getLng() + "," + gaodeDto.getLat();
}
return "";
}
private GaodeDto getGaodeGeo(String city, String address) {
GaodeDto gaodeDto = GeoUtils.geo(city, address);
return gaodeDto;
}
public List<ShopRentStat> findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) {
return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate,
CacheUtils.CachePolicyEnum.MIDDLE, new Closure<List<ShopRentStat>, String>() {
public List<ShopRentStat> execute(String input) {
return doFindRegionBlockStat(city, region, name, cat, startDate, endDate);
}
});
}
public List<ShopRentStat> doFindRegionBlockStat(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<ShopRentStat> regionStats = shopRentStatDao.findAllByParams(params, sortParams);
return regionStats;
}
@Override
public ShopEvaluationDto 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<ShopSellStat> doFindShopSellStat(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<ShopSellStat> sellStatList = shopSellStatDao.findAllByParams(params, sortParams);
return sellStatList;
}
public void setSeawaterService(SeawaterService seawaterService) {
this.seawaterService = seawaterService;
}
public void setShopRentStatDao(ShopRentStatDao shopRentStatDao) {
this.shopRentStatDao = shopRentStatDao;
}
public void setShopSellStatDao(ShopSellStatDao shopSellStatDao) {
this.shopSellStatDao = shopSellStatDao;
}
}
@@ -1,11 +1,11 @@
package com.fangjia.service.datastore;
import java.util.List;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.seaweed.model.Shop;
import java.util.List;
public interface ShopService {
List<Shop> findByKeyword(String city, String keyword);
@@ -0,0 +1,54 @@
package com.fangjia.service.datastore.dto;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.seawater.model.Seawater;
import java.util.List;
/**
* @author shenjian
* @since 2025/2/19
*/
public class ShopEvaluationDto extends Evaluation {
private Double unitPrice;
private List<Seawater> seawater;
private String district;
private String name;
public Double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Double unitPrice) {
this.unitPrice = unitPrice;
}
public List<Seawater> getSeawater() {
return seawater;
}
public void setSeawater(List<Seawater> seawater) {
this.seawater = seawater;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,32 @@
package com.fangjia.service.datastore.dto;
import com.fangjia.dal.seawater.model.Seawater;
import java.util.List;
/**
* @author shenjian
* @since 2025/2/19
*/
public class ShopRentDto {
private Double unitPrice;
private List<Seawater> seawater;
public Double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Double unitPrice) {
this.unitPrice = unitPrice;
}
public List<Seawater> getSeawater() {
return seawater;
}
public void setSeawater(List<Seawater> seawater) {
this.seawater = seawater;
}
}