zhaowc
2025-04-07 19e95f4acc328bbf62a0427fe658d00268019e66
Wms/WMS.BLL/SysServer/PalletsServer.cs
@@ -71,13 +71,17 @@
        {
            try
            {
                var time = DateTime.Now.ToString("yyyy");
                var time2 = time.Substring(2, 2);
                int codeId;
                //var time = DateTime.Now.ToString("yyyy");
                //var time2 = time.Substring(2, 2);
                int liuShuiCode ;
                if (!string.IsNullOrWhiteSpace(palletNo))
                {
                    var code = PalletsRst.GetAllWhereAsync(m => m.PalletNo == palletNo).First();
                    if (code == null)
                    {
                        throw new Exception("托盘码在系统中未查询到");
                    }
                    return code.PalletNo;
                }
                else
@@ -86,22 +90,14 @@
                    if (code != null)
                    {
                        string riQi = code.PalletNo.Substring(1, 2);
                        if (riQi == time2)
                        {
                            codeId = int.Parse(code.PalletNo.Substring(3, 5)) + 1;
                        }
                        else
                        {
                            codeId = int.Parse("00001");
                        }
                        liuShuiCode = int.Parse(code.PalletNo.Substring(2, 6)) + 1;
                    }
                    else
                    {
                        codeId = int.Parse("00001");
                        liuShuiCode = int.Parse("000001");
                    }
                    int liuShuiId = codeId;
                    var pallet = "T"+time2 + Convert.ToString(liuShuiId).PadLeft(5, '0');
                    var pallet = "LN" + Convert.ToString(liuShuiCode).PadLeft(6, '0');
                    return pallet;
                }
            }
@@ -120,21 +116,24 @@
                {
                    throw new Exception("组数需大于0");
                }
                //托盘条码规则  LN+6位流水  例如 LN000001
                var pallNo = db.Queryable<SysPallets>().Max(m => m.PalletNo);
                var str = pallNo.Substring(3, 5);
                string remove = pallNo.Substring(0, 3);
                if (string.IsNullOrWhiteSpace(pallNo))
                {
                    pallNo = "LN000000";
                }
                var str = pallNo.Substring(2, 6);   //
                string remove = pallNo.Substring(0, 2);
                int sibelius = Convert.ToInt16(str);
                var num = 0;
                for (int i = 0; i < groupCount; i++)
                {
                    sibelius += 1;
                    if (sibelius>99999)
                    if (sibelius>999999)
                    {
                        throw new Exception("托盘码位数已达上线");
                    }
                    string code = remove + Convert.ToString(sibelius).PadLeft(5, '0');
                    string code = remove + Convert.ToString(sibelius).PadLeft(6, '0');
                    if (db.Queryable<SysPallets>().Count(m=>m.PalletNo == code)>=1)
                    {
                        continue;