From 8b7abd97e7b69800789134ed8e809e19a5b5ba74 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期三, 17 九月 2025 00:30:27 +0800
Subject: [PATCH] 111

---
 service/Warehouse/InventoryManager.cs |   92 ++++++++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/service/Warehouse/InventoryManager.cs b/service/Warehouse/InventoryManager.cs
index 7fab709..776dcf3 100644
--- a/service/Warehouse/InventoryManager.cs
+++ b/service/Warehouse/InventoryManager.cs
@@ -1,14 +1,12 @@
-锘縰sing NewPdaSqlServer.DB;
+锘縰sing System.Data;
+using System.Data.SqlClient;
+using System.Text;
+using NewPdaSqlServer.DB;
 using NewPdaSqlServer.Dto.service;
 using NewPdaSqlServer.entity;
 using NewPdaSqlServer.service.@base;
 using NewPdaSqlServer.util;
 using SqlSugar;
-using System.Text;
-using System.Data;
-using System.Data.SqlClient;
-using System.Dynamic;
-using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
 namespace NewPdaSqlServer.service.Warehouse;
 
@@ -63,7 +61,10 @@
                 ))
             .Where((a, b) => a.DepotSectionCode == p_section_code)
             .Select((a, b) => new
-                { a.DepotSectionName, b.DepotCode, b.DepotName, b.DepotId,b.FSubsidiary })
+            {
+                a.DepotSectionName, b.DepotCode, b.DepotName, b.DepotId,
+                b.FSubsidiary
+            })
             .Single();
 
         // 濡傛灉搴撲綅浠g爜涓嶅瓨鍦紝鍒欒繑鍥為敊璇俊鎭�
@@ -101,17 +102,17 @@
         var wmsManager = new WmsBaseMangeer();
         // 鏂板鍏ュ簱鏍¢獙锛堣皟鐢ㄥ瓨鍌ㄨ繃绋嬶級
         var checkResult = wmsManager.pdaInvJY(
-            db: Db,
-            edtUserNo: query.userName,
-            barcode: p_item_barcode,
-            sectionCode: p_section_code,
-            stockId: depotSection.DepotId.ToString(),
-            stockOrgId: depotSection.FSubsidiary,
-            billNo: "", // 鏍规嵁瀹為檯鍗曟嵁鍙蜂紶鍊�
-            transactionNo: "601" // 浜嬪姟绫诲瀷涓庡瓨鍌ㄨ繃绋嬪尮閰�
+            Db,
+            query.userName,
+            p_item_barcode,
+            p_section_code,
+            depotSection.DepotId.ToString(),
+            depotSection.FSubsidiary,
+            "", // 鏍规嵁瀹為檯鍗曟嵁鍙蜂紶鍊�
+            "601" // 浜嬪姟绫诲瀷涓庡瓨鍌ㄨ繃绋嬪尮閰�
         );
-        
-        if ( Convert.ToInt32(checkResult.result) < 1) 
+
+        if (Convert.ToInt32(checkResult.result) < 1)
             throw new Exception($"鍏ュ簱鏍¢獙澶辫触锛歿checkResult.strMsg}");
 
         UseTransaction(db =>
@@ -149,15 +150,14 @@
                     SuppId = c_mes_inv_item_barcodes.SuppId,
                     SuppNo = c_mes_inv_item_barcodes.SuppNo,
                     UrgentFlag = c_mes_inv_item_barcodes.UrgentFlag == null
-                        ?
-                        null
+                        ? null
                         : c_mes_inv_item_barcodes.UrgentFlag.Value
                             ? "1"
                             : "0",
                     CbillNo = c_mes_inv_item_barcodes.BillNo,
                     Fstatus = 0,
                     ReceiveOrgId = depotSection.FSubsidiary,
-                    InType = "鏈熷垵鍏ュ簱",
+                    InType = "鏈熷垵鍏ュ簱"
                 };
                 db.Insertable(newMesInvItemIns)
                     .IgnoreColumns(true)
@@ -198,7 +198,7 @@
                 BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
                 TaskNo = c_mes_inv_item_barcodes.TaskNo,
                 ItemId = c_mes_inv_item_barcodes.ItemId,
-                ReceiveOrgId = depotSection.FSubsidiary,
+                ReceiveOrgId = depotSection.FSubsidiary
             }).IgnoreColumns(true).ExecuteCommand();
 
 
@@ -254,7 +254,7 @@
                 SuppNo = c_mes_inv_item_barcodes.SuppNo,
                 ItemId = c_mes_inv_item_barcodes.ItemId,
                 IndepUserCode = c_user,
-                StockOrgId = depotSection.FSubsidiary,
+                StockOrgId = depotSection.FSubsidiary
                 // Fsubsidiary = c_organize
             }).IgnoreColumns(true).ExecuteCommand();
 
