优化商铺返回与写字楼一致
This commit is contained in:
+40
-51
@@ -13,6 +13,7 @@ import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.mongo.model.ShopRentStat;
|
||||
import com.fangjia.dal.mongo.model.ShopSellStat;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seawater.model.SeawaterDto;
|
||||
import com.fangjia.service.datastore.dto.ShopEvaluationDto;
|
||||
import com.fangjia.service.mongo.fangjia.SeawaterService;
|
||||
import com.fangjia.service.util.GeoUtils;
|
||||
@@ -204,53 +205,23 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
return getShopEvaluationDto(seawaters, evaluation, cat);
|
||||
}
|
||||
|
||||
/**
|
||||
* 基准价*楼层系数*装修系数*朝向系数
|
||||
*
|
||||
* @param seawaters
|
||||
* @param evaluation
|
||||
* @return
|
||||
*/
|
||||
private static ShopEvaluationDto getShopEvaluationDtoWithFactor(List<Seawater> seawaters, Evaluation evaluation) {
|
||||
Double sum = 0.0;
|
||||
Double size = 0.0;
|
||||
|
||||
String fitment = FITMENT_MAP.get(evaluation.getFitment());
|
||||
String direction = DIRECTION_MAP.get(evaluation.getDirection());
|
||||
for (Seawater seawater : seawaters) {
|
||||
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
|
||||
Double price = Double.valueOf(seawater.getTotalPrice());
|
||||
// 装修
|
||||
if (seawater.getFitment() != null) {
|
||||
try {
|
||||
price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
// 朝向
|
||||
if (seawater.getDirection() != null) {
|
||||
try {
|
||||
price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sum += price;
|
||||
size += seawater.getArea();
|
||||
}
|
||||
private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) {
|
||||
SeawaterDto seawaterDto = new SeawaterDto();
|
||||
seawaterDto.setCity(seawater.getCity());
|
||||
seawaterDto.setDistrict(seawater.getRegion());
|
||||
seawaterDto.setName(seawater.getDistrictName());
|
||||
seawaterDto.setArea(seawater.getArea());
|
||||
seawaterDto.setFitment(seawater.getFitment());
|
||||
if (cat != null && cat.contains("rent")) {
|
||||
seawaterDto.setUnitPrice(seawater.getDayUnitPrice());
|
||||
} else {
|
||||
seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue());
|
||||
}
|
||||
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
|
||||
if (size > 0) {
|
||||
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
|
||||
shopEvaluationDto.setUnitPrice(unitPrice);
|
||||
shopEvaluationDto.setSeawater(seawaters);
|
||||
shopEvaluationDto.setCity(evaluation.getCity());
|
||||
shopEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
shopEvaluationDto.setName(evaluation.getDistrictName());
|
||||
}
|
||||
return shopEvaluationDto;
|
||||
seawaterDto.setEstateType(seawater.getEstateType());
|
||||
seawaterDto.setBedKind(seawater.getLevel());
|
||||
seawaterDto.setPublishDate(String.valueOf(seawater.getpDate()));
|
||||
seawaterDto.setFloorInfo(seawater.getFloorInfo());
|
||||
return seawaterDto;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,17 +237,20 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
|
||||
ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto();
|
||||
|
||||
List<SeawaterDto> seawaterList = new ArrayList<SeawaterDto>();
|
||||
if ("shop_rent".equals(cat)) {
|
||||
for (Seawater seawater : seawaters) {
|
||||
if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) {
|
||||
sum += seawater.getTotalPrice();
|
||||
size += seawater.getArea();
|
||||
}
|
||||
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
|
||||
seawaterList.add(seawaterDto);
|
||||
}
|
||||
if (size > 0) {
|
||||
Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2);
|
||||
shopEvaluationDto.setUnitPrice(unitPrice);
|
||||
shopEvaluationDto.setSeawater(seawaters);
|
||||
shopEvaluationDto.setSeawater(seawaterList);
|
||||
shopEvaluationDto.setCity(evaluation.getCity());
|
||||
shopEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
shopEvaluationDto.setName(evaluation.getDistrictName());
|
||||
@@ -287,11 +261,13 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
sum += seawater.getTotalPrice();
|
||||
size += seawater.getArea();
|
||||
}
|
||||
SeawaterDto seawaterDto = getSeawaterDto(seawater, cat);
|
||||
seawaterList.add(seawaterDto);
|
||||
}
|
||||
if (size > 0) {
|
||||
Double unitPrice = DataUtil.roundDouble(sum / size, 2);
|
||||
shopEvaluationDto.setUnitPrice(unitPrice);
|
||||
shopEvaluationDto.setSeawater(seawaters);
|
||||
shopEvaluationDto.setSeawater(seawaterList);
|
||||
shopEvaluationDto.setCity(evaluation.getCity());
|
||||
shopEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
shopEvaluationDto.setName(evaluation.getDistrictName());
|
||||
@@ -351,15 +327,24 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
List<Seawater> shops = seawaterService.findSeawatersByQuery(query);
|
||||
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
|
||||
if (CollectionUtils.isNotEmpty(shops)) {
|
||||
// 求均值
|
||||
Double totalPrice = 0D;
|
||||
int count = 0;
|
||||
for (Seawater seawater : shops) {
|
||||
if (seawater.getAvgPrice() != null) {
|
||||
totalPrice += seawater.getAvgPrice();
|
||||
totalPrice += seawater.getDayUnitPrice();
|
||||
count += 1;
|
||||
}
|
||||
SeawaterDto seawaterDto = new SeawaterDto();
|
||||
seawaterDto.setCity(seawater.getCity());
|
||||
seawaterDto.setDistrict(seawater.getDistrict());
|
||||
seawaterDto.setName(seawater.getName());
|
||||
seawaterDto.setUnitPrice(seawater.getDayUnitPrice());
|
||||
seawaterDto.setPublishDate(String.valueOf(seawater.getPublishDate()));
|
||||
seawaterDto.setEstateType(seawater.getEstateType());
|
||||
seawaterDtoList.add(seawaterDto);
|
||||
}
|
||||
Double factor = 1.0;
|
||||
if (evaluation.getFitment() != null) {
|
||||
@@ -370,7 +355,7 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
}
|
||||
Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2);
|
||||
shopEvaluationDto.setUnitPrice(avgPrice);
|
||||
shopEvaluationDto.setSeawater(shops);
|
||||
shopEvaluationDto.setSeawater(seawaterDtoList);
|
||||
shopEvaluationDto.setCity(evaluation.getCity());
|
||||
shopEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
shopEvaluationDto.setName(evaluation.getDistrictName());
|
||||
@@ -401,6 +386,8 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
List<Seawater> shops = seawaterService.findSeawatersByQuery(query);
|
||||
|
||||
List<SeawaterDto> seawaterDtoList = new ArrayList<SeawaterDto>();
|
||||
if (CollectionUtils.isNotEmpty(shops)) {
|
||||
// 求均值
|
||||
Double totalPrice = 0D;
|
||||
@@ -410,6 +397,8 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
totalPrice += seawater.getAvgPrice();
|
||||
count += 1;
|
||||
}
|
||||
SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_sell");
|
||||
seawaterDtoList.add(seawaterDto);
|
||||
}
|
||||
Double factor = 1.0;
|
||||
if (evaluation.getFitment() != null) {
|
||||
@@ -420,7 +409,7 @@ public class AiShopServiceImpl implements AiShopService {
|
||||
}
|
||||
int avgPrice = (int) (totalPrice / count * factor);
|
||||
shopEvaluationDto.setUnitPrice((double) avgPrice);
|
||||
shopEvaluationDto.setSeawater(shops);
|
||||
shopEvaluationDto.setSeawater(seawaterDtoList);
|
||||
shopEvaluationDto.setCity(evaluation.getCity());
|
||||
shopEvaluationDto.setDistrict(evaluation.getRegion());
|
||||
shopEvaluationDto.setName(evaluation.getDistrictName());
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.datastore.dto;
|
||||
|
||||
import com.fangjia.dal.mongo.model.Evaluation;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seawater.model.SeawaterDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ShopEvaluationDto extends Evaluation {
|
||||
|
||||
private Double unitPrice;
|
||||
|
||||
private List<Seawater> seawater;
|
||||
private List<SeawaterDto> seawater;
|
||||
|
||||
private String district;
|
||||
|
||||
@@ -28,11 +28,11 @@ public class ShopEvaluationDto extends Evaluation {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public List<Seawater> getSeawater() {
|
||||
public List<SeawaterDto> getSeawater() {
|
||||
return seawater;
|
||||
}
|
||||
|
||||
public void setSeawater(List<Seawater> seawater) {
|
||||
public void setSeawater(List<SeawaterDto> seawater) {
|
||||
this.seawater = seawater;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user