From ecb386a4201213c6635f28f9e9e02e3faf217b51 Mon Sep 17 00:00:00 2001 From: yuyou_x <2336760928@qq.com> Date: 星期六, 16 三月 2024 11:08:34 +0800 Subject: [PATCH] 修改储位图例柱状图以及圆形图显示数据问题。 --- Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs | 299 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 236 insertions(+), 63 deletions(-) diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs index 4011efa..9b74c1f 100644 --- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs +++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs @@ -264,7 +264,7 @@ .AndIF(!string.IsNullOrWhiteSpace(model.ProductionTime), it => it.ProductionTime >= Convert.ToDateTime(model.ProductionTime)) .AndIF(!string.IsNullOrWhiteSpace(model.InspectMark), it => it.InspectMark == model.InspectMark.Trim()) .AndIF(!string.IsNullOrWhiteSpace(model.BitBoxMark), it => it.BitBoxMark == model.BitBoxMark.Trim()) - .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => it.Origin == model.Origin.Trim()) + .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => model.Origin.Trim().Contains(it.Origin)) .And(m => m.SkuNo != "100099" && m.IsDel == "0" && m.Status == "0") .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏� var total = 0; @@ -412,7 +412,7 @@ .AndIF(!string.IsNullOrWhiteSpace(model.SkuNo), it => it.SkuNo.Contains(model.SkuNo.Trim())) .AndIF(!string.IsNullOrWhiteSpace(model.LotNo), it => it.LotNo.Contains(model.LotNo.Trim())) .AndIF(!string.IsNullOrWhiteSpace(model.SupplierLot), it => it.SupplierLot.Contains(model.SupplierLot.Trim())) - .AndIF(!string.IsNullOrWhiteSpace(model.Status), it => it.Status == model.SupplierLot) + .AndIF(!string.IsNullOrWhiteSpace(model.Status), it => it.Status == model.Status) .AndIF(!string.IsNullOrWhiteSpace(model.ProductionTime), it => it.ProductionTime >= Convert.ToDateTime(model.ProductionTime)) .AndIF(!string.IsNullOrWhiteSpace(model.ProductionTime), it => it.ProductionTime <= Convert.ToDateTime(model.ProductionTime).AddDays(1)) .And(it => it.IsDel == "0" && it.Origin == "WMS鐢熸垚") @@ -529,7 +529,7 @@ } //鑾峰彇鏍囩淇℃伅(鐢熸垚鏍囩) - public List<BllBoxInfo> AddLabelBox(int imId, string isReset, decimal arriveQty, string productionTime, string expirationTime, string storeTime, int userId) + public List<BllBoxInfo> AddLabelBox(int imId, string isReset, decimal arriveQty, string productionTime, string expirationTime, string storeTime,string supplierLot, int userId) { try { @@ -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 @@ -605,7 +605,7 @@ zNum = Convert.ToInt32(pack.L1Num); } - if (packLevel <= 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗� + if (packLevel < 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗� { throw new Exception("鍖呰淇℃伅鏈夎锛屽皬浜庝竴绾�"); } @@ -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,39 @@ 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 = labelCount.Max(a => a.LotNo); + + if (string.IsNullOrWhiteSpace(maxLotNoStr)) + { + maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; + } + maxBoxCode = label.Where(m => m.LotNo == maxLotNoStr).Max(a => a.BoxNo); + } + } 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 +741,7 @@ } //鑾峰彇绠辩爜 - if (maxBoxCode == "") + if (string.IsNullOrWhiteSpace(maxBoxCode)) { var str = "B"+maxLotNoStr + "000001"; //鎵瑰彿+ 娴佹按 2302010001000001 maxBoxCode = str; @@ -744,7 +765,7 @@ LotNo = maxLotNoStr, Standard = asnList.Standard, PackageStandard = packStr, - SupplierLot = asnList.SupplierLot, + SupplierLot = supplierLot, InspectMark = "0", BitBoxMark = bNum > boxQty ? "1":"0", InspectStatus = "", @@ -769,25 +790,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 +829,38 @@ 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 = labelCount.Max(a => a.LotNo); ; + + if (string.IsNullOrWhiteSpace(maxCodestr2)) + { + maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; + } + maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);//绠卞彿; + maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿; + } + } 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 +909,7 @@ } //鑾峰彇绠辩爜 - if (maxboxcode2 == "") + if (string.IsNullOrWhiteSpace(maxboxcode2)) { maxboxcode2 = "B"+maxCodestr2 + "000001"; // 绠卞彿 鎵瑰彿+绗嚑绠� } @@ -912,7 +953,7 @@ } } - if (maxboxcode3 == "") + if (string.IsNullOrWhiteSpace(maxboxcode3)) { maxboxcode3 = "Z"+maxCodestr2 + "0001"; // 鏀彿 鎵瑰彿+绗嚑绠� } @@ -975,7 +1016,7 @@ Db.Updateable(asnList).ExecuteCommand(); } } - + Db.CommitTran(); return modelList; @@ -983,6 +1024,7 @@ } catch (Exception e) { + Db.RollbackTran(); throw new Exception(e.Message); } } @@ -1512,7 +1554,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 +1585,6 @@ #endregion - //dataContext.WmsLabelPrintLog.InsertAllOnSubmit(printlog); - // dataContext.SubmitChanges(); - // return printModel; return printModelList; } catch (Exception e) @@ -1553,5 +1592,139 @@ throw new Exception(e.Message); } } + + //鏍规嵁鍏ュ簱鍗曞彿杩囧幓鍗曟嵁涓嬫墍鏈夋壒娆″彿 + public List<string> GetLotNoListByAsn(string asnNo) + { + try + { + var data = new List<string>(); + var asnList = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); + if (asnList.Count == 0) + { + throw new Exception("鏈煡璇㈠埌璇ュ崟鎹彿鐨勪俊鎭�"); + } + + foreach (var item in asnList) + { + if (string.IsNullOrWhiteSpace(item.LotNo)) + { + continue; + } + + var strList = item.LotNo.Split(";"); + foreach (var str in strList) + { + if (string.IsNullOrWhiteSpace(str)) + { + continue; + } + data.Add(str); + } + } + + return data; + } + catch (Exception e) + { + throw new Exception(e.Message); + } + } + + //鍒犻櫎鍗曟嵁涓嬪崟涓垨澶氫釜鎵规鐨勬爣绛� + public void DelLabelByAsnNo(string asnNo,string lotNo, int userId) + { + try + { + var asnList = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); + if (asnList.Count == 0) + { + throw new Exception("鏈煡璇㈠埌璇ュ崟鎹彿鐨勪俊鎭�"); + } + + Db.BeginTran(); + + //鎵规涓虹┖锛氬綋鍓嶅崟鎹笅鎵�鏈夋壒娆$殑鏍囩鍏ㄩ儴鍒犻櫎锛� 鏈夋壒娆★細浼ゅ褰撳墠鍗曟嵁涓嬪綋鍓嶆壒娆$殑鏍囩 + if (string.IsNullOrWhiteSpace(lotNo)) //鍒犻櫎鍏ㄩ儴鏍囩 + { + var labelList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); + if (labelList.Count(m => m.Status != "0") >= 1) + { + throw new Exception("褰撳墠鍗曟嵁鎵规鐨勬爣绛惧凡鏈夊凡浣跨敤锛屼笉鑳藉垹闄�"); + } + + foreach (var item in asnList) + { + if (string.IsNullOrWhiteSpace(item.LotNo)) + { + continue; + } + + item.LotNo = ""; + Db.Updateable(item).ExecuteCommand(); + + } + Db.Deleteable(labelList).ExecuteCommand(); + } + else //鍒犻櫎鍥哄畾鎵规鏍囩 + { + var labelList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo && m.LotNo == lotNo).ToList(); + if (labelList.Count(m=>m.Status != "0") >= 1 ) + { + throw new Exception("褰撳墠鍗曟嵁鎵规鐨勬爣绛惧凡鏈夊凡浣跨敤锛屼笉鑳藉垹闄�"); + } + + foreach (var item in asnList) + { + if (string.IsNullOrWhiteSpace(item.LotNo) || item.LotNo!=lotNo) + { + continue; + } + + var strList = item.LotNo.Split(";"); + var updateLotNo = ""; + foreach (var str in strList) + { + if (string.IsNullOrWhiteSpace(str) || str == lotNo) + { + continue; + } + + if (string.IsNullOrWhiteSpace(updateLotNo)) + { + updateLotNo = str; + } + else + { + updateLotNo += ";" + str; + } + + } + + item.LotNo = updateLotNo; + Db.Updateable(item).ExecuteCommand(); + + } + Db.Deleteable(labelList).ExecuteCommand(); + } + + Db.CommitTran(); + + var msg = $"鍒犻櫎浜嗗崟鎹彿锛歿asnNo}"; + if (!string.IsNullOrWhiteSpace(lotNo)) + { + msg += $"銆佹壒娆″彿锛歿lotNo}"; + } + msg += "鐨勬爣绛句俊鎭�"; + + new OperationASNServer().AddLogOperationAsn("鍏ュ簱浣滀笟", "鐗╂枡鏍囩", asnNo, "鍒犻櫎", msg, userId); + } + catch (Exception e) + { + Db.RollbackTran(); + throw new Exception(e.Message); + } + } + } } -- Gitblit v1.8.0