mes数据逻辑上传完善,缺陷代码完善,添加S4工位的S2结果上传Plc的通信日志mes优化
1个文件已添加
11个文件已修改
523 ■■■■ 已修改文件
M135.sln 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
global.json 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M135.DBManager/Models/P_PRODUCT.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/Bro.M141.Process.csproj 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/M141Process.cs 174 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/M141Process_ImageCheck.cs 199 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/M141Process_Mysql.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/MyMQTT.cs 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/UI/UIPrinter.Designer.cs 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/UI/UIPrinter.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141.Process/UI/UIPrinter.resx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M141_AOI1.Process/AOI1Process.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
M135.sln
@@ -12,9 +12,9 @@
        .editorconfig = .editorconfig
    EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.M141_AOI1.Process", "src\Bro.M141_AOI1.Process\Bro.M141_AOI1.Process.csproj", "{E51B5103-B3A2-43CD-BA2F-3126F56625DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bro.M141_AOI1.Process", "src\Bro.M141_AOI1.Process\Bro.M141_AOI1.Process.csproj", "{E51B5103-B3A2-43CD-BA2F-3126F56625DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.M135.DBManager", "src\Bro.M135.DBManager\Bro.M135.DBManager.csproj", "{80FDC1C6-604D-462D-97E3-AF56D65F7B1C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bro.M135.DBManager", "src\Bro.M135.DBManager\Bro.M135.DBManager.csproj", "{80FDC1C6-604D-462D-97E3-AF56D65F7B1C}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
global.json
New file
@@ -0,0 +1,5 @@
{
  "sdk": {
    "version": "6.0.136"
  }
}
src/Bro.M135.DBManager/Models/P_PRODUCT.cs
@@ -14,6 +14,8 @@
        public string BasketCode { get; set; } = "NOREAD";
        public string Zword { get; set; } = "NOREAD";
        public string Result { get; set; } = "";
        [NotMapped]
src/Bro.M141.Process/Bro.M141.Process.csproj
@@ -163,9 +163,6 @@
        <Reference Include="SunnyUI.Common">
            <HintPath>..\..\libs\Nuget\SunnyUI.Common.dll</HintPath>
        </Reference>
        <Reference Include="System.Threading.Channels">
          <HintPath>..\..\libs\Nuget\System.Threading.Channels.dll</HintPath>
        </Reference>
        <Reference Include="zxing">
          <HintPath>..\..\libs\Nuget\zxing.dll</HintPath>
        </Reference>
src/Bro.M141.Process/M141Process.cs
@@ -98,9 +98,6 @@
        public override void Open()
        {
            base.Open();
@@ -1064,10 +1061,12 @@
                    if (M141Config.Isreadbasketcode)
                    {
                        p.BasketCode = M141Config.basketcode;
                        p.Zword = M141Config.zwoid;
                    }
                    else
                    {
                        p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE, out string sntem);
                        p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE, out string sntem, out string zword);
                        p.Zword = zword;
                        p.SN = sntem;
                        p.PID = $"{sntem}_{i}";
                        if ("NoRead".Equals(p.BasketCode))
@@ -1231,17 +1230,7 @@
                            }
                        }
                    });
                    //ReplyPlcData(positionSet, plcresult);
                    if (positionSet.IsLastPosition)
                    {
                        if (_ct != null)
                        {
                            UpdateCT(null, (float)((DateTime.Now - _ct.Value).TotalSeconds));
                        }
                        _ct = DateTime.Now;
                    }
                    //ReplyPlcData(positionName, config.TriggerValue);
                    cameraIds.ForEach(c =>
                    {
@@ -1252,6 +1241,162 @@
                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"相机{camera.Name}清理缓存");
                        }
                    });
                    //ReplyPlcData(positionSet, plcresult);
                    if (positionSet.IsLastPosition)
                    {
                        if (_ct != null)
                        {
                            UpdateCT(null, (float)((DateTime.Now - _ct.Value).TotalSeconds));
                        }
                        _ct = DateTime.Now;
                        if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
                        {
                            if (M141Config.numpro >= 50)
                            {
                                M141Config.numpro = 0;
                            }
                            if (pList[0].Result == "OK")
                            {
                                M141Config.numpro++;
                            }
                            //mqtt.demes(productList[0], M141Config.zwoid);
                            string Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(),M141Config.numpro)).Result;
                            M141Config.mesnum2++;
                            if (Msgreceice == null)
                            {
                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES异常 返回数据为null");
                            }
                            else
                            {
                                try
                                {
                                    var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
                                    if (obj.zstatus == "200")
                                    {
                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{pList[0].PID}数据上传MES成功  {Msgreceice}");
                                    }
                                    else
                                    {
                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES失败  {Msgreceice}");
                                    }
                                }
                                catch
                                {
                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES异常  {Msgreceice}");
                                }
                            }
                            int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]);
                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc给出的产品序号为{numplca}");
                            lock (plcnumlock)//1-29999
                            {
                                if (PlcNumForAll == -1)
                                {
                                    PlcNumForAll = numplca;
                                }
                                int differ = numplca - PlcNumForAll;
                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"两个产品中间的差值differ为{differ}");
                                if (differ > 1)
                                {
                                    for (int i = PlcNumForAll + 1; i < numplca; i++)
                                    {
                                        try
                                        {
                                            var plist = mysqlhelper.GetProductList(i + "_1");
                                            ProductModel newp = new ProductModel();
                                            newp.SEQUENCE = plist[0].SEQUENCE;
                                            newp.PID = plist[0].PID;
                                            newp.BasketCode = plist[0].BasketCode;
                                            newp.Zword = plist[0].Zword;
                                            newp.Result = "NG";
                                            newp.SN = plist[0].SN;
                                            var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
                                            M141Config.mesnum2++;
                                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"前站NG排料产品{newp.PID}数据上传,结果为{newp.Result}");
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                else if (differ == -29998 && differ == 1 && differ == 0)
                                {
                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"生产过程中未失去产品");
                                }
                                else if ( differ<0 && differ>-29998)
                                {
                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll为{PlcNumForAll},numplca为{numplca}");
                                    //产品从新计数时
                                    for (int i = PlcNumForAll + 1; i <= 29999; i++)
                                    {
                                        try
                                        {
                                            var plist = mysqlhelper.GetProductList(i + "_1");
                                            ProductModel newp = new ProductModel();
                                            newp.SEQUENCE = plist[0].SEQUENCE;
                                            newp.PID = plist[0].PID;
                                            newp.Zword = plist[0].Zword;
                                            newp.BasketCode = plist[0].BasketCode;
                                            newp.Result = "NG";
                                            newp.SN = plist[0].SN;
                                            var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
                                            M141Config.mesnum2++;
                                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll,前站NG排料且plc触发清零产品{newp.PID}数据上传,结果为{newp.Result}");
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    for (int i = 1; i < numplca; i++)
                                    {
                                        try
                                        {
                                            var plist = mysqlhelper.GetProductList(i + "_1");
                                            ProductModel newp = new ProductModel();
                                            newp.SEQUENCE = plist[0].SEQUENCE;
                                            newp.PID = plist[0].PID;
                                            newp.BasketCode = plist[0].BasketCode;
                                            newp.Zword = plist[0].Zword;
                                            newp.Result = "NG";
                                            newp.SN = plist[0].SN;
                                            var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
                                            M141Config.mesnum2++;
                                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"numplca,前站NG排料且plc触发清零产品{newp.PID}数据上传,结果为{newp.Result}");
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                PlcNumForAll = numplca;
                            }
                        }
                    }
                    //ReplyPlcData(positionName, config.TriggerValue);
                    return pList;
@@ -1287,6 +1432,7 @@
                    newp.SEQUENCE = p.SEQUENCE;
                    newp.PID = p.PID;
                    newp.BasketCode = p.BasketCode;
                    newp.Zword = p.Zword;
                    newp.Result = p.Result;
                    newp.SN = p.SN;
src/Bro.M141.Process/M141Process_ImageCheck.cs
@@ -494,6 +494,9 @@
            {
                ////mysqlhelper.GetS2Result(productList[0].SEQUENCE);
                Plc1.WriteSingleAddress(1526, mysqlhelper.GetS2Result(productList[0].SEQUENCE) ? 1 : 2, out _);
                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{string.Join(",", productList.Select(u => u.PID))}检测反馈{mysqlhelper.GetS2Result(productList[0].SEQUENCE)}");
            }
            else
            {
@@ -502,122 +505,122 @@
            Plc1.WriteSingleAddress(1516, 1, out _);
            if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
            {
                if (M141Config.numpro >= 50)
                {
                    M141Config.numpro = 0;
                }
            //if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
            //{
            //    if (M141Config.numpro >= 50)
            //    {
            //        M141Config.numpro = 0;
            //    }
                if (productList[0].Result == "OK")
                {
                    M141Config.numpro++;
                }
            //    if (productList[0].Result == "OK")
            //    {
            //        M141Config.numpro++;
            //    }
                //mqtt.demes(productList[0], M141Config.zwoid);
                string Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(productList[0], M141Config.zwoid, M141Config.numpro)).Result;
                if (Msgreceice == null)
                {
                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常 返回数据为null");
                }
                else
                {
                    try
                    {
                        var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
            //    //mqtt.demes(productList[0], M141Config.zwoid);
            //    string Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(productList[0], M141Config.zwoid, M141Config.numpro)).Result;
            //    if (Msgreceice == null)
            //    {
            //        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常 返回数据为null");
            //    }
            //    else
            //    {
            //        try
            //        {
            //            var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
                        if (obj.zstatus == "200")
                        {
                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{productList[0].PID}数据上传MES成功  {Msgreceice}");
                        }
                        else
                        {
                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES失败  {Msgreceice}");
                        }
                    }
                    catch
                    {
                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常  {Msgreceice}");
                    }
                }
            //            if (obj.zstatus == "200")
            //            {
            //                LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{productList[0].PID}数据上传MES成功  {Msgreceice}");
            //            }
            //            else
            //            {
            //                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES失败  {Msgreceice}");
            //            }
            //        }
            //        catch
            //        {
            //            LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{productList[0].PID}数据上传MES异常  {Msgreceice}");
            //        }
            //    }
                lock (plcnumlock)
                {
                    int differ = numplca - PlcNumForAll;
                    if (differ > 1)
                    {
                        for (int i = PlcNumForAll + 1; i < numplca; i++)
                        {
                            try
                            {
                                var plist = mysqlhelper.GetProductList(i + "_1");
                                ProductModel newp = new ProductModel();
                                newp.SEQUENCE = plist[0].SEQUENCE;
                                newp.PID = plist[0].PID;
                                newp.BasketCode = plist[0].BasketCode;
                                newp.Result = "NG";
                                newp.SN = plist[0].SN;
                                var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
            //    lock (plcnumlock)
            //    {
            //        int differ = numplca - PlcNumForAll;
            //        if (differ > 1)
            //        {
            //            for (int i = PlcNumForAll + 1; i < numplca; i++)
            //            {
            //                try
            //                {
            //                    var plist = mysqlhelper.GetProductList(i + "_1");
            //                    ProductModel newp = new ProductModel();
            //                    newp.SEQUENCE = plist[0].SEQUENCE;
            //                    newp.PID = plist[0].PID;
            //                    newp.BasketCode = plist[0].BasketCode;
            //                    newp.Result = "NG";
            //                    newp.SN = plist[0].SN;
            //                    var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
                            }
                            catch
                            {
            //                }
            //                catch
            //                {
                            }
                        }
                    }
                    else if (differ != -29998)
                    {
                        for (int i = PlcNumForAll + 1; i <= 29999; i++)
                        {
                            try
                            {
                                var plist = mysqlhelper.GetProductList(i + "_1");
                                ProductModel newp = new ProductModel();
                                newp.SEQUENCE = plist[0].SEQUENCE;
                                newp.PID = plist[0].PID;
                                newp.BasketCode = plist[0].BasketCode;
                                newp.Result = "NG";
                                newp.SN = plist[0].SN;
                                var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
            //                }
            //            }
            //        }
            //        else if (differ != -29998)
            //        {
            //            for (int i = PlcNumForAll + 1; i <= 29999; i++)
            //            {
            //                try
            //                {
            //                    var plist = mysqlhelper.GetProductList(i + "_1");
            //                    ProductModel newp = new ProductModel();
            //                    newp.SEQUENCE = plist[0].SEQUENCE;
            //                    newp.PID = plist[0].PID;
            //                    newp.BasketCode = plist[0].BasketCode;
            //                    newp.Result = "NG";
            //                    newp.SN = plist[0].SN;
            //                    var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
                            }
                            catch
                            {
            //                }
            //                catch
            //                {
                            }
                        }
            //                }
            //            }
                        for (int i = 1; i < numplca; i++)
                        {
                            try
                            {
                                var plist = mysqlhelper.GetProductList(i + "_1");
                                ProductModel newp = new ProductModel();
                                newp.SEQUENCE = plist[0].SEQUENCE;
                                newp.PID = plist[0].PID;
                                newp.BasketCode = plist[0].BasketCode;
                                newp.Result = "NG";
                                newp.SN = plist[0].SN;
                                var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
            //            for (int i = 1; i < numplca; i++)
            //            {
            //                try
            //                {
            //                    var plist = mysqlhelper.GetProductList(i + "_1");
            //                    ProductModel newp = new ProductModel();
            //                    newp.SEQUENCE = plist[0].SEQUENCE;
            //                    newp.PID = plist[0].PID;
            //                    newp.BasketCode = plist[0].BasketCode;
            //                    newp.Result = "NG";
            //                    newp.SN = plist[0].SN;
            //                    var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
                            }
                            catch
                            {
            //                }
            //                catch
            //                {
                            }
                        }
            //                }
            //            }
                    }
                    PlcNumForAll = numplca;
                }
            //        }
            //        PlcNumForAll = numplca;
            //    }
            }
            //}
            return msg;
        }
src/Bro.M141.Process/M141Process_Mysql.cs
@@ -23,10 +23,8 @@
{
    public class M141Process_Mysql
    {
        string connStrAll = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8";
        string connStrLocal = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8";
        #region 基础操作
        public void IniDBIP(string IP)
@@ -107,7 +105,6 @@
        }
        #endregion
        public void NewProduct(ProductModel pro)
@@ -290,7 +287,7 @@
                            Operatoremysql(str2, connStrAll);
                        }
                        string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
                        string mysqlstr = $"insert into forall (basketcode,zword,device,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.Zword}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
                        if (Operatoremysql(mysqlstr, connStrAll))
                        {
@@ -334,7 +331,6 @@
            return null;
        }
        public List<Netdefectdetail> GetNetdefectdetails(string plcnum)
        {
            try
@@ -373,8 +369,8 @@
                {
                    ProductModel p = null;
                    p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
                    return p.Result=="OK";
                    return p.Result == "OK";
                }
            }
            catch (Exception e)
@@ -384,13 +380,13 @@
            return false;
        }
        public string Getbasketcode(string plcnum, out string sn)
        public string Getbasketcode(string plcnum, out string sn, out string zword)
        {
            sn = "Noread";
            zword = "Noread";
            try
            {
                string mysqlstr = $"select basketcode,sn from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1";
                string mysqlstr = $"select basketcode,sn,zword from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1";
                var dt = selectdt(mysqlstr, connStrAll);
                if (dt == null || dt.Rows.Count == 0)
                {
@@ -399,6 +395,7 @@
                else
                {
                    sn = dt.Rows[0][1].ToString();
                    zword = dt.Rows[0][2].ToString();
                    return dt.Rows[0][0].ToString();
                }
            }
@@ -408,7 +405,6 @@
            }
            return "NoRead";
        }
        public List<ProductModel> GetProductList(string plcnum)
        {
@@ -442,8 +438,6 @@
            return null;
        }
        public DataTable getBasketCode()
        {
            try
@@ -468,7 +462,6 @@
        }
        public void NewBasketcode(string code)
        {
src/Bro.M141.Process/MyMQTT.cs
@@ -15,6 +15,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZXing;
namespace Bro.M141.Process
{
@@ -133,7 +134,7 @@
            }
        }
        public async Task<string> MESForBasketAsync(string ztype, string zlsn, string zlpn, string zstatus, string zversion, int timeoutMs = 3000)
        public async Task<string> MESForBasketAsync(string ztype, string zlsn, string zlpn, string zstatus, string zversion, int timeoutMs = 30000)
        {
            var guid = Guid.NewGuid().ToString();
            var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
@@ -167,11 +168,60 @@
            }
        }
        public async Task<string> MESForProduceAsync(ProductModel pro, string zwoid, int znonum, string endtray = "N", string line = "NQ216", int timeoutMs = 3000)
        public async Task<string> MESForProduceAsync(ProductModel pro, string zversion, int znonum, string endtray = "N", string line = "NQ216", int timeoutMs = 3000)
        {
            var guid = Guid.NewGuid().ToString();
            var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
            _pendingTask2[guid] = tcs;
            string zresult = "OK";
            if (string.IsNullOrWhiteSpace(pro.Result))
            {
                zresult = "NG";
            }
            else if (!"OK".Equals(pro.Result))
            {
                zresult = "NG";
            }
            //string zr;
            //switch (pro.Result)
            //{
            //    case "ok":
            //        zr = "";
            //        break;
            //    case "异色":
            //        zr = "SZ2001";
            //        break;
            //    case "磨印":
            //        zr = "SZ2012";
            //        break;
            //    case "压伤":
            //        zr = "SZ2014";
            //        break;
            //    case "变形":
            //        zr = "SZ2014";
            //        break;
            //    case "划伤":
            //        zr = "SZ2021";
            //        break;
            //    default:
            //        zr = "S31006";
            //        break;
            //}
            var DefectCodeMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                ["ok"] = "",
                ["异色"] = "SZ2001",
                ["磨印"] = "SZ2012",
                ["压伤"] = "SZ2014",
                ["变形"] = "SZ2014",
                ["划伤"] = "SZ2021"
            };
            const string DefaultErrorCode = "S31006";
            string zr = DefectCodeMap.TryGetValue(pro.Result, out var code) ? code : DefaultErrorCode;
            var msgObj = new AutoLineMacBarcodeQueue
