Commit f1ecdf15 by 崔彦峰

feat(clues): 添加线索导出功能的数据映射和字段配置

- 集成Excel值替换工具类用于状态字段转换
- 新增线索状态和跟进状态的枚举值映射配置
- 添加下次跟进时间字段到导出数据结构
- 调整Excel列索引顺序以匹配新的字段布局
- 实现线索状态数据从数据库到导出DTO的映射逻辑
- 添加跟进时间状态的空值检查和条件映射
1 parent 40941a08
...@@ -2,6 +2,8 @@ package com.gsc4cloud.gsc.vpc.api.dto.web.resdto.clues; ...@@ -2,6 +2,8 @@ package com.gsc4cloud.gsc.vpc.api.dto.web.resdto.clues;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat; import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.gsc4cloud.gsc.vpc.api.util.excel.ExcelValueReplace;
import com.gsc4cloud.gsc.vpc.api.util.excel.ReplaceIntegerToStringConvert;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
...@@ -45,45 +47,57 @@ public class CluesExportDTO implements Serializable { ...@@ -45,45 +47,57 @@ public class CluesExportDTO implements Serializable {
@ExcelProperty(value = "意向等级", index = 8) @ExcelProperty(value = "意向等级", index = 8)
private String customerIntentLevel; private String customerIntentLevel;
@ExcelValueReplace(replace = {"待跟进_1", "跟进中_2", "暂败_3", "成功收车_4"}, repeatValue = true)
@ExcelProperty(value = "线索状态", index = 9, converter = ReplaceIntegerToStringConvert.class)
private Integer cluesStatus;
@ExcelValueReplace(replace = {"临期_1", "已超期_2"}, repeatValue = true)
@ExcelProperty(value = "线索跟进状态", index = 10, converter = ReplaceIntegerToStringConvert.class)
private Integer followTimeStatus;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "下一次跟进时间", index = 11)
private Date nextFollowTime;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "最后跟进时间", index = 9) @ExcelProperty(value = "最后跟进时间", index = 12)
private Date latestFollowTime; private Date latestFollowTime;
@ExcelProperty(value = "录线索人员", index = 10) @ExcelProperty(value = "录线索人员", index = 13)
private String enterCluesUserType; private String enterCluesUserType;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间1", index = 11) @ExcelProperty(value = "跟进时间1", index = 14)
private Date followTime1; private Date followTime1;
@ExcelProperty(value = "跟进1内容", index = 12) @ExcelProperty(value = "跟进1内容", index = 15)
private String followContent1; private String followContent1;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间2", index = 13) @ExcelProperty(value = "跟进时间2", index = 16)
private Date followTime2; private Date followTime2;
@ExcelProperty(value = "跟进2内容", index = 14) @ExcelProperty(value = "跟进2内容", index = 17)
private String followContent2; private String followContent2;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间3", index = 15) @ExcelProperty(value = "跟进时间3", index = 18)
private Date followTime3; private Date followTime3;
@ExcelProperty(value = "跟进3内容", index = 16) @ExcelProperty(value = "跟进3内容", index = 19)
private String followContent3; private String followContent3;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间4", index = 17) @ExcelProperty(value = "跟进时间4", index = 20)
private Date followTime4; private Date followTime4;
@ExcelProperty(value = "跟进4内容", index = 18) @ExcelProperty(value = "跟进4内容", index = 21)
private String followContent4; private String followContent4;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss") @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间5", index = 19) @ExcelProperty(value = "跟进时间5", index = 22)
private Date followTime5; private Date followTime5;
@ExcelProperty(value = "跟进5内容", index = 20) @ExcelProperty(value = "跟进5内容", index = 23)
private String followContent5; private String followContent5;
} }
  • @wangxw1
    commented
    Master

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

    1. [可维护性/最佳实践] 注解中硬编码字典值,违背开闭原则

    • 问题描述:在 @ExcelValueReplace(replace = {"待跟进_1", "跟进中_2", ...}) 中,直接将状态枚举的映射关系硬编码在 DTO 的注解里。如果未来新增状态或修改状态名称,必须修改此 DTO 代码,这违反了单一职责和开闭原则。
    • 优化建议:建议使用 Java Enum 来统一定义线索状态,并利用 EasyExcel 官方支持的枚举转换器,或者在 Service 层面将状态转换为 String 后再赋值给 DTO。如果必须使用该自定义注解,建议支持读取枚举类或数据字典,而非手写字符串数组。

    2. [规范性/可维护性] 新增字段缺少 Javadoc 注释

    • 问题描述:根据《阿里巴巴 Java 开发手册》规范,实体类(DTO/VO/PO 等)的属性必须具备 Javadoc 注释(/** 内容 */)。本次新增的 cluesStatus、followTimeStatus、nextFollowTime 均缺失注释,不利于后续接手人员理解字段业务含义。
    • 优化建议:为新增字段补充标准 Javadoc 注释,例如: java /** * 线索状态 */ @ExcelValueReplace(...) private Integer cluesStatus;

    3. [健壮性/安全性] 包装类型字段结合自定义转换器的空指针(NPE)风险

    • 问题描述:新增的 cluesStatus 和 followTimeStatus 类型为 Integer(包装类,可能为 null),并绑定了自定义转换器 ReplaceIntegerToStringConvert。在 EasyExcel 导出时,如果数据库中该字段值为 null,且自定义转换器内部未做严格的防空处理,极易引发 NullPointerException 导致整个导出任务失败。
    • 优化建议:请务必检查 ReplaceIntegerToStringConvert.java 的实现,确保在 convertToExcelData 或相关转换方法的第一行进行了 if (value == null) 的防御性编程处理,返回默认字符串(如 "")而非抛出异常。

    二、评分明细

    评审项 满分 得分 扣分原因/评价
    1. 功能正确性与健壮性 40分 36分 索引(index)调整正确,功能逻辑基本可行;但自定义注解传参方式不够健壮,且存在潜在的 null 值处理风险。
    2. 安全性与潜在风险 30分 28分 无明显注入或越权安全漏洞;扣分在于包装类结合自定义转换器时常见的 NPE 风险。
    3. 最佳实践与可维护性 20分 12分 硬编码映射关系严重降低可扩展性;新增字段未遵循阿里规范添加 Javadoc 注释。(注:原代码中 followTime1 到 5 的扁平化设计属于遗留设计坏味道,不在此次变更扣分范围内)。
    4. 性能与资源利用 5分 5分 DTO 层的注解解析对导出性能影响微乎其微,资源利用合理。
    5. 提交信息质量 5分 5分 Commit message 格式规范(符合 Conventional Commits),清晰描述了修改点与业务目的,质量很高。

    总分:86分

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