From 1caf2d9d3f6c2ee8d58d182078d0a8468f6dbfc4 Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期六, 24 八月 2024 19:14:31 +0800
Subject: [PATCH] 物料接收

---
 MES.Service/service/Warehouse/MesInvItemOutCDetailsManager.cs |  138 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 1 deletions(-)

diff --git a/MES.Service/service/Warehouse/MesInvItemOutCDetailsManager.cs b/MES.Service/service/Warehouse/MesInvItemOutCDetailsManager.cs
index 4d40c63..8015c77 100644
--- a/MES.Service/service/Warehouse/MesInvItemOutCDetailsManager.cs
+++ b/MES.Service/service/Warehouse/MesInvItemOutCDetailsManager.cs
@@ -1,4 +1,5 @@
 锘縰sing MES.Service.DB;
+using MES.Service.Dto.service;
 using MES.Service.Modes;
 using SqlSugar;
 
@@ -38,7 +39,8 @@
         conModels.Add(new ConditionalModel
         {
             FieldName = typeof(MesInvItemOutCDetails).GetProperties()[0].Name,
-            ConditionalType = ConditionalType.Equal, FieldValue = "1"
+            ConditionalType = ConditionalType.Equal,
+            FieldValue = "1"
         }); //id=1
         var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom());
 
@@ -75,4 +77,138 @@
     }
 
     #endregion
+
+
+    public MesInvItemOutCDetails GetOutList(WarehouseQuery query)
+    {
+
+
+
+        var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>()
+            .Where(s => s.ItemBarcode == query.barcode).Count();
+
+        if (mesInvItemBarcodes <= 0)
+        {
+            throw new Exception("鏉$爜涓嶅瓨鍦�");
+        }
+
+        var mesInvItemOutCDetails = Db.Queryable<MesInvItemOutCDetails>()
+            .Where(s => s.ItemBarcode == query.barcode && s.Receive == 0).Count();
+
+
+
+        if (mesInvItemOutCDetails <= 0)
+        {
+            throw new Exception("鏉$爜涓嶇鍚堟帴鏀舵潯浠�,璇锋鏌ワ紒");
+        }
+
+
+
+        var entity = Db.Queryable<MesInvItemOutCDetails, MesInvItemOuts, MesItems>((a, b, c) =>
+                  new JoinQueryInfos(JoinType.Left, a.ItemOutId == b.Id,
+                                    JoinType.Left, a.ItemNo == c.ItemNo))
+              .Where((a, b, c) => a.ItemBarcode == query.barcode)
+              .Select((a, b, c) => new MesInvItemOutCDetails
+              {
+                  PbillNo = b.ItemOutNo,
+                  WorkNo = a.WorkNo,
+                  ItemNo = a.ItemNo,
+                  ItemName = c.ItemName,
+                  Quantity = a.Quantity
+              }).First();
+
+        if (entity == null)
+        {
+            throw new Exception("鍑哄簱鏉$爜" + query.barcode + " 涓嶅瓨鍦紝璇风‘璁�!");
+        }
+
+
+        return entity;
+    }
+
+
+    public MaterialReceipt GetFormList(WarehouseQuery query)
+    {
+        var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>()
+            .Where(s => s.ItemBarcode == query.barcode).Count();
+
+        if (mesInvItemBarcodes <= 0)
+        {
+            throw new Exception("鏉$爜涓嶅瓨鍦�");
+        }
+
+        var mesInvItemOutCDetails = Db.Queryable<MesInvItemOutCDetails>()
+            .Where(s => s.ItemBarcode == query.barcode).First();
+
+        MaterialReceipt entity = new MaterialReceipt
+        {
+            InvItemoutCDetails = GetMesInvItemOutCDetails(mesInvItemOutCDetails.PbillNo),
+            ItemOuts = GetMesInvItemOuts(mesInvItemOutCDetails.PbillNo)
+
+        };
+
+        return entity;
+    }
+
+
+    public MesInvItemOutCDetails confirmReceipt(WarehouseQuery query)
+    {
+        if (string.IsNullOrWhiteSpace(query.barcode))
+        {
+            throw new Exception("璇锋壂鍑哄簱鏉$爜锛�");
+        }
+
+        if (string.IsNullOrWhiteSpace(query.billNo))
+        {
+            throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖锛�");
+        }
+
+
+
+
+        var barcodeInfo = GetBarcodeInfo(query.barcode);
+
+
+        if (barcodeInfo.Receive == 1)
+        {
+            throw new Exception("姝ゆ潯鐮佸凡缁忔帴鏀�,璇锋鏌ワ紒");
+        }
+
+
+        UseTransaction(db =>
+        {
+
+            var count = db.Updateable<MesInvItemOutCDetails>()
+             .SetColumns(s => s.Receive == 1)
+             .Where(s => s.ItemBarcode == barcodeInfo.ItemBarcode).ExecuteCommand();
+
+            return 1;
+        });
+
+        return barcodeInfo;
+    }
+
+
+
+    public List<MesInvItemOutCDetails> GetMesInvItemOutCDetails(string billno)
+    {
+        return Db.Queryable<MesInvItemOutCDetails>()
+            .Where(s => s.PbillNo == billno).ToList();
+    }
+
+    public MesInvItemOuts GetMesInvItemOuts(string billno)
+    {
+        return Db.Queryable<MesInvItemOuts>()
+            .Where(a => a.ItemOutNo == billno).Single();
+    }
+
+
+
+    private MesInvItemOutCDetails GetBarcodeInfo(string itemBarcode)
+    {
+        // Get barcode information
+        return Db.Queryable<MesInvItemOutCDetails>()
+            .First(b => b.ItemBarcode == itemBarcode);
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3