From 2b55ea83a98f5f5db2bb1e0576d54b583f017128 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期三, 14 八月 2024 13:45:11 +0800
Subject: [PATCH] 期初扫码入库

---
 MESApplication/bin/Debug/net8.0/MESApplication.pdb               |    0 
 MESApplication/Controllers/Warehouse/OpeningReceiptController.cs |   20 ++++++++++
 MESApplication/bin/Debug/net8.0/MESApplication.exe               |    0 
 MESApplication/bin/Debug/net8.0/MES.Service.pdb                  |    0 
 MESApplication/bin/Debug/net8.0/MESApplication.dll               |    0 
 MES.Service/bin/Debug/net8.0/MES.Service.dll                     |    0 
 MES.Service/service/Warehouse/OpeningReceiptServer.cs            |   69 +++++++++++++++++++++++++++++-----
 MES.Service/Dto/service/PurchaseInventory.cs                     |    2 +
 MESApplication/bin/Debug/net8.0/MES.Service.dll                  |    0 
 MES.Service/bin/Debug/net8.0/MES.Service.pdb                     |    0 
 10 files changed, 80 insertions(+), 11 deletions(-)

diff --git a/MES.Service/Dto/service/PurchaseInventory.cs b/MES.Service/Dto/service/PurchaseInventory.cs
index bb590d6..3067272 100644
--- a/MES.Service/Dto/service/PurchaseInventory.cs
+++ b/MES.Service/Dto/service/PurchaseInventory.cs
@@ -12,4 +12,6 @@
     public List<MesInvItemInCDetails>? InvItemInCDetails { get; set; }
 
     public List<MesInvItemInCItems>? ItemInDetails { get; set; }
+
+    public List<MesInvItemStocks>? ItemStocks { get; set; }
 }
\ No newline at end of file
diff --git a/MES.Service/bin/Debug/net8.0/MES.Service.dll b/MES.Service/bin/Debug/net8.0/MES.Service.dll
index c718d9d..df58553 100644
--- a/MES.Service/bin/Debug/net8.0/MES.Service.dll
+++ b/MES.Service/bin/Debug/net8.0/MES.Service.dll
Binary files differ
diff --git a/MES.Service/bin/Debug/net8.0/MES.Service.pdb b/MES.Service/bin/Debug/net8.0/MES.Service.pdb
index ccb8268..01a7922 100644
--- a/MES.Service/bin/Debug/net8.0/MES.Service.pdb
+++ b/MES.Service/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
diff --git a/MES.Service/service/Warehouse/OpeningReceiptServer.cs b/MES.Service/service/Warehouse/OpeningReceiptServer.cs
index 7e8c60e..c4d73b7 100644
--- a/MES.Service/service/Warehouse/OpeningReceiptServer.cs
+++ b/MES.Service/service/Warehouse/OpeningReceiptServer.cs
@@ -6,12 +6,15 @@
 
 namespace MES.Service.service.Warehouse;
 
-public class OpeningReceiptServer :RepositoryNoEntity
+public class OpeningReceiptServer : RepositoryNoEntity
 {
-    
     private const string Factory = "1000";
 
     private const string Company = "1000";
+
+    private const int billTypeId = 100;
+
+    private const int transactionNo = 601;
 
     public MesInvItemBarcodes ScanInBarcodeQC(WarehouseQuery query)
     {
@@ -25,9 +28,6 @@
         {
             throw new Exception($"002[搴撲綅缂栫爜 {query.sectionCode} 涓嶅瓨鍦紝璇风‘璁わ紒");
         }
-
-        int billTypeId = 100;
-        int transactionNo = 601;
 
         var checkBarcodeAlreadyReceived =
             CheckBarcodeAlreadyReceived(query.barcode);
@@ -49,7 +49,7 @@
         }
 
         var inventoryItemInId = GetOrCreateInventoryItemInId(barcodeInfo,
-            depotCode, query.userName, transactionNo, out string billNo);
+            depotCode, query.userName, out string billNo);
 
         UseTransaction(db =>
         {
@@ -64,8 +64,56 @@
             return 1;
         });
 
-
         return barcodeInfo;
