From a474060ae47fc4c807120b2a6178e8d8f84c0863 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期二, 27 一月 2026 15:07:25 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   77 +++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 42 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 4a091c0..edfcea8 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -561,9 +561,9 @@
                                 return WebResponseContent.Instance.Error("鏈壘鍒板叆搴撳崟淇℃伅");
                             }
                             var allBoxCodesForDetail = BaseDal.Db.Queryable<Dt_StockInfoDetailCP>()
-                         .Where(x => x.StockDetailId == dt_StockInfo.Details.FirstOrDefault().Id)
-                         .Select(x => x.BoxCode)
-                         .ToList();
+              .Where(x => dt_StockInfo.Details.Select(d => d.Id).Contains(x.StockDetailId))
+              .Select(x => x.BoxCode)
+              .ToList();
 
                             // 2. 鑾峰彇鎵樼洏涓嬬殑鎵�鏈夌鍙�
                             var boxCodes = new List<string>();
@@ -640,14 +640,6 @@
                                     .ToList();
                             }
 
-                            // 鏇存柊鎴愬搧鍏ュ簱鏄庣粏鐘舵��
-                            if (cpInboundDetails.Any())
-                            {
-                                foreach (var cpDetail in cpInboundDetails)
-                                {
-                                    cpDetail.CPOrderDetailStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
-                                }
-                            }
 
                             // 4. 鏌ヨ骞舵洿鏂版垚鍝佸簱瀛樻槑缁嗭紙濡傛灉鏈夊崟鐙殑鎴愬搧搴撳瓨琛級
                             List<Dt_StockInfoDetailCP> cpStockDetails = new List<Dt_StockInfoDetailCP>();
@@ -709,7 +701,7 @@
                                 // 鏇存柊鎴愬搧鍏ュ簱鏄庣粏鐘舵��
                                 if (cpInboundDetails.Any())
                                 {
-                                    BaseDal.Db.Updateable(cpInboundDetails).ExecuteCommand();
+                                    BaseDal.Db.Deleteable(cpInboundDetails).ExecuteCommand();
                                 }
 
                                 // 鏇存柊鎴愬搧搴撳瓨鏄庣粏鐘舵��
@@ -3198,58 +3190,59 @@
                 return;
             }
 
-            // 鑾峰彇鎵撳嵃鏈哄悕绉�
+            // 鑾峰彇閰嶇疆鐨勬墦鍗版満鍚嶇О
             string printerName = AppSettings.app("PrinterName");
 
-            PrintUsingSpireSimple(fullPath, printerName);
+            if (string.IsNullOrEmpty(printerName))
+            {
+                Console.WriteLine("鉁� 鎵撳嵃澶辫触锛氭湭閰嶇疆鎵撳嵃鏈哄悕绉�");
+                return;
+            }
 
-
-            Console.WriteLine("鎵�鏈夋墦鍗版柟娉曢兘澶辫触");
+            // 鐩存帴浣跨敤閰嶇疆鐨勬墦鍗版満鍚嶇О锛屼笉杩涜浠讳綍杞崲
+            PrintUsingConfiguredPrinter(fullPath, printerName.Trim());
         }
 
 
-        private void PrintUsingSpireSimple(string filePath, string printerName)
+        /// <summary>
+        /// 鍙娇鐢ㄩ厤缃殑鎵撳嵃鏈鸿繘琛屾墦鍗�
+        /// </summary>
+        private void PrintUsingConfiguredPrinter(string filePath, string printerName)
         {
             try
             {
+                // 1. 棣栧厛楠岃瘉鎵撳嵃鏈烘槸鍚﹀瓨鍦�
+                if (!IsPrinterInstalled(printerName))
+                {
+                    Console.WriteLine($"鉁� 鎵撳嵃鏈� '{printerName}' 鏈畨瑁呮垨涓嶅瓨鍦�");
+                    Console.WriteLine("\n绯荤粺宸插畨瑁呯殑鎵撳嵃鏈哄垪琛�:");
+                    foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
+                    {
+                        Console.WriteLine($"  - {printer}");
+                    }
+                    throw new InvalidOperationException($"鎵撳嵃鏈� '{printerName}' 鏈畨瑁�");
+                }
+
+                // 3. 浣跨敤 Spire.PDF 鎵撳嵃
                 using (Spire.Pdf.PdfDocument pdf = new Spire.Pdf.PdfDocument())
                 {
                     // 鍔犺浇鏂囦欢
                     pdf.LoadFromFile(filePath);
 
-                    // 鑾峰彇瀹為檯鐨勬墦鍗版満鍚嶇О
-                    string actualPrinterName = GetActualPrinterName(printerName);
+                    // 璁剧疆鎵撳嵃鏈哄悕绉帮紙鍙娇鐢ㄩ厤缃殑鍚嶇О锛�
+                    pdf.PrintSettings.PrinterName = printerName;
 
-                    Console.WriteLine($"閰嶇疆鐨勬墦鍗版満鍚嶇О: {printerName}");
-                    Console.WriteLine($"瀹為檯浣跨敤鐨勬墦鍗版満鍚嶇О: {actualPrinterName}");
-
-                    // 濡傛灉鎵句笉鍒板疄闄呮墦鍗版満锛屼娇鐢ㄩ粯璁ゆ墦鍗版満
-                    if (!string.IsNullOrEmpty(actualPrinterName) && IsPrinterInstalled(actualPrinterName))
-                    {
-                        pdf.PrintSettings.PrinterName = actualPrinterName;
-                        Console.WriteLine($"鉁� 宸茶缃墦鍗版満: {actualPrinterName}");
-                    }
-                    else
-                    {
-                        Console.WriteLine($"鈿狅笍 鎵撳嵃鏈� '{actualPrinterName}' 鏈壘鍒帮紝浣跨敤榛樿鎵撳嵃鏈�");
-                    }
+                    Console.WriteLine($"鉁� 浣跨敤閰嶇疆鐨勬墦鍗版満: {printerName}");
+                    Console.WriteLine($"鉁� 姝e湪鎵撳嵃: {Path.GetFileName(filePath)}");
 
                     // 鐩存帴鎵撳嵃
                     pdf.Print();
-                    Console.WriteLine("鉁� 鎵撳嵃浠诲姟宸叉彁浜ゆ垚鍔�");
+                    Console.WriteLine("鉁� 鎵撳嵃浠诲姟宸叉彁浜�");
                 }
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"鉁� Spire.PDF鎵撳嵃澶辫触: {ex.Message}");
-
-                // 杈撳嚭鎵�鏈夊彲鐢ㄦ墦鍗版満锛屽府鍔╄皟璇�
-                Console.WriteLine("\n绯荤粺鎵�鏈夊彲鐢ㄦ墦鍗版満:");
-                foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
-                {
-                    Console.WriteLine($"  - {printer}");
-                }
-
+                Console.WriteLine($"鉁� 鎵撳嵃澶辫触: {ex.Message}");
                 throw;
             }
         }

--
Gitblit v1.9.3