|
@@ -1,10 +1,9 @@
|
|
|
package com.dayou.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.dayou.dto.AddressDTO;
|
|
|
import com.dayou.dto.PersonalFacePriceQueryDTO;
|
|
|
-import com.dayou.enums.GlobalConfigEnum;
|
|
|
import com.dayou.mapper.PersonalFacePriceMapper;
|
|
|
import com.dayou.service.IExternalDyDataBaseService;
|
|
|
import com.dayou.service.IGlobalConfigService;
|
|
@@ -38,15 +37,18 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
private IGlobalConfigService globalConfigService;
|
|
|
|
|
|
@Override
|
|
|
- public List<DayouPersonalPriceVO> dayouPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
+ public List<DayouPersonalPriceVO> personalPriceByLocation(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
//获取配置的价值点范围
|
|
|
Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
//查询策略1:全地址查询
|
|
|
- String location = facePriceQuery.getLocation();
|
|
|
+ List<DayouPersonalPriceVO> byRoadNumberResult = new ArrayList<>();
|
|
|
+ String location = facePriceQuery.getQueryTarget();
|
|
|
AddressDTO targetAddress = AddressUtil.parseAddress(location);
|
|
|
String roadNumberAddress = AddressUtil.getRoadNumberAddress(location);
|
|
|
- List<DayouPersonalPriceVO> byRoadNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadNumberAddress,startDate);
|
|
|
- byRoadNumberResult.stream().forEach(x->x.setMatching("全地址匹配"));
|
|
|
+ if (StrUtil.isNotBlank(roadNumberAddress)) {
|
|
|
+ byRoadNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadNumberAddress,startDate);
|
|
|
+ byRoadNumberResult.stream().forEach(x->x.setMatching("全地址匹配"));
|
|
|
+ }
|
|
|
|
|
|
//查询策略2:路名路号查询
|
|
|
List<DayouPersonalPriceVO> byRoadNameNumberResult = new ArrayList<>();
|
|
@@ -54,9 +56,8 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
if (StrUtil.isNotBlank(roadAndRoadNumber)){
|
|
|
byRoadNameNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadAndRoadNumber,startDate);
|
|
|
filterByCityAndDistrict(byRoadNameNumberResult,targetAddress);
|
|
|
+ byRoadNameNumberResult.stream().forEach(x->x.setMatching("路名路号匹配"));
|
|
|
}
|
|
|
- byRoadNameNumberResult.stream().forEach(x->x.setMatching("路名路号匹配"));
|
|
|
-
|
|
|
|
|
|
//查询策略3:尝试用小区名字查询
|
|
|
List<DayouPersonalPriceVO> byCommunityNameResult = new ArrayList<>();
|
|
@@ -64,8 +65,9 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
if (StrUtil.isNotBlank(communityNameFromAddress)){
|
|
|
byCommunityNameResult = personalFacePriceMapper.queryByFuzzyAddress(communityNameFromAddress,startDate);
|
|
|
filterByCityAndDistrict(byCommunityNameResult,targetAddress);
|
|
|
+ byCommunityNameResult.stream().forEach(x->x.setMatching("楼盘名匹配"));
|
|
|
}
|
|
|
- byCommunityNameResult.stream().forEach(x->x.setMatching("小区名字匹配"));
|
|
|
+
|
|
|
|
|
|
|
|
|
//合并查询结果集
|
|
@@ -81,18 +83,24 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExternalFacePriceVO externalPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
+ public ExternalFacePriceVO externalPriceByLocation(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
|
|
|
Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
- String location = facePriceQuery.getLocation();
|
|
|
+ String location = facePriceQuery.getQueryTarget();
|
|
|
|
|
|
//获取全路名 查询小区名称
|
|
|
- String roadNumberAddress = AddressUtil.getRoadNumberAddress(location);
|
|
|
- List<String> communityName1 = personalFacePriceMapper.queryCommunityNameByFuzzyAddress(roadNumberAddress);
|
|
|
+ List<String> communityName1 = new ArrayList<>();
|
|
|
+ String roadNumberAddress = AddressUtil.getRoadNumberAddress(location);
|
|
|
+ if (StrUtil.isNotBlank(roadNumberAddress)){
|
|
|
+ communityName1 = personalFacePriceMapper.queryCommunityNameByFuzzyAddress(roadNumberAddress);
|
|
|
+ }
|
|
|
|
|
|
//获取路名路号
|
|
|
- String roadAndRoadNumber = AddressUtil.getRoadAndRoadNumber(location);
|
|
|
- List<String> communityName2 = personalFacePriceMapper.queryCommunityNameByFuzzyAddress(roadAndRoadNumber);
|
|
|
+ List<String> communityName2 = new ArrayList<>();
|
|
|
+ String roadAndRoadNumber = AddressUtil.getRoadAndRoadNumber(location);
|
|
|
+ if (StrUtil.isNotBlank(roadAndRoadNumber)){
|
|
|
+ communityName2 = personalFacePriceMapper.queryCommunityNameByFuzzyAddress(roadAndRoadNumber);
|
|
|
+ }
|
|
|
|
|
|
//获取小区名字 从地址中获取
|
|
|
String communityNameFromAddress = AddressUtil.getCommunityNameFromAddress(location);
|
|
@@ -104,47 +112,24 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
}
|
|
|
|
|
|
List<String> communityNames = communityName1.stream().distinct().collect(Collectors.toList());
|
|
|
+ return queryExternalDataByCommunityNames(communityNames,startDate);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- //成交价
|
|
|
- List<ExternalPersonalVO> qiYuDeal = externalDyDataBaseService.externalPriceQiYuDeal(communityNames,startDate);
|
|
|
- List<ExternalPersonalVO> lianJiaDeal = externalDyDataBaseService.externalPriceLianJiaDeal(communityNames, startDate);
|
|
|
-
|
|
|
- //挂牌价
|
|
|
- List<ExternalPersonalVO> qiYuUp = externalDyDataBaseService.externalPriceQiYuUp(communityNames, startDate);
|
|
|
-
|
|
|
- //时间修正参数、面价修正参数、综合修正参数
|
|
|
- String time = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_TIME_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_TIME_PARAM.getCode());
|
|
|
- String acreage = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_ACREAGE_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_ACREAGE_PARAM.getCode());
|
|
|
- String overall = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_OVERALL_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_OVERALL_PARAM.getCode());
|
|
|
-
|
|
|
- //修正成交价
|
|
|
- qiYuDeal.addAll(lianJiaDeal);
|
|
|
- List<BigDecimal> dealPrices = qiYuDeal.stream().map(ExternalPersonalVO::getPrice).collect(Collectors.toList());
|
|
|
- double reduce = dealPrices.stream().mapToDouble(BigDecimal::doubleValue).reduce(0, Double::sum);
|
|
|
- //成交价均值
|
|
|
- BigDecimal dealPrice = BigDecimal.valueOf(reduce).divide(BigDecimal.valueOf(qiYuDeal.size()==0?1:qiYuDeal.size()), 0, RoundingMode.HALF_UP);
|
|
|
- //修正
|
|
|
- BigDecimal xDealPrice = dealPrice.multiply(new BigDecimal(time)).multiply(new BigDecimal(acreage)).multiply(new BigDecimal(overall)).setScale(2, RoundingMode.HALF_UP);
|
|
|
-
|
|
|
- //修正挂牌价
|
|
|
- List<BigDecimal> upPrices = qiYuUp.stream().map(ExternalPersonalVO::getPrice).collect(Collectors.toList());
|
|
|
- double reduce2 = upPrices.stream().mapToDouble(BigDecimal::doubleValue).reduce(0, Double::sum);
|
|
|
- //成交价均值
|
|
|
- BigDecimal upPrice = BigDecimal.valueOf(reduce2).divide(BigDecimal.valueOf(upPrices.size()==0?1: upPrices.size()), 0, RoundingMode.HALF_UP);
|
|
|
- //修正
|
|
|
- BigDecimal xUplPrice = upPrice.multiply(new BigDecimal(time)).multiply(new BigDecimal(acreage)).multiply(new BigDecimal(overall)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
-
|
|
|
- ExternalFacePriceVO facePriceVO = new ExternalFacePriceVO();
|
|
|
- facePriceVO.setDealPrice(xDealPrice);
|
|
|
- facePriceVO.setUpPrice(xUplPrice);
|
|
|
- facePriceVO.setDeals(qiYuDeal);
|
|
|
- facePriceVO.setUps(qiYuUp);
|
|
|
- facePriceVO.setTimeParam(time);
|
|
|
- facePriceVO.setAcreageParam(acreage);
|
|
|
- facePriceVO.setOverAllParam(overall);
|
|
|
- facePriceVO.setDealAvgPrice(dealPrice);
|
|
|
- facePriceVO.setUpAvgPrice(upPrice);
|
|
|
- return facePriceVO;
|
|
|
+ @Override
|
|
|
+ public List<DayouPersonalPriceVO> personalPriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
+ Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
+ String community = facePriceQuery.getQueryTarget();
|
|
|
+ List<DayouPersonalPriceVO> result = personalFacePriceMapper.queryByFuzzyCommunityName(community,startDate);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExternalFacePriceVO externalPersonalPriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
+ Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
+ String communityName = facePriceQuery.getQueryTarget();
|
|
|
+ List<String> communityNames = Collections.singletonList(communityName);
|
|
|
+ return queryExternalDataByCommunityNames(communityNames,startDate);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -173,14 +158,56 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 根据小区名字在个贷评估历史中查询小区名字
|
|
|
- * @param address
|
|
|
+ * 用楼盘名称查询外部数据
|
|
|
+ * @param communityNames
|
|
|
+ * @param startDate
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getCommunityNameByAddress(String address){
|
|
|
- String roadNumberAddress = AddressUtil.getRoadNumberAddress(address);
|
|
|
- // personalFacePriceMapper.queryCommuintyName(roadNumberAddress);
|
|
|
+ private ExternalFacePriceVO queryExternalDataByCommunityNames(List<String> communityNames, Date startDate){
|
|
|
+ if (CollectionUtil.isNotEmpty(communityNames)){
|
|
|
+ //成交价
|
|
|
+ List<ExternalPersonalVO> qiYuDeal = externalDyDataBaseService.externalPriceQiYuDeal(communityNames,startDate);
|
|
|
+ List<ExternalPersonalVO> lianJiaDeal = externalDyDataBaseService.externalPriceLianJiaDeal(communityNames, startDate);
|
|
|
+
|
|
|
+ //挂牌价
|
|
|
+ List<ExternalPersonalVO> qiYuUp = externalDyDataBaseService.externalPriceQiYuUp(communityNames, startDate);
|
|
|
+
|
|
|
+ //时间修正参数、面价修正参数、综合修正参数
|
|
|
+ String time = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_TIME_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_TIME_PARAM.getCode());
|
|
|
+ String acreage = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_ACREAGE_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_ACREAGE_PARAM.getCode());
|
|
|
+ String overall = StrUtil.isBlank(globalConfigService.getValue(SYS.getCode(), FACE_PRICE_OVERALL_PARAM.getCode()))?"1":globalConfigService.getValue(SYS.getCode(), FACE_PRICE_OVERALL_PARAM.getCode());
|
|
|
+
|
|
|
+ //修正成交价
|
|
|
+ qiYuDeal.addAll(lianJiaDeal);
|
|
|
+ List<BigDecimal> dealPrices = qiYuDeal.stream().map(ExternalPersonalVO::getPrice).collect(Collectors.toList());
|
|
|
+ double reduce = dealPrices.stream().mapToDouble(BigDecimal::doubleValue).reduce(0, Double::sum);
|
|
|
+ //成交价均值
|
|
|
+ BigDecimal dealPrice = BigDecimal.valueOf(reduce).divide(BigDecimal.valueOf(qiYuDeal.size()==0?1:qiYuDeal.size()), 0, RoundingMode.HALF_UP);
|
|
|
+ //修正
|
|
|
+ BigDecimal xDealPrice = dealPrice.multiply(new BigDecimal(time)).multiply(new BigDecimal(acreage)).multiply(new BigDecimal(overall)).setScale(2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ //修正挂牌价
|
|
|
+ List<BigDecimal> upPrices = qiYuUp.stream().map(ExternalPersonalVO::getPrice).collect(Collectors.toList());
|
|
|
+ double reduce2 = upPrices.stream().mapToDouble(BigDecimal::doubleValue).reduce(0, Double::sum);
|
|
|
+ //成交价均值
|
|
|
+ BigDecimal upPrice = BigDecimal.valueOf(reduce2).divide(BigDecimal.valueOf(upPrices.size()==0?1: upPrices.size()), 0, RoundingMode.HALF_UP);
|
|
|
+ //修正
|
|
|
+ BigDecimal xUplPrice = upPrice.multiply(new BigDecimal(time)).multiply(new BigDecimal(acreage)).multiply(new BigDecimal(overall)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ ExternalFacePriceVO facePriceVO = new ExternalFacePriceVO();
|
|
|
+ facePriceVO.setDealPrice(xDealPrice);
|
|
|
+ facePriceVO.setUpPrice(xUplPrice);
|
|
|
+ facePriceVO.setDeals(qiYuDeal);
|
|
|
+ facePriceVO.setUps(qiYuUp);
|
|
|
+ facePriceVO.setTimeParam(time);
|
|
|
+ facePriceVO.setAcreageParam(acreage);
|
|
|
+ facePriceVO.setOverAllParam(overall);
|
|
|
+ facePriceVO.setDealAvgPrice(dealPrice);
|
|
|
+ facePriceVO.setUpAvgPrice(upPrice);
|
|
|
+ return facePriceVO;
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
}
|