From 86e443e42c4bee972c5b795def4917e02f98ce40 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期五, 11 七月 2025 16:45:08 +0800
Subject: [PATCH] 修改问题

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |  151 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 145 insertions(+), 6 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 43d5844..bae79e7 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -29,6 +29,7 @@
 using Model.ModelVm.SysVm;
 using System.Security.Cryptography.X509Certificates;
 using AutoMapper.Configuration.Annotations;
+using Utility;
 
 namespace WMS.BLL.BllPdaServer
 {
@@ -2643,6 +2644,22 @@
                         //娣诲姞搴撳瓨绠辩爜鏄庣粏
                         Db.Insertable(box2).ExecuteCommand();
                         #endregion
+
+                        #region  鎻掑叆杞﹂棿鍑哄叆搴撹褰曡〃
+                        //鎻掑叆鍏ュ簱鏃ュ織
+                        var _log = new LogWorkShop
+                        {
+                            Type = "0",//绫诲瀷锛�0锛氬叆搴� 1锛氬嚭搴�
+                            PalletNo = palletNo,
+                            BoxNo=box.BoxNo,
+                            LotNo=box.LotNo,
+                            SkuNo=box.SkuNo,
+                            SkuName=box.SkuName,
+                            Qty=box.Qty
+                        };
+                        //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                        Db.Insertable(_log).ExecuteCommand();
+                        #endregion
                     }
                     if (boxFullQty > bNum)
                     {
@@ -2651,7 +2668,6 @@
                 }
                 //鏇存敼绠辨敮鍏崇郴琛ㄤ俊鎭�
                 Db.Updateable(boxInfoList).ExecuteCommand();
-
 
                 #region 搴撳瓨
                 var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == boxInfoOne.LotNo);
@@ -2681,6 +2697,7 @@
                 }
                 #endregion
 
+                
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
                 var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{palletNo}';";
                 ////娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
@@ -2751,8 +2768,6 @@
                 new Common().GetPackQtyInfo(pack.PackagNo, ref pNum, ref bNum);
 
                 #endregion
-
-                 
 
                 #region 搴撳瓨鏄庣粏
 
@@ -2827,7 +2842,6 @@
                 // 鏇存敼绠辨敮鍏崇郴琛�
                 decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
 
-
                 #region 搴撳瓨
                 var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == skuInfo.SkuNo && m.LotNo == lotNo);
                 if (dataStock != null)
@@ -2856,6 +2870,21 @@
                 }
                 #endregion
 
+                #region
+                //鎻掑叆鍏ュ簱鏃ュ織
+                var _log = new LogWorkShop
+                {
+                    Type = "0",//绫诲瀷锛�0锛氬叆搴� 1锛氬嚭搴�
+                    PalletNo = palletNo,
+                    BoxNo = "",
+                    LotNo = lotNo,
+                    SkuNo = sd1.SkuNo,
+                    SkuName = sd1.SkuName,
+                    Qty = qty
+                };
+                //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                Db.Insertable(_log).ExecuteCommand();
+                #endregion
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
                 var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{palletNo}';";
                 ////娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
@@ -6045,9 +6074,12 @@
                 {
                     foreach (var item in stockDetail)
                     {
-                        if (!string.IsNullOrEmpty(item.WareHouseNo))
+                        if (!string.IsNullOrEmpty(item.WareHouseNo) && !string.IsNullOrEmpty(item.AreaNo))
                         {
-                            throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳鏌�!");
+                            if (item.AreaNo != "B06" && item.AreaNo != "B07" && item.AreaNo != "B09") 
+                            {
+                                throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳鏌�!");
+                            }
                         }
                     }
                     iscount = 1; //鍥炴祦鍏ュ簱
@@ -6484,6 +6516,113 @@
         }
         #endregion
 
