|
@@ -4,19 +4,27 @@ 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;
|
|
|
import com.dayou.service.IPersonalFacePriceService;
|
|
|
import com.dayou.utils.AddressUtil;
|
|
|
import com.dayou.utils.DateUtils;
|
|
|
import com.dayou.vo.DayouPersonalPriceVO;
|
|
|
+import com.dayou.vo.ExternalFacePriceVO;
|
|
|
import com.dayou.vo.ExternalPersonalVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.dayou.enums.GlobalConfigEnum.SYS;
|
|
|
+import static com.dayou.enums.GlobalConfigEnum.Sys.*;
|
|
|
+
|
|
|
@Service
|
|
|
public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
|
|
@@ -26,10 +34,13 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
@Autowired
|
|
|
private IExternalDyDataBaseService externalDyDataBaseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGlobalConfigService globalConfigService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<DayouPersonalPriceVO> dayouPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
//获取配置的价值点范围
|
|
|
- Date startDate = DateUtils.addYears(new Date(),-1);
|
|
|
+ Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
//查询策略1:全地址查询
|
|
|
String location = facePriceQuery.getLocation();
|
|
|
AddressDTO targetAddress = AddressUtil.parseAddress(location);
|
|
@@ -70,12 +81,10 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DayouPersonalPriceVO> externalPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
- //获取配置的价值点范围
|
|
|
- Date startDate = DateUtils.addYears(new Date(),-1);
|
|
|
- String location = facePriceQuery.getLocation();
|
|
|
+ public ExternalFacePriceVO externalPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
|
|
|
- AddressDTO targetAddress = AddressUtil.parseAddress(location);
|
|
|
+ Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
+ String location = facePriceQuery.getLocation();
|
|
|
|
|
|
//获取全路名 查询小区名称
|
|
|
String roadNumberAddress = AddressUtil.getRoadNumberAddress(location);
|
|
@@ -95,8 +104,47 @@ public class PersonalFacePriceServiceImpl implements IPersonalFacePriceService {
|
|
|
}
|
|
|
|
|
|
List<String> communityNames = communityName1.stream().distinct().collect(Collectors.toList());
|
|
|
- List<ExternalPersonalVO> externalPersonalVOS = externalDyDataBaseService.externalPriceByCommunityName(communityNames);
|
|
|
- return null;
|
|
|
+
|
|
|
+ //成交价
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
|