sen
7 天以前 ca2eb1da04248a0b7d6d605f3648a645af88b2d4
Merge remote-tracking branch 'origin/yagwly_fa_master' into yagwly_fa_master
1个文件已修改
398 ■■■■■ 已修改文件
tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java 398 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java
@@ -543,7 +543,7 @@
            createDynamicTableHeader(sheet, styles, feeNameList, baseColumns, remarkColumn);
            
            // 数据区域
            int startRow = 4;
            int startRow = 5;
            // 费用合计映射
            Map<String, BigDecimal> feeTotals = new HashMap<>();
            for (String feeName : feeNameList) {
@@ -569,36 +569,31 @@
                        }
                        // 装货日期
                        Cell cell1 = row.createCell(1);
                        if (dispatchOrder != null) {
                          TmsTrip tmsTrip = tmsTripMapper.selectTmsTripByTripType(3,dispatchOrder.getId() );
                          if (tmsTrip!=null) {
                              cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", tmsTrip.getTripTime()));
                              cell1.setCellStyle(styles.get("data"));
                          }
                        if (dispatchOrder != null && dispatchOrder.getOrderTime() !=null) {
                            cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", dispatchOrder.getOrderTime()));
                        }
                        cell1.setCellStyle(styles.get("data"));
                        // 装货点
                        Cell cell2 = row.createCell(2);
                        if (dispatchOrder != null && dispatchOrder.getShipperRegionLabel() != null) {
                            cell2.setCellValue(dispatchOrder.getShipperRegionLabel());
                            cell2.setCellStyle(styles.get("data"));
                        }
                        cell2.setCellStyle(styles.get("data"));
                        // 卸货点
                        Cell cell3 = row.createCell(3);
                        if (dispatchOrder != null && dispatchOrder.getReceiverRegionLabel() != null) {
                            cell3.setCellValue(dispatchOrder.getReceiverRegionLabel());
                            cell3.setCellStyle(styles.get("data"));
                        }
                        cell3.setCellStyle(styles.get("data"));
                        // 车牌
                        Cell cell4 = row.createCell(4);
                        if (dispatchOrder != null && dispatchOrder.getLicensePlate() != null) {
                            cell4.setCellValue(dispatchOrder.getLicensePlate());
                            cell4.setCellStyle(styles.get("data"));
                        }
                        cell4.setCellStyle(styles.get("data"));
                        // 型号
                        Cell cell5 = row.createCell(5);
@@ -607,8 +602,8 @@
                            String vehicleType = dispatchOrder.getActualVehicleType();
                            String vehicleTypeLabel = DictUtils.getDictLabel("vehicle_type", vehicleType);
                            cell5.setCellValue(StringUtils.isNotEmpty(vehicleTypeLabel) ? vehicleTypeLabel : vehicleType);
                            cell5.setCellStyle(styles.get("data"));
                        }
                        cell5.setCellStyle(styles.get("data"));
                        // 构建费用名称到金额的映射(港币转人民币)
                        Map<String, BigDecimal> feeMap = new HashMap<>();
@@ -651,25 +646,34 @@
            // 小计行
            int subTotalRow = startRow + rowIndex;
            Row subTotal = sheet.createRow(subTotalRow);
            Cell subTotalCell = subTotal.createCell(0);
            subTotalCell.setCellValue("小计");
            subTotalCell.setCellStyle(styles.get("total"));
            // 为所有列创建单元格
            for (int i = 0; i <= remarkColumn; i++) {
                Cell cell = subTotal.createCell(i);
                if (i == 0) {
                    cell.setCellValue("小计");
                }
                cell.setCellStyle(styles.get("total"));
            }
            sheet.addMergedRegion(new CellRangeAddress(subTotalRow, subTotalRow, 0, 5));
            
            // 填充费用小计
            for (int j = 0; j < feeNameList.size(); j++) {
                String feeName = feeNameList.get(j);
                Cell cell = subTotal.createCell(baseColumns + j);
                Cell cell = subTotal.getCell(baseColumns + j);
                cell.setCellValue(feeTotals.get(feeName).doubleValue());
                cell.setCellStyle(styles.get("total"));
            }
            // 合计行
            int totalRow = subTotalRow + 1;
            Row total = sheet.createRow(totalRow);
            Cell totalCell = total.createCell(0);
            totalCell.setCellValue("合计(RMB)");
            totalCell.setCellStyle(styles.get("total"));
            // 为所有列创建单元格
            for (int i = 0; i <= remarkColumn; i++) {
                Cell cell = total.createCell(i);
                if (i == 0) {
                    cell.setCellValue("合计(RMB)");
                }
                cell.setCellStyle(styles.get("total"));
            }
            sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, 0, 5));
            // 计算所有费用的合计
