From f5663e67ebd1a853eaf18287da54fc34f101f975 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 23 四月 2026 16:22:27 +0800
Subject: [PATCH] 导出销售台账送货单

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |  143 +++++++++++++++--------------------------------
 1 files changed, 45 insertions(+), 98 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 6ebc49c..9918fb8 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -245,16 +245,16 @@
             for (SalesLedger ledger : ledgerList) {
                 XSSFSheet sheet = workbook.createSheet(ledger.getSalesContractNo());
 
-                sheet.setColumnWidth(0, 2500);
-                sheet.setColumnWidth(1, 4000);
-                sheet.setColumnWidth(2, 9000);
-                sheet.setColumnWidth(3, 2500);
-                sheet.setColumnWidth(4, 3000);
-                sheet.setColumnWidth(5, 4500);
-                sheet.setColumnWidth(6, 2000);
+                sheet.setColumnWidth(0, 1310);  // 4.56 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(1, 4000);  // 15.06 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(2, 8980);  // 34.43 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(3, 1820);  // 6.56 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(4, 2880);  // 10.68 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(5, 5090);  // 19.31 鈫� 绮惧噯鏄剧ず
+                sheet.setColumnWidth(6, 1410);  // 4.97 鈫� 绮惧噯鏄剧ず
 
                 CellStyle companyTitle = createBaseStyle(workbook, "瀹嬩綋", (short) 20, true, true);
-                CellStyle billTitle = createBaseStyle(workbook, "瀹嬩綋", (short) 18, true, true);
+                CellStyle billTitle = createBaseStyle(workbook, "瀹嬩綋", (short) 18, false, true);
                 CellStyle headerStyle = createBorderStyle(workbook, "瀹嬩綋", (short) 12, true, true);
                 CellStyle dataCenterStyle = createBorderStyle(workbook, "瀹嬩綋", (short) 11, false, true);
 
@@ -275,33 +275,40 @@
                 fillMergeRange(sheet, 0, 0, 0, 6, companyTitle);
 
                 Row row1 = sheet.createRow(1);
-                row1.createCell(0).setCellValue("閫� 璐� 鍗�");
+                row1.createCell(0).setCellValue("閫�   璐�   鍗�");
                 sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6));
                 fillMergeRange(sheet, 1, 1, 0, 6, billTitle);
 
                 Customer customer = customerMapper.selectById(ledger.getCustomerId());
 
                 Row row2 = sheet.createRow(2);
+                row2.setHeightInPoints(13);
                 row2.createCell(0).setCellValue("瀹㈡埛鍚嶇О锛�" + ledger.getCustomerName());
                 row2.createCell(4).setCellValue("鍗曟嵁缂栧彿锛�" + ledger.getSalesContractNo());
 
                 Row row3 = sheet.createRow(3);
+                row3.setHeightInPoints(13);
                 row3.createCell(0).setCellValue("閫佽揣鍦板潃锛�" + customer.getCompanyAddress());
                 row3.createCell(4).setCellValue("閫佽揣鏃ユ湡锛�" + formatDate(LocalDate.now()));
 
+                // 绌鸿
                 Row row4 = sheet.createRow(4);
-                row4.createCell(0).setCellValue("鑱旂郴鏂瑰紡锛�" + customer.getContactPerson() + " " + customer.getContactPhone());
+                row4.setHeightInPoints(13);
                 row4.createCell(4).setCellValue("鑱旂郴鐢佃瘽锛�" + customer.getCompanyPhone());
 
                 Row row5 = sheet.createRow(5);
-                row5.createCell(0).setCellValue("閫佽揣鍗曚綅锛氭箹鍗楅箯鍒涚數瀛愭湁闄愬叕鍙�");
+                row5.createCell(0).setCellValue("鑱旂郴鏂瑰紡锛�" + customer.getContactPerson() + " " + customer.getContactPhone());
                 Row row6 = sheet.createRow(6);
-                row6.createCell(0).setCellValue("鍦板潃锛氭箹鍗楃渷鑰掗槼甯傚垱鏂板垱涓氬洯A1鏍�");
+                row6.createCell(0).setCellValue("閫佽揣鍗曚綅锛氭箹鍗楅箯鍒涚數瀛愭湁闄愬叕鍙�");
                 Row row7 = sheet.createRow(7);
-                row7.createCell(0).setCellValue("璐х墿璇︾粏淇℃伅锛�");
+                row7.createCell(0).setCellValue("鍦板潃锛氭箹鍗楃渷鑰掗槼甯傚垱鏂板垱涓氬洯A1鏍�");
+                Row row8 = sheet.createRow(8);
+                row8.createCell(0).setCellValue("璐х墿璇︾粏淇℃伅锛�");
 