@@ -180,16 +230,21 @@
                zdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"),
                zline = line,
                zbarcode = pro.SN,
                zresult = string.IsNullOrWhiteSpace(pro.Result) ? "NG" : pro.Result,
                zreson = pro.Result == "OK" ? "" : "SZ2014",
                zresult = zresult,
                zreson = zr,
                //zreson = pro.Result == "OK" ? "" : "SZ2014",
                //
                //
                zno = znonum.ToString(),
                zwoid = zwoid,
                endtray = endtray
                zwoid = pro.Zword,
                endtray = endtray,
                zversion = zversion
            };
            var message = JsonConvert.SerializeObject(msgObj);
            var body = Encoding.UTF8.GetBytes(message);
            CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ发送产品{pro.PID} 数据2:{message}");
            CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ发送产品{pro.PID} 数据2:{message},缺陷代码为{zr}");
            _sendChannel.BasicPublish("", "auto_line_mac_barcode_queue", null, body);
            var completed = await Task.WhenAny(tcs.Task, Task.Delay(timeoutMs));
@@ -600,6 +655,17 @@
        /// 默认:N;零数尾盘:Y
        /// </summary>
        public string endtray { get; set; } = "N";
              /// <summary>
        /// 每个ztype下对应独立一个序列号,一个业务动作一个,从0开始,
        /// 每次加1,到达阈值后可重置(比如100后从0开始),只要和上一
        /// 次的不一样即可
        /// 业务动作解释:比如ztype为2时,Q01-000001解绑时传序列号1,
        /// 如果Q01-000001在一些异常情况下,需要重试则还是传序列号为1,
        /// 下一个Q01-000002解绑时传序列号2
        /// 通俗的说:一个ztype+zversion只能成功处理一次(阈值重置导致
        /// 的重复除外)
        /// </summary>
        public string zversion { get; set; }
    }
    public class AutoLineMacBarcodeQueueBak