@@ -679,9 +683,12 @@
            }
            
            // 填充费用合计(所有费用的总和)
            Cell totalAmountCell = total.createCell(baseColumns);
            totalAmountCell.setCellValue(grandTotal.doubleValue());
            totalAmountCell.setCellStyle(styles.get("total"));
            for (int j = 0; j < feeNameList.size(); j++) {
                Cell cell = total.getCell(baseColumns + j);
                if (j == 0) {
                    cell.setCellValue(grandTotal.doubleValue());
                }
            }
            // 合并费用列单元格
            if (feeNameList.size() > 1) {
                sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, baseColumns, baseColumns + feeNameList.size() - 1));
@@ -690,11 +697,8 @@
            // 备注说明区域
            createNotesArea(sheet, styles, totalRow + 1, grandTotal);
            
            // 账户信息区域
            createAccountInfo(sheet, styles, totalRow + 4);
            // 签字盖章区域
            createSignatureArea(sheet, styles, totalRow + 8,bill);
            // 账户信息和签字盖章区域(合并成一个大格)
            createAccountAndSignatureArea(sheet, styles, totalRow + 4, bill);
            // 保存文件
            String path = RuoYiConfig.getDownloadPath() + fileName;
@@ -729,6 +733,10 @@
        CellStyle titleStyle = workbook.createCellStyle();
        titleStyle.setAlignment(HorizontalAlignment.CENTER);
        titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        titleStyle.setBorderTop(BorderStyle.THIN);
        titleStyle.setBorderBottom(BorderStyle.THIN);
        titleStyle.setBorderLeft(BorderStyle.THIN);
        titleStyle.setBorderRight(BorderStyle.THIN);
        Font titleFont = workbook.createFont();
        titleFont.setFontName("微软雅黑");
        titleFont.setFontHeightInPoints((short) 16);
@@ -784,11 +792,29 @@
        CellStyle textStyle = workbook.createCellStyle();
        textStyle.setAlignment(HorizontalAlignment.LEFT);
        textStyle.setVerticalAlignment(VerticalAlignment.TOP);
        textStyle.setBorderTop(BorderStyle.THIN);
        textStyle.setBorderBottom(BorderStyle.THIN);
        textStyle.setBorderLeft(BorderStyle.THIN);
        textStyle.setBorderRight(BorderStyle.THIN);
        Font textFont = workbook.createFont();
        textFont.setFontName("微软雅黑");
        textFont.setFontHeightInPoints((short) 11);
        textStyle.setFont(textFont);
        styles.put("text", textStyle);
        // 文本样式
        CellStyle textStyle2 = workbook.createCellStyle();
        textStyle2.setAlignment(HorizontalAlignment.LEFT);
        textStyle2.setVerticalAlignment(VerticalAlignment.TOP);
        textStyle2.setBorderTop(BorderStyle.THIN);
        textStyle2.setBorderBottom(BorderStyle.THIN);
        textStyle2.setBorderLeft(BorderStyle.THIN);
        Font textFont2 = workbook.createFont();
        textFont2.setFontName("微软雅黑");
        textFont2.setFontHeightInPoints((short) 11);
        textStyle2.setFont(textFont2);
        styles.put("text2", textStyle2);
        
        return styles;
    }