@@ -277,11 +277,12 @@
 
     public dynamic GetDepoptsInfo(dynamic unity)
     {
-
         //// 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆
-        var sqlParams = new List<SugarParameter> { new("@sectionCode", unity.sectionCode) };
+        var sqlParams = new List<SugarParameter>
+            { new("@sectionCode", unity.sectionCode) };
 
-        var sql2 = @"        SELECT TOP 1  B.depot_code + '('+B.depot_name+')' depotsInfo,
+        var sql2 =
+            @"        SELECT TOP 1  B.depot_code + '('+B.depot_name+')' depotsInfo,
                      B.FSubsidiary,
                      C.FNumber + '('+C.NAME+')' orgInfo
         FROM MES_DEPOT_SECTIONS A
@@ -290,17 +291,16 @@
             LEFT JOIN SYS_ORGANIZATION C ON C.FID = B.FSubsidiary
         WHERE a.depot_section_code = @sectionCode;";
 
-        var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault();
+        var XcslItem =
+            Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault();
 
         // 妫�鏌ョ粨鏋滄湁鏁堟��
         if (XcslItem == null)
-        {
-            throw new Exception($"搴撲綅 [{unity.sectionCode}] 涓嶅瓨鍦紝鎴栨墍灞炰粨搴撶姸鎬佸紓甯革紙鍙兘琚鐢ㄦ垨鍒犻櫎锛夈��");
-        }
+            throw new Exception(
+                $"搴撲綅 [{unity.sectionCode}] 涓嶅瓨鍦紝鎴栨墍灞炰粨搴撶姸鎬佸紓甯革紙鍙兘琚鐢ㄦ垨鍒犻櫎锛夈��");
 
         return XcslItem; // 杩斿洖绗竴琛屾暟鎹紝濡傛灉娌℃湁鍒欒繑鍥� null
     }
-
 
 
     public dynamic GetItemsList(dynamic unity)
@@ -323,10 +323,7 @@
 
         var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2.ToString(), sqlParams);
 
-        if (XcslItem == null)
-        {
-            throw new Exception("璇ユ潯浠朵笅鏃犲搴旂墿鏂欎俊鎭紝璇烽噸鏂拌緭鍏ワ紒");
-        }
+        if (XcslItem == null) throw new Exception("璇ユ潯浠朵笅鏃犲搴旂墿鏂欎俊鎭紝璇烽噸鏂拌緭鍏ワ紒");
 
         return XcslItem;
     }
@@ -351,11 +348,15 @@
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddRange(new[]
             {
-                new SqlParameter("@inUser", SqlDbType.NVarChar, 50) { Value = query.userName },
-                new SqlParameter("@inItemId", SqlDbType.NVarChar, 50) { Value = query.itemid },
+                new SqlParameter("@inUser", SqlDbType.NVarChar, 50)
+                    { Value = query.userName },
+                new SqlParameter("@inItemId", SqlDbType.NVarChar, 50)
+                    { Value = query.itemid },
                 new SqlParameter("@isDesign", SqlDbType.Int) { Value = 0 },
-                new SqlParameter("@in4", SqlDbType.NVarChar, 20) { Value = query.in4 ?? DBNull.Value },
-                new SqlParameter("@in5", SqlDbType.NVarChar, 20) { Value = query.num ?? DBNull.Value }
+                new SqlParameter("@in4", SqlDbType.NVarChar, 20)
+                    { Value = query.in4 ?? DBNull.Value },
+                new SqlParameter("@in5", SqlDbType.NVarChar, 20)
+                    { Value = query.num ?? DBNull.Value }
             });
 
             try
@@ -366,28 +367,30 @@
                     while (reader.Read())
                     {
                         var barcode = reader.GetString(0);
-                        
+
                         // 鏋勫缓绗﹀悎鏂规硶绛惧悕鐨勫弬鏁板璞�
-                        var scanQuery = new WarehouseQuery 
+                        var scanQuery = new WarehouseQuery
                         {
                             barcode = barcode,
                             DepotCode = query.sectionCode, // 浠庡師濮媞uery鑾峰彇搴撲綅缂栫爜
                             userName = query.userName // 浠庡師濮媞uery鑾峰彇鐢ㄦ埛璐﹀彿
                         };
-                        
+
                         try
                         {
                             // 璋冪敤姝e紡绛惧悕鏂规硶
                             ScanBarcode(scanQuery);
-                            var printData = GetPrintBar(barcode); 
+                            var printData = GetPrintBar(barcode);
                             resultList.Add(printData);
                         }
                         catch (Exception ex)
                         {
-                            throw new Exception($"鏈熷垵鏉$爜鎵撳嵃鍏ュ簱瀛樺湪寮傚父{ex.Message}锛岃閲嶆柊鎵撳嵃锛�");
+                            throw new Exception(
+                                $"鏈熷垵鏉$爜鎵撳嵃鍏ュ簱瀛樺湪寮傚父{ex.Message}锛岃閲嶆柊鎵撳嵃锛�");
                         }
                     }
                 }
+
                 return resultList;
             }
             catch (Exception ex)
@@ -401,7 +404,8 @@
     {
         var sqlParams = new List<SugarParameter> { new("@barcode", barcode) };
 
-        var sql1 = @"    SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.OLDQTY as QUANTITY,B.CREATE_DATE, '鏈熷垵鏉$爜' AS BarType,A.ITEM_BARCODE,GETDATE() as print_date
+        var sql1 =
+            @"    SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.OLDQTY as QUANTITY,B.CREATE_DATE, '鏈熷垵鏉$爜' AS BarType,A.ITEM_BARCODE,GETDATE() as print_date
             FROM MES_INV_ITEM_STOCKS A
             LEFT JOIN MES_INV_ITEM_BARCODES B ON A.ITEM_BARCODE = B.ITEM_BARCODE
             LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID

--
Gitblit v1.9.3