Commit 40941a08 by 崔彦峰

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

- 修改 CluesExportDTO 类注释为"线索管理导出数据"
- 移除 ExcelValueReplace 和 ReplaceIntegerToStringConvert 相关依赖
- 重新排列 ExcelProperty 注解,调整字段顺序并添加索引值
- 新增跟进时间1-5和跟进内容1-5等字段用于展示最近5条跟进记录
- 在 CluesPageResp 中新增 enterType 字段用于标识线索录入类型
- 修改数据库查询 SQL,添加 enter_type 字段查询
- 重构 toCluesExportDTO 方法,逐字段设置属性并优化跟进记录处理
- 添加 formatCarBrandModel 方法用于格式化车辆品牌型号显示
- 添加 getEnterTypeDesc 方法用于获取录入类型描述
- 实现 setFollowRecord 方法将跟进记录按序分配到对应字段中
1 parent 09fc73b0
package com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -19,6 +20,9 @@ public class CluesPageResp implements Serializable {
@Schema(description = "线索ID")
private Integer id;
@Schema(description = "线索录入类型:1-销售 2-评估师")
private Integer enterType;
@Schema(description = "线索编号")
private String cluesNo;
......
......@@ -2,8 +2,6 @@ package com.gsc4cloud.gsc.vpc.api.dto.web.resdto.clues;
import com.alibaba.excel.annotation.ExcelProperty;
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 java.io.Serial;
......@@ -11,7 +9,7 @@ import java.io.Serializable;
import java.util.Date;
/**
* 线索导出数据。
* 线索管理导出数据。
*/
@Data
public class CluesExportDTO implements Serializable {
......@@ -19,62 +17,73 @@ public class CluesExportDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelProperty("线索编号")
@ExcelProperty(value = "线索ID", index = 0)
private String cluesNo;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty("录入时间")
private Date enterTime;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty("最新跟进时间")
private Date latestFollowTime;
@ExcelProperty("线索门店")
@ExcelProperty(value = "线索门店", index = 1)
private String sellerMerchantName;
@ExcelProperty("销售门店ID")
private Integer sellerMerchantId;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "录入时间", index = 2)
private Date enterTime;
@ExcelProperty("销售名称")
@ExcelProperty(value = "推荐销售顾问", index = 3)
private String sellerName;
@ExcelProperty("车主名称")
@ExcelProperty(value = "车主姓名", index = 4)
private String carOwnerName;
@ExcelProperty("车主电话")
@ExcelProperty(value = "车主电话", index = 5)
private String carOwnerPhone;
@ExcelProperty("车辆品牌")
private String carBrand;
@ExcelProperty(value = "评估品牌车型", index = 6)
private String carBrandModel;
@ExcelProperty("子品牌")
private String carChildsBrandName;
@ExcelProperty(value = "评估师", index = 7)
private String conversionName;
@ExcelProperty("车系")
private String carSeriesName;
@ExcelProperty(value = "意向等级", index = 8)
private String customerIntentLevel;
@ExcelProperty("车型")
private String carTypeName;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "最后跟进时间", index = 9)
private Date latestFollowTime;
@ExcelProperty("意向等级")
private String customerIntentLevel;
@ExcelProperty(value = "录线索人员", index = 10)
private String enterCluesUserType;
@ExcelValueReplace(replace = {"待跟进_1", "跟进中_2", "暂败_3", "成功收车_4"}, repeatValue = true)
@ExcelProperty(value = "线索状态", converter = ReplaceIntegerToStringConvert.class)
private Integer cluesStatus;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间1", index = 11)
private Date followTime1;
@ExcelValueReplace(replace = {"正常_0", "临期_1", "已超期_2"}, repeatValue = true)
@ExcelProperty(value = "跟进状态", converter = ReplaceIntegerToStringConvert.class)
private Integer followTimeStatus;
@ExcelProperty(value = "跟进1内容", index = 12)
private String followContent1;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty("下一次跟进时间")
private Date nextFollowTime;
@ExcelProperty(value = "跟进时间2", index = 13)
private Date followTime2;
@ExcelProperty("评估师")
private String conversionName;
@ExcelProperty(value = "跟进2内容", index = 14)
private String followContent2;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间3", index = 15)
private Date followTime3;
@ExcelProperty(value = "跟进3内容", index = 16)
private String followContent3;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间4", index = 17)
private Date followTime4;
@ExcelProperty(value = "跟进4内容", index = 18)
private String followContent4;
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "跟进时间5", index = 19)
private Date followTime5;
@ExcelProperty("跟进记录")
private String followRecordList;
@ExcelProperty(value = "跟进5内容", index = 20)
private String followContent5;
}
  • @wangxw1
    commented
    Master

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

    1. 违反开闭原则的硬编码设计(最佳实践与可维护性)

    • 问题描述:在 CluesExportDTO.java 中,为了导出最近 5 条跟进记录,硬编码了 followTime1 到 followTime5 以及对应的 followContent 共 10 个字段。这种“平铺式”设计极大地破坏了代码的可维护性和扩展性。如果未来业务需求变更为导出 3 条或 10 条,将不得不修改 DTO 结构并重新编译代码。
    • 优化建议:
      • 方案A(推荐):利用 EasyExcel 的动态表头(Dynamic Head)功能,根据实际查询到的最大跟进次数动态生成列。
      • 方案B:如果为了降低实现复杂度,建议将跟进记录合并为一个单一字段,内部通过换行符(如 \n)拼接时间与内容,并开启 Excel 的自动换行属性。

    2. 存在魔法值定义,未使用枚举(阿里巴巴 Java 开发规范)

    • 问题描述:CluesPageResp.java 中的 enterType 字段仅通过 Swagger 注释 @Schema(description = "线索录入类型:1-销售 2-评估师") 来约束类型。在业务代码中处理该字段时极易出现魔法值(Magic Number),且注释与实际逻辑容易脱节。
    • 优化建议:根据《阿里巴巴 Java 开发手册》规范,建议为 enterType 定义专门的枚举类(如 EnterTypeEnum),并在枚举中定义 SALES(1, "销售") 和 APPRAISER(2, "评估师")。这能提升代码的可读性,并方便后续配合 EasyExcel 的 Converter 或 Jackson 进行序列化处理。

    3. 存在无用 Import 及代码提交不完整风险(代码整洁度与功能风险)

    • 问题描述:
      • CluesPageResp.java 中新增了 import com.fasterxml.jackson.annotation.JsonIgnore;,但在代码中并未实际使用,违反了“不得保留无用 import”的规范。
      • 高风险提醒:Commit Message 中明确提到了“修改数据库查询 SQL”、“重构 toCluesExportDTO 方法”、“实现 setFollowRecord 方法”等核心业务逻辑的变更,但本次代码 Diff 中仅包含了 DTO 类的修改,完全缺失了具体的实现逻辑代码。
    • 优化建议:移除无用的 JsonIgnore 导入。同时,请开发者确认是否漏提交了 Mapper XML、Service 实现类及转换工具类的代码,确保 PR/Commit 的完整性,避免破坏构建。

    二、评分明细

    • 功能实现的正确性与健壮性 (35/40分):DTO 字段映射本身无语法错误,但由于缺失了 Commit Message 中提到的核心逻辑代码(赋值逻辑、SQL 调整),无法评估数据组装时的健壮性(如空指针防护),扣 5 分。
    • 安全性与潜在风险 (30/30分):本次 Diff 仅涉及纯数据传输对象(DTO)的字段增删改,暂未发现明显的 SQL 注入、XSS 或越权等安全风险。
    • 最佳实践与可维护性 (12/20分):硬编码 5 次跟进记录字段严重违反开闭原则;存在未使用的 Import;使用数字而非枚举来标识状态,不符合阿里规范。扣 8 分。
    • 性能与资源利用 (5/5分):DTO 类的简单调整对系统性能和内存占用的影响微乎其微。
    • 提交信息质量 (5/5分):Commit Message 编写得非常规范且详细,清晰地列出了修改目的和具体变更点(尽管代码本身疑似漏提交),值得肯定。

    总分:87分

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