Demo
2024-02-19 1204e1ae66a50ec99b4dea80e839c1264c36ef48
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!");
                }
                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,15 +661,16 @@
                    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;
                        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";
@@ -672,7 +678,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";
@@ -720,7 +726,7 @@
                        }
                        //获取箱码
                        if (maxBoxCode == "")
                        if (string.IsNullOrWhiteSpace(maxBoxCode))
                        {
                            var str = "B"+maxLotNoStr + "000001"; //批号+ 流水  2302010001000001
                            maxBoxCode = str;
@@ -769,25 +775,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,6 +814,11 @@
                    string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
                    if (isReset == "0")
                    {
                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
                        if (labelCount.Count <= 0)
                        {
                            throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;");
                        }
                        var maxCode = label.Max(a => a.LotNo);
                        var boxCode1 = label.Max(a => a.BoxNo);//箱号
                        var boxCode2 = label.Max(a => a.BoxNo3);//支号
@@ -819,7 +832,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";
@@ -868,7 +881,7 @@
                        }
                        //获取箱码
                        if (maxboxcode2 == "")
                        if (string.IsNullOrWhiteSpace(maxboxcode2))
                        {
                            maxboxcode2 = "B"+maxCodestr2 + "000001"; // 箱号     批号+第几箱
                        }
@@ -912,7 +925,7 @@
                                }
                            }
                            
                            if (maxboxcode3 == "")
                            if (string.IsNullOrWhiteSpace(maxboxcode3))
                            {
                                maxboxcode3 = "Z"+maxCodestr2 + "0001"; // 支号     批号+第几箱 
                            }
@@ -1512,7 +1525,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);
                                        // 添加到list集合
                                        printModelList.Add(model1);
@@ -1543,9 +1556,6 @@
                #endregion
                //dataContext.WmsLabelPrintLog.InsertAllOnSubmit(printlog);
                //    dataContext.SubmitChanges();
                //    return printModel;
                return printModelList;
            }
            catch (Exception e)