Commit e0722db2 by 潘诗林

采购订单导出优化

1 parent 7366673e
...@@ -301,6 +301,8 @@ public class PurchaseOrderDeliveryController { ...@@ -301,6 +301,8 @@ public class PurchaseOrderDeliveryController {
purchaseOrderShipmentGoodsExportVO.setSignStatus(data.getSignStatus()); purchaseOrderShipmentGoodsExportVO.setSignStatus(data.getSignStatus());
if (data.getUploadFileUrls() != null && data.getUploadFileUrls().contains(",")) { if (data.getUploadFileUrls() != null && data.getUploadFileUrls().contains(",")) {
purchaseOrderShipmentGoodsExportVO.setUploadFileUrls(data.getUploadFileUrls().replace(",", "\n")); purchaseOrderShipmentGoodsExportVO.setUploadFileUrls(data.getUploadFileUrls().replace(",", "\n"));
}else {
purchaseOrderShipmentGoodsExportVO.setUploadFileUrls(data.getUploadFileUrls());
} }
//处理订单发货信息 //处理订单发货信息
if(CollectionUtils.isNotEmpty(purchaseOrderDeliveryDetailList)){ if(CollectionUtils.isNotEmpty(purchaseOrderDeliveryDetailList)){
......
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import org.oreframework.commons.office.easyexcel.annotation.ExcelMergeRow; import org.oreframework.commons.office.easyexcel.annotation.ExcelMergeRow;
import org.oreframework.commons.office.easyexcel.annotation.ExcelValueReplace; import org.oreframework.commons.office.easyexcel.annotation.ExcelValueReplace;
import org.oreframework.commons.office.easyexcel.converter.ReplaceByteToStringConvert; import org.oreframework.commons.office.easyexcel.converter.ReplaceByteToStringConvert;
import org.oreframework.commons.office.easyexcel.converter.ReplaceIntegerToStringConvert;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -100,7 +101,7 @@ public class PurchaseOrderShipmentGoodsExportVO implements Serializable { ...@@ -100,7 +101,7 @@ public class PurchaseOrderShipmentGoodsExportVO implements Serializable {
@ExcelMergeRow(columIndex = 15) @ExcelMergeRow(columIndex = 15)
@ExcelValueReplace(replace={"待签收_0","部分签收_1","全部签收_2"}) @ExcelValueReplace(replace={"待签收_0","部分签收_1","全部签收_2"})
@ExcelProperty(value = "签收状态",converter= ReplaceByteToStringConvert.class) @ExcelProperty(value = "签收状态",converter= ReplaceIntegerToStringConvert.class)
private Integer signStatus; private Integer signStatus;
......
  • @wangxw1
    commented
    Master

    你好!我是你的资深 Java 开发工程师。针对你提供的代码变更,我进行了详细的审查。以下是本次审查的结果:

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

    1. 逻辑冗余与空指针风险(功能正确性)

      • 问题描述:在 PurchaseOrderDeliveryController 中,对 uploadFileUrls 的处理逻辑存在冗余且不够健壮。当前代码仅在包含逗号时进行替换,否则原样赋值。如果 data.getUploadFileUrls() 为 null,虽然进入了 else 分支,但逻辑上应更严谨。
      • 优化建议:建议使用一行代码简化逻辑,并增加判空处理,例如: purchaseOrderShipmentGoodsExportVO.setUploadFileUrls(data.getUploadFileUrls() == null ? "" : data.getUploadFileUrls().replace(",", "\n")); 这样既处理了 null 值,也涵盖了包含和不包含逗号的所有场景。
    2. 类型转换器不匹配风险(功能正确性)

      • 问题描述:在 PurchaseOrderShipmentGoodsExportVO 中,将 signStatus 的转换器从 ReplaceByteToStringConvert 改为 ReplaceIntegerToStringConvert。
      • 优化建议:请务必确认 org.oreframework 框架中 ReplaceIntegerToStringConvert 是否能正确解析 @ExcelValueReplace 注解中的映射关系。部分自定义转换器可能对 Integer 类型有特定的处理逻辑,若底层反射获取类型失败,会导致导出结果显示为原始数字而非文字(如“待签收”)。
    3. 代码风格与硬编码(规范性/可维护性)

      • 问题描述:在 Controller 中直接进行复杂的 VO 转换和字符串替换(如将逗号替换为换行符),违反了阿里巴巴 Java 开发手册中“Controller 层应尽量轻量”的原则。此外,硬编码的分隔符 "," 建议定义为常量。
      • 优化建议:建议将此类数据转换逻辑封装在 Service 层的 Convert 或 Mapper 中,或者在 VO 的 Getter/Setter 方法中处理,保持 Controller 逻辑的简洁。

    二、评分明细

    • 1. 功能实现的正确性与健壮性:32/40分
      • 实现了基本的字符串替换逻辑,但对 null 值的处理不够优雅,存在潜在的健壮性隐患。
    • 2. 安全性与潜在风险:28/30分
      • 未发现明显的 SQL 注入或越权风险,数据导出场景安全性尚可。
    • 3. 最佳实践与可维护性:15/20分
      • Controller 承载了过多的转换逻辑;代码中存在微小的逻辑重复(if-else)。
    • 4. 性能与资源利用:5/5分
      • 字符串替换操作对性能影响微乎其微。
    • 5. 提交信息质量:4/5分
      • 提交信息“采购订单导出优化”较为准确,但如果能补充具体的优化点(如:修复签收状态转换异常)会更好。

    总分:84分

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