From 3ffc9e207b22b4fff12e601aeb512b8d373e5a9d Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期四, 30 十月 2025 17:01:05 +0800
Subject: [PATCH] 修改问题

---
 Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs |  139 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 102 insertions(+), 37 deletions(-)

diff --git a/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
index c28c5bc..fd465ab 100644
--- a/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
+++ b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
@@ -997,10 +997,10 @@
                         inspectStatus = "1";
                         break;
                     case "1"://棰嗘枡鍑哄簱
-                        if (house != "W02")
-                        {
-                            throw new Exception("棰嗘枡鍑哄簱鍙兘閫夋嫨鍘熸枡搴�");
-                        }
+                        //if (house != "W02")
+                        //{
+                        //    throw new Exception("棰嗘枡鍑哄簱鍙兘閫夋嫨鍘熸枡搴�");
+                        //}
                         skuType = "(0,1,3)";
                         inspectStatus = "1";
                         break;
@@ -1097,7 +1097,7 @@
                     skuList = skuList.Where(m => m.SkuNo == "100088").ToList();
                 }
                 skuStrList = skuList.Select(m => m.SkuNo).ToList();
-                var areaStr = new List<string>() { "B06", "B07", "B09" };
+                var areaStr = new List<string>() { "B06", "B07", "B09", "B24" };
                 var stockRst = new StockServer();
                 var stockDetailRst = new StockDetailServer();
                 Expression<Func<DataStockDetail, bool>> item = Expressionable.Create<DataStockDetail>()
@@ -1194,6 +1194,12 @@
                         //}
                         break;
                     case "W02"://鍘熸枡搴�
+                        if (skuList.Any(m => m.Type == "2"))
+                        {
+                            throw new Exception("浠撳簱涓庡嚭搴撶墿鏂欎笉绗�");
+                        }
+                        break;
+                    case "W04"://骞冲簱
                         if (skuList.Any(m => m.Type == "2"))
                         {
                             throw new Exception("浠撳簱涓庡嚭搴撶墿鏂欎笉绗�");
@@ -2765,8 +2771,8 @@
                         }
                         #region 鍖呰淇℃伅
 
-                        var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺
-                        var bNum = 0;//绠辩墿鍝佹暟閲�
+                        var pNum = 0m;//鎵樼洏鐗╁搧鏁伴噺
+                        var bNum = 0m;//绠辩墿鍝佹暟閲�
                         //鍏叡鏂规硶鑾峰彇鍖呰鏁伴噺
                         new Common().GetPackQtyInfo(detail.PackagNo, ref pNum, ref bNum);
 
@@ -2774,7 +2780,8 @@
 
                         //鍙栧悎閫傚簱瀛樺晢鍝�
                         Dictionary<int, decimal> stockQtyDic = new Dictionary<int, decimal>();//鎵樺嚭搴撶墿鍝佹暟
-                        var qty = 0m;
+                        var qty = 0m;//鍒嗛厤鏁伴噺
+                        var xQty = 0m;//涓嬫灦鏁伴噺
                         var house = "";
 
                         //鍒嗛厤璐х墿
@@ -2810,6 +2817,11 @@
                                 CreateUser = userId,
                                 CreateTime = DateTime.Now
                             };
+                            if (s.WareHouseNo == "W04")
+                            {
+                                allot.Status = "2";//寰呮嫞璐�
+                                xQty += allot.Qty;
+                            }
                             exAllotList.Add(allot);
 
                             s.LockQty += stockQtyDic[s.Id];
@@ -2822,11 +2834,12 @@
                             {
                                 s.Status = "1";
                             }
-
+                           
                             var sd = Db.Updateable(s).UpdateColumns(it => new { it.LockQty, it.Status }).ExecuteCommand();
 
                         }
-                        detail.AllotQty += qty;
+                        detail.AllotQty += qty;//鍒嗛厤鏁伴噺
+                        detail.FactQty += xQty;//涓嬫灦鏁伴噺
                         detail.UpdateUser = userId;
                         detail.UpdateTime = DateTime.Now;
                         if (detail.Status == "0")
