diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index fa14df84..21b0edbe 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1996,71 +1996,6 @@ namespace Tnb.ProductionMgr - if (prdMoTask.schedule_type == 2) - { - // Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) - // { - // ["DevName"] = dic[prdMoTask.workline_id], - // ["token"] = _eleCtlCfg.token, - // ["TagName"] = "WBZX_x1_ok", - // ["Value"] = "true", - // }; - // Log.Information($"提拔确认完成参数:{JsonConvert.SerializeObject(dicCommand2)}"); - // string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2); - // Log.Information($"提拔确认完成参数成返回结果:{responseresult}"); - // X2ServerResult x2ServerResult = JsonConvert.DeserializeObject(responseresult); - // if (x2ServerResult.Result != X2ServerResult.Ok) - // { - // throw Oops.Bah(x2ServerResult.Msg); - // } - - Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = "外包装箱码垛线", - ["token"] = _eleCtlCfg.token, - ["TagName"] = dic2[prdMoTask.workline_id], - ["Value"] = "0", - }; - - Log.Information($"清除提报码垛数参数:{JsonConvert.SerializeObject(dicCommand4)}"); - string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand4); - Log.Information($"清除提报码垛数成返回结果:{responseresult2}"); - X2ServerResult x2ServerResult2 = JsonConvert.DeserializeObject(responseresult2); - if (x2ServerResult2.Result != X2ServerResult.Ok) - { - throw Oops.Bah(x2ServerResult2.Msg); - } - } - - if (basMaterial.category_id.Contains("ZSJ") || basMaterial.category_id.Contains("DGJCJ")) - { - EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); - EqpDaq eqpDaq3 = await _repository.AsSugarClient().Queryable(). - LeftJoin((x,y)=>x.equip_id==y.id). - Where((x,y) => y.code == equipment.code && x.label_name.Contains("称重完成")).FirstAsync(); - - if (eqpDaq3 == null) - { - throw Oops.Bah("未在数据采集中设置称重完成标签点"); - } - - Dictionary dicCommand3 = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = eqpDaq3.equip_code, - ["token"] = _eleCtlCfg.token, - ["TagName"] = eqpDaq3.label_name, - ["Value"] = "true", - }; - Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand3)}"); - string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3,false); - Log.Information($"{eqpDaq3.equip_code},{eqpDaq3.label_name}称重完成返回结果:{responseresult}"); - X2ServerResult x2ServerResult = JsonConvert.DeserializeObject(responseresult); - if (x2ServerResult.Result != X2ServerResult.Ok) - { - throw Oops.Bah(x2ServerResult.Msg); - } - } - // Dictionary header = new() // { @@ -2173,6 +2108,72 @@ namespace Tnb.ProductionMgr { throw Oops.Bah(result2.msg !=null ? result2.msg : "生产入库接口报错"); } + + + if (prdMoTask.schedule_type == 2) + { + // Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) + // { + // ["DevName"] = dic[prdMoTask.workline_id], + // ["token"] = _eleCtlCfg.token, + // ["TagName"] = "WBZX_x1_ok", + // ["Value"] = "true", + // }; + // Log.Information($"提拔确认完成参数:{JsonConvert.SerializeObject(dicCommand2)}"); + // string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2); + // Log.Information($"提拔确认完成参数成返回结果:{responseresult}"); + // X2ServerResult x2ServerResult = JsonConvert.DeserializeObject(responseresult); + // if (x2ServerResult.Result != X2ServerResult.Ok) + // { + // throw Oops.Bah(x2ServerResult.Msg); + // } + + Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "外包装箱码垛线", + ["token"] = _eleCtlCfg.token, + ["TagName"] = dic2[prdMoTask.workline_id], + ["Value"] = "0", + }; + + Log.Information($"清除提报码垛数参数:{JsonConvert.SerializeObject(dicCommand4)}"); + string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand4); + Log.Information($"清除提报码垛数成返回结果:{responseresult2}"); + X2ServerResult x2ServerResult2 = JsonConvert.DeserializeObject(responseresult2); + if (x2ServerResult2.Result != X2ServerResult.Ok) + { + throw Oops.Bah(x2ServerResult2.Msg); + } + } + + if (basMaterial.category_id.Contains("ZSJ") || basMaterial.category_id.Contains("DGJCJ")) + { + EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + EqpDaq eqpDaq3 = await _repository.AsSugarClient().Queryable(). + LeftJoin((x,y)=>x.equip_id==y.id). + Where((x,y) => y.code == equipment.code && x.label_name.Contains("称重完成")).FirstAsync(); + + if (eqpDaq3 == null) + { + throw Oops.Bah("未在数据采集中设置称重完成标签点"); + } + + Dictionary dicCommand3 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = eqpDaq3.equip_code, + ["token"] = _eleCtlCfg.token, + ["TagName"] = eqpDaq3.label_name, + ["Value"] = "true", + }; + Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand3)}"); + string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3,false); + Log.Information($"{eqpDaq3.equip_code},{eqpDaq3.label_name}称重完成返回结果:{responseresult}"); + X2ServerResult x2ServerResult = JsonConvert.DeserializeObject(responseresult); + if (x2ServerResult.Result != X2ServerResult.Ok) + { + throw Oops.Bah(x2ServerResult.Msg); + } + } await _db.Ado.CommitTranAsync();