-                int tableStart = 8;
+                int tableStart = 9;
                 Row headerRow = sheet.createRow(tableStart);
+                headerRow.setHeightInPoints((short)22);
+
                 String[] headers = {"搴忓彿", "鐗╂枡缂栧彿", "鍝佸悕/瑙勬牸", "鍗曚綅", "鏁伴噺", "璁㈠崟鍙�", "鍏卞洓鑱�"};
                 for (int i = 0; i < headers.length; i++) {
                     Cell hc = headerRow.createCell(i);
@@ -330,6 +337,7 @@
                 for (int i = 0; i < productList.size(); i++) {
                     SalesLedgerProduct p = productList.get(i);
                     Row dataRow = sheet.createRow(currentRow++);
+                    dataRow.setHeightInPoints((short)22);
 
                     String materialCode = "";
                     if (p.getProductModelId() != null) {
@@ -365,6 +373,7 @@
                 for (int i = 0; i < needEmpty; i++) {
                     int seq = productList.size() + i;
                     Row dataRow = sheet.createRow(currentRow++);
+                    dataRow.setHeightInPoints((short)22);
 
                     for (int c = 0; c <= 5; c++) dataRow.createCell(c).setCellStyle(dataCenterStyle);
 
@@ -383,27 +392,41 @@
 
                 // 鍚堣
                 Row totalRow = sheet.createRow(currentRow);
-                sheet.addMergedRegion(new CellRangeAddress(currentRow, currentRow, 0, 3));
-                totalRow.createCell(0).setCellValue("鍚堣");
+                totalRow.setHeightInPoints((short)22);
+
+                // 鍚堣鏀惧湪绗簩鍒楋紝涓嶅悎骞跺崟鍏冩牸
+                totalRow.createCell(1).setCellValue("鍚堣");
                 totalRow.createCell(4).setCellValue(totalQuantity.doubleValue());
-                fillMergeRange(sheet, currentRow, currentRow, 0, 5, dataCenterStyle);
+                
+                // 璁剧疆鏍峰紡
+                for (int c = 0; c <= 5; c++) {
+                    Cell cell = totalRow.getCell(c) != null ? totalRow.getCell(c) : totalRow.createCell(c);
+                    cell.setCellStyle(dataCenterStyle);
+                }
                 totalRow.createCell(6).setCellStyle(centerNoBorder);
 
-                // 澶囨敞
+                currentRow++;
+                Row emptyRow1 = sheet.createRow(currentRow);
+                emptyRow1.setHeightInPoints((short) 9); // 琛岄珮9纾�
+
                 currentRow++;
                 Row remarkRow = sheet.createRow(currentRow);
-                remarkRow.createCell(0).setCellValue("澶囨敞锛氳吹鍙稿湪鏀惰揣鍚庤鍗冲埢鏍稿疄鏁伴噺鍙婂搧璐紝鑻ユ湁寮傝锛岃鍦�3鏃ュ唴鎻愬嚭锛屽惁鍒欒涓烘敹鍙椼��");
+                remarkRow.createCell(0).setCellValue("澶囨敞锛氳吹鍙稿湪鏀惰揣鍚庤鍗冲埢鏍稿疄鏁伴噺鍙婂搧璐紝鑻ユ湁寮傝锛岃鍦�3鏃ュ唴鎻愬嚭锛屽惁鍒欒涓烘敹濡ャ��");
                 sheet.addMergedRegion(new CellRangeAddress(currentRow, currentRow, 0, 6));
+
+                currentRow++;
+                Row emptyRow2 = sheet.createRow(currentRow);
+                emptyRow2.setHeightInPoints((short) 9); // 琛岄珮9纾�
 
                 currentRow++;
                 Row sign1 = sheet.createRow(currentRow);
                 sign1.createCell(0).setCellValue("閫佽揣鍗曚綅锛堢绔狅級锛�");
-                sign1.createCell(5).setCellValue("鏀惰揣鍗曚綅锛�");
+                sign1.createCell(4).setCellValue("鏀惰揣鍗曚綅锛�");
 
                 currentRow++;
                 Row sign2 = sheet.createRow(currentRow);
                 sign2.createCell(0).setCellValue("閫佽揣浜猴細");
-                sign2.createCell(5).setCellValue("鏀惰揣浜猴細");
+                sign2.createCell(4).setCellValue("鏀惰揣浜猴細");
             }
 
             workbook.write(response.getOutputStream());
@@ -415,7 +438,7 @@
         }
     }
 
-    // 宸ュ叿绫讳笉鍔�
+    // 宸ュ叿绫�
     private CellStyle createBaseStyle(Workbook workbook, String fontName, short fontSize, boolean bold, boolean center) {
         CellStyle style = workbook.createCellStyle();
         Font font = workbook.createFont();
@@ -464,82 +487,6 @@
             return null;
         }
         return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-    }
