Demo
2024-02-19 d3521d4f8feda989df7f0f48eff6ee3fd6ebec47
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生成")
@@ -612,29 +612,37 @@
                #endregion
                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; //生产条码数量
@@ -669,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";
@@ -690,9 +698,10 @@
                        }
                    }
                    addLotNo = maxLotNoStr;
                    #endregion
                    for (int i = 1; i <= labelNum; i++)
                    {
@@ -765,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());
@@ -815,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";
@@ -836,9 +847,10 @@
                        }
                    }
                    addLotNo = maxCodestr2;
                    #endregion
                    for (int i = 1; i <= labelNum2; i++)//箱码标签
                    {
@@ -916,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()
                            {
@@ -923,7 +938,7 @@
                                ASNDetailNo = asnList.Id,
                                BoxNo = maxboxcode2,
                                BoxNo3 = maxboxcode3,
                                Qty = int.Parse(d.ToString()),
                                Qty = sss,
                                FullQty = bNum,
                                Status = "0",
                                SkuNo = asnList.SkuNo,
@@ -954,7 +969,20 @@
                    #endregion
                }
                if (string.IsNullOrWhiteSpace(asnList.LotNo))
                {
                    asnList.LotNo = addLotNo;
                    Db.Updateable(asnList).ExecuteCommand();
                }
                else
                {
                    if (!asnList.LotNo.Contains(addLotNo))
                    {
                        asnList.LotNo += ";" + addLotNo;
                        Db.Updateable(asnList).ExecuteCommand();
                    }
                }
                return modelList;
@@ -1014,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);
                            // 添加到list集合
                            printModelList.Add(model);
@@ -1069,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);
                                // 添加到list集合
                                printModelList.Add(model);
@@ -1121,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);
                            // 添加到list集合
                            printModelList.Add(model);
@@ -1173,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);
                                // 添加到list集合
                                printModelList.Add(model);
@@ -1237,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);
                                    // 添加到list集合
                                    printModelList.Add(model1);
@@ -1256,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);
                                    // 添加到list集合
                                    printModelList.Add(model);
@@ -1303,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);
                                    // 添加到list集合
                                    printModelList.Add(model);
@@ -1325,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);
                                        // 添加到list集合
                                        printModelList.Add(model);
@@ -1371,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);
                                // 添加到list集合
                                printModelList.Add(model);
@@ -1395,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);
                                        // 添加到list集合
@@ -1463,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);
                                // 添加到list集合
                                printModelList.Add(model);
@@ -1491,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);
                                        // 添加到list集合
                                        printModelList.Add(model1);
@@ -1522,9 +1550,6 @@
                #endregion
                //dataContext.WmsLabelPrintLog.InsertAllOnSubmit(printlog);
                //    dataContext.SubmitChanges();
                //    return printModel;
                return printModelList;
            }
            catch (Exception e)