From 19be6575a27a007b3dba7b0d28ddb769b5a1fed6 Mon Sep 17 00:00:00 2001
From: Demo <Demo@DESKTOP-CPA90BF>
Date: 星期二, 26 三月 2024 16:31:46 +0800
Subject: [PATCH] Merge branch 'csc'

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |  166 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 129 insertions(+), 37 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index c57bae9..2344c3b 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -17,6 +17,7 @@
 using Model.ModelDto.PdaDto;
 using Dm;
 using Model.InterFaceModel;
+using WMS.Entity.BllQualityEntity;
 
 namespace WMS.BLL.BllPdaServer
 {
@@ -68,7 +69,17 @@
                 sqlString = $"select * from BllArrivalNoticeDetail where ASNNo = '{model.ASNNo}' and isdel='0' order by CreateTime;";
                 var modelList = Db.Ado.SqlQuery<ArrivalNoticeDetailDto>(sqlString);
 
-                return modelList;
+                List<ArrivalNoticeDetailDto> list = new List<ArrivalNoticeDetailDto>();
+                foreach (var item in modelList)
+                {
+                    string str = BySkuNoGetPackInfo(item.SkuNo);
+                    if (str == "涓嶅瓨鍦�")
+                    {
+                        list.Add(item);
+                    }
+                }
+
+                return list;
             }
             catch (Exception ex)
             {
@@ -366,12 +377,12 @@
             {
                 //鑾峰彇浠诲姟淇℃伅
                 var logtask = Db.Queryable<LogTask>().First(a => a.PalletNo == upBindPalletNo && a.IsDel == "0" && a.Status == "1");
-                if (logtask == null)
+                if (logtask != null)
                 {
                     strMsg = "璇ユ墭鐩樹换鍔″凡瀹屾垚 鎴栨湭鎴愬姛鍒涘缓浠诲姟 璇锋牳瀹烇紒";
                     return strMsg;
                 }
-                string bindstr = "select * from BllPalletBind Where IsDel = @isdel and PalletNo = @palletno and ASNDetailNo = 0 and ASNNo = ''";
+                string bindstr = "select * from BllPalletBind Where IsDel = @isdel and PalletNo = @palletno and ASNDetailNo = 0 and ASNNo = '' ";
                 //鑾峰彇缁戝畾鎵樼洏琛ㄤ俊鎭�
                 List<PalletBindVm> bindVms = Db.Ado.SqlQuery<PalletBindVm>(bindstr, new
                 {
@@ -387,10 +398,13 @@
                     return strMsg;
                 }
                 //鍒犻櫎缁戝畾鎵樼洏琛ㄤ俊鎭�
-                string delstr = "delete from BllPalletBind Where PalletNo = @palletno";
+                string delstr = "update BllPalletBind set IsDel = 1,UpdateUser = @UpdateUser,UpdateTime = @UpdateTime Where PalletNo = @palletno and Id =@Id ";
                 int i = Db.Ado.ExecuteCommand(delstr, new
                 {
-                    palletno = upBindPalletNo
+                    UpdateUser = createUser,
+                    UpdateTime = DateTime.Now,
+                    palletno = upBindPalletNo,
+                    Id = bindVms[0].Id
                 });
                 //淇敼鎵樼洏鐘舵��
                 Db.BeginTran();
@@ -417,12 +431,12 @@
                 box.IsDel = "1";
                 Db.Updateable(box).ExecuteCommand();
 
-                //淇敼浠诲姟鐘舵��
-                logtask.IsDel = "1";
-                logtask.Status = "4"; //3 宸插彇娑�
-                logtask.UpdateUser = createUser; //鍙栨秷浜�
-                logtask.UpdateTime = DateTime.Now; //鍙栨秷鏃堕棿
-                Db.Updateable(logtask).ExecuteCommand();
+                ////淇敼浠诲姟鐘舵��
+                //logtask.IsDel = "1";
+                //logtask.Status = "4"; //3 宸插彇娑�
+                //logtask.UpdateUser = createUser; //鍙栨秷浜�
+                //logtask.UpdateTime = DateTime.Now; //鍙栨秷鏃堕棿
+                //Db.Updateable(logtask).ExecuteCommand();
                 //鏇存敼搴撳瓨鏁伴噺
                 //string str = $"update DataStock set Qty = Qty - {(int)bindVms[0].Qty} Where SkuNo = '100099'";
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
@@ -1751,11 +1765,44 @@
                         }
                     }
                 }
