From 18480213c000dfd7f6f236903f965a4d3f254597 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 09 六月 2026 17:23:46 +0800
Subject: [PATCH] 销售台账列表返回库存类型

---
 src/main/resources/mapper/sales/SalesLedgerMapper.xml                     |    7 +++++++
 src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java |   17 +++++++++++++----
 src/main/java/com/ruoyi/sales/vo/SalesLedgerVo.java                       |    2 ++
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/vo/SalesLedgerVo.java b/src/main/java/com/ruoyi/sales/vo/SalesLedgerVo.java
index fb932f8..c6f8208 100644
--- a/src/main/java/com/ruoyi/sales/vo/SalesLedgerVo.java
+++ b/src/main/java/com/ruoyi/sales/vo/SalesLedgerVo.java
@@ -10,4 +10,6 @@
 public class SalesLedgerVo extends SalesLedger {
 
     private List<StorageBlobVO> storageBlobVOs;
+
+    private String stockType;
 }
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
index e01d9d3..a5da266 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
@@ -142,10 +142,19 @@
     public void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto) {
         List<StockOutRecordExportData> list = stockOutRecordMapper.listStockOutRecordExportData(stockOutRecordDto);
         for (StockOutRecordExportData stockInRecordExportData : list) {
-            if (stockInRecordExportData.getType().equals("0")) {
-                stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockOutQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
-            }else {
-                stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockInQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
+            if (StringUtils.isEmpty(stockInRecordExportData.getRecordType())) {
+                continue;
+            }
+            StockOutQualifiedRecordTypeEnum outRecordTypeEnum =
+                    EnumUtil.fromCode(StockOutQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType()));
+            if (outRecordTypeEnum != null) {
+                stockInRecordExportData.setRecordType(outRecordTypeEnum.getValue());
+                continue;
+            }
+            StockInQualifiedRecordTypeEnum inRecordTypeEnum =
+                    EnumUtil.fromCode(StockInQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType()));
+            if (inRecordTypeEnum != null) {
+                stockInRecordExportData.setRecordType(inRecordTypeEnum.getValue());
             }
         }
         ExcelUtil<StockOutRecordExportData> util = new ExcelUtil<>(StockOutRecordExportData.class);
diff --git a/src/main/resources/mapper/sales/SalesLedgerMapper.xml b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
index a5650f9..a7819d1 100644
--- a/src/main/resources/mapper/sales/SalesLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -62,10 +62,17 @@
         T1.payment_method,
         T1.delivery_date,
         DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff,
+        COALESCE(stock_type_info.stock_type, 'qualified') AS stock_type,
         IFNULL(shipping_status_counts.is_all_shipped, FALSE) AS is_fh
         FROM sales_ledger T1
         LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id
         LEFT JOIN (
+        SELECT sales_ledger_id, MAX(stock_type) AS stock_type
+        FROM sales_ledger_product
+        WHERE type = 1
+        GROUP BY sales_ledger_id
+        ) stock_type_info ON T1.id = stock_type_info.sales_ledger_id
+        LEFT JOIN (
         SELECT sales_ledger_id,
         CASE
         WHEN SUM(CASE WHEN status != '宸插彂璐�' THEN 1 ELSE 0 END) = 0 THEN TRUE

--
Gitblit v1.9.3