@@ -2892,8 +2905,13 @@
                                 //璇佹槑鎵�鏈夊垎閰嶆暟閲忓叏閮ㄥ皬浜庣瓑浜庡嚭搴撴暟閲� 涓嶅仛淇敼
                                 break;
                         }
-
+                        var outPalletCount = exAllotList.Where(w => w.Status == "0").Count();//鏌ユ壘鏈夋棤闇�瑕佸嚭搴撶殑鎵樼洏
+                        if (outPalletCount <= 0)
+                        {
+                            notice.Status = "3";//姝e湪鎵ц
+                        }
                     }
+                    
                     notice.UpdateUser = userId;
                     notice.UpdateTime = DateTime.Now;
                     var zd = Db.Updateable(notice).ExecuteCommand();
@@ -3005,6 +3023,7 @@
                             soDetailList.Add(soDetail);
                         }
                         d.AllotQty = 0;
+                        d.FactQty = 0;
                         d.Status = "0";
                         d.UpdateUser = userId;
                         d.UpdateTime = DateTime.Now;
@@ -3210,7 +3229,8 @@
                 //var stockz = Db.Queryable<DataStock>().First(d => d.IsDel == "0" && d.SkuNo == detail.SkuNo && d.LotNo == detail.LotNo);
 
                 var allotList = new List<BllExportAllot>();
-                decimal outQtys = 0;
+                decimal outQtys = 0;//鍒嗛厤鏁伴噺
+                decimal xQty = 0;//涓嬫灦鏁伴噺
                 foreach (var st in model.StockList)
                 {
                     var stock = stockList.First(a => a.Id == st.StockId);
@@ -3252,6 +3272,11 @@
                             CreateUser = userId,
                             CreateTime = DateTime.Now
                         };
+                        if (stock.WareHouseNo == "W04")
+                        {
+                            allot.Status = "2";//寰呮嫞璐�
+                            xQty += allot.Qty;
+                        }
                         allotList.Add(allot);
                     }
                     else
@@ -3274,7 +3299,8 @@
                 }
                 Db.Insertable(allotList).ExecuteCommand();
                 //淇敼鍗曟嵁鏄庣粏
-                detail.AllotQty += outQtys;
+                detail.AllotQty += outQtys;//鍒嗛厤鏁伴噺
+                detail.FactQty += xQty;//涓嬫灦鏁伴噺
                 detail.UpdateUser = userId;
                 detail.UpdateTime = DateTime.Now;
                 if (detail.Status == "0")
@@ -3303,6 +3329,12 @@
                     else if (totalAllotQty < totalQty && totalAllotQty > 0)
                     {
                         notice.Status = "1";//璇佹槑鍒嗛厤鏁伴噺灏忎簬绛変簬鍑哄簱鏁伴噺  淇敼涓洪儴鍒嗗垎閰�
+                    }
+
+                    var outPalletCount = allotList.Where(w => w.Status == "0").Count();//鏌ユ壘鏈夋棤闇�瑕佸嚭搴撶殑鎵樼洏
+                    if (outPalletCount <= 0)
+                    {
+                        notice.Status = "3";//姝e湪鎵ц
                     }
                     Db.Updateable(notice).ExecuteCommand();
                 }
@@ -4308,31 +4340,65 @@
 
                         var tray2 = Db.Queryable<DataStockDetail>().Where(m => m.SkuNo == item2.SkuNo
                             && m.LotNo == item2.LotNo && !slotList.Contains(m.LocatNo) && m.PalletTags == item2.PalletTags && okLan.Contains(m.RoadwayNo)).ToList();
