Commit 875333e9 by chenxi

5.8.6版本 发货单详情、调拨单详情新增产品ID字段

1 parent 95d4db50
......@@ -150,6 +150,7 @@ public class WarehouseDeliveryController {
warehousedeliverGoodsExportVO.setType(data.getType());
warehousedeliverGoodsExportVO.setSpecificationData(data.getSpecificationData());
warehousedeliverGoodsExportVO.setUpgradeGoodsName(data.getUpgradeGoodsName());
warehousedeliverGoodsExportVO.setUpgradeGoodsCommodityCode(data.getUpgradeGoodsCommodityCode());
warehousedeliverGoodsExportVO.setThirdPartyName(data.getThirdPartyName());
warehousedeliverGoodsExportVO.setThirdPartyCode(data.getThirdPartyCode());
warehousedeliverGoodsExportVO.setPurchaseGoodsName(data.getPurchaseGoodsName());
......
......@@ -50,6 +50,10 @@ public class WarehousedeliverGoodsExportVO implements Serializable {
private String upgradeGoodsName;
@ExcelMergeRow(columIndex = 7)
@ExcelProperty(value = "产品ID")
private String upgradeGoodsCommodityCode;
@ExcelMergeRow(columIndex = 8)
@ExcelProperty(value = "供应商名称")
private String thirdPartyName;
......@@ -58,54 +62,54 @@ public class WarehousedeliverGoodsExportVO implements Serializable {
*/
private String thirdPartyCode;
@ExcelMergeRow(columIndex = 8)
@ExcelMergeRow(columIndex = 9)
@ExcelProperty(value = "规格")
private String specificationData;
@ExcelMergeRow(columIndex = 9)
@ExcelMergeRow(columIndex = 10)
@ExcelProperty(value = "适用车型")
private String suitCarTypeNames;
/**
* 已发货数量 卷/件
*/
@ExcelMergeRow(columIndex = 10)
@ExcelMergeRow(columIndex = 11)
@ExcelProperty(value = "审核数量")
private String goodsNumber;
/**
* 库存总量 米/件
*/
@ExcelMergeRow(columIndex = 11)
@ExcelMergeRow(columIndex = 12)
@ExcelProperty(value = "库存总量")
private String stockNum;
@ExcelMergeRow(columIndex = 12)
@ExcelMergeRow(columIndex = 13)
@ExcelProperty(value = "发货数量")
private String purchaseNumber;
@ExcelMergeRow(columIndex = 13)
@ExcelMergeRow(columIndex = 14)
@ExcelProperty(value = "欠货数量")
private String toBeShippedNumber;
@ExcelMergeRow(columIndex = 14)
@ExcelMergeRow(columIndex = 15)
@ExcelProperty(value = "下单时间")
@DateTimeFormat(value="yyyy-MM-dd HH:mm:ss")
private Date orderTime;
@ExcelMergeRow(columIndex = 15)
@ExcelMergeRow(columIndex = 16)
@ExcelProperty(value = "备注")
private String purchaseOrderRemark;
@ExcelMergeRow(columIndex = 16)
@ExcelMergeRow(columIndex = 17)
@ExcelProperty(value = "收货人")
private String contactName;
@ExcelMergeRow(columIndex = 17)
@ExcelMergeRow(columIndex = 18)
@ExcelProperty(value = "收货人电话")
private String contactPhone;
@ExcelMergeRow(columIndex = 18)
@ExcelMergeRow(columIndex = 19)
@ExcelProperty(value = "收货人地址")
private String contactAddress;
......
......@@ -32,6 +32,9 @@ public class PurchaseOrderDeliveryDetailPageExportVO implements Serializable {
@ExcelProperty(value="产品名称")
private String upgradeGoodsName;
@ExcelProperty(value="产品ID")
private String upgradeCommodityCode;
@ExcelProperty(value="供应商名称")
private String thirdPartyName;
......
  • @wangxw1
    commented
    Master

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

    1. 可维护性与潜在Bug风险:Excel导出列索引硬编码导致“散弹式修改”

    • 问题描述:在 WarehousedeliverGoodsExportVO.java 中,为了在中间插入一个“产品ID”字段,导致后续所有字段的 @ExcelMergeRow(columIndex = X) 注解的值都需要手动加 1(从 8 级联修改到了 19)。这种硬编码极大地破坏了代码的开闭原则(OCP),不仅增加了代码审查和合并冲突的成本,还极易因为漏改或错改导致合并单元格错位。
    • 优化建议: 建议重构自定义注解 @ExcelMergeRow 的处理逻辑(通常在对应的 WriteHandler 中)。可以通过反射动态获取字段在类中的声明顺序(或读取 @ExcelProperty 的隐式/显式 index)来决定合并的列索引,彻底消除对 columIndex 属性的硬编码依赖。如果短期内无法重构,务必仔细核对 EasyExcel 实际导出的列顺序与 columIndex 是否严格一致。

    2. 规范性:相同业务概念的字段命名不一致

    • 问题描述:根据阿里巴巴 Java 开发手册规定,相同业务含义的变量命名应保持一致,以降低沟通和理解成本。在本次修改中,同样表示“产品ID”,在 WarehousedeliverGoodsExportVO 中命名为 upgradeGoodsCommodityCode,而在 PurchaseOrderDeliveryDetailPageExportVO 中却命名为 upgradeCommodityCode(缺少了 Goods)。
    • 优化建议: 统一字段命名规则。建议将 PurchaseOrderDeliveryDetailPageExportVO 中的字段也统一修改为 upgradeGoodsCommodityCode,保持各 VO 间同一业务字段的命名一致性。

    3. 最佳实践:Controller 层的冗长手动对象映射

    • 问题描述:在 WarehouseDeliveryController.java 中,使用了大量 vo.setXxx(data.getXxx()) 的硬编码方式进行对象属性拷贝。当字段不断增加时(如本次新增字段),Controller 层代码会变得越来越臃肿,且容易发生漏写或错写(例如把 A 字段 set 给了 B 字段)。
    • 优化建议: 推荐引入 MapStruct 等编译时代码生成工具进行 DTO/VO 之间的转换。这不仅能使 Controller 层代码更加简洁(只需一行 converter.toVO(data)),性能也与手动写 getter/setter 几乎一致,且能有效避免漏写字段的问题。

    二、评分明细

    • 1. 功能实现的正确性与健壮性(36/40分): 功能逻辑基本正确,成功添加了所需的字段。扣分点在于 Excel 导出的自定义合并注解依赖手动维护索引,随着字段增多,出现下标错位导致导出格式错乱的风险较高。
    • 2. 安全性与潜在风险(30/30分): 本次变更为简单的 VO 字段扩展和赋值,未涉及数据库查询拼接或外部输入反序列化,无明显的安全漏洞(如 SQL 注入、XSS 等)风险。
    • 3. 最佳实践与可维护性(12/20分): 扣分主要集中在违反开闭原则的级联修改(牵一发而动全身)、缺乏对象映射工具导致样板代码过多,以及不同类之间字段命名不一致的问题上。
    • 4. 性能与资源利用(5/5分): 仅增加了一个字符串字段的赋值与导出,对 CPU 和内存开销的影响微乎其微,性能无影响。
    • 5. 提交信息质量(4/5分): 提交信息("5.8.6版本 发货单详情、调拨单详情新增产品ID字段 (by chenxi)")清晰地说明了版本、修改内容及修改人。若能附带对应的 Jira 任务号或需求编号会更加完美。

    总分:87分

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