From 4d99e718536ac77dff26dde8da7a59cdc9b52de8 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 20 五月 2026 10:13:57 +0800
Subject: [PATCH] fix:1.生产报工优化

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |   75 +++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 37 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 9918fb8..3e7bc29 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,10 +1,5 @@
 package com.ruoyi.sales.service.impl;
 
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.ExcelWriter;
-import com.alibaba.excel.write.metadata.WriteSheet;
-import com.alibaba.excel.write.metadata.fill.FillConfig;
-import com.alibaba.excel.write.metadata.fill.FillWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,9 +8,6 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.deepoove.poi.XWPFTemplate;
-import com.deepoove.poi.config.Configure;
-import com.ruoyi.account.pojo.AccountIncome;
 import com.ruoyi.account.service.AccountIncomeService;
 import com.ruoyi.basic.mapper.CustomerMapper;
 import com.ruoyi.basic.mapper.ProductMapper;
@@ -25,11 +17,9 @@
 import com.ruoyi.common.enums.FileNameType;
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.HackLoopTableRenderPolicy;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.device.execl.DeviceMaintenanceExeclDto;
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.other.mapper.TempFileMapper;
@@ -46,7 +36,6 @@
 import com.ruoyi.sales.pojo.*;
 import com.ruoyi.sales.service.ISalesLedgerProductService;
 import com.ruoyi.sales.service.ISalesLedgerService;
