Commit 79675a2e by 林永健

feat(business-scene): 新增项目组和预警类型过滤功能

- 在SceneBaseRequest中新增projectGroupId和warningType字段
- 实现按项目组和预警类型过滤门店的功能
- 添加isWarningCycle方法判断是否为周月周期
- 集成ProjectGroupRemote远程调用项目组服务
- 更新依赖版本strategy.api.version和pe-analysis.api.version至5.8.2-SNAPSHOT
- 移除原有的生态预警门店处理逻辑
- 使用新的预警结果落地数据替换旧的预警计算方式
1 parent 3f329613
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx.dj.peanalysis</groupId> <groupId>cn.com.glsx.dj.peanalysis</groupId>
<artifactId>rpc-dj-pe-analysis-api</artifactId> <artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.7.1-SNAPSHOT</version> <version>5.8.2-SNAPSHOT</version>
<name>rpc-dj-pe-analysis-api</name> <name>rpc-dj-pe-analysis-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.peanalysis.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.peanalysis.remote</deploy.scanPackage>
......
...@@ -138,6 +138,12 @@ public class SceneBaseReq implements Serializable { ...@@ -138,6 +138,12 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "生态预警门店 1.是 0.否") @ApiModelProperty(notes = "生态预警门店 1.是 0.否")
private Byte styjMerchantFlag; private Byte styjMerchantFlag;
@ApiModelProperty(notes = "项目组id")
private Integer projectGroupId;
@ApiModelProperty(notes = "预警类型")
private Integer warningType;
/** /**
* 转换指标参数 * 转换指标参数
*/ */
......
...@@ -91,8 +91,10 @@ public class StoreSceneSummaryResponse implements Serializable { ...@@ -91,8 +91,10 @@ public class StoreSceneSummaryResponse implements Serializable {
private List<Integer> bottomLineWarningStoreIds; private List<Integer> bottomLineWarningStoreIds;
@ApiModelProperty(notes = "生态指标预警门店数量") @ApiModelProperty(notes = "生态指标预警门店数量")
@Deprecated
private Integer ecosystemWarningStores; private Integer ecosystemWarningStores;
@ApiModelProperty(notes = "生态指标预警门店商户号") @ApiModelProperty(notes = "生态指标预警门店商户号")
@Deprecated
private List<Integer> ecosystemWarningStoreIds; private List<Integer> ecosystemWarningStoreIds;
} }
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<platform-merchants.api.version>5.5.1-SNAPSHOT</platform-merchants.api.version> <platform-merchants.api.version>5.5.1-SNAPSHOT</platform-merchants.api.version>
<smartcarlife.api.version>5.6.4-SNAPSHOT</smartcarlife.api.version> <smartcarlife.api.version>5.6.4-SNAPSHOT</smartcarlife.api.version>
<mindworkplate.api.version>5.7.0-SNAPSHOT</mindworkplate.api.version> <mindworkplate.api.version>5.7.0-SNAPSHOT</mindworkplate.api.version>
<pe-analysis.api.version>5.7.1-SNAPSHOT</pe-analysis.api.version> <pe-analysis.api.version>5.8.2-SNAPSHOT</pe-analysis.api.version>
<strategy.api.version>5.7.0-SNAPSHOT</strategy.api.version> <strategy.api.version>5.8.2-SNAPSHOT</strategy.api.version>
<supervisor.api.version>1.0.0-SNAPSHOT</supervisor.api.version> <supervisor.api.version>1.0.0-SNAPSHOT</supervisor.api.version>
<wechat.api.version>4.54.0-SNAPSHOT</wechat.api.version> <wechat.api.version>4.54.0-SNAPSHOT</wechat.api.version>
<entmicro.api.version>5.3.0-SNAPSHOT</entmicro.api.version> <entmicro.api.version>5.3.0-SNAPSHOT</entmicro.api.version>
......
package cn.com.glsx.dj.peanalysis.config; package cn.com.glsx.dj.peanalysis.config;
import cn.com.glsx.dj.strategy.remote.ProjectGroupRemote;
import cn.com.glsx.dj.smartcarlife.remote.MerchantOutputTargetConfigRemote; import cn.com.glsx.dj.smartcarlife.remote.MerchantOutputTargetConfigRemote;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -17,4 +18,9 @@ public class SmartCarLifeDubboConfig extends DubboConfig { ...@@ -17,4 +18,9 @@ public class SmartCarLifeDubboConfig extends DubboConfig {
public StaffInfoRemote staffInfoRemote(){ public StaffInfoRemote staffInfoRemote(){
return factory.builder(StaffInfoRemote.class).version("1.0.0").check(check).timeout(timeout).build(); return factory.builder(StaffInfoRemote.class).version("1.0.0").check(check).timeout(timeout).build();
} }
@Bean
public ProjectGroupRemote projectGroupRemote() {
return factory.builder(ProjectGroupRemote.class).version("1.0.0").check(check).timeout(timeout).build();
}
} }
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 违反重大安全规则:Dubbo Remote 接口已有请求参数变更

    • 问题描述:在 rpc-dj-pe-analysis-api 模块下的 SceneBaseReq.java 中,新增了 projectGroupId 和 warningType 字段。根据审查规则,Dubbo 服务提供者 Remote 接口中的已有请求参数变更被视为危险实现。
    • 影响分析:直接修改已被广泛引用的基础请求 DTO,在微服务架构中,如果消费端(Consumer)和提供端(Provider)未能严格同步发版,可能会引发反序列化异常(如 Hessian 序列化兼容性问题),导致线上 RPC 调用失败或丢失关键参数。
    • 优化建议:
      1. 评估该 DTO 的影响范围,确认所有调用该接口的 Consumer 是否能做到强同步发版。
      2. 推荐做法:如果业务允许,应尽量新增接口或通过扩展字段(如已有的 Map<String, Object> ext)传递非核心业务参数,避免直接修改核心基础基类参数。

    2. 集合操作存在潜在的 NullPointerException (NPE) 风险

    • 问题描述:在 BusinessSceneAnalysisService.java 的 findBackUpStores 和 getDelayWarningStore 方法中,直接将 Map.get() 的结果传递给其他方法。 java Map<Integer, List<Integer>> warnTypeStore = getWarnTypeStores(queryDTO); return excludeWhite(warnTypeStore.get(2), sceneBaseReq.getExcludeIds()); // warnTypeStore.get(2) 可能为 null
    • 影响分析:getWarnTypeStores 返回的 Map 中并不保证一定包含 Key 为 2 或 3 的数据。如果不存在,get() 会返回 null。如果下游的 excludeWhite 方法没有对入参做严格的判空处理,将直接引发 NPE,导致整个接口请求崩溃。
    • 优化建议:使用 getOrDefault 方法提供安全的默认空集合兜底。 java // 优化示例 List<Integer> stores = warnTypeStore.getOrDefault(2, Collections.emptyList()); return excludeWhite(stores, sceneBaseReq.getExcludeIds());

    3. 代码可维护性极差:存在大量被注释的废弃代码(Dead Code)

    • 问题描述:在 BusinessSceneAnalysisService.java 中,原有的生态预警逻辑(如 handleDelayWarningStore、handleLightChangeWarningStore 等数百行代码)被直接使用 // 注释掉,而不是被删除。
    • 影响分析:大段的注释代码会严重干扰代码阅读,降低代码的可维护性,且容易让后续接手的开发者产生困惑(不清楚这些代码是暂时屏蔽还是永久废弃)。
    • 优化建议:现代软件工程依赖 Git 等版本控制系统来追溯历史代码。对于确定已被新逻辑(预警结果落地数据)替代的旧逻辑代码,请直接删除。如果未来需要找回,可通过 Git Commit 历史查看。

    二、评分明细

    • 功能实现的正确性与健壮性(32/40分) 理由:整体业务逻辑(项目组与预警类型过滤)实现闭环,考虑了周期类型的判断。但扣分点在于 Map.get() 提取数据时未考虑 Key 不存在导致的 NPE 风险,健壮性存在瑕疵。

    • 安全性与潜在风险(20/30分) 理由:触发了“Dubbo服务提供者Remote接口中的已有请求参数变更视为危险实现”的红线规则。修改公共 API 层的 DTO 存在破坏 RPC 序列化向后兼容性的风险,需严格评估发版依赖。

    • 最佳实践与可维护性(12/20分) 理由:严重违反了“不要在代码库中遗留大量注释掉的废弃代码”的工程最佳实践。此外,getStoreWarnTypes 中的 Java 8 Stream 语法过于繁琐(使用了 collectingAndThen 配合 distinct),实际上可以直接使用 Collectors.toSet() 来简化去重逻辑。

    • 性能与资源利用(4/5分) 理由:性能表现基本合格。但在一次完整的业务请求链路中,可能会多次触发 buildWarningQueryDTO 并调用远程 RPC 接口 listWarningRecords。建议在当前请求的上下文(如 ThreadLocal 或方法内部局部变量)中对 RPC 结果进行适当复用,以减少不必要的网络开销。

    • 提交信息质量(5/5分) 理由:Commit 信息非常规范,清晰地罗列了新增功能、修改的类、移除的逻辑以及底层实现的变更原因,具有极高的可追溯性。

    总分:73分

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