优化接口
This commit is contained in:
+50
-29
@@ -42,6 +42,7 @@ import org.slf4j.Logger;
|
||||
import org.sothis.web.mvc.ActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -218,6 +219,11 @@ public class ComprehensiveQueryController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("地址(address),面积(size)为必填字段"));
|
||||
return mav;
|
||||
}
|
||||
// 不支持车位等估价
|
||||
if (model.getAddress().contains("车位")) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("非住宅无法估值"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
String cityStr = model.getCity();
|
||||
if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) {
|
||||
@@ -247,35 +253,36 @@ public class ComprehensiveQueryController {
|
||||
} catch (HttpRequestException e) {
|
||||
|
||||
}
|
||||
if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) {
|
||||
//加上高德获取经纬度 和 根据经纬度估值
|
||||
Map<String, String> map = GeoUtils.parserByGaode(model.getCity(), model.getAddress());
|
||||
if (map.containsKey("level") && GAODE_LEVEL.contains(map.get("level"))
|
||||
&& map.containsKey("lng") && map.containsKey("lat")) {
|
||||
String location = map.get("lng") + "," + map.get("lat");
|
||||
JSONObject jsonResult = null;
|
||||
Map<String, String> param = new HashMap<String, String>();
|
||||
param.put("location", location);
|
||||
param.put("area", String.valueOf(model.getSize()));
|
||||
try {
|
||||
jsonResult = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
|
||||
if (jsonResult.containsKey("msg") && "成功".equals(jsonResult.getString("msg"))) {
|
||||
HashMap<String, Object> resultMap = new HashMap<String, Object>();
|
||||
resultMap.put("avgPrice", jsonResult.getString("unitPrice"));
|
||||
resultMap.put("totalPrice", jsonResult.getString("totalPrice"));
|
||||
houseValueInformation.setAddressValue(resultMap);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation));
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
}
|
||||
} catch (HttpRequestException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
// 去掉经纬度解析
|
||||
// if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) {
|
||||
// //加上高德获取经纬度 和 根据经纬度估值
|
||||
// Map<String, String> map = GeoUtils.parserByGaode(model.getCity(), model.getAddress());
|
||||
// if (map.containsKey("level") && GAODE_LEVEL.contains(map.get("level"))
|
||||
// && map.containsKey("lng") && map.containsKey("lat")) {
|
||||
// String location = map.get("lng") + "," + map.get("lat");
|
||||
// JSONObject jsonResult = null;
|
||||
// Map<String, String> param = new HashMap<String, String>();
|
||||
// param.put("location", location);
|
||||
// param.put("area", String.valueOf(model.getSize()));
|
||||
// try {
|
||||
// jsonResult = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
|
||||
// if (jsonResult.containsKey("msg") && "成功".equals(jsonResult.getString("msg"))) {
|
||||
// HashMap<String, Object> resultMap = new HashMap<String, Object>();
|
||||
// resultMap.put("avgPrice", jsonResult.getString("unitPrice"));
|
||||
// resultMap.put("totalPrice", jsonResult.getString("totalPrice"));
|
||||
// houseValueInformation.setAddressValue(resultMap);
|
||||
// mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation));
|
||||
// } else {
|
||||
// mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
// }
|
||||
// } catch (HttpRequestException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// } else {
|
||||
// mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
// }
|
||||
// return mav;
|
||||
// }
|
||||
String id = matchResponse.getJSONObject("result").getString("id");
|
||||
District district = districtService.findById(id);
|
||||
if (district == null) {
|
||||
@@ -305,6 +312,13 @@ public class ComprehensiveQueryController {
|
||||
}
|
||||
|
||||
}
|
||||
// 价格下调10%
|
||||
if (dto.getAvgPrice() != null) {
|
||||
int avgPrice = new BigDecimal(dto.getAvgPrice()).multiply(new BigDecimal(0.9)).intValue();
|
||||
dto.setAvgPrice(avgPrice);
|
||||
}
|
||||
// 非住宅无法估值
|
||||
|
||||
// 保存小区均价的返回结果
|
||||
houseValueInformation.setCommunityAvgPrice(dto);
|
||||
|
||||
@@ -328,6 +342,13 @@ public class ComprehensiveQueryController {
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
}
|
||||
// 价格下调10%
|
||||
Map<String, Object> addressValue = houseValueInformation.getAddressValue();
|
||||
if (addressValue != null && addressValue.get("totalPrice") != null && addressValue.get("avgPrice") != null) {
|
||||
int evaluatePrice = new BigDecimal((Integer) addressValue.get("avgPrice")).multiply(new BigDecimal(0.9)).intValue();
|
||||
addressValue.put("avgPrice", evaluatePrice);
|
||||
addressValue.put("totalPrice", new BigDecimal(evaluatePrice * model.getSize()).intValue());
|
||||
}
|
||||
// houseValueInformation.setAddressValue(modelAndView);
|
||||
|
||||
//房源样本
|
||||
|
||||
Reference in New Issue
Block a user