src/Bro.M141.Process/UI/UIPrinter.Designer.cs
@@ -44,6 +44,7 @@
            label2 = new Label();
            button6 = new Button();
            label3 = new Label();
            textBox8 = new TextBox();
            SuspendLayout();
            // 
            // button2
@@ -125,7 +126,7 @@
            // 
            // textBox3
            // 
            textBox3.Location = new Point(82, 226);
            textBox3.Location = new Point(82, 195);
            textBox3.Margin = new Padding(3, 2, 3, 2);
            textBox3.Name = "textBox3";
            textBox3.Size = new Size(151, 21);
@@ -133,7 +134,7 @@
            // 
            // textBox4
            // 
            textBox4.Location = new Point(82, 263);
            textBox4.Location = new Point(82, 231);
            textBox4.Margin = new Padding(3, 2, 3, 2);
            textBox4.Name = "textBox4";
            textBox4.Size = new Size(151, 21);
@@ -141,7 +142,7 @@
            // 
            // textBox5
            // 
            textBox5.Location = new Point(82, 298);
            textBox5.Location = new Point(82, 267);
            textBox5.Margin = new Padding(3, 2, 3, 2);
            textBox5.Name = "textBox5";
            textBox5.Size = new Size(151, 21);
@@ -149,7 +150,7 @@
            // 
            // textBox6
            // 
            textBox6.Location = new Point(82, 336);
            textBox6.Location = new Point(82, 303);
            textBox6.Margin = new Padding(3, 2, 3, 2);
            textBox6.Name = "textBox6";
            textBox6.Size = new Size(151, 21);
