优化样本查询接口
This commit is contained in:
@@ -80,6 +80,8 @@ public class DistrictAnalyData implements MongoEntity {
|
|||||||
private String tag;
|
private String tag;
|
||||||
private String economic;
|
private String economic;
|
||||||
private Double halfYearMarkup;
|
private Double halfYearMarkup;
|
||||||
|
private Integer valueRate;
|
||||||
|
private String commId;
|
||||||
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -501,4 +503,21 @@ public class DistrictAnalyData implements MongoEntity {
|
|||||||
public void setHalfYearMarkup(Double halfYearMarkup) {
|
public void setHalfYearMarkup(Double halfYearMarkup) {
|
||||||
this.halfYearMarkup = halfYearMarkup;
|
this.halfYearMarkup = halfYearMarkup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Column(name = "value_rate")
|
||||||
|
public Integer getValueRate() {
|
||||||
|
return valueRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValueRate(Integer valueRate) {
|
||||||
|
this.valueRate = valueRate;
|
||||||
|
}
|
||||||
|
@Column(name = "comm_id")
|
||||||
|
public String getCommId() {
|
||||||
|
return commId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommId(String commId) {
|
||||||
|
this.commId = commId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+56
@@ -1,9 +1,12 @@
|
|||||||
package com.fangjia.open.controllers;
|
package com.fangjia.open.controllers;
|
||||||
|
|
||||||
|
import com.fangjia.core.util.DataUtil;
|
||||||
import com.fangjia.core.util.HttpRequest;
|
import com.fangjia.core.util.HttpRequest;
|
||||||
|
import com.fangjia.dal.mongo.model.DistrictAnalyData;
|
||||||
import com.fangjia.dal.mongo.model.VillageIdentify;
|
import com.fangjia.dal.mongo.model.VillageIdentify;
|
||||||
import com.fangjia.dal.seaweed.model.District;
|
import com.fangjia.dal.seaweed.model.District;
|
||||||
import com.fangjia.open.APIConstant;
|
import com.fangjia.open.APIConstant;
|
||||||
|
import com.fangjia.open.dto.UniversalDto;
|
||||||
import com.fangjia.open.dto.addressGovernance.DistrictDto;
|
import com.fangjia.open.dto.addressGovernance.DistrictDto;
|
||||||
import com.fangjia.open.dto.addressGovernance.DistrictIdentifyDto;
|
import com.fangjia.open.dto.addressGovernance.DistrictIdentifyDto;
|
||||||
import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
|
import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
|
||||||
@@ -19,6 +22,7 @@ import com.fangjia.service.bo.DistrictAvgBo;
|
|||||||
import com.fangjia.service.datastore.DistrictService;
|
import com.fangjia.service.datastore.DistrictService;
|
||||||
import com.fangjia.service.district.DistrictStatService;
|
import com.fangjia.service.district.DistrictStatService;
|
||||||
import com.fangjia.service.mongo.fangjia.VillageIdentifyService;
|
import com.fangjia.service.mongo.fangjia.VillageIdentifyService;
|
||||||
|
import com.fangjia.service.open.DistrictAnalyDataService;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@@ -58,6 +62,7 @@ public class AddrSvcController {
|
|||||||
private DistrictStatService districtStatService;
|
private DistrictStatService districtStatService;
|
||||||
private DistrictService districtService;
|
private DistrictService districtService;
|
||||||
private VillageIdentifyService villageIdentifyService;
|
private VillageIdentifyService villageIdentifyService;
|
||||||
|
private DistrictAnalyDataService districtAnalyDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址结构化
|
* 地址结构化
|
||||||
@@ -228,6 +233,53 @@ public class AddrSvcController {
|
|||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object valueRateAction(AddesssMatchModel model) throws Exception {
|
||||||
|
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", model.getCity());
|
||||||
|
params.put("address", model.getAddress());
|
||||||
|
params.put("category", "property");
|
||||||
|
params.put("useMap", "false");
|
||||||
|
params.put("district", model.getSuggestDistrict());
|
||||||
|
try {
|
||||||
|
//新匹配接口
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
|
||||||
|
UniversalDto dto = null;
|
||||||
|
if (json != null && json.size() > 0 && json.containsKey("id")) {
|
||||||
|
String commId = json.getString("id");
|
||||||
|
if (StringUtils.isNotBlank(commId)) {
|
||||||
|
DistrictAnalyData districtAnalyData = districtAnalyDataService.findByDistrictId(commId);
|
||||||
|
if (districtAnalyData != null) {
|
||||||
|
District district = districtService.findById(commId);
|
||||||
|
dto = new UniversalDto();
|
||||||
|
dto.append("city", districtAnalyData.getCity());
|
||||||
|
dto.append("district", districtAnalyData.getRegion());
|
||||||
|
dto.append("name", districtAnalyData.getDistrictName());
|
||||||
|
dto.append("lng", DataUtil.roundDouble(district.getLng()/10000000000d, 6));
|
||||||
|
dto.append("lat", DataUtil.roundDouble(district.getLat()/10000000000d, 6));
|
||||||
|
dto.append("valueRate", districtAnalyData.getValueRate());
|
||||||
|
dto.append("avgPrice", districtAnalyData.getAvgPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dto == null) {
|
||||||
|
mav.setModel(BasicModel.buildOKModel().markNoData());
|
||||||
|
}else{
|
||||||
|
mav.setModel(BasicModel.buildOKModel().setResult(dto));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||||
|
}
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址匹配
|
* 地址匹配
|
||||||
*/
|
*/
|
||||||
@@ -1732,4 +1784,8 @@ public class AddrSvcController {
|
|||||||
public void setVillageIdentifyService(VillageIdentifyService villageIdentifyService) {
|
public void setVillageIdentifyService(VillageIdentifyService villageIdentifyService) {
|
||||||
this.villageIdentifyService = villageIdentifyService;
|
this.villageIdentifyService = villageIdentifyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDistrictAnalyDataService(DistrictAnalyDataService districtAnalyDataService) {
|
||||||
|
this.districtAnalyDataService = districtAnalyDataService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -83,4 +83,10 @@ public interface DistrictAnalyDataService {
|
|||||||
* 此方法将查询不到数据的小区默认为0
|
* 此方法将查询不到数据的小区默认为0
|
||||||
*/
|
*/
|
||||||
LevelInfoBo findQuoteLevelInfo(String city,String region,String name);
|
LevelInfoBo findQuoteLevelInfo(String city,String region,String name);
|
||||||
|
/**
|
||||||
|
* 获取指定小区的价格统计数据
|
||||||
|
* @param commId 小区ID
|
||||||
|
* 此方法将查询不到数据的小区默认为0
|
||||||
|
*/
|
||||||
|
DistrictAnalyData findByDistrictId(String commId);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
@@ -40,6 +40,19 @@ public class DistrictAnalyDataServiceImpl implements DistrictAnalyDataService {
|
|||||||
return districtAnalyData;
|
return districtAnalyData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DistrictAnalyData findByDistrictId(String commId) {
|
||||||
|
String cacheKey = this.getClass().getName() + "_findByDistrictId_" + commId;
|
||||||
|
DistrictAnalyData districtAnalyData = (DistrictAnalyData) CacheUtils.getValue(this.getClass(), cacheKey);
|
||||||
|
if(null != districtAnalyData){
|
||||||
|
return districtAnalyData;
|
||||||
|
}
|
||||||
|
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||||
|
params.add(new QueryParam("commId", commId));
|
||||||
|
districtAnalyData = districtAnalyDataDao.findFirstByParams(params);
|
||||||
|
CacheUtils.putValue(CacheUtils.CachePolicyEnum.LONG,this.getClass(), cacheKey, districtAnalyData);
|
||||||
|
return districtAnalyData;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDistrictAnalyDataDao(DistrictAnalyDataDao districtAnalyDataDao) {
|
public void setDistrictAnalyDataDao(DistrictAnalyDataDao districtAnalyDataDao) {
|
||||||
this.districtAnalyDataDao = districtAnalyDataDao;
|
this.districtAnalyDataDao = districtAnalyDataDao;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user