Commit a03ccfa5 by 林永健

feat(analysis): 支持趋势数据的预估值计算和屏蔽门店过滤

- 在趋势数据接口中新增预估趋势功能,基于起始时间和产值进行计算
- 新增请求参数isPredictTrend用于控制是否启用趋势预估
- 查询门店权限时支持屏蔽配置的门店ID,过滤结果中排除屏蔽门店
- 业务层、RPC接口和请求响应类中新增对应字段支持过滤和预估功能
- 修改时间参数类型及范围,保证查询的准确性和完整性
- 数据查询层增加对屏蔽门店的排除处理,确保数据准确性
- 区域分布响应添加商户ID列表,支持前端更丰富展示
- 修正多个渗透率指标代码映射,保持指标一致性
- 代码中增加日志记录屏蔽门店过滤后的门店列表,方便问题定位
1 parent 0b53dc0e
...@@ -25,6 +25,7 @@ public class SalePotentialCustomersReq implements Serializable { ...@@ -25,6 +25,7 @@ public class SalePotentialCustomersReq implements Serializable {
*/ */
@ApiModelProperty(notes = "关联商户id ") @ApiModelProperty(notes = "关联商户id ")
private List<Integer> merchantIds; private List<Integer> merchantIds;
private List<Integer> excludeMerchantIds;
/** /**
* 是否绑定 0-否 1-是 * 是否绑定 0-否 1-是
......
...@@ -87,6 +87,9 @@ public class SceneBaseReq implements Serializable { ...@@ -87,6 +87,9 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "是否查询达成率趋势") @ApiModelProperty(notes = "是否查询达成率趋势")
private boolean withTargetRatio; private boolean withTargetRatio;
@ApiModelProperty(notes = "是否预估趋势")
private boolean isPredictTrend;
@ApiModelProperty(notes = "查询类型") @ApiModelProperty(notes = "查询类型")
private int queryType; private int queryType;
......
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@ApiModel(description = "区域分布响应") @ApiModel(description = "区域分布响应")
...@@ -25,4 +26,6 @@ public class RegionalDistributionResponse implements Serializable { ...@@ -25,4 +26,6 @@ public class RegionalDistributionResponse implements Serializable {
@ApiModelProperty(notes = "新车交付数总和") @ApiModelProperty(notes = "新车交付数总和")
private BigDecimal deliveryCount; private BigDecimal deliveryCount;
private List<Integer> merchantIds;
} }
...@@ -34,4 +34,7 @@ public class TrendOutputResponse implements Serializable { ...@@ -34,4 +34,7 @@ public class TrendOutputResponse implements Serializable {
@ApiModelProperty(notes = "达成率") @ApiModelProperty(notes = "达成率")
private BigDecimal ratio; private BigDecimal ratio;
@ApiModelProperty(notes = "预估值")
private BigDecimal predictValue = BigDecimal.ZERO;
} }
...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date;
import java.util.List; import java.util.List;
@Mapper @Mapper
...@@ -15,7 +16,7 @@ public interface GoodsOrderMapper extends OreMapper<GoodsOrder> { ...@@ -15,7 +16,7 @@ public interface GoodsOrderMapper extends OreMapper<GoodsOrder> {
List<TrafficContributionRankResponse> findTrafficRank( List<TrafficContributionRankResponse> findTrafficRank(
@Param("merchantIds") List<Integer> merchantIds, @Param("merchantIds") List<Integer> merchantIds,
@Param("staffUuids") List<String> staffUuids, @Param("staffUuids") List<String> staffUuids,
@Param("startDate") String startDate, @Param("startDate") Date startDate,
@Param("endDate") String endDate, @Param("endDate") Date endDate,
@Param("scene") Integer sceneType); @Param("scene") Integer sceneType);
} }
\ No newline at end of file \ No newline at end of file
...@@ -95,6 +95,12 @@ ...@@ -95,6 +95,12 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="excludeMerchantIds != null and excludeMerchantIds.size() > 0">
and spc.merchant_id not in
<foreach item="item" collection="excludeMerchantIds" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="isBind != null"> <if test="isBind != null">
and spc.is_bind = #{isBind} and spc.is_bind = #{isBind}
</if> </if>
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. SalePotentialCustomersReq 类

    • 问题: 新增的 excludeMerchantIds 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    2. SceneBaseReq 类

    • 问题: 新增的 isPredictTrend 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    3. RegionalDistributionResponse 类

    • 问题: 新增的 merchantIds 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    4. TrendOutputResponse 类

    • 问题: 新增的 predictValue 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    5. BusinessSceneAnalysisService 类

    • 问题: 在 getMerchantIdPermission 方法调用后,过滤门店逻辑存在错误。 java if (CollectionUtils.isNotEmpty(req.getExcludeIds())) { merchantIds = merchantIds.stream().filter(p -> req.getExcludeIds().contains(p)).collect(Collectors.toList()); log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds); } 这里的逻辑应该是排除 excludeIds 中的门店 ID,而不是包含它们。
    • 影响: 导致实际逻辑与预期不符,可能会返回错误的结果。
    • 建议: 修改为排除 excludeIds 中的门店 ID。 java if (CollectionUtils.isNotEmpty(req.getExcludeIds())) { merchantIds = merchantIds.stream().filter(p -> !req.getExcludeIds().contains(p)).collect(Collectors.toList()); log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds); }

    6. BusinessSceneAnalysisService 类

    • 问题: 在 touchRateSummary 方法中,捕获异常后直接返回空列表,可能隐藏潜在问题。 java try { merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false); } catch (Exception e){ return res; }
    • 影响: 异常信息被忽略,难以排查问题。
    • 建议: 增加日志记录异常信息,以便于后续排查问题。 java try { merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false); } catch (Exception e){ log.error("获取商户ID权限时发生异常", e); return res; }

    7. BusinessSceneAnalysisService 类

    • 问题: 在 storeList 方法中,调用 getMerchantIdPermission 方法时缺少参数。 java try { req.setMerchantIds(getMerchantIdPermission(req)); } catch (Exception e){ return Collections.emptyList(); }
    • 影响: 可能导致方法调用错误。
    • 建议: 确保传递正确的参数。 java try { req.setMerchantIds(getMerchantIdPermission(req, false)); } catch (Exception e){ return Collections.emptyList(); }

    8. BusinessSceneAnalysisService 类

    • 问题: 在 dailyReportCompletionRate 计算中,直接使用 dataResp.getContent().size() 来计算日报完成率,未验证数据的有效性。 java int reportCount = dataResp.getContent().size();
    • 影响: 如果 dataResp.getContent() 中的数据不符合预期,可能导致计算错误。
    • 建议: 增加数据有效性验证。 java if (CollectionUtils.isEmpty(dataResp.getContent())) { log.error("日报完成率查询失败,参数:{}", queryParams); return res; // 或者返回默认值 } int reportCount = dataResp.getContent().size();

    9. 注释与文档

    • 问题: 部分代码缺少必要的注释,难以理解其功能和作用。
    • 影响: 影响代码可读性和可维护性。
    • 建议: 增加必要的注释,提高代码可读性。

    评分明细

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

      • 代码逻辑基本正确,但存在一些小错误和潜在问题。
      • 得分: 32分
    2. 安全性与潜在风险(30分):

      • 代码中未发现明显的安全漏洞。
      • 得分: 28分
    3. 是否符合最佳实践(20分):

      • 缺少部分 getter 和 setter 方法,影响代码的可访问性。
      • 注释不足,影响代码可读性。
      • 得分: 15分
    4. 性能与资源利用效率(5分):

      • 代码中未发现明显的性能问题。
      • 得分: 5分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息清晰,准确描述了变更内容。
      • 得分: 5分

    总分: 85分

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