-    
-    /**
-     * 璁剧疆鍗曞厓鏍兼牱寮�
-     */
-    private void setCellStyle(Cell cell, boolean isHeader, boolean isTitle) {
-        Workbook workbook = cell.getSheet().getWorkbook();
-        CellStyle style = workbook.createCellStyle();
-        
-        // 璁剧疆瀵归綈鏂瑰紡
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-        
-        // 璁剧疆杈规
-        style.setBorderTop(BorderStyle.THIN);
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBorderLeft(BorderStyle.THIN);
-        style.setBorderRight(BorderStyle.THIN);
-        
-        // 璁剧疆瀛椾綋
-        Font font = workbook.createFont();
-        font.setFontName("瀹嬩綋");
-        if (isTitle) {
-            font.setFontHeightInPoints((short) 16);
-            font.setBold(true);
-        } else if (isHeader) {
-            font.setFontHeightInPoints((short) 12);
-            font.setBold(true);
-        } else {
-            font.setFontHeightInPoints((short) 11);
-        }
-        style.setFont(font);
-        
-        cell.setCellStyle(style);
-    }
-    
-    
-    /**
-     * 閫佽揣鍗曟牱寮忓鐞嗗櫒
-     */
-    public static class ShippingNoteStyleHandler implements com.alibaba.excel.write.handler.CellWriteHandler {
-        @Override
-        public void beforeCellCreate(com.alibaba.excel.write.metadata.holder.WriteSheetHolder writeSheetHolder, com.alibaba.excel.write.metadata.holder.WriteTableHolder writeTableHolder, org.apache.poi.ss.usermodel.Row row, com.alibaba.excel.metadata.Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
-        }
-        
-//        @Override
-//        public void afterCellDispose(com.alibaba.excel.write.metadata.holder.WriteSheetHolder writeSheetHolder, com.alibaba.excel.write.metadata.holder.WriteTableHolder writeTableHolder, org.apache.poi.ss.usermodel.Cell cell, com.alibaba.excel.metadata.Head head, Integer relativeRowIndex, Boolean isHead) {
-//            org.apache.poi.ss.usermodel.Workbook workbook = writeSheetHolder.getSheet().getWorkbook();
-//            org.apache.poi.ss.usermodel.Sheet sheet = writeSheetHolder.getSheet();
-//
-//            // 璁剧疆鍒楀
-//            sheet.setColumnWidth(0, 6000); // 搴忓彿
-//            sheet.setColumnWidth(1, 6000); // 鐗╂枡缂栧彿
-//            sheet.setColumnWidth(2, 10000); // 鍝佸悕/瑙勬牸
-//            sheet.setColumnWidth(3, 4000); // 鍗曚綅
-//            sheet.setColumnWidth(4, 4000); // 鏁伴噺
-//            sheet.setColumnWidth(5, 6000); // 璁㈠崟鍙�
-//            sheet.setColumnWidth(6, 4000); // 鍏卞洓鑱�
-//
-//            // 璁剧疆鍗曞厓鏍兼牱寮�
-//            org.apache.poi.ss.usermodel.CellStyle style = workbook.createCellStyle();
-//            style.setAlignment(org.apache.poi.ss.usermodel.HorizontalAlignment.CENTER);
-//            style.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
-//            style.setBorderTop(org.apache.poi.ss.usermodel.BorderStyle.THIN);
-//            style.setBorderBottom(org.apache.poi.ss.usermodel.BorderStyle.THIN);
-//            style.setBorderLeft(org.apache.poi.ss.usermodel.BorderStyle.THIN);
-//            style.setBorderRight(org.apache.poi.ss.usermodel.BorderStyle.THIN);
-//
-//            // 璁剧疆瀛椾綋
-//            org.apache.poi.ss.usermodel.Font font = workbook.createFont();
-//            font.setFontName("瀹嬩綋");
-//            font.setFontHeightInPoints((short) 11);
-//            style.setFont(font);
-//
-//            cell.setCellStyle(style);
-//        }
     }
 
     @Override

--
Gitblit v1.9.3