wujianwei
2026-04-01 c11e6f07b031eea6c7de4c5508b8dbf0ee01d2c7
tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java
@@ -6,7 +6,7 @@
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.tms.domain.*;
import com.ruoyi.tms.mapper.*;
@@ -332,7 +332,7 @@
            sheet.setColumnWidth(remarkColumn, 10000); // 备注
            
            // 标题区域
            createTitleArea(sheet, styles,tmsArBill);
            createTitleArea(sheet, styles,bill);
            
            // 表头
            createDynamicTableHeader(sheet, styles, feeNameList, baseColumns, remarkColumn);
@@ -366,24 +366,25 @@
                        Cell cell1 = row.createCell(1);
                        if (dispatchOrder != null) {
                          TmsTrip tmsTrip = tmsTripMapper.selectTmsTripByTripType(3,dispatchOrder.getId() );
                            cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", tmsTrip.getTripTime()));
                            cell1.setCellStyle(styles.get("data"));
                          if (tmsTrip!=null) {
                              cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", tmsTrip.getTripTime()));
                              cell1.setCellStyle(styles.get("data"));
                          }
                        }
                        
                        // 装货点
                        Cell cell2 = row.createCell(2);
                        if (dispatchOrder != null && dispatchOrder.getShipperAddress() != null) {
                            cell2.setCellValue(dispatchOrder.getShipperAddress());
                        if (dispatchOrder != null && dispatchOrder.getShipperRegionLabel() != null) {
                            cell2.setCellValue(dispatchOrder.getShipperRegionLabel());
                            cell2.setCellStyle(styles.get("data"));
                        }
                        // 卸货点
                        Cell cell3 = row.createCell(3);
                        if (dispatchOrder != null && dispatchOrder.getReceiverAddress() != null) {
                            cell3.setCellValue(dispatchOrder.getReceiverAddress());
                        if (dispatchOrder != null && dispatchOrder.getReceiverRegionLabel() != null) {
                            cell3.setCellValue(dispatchOrder.getReceiverRegionLabel());
                            cell3.setCellStyle(styles.get("data"));
                        }
@@ -454,7 +455,7 @@
                cell.setCellValue(feeTotals.get(feeName).doubleValue());
                cell.setCellStyle(styles.get("total"));
            }
            // 合计行
            int totalRow = subTotalRow + 1;
            Row total = sheet.createRow(totalRow);
@@ -462,7 +463,7 @@
            totalCell.setCellValue("合计(CNB)");
            totalCell.setCellStyle(styles.get("total"));
            sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, 2, 5));
            // 填充费用合计
            for (int j = 0; j < feeNameList.size(); j++) {
                String feeName = feeNameList.get(j);
@@ -478,18 +479,26 @@
            createAccountInfo(sheet, styles, totalRow + 4);
            
            // 签字盖章区域
            createSignatureArea(sheet, styles, totalRow + 8);
            // 生成文件
            File file = new File(fileName);
            createSignatureArea(sheet, styles, totalRow + 8,bill);
            // 保存文件
            String path = RuoYiConfig.getDownloadPath() + fileName;
            File file = new File(path);
            File parentFile = file.getParentFile();
            if (!parentFile.exists()) {
                parentFile.mkdirs();
            }
            try (FileOutputStream fos = new FileOutputStream(file)) {
                workbook.write(fos);
            }
            return fileName;
        } catch (Exception e) {
            logger.error("导出对账单一式多联格式失败", e);
            throw new RuntimeException("导出失败,请检查数据", e);
        }
    }
    /**
@@ -700,14 +709,15 @@
    /**
     * 创建签字盖章区域
     *
     * @param sheet 工作表
     * @param styles 样式映射
     * @param sheet    工作表
     * @param styles   样式映射
     * @param startRow 起始行
     * @param bill
     */
    private void createSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow) {
    private void createSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, TmsArBill bill) {
        Row payerRow = sheet.createRow(startRow);
        Cell payerCell = payerRow.createCell(0);
        payerCell.setCellValue("付款单位(甲方):XXXXXXXXXXXXXX");
        payerCell.setCellValue("付款单位(甲方):"+bill.getCustomerName());
        payerCell.setCellStyle(styles.get("text"));
        Cell payeeCell = payerRow.createCell(6);