From 411ebc3c0a2b457bc5eb61443c549b6142a60ff6 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期六, 19 四月 2025 08:16:13 +0800
Subject: [PATCH] 1.采购入库取消检验结果校验 2.新增ipqc查询

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

diff --git a/service/Warehouse/InventoryManager.cs b/service/Warehouse/InventoryManager.cs
index d464742..66f8477 100644
--- a/service/Warehouse/InventoryManager.cs
+++ b/service/Warehouse/InventoryManager.cs
@@ -1,6 +1,7 @@
 锘縰sing NewPdaSqlServer.DB;
 using NewPdaSqlServer.Dto.service;
 using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.@base;
 using NewPdaSqlServer.util;
 using SqlSugar;
 
@@ -47,8 +48,8 @@
         var p_transction_no = 601;
 
         // 妫�鏌ュ簱浣嶄唬鐮佹槸鍚︿负绌�
-        if (string.IsNullOrEmpty(p_section_code))
-            throw new Exception("002[璇锋壂搴撲綅鏉$爜锛�");
+        // if (string.IsNullOrEmpty(p_section_code))
+        //     throw new Exception("002[璇锋壂搴撲綅鏉$爜锛�");
 
         // 鏌ヨ搴撳尯搴撲綅淇℃伅
         var depotSection = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
@@ -57,40 +58,56 @@
                 ))
             .Where((a, b) => a.DepotSectionCode == p_section_code)
             .Select((a, b) => new
-                { a.DepotSectionName, b.DepotCode, b.DepotName, b.DepotId })
+                { a.DepotSectionName, b.DepotCode, b.DepotName, b.DepotId,b.FSubsidiary })
             .Single();
 
         // 濡傛灉搴撲綅浠g爜涓嶅瓨鍦紝鍒欒繑鍥為敊璇俊鎭�
-        if (depotSection == null)
-            throw new Exception("搴撲綅缂栫爜 " + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+        // if (depotSection == null)
+        //     throw new Exception("搴撲綅缂栫爜 " + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
 
         // 妫�鏌ユ槸鍚﹀凡缁忔敹璐�
-        var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
-                new JoinQueryInfos(
-                    JoinType.Inner, a.Guid == b.ItemInId
-                ))
-            .Where((a, b) => b.ItemBarcode == p_item_barcode)
-            .Count();
+        // var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
+        //         new JoinQueryInfos(
+        //             JoinType.Inner, a.Guid == b.ItemInId
+        //         ))
+        //     .Where((a, b) => b.ItemBarcode == p_item_barcode)
+        //     .Count();
 
-        if (c_num > 0) throw new Exception("002[鏉$爜閲嶅鎵弿锛岃鏍稿锛�");
+        // if (c_num > 0) throw new Exception("002[鏉$爜閲嶅鎵弿锛岃鏍稿锛�");
 
         // 鏌ヨ鏉$爜淇℃伅
-        c_num = Db.Queryable<MesInvItemStocks>()
-            .Where(t => t.ItemBarcode == p_item_barcode)
-            .Count();
+        // c_num = Db.Queryable<MesInvItemStocks>()
+        //     .Where(t => t.ItemBarcode == p_item_barcode)
+        //     .Count();
 
-        if (c_num > 0) throw new Exception("002[鏉$爜宸插湪搴撳瓨涓紝璇锋牳瀵癸紒");
+        // if (c_num > 0) throw new Exception("002[鏉$爜宸插湪搴撳瓨涓紝璇锋牳瀵癸紒");
 
         // 鏌ヨ鏉$爜璇︾粏淇℃伅
         var c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>()
             .Where(t => t.ItemBarcode == p_item_barcode)
             .Single();
 
-        if (c_mes_inv_item_barcodes == null)
-            throw new Exception("002[鏉$爜涓嶅瓨鍦紝璇锋牳瀵癸紒");
+        // if (c_mes_inv_item_barcodes == null)
+        //     throw new Exception("002[鏉$爜涓嶅瓨鍦紝璇锋牳瀵癸紒");
 
-        if (c_mes_inv_item_barcodes.ComeFlg != 0)
+        if (c_mes_inv_item_barcodes.Memo != "鍒濇湡鐗╂枡")
             throw new Exception("002[鏉$爜涓嶆槸鏈熷垵鏉$爜锛屾棤娉曠敤鏈熷垵鍏ュ簱锛�");
+
+        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" // 浜嬪姟绫诲瀷涓庡瓨鍌ㄨ繃绋嬪尮閰�
+        );
+        
+        if ( Convert.ToInt32(checkResult.result) < 1) 
+            throw new Exception($"鍏ュ簱鏍¢獙澶辫触锛歿checkResult.strMsg}");
 
         UseTransaction(db =>
         {
@@ -133,7 +150,9 @@
                             ? "1"
                             : "0",
                     CbillNo = c_mes_inv_item_barcodes.BillNo,
-                    Fstatus = 0
+                    Fstatus = 0,
+                    ReceiveOrgId = depotSection.FSubsidiary,
+                    InType = "鏈熷垵鍏ュ簱",
                 };
                 db.Insertable(newMesInvItemIns)
                     .IgnoreColumns(true)
@@ -173,7 +192,8 @@
                 UrgentFlag = c_mes_inv_item_barcodes.UrgentFlag,
                 BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
                 TaskNo = c_mes_inv_item_barcodes.TaskNo,
-                ItemId = c_mes_inv_item_barcodes.ItemId
+                ItemId = c_mes_inv_item_barcodes.ItemId,
+                ReceiveOrgId = depotSection.FSubsidiary,
             }).IgnoreColumns(true).ExecuteCommand();
 
 
@@ -227,7 +247,9 @@
                 WorkLine = c_mes_inv_item_barcodes.WorkLine,
                 // ItemUnit = c_mes_inv_item_barcodes.Unit,
                 SuppNo = c_mes_inv_item_barcodes.SuppNo,
-                ItemId = c_mes_inv_item_barcodes.ItemId
+                ItemId = c_mes_inv_item_barcodes.ItemId,
+                IndepUserCode = c_user,
+                StockOrgId = depotSection.FSubsidiary,
                 // Fsubsidiary = c_organize
             }).IgnoreColumns(true).ExecuteCommand();
 

--
Gitblit v1.9.3