From adb69643f9f8fef29f2f20f51ee8faff97583ad2 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期二, 13 八月 2024 11:18:44 +0800
Subject: [PATCH] Merge branch 'wxw'

---
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 1b53369..2c3e986 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -1083,5 +1083,86 @@
         }
         #endregion
 
+        #region 闆剁瑙g粦
+        public void LingxingUnbind(string palletNo,string boxNo, int userId)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(palletNo))
+                {
+                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
+                }
+                if (string.IsNullOrEmpty(boxNo))
+                {
+                    throw new Exception("绠辩爜涓嶈兘涓虹┖");
+                }
+                //寮�鍚簨鍔�
+                Db.BeginTran();
+                var comTime = DateTime.Now;
+
+                //鎵樼洏搴撳瓨鏄庣粏淇℃伅
+                var detail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (detail == null)
+                {
+                    throw new Exception("璇ユ墭鐩樺簱瀛樻槑缁嗕俊鎭笉瀛樺湪");
+                }
+                //搴撳瓨绠辨敮鏄庣粏淇℃伅
+                var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.StockDetailId == detail.Id && w.BoxNo == boxNo).ToList();
+                if (boxList.Count <= 0)
+                {
+                    throw new Exception("璇ョ鐮佸簱瀛樼鏀俊鎭笉瀛樺湪");
+                }
+                decimal boxQty = 0;//绠卞唴鏁伴噺
+                foreach (var item in boxList)
+                {
+                    boxQty += item.Qty;
+
+                    item.StockDetailId = 0;//娓呯┖鎵樼洏澶栭敭
+                }
+                //鏇存柊搴撳瓨绠辨敮鏄庣粏琛�
+                Db.Updateable(boxList).ExecuteCommand();
+
+                detail.Qty -= boxQty;//鎵樼洏搴撳瓨鏁伴噺
+                detail.BitPalletMark = "1";//闆舵墭鏍囪
+                //鏇存柊鎵樼洏搴撳瓨琛�
+                Db.Updateable(detail).ExecuteCommand();
+
+                //娣诲姞鎵樼洏瑙g粦缁戝畾璁板綍
+                var unBind = new BllPalletUnbind()
+                {
+                    UpbindPalletNo = palletNo,
+                    BindPalletNo = "",
+                    LotNo = detail.LotNo,
+                    LotText = detail.LotText,
+                    SupplierLot = detail.SupplierLot,
+                    SkuNo = detail.SkuNo,
+                    SkuName = detail.SkuName,
+                    Standard = detail.Standard,
+                    Qty = boxQty,
+                    PalletNo2 = detail.PalletNo2,
+                    PalletNo3 = detail.PalletNo3,
+                    BoxNo = boxNo,
+                    InspectNo = "",
+                    InspectStatus = detail.InspectStatus,
+
+                    IsDel = "0",
+                    CreateTime = comTime,
+                    CreateUser = userId
+                };
+                Db.Insertable(unBind).ExecuteCommand();
+
+                //娣诲姞鎿嶄綔鏃ュ織
+                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"闆剁瑙g粦锛氬師鎵樼洏鐮侊細{palletNo}涓婄殑绠辩爜{boxNo}瑙g粦", userId);
+                //鎻愪氦浜嬪姟
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                //鍥炴粴浜嬪姟
+                Db.RollbackTran();
+                throw new Exception(e.Message);
+            }
+        }
+        #endregion
     }
 }

--
Gitblit v1.8.0