Demo
2024-02-20 5231a00695cfd27cf320a4e19a0c1417cb99128d
Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -618,7 +618,7 @@
                {
                    throw new Exception("到货数量不能小于0!");
                }
                Db.BeginTran();
                if (packLevel == 1)
                {
                    #region 一级包装
@@ -664,17 +664,31 @@
                    
                    if (isReset == "0")
                    {
                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
                        if (labelCount.Count <=0)
                        //判断单据是否是余料退回单
                        if (asn.Type == "4")
                        {
                            throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;");
                            maxLotNoStr = asnList.LotNo;
                            maxBoxCode = label.Where(m=>m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
                            {
                                throw new Exception("车间余料退回单据批次不能为空");
                            }
                        }
                        maxLotNoStr = label.Max(a => a.LotNo);
                        maxBoxCode = label.Max(a => a.BoxNo);
                        if (string.IsNullOrWhiteSpace(maxLotNoStr))
                        else
                        {
                            maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
                            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
                    {
@@ -814,21 +828,33 @@
                    string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
                    if (isReset == "0")
                    {
                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
                        if (labelCount.Count <= 0)
                        //判断单据是否是余料退回单
                        if (asn.Type == "4")
                        {
                            throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;");
                            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("车间余料退回单据批次不能为空");
                            }
                        }
                        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))
                        else
                        {
                            maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
                            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
                    {
@@ -988,7 +1014,7 @@
                        Db.Updateable(asnList).ExecuteCommand();
                    } 
                }
                Db.CommitTran();
                return modelList;
@@ -996,6 +1022,7 @@
            }
            catch (Exception e)
            {
                Db.RollbackTran();
                throw new Exception(e.Message);
            }
        }