@@ -801,32 +827,61 @@
     * @param tmsReceivableFee 应收费用查询条件
     */
    private void createTitleArea(SXSSFSheet sheet, Map<String, CellStyle> styles, TmsArBill tmsArBill) {
        // 标题行
        // 标题行(无边框,居中)
        Row titleRow = sheet.createRow(0);
        titleRow.setHeightInPoints(30);
        Cell titleCell = titleRow.createCell(0);
        titleCell.setCellValue(tmsArBill.getCustomerName());
        titleCell.setCellStyle(styles.get("title"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = titleRow.createCell(i);
            if (i == 0) {
                cell.setCellValue(tmsArBill.getCustomerName());
                // 居中显示
                CellStyle centerStyle = sheet.getWorkbook().createCellStyle();
                centerStyle.setAlignment(HorizontalAlignment.CENTER);
                centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
                cell.setCellStyle(centerStyle);
            }
            // 不设置边框样式
        }
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
        // 对账单行 - 居中显示
        // 对账单行 - 居中显示(无边框)
        Row billRow = sheet.createRow(1);
        billRow.setHeightInPoints(20);
        Cell billTitleCell = billRow.createCell(0);
        billTitleCell.setCellValue(tmsArBill.getBillName());
        billTitleCell.setCellStyle(styles.get("title"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = billRow.createCell(i);
            if (i == 0) {
                cell.setCellValue(tmsArBill.getBillName());
                // 居中显示
                CellStyle centerStyle = sheet.getWorkbook().createCellStyle();
                centerStyle.setAlignment(HorizontalAlignment.CENTER);
                centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
                cell.setCellStyle(centerStyle);
            }
            // 不设置边框样式
        }
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
        // 公司信息行
        Row companyRow = sheet.createRow(2);
        companyRow.setHeightInPoints(20);
        Cell toCell = companyRow.createCell(0);
        toCell.setCellValue("TO: "+tmsArBill.getCustomerName());
        toCell.setCellStyle(styles.get("text"));
        // FROM行(在TO上面,无边框)
        Row fromRow = sheet.createRow(2);
        fromRow.setHeightInPoints(20);
        for (int i = 0; i <= 9; i++) {
            Cell cell = fromRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("FROM:珠海市汇畅交通投资有限公司");
            }
            // 不设置边框样式
        }
        Cell fromCell = companyRow.createCell(5);
        fromCell.setCellValue("FROM:珠海市汇畅交通投资有限公司");
        fromCell.setCellStyle(styles.get("text"));
        // TO行(无边框)
        Row toRow = sheet.createRow(3);
        toRow.setHeightInPoints(20);
        for (int i = 0; i <= 9; i++) {
            Cell cell = toRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("TO: "+tmsArBill.getCustomerName());
            }
            // 不设置边框样式
        }
    }
    /**
@@ -839,7 +894,7 @@
     * @param remarkColumn 备注列位置
     */
    private void createDynamicTableHeader(SXSSFSheet sheet, Map<String, CellStyle> styles, List<String> feeNameList, int baseColumns, int remarkColumn) {
        Row headerRow = sheet.createRow(3);
        Row headerRow = sheet.createRow(4);
        headerRow.setHeightInPoints(25);
        
        // 基础列
@@ -933,51 +988,126 @@
     * @param grandTotal 总金额
     */
    private void createNotesArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, BigDecimal grandTotal) {
        Row note1Row = sheet.createRow(startRow);
        Cell note1Cell = note1Row.createCell(0);
        // 创建无边界样式
        CellStyle noBorderStyle = sheet.getWorkbook().createCellStyle();
        // 创建两行
        for (int rowIdx = 0; rowIdx < 2; rowIdx++) {
            Row row = sheet.createRow(startRow + rowIdx);
            for (int i = 0; i <= 9; i++) {
                Cell cell = row.createCell(i);
                if (i == 0) {
                    // 第一列设置带边框的样式
                    cell.setCellStyle(styles.get("text2"));
                } else {
                    // 其他列设置无边界样式
                    cell.setCellStyle(noBorderStyle);
                }
            }
        }
        // 第一行备注
        Row firstRow = sheet.getRow(startRow);
        Cell cell1 = firstRow.getCell(0);
        String chineseAmount = convertToChineseUppercase(grandTotal);
        note1Cell.setCellValue("1.依据合同相关规定,贵司需向我司支付¥" + grandTotal.setScale(2, RoundingMode.HALF_UP) + "(大写金额:" + chineseAmount + ")的费用,请贵司及时安排支付。");
        note1Cell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow, startRow, 0, 9));
        Row note2Row = sheet.createRow(startRow + 1);
        Cell note2Cell = note2Row.createCell(0);
        note2Cell.setCellValue("2.传真件与原件起同等法律效力。");
        note2Cell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow + 1, startRow + 1, 0, 9));
        cell1.setCellValue("1.依据合同相关规定,贵司需向我司支付¥" + grandTotal.setScale(2, RoundingMode.HALF_UP) + "(大写金额:" + chineseAmount + ")的费用,请贵司及时安排支付。");
        // 第二行备注
        Row secondRow = sheet.getRow(startRow + 1);
        Cell cell2 = secondRow.getCell(0);
        cell2.setCellValue("2.传真件与原件起同等法律效力。");
    }
    /**
     * 创建账户信息区域
     * 创建账户信息和签字盖章区域
     *
     * @param sheet 工作表
     * @param styles 样式映射
     * @param sheet    工作表
     * @param styles   样式映射
     * @param startRow 起始行
     * @param bill
     */
    private void createAccountInfo(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow) {
        Row accountTitleRow = sheet.createRow(startRow);
        Cell accountTitleCell = accountTitleRow.createCell(0);
        accountTitleCell.setCellValue("烦请核对确认并转至我司如下帐号:");
        accountTitleCell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow, startRow, 0, 9));
    private void createAccountAndSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, TmsArBill bill) {
        // 计算结束行(账户信息4行 + 签字盖章6行)
        int endRow = startRow + 9;
        // 创建所有行,设置行高
        for (int rowIdx = 0; rowIdx <= 9; rowIdx++) {
            Row row = sheet.createRow(startRow + rowIdx);
            row.setHeightInPoints(20);
            for (int i = 0; i <= 9; i++) {
                Cell cell = row.createCell(i);
                // 不设置边框样式,只显示数据
            }
        }
        // 账户信息区域(左上角)
        Row infoRow1 = sheet.getRow(startRow);
        Cell infoCell1 = infoRow1.getCell(0);
        infoCell1.setCellValue("烦请核对确认并转至我司如下帐号:");
        Row infoRow2 = sheet.getRow(startRow + 1);
        Cell infoCell2 = infoRow2.getCell(0);
        infoCell2.setCellValue("开户银行:中国农业发展银行珠海市分行");
        Row infoRow3 = sheet.getRow(startRow + 2);
        Cell infoCell3 = infoRow3.getCell(0);
        infoCell3.setCellValue("账号:20344990100000422001");
        Row infoRow4 = sheet.getRow(startRow + 3);
        Cell infoCell4 = infoRow4.getCell(0);
        infoCell4.setCellValue("户名:珠海市汇畅交通投资有限公司");
        // 付款单位(左下角)
        Row payerRow = sheet.getRow(startRow + 4);
        Cell payerCell = payerRow.getCell(0);
        payerCell.setCellValue("付款单位(甲方):" + bill.getCustomerName());
        // 收款单位(右下角)
        Row payeeRow = sheet.getRow(startRow + 4);
        Cell payeeCell = payeeRow.getCell(6);
        payeeCell.setCellValue("收款单位(乙方):珠海市汇畅交通投资有限公司");
        // 制表人员
        Row creatorRow = sheet.getRow(startRow + 5);
        Cell creatorCell1 = creatorRow.getCell(0);
        creatorCell1.setCellValue("制表人员:");
        Cell creatorCell2 = creatorRow.getCell(6);
        creatorCell2.setCellValue("制表人员:");
        // 审核人员
        Row checkerRow = sheet.getRow(startRow + 6);
        Cell checkerCell1 = checkerRow.getCell(0);
        checkerCell1.setCellValue("审核人员:");
        Cell checkerCell2 = checkerRow.getCell(6);
        checkerCell2.setCellValue("审核人员:");
        // 复核人员
        Row reviewerRow = sheet.getRow(startRow + 7);
        Cell reviewerCell1 = reviewerRow.getCell(0);
        reviewerCell1.setCellValue("复核人员:");
        Cell reviewerCell2 = reviewerRow.getCell(6);
        reviewerCell2.setCellValue("复核人员:");
        // 盖章
        Row stampRow = sheet.getRow(startRow + 8);
        Cell stampCell1 = stampRow.getCell(0);
        stampCell1.setCellValue("盖章:");
        Cell stampCell2 = stampRow.getCell(6);
        stampCell2.setCellValue("盖章:");
        // 日期
        Row dateRow = sheet.getRow(startRow + 9);
        Cell dateCell1 = dateRow.getCell(0);
        dateCell1.setCellValue("日期:2026年  月  日");
        Cell dateCell2 = dateRow.getCell(6);
        dateCell2.setCellValue("日期:2026年  月  日");
        Row bankRow = sheet.createRow(startRow + 1);
        Cell bankCell = bankRow.createCell(0);
        bankCell.setCellValue("开户银行:中国农业发展银行珠海市分行");
        bankCell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow + 1, startRow + 1, 0, 9));
        Row accountRow = sheet.createRow(startRow + 2);
        Cell accountCell = accountRow.createCell(0);
        accountCell.setCellValue("账号:20344990100000422001");
        accountCell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow + 2, startRow + 2, 0, 9));
        Row nameRow = sheet.createRow(startRow + 3);
        Cell nameCell = nameRow.createCell(0);
        nameCell.setCellValue("户名:珠海市汇畅交通投资有限公司");
        nameCell.setCellStyle(styles.get("text"));
        sheet.addMergedRegion(new CellRangeAddress(startRow + 3, startRow + 3, 0, 9));
    }
    /**
@@ -989,59 +1119,77 @@
     * @param bill
     */
    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("付款单位(甲方):"+bill.getCustomerName());
        payerCell.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = payerRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("付款单位(甲方):"+bill.getCustomerName());
            } else if (i == 6) {
                cell.setCellValue("收款单位(乙方):珠海市汇畅交通投资有限公司");
            }
            cell.setCellStyle(styles.get("text"));
        }
        Cell payeeCell = payerRow.createCell(6);
        payeeCell.setCellValue("收款单位(乙方):珠海市汇畅交通投资有限公司");
        payeeCell.setCellStyle(styles.get("text"));
        // 制表人员行
        Row creatorRow = sheet.createRow(startRow + 1);
        Cell creatorCell = creatorRow.createCell(0);
        creatorCell.setCellValue("制表人员:");
        creatorCell.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = creatorRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("制表人员:");
            } else if (i == 6) {
                cell.setCellValue("制表人员:");
            }
            cell.setCellStyle(styles.get("text"));
        }
        Cell creatorCell2 = creatorRow.createCell(6);
        creatorCell2.setCellValue("制表人员:");
        creatorCell2.setCellStyle(styles.get("text"));
        // 审核人员行
        Row checkerRow = sheet.createRow(startRow + 2);
        Cell checkerCell = checkerRow.createCell(0);
        checkerCell.setCellValue("审核人员:");
        checkerCell.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = checkerRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("审核人员:");
            } else if (i == 6) {
                cell.setCellValue("审核人员:");
            }
            cell.setCellStyle(styles.get("text"));
        }
        Cell checkerCell2 = checkerRow.createCell(6);
        checkerCell2.setCellValue("审核人员:");
        checkerCell2.setCellStyle(styles.get("text"));
        // 复核人员行
        Row reviewerRow = sheet.createRow(startRow + 3);
        Cell reviewerCell = reviewerRow.createCell(0);
        reviewerCell.setCellValue("复核人员:");
        reviewerCell.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = reviewerRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("复核人员:");
            } else if (i == 6) {
                cell.setCellValue("复核人员:");
            }
            cell.setCellStyle(styles.get("text"));
        }
        Cell reviewerCell2 = reviewerRow.createCell(6);
        reviewerCell2.setCellValue("复核人员:");
        reviewerCell2.setCellStyle(styles.get("text"));
        // 盖章行
        Row stampRow = sheet.createRow(startRow + 4);
        Cell stampCell = stampRow.createCell(0);
        stampCell.setCellValue("盖章:");
        stampCell.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = stampRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("盖章:");
            } else if (i == 6) {
                cell.setCellValue("盖章:");
            }
            cell.setCellStyle(styles.get("text"));
        }
        Cell stampCell2 = stampRow.createCell(6);
        stampCell2.setCellValue("盖章:");
        stampCell2.setCellStyle(styles.get("text"));
        // 日期行
        Row dateRow = sheet.createRow(startRow + 5);
        Cell dateCell = dateRow.createCell(0);
        dateCell.setCellValue("日期:2026年  月  日");
        dateCell.setCellStyle(styles.get("text"));
        Cell dateCell2 = dateRow.createCell(6);
        dateCell2.setCellValue("日期:2026年  月  日");
        dateCell2.setCellStyle(styles.get("text"));
        for (int i = 0; i <= 9; i++) {
            Cell cell = dateRow.createCell(i);
            if (i == 0) {
                cell.setCellValue("日期:2026年  月  日");
            } else if (i == 6) {
                cell.setCellValue("日期:2026年  月  日");
            }
            cell.setCellStyle(styles.get("text"));
        }
    }
}