Parcourir la source

对账单导出

24282 il y a 1 an
Parent
commit
a0e02e2269

+ 11 - 2
sd-business/src/main/java/com/sd/business/controller/statement/StatementOfAccountController.java

@@ -116,7 +116,7 @@ public class StatementOfAccountController {
      */
     @NonInterception
     @GetMapping("/exportDocumentBySku")
-    public void exportDocumentBySku(HttpServletResponse response, @RequestBody BaseSelectDto dto) {
+    public void exportDocumentBySku(HttpServletResponse response, BaseSelectDto dto) {
         statementOfAccountService.exportDocumentBySku(response, dto.getId());
     }
 
@@ -125,8 +125,17 @@ public class StatementOfAccountController {
      */
     @NonInterception
     @GetMapping("/exportDocumentByBom")
-    public void exportDocumentByBom(HttpServletResponse response, @RequestBody BaseSelectDto dto) {
+    public void exportDocumentByBom(HttpServletResponse response, BaseSelectDto dto) {
         statementOfAccountService.exportDocumentByBom(response, dto.getId());
     }
 
+    /**
+     * 导出订单对账单
+     */
+    @NonInterception
+    @GetMapping("/exportDocumentByOrder")
+    public void exportDocumentByOrder(HttpServletResponse response, BaseSelectDto dto) {
+        statementOfAccountService.exportDocumentByOrder(response, dto.getId());
+    }
+
 }

+ 110 - 0
sd-business/src/main/java/com/sd/business/entity/statement/bo/ExportDocumentByOrderBo.java

@@ -0,0 +1,110 @@
+package com.sd.business.entity.statement.bo;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Getter
+@Setter
+@Builder
+public class ExportDocumentByOrderBo {
+
+    /**
+     * 万里牛订单创建时间
+     */
+    private Date wlnCreateTime;
+
+    /**
+     * 订单号
+     */
+    private String code;
+
+    /**
+     * 万里牛订单号
+     */
+    private String wlnCode;
+
+    /**
+     * 占位符
+     */
+    private Integer placeholder;
+
+    /**
+     * sku规格品号
+     */
+    private String skuSpecCode;
+
+    /**
+     * sku规格品名
+     */
+    private String skuSpecName;
+
+    /**
+     * 数量
+     */
+    private BigDecimal quantity;
+
+    /**
+     * sku单价
+     */
+    private BigDecimal unitPrice;
+
+    /**
+     * 小计
+     */
+    private BigDecimal subtotal;
+
+    /**
+     * 合计
+     */
+    private BigDecimal total;
+
+    /**
+     * bom规格品号
+     */
+    private String bomSpecCode;
+
+    /**
+     * bom规格品名
+     */
+    private String bomSpecName;
+
+    /**
+     * 数量
+     */
+    private BigDecimal bomQuantity;
+
+    /**
+     * bom单价
+     */
+    private BigDecimal bomUnitPrice;
+
+    /**
+     * 激光logo
+     */
+    private BigDecimal laserLogoSummary;
+
+    /**
+     * 激光线粒体
+     */
+    private BigDecimal laserMitochondrialSummary;
+
+    /**
+     * 代发费
+     */
+    private BigDecimal lssueFeeSummary;
+
+    /**
+     * 快递包材费
+     */
+    private BigDecimal deliveryMaterialsFeeSummary;
+
+    /**
+     * 包装人工费
+     */
+    private BigDecimal packingLaborSummary;
+
+}

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/DocumentByOrderVo.java

@@ -34,6 +34,11 @@ public class DocumentByOrderVo {
     private String wlnCode;
 
     /**
+     * 占位符
+     */
+    private Integer placeholder;
+
+    /**
      * sku规格列表
      */
     private List<SkuSpec> skuSpecList;

+ 5 - 0
sd-business/src/main/java/com/sd/business/service/statement/StatementOfAccountService.java

@@ -77,4 +77,9 @@ public interface StatementOfAccountService extends BaseService<StatementOfAccoun
      */
     void exportDocumentByBom(HttpServletResponse response, Long id);
 
+    /**
+     * 导出订单对账单
+     */
+    void exportDocumentByOrder(HttpServletResponse response, Long id);
+
 }

+ 106 - 0
sd-business/src/main/java/com/sd/business/service/statement/impl/DocumentByOrderExcelCellMergeStrategy.java

@@ -0,0 +1,106 @@
+package com.sd.business.service.statement.impl;
+
+import com.alibaba.excel.metadata.Head;
+import com.alibaba.excel.metadata.data.WriteCellData;
+import com.alibaba.excel.write.handler.CellWriteHandler;
+import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
+import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
+import com.sd.business.entity.statement.vo.DocumentByOrderVo;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.util.CellRangeAddress;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class DocumentByOrderExcelCellMergeStrategy implements CellWriteHandler {
+
+    // 无需合并的行数
+    private final int mergeRowIndex = 3;
+    // 订单无需合并的行
+    private final List<Integer> orderRowIndex = new ArrayList<>();
+    // 订单需要合并的列
+    private final List<Integer> orderColIndex = Arrays.asList(0, 1, 2);
+    // sku无需合并的行
+    private final List<Integer> skuRowIndex = new ArrayList<>();
+    // sku需要合并的列
+    private final List<Integer> skuColIndex = Arrays.asList(3, 4, 5, 15, 16, 17, 18, 19);
+
+    public DocumentByOrderExcelCellMergeStrategy(List<DocumentByOrderVo> documentByOrderVoList) {
+        for (DocumentByOrderVo documentByOrderVo : documentByOrderVoList) {
+
+            List<DocumentByOrderVo.SkuSpec> skuSpecList = documentByOrderVo.getSkuSpecList();
+
+            // 赋值订单无需合并的行
+            Integer size = skuSpecList.stream().map(item -> item.getBomSpecList().size()).reduce(0, Integer::sum);
+            if (orderRowIndex.size() == 0) {
+                orderRowIndex.add(size + mergeRowIndex);
+            } else {
+                orderRowIndex.add(size + orderRowIndex.get(orderRowIndex.size() - 1));
+            }
+
+            // 赋值sku无需合并的行
+            for (DocumentByOrderVo.SkuSpec skuSpec : skuSpecList) {
+                if (skuRowIndex.size() == 0) {
+                    skuRowIndex.add(skuSpec.getBomSpecList().size() + mergeRowIndex);
+                } else {
+                    skuRowIndex.add(skuSpec.getBomSpecList().size() + skuRowIndex.get(skuRowIndex.size() - 1));
+                }
+            }
+
+        }
+    }
+
+    @Override
+    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
+
+        // 当前行
+        int curRowIndex = cell.getRowIndex();
+
+        // 当前列
+        int curColIndex = cell.getColumnIndex();
+
+        // 前4行不合并
+        if (curRowIndex <= mergeRowIndex) {
+            return;
+        }
+
+        // 合并订单列
+        if (orderColIndex.contains(curColIndex) && !orderRowIndex.contains(curRowIndex)) {
+            mergeWithPrevRow(writeSheetHolder, curRowIndex, curColIndex);
+        }
+
+        // 合并sku列
+        if (skuColIndex.contains(curColIndex) && !skuRowIndex.contains(curRowIndex)) {
+            mergeWithPrevRow(writeSheetHolder, curRowIndex, curColIndex);
+        }
+
+    }
+
+    /**
+     * 当前单元格向上合并
+     */
+    private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, int curRowIndex, int curColIndex) {
+
+        Sheet sheet = writeSheetHolder.getSheet();
+        List<CellRangeAddress> mergeRegions = sheet.getMergedRegions();
+
+        for (int i = 0; i < mergeRegions.size(); i++) {
+            CellRangeAddress cellRangeAddr = mergeRegions.get(i);
+            // 若上一个单元格已经被合并,则先移出原有的合并单元,再重新添加合并单元
+            if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
+                sheet.removeMergedRegion(i);
+                cellRangeAddr.setLastRow(curRowIndex);
+                sheet.addMergedRegion(cellRangeAddr);
+                return;
+            }
+        }
+
+        // 若上一个单元格未被合并,则新增合并单元
+        CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
+        sheet.addMergedRegion(cellRangeAddress);
+
+    }
+
+}

