啊鑫
2024-08-28 481e4bef4be32a5a9754d01faf80bf0bc4e14951
MES.Service/service/Warehouse/OrganizeService.cs
@@ -1,4 +1,5 @@
using System.Data;
using System.Dynamic;
using MES.Service.DB;
using MES.Service.Dto.service;
using MES.Service.Modes;
@@ -28,10 +29,7 @@
        var printCommandResult = Db.Queryable<MesBarcodeType>()
            .Where(t => t.TypeCode == 108)
            .First();
        if (printCommandResult == null)
        {
            throw new Exception("模版ID为空,请设置打印格式!");
        }
        if (printCommandResult == null) throw new Exception("模版ID为空,请设置打印格式!");
        var cPrintCommand = printCommandResult.Mbtype;
        var cBid = printCommandResult.Id;
@@ -41,40 +39,21 @@
                s.ItemNo == query.ItemNo && s.Factory == "1000" &&
                s.Company == "1000")
            .First();
        if (cMesItems == null)
        {
            throw new Exception("物料信息不存在该物料编码,请维护!");
        }
        if (cMesItems == null) throw new Exception("物料信息不存在该物料编码,请维护!");
        if (string.IsNullOrEmpty(query.ItemNo))
        {
            throw new Exception("请录入物料编码");
        }
        if (string.IsNullOrEmpty(query.ItemNo)) throw new Exception("请录入物料编码");
        if (string.IsNullOrEmpty(query.ItemModel))
        {
            throw new Exception("请输入完物料编码后,点击确认生成规格!");
        }
        if (string.IsNullOrEmpty(query.OrgName))
        {
            throw new Exception("请录入组织");
        }
        if (string.IsNullOrEmpty(query.OrgName)) throw new Exception("请录入组织");
        if (string.IsNullOrEmpty(query.OrgOwner))
        {
            throw new Exception("请录入货主");
        }
        if (string.IsNullOrEmpty(query.OrgOwner)) throw new Exception("请录入货主");
        if (string.IsNullOrEmpty(query.ItemNum))
        {
            throw new Exception("请录入物料数量");
        }
        if (string.IsNullOrEmpty(query.ItemNum)) throw new Exception("请录入物料数量");
        if (string.IsNullOrEmpty(query.Printnumn))
        {
            throw new Exception("请录入条码数量");
        }
        var cId =
            Db.Ado.GetInt(
@@ -89,7 +68,7 @@
                .Where(it => it.CreateDate < DateTime.Now.AddDays(-10))
                .ExecuteCommand();
            for (int i = 1; i <= int.Parse(query.Printnumn); i++)
            for (var i = 1; i <= int.Parse(query.Printnumn); i++)
            {
                var cIndate = DateTime.Now.ToString("yyyyMMdd");
@@ -104,19 +83,12 @@
                        query.ItemNo + cIndate, query.ItemNo + cIndate, 0);
                    serial = barcodeResult.Value;
                    poBarcodeComand = barcodeResult.Msg;
                    if (!string.IsNullOrEmpty(poBarcodeComand))
                    {
                        return null;
                    }
                    if (!string.IsNullOrEmpty(poBarcodeComand)) return null;
                    if (string.IsNullOrEmpty(serial))
                    {
                        cBarcode2 = "9";
                    }
                    else
                    {
                        cBarcode2 = "9" + serial[1..];
                    }
                    itemBarcode = query.ItemNo + cIndate + cBarcode2;
                }
                else
@@ -135,10 +107,7 @@
                            query.ItemNo + cIndate, query.ItemNo + cIndate, 0);
                        serial = barcodeResult.Value;
                        poBarcodeComand = barcodeResult.Msg;
                        if (!string.IsNullOrEmpty(poBarcodeComand))
                        {
                            return null;
                        }
                        if (!string.IsNullOrEmpty(poBarcodeComand)) return null;
                        cBarcode2 = "9" + serial.Substring(1);
                        itemBarcode = query.ItemNo + cIndate +
@@ -155,7 +124,6 @@
                        s.Company == "1000")
                    .Count();
                if (cCount == 0)
                {
                    // Insert new barcode
                    Db.Insertable(new MesInvItemBarcodes
                    {
@@ -174,7 +142,6 @@
                        OrgName = query.OrgName,
                        OrgOwner = query.OrgOwner
                    }).ExecuteCommand();
                }
                // Insert record into MES_RF_PRNBARCODE
                Db.Insertable(new MesRfPrnbarcode
@@ -196,7 +163,7 @@
                    Strp11 = poBarcode,
                    Strp12 = query.ItemName ?? " ",
                    Strp15 = query.OrgName ?? " ",
                    Strp16 = query.OrgOwner ?? " ",
                    Strp16 = query.OrgOwner ?? " "
                }).ExecuteCommand();
            }
@@ -254,7 +221,7 @@
            var resultValue = outputResult.Value?.ToString();
            var messageValue = outputMessage.Value?.ToString();
            dynamic m = new System.Dynamic.ExpandoObject();
            dynamic m = new ExpandoObject();
            m.Value = resultValue;
            m.Msg = messageValue;