Commit ee26dd82 by 林永健

Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1

2 parents 97b95ab5 2cddf249
...@@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank; ...@@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* BI-事项管理响应对象 * BI-事项管理响应对象
...@@ -85,5 +86,18 @@ public class MerchantBiMatterDTO implements Serializable { ...@@ -85,5 +86,18 @@ public class MerchantBiMatterDTO implements Serializable {
*/ */
@NotBlank(message = "运营人员名称不能为空") @NotBlank(message = "运营人员名称不能为空")
private String username; private String username;
@Override
public boolean equals(Object o) {
if (this == o) {return true;}
if (o == null || getClass() != o.getClass()) {return false;}
OperatorDTO that = (OperatorDTO) o;
return Objects.equals(uuid, that.uuid);
}
@Override
public int hashCode() {
return Objects.hash(uuid);
}
} }
} }
...@@ -772,13 +772,14 @@ public class BiAnalyseBackgroundService { ...@@ -772,13 +772,14 @@ public class BiAnalyseBackgroundService {
request.setDirectorTypes(directorTypeEnums.stream().map(ele -> ObjectUtil.toString(ele.getValue())).collect(Collectors.toList())); request.setDirectorTypes(directorTypeEnums.stream().map(ele -> ObjectUtil.toString(ele.getValue())).collect(Collectors.toList()));
List<ShopMerchantDirectorConfig> directorConfigs = merchantBiMatterMapper.selectBiMerchantOperator(request); List<ShopMerchantDirectorConfig> directorConfigs = merchantBiMatterMapper.selectBiMerchantOperator(request);
Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>> directorTypeMapOperator = directorConfigs.stream() Map<Byte, Set<MerchantBiMatterDTO.OperatorDTO>> directorTypeMapOperator = directorConfigs.stream()
.collect(Collectors.groupingBy(ShopMerchantDirectorConfig::getDirectorType, .collect(Collectors.groupingBy(ShopMerchantDirectorConfig::getDirectorType,
Collectors.mapping(ele -> MerchantBiMatterDTO.OperatorDTO.builder() Collectors.mapping(ele -> MerchantBiMatterDTO.OperatorDTO.builder()
.uuid(ele.getDirectorUserId()) .uuid(ele.getDirectorUserId())
.username(ele.getDirectorName()) .username(ele.getDirectorName())
.build(), .build(),
Collectors.toList()))); Collectors.toSet())));
// 处理区域运营和线上运营 // 处理区域运营和线上运营
MerchantOperatorDetailDTO result = new MerchantOperatorDetailDTO(); MerchantOperatorDetailDTO result = new MerchantOperatorDetailDTO();
...@@ -792,11 +793,24 @@ public class BiAnalyseBackgroundService { ...@@ -792,11 +793,24 @@ public class BiAnalyseBackgroundService {
Optional.ofNullable(directorTypeMapOperator.get(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue())) Optional.ofNullable(directorTypeMapOperator.get(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue()))
.ifPresent(r -> result.getAreaOperator().addAll(r)); .ifPresent(r -> result.getAreaOperator().addAll(r));
// 无关联的线上运营或区域运营,则无法提交并toast:无可跟进的线上运营或区域运营,请确认后重新操作; // 无关联的线上运营或区域运营,则无法提交并toast:无可跟进的线上运营或区域运营,请确认后重新操作;
if (CollUtil.isEmpty(result.getOnlineOperator()) && CollUtil.isEmpty(result.getAreaOperator())) { if (CollUtil.isEmpty(result.getOnlineOperator()) && CollUtil.isEmpty(result.getAreaOperator())) {
throw new RpcServiceException(BiErrorEnum.NO_ONLINE_AREA_OPERATOR_ERROR); throw new RpcServiceException(BiErrorEnum.NO_ONLINE_AREA_OPERATOR_ERROR);
} }
// 去重
List<MerchantBiMatterDTO.OperatorDTO> onlineOperator = result.getOnlineOperator();
if (CollUtil.isNotEmpty(onlineOperator)) {
result.setOnlineOperator(onlineOperator.stream()
.distinct()
.collect(Collectors.toList()));
}
List<MerchantBiMatterDTO.OperatorDTO> areaOperator = result.getAreaOperator();
if (CollUtil.isNotEmpty(areaOperator)) {
result.setAreaOperator(areaOperator.stream().distinct().collect(Collectors.toList()));
}
return result; return result;
} }
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    问题1: 重复遍历集合

    问题描述: 在新增的代码中,res 集合被遍历了两次,一次用于设置特定状态 "3",另一次用于设置默认状态 "1"。这可能导致不必要的性能开销,尤其是在 res 集合较大时。

    优化建议: 可以将这两个操作合并到一个流操作中,减少集合的遍历次数。例如,可以使用 Collectors.toMap 或者其他适当的收集器来实现。

    res.forEach(item -> {
        if (ecosystemWarningStoreIds.contains(item.getStoreId())) {
            item.appendStoreStatus("3");
        } else if (CollectionUtils.isEmpty(item.getStoreStatus())) {
            item.setStoreStatus(Lists.newArrayList("1"));
        }
    });
    

    问题2: SQL查询相关描述不明确

    问题描述: 提交信息中提到“在SQL查询中增加对 merchantIds 列表的过滤条件支持”,但实际代码变更并没有展示相关的SQL查询修改。这可能引起其他开发者的混淆。

    优化建议: 确保提交信息与实际代码变更一致。如果确实有SQL查询相关的修改,应该在代码变更中体现出来。如果没有,应该更新提交信息以反映实际情况。

    评分明细

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

      • 新增的代码实现了预期的功能,但存在性能优化的空间。
      • 评分: 35分
    2. 安全性与潜在风险(30分):

      • 没有明显的安全漏洞,但需要注意避免SQL注入等问题。
      • 评分: 28分
    3. 是否符合最佳实践(20分):

      • 代码结构合理,但存在重复遍历集合的问题。
      • 评分: 17分
    4. 性能与资源利用效率(5分):

      • 存在不必要的集合遍历,可能影响性能。
      • 评分: 2分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息不够明确,特别是关于SQL查询的部分。
      • 评分: 3分

    总分: 85分


    备注: 以上评分基于提供的代码变更内容和提交信息。若实际代码中有更多细节或上下文,可能会导致评分有所不同。

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