+ 89 - 22
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountServiceImpl.java

@@ -16,6 +16,7 @@ import com.sd.business.entity.department.po.Department;
 import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.po.OrderSku;
 import com.sd.business.entity.order.po.OrderSkuBom;
+import com.sd.business.entity.statement.bo.ExportDocumentByOrderBo;
 import com.sd.business.entity.statement.dto.FileUploadDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
@@ -31,6 +32,7 @@ import com.sd.business.service.sku.SkuSpecService;
 import com.sd.business.service.statement.StatementOfAccountService;
 import com.sd.business.util.CodeEnum;
 import com.sd.framework.util.Assert;
+import com.sd.framework.util.StreamUtil;
 import com.sd.framework.util.TemplateExcelUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -252,9 +254,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                         item -> item.getUnitPrice() + ":" + item.getSkuSpecId(),
                         Function.identity(),
                         (v1, v2) -> {
-                            v1.setQuantity(v2.getQuantity());
-                            v1.setSubtotal(v2.getSubtotal());
-                            v1.setTotal(v2.getTotal());
+                            v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
+                            v1.setSubtotal(v1.getSubtotal().add(v2.getSubtotal()));
+                            v1.setTotal(v1.getTotal().add(v2.getTotal()));
                             return v1;
                         }
                 )).values();