-import com.ruoyi.sales.vo.ShippingNoteVo;
 import com.ruoyi.stock.mapper.StockInventoryMapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -65,12 +54,12 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -78,14 +67,11 @@
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.YearMonth;
-import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
 
 /**
  * 閿�鍞彴璐ervice涓氬姟灞傚鐞�
@@ -245,13 +231,22 @@
             for (SalesLedger ledger : ledgerList) {
                 XSSFSheet sheet = workbook.createSheet(ledger.getSalesContractNo());
 
-                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 鈫� 绮惧噯鏄剧ず
+                // 璁剧疆椤佃竟璺濓紙鍗曚綅锛氳嫳瀵革紝1鑻卞=2.54鍘樼背锛�
+                sheet.getPrintSetup().setLandscape(false); // 绾靛悜鎵撳嵃
+                sheet.setMargin(Sheet.TopMargin, 0.54 / 2.54);     // 涓婇〉杈硅窛锛�0.54鍘樼背
+                sheet.setMargin(Sheet.BottomMargin, 0.54 / 2.54);  // 涓嬮〉杈硅窛锛�0.54鍘樼背
+                sheet.setMargin(Sheet.LeftMargin, 0.41 / 2.54);   // 宸﹂〉杈硅窛锛�0.41鍘樼背
+                sheet.setMargin(Sheet.RightMargin, 0.41 / 2.54);  // 鍙抽〉杈硅窛锛�0.41鍘樼背
+                sheet.setMargin(Sheet.HeaderMargin, 0.77 / 2.54); // 椤电湁锛�0.77鍘樼背
+                sheet.setMargin(Sheet.FooterMargin, 0.27 / 2.54); // 椤佃剼锛�0.27鍘樼背
+
+                sheet.setColumnWidth(0, 1310);
+                sheet.setColumnWidth(1, 4000);
+                sheet.setColumnWidth(2, 8980);
+                sheet.setColumnWidth(3, 1820);
+                sheet.setColumnWidth(4, 2880);
+                sheet.setColumnWidth(5, 5090);
+                sheet.setColumnWidth(6, 1410);
 
                 CellStyle companyTitle = createBaseStyle(workbook, "瀹嬩綋", (short) 20, true, true);
                 CellStyle billTitle = createBaseStyle(workbook, "瀹嬩綋", (short) 18, false, true);
@@ -303,11 +298,13 @@
                 Row row7 = sheet.createRow(7);
                 row7.createCell(0).setCellValue("鍦板潃锛氭箹鍗楃渷鑰掗槼甯傚垱鏂板垱涓氬洯A1鏍�");
                 Row row8 = sheet.createRow(8);
-                row8.createCell(0).setCellValue("璐х墿璇︾粏淇℃伅锛�");
+                row8.setHeightInPoints((short) 3); // 琛岄珮3纾�
+                Row row9 = sheet.createRow(9);
+                row9.createCell(0).setCellValue("璐х墿璇︾粏淇℃伅锛�");
 
-                int tableStart = 9;
+                int tableStart = 10;
                 Row headerRow = sheet.createRow(tableStart);
-                headerRow.setHeightInPoints((short)22);
+                headerRow.setHeightInPoints((short) 18);
 
                 String[] headers = {"搴忓彿", "鐗╂枡缂栧彿", "鍝佸悕/瑙勬牸", "鍗曚綅", "鏁伴噺", "璁㈠崟鍙�", "鍏卞洓鑱�"};
                 for (int i = 0; i < headers.length; i++) {
@@ -337,7 +334,7 @@
                 for (int i = 0; i < productList.size(); i++) {
                     SalesLedgerProduct p = productList.get(i);
                     Row dataRow = sheet.createRow(currentRow++);
-                    dataRow.setHeightInPoints((short)22);
+                    dataRow.setHeightInPoints((short) 18);
 
                     String materialCode = "";
                     if (p.getProductModelId() != null) {
@@ -373,7 +370,7 @@
                 for (int i = 0; i < needEmpty; i++) {
                     int seq = productList.size() + i;
                     Row dataRow = sheet.createRow(currentRow++);
-                    dataRow.setHeightInPoints((short)22);
+                    dataRow.setHeightInPoints((short) 18);
 
                     for (int c = 0; c <= 5; c++) dataRow.createCell(c).setCellStyle(dataCenterStyle);
 
@@ -392,12 +389,12 @@
 
                 // 鍚堣
                 Row totalRow = sheet.createRow(currentRow);
-                totalRow.setHeightInPoints((short)22);
+                totalRow.setHeightInPoints((short) 18);
 
                 // 鍚堣鏀惧湪绗簩鍒楋紝涓嶅悎骞跺崟鍏冩牸
                 totalRow.createCell(1).setCellValue("鍚堣");
                 totalRow.createCell(4).setCellValue(totalQuantity.doubleValue());
-                
+
                 // 璁剧疆鏍峰紡
                 for (int c = 0; c <= 5; c++) {
                     Cell cell = totalRow.getCell(c) != null ? totalRow.getCell(c) : totalRow.createCell(c);
@@ -486,7 +483,7 @@
         if (date == null) {
             return null;
         }
-        return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        return date.format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
     }
 
     @Override
@@ -609,7 +606,7 @@
     }
 
     @Override
-    public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
+    public IPage<SalesLedgerDto> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
         return salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
     }
 
@@ -886,7 +883,7 @@
             // 4. 澶勭悊瀛愯〃鏁版嵁
             List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
             if (productList != null && !productList.isEmpty()) {
-                handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType(), salesLedgerDto.isProduce());
+                handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType(), Boolean.TRUE.equals(salesLedgerDto.getProduce()));
                 updateMainContractAmount(
                         salesLedger.getId(),
                         productList,
@@ -1032,10 +1029,13 @@
                 salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
                 salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
                 salesLedgerProductMapper.insert(salesLedgerProduct);
+
+            }
+        }
+        if (isProduce) {
+            for (SalesLedgerProduct salesLedgerProduct : products) {
                 // 娣诲姞鐢熶骇鏁版嵁
-                if (isProduce) {
-                    salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
-                }
+                salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
             }
         }
     }
@@ -1043,6 +1043,7 @@
     private SalesLedger convertToEntity(SalesLedgerDto dto) {
         SalesLedger entity = new SalesLedger();
         BeanUtils.copyProperties(dto, entity);
+        entity.setProduce(dto.getProduce());
         return entity;
     }
 
@@ -1149,4 +1150,4 @@
             throw new RuntimeException("鍔ㄦ�佹洿鏂颁富琛ㄩ噾棰濆け璐�", e);
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3