Commit a8a1ba26 by 崔彦峰

feat(clues): 更新线索导出功能和字段映射

- 修改 CluesExportDTO 类注释为"线索管理导出数据"
- 移除 ExcelValueReplace 和 ReplaceIntegerToStringConvert 相关依赖
- 重新排列 ExcelProperty 注解,调整字段顺序并添加索引值
- 新增跟进时间1-5和跟进内容1-5等字段用于展示最近5条跟进记录
- 在 CluesPageResp 中新增 enterType 字段用于标识线索录入类型
- 修改数据库查询 SQL,添加 enter_type 字段查询
- 重构 toCluesExportDTO 方法,逐字段设置属性并优化跟进记录处理
- 添加 formatCarBrandModel 方法用于格式化车辆品牌型号显示
- 添加 getEnterTypeDesc 方法用于获取录入类型描述
- 实现 setFollowRecord 方法将跟进记录按序分配到对应字段中
1 parent 31a46c23
......@@ -456,18 +456,75 @@ public class CluesInfoService extends ServiceImpl<CluesInfoMapper, CluesInfo> {
private CluesExportDTO toCluesExportDTO(CluesPageResp clues) {
CluesExportDTO exportDTO = new CluesExportDTO();
BeanUtils.copyProperties(clues, exportDTO);
exportDTO.setFollowRecordList(formatFollowRecordList(clues.getFollowRecordList()));
exportDTO.setCluesNo(clues.getCluesNo());
exportDTO.setSellerMerchantName(clues.getSellerMerchantName());
exportDTO.setEnterTime(clues.getEnterTime());
exportDTO.setSellerName(clues.getSellerName());
exportDTO.setCarOwnerName(clues.getCarOwnerName());
exportDTO.setCarOwnerPhone(clues.getCarOwnerPhone());
exportDTO.setCarBrandModel(formatCarBrandModel(clues));
exportDTO.setConversionName(clues.getConversionName());
exportDTO.setCustomerIntentLevel(clues.getCustomerIntentLevel());
exportDTO.setLatestFollowTime(clues.getLatestFollowTime());
exportDTO.setEnterCluesUserType(getEnterTypeDesc(clues.getEnterType()));
List<FollowRecordItemResp> followRecordList = clues.getFollowRecordList();
if (followRecordList != null) {
for (int i = 0; i < Math.min(followRecordList.size(), 5); i++) {
setFollowRecord(exportDTO, i + 1, followRecordList.get(i));
}
}
return exportDTO;
}
private String formatFollowRecordList(List<FollowRecordItemResp> followRecordList) {
if (followRecordList == null || followRecordList.isEmpty()) {
return "";
private String formatCarBrandModel(CluesPageResp clues) {
StringJoiner joiner = new StringJoiner("/");
addTextIfPresent(joiner, clues.getCarBrand());
addTextIfPresent(joiner, clues.getCarChildsBrandName());
addTextIfPresent(joiner, clues.getCarSeriesName());
addTextIfPresent(joiner, clues.getCarTypeName());
return joiner.toString();
}
private void addTextIfPresent(StringJoiner joiner, String value) {
if (StringUtils.hasText(value)) {
joiner.add(value);
}
}
private String getEnterTypeDesc(Integer enterType) {
EnterTypeEnum enterTypeEnum = EnterTypeEnum.getByCode(enterType);
return enterTypeEnum == null ? "" : enterTypeEnum.getDesc();
}
private void setFollowRecord(CluesExportDTO exportDTO, int index, FollowRecordItemResp followRecord) {
Date followTime = followRecord.getCreatedDate();
String followContent = formatFollowRecord(followRecord);
switch (index) {
case 1 -> {
exportDTO.setFollowTime1(followTime);
exportDTO.setFollowContent1(followContent);
}
case 2 -> {
exportDTO.setFollowTime2(followTime);
exportDTO.setFollowContent2(followContent);
}
case 3 -> {
exportDTO.setFollowTime3(followTime);
exportDTO.setFollowContent3(followContent);
}
case 4 -> {
exportDTO.setFollowTime4(followTime);
exportDTO.setFollowContent4(followContent);
}
case 5 -> {
exportDTO.setFollowTime5(followTime);
exportDTO.setFollowContent5(followContent);
}
default -> {
// 仅展开最新 5 条跟进记录。
}
}
return followRecordList.stream()
.map(this::formatFollowRecord)
.collect(Collectors.joining("\n"));
}
private String formatFollowRecord(FollowRecordItemResp followRecord) {
......
......@@ -133,7 +133,7 @@
<!-- PAD/Web端线索分页列表 -->
<select id="page" resultType="com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesPageResp">
SELECT
c.id, c.clues_no, c.enter_time, c.seller_merchant_name, c.seller_merchant_id,
c.id, c.clues_no, c.enter_type, c.enter_time, c.seller_merchant_name, c.seller_merchant_id,
c.seller_name, c.car_owner_name, c.car_owner_phone, c.car_brand,
c.car_childs_brand_name, c.car_series_name, c.car_type_name,
c.customer_intent_level, c.clues_status, c.next_follow_time,
......
  • @wangxw1
    commented
    Master

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

    1. 安全性问题:敏感信息(PII)明文导出风险

    • 问题描述:在 toCluesExportDTO 方法中,车主手机号(carOwnerPhone)、车主姓名(carOwnerName)等个人敏感信息被直接明文赋值到导出 DTO 中。
    • 影响分析:导出包含大量明文手机号的 Excel 文件存在较高的数据泄露风险。除非该导出功能明确仅面向具有最高数据权限的安全审计人员,否则直接导出明文违反了常见的企业数据安全规范及《个人信息保护法》相关合规要求。
    • 优化建议:建议对敏感字段进行脱敏(掩码)处理。若项目已集成数据脱敏组件,建议在 DTO 字段上添加 @Desensitize 等注解;若无组件支持,建议在赋值时进行手动脱敏处理。 java // 示例:手动脱敏处理(保留前3后4) exportDTO.setCarOwnerPhone(DesensitizeUtil.mobilePhone(clues.getCarOwnerPhone()));

    2. 健壮性问题:集合元素潜在的 NullPointerException 风险

    • 问题描述:在 setFollowRecord 方法中,直接调用了 followRecord.getCreatedDate() 和 formatFollowRecord(followRecord),但没有对 followRecord 对象本身进行非空校验。
    • 影响分析:虽然 clues.getFollowRecordList() 正常情况下不应包含 null 元素,但如果上游数据组装存在脏数据,列表中混入了 null,此处将抛出 NullPointerException,直接导致整个批量导出任务崩溃失败。
    • 优化建议:在 setFollowRecord 方法的开头增加防御性编程的非空判断。 java private void setFollowRecord(CluesExportDTO exportDTO, int index, FollowRecordItemResp followRecord) { if (followRecord == null) { return; } Date followTime = followRecord.getCreatedDate(); // ... }

    3. 可维护性问题:硬编码字段与 Switch 逻辑扩展性较差

    • 问题描述:为了将最近 5 条跟进记录导出为独立列,DTO 中硬编码了 followTime1 到 followTime5 等平铺字段,并在 setFollowRecord 中使用 switch 语句进行 1-5 的强绑定映射。
    • 影响分析:此设计违反了“开闭原则(OCP)”。如果未来业务方要求导出最近 10 条或动态条数的跟进记录,不仅需要大幅修改 DTO 的类结构,还要继续拉长 switch 语句,代码显得笨重且难以维护。
    • 优化建议:对于固定模板的 Excel 导出,当前的平铺字段做法是可行的妥协方案。但为了长远的可维护性,建议评估是否可以使用 EasyExcel/POI 的动态列(Dynamic Columns)特性,将跟进记录作为动态表头进行渲染,从而彻底消除硬编码的 switch 映射逻辑。

    二、评分明细

    • 功能实现的正确性与健壮性 (37/40分)
      • 理由:核心业务逻辑实现正确,成功移除了性能较差的 BeanUtils.copyProperties,改为手动设值。Math.min 处理集合越界非常得当,StringJoiner 使用优雅。MyBatis XML 中未使用子查询,符合规范。扣分点在于处理集合元素时缺乏防御性 null 校验。
    • 安全性与潜在风险 (24/30分)
      • 理由:SQL 层面没有注入风险,但存在明显的个人敏感信息(手机号码等)明文导出风险,在 B 端系统中这是典型的安全隐患,需结合业务权限进行脱敏评估。
    • 最佳实践与可维护性 (17/20分)
      • 理由:代码结构清晰,方法拆分合理(如 formatCarBrandModel、getEnterTypeDesc),使用了较新的 Java switch 表达式语法,可读性好。扣分点在于导出字段的硬编码平铺设计扩展性稍弱。
    • 性能与资源利用 (5/5分)
      • 理由:去除了对 BeanUtils 反射拷贝的依赖,直接使用 Setter 赋值,对于数据量较大的导出场景,能有效降低 CPU 和内存消耗,提升导出性能。
    • 提交信息质量 (5/5分)
      • 理由:Commit message 极其优秀。采用了标准的前缀(feat(clues):),并且使用列表清晰、详尽地描述了每一次修改的“What”和“Why”,具备极高的可追溯性。

    总分:88分

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