@@ -376,7 +378,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         List<DocumentByOrderVo> result = orderList.stream().map(item ->
                 DocumentByOrderVo.builder()
                         .orderId(item.getId())
-                        .wlnCreateTime(item.getWlnCreateTime())
+                        .wlnCreateTime(ObjectUtil.defaultIfNull(item.getWlnCreateTime(), item.getCreateTime()))
                         .code(item.getCode())
                         .wlnCode(item.getWlnCode())
                         .build()
@@ -410,14 +412,14 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
 
     @Override
     public void exportDocumentBySku(HttpServletResponse response, Long id) {
-        List<DocumentBySkuVo> list = getDocumentBySku(id);
+
         StatementOfAccount statementOfAccount = getById(id);
         Assert.notNull(statementOfAccount, "没有找到对账单");
         Department department = departmentService.getById(statementOfAccount.getDepartmentId());
         Assert.notNull(department, "没有找到事业部");
 
-        BigDecimal totalQuantity = list.stream().map(DocumentBySkuVo::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
-        BigDecimal totalSubtotal = list.stream().map(DocumentBySkuVo::getSubtotal).reduce(BigDecimal.ZERO, BigDecimal::add);
+        List<DocumentBySkuVo> list = getDocumentBySku(id);
+
         Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
         Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
 
@@ -425,22 +427,83 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         map.put("department", department.getName());
         map.put("beginDate", timePeriodBegin != null ? DateUtil.formatDate(timePeriodBegin) : StringPool.EMPTY);
         map.put("endDate", timePeriodEnd != null ? DateUtil.formatDate(timePeriodEnd) : StringPool.EMPTY);
-        map.put("totalQuantity", totalQuantity);
-        map.put("totalSubtotal", totalSubtotal);
+        map.put("totalQuantity", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getQuantity));
+        map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getSubtotal));
 