+        #region 浠撳簱鏀惰揣
+        /// <summary>
+        /// 浠撳簱纭鏀惰揣
+        /// </summary>
+        /// <param name="model"></param>
+        public void ConfirmTakeOf(string palletNo,int userId)
+        {
+            try
+            {
+                #region 楠岃瘉淇℃伅
+                if (string.IsNullOrEmpty(palletNo))
+                {
+                    throw new Exception("鎵樼洏鏉$爜涓嶈兘涓虹┖!");
+                }
+
+                //鑾峰彇鎵樼洏淇℃伅
+                var pallet = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                //楠岃瘉鎵樼洏淇℃伅鏄惁涓虹┖
+                if (pallet == null)
+                {
+                    throw new Exception("鎵樼洏淇℃伅涓嶅瓨鍦紝璇锋鏌�!");
+                }
+                if (pallet.Status == "0")
+                {
+                    throw new Exception("鎵樼洏鏈娇鐢紝璇锋鏌�!");
+                }
+                #endregion
+
+                //鑾峰彇搴撳瓨鏄庣粏淇℃伅
+                var stockDetailList = Db.Queryable<DataStockDetail>().Where(s => s.IsDel == "0" && s.PalletNo == palletNo).ToList();
+                //楠岃瘉搴撳瓨鏄庣粏淇℃伅鏄惁瀛樺湪
+                if (stockDetailList.Count<=0)
+                {
+                    throw new Exception("搴撳瓨鏄庣粏涓嶅瓨鍦紝璇锋鏌ュ簱瀛樹俊鎭�!");
+                }
+                //寮�鍚簨鍔�
+                Db.BeginTran();
+
+                foreach (var item in stockDetailList)
+                {
+                    if (item.AreaNo != "B06" && item.AreaNo != "B07" && item.AreaNo != "B09")
+                    {
+                        throw new Exception("璇ユ墭鐩橀潪绾胯竟鍥炲簱鎵樼洏!");
+                    }
+                    //搴撳瓨鎬昏〃
+                    var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == item.SkuNo && w.LotNo == item.LotNo);
+                    if (stock == null)
+                    {
+                        throw new Exception($"鏈煡璇㈠埌璇ユ墭鐩樹笂鐗╂枡缂栫爜涓�:{item.SkuNo}鐨勫簱瀛樹俊鎭�!");
+                    }
+
+                    var boxInfoList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.PalletNo == palletNo && w.SkuNo == item.SkuNo && w.LotNo == item.LotNo).ToList();
+                    if (boxInfoList.Count > 0)
+                    {
+                        foreach (var box in boxInfoList)
+                        {
+                            var bllBox = Db.Queryable<BllBoxInfo>().First(w => w.IsDel == "0" && w.Status != "0" && w.BoxNo == box.BoxNo);
+                            if (bllBox != null)
+                            {
+                                bllBox.Status = "0";
+                                bllBox.ASNDetailNo = null;
+                                bllBox.BindNo = null;
+                                bllBox.PalletNo = "";
+                                //鏇存柊绠辨敮鏄庣粏琛�
+                                Db.Updateable(bllBox).ExecuteCommand();
+                            }
+                        }
+                        //鍒犻櫎搴撳瓨绠辩爜淇℃伅
+                        Db.Deleteable(boxInfoList).ExecuteCommand();
+                    }
+                    
+                    //鍒犻櫎鎴栦慨鏀瑰簱瀛�
+                    stock.Qty -= (decimal)item.Qty;
+                    if (stock.Qty <= 0)
+                    {
+                        Db.Deleteable(stock).ExecuteCommand();
+                    }
+                    else
+                    {
+                        Db.Updateable(stock).ExecuteCommand();
+                    }
+                    //鍒犻櫎搴撳瓨鏄庣粏
+                    Db.Deleteable(item).ExecuteCommand();
+
+                    //鍒ゆ柇鎵樼洏涓婅繕鏈夋病鏈夊叾浠栫墿鏂�
+                    var palletData = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && w.Id != item.Id);
+                    if (palletData == null)
+                    {
+                        pallet.Status = "0";
+                        Db.Updateable(pallet).ExecuteCommand();
+                    }
+                }
+
+                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "浠撳簱鏀惰揣", palletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愭墭鐩樼爜涓猴細{palletNo}鐨勪粨搴撴敹璐ф搷浣�", userId);
+
+                //鎻愪氦浜嬪姟
+                Db.CommitTran();
+            }
+            catch (Exception ex)
+            {
+                //鍥炴粴浜嬪姟
+                Db.RollbackTran();
+                throw ex;
+            }
+        }
+        #endregion
+
         #region JC23鍙栨牱涓氬姟鎺ュ彛
 
         //鑾峰彇鏈粍鎵樻垨宸茬粍鎵樼殑绠辩爜绾у埆

--
Gitblit v1.8.0