|
@@ -1,28 +1,32 @@
|
|
|
package com.dayou.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayou.dto.AddressDTO;
|
|
|
+import com.dayou.dto.PersonalFacePriceBatchDTO;
|
|
|
import com.dayou.dto.PersonalFacePriceQueryDTO;
|
|
|
import com.dayou.entity.PersonalFacePrice;
|
|
|
+import com.dayou.exception.ErrorCode;
|
|
|
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.utils.LoginContext;
|
|
|
+import com.dayou.utils.*;
|
|
|
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 org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -53,8 +57,8 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
AddressDTO targetAddress = AddressUtil.parseAddress(location);
|
|
|
String roadNumberAddress = AddressUtil.getRoadNumberAddress(location);
|
|
|
if (StrUtil.isNotBlank(roadNumberAddress)) {
|
|
|
- byRoadNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadNumberAddress,startDate);
|
|
|
- facePricesByRoadNumber = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate);
|
|
|
+ byRoadNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadNumberAddress,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
+ facePricesByRoadNumber = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
facePricesByRoadNumber.stream().forEach(x->x.setMatching("全地址匹配(口估)"));
|
|
|
byRoadNumberResult.stream().forEach(x->x.setMatching("全地址匹配"));
|
|
|
}
|
|
@@ -64,9 +68,9 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
List<DayouPersonalPriceVO> facePricesByRoadNameNumber = new ArrayList<>();
|
|
|
String roadAndRoadNumber = AddressUtil.getRoadAndRoadNumber(location);
|
|
|
if (StrUtil.isNotBlank(roadAndRoadNumber)){
|
|
|
- byRoadNameNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadAndRoadNumber,startDate);
|
|
|
+ byRoadNameNumberResult = personalFacePriceMapper.queryByFuzzyAddress(roadAndRoadNumber,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
filterByCityAndDistrict(byRoadNameNumberResult,targetAddress);
|
|
|
- facePricesByRoadNameNumber = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate);
|
|
|
+ facePricesByRoadNameNumber = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
facePricesByRoadNameNumber.stream().forEach(x->x.setMatching("路名路号匹配(口估)"));
|
|
|
byRoadNameNumberResult.stream().forEach(x->x.setMatching("路名路号匹配"));
|
|
|
}
|
|
@@ -76,8 +80,8 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
List<DayouPersonalPriceVO> facePriceByCommunity = new ArrayList<>();
|
|
|
String communityNameFromAddress = AddressUtil.getCommunityNameFromAddress(location);
|
|
|
if (StrUtil.isNotBlank(communityNameFromAddress)){
|
|
|
- byCommunityNameResult = personalFacePriceMapper.queryByFuzzyAddress(communityNameFromAddress,startDate);
|
|
|
- facePriceByCommunity = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate);
|
|
|
+ byCommunityNameResult = personalFacePriceMapper.queryByFuzzyAddress(communityNameFromAddress,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
+ facePriceByCommunity = personalFacePriceMapper.queryFromFacePriceHis(roadNumberAddress,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
filterByCityAndDistrict(byCommunityNameResult,targetAddress);
|
|
|
byCommunityNameResult.stream().forEach(x->x.setMatching("楼盘名匹配"));
|
|
|
facePriceByCommunity.stream().forEach(x->x.setMatching("楼盘名匹配(口估)"));
|
|
@@ -135,7 +139,7 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
}
|
|
|
|
|
|
List<String> communityNames = communityName1.stream().distinct().collect(Collectors.toList());
|
|
|
- return queryExternalDataByCommunityNames(communityNames,startDate);
|
|
|
+ return queryExternalDataByCommunityNames(communityNames,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -144,7 +148,7 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
String community = facePriceQuery.getQueryTarget();
|
|
|
List<DayouPersonalPriceVO> result = personalFacePriceMapper.queryByFuzzyCommunityName(community,startDate);
|
|
|
- List<DayouPersonalPriceVO> facePrices = personalFacePriceMapper.queryFromFacePriceHis(community, startDate);
|
|
|
+ List<DayouPersonalPriceVO> facePrices = personalFacePriceMapper.queryFromFacePriceHis(community, startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
facePrices.forEach(x->{
|
|
|
x.setMatching("楼盘名(口估)");
|
|
|
x.setCommunityName(x.getLocation());
|
|
@@ -160,7 +164,7 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
Date startDate = DateUtils.facePriceLimitDate(facePriceQuery.getLimit());
|
|
|
String communityName = facePriceQuery.getQueryTarget();
|
|
|
List<String> communityNames = Collections.singletonList(communityName);
|
|
|
- return queryExternalDataByCommunityNames(communityNames,startDate);
|
|
|
+ return queryExternalDataByCommunityNames(communityNames,startDate,facePriceQuery.getAcreageMin(),facePriceQuery.getAcreageMax());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -178,6 +182,61 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BigDecimal querySysFacePrice(PersonalFacePriceQueryDTO facePriceQuery) {
|
|
|
+ //定义面积区间跨度
|
|
|
+ BigDecimal diff = new BigDecimal(10);
|
|
|
+ BigDecimal acreage = facePriceQuery.getAcreage();
|
|
|
+ if (acreage != null){
|
|
|
+ facePriceQuery.setAcreageMax(acreage.add(diff));
|
|
|
+ facePriceQuery.setAcreageMin(acreage.subtract(diff));
|
|
|
+ }
|
|
|
+
|
|
|
+ facePriceQuery.setLimit("一年内");
|
|
|
+
|
|
|
+ //获取数据源集合
|
|
|
+ List<DayouPersonalPriceVO> dyPrices = this.personalPriceByLocation(facePriceQuery);
|
|
|
+ ExternalFacePriceVO externalFacePriceVO = this.externalPriceByLocation(facePriceQuery);
|
|
|
+ BigDecimal dealAvgPrice = BigDecimal.ZERO;
|
|
|
+ BigDecimal dyAvgPrice = BigDecimal.ZERO;
|
|
|
+ int i = 0;
|
|
|
+ if (externalFacePriceVO != null){
|
|
|
+ //链家成交均价
|
|
|
+ dealAvgPrice = externalFacePriceVO.getDealPrice();
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(dyPrices)){
|
|
|
+ //大友评估均价
|
|
|
+ double reduce = dyPrices.stream().filter(x->x.getPrice()!=null).map(DayouPersonalPriceVO::getPrice).mapToDouble(BigDecimal::doubleValue).reduce(0, Double::sum);
|
|
|
+ dyAvgPrice = BigDecimal.valueOf(reduce).divide(BigDecimal.valueOf(dyPrices.size()==0?1:dyPrices.size()), 0, RoundingMode.HALF_UP);
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //综合均价
|
|
|
+ return i==0?BigDecimal.ZERO:dealAvgPrice.add(dyAvgPrice).divide(new BigDecimal(i), RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String uploadPersonalFacePriceTemp(MultipartFile file) {
|
|
|
+ try {
|
|
|
+ List<PersonalFacePriceBatchDTO> batchQuery = ExcelUtil.importExcel(PersonalFacePriceBatchDTO.class,file.getInputStream(),1);
|
|
|
+ for (PersonalFacePriceBatchDTO batch : batchQuery) {
|
|
|
+ PersonalFacePriceQueryDTO target = new PersonalFacePriceQueryDTO();
|
|
|
+ BeanUtil.copyProperties(batch, target);
|
|
|
+ batch.setPrice(this.querySysFacePrice(target));
|
|
|
+ batch.setAmount(batch.getPrice().multiply(batch.getAcreage()==null?BigDecimal.ZERO:batch.getAcreage()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ batch.setValueTiming(LocalDate.now());
|
|
|
+ }
|
|
|
+ ExcelPlusUtil<PersonalFacePriceBatchDTO> util = new ExcelPlusUtil<PersonalFacePriceBatchDTO>(PersonalFacePriceBatchDTO.class);
|
|
|
+ String url = util.exportExcel2File(batchQuery, "批量询价结果");
|
|
|
+ return url;
|
|
|
+ } catch (IOException e) {
|
|
|
+ ErrorCode.throwBusinessException(ErrorCode.DEFAULTERROR);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 移除路名相同,但行政区域不同的元素
|
|
@@ -211,10 +270,10 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
|
|
|
* @param startDate
|
|
|
* @return
|
|
|
*/
|
|
|
- private ExternalFacePriceVO queryExternalDataByCommunityNames(List<String> communityNames, Date startDate){
|
|
|
+ private ExternalFacePriceVO queryExternalDataByCommunityNames(List<String> communityNames, Date startDate, BigDecimal acreageMin,BigDecimal acreageMax){
|
|
|
if (CollectionUtil.isNotEmpty(communityNames)){
|
|
|
//成交价
|
|
|
- List<ExternalPersonalVO> lianJiaDeal = externalDyDataBaseService.externalPriceLianJiaDeal(communityNames, startDate);
|
|
|
+ List<ExternalPersonalVO> lianJiaDeal = externalDyDataBaseService.externalPriceLianJiaDeal(communityNames, startDate,acreageMin,acreageMax);
|
|
|
//List<ExternalPersonalVO> qiYuDeal = externalDyDataBaseService.externalPriceQiYuDeal(communityNames,startDate);
|
|
|
//挂牌价
|
|
|
List<ExternalPersonalVO> qiYuUp = externalDyDataBaseService.externalPriceQiYuUp(communityNames, startDate);
|