-                        foreach (var s in tray2)
+                        if (tray2.Count > 0)
                         {
-                            if (string.IsNullOrWhiteSpace(s.RoadwayNo))//鍒ゆ柇鏄惁鍦ㄥ簱澶栵紝濡傛槸璺宠繃
+                            foreach (var s in tray2)
                             {
-                                continue;
-                            }
-                            var lan = Db.Queryable<SysStorageLocat>().Where(m => m.RoadwayNo == s.RoadwayNo).OrderBy(m => m.LocatNo).ToList();
-                            //鍒ゆ柇鏄惁鏈夊叆搴撲腑銆佸嚭搴撲腑銆佺Щ鍏ヤ腑銆佺Щ鍑轰腑
-                            if (lan.Count(m => m.Status == "2" || m.Status == "3" || m.Status == "4" || m.Status == "5") > 0)
-                            {
-                                continue;
-                            }
-                            if (lan.Count(m => m.Status == "0") > 0)
-                            {
-
-                                var bol = GetBecomingLocation(s.RoadwayNo, ref location);
-                                if (bol && !string.IsNullOrWhiteSpace(location))
+                                if (string.IsNullOrWhiteSpace(s.RoadwayNo))//鍒ゆ柇鏄惁鍦ㄥ簱澶栵紝濡傛槸璺宠繃
                                 {
-                                    newAddress = location;
-                                    return newAddress;
+                                    continue;
+                                }
+                                var lan = Db.Queryable<SysStorageLocat>().Where(m => m.RoadwayNo == s.RoadwayNo).OrderBy(m => m.LocatNo).ToList();
+                                //鍒ゆ柇鏄惁鏈夊叆搴撲腑銆佸嚭搴撲腑銆佺Щ鍏ヤ腑銆佺Щ鍑轰腑
+                                if (lan.Count(m => m.Status == "2" || m.Status == "3" || m.Status == "4" || m.Status == "5") > 0)
+                                {
+                                    continue;
+                                }
+                                if (lan.Count(m => m.Status == "0") > 0)
+                                {
+
+                                    var bol = GetBecomingLocation(s.RoadwayNo, ref location);
+                                    if (bol && !string.IsNullOrWhiteSpace(location))
+                                    {
+                                        newAddress = location;
+                                        return newAddress;
+                                    }
 
                                 }
-
                             }
                         }
+                        if(string.IsNullOrEmpty(newAddress))
+                        {
+                            //宸叉湁鐗╁搧鐨勫贩閬�
+                            var roadwayHave = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.WareHouseNo == "W01").GroupBy(g => g.RoadwayNo).Select(s => s.RoadwayNo).ToList();
+                            //鏌ユ壘娌℃湁鐗╁搧鐨勫贩閬�
+                            var roadwayNull = Db.Queryable<SysStorageRoadway>().Where(w => w.IsDel == "0" && w.WareHouseNo == "W01" && w.Status == "0" && okLan.Contains(w.RoadwayNo) && !roadwayHave.Contains(w.RoadwayNo)).Select(s => s.RoadwayNo).ToList();
+                            if (roadwayNull.Count > 0)
+                            {
+                                foreach (var itemRoad in roadwayNull)
+                                {
+                                    var bol = GetBecomingLocation(itemRoad, ref location);
+                                    if (bol && !string.IsNullOrWhiteSpace(location))
+                                    {
+                                        newAddress = location;
+                                        return newAddress;
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                foreach (var itemRoad in roadwayHave)
+                                {
+                                    var bol = GetBecomingLocation(itemRoad, ref location);
+                                    if (bol && !string.IsNullOrWhiteSpace(location))
+                                    {
+                                        newAddress = location;
+                                        return newAddress;
+                                    }
+                                }
+                            }
+                        }
+                        
                     }
                 }
 
@@ -4506,16 +4572,15 @@
 
                 if (slotModel[0].Column > aisleRow)
                 {
-                    // 鍙栨渶涓婇潰涓�鎺�
-                    location = slotModel[0].LocatNo;
-
-                }
-                else
-                {
                     // 鍙栨渶涓嬮潰涓�鎺�
 
                     location = slotModel[slotModel.Count - 1].LocatNo;
                 }
+                else
+                {
+                    // 鍙栨渶涓婇潰涓�鎺�
+                    location = slotModel[0].LocatNo;                    
+                }
 
                 bl = true;
             }

--
Gitblit v1.8.0