新增接口及接口bug修改
This commit is contained in:
+49
-25
@@ -222,32 +222,50 @@ public class OfficeSellController {
|
||||
public Object evaluateSellAction(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");
|
||||
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 (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) {
|
||||
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) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该写字楼不存在"));
|
||||
return mav;
|
||||
|
||||
}
|
||||
|
||||
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.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法"));
|
||||
return mav;
|
||||
}
|
||||
if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
|
||||
return mav;
|
||||
@@ -287,16 +305,19 @@ public class OfficeSellController {
|
||||
districtPriceMap.put("district", district.getRegion());
|
||||
districtPriceMap.put("name", district.getName());
|
||||
districtPriceMap.put("unitPrice", evaluation.getUnitPrice());
|
||||
districtPriceMap.put("samples", 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, "/officeSell/evaluateSell");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Long totalPrice = (long) (evaluation.getUnitPrice() * model.getSize());
|
||||
districtPriceMap.put("totalPrice", totalPrice);
|
||||
if(model.getShow()!=null && model.getShow()==1){
|
||||
districtPriceMap.put("samples", 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, "/officeSell/evaluateSell");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
return mav;
|
||||
} else {
|
||||
@@ -473,7 +494,10 @@ public class OfficeSellController {
|
||||
if (StringUtils.isNotBlank(model.getOtherFactor())) {
|
||||
evaluation.setOtherFactor(model.getOtherFactor());
|
||||
}
|
||||
evaluation.setRegion(model.getDistrict());
|
||||
if(StringUtils.isNotBlank(model.getDistrict())){
|
||||
evaluation.setRegion(model.getDistrict());
|
||||
}
|
||||
|
||||
if (null != model.getRoom()) {
|
||||
evaluation.setRoom(model.getRoom());
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ public class PoiController {
|
||||
|
||||
for (Map<String, Object> hit : hits) {
|
||||
Map<String, Object> source = (Map<String, Object>) hit.get("_source");
|
||||
if (source.containsKey("name")) {
|
||||
if (source.containsKey("name") && !source.get("name").toString().contains("公司")) {
|
||||
poiNames.add(source.get("name").toString());
|
||||
}
|
||||
}
|
||||
|
||||
+530
-4
@@ -51,6 +51,7 @@ import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.sothis.core.util.CollectionUtils;
|
||||
@@ -1660,7 +1661,16 @@ public class PropertyController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (district == null) {
|
||||
//加上高德获取经纬度 和 根据经纬度估值
|
||||
@@ -2493,9 +2503,19 @@ public class PropertyController {
|
||||
item.put("name", districtStat.getDistrictName());
|
||||
item.put("avgPrice", districtStat.getAvgPrice());
|
||||
item.put("date", districtStat.getDate() / 100 + "-" + String.format("%02d", districtStat.getDate() % 100));
|
||||
item.put("changePercent", BigDecimal.valueOf(districtStat.getMom() * 100)
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
if(null == districtStat.getMom()){
|
||||
if(result.size()>0){
|
||||
Integer avgPrice = (Integer) result.get(result.size() - 1).get("avgPrice");
|
||||
double mom = (districtStat.getAvgPrice() - avgPrice)*100.0/avgPrice;
|
||||
item.put("changePercent", DataUtil.getRound(2, mom));
|
||||
}else{
|
||||
item.put("changePercent", 0);
|
||||
}
|
||||
}else{
|
||||
item.put("changePercent", BigDecimal.valueOf(districtStat.getMom() * 100)
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
}
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
@@ -6013,6 +6033,512 @@ public class PropertyController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
public Object sellCaseAction(PropertyEvaluationModel model, HttpServletRequest request){
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
|
||||
if (StringUtils.isBlank(model.getCity())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
String estateType = null;
|
||||
if(StringUtils.isNotBlank(model.getPropertyType())){
|
||||
if(model.getPropertyType().equals("0")){
|
||||
estateType = "普通住宅";
|
||||
}else if(model.getPropertyType().equals("1")){
|
||||
estateType = "别墅";
|
||||
}else if(model.getPropertyType().equals("2")){
|
||||
estateType = "商住";
|
||||
}
|
||||
}
|
||||
|
||||
District district = null;
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())){
|
||||
if(StringUtils.isNotBlank(model.getEstateType()) && model.getEstateType().equals("别墅") && !model.getName().contains("别墅")){
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName()+"别墅","district");
|
||||
}else{
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
|
||||
}
|
||||
}
|
||||
|
||||
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(), "property", false);
|
||||
}else if(StringUtils.isNotBlank(model.getName())){
|
||||
if(estateType !=null && estateType.equals("别墅") && !model.getName().contains("别墅")){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName()+"别墅", "property", false);
|
||||
}else{
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName(), "property", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(resultObject != null){
|
||||
String id = (String) resultObject.get("id");
|
||||
district = districtService.findById(id);
|
||||
}
|
||||
}
|
||||
if(district == null && StringUtils.isBlank(model.getLocation())){
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(null));
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
String startDate = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -3),"yyyyMMdd");
|
||||
String endDate = DateUtil.formatByPattern(new Date(), "yyyyMMdd");
|
||||
|
||||
List<HouseCaseDto> caseDtos = new ArrayList<HouseCaseDto>();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
if (model.getPageSize() != null) {
|
||||
pager.setPageSize(model.getPageSize());
|
||||
// if(model.getPageSize() <=50){
|
||||
// pager.setPageSize(model.getPageSize());
|
||||
// }else{
|
||||
// pager.setPageSize(50);
|
||||
// }
|
||||
} else {
|
||||
pager.setPageSize(5);
|
||||
}
|
||||
|
||||
// 默认1公里内
|
||||
if (model.getRadius() == null) {
|
||||
model.setRadius(1000);
|
||||
}
|
||||
|
||||
|
||||
if(district != null){
|
||||
if(model.getMinPrice() == null){
|
||||
DistrictSellStat districtSellStat = districtSellStatService.findFirstByParams(district.getCity(), district.getRegion(), district.getName());
|
||||
if(districtSellStat != null) {
|
||||
int minPrice = (int) (districtSellStat.getAvgPrice() - districtSellStat.getAvgPrice() * 0.1);
|
||||
model.setMinPrice(minPrice);
|
||||
|
||||
int maxPrice = (int) (districtSellStat.getAvgPrice() + districtSellStat.getAvgPrice() * 0.1);
|
||||
model.setMaxPrice(maxPrice);
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null && model.getMinPrice()>0){
|
||||
model.setMinPrice(model.getMinPrice());
|
||||
}
|
||||
if(model.getMaxPrice() != null && model.getMaxPrice()>0){
|
||||
model.setMaxPrice(model.getMaxPrice());
|
||||
}
|
||||
}
|
||||
//先查成交案例
|
||||
Date startTime = DateUtil.parseDate(startDate,"yyyyMMdd");
|
||||
Date endTime = DateUtil.parseDate(endDate,"yyyyMMdd");
|
||||
List<DealPrice> dealPrices = dealPriceService.findDealPrices(district.getId(), pager.getPageSize(), model.getMinPrice(), model.getMaxPrice(), startTime, endTime);
|
||||
|
||||
if(dealPrices!=null && dealPrices.size()>0){
|
||||
caseDtos = createDealHouseCase(caseDtos, dealPrices, 0, model.getShowSource());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
if(caseDtos.size() < pager.getPageSize()){
|
||||
//查自身样本
|
||||
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());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
if(caseDtos.size() < pager.getPageSize() && StringUtils.isNotBlank(estateType) && district.getName().contains("别墅")){
|
||||
District newDist = new District();
|
||||
newDist.setCity(district.getCity());
|
||||
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);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
}
|
||||
//有物业类型且自身样本数据不足,忽略物业类型查
|
||||
if(caseDtos.size() ==0 && StringUtils.isNotBlank(estateType)){
|
||||
District newDist = new District();
|
||||
newDist.setCity(district.getCity());
|
||||
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);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//自身样本不足,查周边成交
|
||||
List<District> districts = districtService.findNearestDistrict(district, 1000, 20);
|
||||
if(districts!=null && districts.size()>0){
|
||||
for(District d : districts){
|
||||
if(!district.getId().equals(d.getId())){
|
||||
dealPrices = dealPriceService.findDealPrices(d.getId(), pager.getPageSize(), model.getMinPrice(), model.getMaxPrice(), DateUtil.parseDate(startDate,"yyyyMMdd"), DateUtil.parseDate(endDate,"yyyyMMdd"));
|
||||
if(dealPrices!=null && dealPrices.size()>0 && d.getLng()!=null && d.getLng()>0){
|
||||
double distance = GeoUtils.calculateDistance(district.getLng()/10000000000.0, district.getLat()/10000000000.0, d.getLng()/10000000000.0, d.getLat()/10000000000.0);
|
||||
caseDtos = createDealHouseCase(caseDtos, dealPrices, (int)distance, model.getShowSource());
|
||||
if(caseDtos.size()>pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//自身成交,自身样本,周边成交不足,查周边挂牌
|
||||
List<Seawater> houseAround = null;
|
||||
if (caseDtos.size() < pager.getPageSize() ) {
|
||||
Double lng = null;
|
||||
Double lat = null;
|
||||
if(district!=null && district.getLat()!=null && district.getLat()>0){
|
||||
lng = district.getLng()/10000000000.0;
|
||||
lat = district.getLat()/10000000000.0;
|
||||
if(estateType == null ){
|
||||
estateType = district.getEstateType2();
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(model.getLocation())){
|
||||
String[] locationStr = model.getLocation().split(",");
|
||||
String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数
|
||||
for (String loc : locationStr) {
|
||||
if (!loc.trim().matches(numberPattern)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)格式错误"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
lng = Double.valueOf(locationStr[0]);
|
||||
lat = Double.valueOf(locationStr[1]);
|
||||
if (lng < 70 || lng > 140 || lat < 0 || lat > 55) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("非中国经纬度"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
if(lat !=null && lat>0){
|
||||
houseAround = houseService.findArroundHouseByParams("sell", lng, lat, Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager, model.getRadius());
|
||||
}
|
||||
if(houseAround != null && houseAround.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource());
|
||||
}
|
||||
}
|
||||
if(caseDtos.size()>pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
public Object rentCaseAction(PropertyEvaluationModel model, HttpServletRequest request){
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
|
||||
if (StringUtils.isBlank(model.getCity())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getName()) && StringUtils.isBlank(model.getAddress()) ) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:名称或地址至少填一个"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
District district = null;
|
||||
String estateType = null;
|
||||
if(StringUtils.isNotBlank(model.getPropertyType())){
|
||||
if(model.getPropertyType().equals("0")){
|
||||
estateType = "普通住宅";
|
||||
}else if(model.getPropertyType().equals("1")){
|
||||
estateType = "别墅";
|
||||
}else if(model.getPropertyType().equals("2")){
|
||||
estateType = "商住";
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())){
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
|
||||
}
|
||||
|
||||
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(), "property", false);
|
||||
}else if(StringUtils.isNotBlank(model.getName())){
|
||||
if(estateType !=null && estateType.equals("别墅") && !model.getName().contains("别墅")){
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName()+"别墅", "property", false);
|
||||
}else{
|
||||
resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getName(), "property", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(resultObject != null){
|
||||
String id = (String) resultObject.get("id");
|
||||
district = districtService.findById(id);
|
||||
}
|
||||
}
|
||||
if(district == null && StringUtils.isBlank(model.getLocation())){
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(null));
|
||||
return mav;
|
||||
}
|
||||
|
||||
String startDate = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -6),"yyyyMMdd");
|
||||
String endDate = DateUtil.formatByPattern(new Date(), "yyyyMMdd");
|
||||
|
||||
List<HouseCaseDto> caseDtos = new ArrayList<HouseCaseDto>();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
if (model.getPageSize() != null) {
|
||||
// pager.setPageSize(model.getPageSize());
|
||||
if(model.getPageSize() <=50){
|
||||
pager.setPageSize(model.getPageSize());
|
||||
}else{
|
||||
pager.setPageSize(50);
|
||||
}
|
||||
} else {
|
||||
pager.setPageSize(5);
|
||||
}
|
||||
|
||||
// 默认1公里内
|
||||
if (model.getRadius() == null) {
|
||||
model.setRadius(1000);
|
||||
}
|
||||
|
||||
|
||||
if(district != null){
|
||||
if(model.getMinPrice() == null){
|
||||
SqmetreRent rent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), "district");
|
||||
|
||||
if(rent != null) {
|
||||
int minPrice = (int) (rent.getAvgPrice().intValue() - rent.getAvgPrice().intValue() * 0.1);
|
||||
model.setMinPrice(minPrice);
|
||||
|
||||
int maxPrice = (int) (rent.getAvgPrice().intValue() + rent.getAvgPrice().intValue() * 0.1);
|
||||
model.setMaxPrice(maxPrice);
|
||||
}
|
||||
}else{
|
||||
if(model.getMinPrice() != null && model.getMinPrice()>0){
|
||||
model.setMinPrice(model.getMinPrice());
|
||||
}
|
||||
if(model.getMaxPrice() != null && model.getMaxPrice()>0){
|
||||
model.setMaxPrice(model.getMaxPrice());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(caseDtos.size() < pager.getPageSize()){
|
||||
//查自身样本
|
||||
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());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
if(caseDtos.size() < pager.getPageSize() && StringUtils.isNotBlank(estateType) && district.getName().contains("别墅")){
|
||||
District newDist = new District();
|
||||
newDist.setCity(district.getCity());
|
||||
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);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//有物业类型且自身样本数据不足,忽略物业类型查
|
||||
if(caseDtos.size() ==0 && StringUtils.isNotBlank(estateType)){
|
||||
District newDist = new District();
|
||||
newDist.setCity(district.getCity());
|
||||
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);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//自身样本不足,查周边挂牌
|
||||
List<Seawater> houseAround = null;
|
||||
if (caseDtos.size() < pager.getPageSize() ) {
|
||||
Double lng = null;
|
||||
Double lat = null;
|
||||
if(district!=null && district.getLat()!=null && district.getLat()>0){
|
||||
lng = district.getLng()/10000000000.0;
|
||||
lat = district.getLat()/10000000000.0;
|
||||
if(estateType == null ){
|
||||
estateType = district.getEstateType2();
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(model.getLocation())){
|
||||
String[] locationStr = model.getLocation().split(",");
|
||||
String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数
|
||||
for (String loc : locationStr) {
|
||||
if (!loc.trim().matches(numberPattern)) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)格式错误"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
lng = Double.valueOf(locationStr[0]);
|
||||
lat = Double.valueOf(locationStr[1]);
|
||||
if (lng < 70 || lng > 140 || lat < 0 || lat > 55) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("非中国经纬度"));
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
if(lat !=null && lat>0){
|
||||
houseAround = houseService.findArroundHouseByParams("rent", lng, lat, Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager, model.getRadius());
|
||||
}
|
||||
if(houseAround != null && houseAround.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource());
|
||||
}
|
||||
}
|
||||
if(caseDtos.size()>pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<HouseCaseDto> createDealHouseCase(List<HouseCaseDto> caseDtos, List<DealPrice> dealPrices,int distance, Integer showSource){
|
||||
if(dealPrices!=null && dealPrices.size()>0){
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for(HouseCaseDto dto : caseDtos){
|
||||
ids.add(dto.getId());
|
||||
}
|
||||
for(DealPrice dp : dealPrices){
|
||||
if(!ids.contains(dp.getId())){
|
||||
HouseCaseDto dto = new HouseCaseDto();
|
||||
dto.setId(dp.getId());
|
||||
dto.setCity(dp.getCity());
|
||||
dto.setDistrict(dp.getRegion());
|
||||
dto.setName(dp.getDistrictName());
|
||||
dto.setSize(dp.getArea());
|
||||
dto.setDistance(distance);
|
||||
dto.setUnitPrice(dp.getAvgPrice());
|
||||
dto.setTotalPrice(dp.getTotalPrice());
|
||||
dto.setDecoration(dp.getFitment());
|
||||
dto.setDirection(dp.getDirection());
|
||||
dto.setFloor(dp.getFloor());
|
||||
dto.setMaxFloor(dp.getHeight());
|
||||
dto.setRoom(String.valueOf(dp.getRoom()));
|
||||
dto.setHall(String.valueOf(dp.getHall()));
|
||||
dto.setCaseDate(DateUtil.formatByPattern(dp.getTradeDate(), "yyyy-MM-dd"));
|
||||
if(showSource!=null && showSource==1){
|
||||
dto.setSource("成交");
|
||||
}
|
||||
caseDtos.add(dto);
|
||||
}
|
||||
}
|
||||
return caseDtos;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private List<HouseCaseDto> createHouseCase(List<HouseCaseDto> caseDtos, List<Seawater> houses, Integer showSource){
|
||||
if (houses != null && !houses.isEmpty()) {
|
||||
Set<String> seenIds = new HashSet<String>();
|
||||
Iterator<Seawater> iterator = houses.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Seawater s = iterator.next();
|
||||
if (!seenIds.add(s.getId())) {
|
||||
// 如果已经存在,则从列表中移除
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for(HouseCaseDto dto : caseDtos){
|
||||
ids.add(dto.getId());
|
||||
}
|
||||
for (Seawater house : houses) {
|
||||
if(!ids.contains(house.getId())){
|
||||
HouseCaseDto caseDto = new HouseCaseDto();
|
||||
caseDto.setId(house.getId());
|
||||
caseDto.setCity(house.getCity());
|
||||
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());
|
||||
caseDto.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
caseDto.setDirection(house.getDirection());
|
||||
caseDto.setDecoration(house.getFitment());
|
||||
caseDto.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
|
||||
caseDto.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight());
|
||||
caseDto.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom().toString());
|
||||
caseDto.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall().toString());
|
||||
|
||||
if (house.getpDate() != null && house.getpDate() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getpDate());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
caseDto.setCaseDate(formattedDate);
|
||||
}
|
||||
caseDto.setDistance(house.getDistance());
|
||||
if(showSource!=null && showSource==1){
|
||||
caseDto.setSource("挂牌");
|
||||
}
|
||||
caseDtos.add(caseDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return caseDtos;
|
||||
}
|
||||
|
||||
public void setHouseLoudongService(HouseLoudongService houseLoudongService) {
|
||||
this.houseLoudongService = houseLoudongService;
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.fangjia.open.dto;
|
||||
|
||||
public class HouseCaseDto {
|
||||
|
||||
private String id;//房源id
|
||||
private String city;//城市
|
||||
private String district;//区域
|
||||
private String name;//楼盘名称
|
||||
private Integer distance;//距离(单位:米)
|
||||
private Double size;//面积(单位:平米)
|
||||
private Integer unitPrice;//单价(单位:元/平米)
|
||||
private Integer totalPrice;//总价(单位:元)
|
||||
private String decoration;//装修(如:精装)
|
||||
private String direction;//朝向(如:南)
|
||||
private Integer floor;//所在楼层
|
||||
private Integer maxFloor;//总楼层
|
||||
private String room;//室
|
||||
private String hall;//厅
|
||||
private String caseDate;//案例时间(如: 2013-07-12)
|
||||
private String source;//来源
|
||||
|
||||
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 Double getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Integer getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Integer unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public Integer getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(Integer totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
public String getDecoration() {
|
||||
return decoration;
|
||||
}
|
||||
|
||||
public void setDecoration(String decoration) {
|
||||
this.decoration = decoration;
|
||||
}
|
||||
|
||||
public String getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(String direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
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 String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public String getHall() {
|
||||
return hall;
|
||||
}
|
||||
|
||||
public void setHall(String hall) {
|
||||
this.hall = hall;
|
||||
}
|
||||
|
||||
public String getCaseDate() {
|
||||
return caseDate;
|
||||
}
|
||||
|
||||
public void setCaseDate(String caseDate) {
|
||||
this.caseDate = caseDate;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
}
|
||||
+65
@@ -296,6 +296,39 @@ public class PropertyEvaluationModel extends FangjiaApiModel {
|
||||
|
||||
private String sampleIds;
|
||||
|
||||
private Integer max;
|
||||
|
||||
|
||||
private Date startDate;
|
||||
private Date endDate;
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 显示来源
|
||||
*/
|
||||
private Integer showSource;
|
||||
|
||||
/**
|
||||
* 显示房源 1:显示 0:默认 不显示
|
||||
*/
|
||||
private Integer show;
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getShowSource() {
|
||||
return showSource;
|
||||
}
|
||||
|
||||
public void setShowSource(Integer showSource) {
|
||||
this.showSource = showSource;
|
||||
}
|
||||
|
||||
public void setDecorationAge(int decorationAge) {
|
||||
this.decorationAge = decorationAge;
|
||||
}
|
||||
@@ -962,4 +995,36 @@ public class PropertyEvaluationModel extends FangjiaApiModel {
|
||||
public String getSampleIds() {
|
||||
return sampleIds;
|
||||
}
|
||||
|
||||
public Integer getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(Integer max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Integer getShow() {
|
||||
return show;
|
||||
}
|
||||
|
||||
public void setShow(Integer show) {
|
||||
this.show = show;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,11 @@
|
||||
</ladders>
|
||||
</rule>
|
||||
|
||||
<rule controller="officeSell" action="evaluateSell" channel="office">
|
||||
<ladders>
|
||||
<ladder>/evaluateSell</ladder>
|
||||
</ladders>
|
||||
</rule>
|
||||
|
||||
</rules>
|
||||
</urlrewrite>
|
||||
+1
@@ -1469,6 +1469,7 @@ public class AddressParserImpl implements AddressParser {
|
||||
.replaceAll("【】()\\(\\)\\[\\]", "").replaceAll("\\*+", "").replaceAll("[\\s ]+", "");
|
||||
}
|
||||
|
||||
|
||||
public void setDistrictService(DistrictService districtService) {
|
||||
this.districtService = districtService;
|
||||
}
|
||||
|
||||
+11
@@ -88,5 +88,16 @@ public interface AddressMatchProxyService {
|
||||
|
||||
|
||||
JSONObject addressStructure(String city, String address);
|
||||
|
||||
|
||||
/**
|
||||
* 最新的匹配算法(穆)
|
||||
* @param city
|
||||
* @param address
|
||||
* @param category
|
||||
* @param useMap
|
||||
* @return
|
||||
*/
|
||||
JSONObject newMatch(String city, String address, String category, boolean useMap );
|
||||
|
||||
}
|
||||
|
||||
+29
@@ -866,6 +866,35 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject newMatch(String city, String address, String category, boolean useMap ){
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("city", city);
|
||||
params.put("address", address);
|
||||
if(StringUtils.isNotBlank(category)){
|
||||
params.put("category", category);
|
||||
}
|
||||
|
||||
params.put("useMap", String.valueOf(useMap));
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (json != null && json.size()>0) {
|
||||
return (JSONObject)json;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setHouseLoudongService(HouseLoudongService houseLoudongService) {
|
||||
this.houseLoudongService = houseLoudongService;
|
||||
}
|
||||
|
||||
+10
-1
@@ -99,6 +99,15 @@ public interface DistrictSellStatService {
|
||||
* @return
|
||||
*/
|
||||
Long findCityMarkDownDistrictCount(String city);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查找最新一期的月度增价
|
||||
* @param city
|
||||
* @param region
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DistrictSellStat findFirstByParams(String city, String region,String name);
|
||||
|
||||
}
|
||||
|
||||
+13
@@ -219,4 +219,17 @@ public class DistrictSellStatServiceImpl implements DistrictSellStatService {
|
||||
params.add(new QueryParam("mom", QueryParam.LESS_THAN_OPERATOR, 0));
|
||||
return districtSellStatDao.findCountByParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistrictSellStat findFirstByParams(String city, String region,String name) {
|
||||
List<QueryParam> queryParams = ImmutableList.of(
|
||||
new QueryParam("city", city),
|
||||
new QueryParam("region", region),
|
||||
new QueryParam("districtName", name)
|
||||
);
|
||||
List<SortParam> sortParams = ImmutableList.of(
|
||||
new SortParam("date", false)
|
||||
);
|
||||
return districtSellStatDao.findFirstByParams(queryParams, sortParams);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -2014,6 +2014,13 @@ public class DistrictServiceImpl implements DistrictService {
|
||||
if (city == null){
|
||||
return null;
|
||||
}
|
||||
if(RegionData.isRegion(city, region)){
|
||||
region = RegionData.formatRegion(city, region);
|
||||
}
|
||||
if(region == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
District districtInfo = findDistrict(new DistrictKey(city, region, name), target);
|
||||
// 先精确查询,查不到再根据别名匹配
|
||||
if (districtInfo != null) {
|
||||
@@ -2449,6 +2456,7 @@ public class DistrictServiceImpl implements DistrictService {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("category", "district"));
|
||||
params.add(new QueryParam("city", district.getCity()));
|
||||
params.add(new QueryParam("estateType2", district.getEstateType2()));
|
||||
params.add(new QueryParam("visible", 0));
|
||||
SdQuery sdQuery = new SdQuery();
|
||||
sdQuery.setPoint((double) district.getLat() / 10000000000.0 + "," + (double) district.getLng() / 10000000000.0);
|
||||
@@ -2456,7 +2464,7 @@ public class DistrictServiceImpl implements DistrictService {
|
||||
sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0));
|
||||
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
||||
List<District> list = districtDao.findAllByParams(params, null, 0, limit * 2,
|
||||
new String[] { "city", "region", "name", "estateType2", "id" });
|
||||
new String[] { "city", "region", "name", "estateType2", "id","lat","lng" });
|
||||
if (list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
+28
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import com.fangjia.dal.FacetQuery;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.datastore.model.RentHouse;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.datastore.driver.FacetResult;
|
||||
import com.fangjia.service.bo.HousePDSBo;
|
||||
import com.fangjia.service.bo.HouseScorer;
|
||||
@@ -473,5 +474,32 @@ public interface HouseService extends ModeService<String, HouseBo> {
|
||||
|
||||
List<House> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit);
|
||||
|
||||
/**
|
||||
* 查询自身房源
|
||||
* @param district
|
||||
* @param cat
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param startPrie
|
||||
* @param endPrice
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
List<Seawater> findSelfHouseByParams(District district, String cat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager);
|
||||
|
||||
/**
|
||||
* 根据经纬度查周边样本
|
||||
* @param lng
|
||||
* @param lat
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param startPrie
|
||||
* @param endPrice
|
||||
* @param pager
|
||||
* @param radius
|
||||
* @return
|
||||
*/
|
||||
List<Seawater> findArroundHouseByParams(String cat, Double lng, Double lat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager, Integer radius);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+247
-5
@@ -11,16 +11,18 @@ import com.fangjia.dal.datastore.model.House;
|
||||
import com.fangjia.dal.datastore.model.RentHouse;
|
||||
import com.fangjia.dal.mongo.dao.UserHouseDao;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.DistrictStat;
|
||||
import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
|
||||
import com.fangjia.dal.mongo.model.UserHouse;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
|
||||
import com.fangjia.dal.seawater.dao.SeawaterDao;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.datastore.driver.DSCollection;
|
||||
import com.fangjia.datastore.driver.DataStore;
|
||||
import com.fangjia.datastore.driver.FacetResult;
|
||||
import com.fangjia.service.api.KnowbaseService;
|
||||
import com.fangjia.service.bo.HouseBo;
|
||||
import com.fangjia.service.bo.HousePDSBo;
|
||||
import com.fangjia.service.bo.HouseScorer;
|
||||
import com.fangjia.service.bo.KnowbaseBo;
|
||||
import com.fangjia.service.bo.*;
|
||||
import com.fangjia.service.common.SellSimilar;
|
||||
import com.fangjia.service.datastore.bean.HouseQueryBean;
|
||||
import com.fangjia.service.district.DistrictStatService;
|
||||
@@ -31,6 +33,7 @@ import com.fangjia.service.menu.Menu;
|
||||
import com.fangjia.service.mode.ModeEnum;
|
||||
import com.fangjia.service.mongo.fangjia.MetroService;
|
||||
import com.fangjia.service.query.QueryBean;
|
||||
import com.fangjia.service.util.CommonUtils;
|
||||
import com.fangjia.service.util.ServiceUtil;
|
||||
import com.fangjia.service.util.SitenameUtil;
|
||||
import com.fangjia.service.web.MenuService;
|
||||
@@ -38,6 +41,7 @@ import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
@@ -83,7 +87,9 @@ public class HouseServiceImpl implements HouseService {
|
||||
* 房源样本估价简洁模式检索属性
|
||||
*/
|
||||
private static final String[] SAMPLE_COMPACT = {"id", "city", "region", "districtName", "name", "area", "hall", "room", "toilet", "floor", "height", "direction", "fitment", "totalPrice", "url", "publishDate" };
|
||||
|
||||
|
||||
public static String[] TAGS = new String[]{"独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园", "洋房", "叠拼", "独院", "联体", "微墅", "大平墅"};
|
||||
|
||||
private HouseDao houseDao;
|
||||
private PicService picService;
|
||||
private DistrictService districtService;
|
||||
@@ -94,6 +100,7 @@ public class HouseServiceImpl implements HouseService {
|
||||
private BoostQueryPolicy boostQueryInformationPolicy;
|
||||
private UserHouseDao userHouseDao;
|
||||
private DistrictStatService districtStatService;
|
||||
private SeawaterDao seawaterDao;
|
||||
|
||||
public FacetQueryResult<HouseBo> randomGainHouse(HouseQueryBean queryBean, int count) {
|
||||
long totalCount = this.findHouseCount(queryBean);
|
||||
@@ -2635,4 +2642,239 @@ public class HouseServiceImpl implements HouseService {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Seawater> findSelfHouseByParams(District district, String cat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager) {
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
// 先用名字查自身的样本
|
||||
query.setCityDisplay(district.getCity());
|
||||
query.setRegion(district.getRegion());
|
||||
query.setDistrictName(district.getName());
|
||||
query.setCat(cat);
|
||||
query.setStartDate(startTime);
|
||||
query.setEndDate(endTime);
|
||||
if(StringUtils.isNotBlank(estateType)){
|
||||
query.setEstateType(estateType);
|
||||
}
|
||||
|
||||
if (startPrie != null) {
|
||||
query.setStartPrice(startPrie);
|
||||
}
|
||||
if(endPrice != null){
|
||||
query.setEndPrice(endPrice);
|
||||
}
|
||||
query.setPager(pager);
|
||||
query.setSortField("p_date");
|
||||
query.setOrder(false);
|
||||
query.setTable("latest_seawater");
|
||||
// if(StringUtils.isNotBlank(estateType)){
|
||||
List<Seawater> seawaters = seawaterDao.findSeawatersByQuery(query);
|
||||
List<Seawater> houses = new ArrayList<Seawater>();
|
||||
for(Seawater s : seawaters){
|
||||
if(StringUtils.isNotBlank(district.getEstateType2())){
|
||||
if (district.getEstateType2().equals("普通住宅")) {//01:普通住宅 02:别墅
|
||||
if (StringUtils.isNotBlank(s.getEstateType()) && s.getEstateType().contains("别墅")) {
|
||||
continue;
|
||||
}
|
||||
if (isVilla(s.getArea(), s.getName(), s.getHeight(), s.getRoom())) {
|
||||
continue;
|
||||
}
|
||||
houses.add(s);
|
||||
} else if (district.getEstateType2().equals("别墅")) {
|
||||
if (s.getHeight() != null && s.getHeight() >= 10) {
|
||||
continue;
|
||||
}
|
||||
if (s.getFloor() != null && s.getFloor() >= 10) {
|
||||
continue;
|
||||
}
|
||||
if (s.getArea()<=150) {
|
||||
continue;
|
||||
}
|
||||
houses.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return houses;
|
||||
// }
|
||||
// return seawaterDao.findSeawatersByQuery(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Seawater> findArroundHouseByParams(String cat, Double lng, Double lat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager, Integer radius) {
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setLat(lat);
|
||||
query.setLng(lng);
|
||||
query.setRadius(radius);
|
||||
|
||||
query.setCat(cat);
|
||||
query.setStartDate(startTime);
|
||||
query.setEndDate(endTime);
|
||||
|
||||
if (startPrie != null) {
|
||||
query.setStartPrice(startPrie);
|
||||
}
|
||||
if(endPrice != null){
|
||||
query.setEndPrice(endPrice);
|
||||
}
|
||||
if(StringUtils.isNotBlank(estateType)){
|
||||
query.setEstateType(estateType);
|
||||
}
|
||||
query.setPager(pager);
|
||||
query.setSortField("p_date");
|
||||
query.setOrder(false);
|
||||
query.setTable("latest_seawater");
|
||||
|
||||
return seawaterDao.findSeawatersByQuery(query);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param estateType 用户查询物业类型
|
||||
* @param startDate
|
||||
* @return
|
||||
*/
|
||||
private List<SampleWrapper> findByDistrict(District district, List<String> keys, List<String> names, Date startDate, Integer startPrice, Integer endPrice) {
|
||||
|
||||
//改为从ES 查房源
|
||||
ArrayList<String> districtNames = new ArrayList<String>();
|
||||
BooleanQuery nameQuery = new BooleanQuery();
|
||||
int c = 0;
|
||||
for (String namekey : keys) {
|
||||
if (StringUtils.isNotBlank(namekey)) {
|
||||
namekey = ClientUtils.escapeQueryChars(namekey);
|
||||
if (namekey.contains("_")) {
|
||||
districtNames.add(namekey.split("_")[0]);
|
||||
}
|
||||
c++;
|
||||
nameQuery.add(new TermQuery(new Term("districtname_key", namekey)), BooleanClause.Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
List<SampleWrapper> samples = new ArrayList<SampleWrapper>();
|
||||
List<SampleWrapper> nolianjiaSamples = new ArrayList<SampleWrapper>();
|
||||
|
||||
List<QueryParam> houseQuery = new ArrayList<QueryParam>();
|
||||
houseQuery.add(new QueryParam("city", district.getCity()));
|
||||
houseQuery.add(new QueryParam("region", district.getRegion()));
|
||||
SeawaterQuery seawaterQuery = new SeawaterQuery();
|
||||
if (startPrice!=null && startPrice>0) {
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startPrice));
|
||||
}
|
||||
if(endPrice!=null && endPrice>0){
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, endPrice));
|
||||
}
|
||||
|
||||
if (nameQuery.clauses().isEmpty()) {
|
||||
return samples;
|
||||
}
|
||||
BooleanQuery srQuery = new BooleanQuery();
|
||||
srQuery.add(nameQuery, BooleanClause.Occur.MUST);
|
||||
houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery)));
|
||||
if (startDate != null) {
|
||||
houseQuery.add(new QueryParam("publishDate", QueryParam.GREATER_THAN_OPERATOR, startDate));
|
||||
}
|
||||
|
||||
List<SortParam> houseSortParams = new ArrayList<SortParam>();
|
||||
houseSortParams.add(new SortParam("publishDate", false));
|
||||
|
||||
seawaterQuery.setCityDisplay(district.getCity());
|
||||
seawaterQuery.setDistrictAlias(names);
|
||||
seawaterQuery.setRegion(district.getRegion());
|
||||
seawaterQuery.setDistrictName(district.getName());
|
||||
|
||||
seawaterQuery.setSortField("p_date");
|
||||
seawaterQuery.setOrder(false);
|
||||
Pager pager = new Pager(0, 200);
|
||||
pager.setPageSize(200);
|
||||
seawaterQuery.setTable("latest_seawater");
|
||||
seawaterQuery.setPager(pager);
|
||||
seawaterQuery.setCat("sell");
|
||||
List<Seawater> seawaters = seawaterDao.findSeawatersByQuery(seawaterQuery);
|
||||
List<House> houses = CommonUtils.transformListV(House.class, seawaters);
|
||||
|
||||
int height = 0;
|
||||
int maxFloor = 0;
|
||||
boolean allSampleHasHeight = true;
|
||||
for (House house : houses) {
|
||||
if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().equals("普通住宅")) {//01:普通住宅 02:别墅
|
||||
if (StringUtils.isNotBlank(house.getEstateType()) && house.getEstateType().contains("别墅")) {
|
||||
continue;
|
||||
}
|
||||
if (isVilla(house.getArea(), house.getName(), house.getHeight(), house.getRoom())) {
|
||||
continue;
|
||||
}
|
||||
} else if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().equals("别墅")) {
|
||||
if (house.getHeight() != null && house.getHeight() >= 10) {
|
||||
continue;
|
||||
}
|
||||
if (house.getFloor() != null && house.getFloor() >= 10) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
SampleWrapper sample = null;//convertHouse2Sample(house);
|
||||
if (isAvailableSample(sample)) {
|
||||
if (house.getUrl().contains("lianjia.com") || house.getUrl().contains("ke.com")) {
|
||||
samples.add(sample);
|
||||
} else {
|
||||
nolianjiaSamples.add(sample);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断样本是否可用
|
||||
*
|
||||
* @param sample
|
||||
* @return
|
||||
*/
|
||||
private boolean isAvailableSample(SampleWrapper sample) {
|
||||
if (sample.getStrctureArea() > 500 || sample.getStrctureArea() < 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是别墅
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isVilla(Double area, String name, Integer height, Integer room) {
|
||||
if (area == null) {
|
||||
return false;
|
||||
}
|
||||
if (area >= 150 && StringUtils.indexOfAny(name, TAGS) > -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean ret = false;
|
||||
if (height != null && room != null) {
|
||||
if (height <= 3) {
|
||||
if (area > 200 && room >= 5) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
} else if (height == null && room != null) {
|
||||
if (area > 360 && room >= 6) {
|
||||
ret = true;
|
||||
}
|
||||
} else if (height == null && room == null) {
|
||||
if (area > 500) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setSeawaterDao(SeawaterDao seawaterDao) {
|
||||
this.seawaterDao = seawaterDao;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -197,9 +197,6 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
params.add(new QueryParam("city", evaluation.getCity()));
|
||||
params.add(new QueryParam("district", evaluation.getRegion()));
|
||||
params.add(new QueryParam("name", evaluation.getDistrictName()));
|
||||
// 获取上个月yyyyMM日期
|
||||
String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM");
|
||||
params.add(new QueryParam("date", Integer.parseInt(date)));
|
||||
|
||||
// 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
@@ -207,7 +204,15 @@ public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
// 第二步:基准价*楼层系数*装修系数*朝向系数
|
||||
OfficeRentStat officeRentStat = officeRentStatDao.findFirstByParams(params);
|
||||
Double avgPrice = officeRentStat.getAvgPrice();
|
||||
// if(officeRentStat == null){
|
||||
// // 获取上个月yyyyMM日期
|
||||
// String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -1), "yyyyMM");
|
||||
// params.add(new QueryParam("date", Integer.parseInt(date)));
|
||||
// }
|
||||
Double avgPrice = null;
|
||||
if(officeRentStat != null){
|
||||
avgPrice = officeRentStat.getAvgPrice();
|
||||
}
|
||||
if (avgPrice != null) {
|
||||
Double factor = 1.0;
|
||||
if (evaluation.getFitment() != null) {
|
||||
|
||||
+2
@@ -69,6 +69,8 @@ public interface DealPriceService {
|
||||
*/
|
||||
public List<DealPrice> findDealPrices(List<QueryParam> params, int max);
|
||||
|
||||
public List<DealPrice> findDealPrices(String id, int max, Integer startPrice, Integer endPrice, Date startDate, Date endDate);
|
||||
|
||||
public Integer findDealPrices(String city, String region, String districtName, Date startDate, Date endDate);
|
||||
|
||||
public List<DealPrice> findDealPriceList(String city, String region, String districtName, Date startDate,
|
||||
|
||||
+27
@@ -180,6 +180,33 @@ public class DealPriceServiceImpl implements DealPriceService {
|
||||
"tradeDate", "source", "room", "hall", "toilet", "height", "floor","direction" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DealPrice> findDealPrices(String id, int max, Integer startPrice, Integer endPrice, Date startDate, Date endDate) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, DateUtil.add(new Date(), -6)));
|
||||
params.add(new QueryParam("matchId", id));
|
||||
if(startPrice!=null && startPrice>0){
|
||||
params.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startPrice));
|
||||
}
|
||||
if(startPrice!=null && startPrice>0){
|
||||
params.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, endPrice));
|
||||
}
|
||||
|
||||
if(startDate!=null){
|
||||
params.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
|
||||
}
|
||||
if(endDate!=null){
|
||||
params.add(new QueryParam("tradeDate", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate));
|
||||
}
|
||||
|
||||
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("tradeDate", false));
|
||||
return dealPriceDao.findAllByParams(params, sortParams, 0, max,
|
||||
new String[] { "city", "region", "districtName", "avgPrice", "fitment", "area", "totalPrice",
|
||||
"tradeDate", "source", "room", "hall", "toilet", "height", "floor","direction" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findDealPrices(String city, String region, String districtName, Date startDate, Date endDate) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
|
||||
Reference in New Issue
Block a user