Browse Source

口估新加楼盘名称查询接口

wucl 3 months ago
parent
commit
267e9884b8

+ 30 - 8
biz-base/src/main/java/com/dayou/controller/PersonalFacePriceController.java

@@ -23,24 +23,46 @@ public class PersonalFacePriceController extends BaseController {
     private IPersonalFacePriceService personalFacePriceService;
 
     /**
-     * 查询大友个贷历史评估价格
+     * 查询大友个贷历史评估价格(地址)
      * @param facePriceQuery
      * @return
      */
-    @PostMapping("/dy/price")
-    public RestResponse<List<DayouPersonalPriceVO>> dayouPersonalPrice(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
-        List<DayouPersonalPriceVO> ret = personalFacePriceService.dayouPersonalPrice(facePriceQuery);
+    @PostMapping("/dy/location/price")
+    public RestResponse<List<DayouPersonalPriceVO>> personalPriceByLocation(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
+        List<DayouPersonalPriceVO> ret = personalFacePriceService.personalPriceByLocation(facePriceQuery);
         return RestResponse.success(ret);
     }
 
     /**
-     * 查询外部数据价格
+     * 查询大友个贷历史评估价格(小区名字)
      * @param facePriceQuery
      * @return
      */
-    @PostMapping("/external/price")
-    public RestResponse<ExternalFacePriceVO> externalPersonalPrice(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
-        ExternalFacePriceVO ret = personalFacePriceService.externalPersonalPrice(facePriceQuery);
+    @PostMapping("/dy/community/price")
+    public RestResponse<List<DayouPersonalPriceVO>> personalPriceByCommunity(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
+        List<DayouPersonalPriceVO> ret = personalFacePriceService.personalPriceByCommunity(facePriceQuery);
+        return RestResponse.success(ret);
+    }
+
+    /**
+     * 查询外部数据价格(地址)
+     * @param facePriceQuery
+     * @return
+     */
+    @PostMapping("/external/location/price")
+    public RestResponse<ExternalFacePriceVO> externalPriceByLocation(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
+        ExternalFacePriceVO ret = personalFacePriceService.externalPriceByLocation(facePriceQuery);
+        return RestResponse.success(ret);
+    }
+
+    /**
+     * 查询外部数据价格(小区名字)
+     * @param facePriceQuery
+     * @return
+     */
+    @PostMapping("/external/community/price")
+    public RestResponse<ExternalFacePriceVO> externalPersonalPriceByCommunity(@RequestBody PersonalFacePriceQueryDTO facePriceQuery) {
+        ExternalFacePriceVO ret = personalFacePriceService.externalPersonalPriceByCommunity(facePriceQuery);
         return RestResponse.success(ret);
     }
 }

+ 1 - 1
common/src/main/java/com/dayou/utils/AddressUtil.java

@@ -158,7 +158,7 @@ public class AddressUtil {
 
 
     public static void main(String[] args) {
-        String location = "四川省成都市锦江区四海逸家三期四海逸家三期2号楼2单元1101";
+        String location = "测试订单";
         //String location = "成都市天府新区万安镇麓山大道二段20号附9号麓山国际3栋2单元2层3号住宅";
         System.out.println(getRoadNumberAddress(location));
         AddressDTO addressDTO = AddressUtil.parseAddress(location);

+ 2 - 0
dao/src/main/java/com/dayou/mapper/PersonalFacePriceMapper.java

@@ -11,4 +11,6 @@ public interface PersonalFacePriceMapper {
     List<DayouPersonalPriceVO> queryByFuzzyAddress(@Param("address") String roadNumberAddress, @Param("valueTiming") Date startDate);
 
     List<String> queryCommunityNameByFuzzyAddress(@Param("address") String address);
+
+    List<DayouPersonalPriceVO> queryByFuzzyCommunityName(@Param("community")String community, @Param("valueTiming")Date valueTiming);
 }

+ 1 - 1
dao/src/main/resources/mapper/ItemMapper.xml

@@ -105,7 +105,7 @@
         FROM
         item i left join department d on i.department_id = d.id  left join dict_data dd1 on i.cate = dd1.id and dd1.deleted =0
         left join dict_data dd2 on i.business_source = dd2.id and dd2.deleted = 0 left join user u on u.id = i.user_id left join customer c on c.id = i.customer_id
-        LEFT JOIN order_fund ON order_fund.business_id = i.id AND order_fund.order_id = business_no AND order_fund.business_type = 'ITEM_BUSINESS' AND order_fund.deleted = 0
+        LEFT JOIN order_fund ON order_fund.business_id = i.id AND order_fund.order_id = oa_no AND order_fund.business_type = 'ITEM_BUSINESS' AND order_fund.deleted = 0
         where i.deleted = 0
     </sql>
 

+ 48 - 0
dao/src/main/resources/mapper/PersonalFacePriceMapper.xml

@@ -45,5 +45,53 @@
         where pe.communityName is not null
     </select>
 
+    <select id="queryByFuzzyCommunityName" resultType="com.dayou.vo.DayouPersonalPriceVO">
+        SELECT
+            * ,
+            '楼盘名匹配' as matching
+        FROM
+            (
+                SELECT
+                    target_id,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( location, '$.valueA' )) AS communityName,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( decoration, '$.valueA' )) AS decoration
+                FROM
+                    personal_example
+                WHERE
+                    JSON_EXTRACT( location, '$.valueA' ) LIKE concat( '%', #{community}, '%' )
+                  AND is_example = 0
+                  AND deleted = 0
+            ) pe
+                LEFT JOIN (
+                SELECT
+                    id AS targetId,
+                    personal_id,
+                    location,
+                    acreage,
+                    amount,
+                    price,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( entity_info, '$.atFloor' )) AS atFloor,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( entity_info, '$.allFloor' )) AS allFloor,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( entity_info, '$.buildingType' )) AS buildingType,
+                    JSON_UNQUOTE(
+                            JSON_EXTRACT( entity_info, '$.houseType' )) AS houseType
+                FROM
+                    personal_target
+                WHERE
+                    deleted = 0
+            ) pt ON pe.target_id = pt.targetId
+                LEFT JOIN ( SELECT id, DATE_FORMAT( created, '%Y-%m-%d' ) AS valueTiming, created FROM personal ) p ON p.id = pt.personal_id
+        WHERE
+            p.created &gt;= #{valueTiming} and pt.amount is not null
+        ORDER BY
+            p.created DESC
+            LIMIT 0,
+	10
+    </select>
 
 </mapper>

