Merge branch 'open_v2' into 'master'

Open v2

See merge request !1225
This commit is contained in:
2026-01-14 13:37:43 +08:00
10 changed files with 690 additions and 98 deletions
@@ -9,6 +9,7 @@ public class SeawaterDto {
private String fitment;
private Double area;
private Double unitPrice;
private Integer totalPrice;
private String publishDate;
private String floorInfo;
@@ -25,6 +26,8 @@ public class SeawaterDto {
private String location;
public String getCity() {
return city;
}
@@ -152,4 +155,12 @@ public class SeawaterDto {
public void setId(String id) {
this.id = id;
}
public Integer getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(Integer totalPrice) {
this.totalPrice = totalPrice;
}
}
@@ -1,15 +1,14 @@
package com.fangjia.open.controllers;
import com.fangjia.core.util.AvmUrls;
import com.fangjia.core.util.GeoUtils;
import com.fangjia.core.util.HttpRequest;
import com.fangjia.core.util.HttpRequestException;
import com.fangjia.core.util.*;
import com.fangjia.open.dto.BusinessCaseDto;
import com.fangjia.open.interceptors.Authority;
import com.fangjia.open.interceptors.Role;
import com.fangjia.open.model.AddesssMatchModel;
import com.fangjia.open.model.BasicModel;
import com.fangjia.open.model.CommercialModel;
import com.fangjia.open.model.RestfulModelAndView;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
@@ -38,11 +37,12 @@ public class CommercialController {
if (json != null) {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("avgPrice", Long.valueOf(json.getString("unitPrice")));
resultMap.put("unitPrice", Long.valueOf(json.getString("unitPrice")));
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
if (model.getShowSample()!=null && model.getShowSample()==1 && json.containsKey("case")) {
resultMap.put("samples", json.get("case"));
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell");
resultMap.put("result", dtos);
}
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
@@ -61,7 +61,7 @@ public class CommercialController {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
mav = checkParmas(model, mav);
if(mav.model()!=null){
if(mav.model()!=null){
return mav;
}
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPSELL_EVALUATE);
@@ -69,8 +69,11 @@ public class CommercialController {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
if (json.containsKey("case")) {
mav.setModel(BasicModel.buildOKModel().setResult(json.get("case")));
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell");
mav.setModel(BasicModel.buildOKModel().setResult(dtos));
}
}else{
mav.setModel(BasicModel.buildServerErrorModel().setMsg(json.getString("msg")));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
@@ -98,16 +101,17 @@ public class CommercialController {
if (json != null) {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("avgPrice", Double.valueOf(json.getString("unitPrice")));
resultMap.put("unitPrice", Double.valueOf(json.getString("unitPrice")));
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
if (model.getShowSample()!=null && model.getShowSample()==1 && json.containsKey("case")) {
resultMap.put("samples", json.get("case"));
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent");
resultMap.put("result", dtos);
}
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
} else {
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
mav.setModel(BasicModel.buildServerErrorModel().setMsg(json.getString("msg")));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
@@ -116,6 +120,43 @@ public class CommercialController {
return mav;
}
private List<BusinessCaseDto> createBusiness(JSONArray cases, String cat){
if(cases != null && cases.size()>0){
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
for(int i=0 ;i < cases.size(); i++){
JSONObject jsonObject = cases.getJSONObject(i);
BusinessCaseDto dto = new BusinessCaseDto();
dto.setCity(jsonObject.getString("city"));
dto.setDistrict(jsonObject.getString("district"));
dto.setName(jsonObject.getString("name"));
dto.setLocation(jsonObject.getString("location"));
if(cat.equals("rent")){
Double dayPrice = jsonObject.getInt("totalPrice")/(jsonObject.getDouble("size")*30);
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
}else{
dto.setUnitPrice(jsonObject.getInt("unitPrice"));
}
dto.setTotalPrice(jsonObject.getInt("totalPrice"));
dto.setDistance(jsonObject.getInt("distance"));
dto.setSize(jsonObject.getDouble("size"));
if(jsonObject.containsKey("type")){
dto.setType(jsonObject.getString("type"));
}
if(jsonObject.containsKey("floor")){
dto.setFloor(jsonObject.getInt("floor"));
}
dto.setCaseDate(jsonObject.getString("publishDate"));
dtos.add(dto);
}
return dtos;
}
return null;
}
public Object shopRentSampleAction(CommercialModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
@@ -129,8 +170,11 @@ public class CommercialController {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
if (json.containsKey("case")) {
mav.setModel(BasicModel.buildOKModel().setResult(json.get("case")));
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent");
mav.setModel(BasicModel.buildOKModel().setResult(dtos));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg(json.getString("msg")));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
@@ -6,9 +6,11 @@ import com.fangjia.dal.common.ServerAreaData;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeRentStat;
import com.fangjia.dal.seawater.model.SeawaterDto;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.open.HttpCode;
import com.fangjia.open.OpenHttpCodeEnum;
import com.fangjia.open.dto.BusinessCaseDto;
import com.fangjia.open.dto.DistrictInfoDto;
import com.fangjia.open.interceptors.AuthenticationBean;
import com.fangjia.open.interceptors.Authority;
@@ -33,10 +35,7 @@ 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 java.util.*;
import static com.fangjia.open.util.CommonUtils.convertToString;
import static com.fangjia.open.util.EvaluationFactorUtil.*;
@@ -456,32 +455,43 @@ public class OfficeController {
public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("全国")
|| model.getDistrict().contains("全国")) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,写字楼名,面积(size)为必填项"));
if (StringUtils.isBlank(model.getCity()) || model.getSize()<=0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,面积为必填项"));
return mav;
}
if (model.getCity().endsWith("市")) {
model.setCity(model.getCity().replaceAll("市$", ""));
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
return mav;
}
/* 先到CPDB库中查找写字楼 */
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office");
if (district == null) {
if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) {
district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office");
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 && (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 (district == null) {
mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在"));
return mav;
if(resultObject != null){
String id = (String) resultObject.get("id");
district = districtService.findById(id);
}
}
model.setName(district.getName());
if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) {
mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法"));
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;
@@ -521,16 +531,20 @@ public class OfficeController {
districtPriceMap.put("district", district.getRegion());
districtPriceMap.put("name", district.getName());
districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
districtPriceMap.put("samples", evaluation.getSeawater());
Long totalPrice = (long) (evaluation.getUnitPrice() * model.getSize() * 30);
districtPriceMap.put("totalPrice", totalPrice);
if(model.getShow()!=null && model.getShow()==1) {
districtPriceMap.put("result", evaluation.getSeawater());
}
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
try {
if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/evaluateRent");
}
} catch (Exception e) {
e.printStackTrace();
}
// try {
// if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
// openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/evaluateRent");
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
return mav;
} else {
@@ -677,6 +691,78 @@ public class OfficeController {
return mav;
}
public Object rentCaseAction(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;
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;
}
model.setRegion(district.getRegion());
model.setDistrictName(district.getName());
OfficeEvaluationDto evaluation = officeService.evaluateRent(district, buildEvaluation(model, request));
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_rent", district);
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
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) {
@@ -767,7 +853,8 @@ public class OfficeController {
if (StringUtils.isNotBlank(model.getOtherFactor())) {
evaluation.setOtherFactor(model.getOtherFactor());
}
evaluation.setRegion(model.getDistrict());
if (null != model.getRoom()) {
evaluation.setRoom(model.getRoom());
}
@@ -857,6 +944,47 @@ public class OfficeController {
}
};
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district){
if(seawaterDtos != null && seawaterDtos.size()>0){
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
for(SeawaterDto house : seawaterDtos){
BusinessCaseDto dto = new BusinessCaseDto();
dto.setCity(house.getCity());
dto.setDistrict(house.getDistrict());
dto.setName(house.getName());
dto.setLocation(house.getLocation());
if(cat.equals("office_rent")){
Double dayPrice = house.getTotalPrice()/(house.getArea()*30);
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
}else{
dto.setUnitPrice(house.getUnitPrice());
}
if(StringUtils.isNotBlank(house.getEstateType())){
dto.setType(house.getEstateType());
}
dto.setTotalPrice(house.getTotalPrice());
if(StringUtils.isNotBlank(house.getLocation()) && district.getLat()!=null){
String[] arrs = house.getLocation().split(",");
double distance = GeoUtils.calculateDistance(district.getLng()/10000000000.0, district.getLat()/10000000000.0, Double.valueOf(arrs[0]), Double.valueOf(arrs[1]));
dto.setDistance((int) distance);
}
dto.setSize(house.getArea());
if (StringUtils.isNotBlank(house.getPublishDate())) {
String numberStr = house.getPublishDate();
// 拆分字符串并格式化
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;
}
@@ -3,14 +3,17 @@ 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.GeoUtils;
import com.fangjia.core.util.LoggerFactory;
import com.fangjia.dal.common.ServerAreaData;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.OfficeSellStat;
import com.fangjia.dal.seawater.model.SeawaterDto;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.open.HttpCode;
import com.fangjia.open.OpenHttpCodeEnum;
import com.fangjia.open.dto.BusinessCaseDto;
import com.fangjia.open.interceptors.AuthenticationBean;
import com.fangjia.open.interceptors.Authority;
import com.fangjia.open.interceptors.Role;
@@ -23,6 +26,7 @@ import com.fangjia.service.datastore.DistrictService;
import com.fangjia.service.datastore.OfficeService;
import com.fangjia.service.datastore.OpenApiLogService;
import com.fangjia.service.datastore.dto.OfficeEvaluationDto;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
@@ -32,10 +36,7 @@ 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 java.util.*;
import static com.fangjia.open.util.CommonUtils.convertToString;
import static com.fangjia.open.util.EvaluationFactorUtil.*;
@@ -308,7 +309,7 @@ public class OfficeSellController {
Long totalPrice = (long) (evaluation.getUnitPrice() * model.getSize());
districtPriceMap.put("totalPrice", totalPrice);
if(model.getShow()!=null && model.getShow()==1){
districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("result", evaluation.getSeawater());
}
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
// try {
@@ -385,7 +386,7 @@ public class OfficeSellController {
districtPriceMap.put("city", evaluation.getCity());
districtPriceMap.put("district", evaluation.getDistrict());
districtPriceMap.put("name", evaluation.getName());
districtPriceMap.put("samples", evaluation.getSeawater());
districtPriceMap.put("result", evaluation.getSeawater());
districtPriceMap.put("location", evaluation.getLocation());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
@@ -404,6 +405,81 @@ public class OfficeSellController {
}
}
public Object sellCaseAction(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;
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;
}
model.setRegion(district.getRegion());
model.setDistrictName(district.getName());
OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request));
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_sell", district);
// districtPriceMap.put("result", createBusiness);
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
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) {
@@ -573,6 +649,48 @@ public class OfficeSellController {
return evaluation;
}
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district){
if(seawaterDtos != null && seawaterDtos.size()>0){
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
for(SeawaterDto house : seawaterDtos){
BusinessCaseDto dto = new BusinessCaseDto();
dto.setCity(house.getCity());
dto.setDistrict(house.getDistrict());
dto.setName(house.getName());
dto.setLocation(house.getLocation());
if(cat.equals("office_rent")){
Double dayPrice = house.getTotalPrice()/(house.getUnitPrice()*30);
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
}else{
dto.setUnitPrice(house.getUnitPrice());
}
if(StringUtils.isNotBlank(house.getEstateType())){
dto.setType(house.getEstateType());
}
dto.setTotalPrice(house.getTotalPrice());
if(StringUtils.isNotBlank(house.getLocation()) && district.getLat()!=null){
String[] arrs = house.getLocation().split(",");
double distance = GeoUtils.calculateDistance(district.getLng()/10000000000.0, district.getLat()/10000000000.0, Double.valueOf(arrs[0]), Double.valueOf(arrs[1]));
dto.setDistance((int) distance);
}
dto.setSize(house.getArea());
if (StringUtils.isNotBlank(house.getPublishDate())) {
String numberStr = house.getPublishDate();
// 拆分字符串并格式化
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 setOfficeService(OfficeService officeService) {
this.officeService = officeService;
}
@@ -1303,6 +1303,58 @@ public class PropertyController {
}
}
public Object areaFactorAction(PropertyEvaluationModel model, HttpServletRequest request){
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getDistrict()) || model.getSize()<=0 || model.getAvgPrice()<0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
return mav;
}
/* 先到CPDB库中查找小区 */
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
"district");
if (district == null) {
mav.setModel(BasicModel.buildBadRequestModel("该小区不存在"));
return mav;
}
DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district));
int orgAvgPrice = 0;
if (districtStatBo != null) {
if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) {
if(districtStatBo.getVillaDistrictStat().getAvg_price_2b() != null && districtStatBo.getVillaDistrictStat().getAvg_price_2b() > 0){
orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvg_price_2b();
}else{
orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice();
}
} else if (districtStatBo.getDistrictStat() != null) {
if(districtStatBo.getDistrictStat().getAvg_price_2b() != null && districtStatBo.getDistrictStat().getAvg_price_2b() > 0){
orgAvgPrice = districtStatBo.getDistrictStat().getAvg_price_2b();
}else{
orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice();
}
}
}
int newAvgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), model.getSize(), model.getAvgPrice(), 0);
Integer minPrice = (int) ( model.getAvgPrice() * 0.95);
Integer maxPrice = (int) ( model.getAvgPrice() * 1.05);
// 偏离度超过5%不进行调整
Map map = new HashMap();
if (minPrice <= newAvgPrice && newAvgPrice <= maxPrice) {
map.put("newAvgPrice", newAvgPrice);
map.put("ratio",DataUtil.getRound(4, newAvgPrice*1.0/model.getAvgPrice()));
}else{
map.put("newAvgPrice", model.getAvgPrice());
map.put("ratio", 1);
}
mav.setModel(BasicModel.buildOKModel().setResult(map));
return mav;
}
/**
* 系数下调
*
@@ -5918,9 +5970,8 @@ public class PropertyController {
public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项"));
return mav;
}
if (model.getCity().endsWith("市")) {
@@ -5940,15 +5991,6 @@ public class PropertyController {
model.setCalDate(calDate);
}
}
/* 先到CPDB库中查找小区 */
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
"district");
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)"));
@@ -5964,45 +6006,99 @@ public class PropertyController {
return mav;
}
model.setRegion(district.getRegion());
model.setDistrictName(district.getName());
if (StringUtils.isBlank(model.getPropertyType())) {
if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) {
model.setPropertyType("1");
District district = null;
if(StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())){
/* 先到CPDB库中查找小区 */
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
"district");
}
boolean villaFlag = DataUtil.isVilla(model.getSize(), model.getName(), model.getHeight(), model.getRoom());
Map<String, Object> params = new HashMap<String, Object>();
params.put("city", model.getCity());
if (StringUtils.isNotBlank(model.getDistrict())) {
params.put("suggestDistrict", model.getDistrict());
}
params.put("address", model.getAddress());
if (StringUtils.isNotBlank(model.getName())) {
params.put("suggestName", model.getName());
}
params.put("category", "district");
params.put("propertyType", model.getPropertyType());
String result = addressMatchProxyService.parser(params);
if (result != null) {
JSONObject json = JSONObject.fromObject(result);
if (json.getInt("code") == 200) {
Map<String, Object> map = (Map<String, Object>) json.get("result");
if ((Integer) map.get("precise") >= 0) {
String propertyType = (String) map.get("propertyType");
// 优先使用客户的物业类型,即使面积很大也不进行别墅推断 20241111
String userPropertyTypeParam = model.getPropertyType();
if (StringUtils.isNotBlank(userPropertyTypeParam) && ("0,2".contains(userPropertyTypeParam))) {
villaFlag = false;
}
if (villaFlag && StringUtils.isNotBlank(propertyType) && !propertyType.equals("别墅")) {
district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name") + "别墅", "district");
}
if (null == district) {
district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name"), "district");
}
}
}
}
if (district == null) {
//使用新匹配再配一遍,不加类型,有结果,类型为district则走小区估值,其它类型也走经纬度估值
JSONObject resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getAddress(), null, false);
if (resultObject != null && resultObject.containsKey("category") && resultObject.get("category")!=null) {
if(resultObject.containsKey("id") && resultObject.get("category").equals("district")){
String id = (String) resultObject.get("id");
district = districtService.findById(id);
}
}
}
if (model.getCalDate() != null) {
if (new Date().before(model.getCalDate())) {
model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
if(district != null){
model.setRegion(district.getRegion());
model.setDistrictName(district.getName());
if (StringUtils.isBlank(model.getPropertyType())) {
if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) {
model.setPropertyType("1");
}
}
if (model.getCalDate() != null) {
if (new Date().before(model.getCalDate())) {
model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
} else {
model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate()));
}
} else {
model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate()));
model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
}
Evaluation evaluation = buildEvaluation(model, request);
evaluation.setSource("api_property_evaluate_rent");
evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate());
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
districtPriceMap.put("city", district.getCity());
districtPriceMap.put("district", district.getRegion());
districtPriceMap.put("name", district.getName());
districtPriceMap.put("address", district.getAddress());
districtPriceMap.put("totalPrice", evaluation.getTotalPrice());
//districtPriceMap.put("cal_date", model.getCalDate());
districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
return mav;
}else{
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
} else {
model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
}
Evaluation evaluation = buildEvaluation(model, request);
evaluation.setSource("api_property_evaluate_rent");
evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate());
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
districtPriceMap.put("city", district.getCity());
districtPriceMap.put("district", district.getRegion());
districtPriceMap.put("name", district.getName());
districtPriceMap.put("address", district.getAddress());
districtPriceMap.put("totalPrice", evaluation.getTotalPrice());
//districtPriceMap.put("cal_date", model.getCalDate());
districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
return mav;
} else {
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
public Object searchHouseLoudongAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException {
@@ -6155,8 +6251,12 @@ public class PropertyController {
List<Seawater> houseSelf = houseService.findSelfHouseByParams(district, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
if(houseSelf!=null && houseSelf.size()>0){
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
for(HouseCaseDto house : caseDtos){
house.setDistance(0);
}
if(caseDtos.size() == pager.getPageSize()){
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
return mav;
}
@@ -6365,6 +6465,9 @@ public class PropertyController {
List<Seawater> houseSelf = houseService.findSelfHouseByParams(district, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
if(houseSelf!=null && houseSelf.size()>0){
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
for(HouseCaseDto house : caseDtos){
house.setDistance(0);
}
if(caseDtos.size() == pager.getPageSize()){
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
@@ -6378,7 +6481,7 @@ public class PropertyController {
newDist.setRegion(district.getRegion());
newDist.setName(district.getName().replace("别墅",""));
newDist.setEstateType2(estateType);
houseSelf = houseService.findSelfHouseByParams(newDist, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
houseSelf = houseService.findSelfHouseByParams(newDist, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
if(houseSelf!=null && houseSelf.size()>0){
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
if(caseDtos.size() == pager.getPageSize()){
@@ -6397,7 +6500,7 @@ public class PropertyController {
newDist.setRegion(district.getRegion());
newDist.setName(district.getName().replace("别墅",""));
newDist.setEstateType2(estateType);
houseSelf = houseService.findSelfHouseByParams(newDist, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), null, pager);
houseSelf = houseService.findSelfHouseByParams(newDist, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), null, pager);
if(houseSelf!=null && houseSelf.size()>0){
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
if(caseDtos.size() == pager.getPageSize()){
@@ -6513,7 +6616,12 @@ public class PropertyController {
caseDto.setDistrict(house.getRegion());
caseDto.setName(house.getDistrictName());
caseDto.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
caseDto.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
if(house.getCategory().equals("sell")){
caseDto.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
}else if(house.getCategory().equals("rent")){
Double dayPrice = house.getTotalPrice()/(30*house.getArea());
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
}
caseDto.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
caseDto.setDirection(house.getDirection());
caseDto.setDecoration(house.getFitment());
@@ -0,0 +1,112 @@
package com.fangjia.open.dto;
public class BusinessCaseDto {
private String id;//房源id
private String city;//城市
private String district;//区域
private String name;//楼盘名称
private Integer distance;//距离(单位:米)
private String location;//经纬度
private Double size;//面积(单位:平米)
private Number unitPrice;//单价(单位:元/平米)
private Integer totalPrice;//总价(单位:元)
private Integer floor;//所在楼层
private String caseDate;//案例时间(如: 2013-07-12)
private String type;//类型
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
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;
}
public Integer getDistance() {
return distance;
}
public void setDistance(Integer distance) {
this.distance = distance;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Double getSize() {
return size;
}
public void setSize(Double size) {
this.size = size;
}
public Number getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Number unitPrice) {
this.unitPrice = unitPrice;
}
public Integer getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(Integer totalPrice) {
this.totalPrice = totalPrice;
}
public Integer getFloor() {
return floor;
}
public void setFloor(Integer floor) {
this.floor = floor;
}
public String getCaseDate() {
return caseDate;
}
public void setCaseDate(String caseDate) {
this.caseDate = caseDate;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
@@ -8,7 +8,7 @@ public class HouseCaseDto {
private String name;//楼盘名称
private Integer distance;//距离(单位:米)
private Double size;//面积(单位:平米)
private Integer unitPrice;//单价(单位:元/平米)
private Number unitPrice;//单价(单位:元/平米)
private Integer totalPrice;//总价(单位:元)
private String decoration;//装修(如:精装)
private String direction;//朝向(如:南)
@@ -68,11 +68,11 @@ public class HouseCaseDto {
this.size = size;
}
public Integer getUnitPrice() {
public Number getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Integer unitPrice) {
public void setUnitPrice(Number unitPrice) {
this.unitPrice = unitPrice;
}
@@ -313,6 +313,9 @@ public class PropertyEvaluationModel extends FangjiaApiModel {
*/
private Integer show;
private Integer newAvgPrice;
private Double ratio;//系数
public Integer getPageSize() {
return pageSize;
}
@@ -1027,4 +1030,20 @@ public class PropertyEvaluationModel extends FangjiaApiModel {
public void setShow(Integer show) {
this.show = show;
}
public Integer getNewAvgPrice() {
return newAvgPrice;
}
public void setNewAvgPrice(Integer newAvgPrice) {
this.newAvgPrice = newAvgPrice;
}
public Double getRatio() {
return ratio;
}
public void setRatio(Double ratio) {
this.ratio = ratio;
}
}
@@ -55,5 +55,37 @@
</ladders>
</rule>
<rule controller="officeSell" action="sellCase" channel="office">
<ladders>
<ladder>/sellCase</ladder>
</ladders>
</rule>
<rule controller="commercial" action="shopSellEvaluate" channel="shop">
<ladders>
<ladder>/sellEvaluate</ladder>
</ladders>
</rule>
<rule controller="commercial" action="shopSellSample" channel="shop">
<ladders>
<ladder>/sellCase</ladder>
</ladders>
</rule>
<rule controller="commercial" action="shopRentEvaluate" channel="shop">
<ladders>
<ladder>/rentEvaluate</ladder>
</ladders>
</rule>
<rule controller="commercial" action="shopRentSample" channel="shop">
<ladders>
<ladder>/rentCase</ladder>
</ladders>
</rule>
</rules>
</urlrewrite>
@@ -45,6 +45,10 @@ public class OfficeServiceImpl implements OfficeService {
evaluation.setFloor(null);
evaluation.setHeight(null);
}
if(null != district.getLng()){
String location = district.getLng()/10000000000.0+","+district.getLat()/10000000000.0;
evaluation.setLocation(location);
}
OfficeEvaluationDto officeEvaluationDto = this.calcRent(evaluation);
// 如果从基价表中找不到,// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数
if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) {
@@ -345,6 +349,11 @@ public class OfficeServiceImpl implements OfficeService {
}
query.setCat(cat);
query.setRadius(3000);
if(StringUtils.isNotBlank(evaluation.getLocation())){
String[] locationArrs = evaluation.getLocation().split(",");
query.setLng(Double.valueOf(locationArrs[0]));
query.setLat(Double.valueOf(locationArrs[1]));
}
Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd"));
Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
@@ -357,6 +366,7 @@ public class OfficeServiceImpl implements OfficeService {
pager.setPageSize(5);
query.setPager(pager);
query.setTable("latest_seawater");
List<Seawater> seawaters = seawaterService.findSeawatersByQuery(query);
return getOfficeEvaluationDto(seawaters, evaluation, cat);
}
@@ -496,6 +506,12 @@ public class OfficeServiceImpl implements OfficeService {
seawaterDto.setBedKind(seawater.getLevel());
seawaterDto.setPublishDate(String.valueOf(seawater.getpDate()));
seawaterDto.setFloorInfo(seawater.getFloorInfo());
if(StringUtils.isNotBlank(seawater.getLocation())){
seawaterDto.setLocation(seawater.getLocation());
}
seawaterDto.setTotalPrice(seawater.getTotalPrice());
seawaterDto.setEstateType(seawater.getEstateType());
seawaterDto.setId(seawater.getId());
return seawaterDto;
}
@@ -749,6 +765,10 @@ public class OfficeServiceImpl implements OfficeService {
evaluation.setFloor(null);
evaluation.setHeight(null);
}
if(null != district.getLng()){
String location = district.getLng()/10000000000.0+","+district.getLat()/10000000000.0;
evaluation.setLocation(location);
}
OfficeEvaluationDto officeEvaluationDto = this.calcSell(evaluation);
// 如果从基价表中找不到,// 第三步:周边(三公里内最近的10个写字楼)同等级、同类型写字楼的均值*楼层系数*装修系数*朝向系数
if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) {