From d3521d4f8feda989df7f0f48eff6ee3fd6ebec47 Mon Sep 17 00:00:00 2001
From: Demo <Demo@DESKTOP-CPA90BF>
Date: 星期一, 19 二月 2024 09:59:22 +0800
Subject: [PATCH] 修改标签生成数量限制问题

---
 Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs |  103 +++++++++++++++++++++++++++------------------------
 1 files changed, 55 insertions(+), 48 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
index 8511af4..870b0e8 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -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鐢熸垚")
@@ -614,30 +614,35 @@
                 var modelList = new List<BllBoxInfo>();
 
                 var addLotNo = "";
+                if (arriveQty < 0)
+                {
+                    throw new Exception("鍒拌揣鏁伴噺涓嶈兘灏忎簬0!");
+                }
 
                 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; //鐢熶骇鏉$爜鏁伴噺
@@ -672,7 +677,7 @@
                     }
                     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";
@@ -769,25 +774,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());
@@ -819,7 +826,7 @@
                     }
                     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";
@@ -921,6 +928,9 @@
                                 maxboxcode3 = maxboxcode3.Substring(0, 11) + (int.Parse(maxboxcode3.Substring(11, 4)) + 1).ToString().PadLeft(4, '0'); 
                             }
 
+                            var ssss = d.ToString("0");
+                            var sss = int.Parse(ssss);
+
                             // 灏嗘潯鐮佷繚瀛樺埌鍘熸枡鏉$爜琛�
                             var labelModel = new BllBoxInfo()
                             {
@@ -928,7 +938,7 @@
                                 ASNDetailNo = asnList.Id,
                                 BoxNo = maxboxcode2,
                                 BoxNo3 = maxboxcode3,
-                                Qty = int.Parse(d.ToString()),
+                                Qty = sss,
                                 FullQty = bNum,
                                 Status = "0",
                                 SkuNo = asnList.SkuNo,
@@ -1032,7 +1042,7 @@
 
                             model.BoxNo = data.BoxNo;                 // 绠卞彿     
 
-                            model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo,260, 15,true);
+                            model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo,160, 40,false);
 
                             // 娣诲姞鍒發ist闆嗗悎
                             printModelList.Add(model);
@@ -1087,7 +1097,7 @@
 
                                 model.BoxNo = data.BoxNo;                 // 绠卞彿     
 
-                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                 // 娣诲姞鍒發ist闆嗗悎
                                 printModelList.Add(model);
@@ -1139,7 +1149,7 @@
 
                             model.BoxNo = data.BoxNo3;                 // 鏀彿     
 
-                            model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                            model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                             // 娣诲姞鍒發ist闆嗗悎
                             printModelList.Add(model);
@@ -1191,7 +1201,7 @@
 
                                 model.BoxNo = data.BoxNo3;                 // 绠卞彿     
 
-                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                 // 娣诲姞鍒發ist闆嗗悎
                                 printModelList.Add(model);
@@ -1255,7 +1265,7 @@
                                     model1.Qty = dataList.Sum(m=>m.Qty);// 鏁伴噺
                                     model1.BoxNo = data.BoxNo;                 // 绠卞彿     
 
-                                    model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 15, true);
+                                    model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false);
 
                                     // 娣诲姞鍒發ist闆嗗悎
                                     printModelList.Add(model1);
@@ -1274,7 +1284,7 @@
                                     model.Qty = data.Qty;// 鏁伴噺
                                     model.BoxNo = data.BoxNo3;                 // 鏀彿     
 
-                                    model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                    model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                     // 娣诲姞鍒發ist闆嗗悎
                                     printModelList.Add(model);
@@ -1321,7 +1331,7 @@
                                     model.Qty = data.Sum(m => m.Qty);     // 鏁伴噺
                                     model.BoxNo = boxData.BoxNo;                 // 鏀彿     
 
-                                    model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                    model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                     // 娣诲姞鍒發ist闆嗗悎
                                     printModelList.Add(model);
@@ -1343,7 +1353,7 @@
                                         model1.Qty = item.Qty;// 鏁伴噺
                                         model1.BoxNo = item.BoxNo3;                 // 鏀彿     
 
-                                        model.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 15, true);
+                                        model.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false);
 
                                         // 娣诲姞鍒發ist闆嗗悎
                                         printModelList.Add(model);
@@ -1389,7 +1399,7 @@
                                 model.Qty = data.Sum(m => m.Qty);     // 鏁伴噺
                                 model.BoxNo = boxData.BoxNo;                 // 鏀彿     
 
-                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                 // 娣诲姞鍒發ist闆嗗悎
                                 printModelList.Add(model);
@@ -1413,7 +1423,7 @@
                                         model1.Qty = item.Qty;     // 鏁伴噺
                                         model1.BoxNo = item.BoxNo3;                 // 鏀彿     
 
-                                        model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 15, true);
+                                        model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false);
 
 
                                         // 娣诲姞鍒發ist闆嗗悎
@@ -1481,7 +1491,7 @@
                                 model.Qty = data.Sum(m => m.Qty);     // 鏁伴噺
                                 model.BoxNo = boxData.BoxNo;                 // 鏀彿     
 
-                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 15, true);
+                                model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 160, 40, false);
 
                                 // 娣诲姞鍒發ist闆嗗悎
                                 printModelList.Add(model);
@@ -1509,7 +1519,7 @@
                                         model1.Qty = item.Qty;// 鏁伴噺
                                         model1.BoxNo = item.BoxNo3;                 // 鏀彿     
 
-                                        model.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 15, true);
+                                        model1.ImgStr = BarcodeHelper.GetCodeBarBase64(model1.BoxNo, 160, 40, false);
 
                                         // 娣诲姞鍒發ist闆嗗悎
                                         printModelList.Add(model1);
@@ -1540,9 +1550,6 @@
 
                 #endregion
 
-                //dataContext.WmsLabelPrintLog.InsertAllOnSubmit(printlog);
-                //    dataContext.SubmitChanges();
-                //    return printModel;
                 return printModelList;
             }
             catch (Exception e)

--
Gitblit v1.8.0