+ 2 - 2
domain/src/main/java/com/dayou/dto/PersonalFacePriceQueryDTO.java

@@ -11,8 +11,8 @@ public class PersonalFacePriceQueryDTO {
     /**
      * 口估地址
      */
-    @AbcValidate(required = true,message = "房屋坐落不能为空" , fun = Check.NotEmpty)
-    private String location;
+    @AbcValidate(required = true,message = "房屋坐落或小区名字不能为空" , fun = Check.NotEmpty)
+    private String queryTarget;
 
     /**
      * 时间范围

+ 18 - 4
service/src/main/java/com/dayou/service/IPersonalFacePriceService.java

@@ -9,16 +9,30 @@ import java.util.List;
 public interface IPersonalFacePriceService {
 
     /**
-     * 大友个贷评估价
+     * 大友个贷评估价 地址
      * @param facePriceQuery
      * @return
      */
-    List<DayouPersonalPriceVO> dayouPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery);
+    List<DayouPersonalPriceVO> personalPriceByLocation(PersonalFacePriceQueryDTO facePriceQuery);
 
     /**
-     * 外部数据价格
+     * 外部数据价格 地址
      * @param facePriceQuery
      * @return
      */
-    ExternalFacePriceVO externalPersonalPrice(PersonalFacePriceQueryDTO facePriceQuery);
+    ExternalFacePriceVO externalPriceByLocation(PersonalFacePriceQueryDTO facePriceQuery);
+
+    /**
+     * 大友个贷评估价 小区名字
+     * @param facePriceQuery
+     * @return
+     */
+    List<DayouPersonalPriceVO> personalPriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery);
+
+    /**
+     * 外部数据价格 小区名字
+     * @param facePriceQuery
+     * @return
+     */
+    ExternalFacePriceVO externalPersonalPriceByCommunity(PersonalFacePriceQueryDTO facePriceQuery);
 }

+ 87 - 60
service/src/main/java/com/dayou/service/impl/PersonalFacePriceServiceImpl.java

@@ -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;
     }
 }