+    }
+
+    public PurchaseInventory GetForm(WarehouseQuery query)
+    {
+        var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>()
+            .Where(s => s.ItemBarcode == query.barcode).Count();
+
+        if (mesInvItemBarcodes <= 0)
+        {
+            throw new Exception("鏉$爜涓嶅瓨鍦�");
+        }
+
+        var mesInvItemInCDetails = Db.Queryable<MesInvItemInCDetails>()
+            .Where(s => s.ItemBarcode == query.barcode).Single();
+
+        PurchaseInventory entity = new PurchaseInventory
+        {
+            ItemIns = GetMesInvItemIns(mesInvItemInCDetails.ItemInId),
+            InvItemInCDetails =
+                GetMesInvItemInCDetailsList(mesInvItemInCDetails.ItemInId),
+            ItemStocks = Db.Queryable<MesInvItemStocks>()
+                .Where(s => s.ItemBarcode == query.barcode).ToList()
+        };
+
+        return entity;
+    }
+
+    public MesInvItemIns GetMesInvItemIns(decimal id)
+    {
+        return Db.Queryable<MesInvItemIns>()
+            .Where(s => s.Id == id).Single();
+    }
+
+    public List<MesInvItemInCDetails> GetMesInvItemInCDetailsList(decimal id)
+    {
+        return Db.Queryable<MesInvItemInCDetails, MesUnit>((a, b) =>
+                new JoinQueryInfos(JoinType.Inner, a.Unit == b.Id.ToString()))
+            .Where((a, b) => a.ItemInId == id)
+            .Select((a, b) => new MesInvItemInCDetails
+            {
+                ItemBarcode = a.ItemBarcode,
+                ItemNo = a.ItemNo,
+                ItemSname = a.ItemSname,
+                DepotSectionCode = a.DepotSectionCode,
+                Quantity = a.Quantity,
+                Unit = b.Fname,
+                Remark = a.Remark
+            })
+            .ToList();
     }
 
     private void InsertInventoryDetails(decimal itemInId, string billNo,
@@ -113,7 +161,7 @@
     }
 
     private decimal GetOrCreateInventoryItemInId(MesInvItemBarcodes barcodeInfo,
-        string depotCode, string userName, int transactionNo, out string billNo)
+        string depotCode, string userName, out string billNo)
     {
         var inventory = Db.Queryable<MesInvItemIns>()
             .Where(d => d.InsDate >= DateTime.Today &&
@@ -125,7 +173,6 @@
                         d.SuppNo == barcodeInfo.SuppNo &&
                         d.DepotsCode == depotCode)
             .First();
-
         if (inventory != null)
         {
             billNo = inventory.BillNo;
@@ -139,7 +186,7 @@
         var executeReturnIdentity = Db.Insertable(new MesInvItemIns
         {
             BillNo = billNo,
-            BillTypeId = 100,
+            BillTypeId = billTypeId,
             InsDate = DateTime.Now,
             DepotsCode = depotCode,
             TransctionNo = transactionNo.ToString(),
@@ -231,7 +278,7 @@
         var executeCommand = Db.Insertable(new MesInvBusiness2
         {
             Status = 1,
-            BillTypeId = 100,
+            BillTypeId = billTypeId,
             TransactionCode = "601",
             BusinessType = 1,
             ItemBarcode = barcodeInfo.ItemBarcode,
diff --git a/MESApplication/Controllers/Warehouse/OpeningReceiptController.cs b/MESApplication/Controllers/Warehouse/OpeningReceiptController.cs
index 16b6884..9ed6425 100644
--- a/MESApplication/Controllers/Warehouse/OpeningReceiptController.cs
+++ b/MESApplication/Controllers/Warehouse/OpeningReceiptController.cs
@@ -31,4 +31,24 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+    
+    [HttpPost("GetForm")]
+    public ResponseResult GetForm(WarehouseQuery query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = m.GetForm(query);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
 }
\ No newline at end of file
diff --git a/MESApplication/bin/Debug/net8.0/MES.Service.dll b/MESApplication/bin/Debug/net8.0/MES.Service.dll
index c718d9d..df58553 100644
--- a/MESApplication/bin/Debug/net8.0/MES.Service.dll
+++ b/MESApplication/bin/Debug/net8.0/MES.Service.dll
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MES.Service.pdb b/MESApplication/bin/Debug/net8.0/MES.Service.pdb
index ccb8268..01a7922 100644
--- a/MESApplication/bin/Debug/net8.0/MES.Service.pdb
+++ b/MESApplication/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.dll b/MESApplication/bin/Debug/net8.0/MESApplication.dll
index c134f1b..d32e6d7 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.dll
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.dll
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.exe b/MESApplication/bin/Debug/net8.0/MESApplication.exe
index 021454c..271e79f 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.exe
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.exe
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.pdb b/MESApplication/bin/Debug/net8.0/MESApplication.pdb
index 8df847a..423e64b 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.pdb
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.pdb
Binary files differ

--
Gitblit v1.9.3