From 7b84eb64d11b12b6fb41ae7f7085452512ad5d3f Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期五, 20 六月 2025 08:18:08 +0800
Subject: [PATCH] 1.采购入库优化

---
 service/Warehouse/MesInvItemInCDetailsManager.cs |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/service/Warehouse/MesInvItemInCDetailsManager.cs b/service/Warehouse/MesInvItemInCDetailsManager.cs
index 78c31d2..648e17b 100644
--- a/service/Warehouse/MesInvItemInCDetailsManager.cs
+++ b/service/Warehouse/MesInvItemInCDetailsManager.cs
@@ -26,25 +26,25 @@
         var freeze = 0;
         decimal cSyQty = 0;
 
-        //if (string.IsNullOrEmpty(sectionCode))
-        //    throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
+        if (string.IsNullOrEmpty(sectionCode))
+            throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
 
         var itemBarcodeDetails = Db.Queryable<MesInvItemBarcodes>()
             .Where(it => it.ItemBarcode == itemBarcode)
             .First();
 
-        //if (itemBarcodeDetails == null)
-        //    throw new Exception("鏉$爜涓嶅瓨鍦紝璇锋牳瀵癸紒");
+        if (itemBarcodeDetails == null)
+            throw new Exception("鏉$爜涓嶅瓨鍦紝璇锋牳瀵癸紒");
 
         if (string.IsNullOrEmpty(itemBarcodeDetails.Memo) || itemBarcodeDetails.Memo != "閲囪喘鍏ュ簱")
             throw new Exception("姝ゆ潯鐮佷笉灞炰簬鍒拌揣鏉$爜锛屾棤娉曠敤閲囪喘鍏ュ簱锛�");
 
         var inventory = Db.Queryable<MesInvItemArn>()
-            .Where(it => it.BillNo == itemBarcodeDetails.BillNo)
+            .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true )
             .First();
 
         if (inventory == null)
-            throw new Exception("姝ゆ潯鐮佹壘涓嶅埌瀵瑰簲鏀惰揣鍗曪紒");
+            throw new Exception("姝ゆ潯鐮佹壘涓嶅埌瀵瑰簲鏀惰揣鍗曟垨鏈鏍革紒");
 
         // var inventoryDetails = Db.Queryable<MesInvItemArnDetail>()
         //     .Where(it => it.ParentGuid == inventory.Guid
@@ -64,9 +64,14 @@
         if (inventoryDetails == null)
             throw new Exception("姝ゆ潯鐮佹壘涓嶅埌瀵瑰簲鏀惰揣鍗曟槑缁嗭紒");
 
-        if (string.IsNullOrEmpty(inventoryDetails.CheckRes) || inventoryDetails.CheckRes != "鍚堟牸")
+        //鑾峰彇鍒拌揣妫�楠屾槑缁�
+        var sqlParams = new List<SugarParameter> { new("@dhmxGuid", itemBarcodeDetails.AboutGuid) };
+        var sql1 = @"SELECT *FROM v_dhmx WHERE dhmxGuid = @dhmxGuid ";
+        var dhjymx = Db.Ado.SqlQuery<vDhmx>(sql1, sqlParams).First();
+        //鍒ゅ畾妫�楠岃兘鍚﹀叆搴�
+        if (dhjymx.CanStore!= 1)
         {
-            throw new Exception("璇ユ潯鐮佸搴旂殑鏀舵枡鍗曟楠屼笉鍚堟牸鎴栨湭妫�楠岋紒");
+            throw new Exception($"璇ユ潯鐮佸搴旂殑鏀舵枡鍗曟楠岀粨鏋�:銆恵dhjymx.InspectionResult}銆�,鍒ゅ畾缁撴灉锛氥�恵dhjymx.JudgmentResult}銆戯紝澶勭悊鎰忚锛氥�恵dhjymx.HandlingSuggestion}銆�,鏃犳硶鍏ュ簱");
         }
 
         var depotCode = Db.Queryable<MesDepotSections>()
@@ -82,10 +87,10 @@
         MesDepots mesDepost = null;
 
         var checkGuid = UtilityHelper.CheckGuid(depotCode);
-        if (checkGuid && depotCode2 != null)
+        if (checkGuid && depotCode != null)
         {
             mesDepost = Db.Queryable<MesDepots>()
-                .Where(s => s.DepotId.ToString() == depotCode2).First();
+                .Where(s => s.DepotId.ToString() == depotCode).First();
 
             // if (depotCode != mesDepost.Guid)
             //     throw new Exception("鎵弿搴撲綅涓庨噰璐叆搴撳簱浣嶄笉涓�鑷达紒");
@@ -784,7 +789,8 @@
                         FQty = a.Quantity, // 鐢宠鏁伴噺
                         FMaterialId = b.ItemId,
                         Id = a.Guid.ToString(),
-                        kw = a.DepotSectionCode
+                        kw = a.DepotSectionCode,
+                        barcode = a.ItemBarcode
                     })
                     .ToList();
 
@@ -855,6 +861,11 @@
             if (mesInvItemInCDetails == null)
                 throw new Exception("鐗╂枡鍏ュ簱鏉$爜鏄庣粏涓嶅瓨鍦�"); // 鎶涘嚭寮傚父浠ヤ緵鍓嶅彴澶勭悊
 
+            // 鍒涘缓 鎻掑叆鏃ュ織
+            var logService = new LogService();
+            var LogMsg = "銆怭DA銆戦噰璐叆搴撱�傛潯鐮併��" + entity.barcode + "銆� 鍏ュ簱鍗曞彿銆�" + cBillNo + "銆�";
+            logService.CreateLog(db, entity.userName, inventory.Guid.ToString(), "MES_INV_ITEM_ARN", LogMsg, inventory.BillNo);
+
             return 1;
         });
 

--
Gitblit v1.9.3