浏览代码

个贷口估楼盘名称批量执行

wucl 1 周之前
父节点
当前提交
a23ee15036

+ 4 - 2
biz-base/src/main/java/com/dayou/controller/PersonalFacePriceController.java

@@ -117,12 +117,14 @@ public class PersonalFacePriceController extends BaseController {
 
     /**
      * 个贷批量口估上传
-     * @param file
+     * @param file 询价文件
+     * @param limit 范围
      * @return
+     * @throws IOException
      */
     @IgnoreAuth
     @PostMapping("/upload/temp")
-    public RestResponse<String> uploadPersonalFacePriceTemp(@RequestPart("file") MultipartFile file,@RequestParam("limit") String limit,HttpServletResponse response) throws IOException {
+    public RestResponse<String> uploadPersonalFacePriceTemp(@RequestPart("file") MultipartFile file,@RequestParam("limit") String limit) throws IOException {
         String url = personalFacePriceService.uploadPersonalFacePriceTemp(file,limit);
         return RestResponse.data(url);
     }

+ 15 - 1
service/src/main/java/com/dayou/service/IPersonalFacePriceService.java

@@ -53,7 +53,21 @@ public interface IPersonalFacePriceService extends IService<PersonalFacePrice> {
     IPage<PersonalFacePrice> getPage(Page page, PersonalFacePrice facePrice);
 
     /**
-     * 查询系统口估价(简单算术平均法)
+     * 通过地址查询系统口估价(简单算术平均法)
+     * @param facePriceQuery
+     * @return
+     */
+    BigDecimal querySysFacePriceByLocation(PersonalFacePriceQueryDTO facePriceQuery);
+
+    /**
+     * 通过楼盘名称查询系统口估价(简单算术平均法)
+     * @param facePriceQuery
+     * @return
+     */
+    BigDecimal querySysFacePriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery);
+
+    /**
+     * 兼容地址和楼盘查询系统口估价(简单算术平均法)
      * @param facePriceQuery
      * @return
      */

+ 105 - 1
service/src/main/java/com/dayou/service/impl/PersonalFacePriceServiceImpl.java

@@ -183,7 +183,7 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
     }
 
     @Override
-    public BigDecimal querySysFacePrice(PersonalFacePriceQueryDTO facePriceQuery) {
+    public BigDecimal querySysFacePriceByLocation(PersonalFacePriceQueryDTO facePriceQuery) {
         //定义面积区间跨度
         BigDecimal diff = new BigDecimal(10);
         BigDecimal acreage = facePriceQuery.getAcreage();
@@ -236,6 +236,110 @@ public class PersonalFacePriceServiceImpl extends ServiceImpl<PersonalFacePriceM
     }
 
     @Override
+    public BigDecimal querySysFacePriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery) {
+        //定义面积区间跨度
+        BigDecimal diff = new BigDecimal(10);
+        BigDecimal acreage = facePriceQuery.getAcreage();
+        if (acreage != null){
+            facePriceQuery.setAcreageMax(acreage.add(diff));
+            facePriceQuery.setAcreageMin(acreage.subtract(diff));
+        }
+
+
+        //获取数据源集合
+        List<DayouPersonalPriceVO> dyPrices = this.personalPriceByCommunity(facePriceQuery);
+        ExternalFacePriceVO externalFacePriceVO = this.externalPersonalPriceByCommunity(facePriceQuery);
+
+        //提升查询结果率
+        if (CollectionUtil.isEmpty(dyPrices)){
+            facePriceQuery.setAcreageMin(null);
+            facePriceQuery.setAcreageMax(null);
+            dyPrices = this.personalPriceByCommunity(facePriceQuery);
+        }
+
+        if (externalFacePriceVO==null){
+            facePriceQuery.setAcreageMin(null);
+            facePriceQuery.setAcreageMax(null);
+            externalFacePriceVO = this.externalPersonalPriceByCommunity(facePriceQuery);
+        }
+
+        BigDecimal dealAvgPrice = BigDecimal.ZERO;
+        BigDecimal dyAvgPrice = BigDecimal.ZERO;
+        int i = 0;
+        if (externalFacePriceVO != null){
+            //链家成交均价
+            dealAvgPrice = externalFacePriceVO.getDealPrice();
+            if (dealAvgPrice.compareTo(BigDecimal.ZERO) > 0){
+                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);
+            if (dyAvgPrice.compareTo(BigDecimal.ZERO) > 0){
+                i+=1;
+            }
+        }
+
+
+        //综合均价
+        return i==0?BigDecimal.ZERO:dealAvgPrice.add(dyAvgPrice).divide(new BigDecimal(i), RoundingMode.HALF_UP);
+
+    }
+
+    @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));
+        }
+
+
+        //获取数据源集合(先用地址查询)
+        List<DayouPersonalPriceVO> dyPrices = this.personalPriceByLocation(facePriceQuery);
+        ExternalFacePriceVO externalFacePriceVO = this.externalPriceByLocation(facePriceQuery);
+
+        //为空再用楼盘名称查
+        if (CollectionUtil.isEmpty(dyPrices)){
+            dyPrices = this.personalPriceByCommunity(facePriceQuery);
+        }
+
+        if (externalFacePriceVO==null){
+            externalFacePriceVO = this.externalPersonalPriceByCommunity(facePriceQuery);
+        }
+
+        BigDecimal dealAvgPrice = BigDecimal.ZERO;
+        BigDecimal dyAvgPrice = BigDecimal.ZERO;
+        int i = 0;
+        if (externalFacePriceVO != null){
+            //链家成交均价
+            dealAvgPrice = externalFacePriceVO.getDealPrice();
+            if (dealAvgPrice.compareTo(BigDecimal.ZERO) > 0){
+                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);
+            if (dyAvgPrice.compareTo(BigDecimal.ZERO) > 0){
+                i+=1;
+            }
+        }
+
+
+        //综合均价
+        return i==0?BigDecimal.ZERO:dealAvgPrice.add(dyAvgPrice).divide(new BigDecimal(i), RoundingMode.HALF_UP);
+
+    }
+
+    @Override
     public String uploadPersonalFacePriceTemp(MultipartFile file,String limit) {
         try {
             List<PersonalFacePriceBatchDTO> batchQuery = ExcelUtil.importExcel(PersonalFacePriceBatchDTO.class,file.getInputStream(),1);