From 415c17f207966603c4c60c408f0e0bfdc3763ca7 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 04 二月 2024 16:07:23 +0800
Subject: [PATCH] Merge branch 'master' into wxw

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |   69 ++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index ea55e4a..353c602 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -1667,8 +1667,48 @@
                 throw ex;
             }
         }
+        // 鏍规嵁鍗曟嵁鍙疯幏鍙栧崟鎹槑缁嗗垪琛�
+        public List<ArrivalNoticeDetailDto> GetBindArrivalNoticeDetails(ArrivalNoticeVm model)
+        {
+            string sqlString = string.Empty;
+            try
+            {
+                sqlString = $"select * from BllArrivalNoticeDetail where ASNNo = '{model.ASNNo}' and isdel='0' order by CreateTime;";
+                var modelList = Db.Ado.SqlQuery<ArrivalNoticeDetailDto>(sqlString);
+                List<ArrivalNoticeDetailDto> noticeList = new List<ArrivalNoticeDetailDto>();
+                foreach (var item in modelList)
+                {
+                    if (string.IsNullOrEmpty(item.LotNo))
+                    {
+                        noticeList.Add(item);
+                    }
+                    else
+                    {
+                        string[] LotNoList = item.LotNo.Split(';');
+                        foreach (var item2 in LotNoList)
+                        {
+                            ArrivalNoticeDetailDto entry = new ArrivalNoticeDetailDto();
+                            entry = item;
+                            entry.LotNo = item2;
 
+                            noticeList.Add(entry);
+                        }
+                    }                   
+                }
+                return noticeList;
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
 
+        /// <summary>
+        /// 缁戝畾鎵樼洏
+        /// </summary>
+        /// <param name="model"></param>
+        /// <param name="userId"></param>
+        /// <param name="origin"></param>
         public void BindPallet(PdaPalletBindVm model, int userId, string origin)
         {
             try
@@ -1686,6 +1726,19 @@
                 if (string.IsNullOrEmpty(model.PalletNo))
                 {
                     throw new Exception("-1:鎵樼洏鍙蜂笉鍙负绌�!");
+                }
+                if (string.IsNullOrEmpty(model.LotNo))
+                {
+                    throw new Exception("-1:鐗╂枡鎵规涓嶅彲涓虹┖!");
+                }
+                else
+                {
+                    //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
+                    int indexOfDash = model.LotNo.IndexOf("-");
+                    if (indexOfDash != -1)
+                    {
+                        model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+                    }
                 }
                 //鍒ゆ柇鐗╂枡鏁伴噺鏄惁涓�0 涓�0鍒ゆ柇绠辩爜淇℃伅 涓嶄负0缁х画
                 if (model.SkuQty == 0)
@@ -1715,7 +1768,7 @@
                     throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
                 }
                 // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
-                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo);
+                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
                 if (detail == null)
                 {
                     throw new Exception("-1:褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
@@ -1791,7 +1844,7 @@
                         FullQty = pNum,
                         Status = "0",
                         Type = "0",
-                        LotNo = detail.LotNo,
+                        LotNo = model.LotNo,
                         LotText = detail.LotText,
                         SupplierLot = "",
                         InspectMark = "0",
@@ -1800,6 +1853,10 @@
                         IsBelt = "0",
                         CreateUser = userId
                     };
+                    if (model.SkuQty > pNum)
+                    {
+                        throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                    }
                     // 鎻掑叆鎵樼洏缁戝畾琛�
                     bindId = Db.Insertable(bind).ExecuteReturnIdentity();
                 }
@@ -1857,7 +1914,7 @@
                                 continue;
                             }
                             //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
-                            if (box.SkuNo != detail.SkuNo || box.LotNo != detail.LotNo)
+                            if (box.SkuNo != detail.SkuNo || box.LotNo != model.LotNo)
                             {
                                 throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
                             }
@@ -1893,6 +1950,10 @@
                 {
                     bind.BitPalletMark = "0";
                 }
+                if (bind.Qty > pNum)
+                {
+                    throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                }
                 Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
 
                 // 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲�
@@ -1922,7 +1983,7 @@
                 //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
                 sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','缁勭洏','0',getDate(),{userId},NULL,NULL);";
                 Db.Ado.ExecuteCommand(sqlStr);
-                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾1", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
+                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
 
                 Db.CommitTran();
             }

--
Gitblit v1.8.0