-                return noticeList;
+                List<ArrivalNoticeDetailDto> list = new List<ArrivalNoticeDetailDto>();
+                foreach (var item in noticeList)
+                {
+                    string str = BySkuNoGetPackInfo(item.SkuNo);
+                    if (str == "瀛樺湪")
+                    {
+                        list.Add(item);
+                    }
+                }
+
+                return list;
             }
             catch (Exception ex)
             {
                 throw ex;
+            }
+        }
+
+        //鏍规嵁鐗╂枡鑾峰彇鏄惁瀛樺湪鍖呰淇℃伅
+        public string BySkuNoGetPackInfo(string skuNo)
+        {
+            try
+            {
+                //鑾峰彇鐗╂枡淇℃伅
+                var sku = Db.Queryable<SysMaterials>().First(a => a.IsDel == "0" && a.SkuNo == skuNo);
+                //鍒ゆ柇鐗╂枡淇℃伅鏄惁涓虹┖
+                if (!string.IsNullOrWhiteSpace(sku.PackagNo))
+                {
+                    return "瀛樺湪";
+                }
+                else
+                {
+                    return "涓嶅瓨鍦�";
+                }
+            }
+            catch (Exception ex)
+            {
+                return ex.Message;
             }
         }
 
@@ -1788,9 +1835,9 @@
                 }
                 //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
                 var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
-                if (notice.Status != "0" && notice.Status != "1")
+                if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2")
                 {
-                    throw new Exception("-1:鍏ュ簱鍗曠姸鎬佷笉鏄瓑寰呮墽琛屾垨鎵ц瀹屾垚!");
+                    throw new Exception("-1:璇ュ崟鎹凡鍏冲崟!");
                 }
                 if (string.IsNullOrEmpty(model.LotNo))
                 {
@@ -1815,7 +1862,7 @@
                     }
                 }
                 //鍒ゆ柇鐗╂枡鏁伴噺鏄惁涓�0 涓�0鍒ゆ柇绠辩爜淇℃伅 涓嶄负0缁х画
-                if (model.SkuQty == 0)
+                if (model.TableType == 0)
                 {
                     if (string.IsNullOrEmpty(model.BoxNo))
                     {
@@ -1831,6 +1878,7 @@
 
                     }
                 }
+                int isTextTable = model.TableType;
                 int isDeposit = 0;
                 //鍒ゆ柇鎬诲崟鍗曟嵁鏄惁涓哄瘎瀛樺崟鎹�
                 if (notice.Type == "7")
@@ -1889,12 +1937,12 @@
                 }
                 //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶�
                 var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
-                if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
+                if (stockDetail != null)// && !string.IsNullOrEmpty(stockDetail.WareHouseNo)
                 {
-                    throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳瀹烇紒");
+                    throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁淇℃伅锛岃鏍稿疄锛�");
                 }
                 // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
-                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && model.LotNo.Contains(m.LotNo));
+                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:褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
@@ -1908,7 +1956,7 @@
                 var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 
 
                 //鍒ゆ柇鏄惁涓哄瘎瀛樼墿鏂�
-                if (isDeposit == 0)
+                if (isDeposit == 0 && isTextTable == 0)
                 {
                     if (pack == null)
                     {
@@ -1961,7 +2009,7 @@
                     }
                 }
                 #endregion
-                var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
+                var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo && m.Status != "2");
                 var bindId = 0;
                 if (bind == null)
                 {
@@ -1978,7 +2026,7 @@
                         Type = "0",
                         LotNo = model.LotNo,
                         LotText = detail.LotText,
-                        SupplierLot = "",
+                        SupplierLot = detail.SupplierLot,
                         InspectMark = "0",
                         BitPalletMark = "1",
                         IsBale = "0",
@@ -1987,10 +2035,10 @@
                         Demo = model.Demo,
 
                     };
-                    if (model.SkuQty > pNum && isDeposit == 0)
-                    {
-                        throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
-                    }
+                    //if (model.TableType == 0 && isDeposit == 0 && isTextTable == 0)   涓嶅お鐞嗚В杩欐浠g爜鐨勫惈涔�
+                    //{
+                    //    throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                    //}
                     // 鎻掑叆鎵樼洏缁戝畾琛�
                     bindId = Db.Insertable(bind).ExecuteReturnIdentity();
                 }
@@ -2037,7 +2085,7 @@
                 // 鏇存敼绠辨敮鍏崇郴琛�
                 decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
                 //鎴愬搧缁勬墭
-                if (model.SkuQty == 0)
+                if (isTextTable == 0)
                 {
                     var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
                     foreach (var g in boxGroup)
@@ -2077,7 +2125,7 @@
                     // 鏇存柊鎵樼洏缁戝畾琛�
                     bind.Qty += factQty;
                 }