@@ -157,7 +158,7 @@
            // 
            // textBox7
            // 
            textBox7.Location = new Point(82, 379);
            textBox7.Location = new Point(82, 339);
            textBox7.Margin = new Padding(3, 2, 3, 2);
            textBox7.Name = "textBox7";
            textBox7.Size = new Size(151, 21);
@@ -188,14 +189,23 @@
            label3.AutoSize = true;
            label3.Location = new Point(96, 537);
            label3.Name = "label3";
            label3.Size = new Size(139, 13);
            label3.Size = new Size(191, 13);
            label3.TabIndex = 17;
            label3.Text = "sn,result,zword,zno,entray";
            label3.Text = "sn,result,zword,zno,entray,zversion";
            //
            // textBox8
            //
            textBox8.Location = new Point(82, 375);
            textBox8.Margin = new Padding(3, 2, 3, 2);
            textBox8.Name = "textBox8";
            textBox8.Size = new Size(151, 21);
            textBox8.TabIndex = 18;
            // 
            // UIPrinter
            // 
            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(textBox8);
            Controls.Add(label3);
            Controls.Add(button6);
            Controls.Add(label2);
@@ -237,5 +247,6 @@
        private Label label2;
        private Button button6;
        private Label label3;
        private TextBox textBox8;
    }
}
src/Bro.M141.Process/UI/UIPrinter.cs
@@ -669,7 +669,7 @@
        int pronum = 0;
        private void button6_Click(object sender, EventArgs e)//sn,result,zword,zno,entray
        {
            string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text }, textBox5.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
            string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text ,Zword= textBox5.Text,}, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
            if (Msg == null)
            {
                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 物料 返回数据为 null");
src/Bro.M141.Process/UI/UIPrinter.resx
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Microsoft ResX Schema
    Version 2.0
@@ -48,7 +48,7 @@
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -484,6 +484,9 @@
        [ProcessMethod("", "MESup1", "MES上传进料口空篮", InvokeType.TestInvoke)]
        public ResponseMessage MESup1(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
        {
@@ -532,7 +535,6 @@
            return msg;
        }
        [ProcessMethod("", "MESup2", "MES上传进料口满载", InvokeType.TestInvoke)]