Commit 8cf62c80 by 林永健

feat(learningcenter): 添加等级考试品牌筛选功能

- 在LevelExamController中新增queryPositionBrandOptions接口用于根据职务查询品牌筛选选项
- 为LevelExamAddRequest、LevelExamUpdateRequest、LevelExamDetailResponse等DTO类添加brandIds和brandNames字段
- 在Excel导出VO中添加品牌相关字段支持
- 更新RPC依赖版本至5.8.6-SNAPSHOT
- 在学习中心等级考试服务中实现品牌过滤逻辑,支持按员工上架门店记录进行品牌匹配
- 添加selectLatestMerchantIdByPhones和selectRecruitmentBrandNamesByPhones数据库查询方法
- 实现基于职务配置的品牌筛选选项查询功能
- 在考试重复性检查中加入品牌ID作为校验条件
- 支持按品牌ID进行考试列表筛选查询
1 parent fa4e253d
Showing 18 changed files with 315 additions and 6 deletions
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-riskmanage-api</artifactId> <artifactId>rpc-dj-riskmanage-api</artifactId>
<version>5.8.3.6-SNAPSHOT</version> <version>5.8.6-SNAPSHOT</version>
<name>rpc-dj-riskmanage-api</name> <name>rpc-dj-riskmanage-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.riskmanage.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.riskmanage.remote</deploy.scanPackage>
......
...@@ -46,6 +46,18 @@ public class LevelExamDetailDTO implements java.io.Serializable { ...@@ -46,6 +46,18 @@ public class LevelExamDetailDTO implements java.io.Serializable {
private String positionName; private String positionName;
/** /**
* 品牌ID列表(逗号分隔)
*/
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
/**
* 品牌名称列表(逗号分隔)
*/
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
/**
* 考试时间 * 考试时间
*/ */
private Integer examTime; private Integer examTime;
......
...@@ -101,5 +101,10 @@ public class LevelExamDetailResponseDTO implements Serializable { ...@@ -101,5 +101,10 @@ public class LevelExamDetailResponseDTO implements Serializable {
@ApiModelProperty(notes = "生效方式 (1:立即生效, 2:定时生效)") @ApiModelProperty(notes = "生效方式 (1:立即生效, 2:定时生效)")
private Byte effectiveType; private Byte effectiveType;
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
} }
...@@ -85,6 +85,12 @@ public class LevelExamPageListRequestDTO implements Serializable { ...@@ -85,6 +85,12 @@ public class LevelExamPageListRequestDTO implements Serializable {
private Integer planId; private Integer planId;
/** /**
* 品牌ID筛选
*/
@ApiModelProperty(notes = "品牌ID筛选")
private Integer brandId;
/**
* 状态 (0:草稿, 1:未生效, 2:生效, 3:失效) * 状态 (0:草稿, 1:未生效, 2:生效, 3:失效)
*/ */
@ApiModelProperty(notes = "状态list (0:草稿, 1:未生效, 2:生效, 3:失效)") @ApiModelProperty(notes = "状态list (0:草稿, 1:未生效, 2:生效, 3:失效)")
......
...@@ -59,6 +59,12 @@ public class LevelExamPageListResponseDTO implements Serializable { ...@@ -59,6 +59,12 @@ public class LevelExamPageListResponseDTO implements Serializable {
@ApiModelProperty(notes = "职务名称") @ApiModelProperty(notes = "职务名称")
private String positionName; private String positionName;
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
/** /**
* 考试时间 * 考试时间
......
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 根据职务查询品牌筛选选项请求
*/
@Data
public class LevelExamPositionBrandRequest {
/**
* 职务编码(北森 OId)
*/
@ApiModelProperty(notes = "职务编码(北森 OId),与职务名称二选一")
private String positionCode;
/**
* 职务名称
*/
@ApiModelProperty(notes = "职务名称,与职务编码二选一")
private String positionName;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 根据职务查询品牌筛选选项响应
*/
@Data
public class LevelExamPositionBrandResponse implements Serializable {
/**
* 品牌ID(一级品牌 firstBrandId)
*/
@ApiModelProperty(notes = "品牌ID")
private Integer brandId;
/**
* 品牌名称
*/
@ApiModelProperty(notes = "品牌名称")
private String brandName;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import lombok.Data;
import java.io.Serializable;
/**
* 招聘需求品牌信息(兜底路径)
*/
@Data
public class RecruitmentBrandDTO implements Serializable {
/**
* 员工手机号
*/
private String phoneNumber;
/**
* 招聘需求品牌文本(如"鸿蒙智行/焜驰/起亚")
*/
private String brand;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import lombok.Data;
import java.io.Serializable;
/**
* 员工最新上架门店关联信息
*/
@Data
public class StaffLatestMerchantDTO implements Serializable {
/**
* 员工手机号
*/
private String staffPhone;
/**
* 关联的商户ID
*/
private Integer merchantId;
}
...@@ -52,6 +52,18 @@ public class LearningCenterLevelExam { ...@@ -52,6 +52,18 @@ public class LearningCenterLevelExam {
private String positionName; private String positionName;
/** /**
* 品牌ID列表(逗号分隔)
*/
@Column(name = "brand_ids")
private String brandIds;
/**
* 品牌名称列表(逗号分隔)
*/
@Column(name = "brand_names")
private String brandNames;
/**
* 考试时间 * 考试时间
*/ */
@Column(name = "exam_time") @Column(name = "exam_time")
......
...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.riskmanage.remote; ...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.riskmanage.remote;
import cn.com.glsx.dj.riskmanage.dto.beisen.OrganizationListResponseDTO; import cn.com.glsx.dj.riskmanage.dto.beisen.OrganizationListResponseDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.*; import cn.com.glsx.dj.riskmanage.dto.learningcenter.*;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandResponse;
import cn.com.glsx.framework.core.annotation.ApiMethod; import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam; import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse; import cn.com.glsx.framework.core.annotation.ApiResponse;
...@@ -50,4 +51,9 @@ public interface LearningCenterLevelExamRemote { ...@@ -50,4 +51,9 @@ public interface LearningCenterLevelExamRemote {
@ApiParam(name = "pagination", notes = "考试人员列表查询", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "考试人员列表查询", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("考试人员列表查询") @ApiResponse("考试人员列表查询")
RpcResponse<RpcPagination<LevelExamPersonDTO>> levelExamDataPersonPage(RpcPagination<LevelExamPersonDTO> pagination); RpcResponse<RpcPagination<LevelExamPersonDTO>> levelExamDataPersonPage(RpcPagination<LevelExamPersonDTO> pagination);
@ApiMethod("根据职务查询品牌筛选选项")
@ApiParam(name = "request", notes = "职务编码或职务名称", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("品牌筛选选项")
RpcResponse<List<LevelExamPositionBrandResponse>> queryPositionBrandOptions(@NotNull LevelExamPositionBrandRequest request);
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-riskmanage-api</artifactId> <artifactId>rpc-dj-riskmanage-api</artifactId>
<version>5.8.3.6-SNAPSHOT</version> <version>5.8.6-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.merchants</groupId> <groupId>cn.com.glsx.merchants</groupId>
......
...@@ -2,10 +2,14 @@ package cn.com.glsx.dj.riskmanage.mapper.learningcenter; ...@@ -2,10 +2,14 @@ package cn.com.glsx.dj.riskmanage.mapper.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LearningCenterLevelExamPersonDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LearningCenterLevelExamPersonDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPersonDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPersonDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.RecruitmentBrandDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.StaffLatestMerchantDTO;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamPerson; import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamPerson;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Collection;
import java.util.List; import java.util.List;
@Mapper @Mapper
...@@ -24,4 +28,18 @@ public interface LearningCenterLevelExamPersonMapper extends OreMapper<LearningC ...@@ -24,4 +28,18 @@ public interface LearningCenterLevelExamPersonMapper extends OreMapper<LearningC
List<LearningCenterLevelExamPersonDTO> findLevelExamPerson(Integer userId); List<LearningCenterLevelExamPersonDTO> findLevelExamPerson(Integer userId);
List<LearningCenterLevelExamPersonDTO> findLevelExamPersonWithEffective(Integer userId); List<LearningCenterLevelExamPersonDTO> findLevelExamPersonWithEffective(Integer userId);
/**
* 批量查询员工最新上架记录关联的商户ID(按手机号去重取MAX(id))
* @param phones 手机号列表
* @return StaffLatestMerchantDTO 列表
*/
List<StaffLatestMerchantDTO> selectLatestMerchantIdByPhones(@Param("phones") Collection<String> phones);
/**
* 批量查询招聘需求品牌名称(兜底路径,无上架门店记录时使用)
* @param phones 手机号列表
* @return RecruitmentBrandDTO 列表
*/
List<RecruitmentBrandDTO> selectRecruitmentBrandNamesByPhones(@Param("phones") Collection<String> phones);
} }
\ No newline at end of file \ No newline at end of file
...@@ -128,4 +128,17 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa ...@@ -128,4 +128,17 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<List<LevelExamPositionBrandResponse>> queryPositionBrandOptions(LevelExamPositionBrandRequest request) {
try {
return RpcResponse.success(learningCenterLevelExamService.queryPositionBrandOptions(request));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
} }
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<result column="department_name" property="departmentName" jdbcType="VARCHAR" /> <result column="department_name" property="departmentName" jdbcType="VARCHAR" />
<result column="position_code" property="positionCode" jdbcType="VARCHAR" /> <result column="position_code" property="positionCode" jdbcType="VARCHAR" />
<result column="position_name" property="positionName" jdbcType="VARCHAR" /> <result column="position_name" property="positionName" jdbcType="VARCHAR" />
<result column="brand_ids" property="brandIds" jdbcType="VARCHAR" />
<result column="brand_names" property="brandNames" jdbcType="VARCHAR" />
<result column="exam_time" property="examTime" jdbcType="INTEGER" /> <result column="exam_time" property="examTime" jdbcType="INTEGER" />
<result column="learning_center_permission" property="learningCenterPermission" jdbcType="TINYINT" /> <result column="learning_center_permission" property="learningCenterPermission" jdbcType="TINYINT" />
<result column="effective_type" property="effectiveType" jdbcType="TINYINT" /> <result column="effective_type" property="effectiveType" jdbcType="TINYINT" />
...@@ -32,8 +34,8 @@ ...@@ -32,8 +34,8 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, beisen_exam_id, beisen_exam_name, department_id, department_name, position_code, position_name, exam_time, id, beisen_exam_id, beisen_exam_name, department_id, department_name, position_code, position_name, brand_ids, brand_names,
learning_center_permission, effective_type, effective_time, status, submitted_count, creator, exam_time, learning_center_permission, effective_type, effective_time, status, submitted_count, creator,
created_by, created_date, updated_by, updated_date, deleted_flag created_by, created_date, updated_by, updated_date, deleted_flag
</sql> </sql>
<update id="completionIncreaseCount"> <update id="completionIncreaseCount">
...@@ -103,10 +105,13 @@ ...@@ -103,10 +105,13 @@
</if> </if>
<if test="statusList != null and statusList.size() > 0"> <if test="statusList != null and statusList.size() > 0">
AND exam.status in AND exam.status in
<foreach item="item" collection="statusList" separator="," open="(" close=")" index=""> <foreach item="item" collection="statusList" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="brandId != null">
AND FIND_IN_SET(#{brandId}, exam.brand_ids) > 0
</if>
ORDER BY ORDER BY
<choose> <choose>
<when test="orderByType != null and orderByType == 0"> <when test="orderByType != null and orderByType == 0">
......
...@@ -127,4 +127,42 @@ ...@@ -127,4 +127,42 @@
AND t3.deleted_flag = 'N' AND t3.deleted_flag = 'N'
AND t3.status = '2' AND t3.status = '2'
</select> </select>
<resultMap id="StaffLatestMerchantResult" type="cn.com.glsx.dj.riskmanage.dto.learningcenter.StaffLatestMerchantDTO">
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="RecruitmentBrandResult" type="cn.com.glsx.dj.riskmanage.dto.learningcenter.RecruitmentBrandDTO">
<result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
<result column="brand" property="brand" jdbcType="VARCHAR" />
</resultMap>
<select id="selectLatestMerchantIdByPhones" resultMap="StaffLatestMerchantResult">
SELECT sar.staff_phone, sar.merchant_id
FROM dj_smartcarlife.dj_car_life_staff_account_assign_record sar
INNER JOIN (
SELECT staff_phone, MAX(id) AS max_id
FROM dj_smartcarlife.dj_car_life_staff_account_assign_record
WHERE staff_phone IN
<foreach item="item" index="index" collection="phones" separator="," open="(" close=")">
#{item}
</foreach>
AND deleted_flag = 'N'
AND merchant_id IS NOT NULL
GROUP BY staff_phone
) latest ON sar.staff_phone = latest.staff_phone AND sar.id = latest.max_id
</select>
<select id="selectRecruitmentBrandNamesByPhones" resultMap="RecruitmentBrandResult">
SELECT plan.phone_number, d.brand
FROM dj_smartcarlife.dj_car_life_recruitment_onboarding_plan plan
INNER JOIN dj_smartcarlife.dj_car_life_recruitment_demand d ON plan.demand_id = d.id
WHERE plan.phone_number IN
<foreach item="item" index="index" collection="phones" separator="," open="(" close=")">
#{item}
</foreach>
AND plan.deleted_flag = 'N'
AND d.deleted_flag = 'N'
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.riskmanage.service.learningcenter; ...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.riskmanage.service.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamDetailDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamDetailDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamLevelDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamLevelDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandRequest;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandResponse;
import cn.com.glsx.dj.riskmanage.service.BaseServiceTest; import cn.com.glsx.dj.riskmanage.service.BaseServiceTest;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import org.junit.Test; import org.junit.Test;
...@@ -130,6 +132,99 @@ public class LearningCenterLevelExamServiceTest extends BaseServiceTest { ...@@ -130,6 +132,99 @@ public class LearningCenterLevelExamServiceTest extends BaseServiceTest {
@Test @Test
public void testPushExamToEmployees() { public void testPushExamToEmployees() {
levelExamService.pushExamToEmployees(11); levelExamService.pushExamToEmployees(13);
}
/**
* 品牌岗位创建带品牌考试
*/
@Test
public void testAddLevelExam_BrandPosition() {
LevelExamDetailDTO request = new LevelExamDetailDTO();
String creator = "xiehx";
request.setCreator(creator);
request.setCreatedBy(creator);
request.setUpdatedBy(creator);
request.setBeisenExamId("e77c8fa1-ad30-4803-967a-231f22090f48");
request.setPositionCode("862166");
request.setPositionName("延保门店销售");
request.setExamTime(30);
request.setBrandIds("1,2");
request.setBrandNames("问界,鸿蒙");
request.setLearningCenterPermission((byte) 1);
request.setEffectiveType((byte) 1);
request.setStatus((byte) 1);
List<LevelExamLevelDTO> levels = new ArrayList<>();
LevelExamLevelDTO level1 = new LevelExamLevelDTO();
level1.setLevelName("B级");
level1.setMinScore(0);
level1.setMaxScore(60);
level1.setSortOrder(1);
levels.add(level1);
LevelExamLevelDTO level2 = new LevelExamLevelDTO();
level2.setLevelName("A级");
level2.setMinScore(61);
level2.setMaxScore(100);
level2.setSortOrder(2);
levels.add(level2);
request.setLevelExamLevels(levels);
Integer examId = levelExamService.addLevelExam(request);
System.out.println("品牌岗位创建考试完成 examId=" + examId);
}
/**
* 品牌岗位切换到非品牌岗位,验证品牌字段被清空
*/
@Test
public void testUpdateLevelExam_SwitchToNonBrand() {
LevelExamDetailDTO request = new LevelExamDetailDTO();
request.setId(25);
request.setStatus((byte) 1);
String creator = "xiehx";
request.setUpdatedBy(creator);
request.setBeisenExamId("e77c8fa1-ad30-4803-967a-231f22090f48");
request.setDepartmentId(900433700);
request.setPositionCode("862110");
request.setPositionName("销售顾问");
request.setExamTime(30);
request.setBrandIds("3,4");
request.setBrandNames("起亚,现代");
request.setLearningCenterPermission((byte) 1);
request.setEffectiveType((byte) 1);
levelExamService.updateLevelExam(request);
System.out.println("品牌岗位切换到非品牌岗位完成");
}
/**
* queryPositionBrandOptions 匹配成功场景
* 需确保 env.level.exam.brand.positions 包含"延保门店销售"
*/
@Test
public void testQueryPositionBrandOptions_Matched() {
LevelExamPositionBrandRequest req = new LevelExamPositionBrandRequest();
req.setPositionCode("862166");
req.setPositionName("延保门店销售");
List<LevelExamPositionBrandResponse> res = levelExamService.queryPositionBrandOptions(req);
System.out.println("匹配成功品牌数量=" + (res != null ? res.size() : 0));
}
/**
* queryPositionBrandOptions 匹配失败场景
* 职务名称不在 env.level.exam.brand.positions 配置中
*/
@Test
public void testQueryPositionBrandOptions_Unmatched() {
LevelExamPositionBrandRequest req = new LevelExamPositionBrandRequest();
req.setPositionCode("862110");
req.setPositionName("销售顾问");
List<LevelExamPositionBrandResponse> res = levelExamService.queryPositionBrandOptions(req);
System.out.println("匹配失败品牌数量=" + (res != null ? res.size() : 0));
} }
} }
  • @wangxw1
    commented
    Master

    这是一份针对您提交代码的专业审查报告。代码整体结构清晰,业务逻辑拆分较好,但在健壮性、数据一致性以及大批量数据处理方面存在几个关键隐患需要修复。

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

    1. 潜在的空指针异常(NPE)与冗余的 RPC/DB 调用

    • 问题描述:在 updateLevelExam 方法中,获取 newJobPost 存在冗余调用,且未进行空值判断直接调用了 getName()。
    • 影响分析:如果传入的 newPositionCode 无效,或者上游北森接口/数据库查询不到对应职务返回 null,newJobPost.getName() 将直接抛出 NullPointerException,导致整个更新接口报 500 错误。此外,代码中写了两次 getBeiSenJobPost(newPositionCode),浪费了系统资源。
    • 优化建议:移除冗余调用,并增加防御性空值判断。 ```java // 原始代码: // BeiSenJobPost newJobPost = getBeiSenJobPost(newPositionCode); // ... // if (newJobPost == null) { // newJobPost = getBeiSenJobPost(newPositionCode); // } // oldLevelExam.setPositionName(newJobPost.getName());

    // 建议修改为: BeiSenJobPost newJobPost = getBeiSenJobPost(newPositionCode); if (newJobPost != null) { oldLevelExam.setPositionName(newJobPost.getName()); } else { // 根据业务诉求,抛出业务异常提示"职务编码无效"或做降级处理 throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "无法获取对应的新职务信息"); }

    
    #### 2. 重复性校验逻辑漏洞(数据一致性问题)
    - **问题描述**:`formatBrandIdsForRepeatCheck` 方法对 `brandIds` 进行了排序(按字符串字典序)以用于重复性查询校验。但是,在实际落库保存时(如 `BeanUtil.copyProperties` 或 `oldLevelExam.setBrandIds(brandIds)`),保存的仍然是**未经排序的原始字符串**。
    - **影响分析**:如果用户A创建考试传入 `"2,10"`,数据库存入 `"2,10"`。用户B创建相同考试传入 `"10,2"`,校验方法将其排序化为 `"10,2"` 去数据库做精确匹配(`andEqualTo`),将无法匹配到库里的 `"2,10"`,从而导致重复校验失效,产生脏数据。
    - **优化建议**:不仅在查询时需要格式化,**落库保存时也必须使用格式化后的字符串**;同时建议按数字大小而非字典序排序。
      ```java
      // 1. 建议的格式化方法(按数字排序)
      private String formatBrandIdsForRepeatCheck(String brandIds) {
          if (StringUtils.isBlank(brandIds)) return null;
          return Arrays.stream(brandIds.split(","))
                  .map(String::trim)
                  .map(Integer::valueOf)
                  .sorted()
                  .map(String::valueOf)
                  .collect(Collectors.joining(","));
      }
    
      // 2. 在新增和修改落库前,统一替换为格式化后的值
      String normalizedBrandIds = formatBrandIdsForRepeatCheck(request.getBrandIds());
      request.setBrandIds(normalizedBrandIds); 
      // 然后再进行 BeanUtil.copyProperties 和 repeatCheck
    

    3. 批量查询与 RPC 调用缺乏分片机制(性能与稳定性风险)

    • 问题描述:filterEmployeesByBrand 方法中,提取了所有员工的手机号 phones,直接传递给 Mapper 的 IN 查询,以及将全量 merchantIds 直接传递给 merchantRemote.getBrandByMerchantIds 进行 RPC 调用。
    • 影响分析:当推送考试的员工基数较大(如数千人)时,超长的 IN 语句会导致 SQL 性能急剧下降甚至超出 MySQL max_allowed_packet 限制报错。同时,RPC 调用传递超大集合容易引发序列化耗时过长或触发 Provider 端的报文大小限制。
    • 优化建议:利用项目中已引入的 Hutool 工具类,对集合进行分片(Batch)处理。 ```java // DB 查询分片示例: List result = new ArrayList<>(); List> phonePartitions = CollectionUtil.split(phones, 500); for (List batch : phonePartitions) { result.addAll(levelExamPersonMapper.selectLatestMerchantIdByPhones(batch)); }

    // RPC 调用分片示例同理,对 merchantIds 进行切片循环调用并合并结果。

    
    ---
    
    ### 二、评分明细
    
    - **功能实现的正确性与健壮性 (30/40分)**
      **理由**:核心的品牌过滤分岔逻辑(主路径与兜底路径)设计清晰。但扣分在于发现了两处严重影响健壮性的缺陷:`newJobPost` 的潜在空指针异常,以及字符串排序与落库不一致导致的重复校验失效漏洞。
    
    - **安全性与潜在风险 (30/30分)**
      **理由**:未发现明显的 SQL 注入风险(MyBatis 传参规范),没有越权或敏感信息泄露问题。新增的 RPC 接口符合规范,没有破坏既有接口的参数结构。
    
    - **最佳实践与可维护性 (15/20分)**
      **理由**:代码注释详尽,流式 API (Stream) 使用熟练,可读性较好。扣分项在于:存在无意义的冗余代码(连续两次 `getBeiSenJobPost`),且内部方法职责存在轻微耦合。
    
    - **性能与资源利用 (3/5分)**
      **理由**:通过提取 Set 集合进行内存匹配,避免了在 for 循环中查库,这点做得很好。但针对大集合未做分片限制(Chunking),直接进行 DB 的 IN 查询和 RPC 批量请求,在生产大考场景下存在明显的性能瓶颈与崩溃风险。
    
    - **提交信息质量 (5/5分)**
      **理由**:Commit message 采用了标准的结构化格式(feat),并以列表形式清晰详尽地罗列了所有变更点,可追溯性极强。
    
    **总分:83分**
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!