-                if (bind.FullQty < bind.Qty && isDeposit == 0)
+                if (bind.FullQty < bind.Qty && isDeposit == 0 && isTextTable == 0)
                 {
                     throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
                 }
@@ -2086,7 +2134,7 @@
                 {
                     bind.BitPalletMark = "0";
                 }
-                if (bind.Qty > pNum && isDeposit == 0)
+                if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0)
                 {
                     throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
                 }
@@ -2148,10 +2196,10 @@
             try
             {
                 #region 楠岃瘉淇℃伅
-                if (string.IsNullOrEmpty(model.ASNNo))
-                {
-                    throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!");
-                }
+                //if (string.IsNullOrEmpty(model.ASNNo))
+                //{
+                //    throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!");
+                //}
                 if (string.IsNullOrEmpty(model.PalletNo))
                 {
                     throw new Exception("鎵樼洏鏉$爜涓嶈兘涓虹┖!");
@@ -2224,7 +2272,7 @@
                     #endregion
 
                     #region 绠辩爜淇℃伅
-                    var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo).ToList();
+                    var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.PalletNo == model.PalletNo).ToList();
                     // type 0:鎴愬搧鍏ュ簱 1:閲囪喘鍏ュ簱 2:涓棿鍝佸叆搴� 3:閫�璐у叆搴� 4:杞﹂棿浣欐枡閫�鍥炲叆搴� 5:鍏跺畠鍏ュ簱 6:浠e偍鍏ュ簱 7:瀵勫瓨鍏ュ簱
                     if (notice.Type == "2" || notice.Type == "6" || notice.Type == "7")
                     {
@@ -2298,6 +2346,12 @@
                             CreateUser = (int)model.CreateUser,
                             CreateTime = serverTime
                         };
+                        //缁存姢搴撳瓨璐т富淇℃伅
+                        if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                        {
+                            stockModel.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                            stockModel.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                        }
                         //鏂板搴撳瓨鎬讳俊鎭�
                         Db.Insertable<DataStock>(stockModel).ExecuteCommand();
                     }
@@ -2350,11 +2404,43 @@
                             PackagNo = sku.PackagNo,
                             IsBale = bindInfo.IsBale,
                             IsBelt = bindInfo.IsBelt,
+
                             CreateUser = (int)model.CreateUser,
                             CreateTime = serverTime
                         };
+                        //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                        if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                        {
+                            detailModel.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                            detailModel.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                        }
+                        else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
+                        {
+                            detailModel.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+                            detailModel.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
+                        }
+                        #region  缁存姢璐ㄦ缁撴灉
+                        //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
+                        var quality = Db.Queryable<BllQualityInspect>().Where(a => a.LotNo == noticeDetail.LotNo && a.IsDel == "0").OrderByDescending(a => a.CreateTime).First();
+                        if (quality != null)
+                        {
+                            //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
+                            if (quality.IsQualified == "1") //鍚堟牸
+                            {
+                                //澧炲姞鍚堟牸鏁伴噺
+                                quality.PassQty += detailModel.Qty;
+                                detailModel.InspectStatus = "1";
+                            }
+                            else if (quality.IsQualified == "0") //涓嶅悎鏍�
+                            {
+                                //澧炲姞涓嶅悎鏍兼暟閲�
+                                quality.FailQty += detailModel.Qty;
+                                detailModel.InspectStatus = "2";
+                            }
+                            Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
+                        }
+                        #endregion
                         stId = Db.Insertable<DataStockDetail>(detailModel).ExecuteReturnIdentity();
-
                     }
                     else
                     {
@@ -2505,7 +2591,7 @@
                         IsFinish = 0,//鏄惁鍙畬鎴�
                         Type = "0",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
                         Status = "2",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
-                        OrderType = "0",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
+                        OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
                         Msg = "鍔涜骞冲簱鐨勫洖搴撲换鍔�",
                     };
                     Db.Insertable(exTask).ExecuteCommand();
@@ -2517,8 +2603,14 @@
                 //淇敼鍌ㄤ綅淇℃伅                                        
                 Db.Updateable(storageLocat).ExecuteCommand();
 
-                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser);
-
+                if (iscount == 1)
+                {
+                    new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愭墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳洖娴佸叆搴撴搷浣�", (int)model.CreateUser);
+                }
+                else
+                {
+                    new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser);
+                }
                 Db.CommitTran();
             }
             catch (Exception ex)

--
Gitblit v1.8.0