Merge remote-tracking branch 'origin/master'

This commit is contained in:
2025-09-17 17:12:32 +08:00
7 changed files with 319 additions and 31 deletions
@@ -1,5 +1,6 @@
package com.fangjia.core.util;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -261,7 +262,9 @@ public class GeoUtils {
public static Map<String, String> parserByGaode(String city, String address) {
Map<String, String> params = new HashMap<String, String>();
params.put("city", city);
if(StringUtils.isNotBlank(city)){
params.put("city", city);
}
params.put("address", address);
String content;
@@ -318,8 +321,8 @@ public class GeoUtils {
private static String getGaodeKey(String endpoint) {
// 实现获取高德 API key 的逻辑
// return "8796b9dfb3889b57c38e2fff1b7e51bd";
return "7516b8e9436de903eef85fb156cbc3cf";//临时2天
return "8796b9dfb3889b57c38e2fff1b7e51bd";
}
public static void main(String[] args) {
@@ -776,7 +776,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
jsonList.add(temp);
}
if (StringUtils.isNotBlank(query.getSortField())) {
if (reqBody.size()==0 && StringUtils.isNotBlank(query.getSortField())) {
JSONObject jsonOrder = new JSONObject();
if (query.getOrder()) {
jsonOrder.put("order", "asc");
@@ -481,6 +481,49 @@ public class AddrSvcController {
return mav;
}
/**
* 楼盘价值识别接口
*
* @param model
* @return
*/
public Object valueRateAction(AddesssMatchModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress())) {
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
return mav;
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
params.put("address", model.getAddress());
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaDataService/valueRate", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaDataService/valueRate", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
if (json.containsKey("result")) {
basicModel.setResult(json.get("result"));
}
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
private static final Map<String, String> areaMap = new HashMap<String, String>() {
{
// 添加键值对到 Map 中
@@ -0,0 +1,153 @@
package com.fangjia.open.controllers;
import com.fangjia.core.util.GeoUtils;
import com.fangjia.core.util.HttpRequest;
import com.fangjia.core.util.HttpRequestException;
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.JSONObject;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 商业地产
*
* @since 2025/9/16
*/
@Authority(role = Role.USER)
public class CommercialController {
private static final List<String> GAODE_LEVEL = Arrays.asList("兴趣点", "门牌号", "单元号", "楼层", "房间", "门址", "住宅区","村庄");
public Object shopSellEvaluateAction(CommercialModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
mav = checkParmas(model, mav);
if(mav.model()!=null){
return mav;
}
JSONObject json = locationEvaluateApi(model.getAddress(), model.getLocation(), String.valueOf(model.getSize()), String.valueOf(model.getEstateType()));
if (json != null) {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
HashMap<String, Long> resultMap = new HashMap<String, Long>();
resultMap.put("avgPrice", Long.valueOf(json.getString("unitPrice")));
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
} else {
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
public Object shopSellSampleAction(CommercialModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
mav = checkParmas(model, mav);
if(mav.model()!=null){
return mav;
}
JSONObject json = locationEvaluateApi(model.getAddress(), model.getLocation(), String.valueOf(model.getSize()), String.valueOf(model.getEstateType()));
if (json != null) {
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(200, "ok");
if (json.containsKey("case")) {
basicModel.setResult(json.get("case"));
}
mav.setModel(BasicModel.buildOKModel().setResult(basicModel));
}
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
private RestfulModelAndView checkParmas(CommercialModel model, RestfulModelAndView mav){
if (StringUtils.isBlank(model.getAddress()) && StringUtils.isBlank(model.getLocation())) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:地址或经纬度不为空"));
return mav;
}
if (model.getSize()==null || model.getEstateType()==null ) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:地址,面积,商铺类型为必填项"));
return mav;
}
if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
return mav;
}
if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) {
mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)"));
return mav;
}
if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) {
mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层"));
return mav;
}
if (model.getPassengerFlow() != null && (model.getPassengerFlow() <0 || model.getPassengerFlow() > 2)) {
mav.setModel(BasicModel.buildBadRequestModel("客流量取值非法,正确范围[0,2]"));
return mav;
}
if (model.getPassengerFlow() != null && (model.getLeaseStability() <0 || model.getLeaseStability() > 3)) {
mav.setModel(BasicModel.buildBadRequestModel("租约稳定性取值非法,正确范围[0,3]"));
return mav;
}
if (model.getSellType()!= null && (model.getSellType() <0 || model.getSellType() > 1)) {
mav.setModel(BasicModel.buildBadRequestModel("出售方式取值非法,正确范围[0,1]"));
return mav;
}
if (model.getEstateType()!= null && (model.getEstateType() <0 || model.getEstateType() > 7)) {
mav.setModel(BasicModel.buildBadRequestModel("商铺类型取值非法,正确范围[0,7]"));
return mav;
}
return mav;
}
private JSONObject locationEvaluateApi(String address, String location, String area, String estateType){
//商铺类型---0:临街商铺 1:住宅底商 2:购物百货中心 3:写字楼商铺 4:档口摊位 5:市场类商铺 6:交通设施商铺 7:旅游商铺
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
if(StringUtils.isNotBlank(address)){
params.put("address", address);
}
if(StringUtils.isNotBlank(location)){
params.put("location", location);
}
params.put("area", area);
params.put("estateType", estateType);
try {
json = request.getJsonContent("http://192.168.0.100:30020/avmWeb/shopSell", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:30020/avmWeb/shopSell", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
return json;
}
}
@@ -1211,15 +1211,6 @@ public class PropertyController {
evaluation.setAvgPrice(avgPrice);
evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea()));
}
if (StringUtils.isNotBlank(evaluation.getFromUserId())) {
// 1007839 广州市慧合信息科技有限公司 huihe_test 价格向上2%-10% 向下 2%-5%
if (evaluation.getFromUserId().equals("1007839")) {
int round = DataUtil.generateRandomNumber(district.getCity() + model.getAddress());
int newAvgPrice = (int) (evaluation.getAvgPrice() + evaluation.getAvgPrice() * round / 100);
evaluation.setAvgPrice(newAvgPrice);
evaluation.setBigTotalPrice((long) (newAvgPrice * evaluation.getArea()));
}
}
}
} catch (Exception ex) {
@@ -1661,18 +1652,13 @@ public class PropertyController {
}
}
ApiUser apiUser = checkNewAuthorized(model.getToken());
String userName = null;
if (apiUser != null) {
User user = userService.findById(apiUser.getId());
if (user != null) {
userName = user.getUserName();
}
}
if (district == null && userName!=null && !userName.equals("huihe_test")) {
if (district == null) {
//加上高德获取经纬度 和 根据经纬度估值
Map<String, String> map = GeoUtils.parserByGaode(model.getCity(), model.getAddress());
if(map != null && (!map.containsKey("lng") || map.containsKey("level") && !GAODE_LEVEL.contains(map.get("level")))){
map = GeoUtils.parserByGaode(model.getCity(), model.getDistrict()+model.getName());
}
if (map != null && map.containsKey("level") && GAODE_LEVEL.contains(map.get("level"))
&& map.containsKey("lng") && map.containsKey("lat")) {
String location = map.get("lng") + "," + map.get("lat");
@@ -1687,15 +1673,6 @@ public class PropertyController {
HashMap<String, Long> resultMap = new HashMap<String, Long>();
resultMap.put("avgPrice", Long.valueOf(json.getString("unitPrice")));
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
if (apiUser.getId() == 1007839) {
int round = DataUtil.generateRandomNumber(model.getCity() + model.getAddress());
Long newAvgPrice = (Long) (json.getLong("unitPrice") + json.getLong("unitPrice") * round / 100);
resultMap.put("avgPrice", newAvgPrice);
double totalPrice = newAvgPrice * model.getSize();
resultMap.put("totalPrice", (long) totalPrice);
}
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
} else {
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
@@ -1711,6 +1688,7 @@ public class PropertyController {
if(district!=null){
model.setDistrict(district.getRegion());
model.setName(district.getName());
model.setCity(district.getCity());
return this.evaluateAction(model, request);
}else{
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
@@ -0,0 +1,111 @@
package com.fangjia.open.model;
import org.hibernate.validator.constraints.NotBlank;
public class CommercialModel extends FangjiaApiModel{
@NotBlank
private String address;
private Double size;
private String location;
private Integer floor;//所在楼层
private Integer maxFloor;//总楼层
private Integer passengerFlow;//客流量---0:高 1:中 2:低
private Integer LeaseStability;//租约稳定性---0:持续稳定出租 1:阶段性出租 2:偶尔出租 3:未出租
private Integer sellType;//出售/转让---0:出售 1:转让
private Integer decorationCost;//装修成本(单位:万元)
private Integer decorationYear;//装修年限(单位:年)
@NotBlank
private Integer estateType;//商铺类型---0:临街商铺 1:住宅底商 2:购物百货中心 3:写字楼商铺 4:档口摊位 5:市场类商铺 6:交通设施商铺 7:旅游商铺
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Double getSize() {
return size;
}
public void setSize(Double size) {
this.size = size;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Integer getFloor() {
return floor;
}
public void setFloor(Integer floor) {
this.floor = floor;
}
public Integer getMaxFloor() {
return maxFloor;
}
public void setMaxFloor(Integer maxFloor) {
this.maxFloor = maxFloor;
}
public Integer getPassengerFlow() {
return passengerFlow;
}
public void setPassengerFlow(Integer passengerFlow) {
this.passengerFlow = passengerFlow;
}
public Integer getLeaseStability() {
return LeaseStability;
}
public void setLeaseStability(Integer leaseStability) {
LeaseStability = leaseStability;
}
public Integer getSellType() {
return sellType;
}
public void setSellType(Integer sellType) {
this.sellType = sellType;
}
public Integer getDecorationCost() {
return decorationCost;
}
public void setDecorationCost(Integer decorationCost) {
this.decorationCost = decorationCost;
}
public Integer getDecorationYear() {
return decorationYear;
}
public void setDecorationYear(Integer decorationYear) {
this.decorationYear = decorationYear;
}
public Integer getEstateType() {
return estateType;
}
public void setEstateType(Integer estateType) {
this.estateType = estateType;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 989 KiB