修改楼盘评级接口

This commit is contained in:
majintao
2025-06-17 16:59:49 +08:00
parent 5b66c702f2
commit 11a6a41abb
6 changed files with 1068 additions and 40 deletions
@@ -1,7 +1,11 @@
package com.fangjia.open.controllers;
import com.fangjia.core.util.*;
import com.fangjia.dal.mongo.model.*;
import com.fangjia.open.model.*;
import com.fangjia.service.address.mode.Address;
import com.fangjia.service.datastore.CommunityRateService;
import com.sun.xml.bind.v2.TODO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -25,10 +29,6 @@ import com.fangjia.dal.SrQuery;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.common.ServerAreaData;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.AddressCheck;
import com.fangjia.dal.mongo.model.CommData;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.RegionBlock;
import com.fangjia.dal.mongo.open.model.WaitCrawlKeywords;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.open.APIConstant;
@@ -96,6 +96,7 @@ public class AddressController {
private HouseLoudongService houseLoudongService;
private FjtEvaluationService fjtEvaluationService;
private AddressMatchProxyService addressMatchProxyService;
private CommunityRateService communityRateService;
private final static String AK = OpenConfig.getConfig().getBaiduAk();
private final static Logger LOGGER = LoggerFactory.getLogger(AddressController.class);
@@ -2141,48 +2142,55 @@ public class AddressController {
* @param model
* @return
*/
public Object propertyRatingAction(CommunitySummaryRequestDto model) {
public Object propertyRatingAction(CommunitySummaryRequestDto model){
// type:all 输出所有字段,否则只输出文档中的字段
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress()) && StringUtils.isBlank(model.getId())) {
mav.setModel(BasicModel.buildBadRequestModel("小区ID或地址不能为空"));
return mav;
BasicModel resultModel = new BasicModel(HttpStatusCodeEnum.OK);
String city = model.getCity();
String address = model.getAddress();
String id = model.getId();
// 借用原有字段 memo :备注 当 memo 为all的时候输出全部字段,默认输出文档中的字段
String memo = model.getMemo();
//TODO 根据城市和地址查询
if ((StringUtils.isBlank(city) && StringUtils.isBlank(address) || StringUtils.isBlank(id))) {
mav.setModel(BasicModel.buildBadRequestModel("需要小区ID或者城市+地址参数组合"));
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
try {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
JSONObject reqBody = new JSONObject();
reqBody.put("city", model.getCity());
reqBody.put("address", model.getAddress());
reqBody.put("id", model.getId());
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/propertyRating", reqBody, headers, "UTF-8");
if (result != null) {
try {
json = JSONObject.fromObject(result);
} catch (Exception e) {
json = null;
if (StringUtils.isNotBlank(id)) {
CommunityRate communityRate = communityRateService.findBySeeweadId(id);
if (communityRate != null) {
if ("all".equals(memo)) {
// 为all的时候输出全部字段
resultModel.setResult(communityRate);
}else {
// 默认输出文档中的字段
CommunityRate communityRateResult = new CommunityRate();
communityRateResult.setCity(communityRate.getCity());
communityRateResult.setAddress(communityRate.getAddress());
communityRateResult.setName(communityRate.getName());
communityRateResult.setRating(communityRate.getRating());
communityRateResult.setTotalScore(communityRate.getTotalScore());
communityRateResult.setCommunityQualityRating(communityRate.getCommunityQualityRating());
communityRateResult.setCommunityQualityScore(communityRate.getCommunityQualityScore());
communityRateResult.setCommunityPriceRating(communityRate.getCommunityPriceRating());
communityRateResult.setCommunityPriceScore(communityRate.getCommunityPriceScore());
communityRateResult.setLocationAdvantageRating(communityRate.getLocationAdvantageRating());
communityRateResult.setLocationAdvantageScore(communityRate.getLocationAdvantageScore());
communityRateResult.setFlowabilityRating(communityRate.getFlowabilityRating());
communityRateResult.setFlowabilityScore(communityRate.getFlowabilityScore());
communityRateResult.setLivingFacilitiesRating(communityRate.getLivingFacilitiesRating());
communityRateResult.setLivingFacilitiesScore(communityRate.getLivingFacilitiesScore());
communityRateResult.setEducationRating(communityRate.getEducationRating());
communityRateResult.setEducationScore(communityRate.getEducationScore());
communityRateResult.setHospitalRating(communityRate.getHospitalRating());
communityRateResult.setHospitalScore(communityRate.getHospitalScore());
resultModel.setResult(communityRateResult);
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (json != null) {
int code = json.getInt("status");
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("服务升级中..."));
}
mav.setModel(resultModel);
return mav;
}
/**
@@ -3455,6 +3463,7 @@ public class AddressController {
return Collections.emptyList();
}
public void setAddressService(AddressService addressService) {
this.addressService = addressService;
}
@@ -3510,4 +3519,8 @@ public class AddressController {
public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) {
this.addressMatchProxyService = addressMatchProxyService;
}
public void setCommunityRateService(CommunityRateService communityRateService) {
this.communityRateService = communityRateService;
}
}