Commit 831c0681 by 张富康

feat(bi): 增加二手车门店数据查询过滤和获取专营门店ID功能

- 业务智能mapper接口countUsedCarMerchants方法新增merchantIds参数支持门店过滤
- 新增getZyMerchantIds方法用于获取特定条件的专营门店ID列表
- 在XML映射文件中为countUsedCarMerchants添加merchantIds的SQL条件判断
- 在XML映射文件中新增getZyMerchantIds对应的SQL查询
- 更新单元测试调用countUsedCarMerchants方法,增加merchantIds参数传入
- 修改UsedCarDataStatsService中调用countUsedCarMerchants方法,传入merchantIds参数实现数据过滤
1 parent 0e170ad5
......@@ -126,7 +126,7 @@ public interface BusinessIntelligenceMapper {
/**
* 查询二手车开店数量
*/
List<TrendChartRes> countUsedCarMerchants(@Param("statDateList") List<Pair<String, String>> statDateList);
List<TrendChartRes> countUsedCarMerchants(@Param("statDateList") List<Pair<String, String>> statDateList, @Param("merchantIds") List<Integer> merchantIds);
List<Integer> getZyMerchantIds(@Param("property") String property);
}
\ No newline at end of file
......@@ -505,7 +505,7 @@ public class UsedCarDataStatsService {
} else {
// 总开单门店
// 查询bi业务表
List<TrendChartRes> trendChartList = businessIntelligenceMapper.countUsedCarMerchants(previousPeriodsIncludingCurrent);
List<TrendChartRes> trendChartList = businessIntelligenceMapper.countUsedCarMerchants(previousPeriodsIncludingCurrent, merchantIds);
trendChartList.forEach(item -> item.setDatePair(item.getDatePairInfo()));
// trendChartRes根据datePair分组
Map<Pair<String, String>, TrendChartRes> trendChartResMap = trendChartList.stream().collect(Collectors.toMap(TrendChartRes::getDatePair, item -> item));
......
......@@ -764,6 +764,12 @@
LEFT JOIN dj_smartcarlife.dj_car_life_service_merchant_bi m
ON m.stat_date BETWEEN p.start_date AND p.end_date
AND m.has_used_car = 1
<if test="merchantIds != null and merchantIds.size > 0">
AND m.merchant_id IN
<foreach item="item" index="index" collection="merchantIds" separator="," open="(" close=")">
#{item}
</foreach>
</if>
GROUP BY p.start_date, p.end_date
</select>
<select id="getZyMerchantIds" resultType="java.lang.Integer">
......
......@@ -22,7 +22,7 @@ public class BusinessIntelligenceMapperTest extends BaseServiceTest {
statDateList.add(new Pair<>("2025-05-01", "2025-07-01"));
statDateList.add(new Pair<>("2025-08-01", "2025-09-01"));
statDateList.add(new Pair<>("2025-10-01", "2025-12-01"));
List<TrendChartRes> trendChartRes = businessIntelligenceMapper.countUsedCarMerchants(statDateList);
List<TrendChartRes> trendChartRes = businessIntelligenceMapper.countUsedCarMerchants(statDateList, null);
trendChartRes.forEach(item -> item.setDatePair(item.getDatePair()));
trendChartRes.forEach(System.out::println);
System.out.println(trendChartRes);
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 新增参数未更新XML映射文件:

      • 问题描述:在BusinessIntelligenceMapper接口的countUsedCarMerchants方法中新增了merchantIds参数,但未在对应的XML映射文件中进行相应的SQL条件更新。
      • 影响:新增的参数不会对查询结果产生任何影响,可能导致预期的数据过滤功能失效。
      • 优化建议:需要在对应的XML映射文件中添加对merchantIds参数的SQL条件判断。
    2. 单元测试中的null值传递:

      • 问题描述:在BusinessIntelligenceMapperTest类的测试方法中,调用countUsedCarMerchants方法时传递了null值给merchantIds参数。
      • 影响:如果merchantIds参数在SQL查询中被不当处理,可能会导致查询失败或返回错误的结果。
      • 优化建议:在单元测试中传递一个实际的merchantIds列表来验证过滤功能的有效性。同时,考虑添加测试用例来验证merchantIds参数为null时的行为是否符合预期。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 评分:20分
      • 原因:新增的merchantIds参数未在XML映射文件中进行相应的SQL条件更新,导致功能不完整。单元测试中传递null值给merchantIds参数,可能无法验证过滤功能的有效性。
    2. 安全性与潜在风险(30分):

      • 评分:25分
      • 原因:代码中未发现明显的安全漏洞,但需要确保SQL查询语句的安全性,特别是在处理用户输入时。
    3. 是否符合最佳实践(20分):

      • 评分:18分
      • 原因:代码整体结构清晰,但缺少对新增参数的详细注释。单元测试中传递null值给merchantIds参数,未能全面验证功能。
    4. 性能与资源利用效率(5分):

      • 评分:5分
      • 原因:代码变更部分未涉及性能问题,但需要在实际运行中监控SQL查询性能,确保新增参数不会引入性能瓶颈。
    5. Commits信息的清晰性与准确性(5分):

      • 评分:4分
      • 原因:提交信息描述了主要变更内容,但可以更具体地描述merchantIds参数的作用及其对现有功能的影响。

    总分: 72分


    备注:请确保在XML映射文件中添加对merchantIds参数的SQL条件判断,并完善单元测试用例,以验证新增参数的功能有效性。

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!