租金估值

This commit is contained in:
2021-04-06 09:46:36 +08:00
parent 1196cee874
commit d007b5d658
20 changed files with 846 additions and 126 deletions
@@ -2408,17 +2408,7 @@ public class DistrictServiceImpl implements DistrictService {
}
}
}
for (District d : list) {
if (district.getName().equals(d.getName()) && district.getRegion().equals(d.getRegion())
&& district.getCity().equals(d.getCity())) {
continue;
}
if (d.getEstateType2() != null) {
if ("普通住宅".equals(district.getEstateType2())) {
ret.add(d);
}
}
}
if (ret.size() > limit) {
ret = ret.subList(0, limit);
}
@@ -80,6 +80,16 @@ public interface EvaluationService {
Evaluation evaluateWithPadding(Evaluation evaluation,Date weekend);
Evaluation evaluate(District district, Evaluation evaluation , Date weekend);
/**
* 根据条件对小区进行租金估价
* @param district
* @param evaluation
* @param weekend
* @return
*/
Evaluation evaluateRent(District district, Evaluation evaluation, Date weekend);
/**
* 友达评估
@@ -14,6 +14,8 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fangjia.dal.mongo.model.*;
import com.fangjia.service.district.SqmetreRentService;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -41,17 +43,6 @@ import com.fangjia.dal.mongo.dao.EvaluationDao;
import com.fangjia.dal.mongo.dao.EvaluationHistoryDao;
import com.fangjia.dal.mongo.dao.HouseLoudongDao;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiUserCfg;
import com.fangjia.dal.mongo.model.BusStation;
import com.fangjia.dal.mongo.model.DistrictAnalyData;
import com.fangjia.dal.mongo.model.DistrictSellStat;
import com.fangjia.dal.mongo.model.DistrictStat;
import com.fangjia.dal.mongo.model.DistrictStatRent;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.EvaluationHistory;
import com.fangjia.dal.mongo.model.HouseLoudong;
import com.fangjia.dal.mongo.model.RegionBlock;
import com.fangjia.dal.mongo.model.YdDealPrice;
import com.fangjia.dal.mongo.pds.model.HourseTypeStat;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.service.api.ApiUserCfgService;
@@ -96,6 +87,8 @@ public class EvaluationServiceImpl implements EvaluationService {
private DistrictSellStatService districtSellStatService;
private ApiUserCfgService apiUserCfgService;
private SqmetreRentService sqmetreRentService;
private final static Logger LOGGER = LoggerFactory.getLogger(EvaluationServiceImpl.class);
public static final Map<String, List<Double>> CREDIT_RATE_MAP = new HashMap<String, List<Double>>();
@@ -1030,6 +1023,31 @@ public class EvaluationServiceImpl implements EvaluationService {
return wrapEvaluation(district,evaluation,weekend,stat);
}
@Override
public Evaluation evaluateRent(District district, Evaluation evaluation, Date weekend) {
if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) {
evaluation.setFloor(null);
evaluation.setHeight(null);
}
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
if(sqmetreRent!=null){
long totalPrice = evaluationRateService.evaluationRent(sqmetreRent.getAvgPrice(), evaluation);
evaluation.setTotalPrice(((Number) (totalPrice)).intValue());
evaluation.setEvaluateWay(sqmetreRent.getSampleEnum());
evaluation.setCredit(sqmetreRent.getCredit());
}else{
evaluation.setTotalPrice(null);
}
if(weekend != null) {
evaluation.setWeekend(weekend);
}
return evaluation;
}
/**
* 友达评估接口
*/
@@ -1338,6 +1356,10 @@ public class EvaluationServiceImpl implements EvaluationService {
this.apiUserCfgService = apiUserCfgService;
}
public void setSqmetreRentService(SqmetreRentService sqmetreRentService) {
this.sqmetreRentService = sqmetreRentService;
}
@Override
public long findUserEvaluationCount(long userId, Date startDate, Date endDate, String source) {
List<QueryParam> params = new ArrayList<QueryParam>();
@@ -1782,7 +1804,7 @@ public class EvaluationServiceImpl implements EvaluationService {
* 封装价格
* @author yinjihuan
* @param dto
* @param model
* @param evaluation
*/
private void buildPrice(EvaluationBeforeLoanBean dto, Evaluation evaluation) {
// 获取房屋总价
@@ -1808,7 +1830,7 @@ public class EvaluationServiceImpl implements EvaluationService {
* 小区年涨幅
* @author yinjihuan
* @param dto
* @param model
* @param evaluation
*/
private void buildOneYearUpDownRange(EvaluationBeforeLoanBean dto, Evaluation evaluation) {
List<DistrictSellStat> districtsSellStats = districtSellStatService.getAllWithMonths(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName(), 12);
@@ -1824,7 +1846,7 @@ public class EvaluationServiceImpl implements EvaluationService {
* 上个月参考均价
* @author yinjihuan
* @param dto
* @param model
* @param evaluation
*/
private void buildTopMonthAvgPrice(EvaluationBeforeLoanBean dto, Evaluation evaluation) {
String topMonth = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -1), "yyyyMM");
@@ -1839,7 +1861,7 @@ public class EvaluationServiceImpl implements EvaluationService {
* 涨跌幅在城市排名
* @author yinjihuan
* @param dto
* @param key
* @param evaluation
*/
private void buildUpDownRangecityLevel(EvaluationBeforeLoanBean dto, Evaluation evaluation, DistrictAnalyData districtAnalyData) {
Double increaseRate = 0d;
@@ -1858,7 +1880,7 @@ public class EvaluationServiceImpl implements EvaluationService {
* 获得最近一期的小区均价
* @author yinjihuan
* @param dto
* @param model
* @param evaluation
*/
private void buildWeekAvgPrice(EvaluationBeforeLoanBean dto, Evaluation evaluation) {
DistrictStatBo bo = getNearestDistrictStat(new DistrictKey(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName()));
@@ -140,4 +140,13 @@ public interface DistrictStatRentService {
List<DistrictStatRent> findLatestDistrictStatRent(District district, int periodCount, int houseType);
Map<String, Object> getRentTrend(String city, String region, String name, Integer count);
}
@@ -898,6 +898,50 @@ public class DistrictStatRentServiceImpl implements DistrictStatRentService {
}
@Override
public Map<String, Object> getRentTrend(String city, String region, String name, Integer count) {
List<Date> dates = DateUtil.getLastDayBetweenDates(DateUtil.addMonthToDate(new Date(),count), new Date());
List<String> times = new ArrayList<String>();
for(Date date : dates){
times.add(org.apache.tools.ant.util.DateUtils.format(date, "yyyy-MM"));
}
List<DistrictStatRentBo> districtRents = findDistrictStatRentsByParams(city, region, name, null, dates.get(0), dates.get(dates.size()-1), null, null, null, null, true);
Map<String, Map<String, Integer>> distMap = null;
List<Integer> rooms = null;
if(null != districtRents){
distMap = new HashMap<String, Map<String, Integer>>();
rooms = new ArrayList<Integer>();
for(DistrictStatRentBo rent : districtRents){
DistrictStatRent distRent = rent.getDistrictStatRent();
if(null == distRent){
distRent = rent.getVillaDistrictStatRent();
}
Map<String, Integer> priceMap = distMap.get(distRent.getHouseType().toString());
if(null == priceMap){
rooms.add(distRent.getHouseType());
priceMap = new HashMap<String, Integer>();
distMap.put(distRent.getHouseType().toString(), priceMap);
}
priceMap.put(org.apache.tools.ant.util.DateUtils.format(distRent.getEndMonthDate(), "yyyy-MM"), distRent.getAvgPrice());
}
}
Map<String, Object> retMap = new HashMap<String, Object>();
if(rooms != null){
Collections.sort(rooms);
retMap.put("times", times);
retMap.put("distMap", distMap);
retMap.put("rooms", rooms);
}
return retMap;
}
private List<DistrictStatRent> doFindLatestDistrictStatRent(District district, int periodCount, int houseType){
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -4);
@@ -12,8 +12,13 @@ public interface SeawaterService {
List<Seawater> findSeawaters(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
Integer room, String root, String sort, boolean order, int start, int limit ,String[] keys);
List<Seawater> findSeawatersFromEs(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
Integer room, String root, String sort, boolean order, int start, int limit ,String[] keys,String table);
Integer room, String root, String sort, boolean order, int start, int limit ,String[] keys,String table);
List<Seawater> findSeawatersFromEs2(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit ,String[] keys,String table);
long findSeawatersCount(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
Integer room, String root);
@@ -64,7 +64,7 @@ public class SeawaterServiceImpl implements SeawaterService {
}
return sells;
}
private Seawater convertDBObjectToSeawater(DBObject dbo) {
Seawater seawater = new Seawater();
@@ -161,6 +161,9 @@ public class SeawaterServiceImpl implements SeawaterService {
return q;
}
@Deprecated
@Override
public List<Seawater> findAllSeawater(String category, String city, String name, String region,Integer room, String root, String sort, Integer startDate, Integer endDate,
@@ -209,6 +212,8 @@ public class SeawaterServiceImpl implements SeawaterService {
return seawaterDao.findSeawatersCountFromEs(category, city, region, name, alias, regionAlias, startDate, endDate, room, root,table);
}
@Override
public Seawater findByIdFromEs(String id,String table) {
return seawaterDao.findByIdFromEs(id,table);
@@ -218,10 +223,18 @@ public class SeawaterServiceImpl implements SeawaterService {
public List<Seawater> findSeawatersFromEs(String category, String city, String region, String name,
List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate, Integer room, String root,
String sort, boolean order, int start, int limit, String[] keys,String table) {
return seawaterDao.findSeawatersFromEs(category,city,region,name,alias,regionAlias,startDate,endDate,room,root,
sort,order,start,limit,keys,table);
return seawaterDao.findSeawatersFromEs(category,city,region,name,alias,regionAlias,startDate,endDate, null, null, null, null, room,root,
sort,order,start,limit,table);
}
@Override
public List<Seawater> findSeawatersFromEs2(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String[] keys, String table) {
return seawaterDao.findSeawatersFromEs(category,city,region,name,alias,regionAlias,startDate,endDate, startArea, endArea, startPrice, endPrice, room,root,
sort,order,start,limit,table);
}
}
@@ -23,6 +23,8 @@ public interface EvaluationRateService {
long evaluation(int districtAvgPrice, Evaluation evaluation);
long evaluation(int districtAvgPrice, FjtEvaluation evaluation);
long evaluationRent(double districtSqmetreRent, Evaluation evaluation);
long evaluation(int districtAvgPrice, Evaluation evaluation, boolean min);
long evalustionShop(int districtAvgPrice, Evaluation evaluation);
@@ -40,7 +42,7 @@ public interface EvaluationRateService {
/**
* 根据房源ID获得房源当前的估价价格,用于房源信息已经经过知识库匹配
*
* @param houseId
* @param house
* @return
*/
public long evaluation(House house);
@@ -515,6 +515,198 @@ public class EvaluationRateServiceImpl implements EvaluationRateService {
return evaluatePrice;
}
private long getEvaluationRatePrice(long evaluatePrice, Evaluation evaluation){
String type = "小区";
Map<String, Map<String, Float>> rateMap = getEvaluationRateMap();
Map<String, Float> map = rateMap.get(evaluation.getCity());
if(null == map){
map = rateMap.get("默认");
}
// 楼层系数
float houseFloorRate = 0;
// 房型
String roomHall = String.valueOf(evaluation.getRoom()) + "室" + String.valueOf(evaluation.getHall()) + "厅";
float chamberRate = getEvaluationRate(map, "房型", roomHall, type);
// 朝向系数
float directionRate = getEvaluationRate(map, "朝向", evaluation.getDirection(), type);
// 小区位置系数
float insideposRate = getEvaluationRate(map, "小区位置", evaluation.getInsidepos(), type);
// 景观情况系数
float sightRate = getEvaluationRate(map, "景观", evaluation.getSight(), type);
// 采光通风系数
float lightingVentilationRate = getEvaluationRate(map, "采光通风", evaluation.getLightingVentilation(), type);
// 噪音影响系数
float noiseRate = getEvaluationRate(map, "噪音", evaluation.getNoise(), type);
// 边套装置系数
float sidesetRate = getEvaluationRate(map, "边套", evaluation.getSideset(), type);
// 厌恶设施系数
float worryFacilityRate = getEvaluationRate(map, "厌恶设施", evaluation.getWorryFacility(), type);
// 车位系数
float carportRate = getEvaluationRate(map, "车位", evaluation.getCarport(), type);
// 装修系数
float fitmentRate = getEvaluationRate(map, "装修情况", evaluation.getFitment(), type);
//装修年限系数
String fitment = "";
if (null != evaluation.getFitmentAge()) {
if (evaluation.getFitmentAge() <= 3) {
fitment = evaluation.getFitmentAge() + "年";
} else if (4 == evaluation.getFitmentAge()) {
fitment = evaluation.getFitmentAge() + "年";
} else {
fitment = "4年以上";
}
}
float fitmentAgeRate = getEvaluationRate(map, "装修年限", fitment, type);
// 赠送花园
float gardenAreaRate = getEvaluationRate(map, "赠送面积因素", "花园", type);
// 赠送地下车库
float basementAreaRate = getEvaluationRate(map, "赠送面积因素", "地下室", type);
// 赠送露台
float outerAreaRate = getEvaluationRate(map, "赠送面积因素", "露台", type);
// 赠送阁楼
float atticAreaRate = getEvaluationRate(map, "赠送面积因素", "阁楼", type);
// 楼间距
float floorSpaceRate = getEvaluationRate(map, "楼间距", evaluation.getFloorSpace(), type);
// 政策因素
float policyRate = getPolicyRate(map);
String houseFloorRateType = null;
if (!StringUtils.contains(evaluation.getBuildType(), DistrictKindEnum.bieshu.getValue())) {// 不是别墅
if (null != evaluation.getHeight() && 0 != evaluation.getHeight() && null != evaluation.getFloor() && 0 != evaluation.getFloor()) {
houseFloorRateType = getHouseFloorRateType(evaluation.getHeight());
if("小高层".equals(houseFloorRateType) || "高层".equals(houseFloorRateType)){
if(evaluation.getFloor() == 1 || evaluation.getFloor() == 2){
houseFloorRate = getFloorRate(map, "小高层", evaluation.getFloor(), "小区");
}else if(evaluation.getFloor().compareTo(evaluation.getHeight()) == 0){
houseFloorRate = getFloorRate(map, "小高层", 17, "小区");
}else{
if(evaluation.getFloor() == 4){//4楼使用3楼的系数
houseFloorRate = 0.9545F + 0.108F * ((3 - 1)/(float) (evaluation.getHeight() - 1));
}else{
houseFloorRate = 0.9545F + 0.108F * ((evaluation.getFloor() - 1)/(float) (evaluation.getHeight() - 1));
}
}
if(evaluation.getFloor() == 14){
houseFloorRate *= 0.99F;
}
evaluatePrice = (long) (evaluatePrice * houseFloorRate);
}else{
houseFloorRate = getFloorRate(map, houseFloorRateType,(null != evaluation.getFloor() ? evaluation.getFloor() : 0), type);
if(houseFloorRateType.equals("多层")){
if(houseFloorRate > 0){
evaluatePrice = (long) (evaluatePrice * houseFloorRate);
}
}else{
double num;
int mid = evaluation.getHeight()/2;
if(evaluation.getHeight() == evaluation.getFloor()){
num = 1 + (evaluation.getFloor() - mid -1) * 0.004 -0.001;
}else{
if(evaluation.getFloor() < mid){
num = 1- (mid - evaluation.getFloor()) * 0.006;
}else{
num = 1 + (evaluation.getFloor() - mid) * 0.004;
}
}
evaluatePrice = (long) (evaluatePrice * num * houseFloorRate);
}
}
}
}
if (chamberRate > 0) {
evaluatePrice = (long) (evaluatePrice * chamberRate);
}
if (directionRate > 0) {
evaluatePrice = (long) (evaluatePrice * directionRate);
}
if (insideposRate > 0) {
evaluatePrice = (long) (evaluatePrice * insideposRate);
}
if (sightRate > 0) {
evaluatePrice = (long) (evaluatePrice * sightRate);
}
if (lightingVentilationRate > 0) {
evaluatePrice = (long) (evaluatePrice * lightingVentilationRate);
}
if (noiseRate > 0) {
evaluatePrice = (long) (evaluatePrice * noiseRate);
}
if (sidesetRate > 0) {
evaluatePrice = (long) (evaluatePrice * sidesetRate);
}
if (worryFacilityRate > 0) {
evaluatePrice = (long) (evaluatePrice * worryFacilityRate);
}
if (carportRate > 0) {
evaluatePrice = (long) (evaluatePrice * carportRate);
}
if(StringUtils.isNotBlank(evaluation.getSource()) && !evaluation.getSource().equals("api_property_evaluate_rent")){
if (null != evaluation.getFitmentAge() && evaluation.getFitmentAge() > 0 && null != evaluation.getFitmentCharge()
&& evaluation.getFitmentCharge() > 0) {
// 输入了装修年限和装修价格
evaluatePrice = (long) (evaluatePrice + evaluation.getFitmentCharge() * fitmentAgeRate);
}
}
if(fitmentRate > 0){
if(evaluatePrice > 10000000){
fitmentRate = (float) (fitmentRate + 0.01);
}
evaluatePrice = (long)(evaluatePrice * fitmentRate);
}
if (null != evaluation.getGardenArea() && evaluation.getGardenArea() > 0) {
evaluatePrice = (long) ((gardenAreaRate * evaluation.getGardenArea()/evaluation.getArea() + 1) * evaluatePrice);
}
if (null != evaluation.getBasementArea() && evaluation.getBasementArea() > 0) {
evaluatePrice = (long) ((basementAreaRate * evaluation.getBasementArea()/ evaluation.getArea() + 1) * evaluatePrice);
}
if (null != evaluation.getAtticArea() && evaluation.getAtticArea() > 0) {
evaluatePrice = (long) ((atticAreaRate * evaluation.getAtticArea()/ evaluation.getArea() + 1) * evaluatePrice);
}
if (null != evaluation.getTerraceArea() && evaluation.getTerraceArea() > 0) {
evaluatePrice = (long) ((outerAreaRate * evaluation.getTerraceArea()/ evaluation.getArea() + 1) * evaluatePrice);
}
if (floorSpaceRate > 0) {
evaluatePrice = (long) (floorSpaceRate * evaluatePrice);
}
if (policyRate > 0) {
evaluatePrice = (long) (policyRate * evaluatePrice);
}
if(evaluation.getCarportPrice() !=null){
evaluatePrice = (long)(evaluatePrice + evaluation.getCarportPrice().intValue());
}
return evaluatePrice;
}
@Override
public long evaluationRent(double districtSqmetreRent, Evaluation evaluation) {
if (districtSqmetreRent < 0 && evaluation != null) {
return 0;
}
long evaluatePrice = (long) (districtSqmetreRent * (null == evaluation.getArea() ? 0 : evaluation.getArea()));
evaluatePrice = getEvaluationRatePrice(evaluatePrice, evaluation);
return evaluatePrice;
}
/**
* 实现估价的功能
*