-        TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "事业部sku对账单", response, list, map);
+        TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "sku对账单", response, list, map);
     }
 
     @Override
     public void exportDocumentByBom(HttpServletResponse response, Long id) {
+
+        StatementOfAccount statementOfAccount = getById(id);
+        Assert.notNull(statementOfAccount, "没有找到对账单");
+        Department department = departmentService.getById(statementOfAccount.getDepartmentId());
+        Assert.notNull(department, "没有找到事业部");
+
         List<DocumentByBomVo> list = getDocumentByBom(id);
+
+        Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
+        Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("department", department.getName());
+        map.put("beginDate", timePeriodBegin != null ? DateUtil.formatDate(timePeriodBegin) : StringPool.EMPTY);
+        map.put("endDate", timePeriodEnd != null ? DateUtil.formatDate(timePeriodEnd) : StringPool.EMPTY);
+        map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getSubtotal));
+        map.put("totalLaserLogoSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLaserLogoSummary));
+        map.put("totalLaserMitochondrialSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLaserMitochondrialSummary));
+        map.put("totalLssueFeeSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLssueFeeSummary));
+        map.put("totalDeliveryMaterialsFeeSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getDeliveryMaterialsFeeSummary));
+        map.put("totalPackingLaborSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getPackingLaborSummary));
+
+        TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "bom对账单", response, list, map);
+    }
+
+    @Override
+    public void exportDocumentByOrder(HttpServletResponse response, Long id) {
+
         StatementOfAccount statementOfAccount = getById(id);
         Assert.notNull(statementOfAccount, "没有找到对账单");
         Department department = departmentService.getById(statementOfAccount.getDepartmentId());
         Assert.notNull(department, "没有找到事业部");
 
-        BigDecimal totalQuantity = list.stream().map(DocumentByBomVo::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
-        BigDecimal totalSubtotal = list.stream().map(DocumentByBomVo::getSubtotal).reduce(BigDecimal.ZERO, BigDecimal::add);
+        List<DocumentByOrderVo> list = getDocumentByOrder(id);
+
+        BigDecimal all = BigDecimal.ZERO;
+
+        List<ExportDocumentByOrderBo> exportDocumentByOrderBos = new ArrayList<>();
+        for (DocumentByOrderVo documentByOrderVo : list) {
+            List<DocumentByOrderVo.SkuSpec> skuSpecList = documentByOrderVo.getSkuSpecList();
+            for (DocumentByOrderVo.SkuSpec skuSpec : skuSpecList) {
+                List<DocumentByOrderVo.BomSpec> bomSpecList = skuSpec.getBomSpecList();
+                for (DocumentByOrderVo.BomSpec bomSpec : bomSpecList) {
+                    ExportDocumentByOrderBo exportDocumentByOrderBo = ExportDocumentByOrderBo.builder()
+                            .wlnCreateTime(documentByOrderVo.getWlnCreateTime())
+                            .code(documentByOrderVo.getCode())
+                            .wlnCode(documentByOrderVo.getWlnCode())
+                            .skuSpecCode(skuSpec.getSkuSpecCode())
+                            .skuSpecName(skuSpec.getSkuSpecName())
+                            .quantity(skuSpec.getQuantity())
+                            .unitPrice(skuSpec.getUnitPrice())
+                            .subtotal(skuSpec.getSubtotal())
+                            .total(skuSpec.getTotal())
+                            .bomSpecCode(bomSpec.getBomSpecCode())
+                            .bomSpecName(bomSpec.getBomSpecName())
+                            .bomQuantity(bomSpec.getQuantity())
+                            .bomUnitPrice(bomSpec.getUnitPrice())
+                            .laserLogoSummary(bomSpec.getLaserLogoSummary())
+                            .laserMitochondrialSummary(bomSpec.getLaserMitochondrialSummary())
+                            .lssueFeeSummary(bomSpec.getLssueFeeSummary())
+                            .deliveryMaterialsFeeSummary(bomSpec.getDeliveryMaterialsFeeSummary())
+                            .packingLaborSummary(bomSpec.getPackingLaborSummary())
+                            .build();
+                    exportDocumentByOrderBos.add(exportDocumentByOrderBo);
+                }
+                all = all.add(skuSpec.getTotal());
+            }
+        }
+
         Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
         Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
 
@@ -448,10 +511,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         map.put("department", department.getName());
         map.put("beginDate", timePeriodBegin != null ? DateUtil.formatDate(timePeriodBegin) : StringPool.EMPTY);
         map.put("endDate", timePeriodEnd != null ? DateUtil.formatDate(timePeriodEnd) : StringPool.EMPTY);
-        map.put("totalQuantity", totalQuantity);
-        map.put("totalSubtotal", totalSubtotal);
+        map.put("all", all);
 
-        TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "事业部sku对账单", response, list, map);
+        TemplateExcelUtil.writeBrowser("orderDocument.xlsx", "订单对账单",
+                new DocumentByOrderExcelCellMergeStrategy(list), response, exportDocumentByOrderBos, map);
     }
 
     /**
@@ -506,15 +569,18 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                         .quantity(item.getQuantity())
                         .unitPrice(item.getUnitPrice())
                         .laserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")
-                                ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
+                                ? item.getCustomProcessingFee() : BigDecimal.ZERO))
                         .laserMitochondrialSummary((Objects.equals(item.getCustomProcessingType(), "10")
-                                ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
-                        .lssueFeeSummary(item.getLssueFee().multiply(item.getQuantity()))
-                        .deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee().multiply(item.getQuantity()))
-                        .packingLaborSummary(item.getPackingLabor().multiply(item.getQuantity()))
+                                ? item.getCustomProcessingFee() : BigDecimal.ZERO))
+                        .lssueFeeSummary(item.getLssueFee())
+                        .deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee())
+                        .packingLaborSummary(item.getPackingLabor())
                         .build()
                 ).collect(Collectors.toList());
 
+        Map<Long, BigDecimal> collect = bomSpecList.stream().collect(
+                Collectors.toMap(DocumentByOrderVo.BomSpec::getOrderSkuId, DocumentByOrderVo.BomSpec::getQuantity));
+
         List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
 
         List<DocumentByOrderVo.BomSpec> packBomSpecList = orderSkuBomList.stream()
@@ -523,8 +589,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                         .bomSpecId(item.getBomSpecId())
                         .quantity(item.getQuantity())
                         .unitPrice(item.getUnitPrice())
-                        .build()
-                ).collect(Collectors.toList());
+                        .build())
+                .peek(item -> item.setQuantity(collect.get(item.getOrderSkuId()).multiply(item.getQuantity())))
+                .collect(Collectors.toList());
 
         bomSpecList.addAll(packBomSpecList);
 

+ 20 - 16
sd-framework/src/main/java/com/sd/framework/util/ExcelFillCellMergeStrategy.java

@@ -14,11 +14,8 @@ import java.util.List;
 
 public class ExcelFillCellMergeStrategy implements CellWriteHandler {
 
-    private int[] mergeColumnIndex;
-    private int mergeRowIndex;
-
-    public ExcelFillCellMergeStrategy() {
-    }
+    private final int[] mergeColumnIndex;
+    private final int mergeRowIndex;
 
     public ExcelFillCellMergeStrategy(int mergeRowIndex, int[] mergeColumnIndex) {
         this.mergeRowIndex = mergeRowIndex;
@@ -26,28 +23,35 @@ public class ExcelFillCellMergeStrategy implements CellWriteHandler {
     }
 
     @Override
-    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
+    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder,
+                                 List<WriteCellData<?>> cellDataList, Cell cell, Head head,
+                                 Integer relativeRowIndex, Boolean isHead) {
+
         int curRowIndex = cell.getRowIndex();
         int curColIndex = cell.getColumnIndex();
-        if (curRowIndex <= mergeRowIndex) {
-            return;
-        }
-        for (int columnIndex : mergeColumnIndex) {
-            if (curColIndex == columnIndex) {
-                mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
-                break;
+        if (curRowIndex > mergeRowIndex) {
+            for (int columnIndex : mergeColumnIndex) {
+                if (curColIndex == columnIndex) {
+                    mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
+                    break;
+                }
             }
         }
-    }
 
+    }
 
     /**
      * 当前单元格向上合并
+     *
+     * @param writeSheetHolder
+     * @param cell             当前单元格
+     * @param curRowIndex      当前行
+     * @param curColIndex      当前列
      */
     private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
-        Object curData = CellType.STRING.equals(cell.getCellType()) ? cell.getStringCellValue() : cell.getNumericCellValue();
+        Object curData = cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
         Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
-        Object preData = CellType.STRING.equals(preCell.getCellType()) ? preCell.getStringCellValue() : preCell.getNumericCellValue();
+        Object preData = preCell.getCellType() == CellType.STRING ? preCell.getStringCellValue() : preCell.getNumericCellValue();
         // 将当前单元格数据与上一个单元格数据比较
         Boolean dataBool = preData.equals(curData);
         // 此处需要注意:因为我是按照序号确定是否需要合并的,所以获取每一行第一列数据和上一行第一列数据进行比较,如果相等合并

+ 21 - 0
sd-framework/src/main/java/com/sd/framework/util/StreamUtil.java

@@ -0,0 +1,21 @@
+package com.sd.framework.util;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Function;
+
+public class StreamUtil {
+
+    /**
+     * 数组某个字段值相加
+     *
+     * @param list   数组
+     * @param mapper 字段
+     * @return 相加结果
+     */
+    public static <T> BigDecimal bigDecimalAdd(List<T> list, Function<T, BigDecimal> mapper) {
+        return list.stream().map(mapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+
+}

BIN
sd-starter/src/main/resources/template/bomDocument.xlsx


BIN
sd-starter/src/main/resources/template/orderDocument.xlsx


BIN
sd-starter/src/main/resources/template/skuDocument.xlsx