From 87d55df7b7446d7c4c3532a2dd2e78f72574e34b Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@DESKTOP-5BIMHQ3> Date: 星期三, 21 二月 2024 08:23:53 +0800 Subject: [PATCH] Merge branch 'master' into wxw --- Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs | 153 +++++++++++++++++++++++++++++++------------------- 1 files changed, 95 insertions(+), 58 deletions(-) diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs index e05c647..34dfa59 100644 --- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs +++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs @@ -576,7 +576,7 @@ packStr += "-" + pack.L5Num + "/" + pack.L5Name; } //鏍囩琛� - var label = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNDetailNo == imId).ToList(); + var label = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.Origin == "WMS鐢熸垚").ToList(); #endregion @@ -614,30 +614,35 @@ var modelList = new List<BllBoxInfo>(); var addLotNo = ""; - + if (arriveQty < 0) + { + throw new Exception("鍒拌揣鏁伴噺涓嶈兘灏忎簬0!"); + } + Db.BeginTran(); if (packLevel == 1) { #region 涓�绾у寘瑁� // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁� - var labQty = label.Sum(m => m.Qty); - var qty = asnList.Qty - labQty;//褰撳墠鍗曟嵁鍓╀綑闇�瑕佹墦鍗扮殑鐗╂枡鏁伴噺(涓嶆槸鏍囩鏁伴噺) - if (qty <= 0) - { - throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦"); - } + //var labQty = label.Sum(m => m.Qty); + //var qty = asnList.Qty - labQty;//褰撳墠鍗曟嵁鍓╀綑闇�瑕佹墦鍗扮殑鐗╂枡鏁伴噺(涓嶆槸鏍囩鏁伴噺) + //if (qty <= 0) + //{ + // throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦"); + //} #region 鍒拌揣鏁伴噺 - if (arriveQty - qty > 0) - { - throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺骞舵牳瀹�!"); - } - else - { - qty = arriveQty; - } - + //if (arriveQty - qty > 0) + //{ + // throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺骞舵牳瀹�!"); + //} + //else + //{ + // qty = arriveQty; + //} + + var qty = arriveQty; #endregion int labelNum = 1; //鐢熶骇鏉$爜鏁伴噺 @@ -656,23 +661,38 @@ string maxBoxCode = ""; //绠辩爜鍙� // 鐢熸垚鑷紪鎵瑰彿 string toDayTime = DateTime.Now.ToString("yyyyMMdd"); - - - var maxLotNo = label.Max(a => a.LotNo); - var maxBoxNo = label.Max(a => a.BoxNo); + if (isReset == "0") { - - maxLotNoStr = maxLotNo; - maxBoxCode = maxBoxNo; - if (string.IsNullOrWhiteSpace(maxLotNoStr)) + //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟 + if (asn.Type == "4") { - maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; + maxLotNoStr = asnList.LotNo; + maxBoxCode = label.Where(m=>m.LotNo == maxLotNoStr).Max(a => a.BoxNo); + if (string.IsNullOrWhiteSpace(maxLotNoStr)) + { + throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�"); + } } + else + { + var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); + if (labelCount.Count <= 0) + { + throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱"); + } + maxLotNoStr = label.Max(a => a.LotNo); + maxBoxCode = label.Max(a => a.BoxNo); + if (string.IsNullOrWhiteSpace(maxLotNoStr)) + { + maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; + } + } + } else { - var maxCode = Db.Queryable<BllLabelBoxNo>().Max(a => a.LotNo); // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿 + var maxCode = Db.Queryable<BllBoxInfo>().Where(m=>m.Origin == "WMS鐢熸垚").Max(a => a.LotNo); // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿 if (string.IsNullOrWhiteSpace(maxCode)) { maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; @@ -720,7 +740,7 @@ } //鑾峰彇绠辩爜 - if (maxBoxCode == "") + if (string.IsNullOrWhiteSpace(maxBoxCode)) { var str = "B"+maxLotNoStr + "000001"; //鎵瑰彿+ 娴佹按 2302010001000001 maxBoxCode = str; @@ -769,25 +789,27 @@ #region 浜岀骇鍖呰 // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁� - var labQty = label.Sum(m => m.Qty); - var qty2 = asnList.Qty - labQty; - if (qty2 <= 0) - { - throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦"); - } + //var labQty = label.Sum(m => m.Qty); + //var qty2 = asnList.Qty - labQty; + //if (qty2 <= 0) + //{ + // throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦"); + //} #region 澧炲姞鍒拌揣鏁伴噺 - if (arriveQty - qty2 > 0) - { - throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺!"); - } - else - { - qty2 = arriveQty; - } + //if (arriveQty - qty2 > 0) + //{ + // throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺!"); + //} + //else + //{ + // qty2 = arriveQty; + //} #endregion + + var qty2 = arriveQty; int labelNum2 = 1; //鐢熶骇绠辨潯鐮佹暟閲� labelNum2 = int.Parse(Math.Ceiling(qty2 / bNum).ToString()); @@ -806,20 +828,37 @@ string toDayTime2 = DateTime.Now.ToString("yyyyMMdd"); if (isReset == "0") { - var maxCode = label.Max(a => a.LotNo); - var boxCode1 = label.Max(a => a.BoxNo);//绠卞彿 - var boxCode2 = label.Max(a => a.BoxNo3);//鏀彿 - maxCodestr2 = maxCode; - maxboxcode2 = boxCode1; - maxboxcode3 = boxCode2; - if (string.IsNullOrWhiteSpace(maxCodestr2)) + //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟 + if (asn.Type == "4") { - maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; + maxCodestr2 = asnList.LotNo; + maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo); + maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿 + if (string.IsNullOrWhiteSpace(maxCodestr2)) + { + throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�"); + } } + else + { + var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); + if (labelCount.Count <= 0) + { + throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱"); + } + maxCodestr2 = label.Max(a => a.LotNo); ; + maxboxcode2 = label.Max(a => a.BoxNo);//绠卞彿; + maxboxcode3 = label.Max(a => a.BoxNo3);//鏀彿; + if (string.IsNullOrWhiteSpace(maxCodestr2)) + { + maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; + } + } + } else { - var maxCode = Db.Queryable<BllLabelBoxNo>().Max(a => a.LotNo); // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿 + var maxCode = Db.Queryable<BllBoxInfo>().Where(m => m.Origin == "WMS鐢熸垚").Max(a => a.LotNo); // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿 if (string.IsNullOrWhiteSpace(maxCode)) { maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; @@ -868,7 +907,7 @@ } //鑾峰彇绠辩爜 - if (maxboxcode2 == "") + if (string.IsNullOrWhiteSpace(maxboxcode2)) { maxboxcode2 = "B"+maxCodestr2 + "000001"; // 绠卞彿 鎵瑰彿+绗嚑绠� } @@ -912,7 +951,7 @@ } } - if (maxboxcode3 == "") + if (string.IsNullOrWhiteSpace(maxboxcode3)) { maxboxcode3 = "Z"+maxCodestr2 + "0001"; // 鏀彿 鎵瑰彿+绗嚑绠� } @@ -975,7 +1014,7 @@ Db.Updateable(asnList).ExecuteCommand(); } } - + Db.CommitTran(); return modelList; @@ -983,6 +1022,7 @@ } catch (Exception e) { + Db.RollbackTran(); throw new Exception(e.Message); } } @@ -1512,7 +1552,7 @@ model1.Qty = item.Qty;// 鏁伴噺 model1.BoxNo = item.BoxNo3; // 鏀彿 - model.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false); + model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false); // 娣诲姞鍒發ist闆嗗悎 printModelList.Add(model1); @@ -1543,9 +1583,6 @@ #endregion - //dataContext.WmsLabelPrintLog.InsertAllOnSubmit(printlog); - // dataContext.SubmitChanges(); - // return printModel; return printModelList; } catch (Exception e) -- Gitblit v1.8.0