mes数据逻辑上传完善,缺陷代码完善,添加S4工位的S2结果上传Plc的通信日志mes优化
| | |
| | | .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 |
New file |
| | |
| | | { |
| | | "sdk": { |
| | | "version": "6.0.136" |
| | | } |
| | | } |
| | |
| | | |
| | | public string BasketCode { get; set; } = "NOREAD"; |
| | | |
| | | public string Zword { get; set; } = "NOREAD"; |
| | | |
| | | public string Result { get; set; } = ""; |
| | | |
| | | [NotMapped] |
| | |
| | | <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> |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public override void Open() |
| | | { |
| | | base.Open(); |
| | |
| | | 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)) |
| | |
| | | } |
| | | } |
| | | }); |
| | | //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 => |
| | | { |
| | |
| | | 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; |
| | | |
| | |
| | | newp.SEQUENCE = p.SEQUENCE; |
| | | newp.PID = p.PID; |
| | | newp.BasketCode = p.BasketCode; |
| | | newp.Zword = p.Zword; |
| | | newp.Result = p.Result; |
| | | newp.SN = p.SN; |
| | | |
| | |
| | | { |
| | | ////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 |
| | | { |
| | |
| | | |
| | | 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; |
| | | } |
| | |
| | | { |
| | | 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) |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | public void NewProduct(ProductModel pro) |
| | |
| | | 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)) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public List<Netdefectdetail> GetNetdefectdetails(string plcnum) |
| | | { |
| | | try |
| | |
| | | { |
| | | ProductModel p = null; |
| | | p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | |
| | | return p.Result=="OK"; |
| | | |
| | | return p.Result == "OK"; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | 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) |
| | | { |
| | |
| | | else |
| | | { |
| | | sn = dt.Rows[0][1].ToString(); |
| | | zword = dt.Rows[0][2].ToString(); |
| | | return dt.Rows[0][0].ToString(); |
| | | } |
| | | } |
| | |
| | | } |
| | | return "NoRead"; |
| | | } |
| | | |
| | | |
| | | public List<ProductModel> GetProductList(string plcnum) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | public DataTable getBasketCode() |
| | | { |
| | | try |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public void NewBasketcode(string code) |
| | | { |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using ZXing; |
| | | |
| | | namespace Bro.M141.Process |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | |
| | | 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)); |
| | |
| | | /// 默认: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 |
| | |
| | | label2 = new Label(); |
| | | button6 = new Button(); |
| | | label3 = new Label(); |
| | | textBox8 = new TextBox(); |
| | | SuspendLayout(); |
| | | // |
| | | // button2 |
| | |
| | | // |
| | | // 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); |
| | |
| | | // |
| | | // 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); |
| | |
| | | // |
| | | // 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); |
| | |
| | | // |
| | | // 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); |
| | |
| | | // |
| | | // 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); |
| | |
| | | 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); |
| | |
| | | private Label label2; |
| | | private Button button6; |
| | | private Label label3; |
| | | private TextBox textBox8; |
| | | } |
| | | } |
| | |
| | | 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"); |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | 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 |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("", "MESup1", "MES上传进料口空篮", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESup1(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | [ProcessMethod("", "MESup2", "MES上传进料口满载", InvokeType.TestInvoke)] |