From 12b64bec6a3e98866adb78309a633fbe02845b31 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Thu, 16 Jan 2025 16:17:36 +0800 Subject: [PATCH] =?UTF-8?q?debug=20-=20=E4=BF=AE=E5=A4=8D=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E8=AE=A1=E5=88=92=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E9=94=99=E8=AF=AF=20-=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8do=20while=20change=20-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=A7=B0=E9=87=8F=E4=BF=A1=E6=81=AF=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E7=BB=93=E6=9D=9F=E4=BB=BB=E5=8A=A1=E7=9A=84=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=EF=BC=8C=E5=85=88=E7=BB=93=E6=9D=9F=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E6=9F=A5=E8=AF=A2=E7=A7=B0=E9=87=8F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=89=B9=E6=AC=A1=E5=8F=B7-=E7=84=B6=E5=90=8E?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/MaterialController.cs | 1 - .../Business/WarehouseController.cs | 54 +++++++------ .../Service_New/xl_materialServices.cs | 81 +++++++++---------- 3 files changed, 66 insertions(+), 70 deletions(-) diff --git a/Admin.Core.Api/Controllers/Business/MaterialController.cs b/Admin.Core.Api/Controllers/Business/MaterialController.cs index d35d294..a8ef68e 100644 --- a/Admin.Core.Api/Controllers/Business/MaterialController.cs +++ b/Admin.Core.Api/Controllers/Business/MaterialController.cs @@ -178,7 +178,6 @@ namespace Admin.Core.Api { if (!code.IsNotEmptyOrNull()) return Failed("桶条码信息传入参数为空!"); - var result = await _xl_materialService.BindBarrel(code.Trim()); if (result == 0) return Failed("未查询到正在执行的计划!"); diff --git a/Admin.Core.Api/Controllers/Business/WarehouseController.cs b/Admin.Core.Api/Controllers/Business/WarehouseController.cs index e1b4690..5e893bc 100644 --- a/Admin.Core.Api/Controllers/Business/WarehouseController.cs +++ b/Admin.Core.Api/Controllers/Business/WarehouseController.cs @@ -302,29 +302,6 @@ namespace Admin.Core.Api.Controllers.Business } var result = await _xl_materialService.BindBarrel(barrelBarcode.Trim()); - if (result == 0) - return Failed>("未查询到正在执行的计划!"); - if (result == 1) - return Failed>("未查询到桶!"); - if (result == 2) - return Failed>($"未查询到[{barrelBarcode}]桶信息!"); - if (result == 3) - return Failed>("该桶已经绑定物料,请联系系统管理员处理!"); - if (result == 6) - //return Success(true); - log.Info("任务结束成功"); - if (result == 7) - return Failed>("称重未完成!"); - if (result == 8) - return Failed>("PLC连接失败,请检查PLC或者联系管理员处理!"); - if (result == 10) - return Failed>("未知异常,请查看错误日志!"); - if (result == 99) - return Failed>("保存处理数据失败!"); - if (result == 100) - return Failed>("处理中....!"); - if (result == 110) - return Failed>("执行批次未获取!"); MessageModel> messageModel = new MessageModel>(); string materialName = _hw_BarrelService.GetMaterialNameByBarrelID(barrelBarcode.Trim()); @@ -345,13 +322,38 @@ namespace Admin.Core.Api.Controllers.Business record.BatchCode = _binFeedingReportServices.GetBatchNumberByMaterialAndBinID(weigh.Material_ID, weigh.Bin_Serial ?? -1); list.Add(record); } - if (list != null) + if (list != null && list.Count != 0) { - return Success(list); + if (result == 0) + return Success(list, "查询成功,任务结束失败,原因:未查询到正在执行的计划!"); + if (result == 1) + return Success(list, "查询成功,任务结束失败,原因:未查询到桶!"); + if (result == 2) + return Success(list, $"查询成功,任务结束失败,原因:未查询到[{barrelBarcode}]桶信息!"); + if (result == 3) + return Success(list, "查询成功,任务结束失败,原因:该桶已经绑定物料,请联系系统管理员处理!"); + if (result == 6) + { + log.Info("任务结束成功"); + return Success(list, "任务结束成功,计划信息查询成功"); + } + if (result == 7) + return Success(list, "查询成功,任务结束失败,原因:称重未完成!"); + if (result == 8) + return Success(list, "查询成功,任务结束失败,原因:PLC连接失败,请检查PLC或者联系管理员处理!"); + if (result == 10) + return Success(list, "查询成功,任务结束失败,原因:未知异常,请查看错误日志!"); + if (result == 99) + return Success(list, "查询成功,任务结束失败,原因:保存处理数据失败!"); + if (result == 100) + return Success(list, "查询成功,任务结束失败,原因:处理中....!"); + if (result == 110) + return Success(list, "查询成功,任务结束失败,原因:执行批次未获取!"); + return Success(list, "查询成功,任务结束失败"); } else { - return Failed>("任务结束成功但称量信息查询失败!"); + return Failed>("称量信息查询失败!查询不到称量信息!任务未结束"); } } diff --git a/Admin.Core.Service/Service_New/xl_materialServices.cs b/Admin.Core.Service/Service_New/xl_materialServices.cs index 7aef69c..e91fc8c 100644 --- a/Admin.Core.Service/Service_New/xl_materialServices.cs +++ b/Admin.Core.Service/Service_New/xl_materialServices.cs @@ -27,11 +27,11 @@ namespace Admin.Core.Service private readonly Ixl_weighRepository _xlWeighRepository; private readonly IBinFeedingReportRepository _binFeedingReportRepository; bool flag = true; - int i = 0; + int i = 0; #region 构造函数 public xl_materialServices(IBaseRepository dal, Ixl_materialRepository xl_materialRepository, - IPmt_BinRepository pmt_BinRepository,Ixl_planRepository planRepository, + IPmt_BinRepository pmt_BinRepository, Ixl_planRepository planRepository, IHw_BarrelRepository hw_BarrelRepository, ILR_planRepository lrPlanRepository, Ixl_weighRepository xlWeighRepository, IBinFeedingReportRepository binFeedingReportRepository) { @@ -57,9 +57,9 @@ namespace Admin.Core.Service /// 物料重量 /// 物料二维码 /// - public async Task> ExecPlcState(int binSerial, int state, string materialCode, decimal weight,string? barCode) + public async Task> ExecPlcState(int binSerial, int state, string materialCode, decimal weight, string? barCode) { - MessageModel mesage=new MessageModel(); + MessageModel mesage = new MessageModel(); log.Info(materialCode + "|" + weight); string station = string.Empty; try @@ -74,12 +74,12 @@ namespace Admin.Core.Service var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC")); if (plcList.plc.IsConnected) { - int ponintVal= plcList.plc.ReadInt16(station); + int ponintVal = plcList.plc.ReadInt16(station); if (ponintVal == 1) { mesage.success = false; mesage.msg = "锁已开,无需重复操作!"; - return mesage; + return mesage; } var pmtBin = await _pmt_BinRepository.FirstAsync(d => d.Bin_Serial == binSerial); var material = await _xl_materialRepository.FirstAsync(d => d.ID == pmtBin.Material_ID); @@ -87,8 +87,8 @@ namespace Admin.Core.Service if (!string.IsNullOrEmpty(barCode.Trim())) { string[] str = barCode.Split("#"); - - //保存料仓投料重量 + + //保存料仓投料重量 Hw_BinTypeErrorPreventionReport hw = new Hw_BinTypeErrorPreventionReport() { BinID = binSerial, @@ -114,8 +114,8 @@ namespace Admin.Core.Service //同时记录该扫码到数据库中 pmtBin.BinWeight = pmtBin.BinWeight + weight; bool saveResult = await _pmt_BinRepository.AddData(binAlarm, hw, pmtBin); - } - + } + bool result = plcList.plc.WriteInt16(station, state.ToString());//写入开锁点位 if (result) { @@ -131,7 +131,7 @@ namespace Admin.Core.Service } mesage.success = false; mesage.msg = "PLC连接失败!"; - + return mesage; } catch (Exception ex) @@ -290,10 +290,10 @@ namespace Admin.Core.Service { try { - var query = await _xl_materialRepository.QueryAsync(d=>d.IsEnable == "是"); + var query = await _xl_materialRepository.QueryAsync(d => d.IsEnable == "是"); if (query == null) return null; - var m= query.FirstOrDefault(d => d.Material_code.Trim() == code.Trim()); - + var m = query.FirstOrDefault(d => d.Material_code.Trim() == code.Trim()); + return m; } catch (Exception ex) @@ -340,7 +340,7 @@ namespace Admin.Core.Service /// public async Task BindBarrel(string code) { - List down=new List(); + List down = new List(); if (flag) { flag = false; @@ -360,11 +360,11 @@ namespace Admin.Core.Service log.Info($"重量:{tcheckWeight}"); //绑定桶 var barrelList = await _hw_BarrelRepository.QueryAsync(); - + if (barrelList == null) return 1; Hw_Barrel barrel = barrelList.FirstOrDefault(d => d.BarCode == code.Trim()); - bool bl = barrel == null?true:false; + bool bl = barrel == null ? true : false; if (barrel == null) return 2; //if (!string.IsNullOrEmpty(barrel.MaterialID)) return 3;//判断桶是否绑定 @@ -374,7 +374,7 @@ namespace Admin.Core.Service barrel.PlanId = exec.Plan_Id; barrel.Weight = tcheckWeight; barrel.CreateDateTime = DateTime.Now; - + int tcheckBatch = GetTcheckBatch(plcList);//当前执行的车次 log.Info("批次:" + tcheckBatch.ToString()); if (tcheckBatch > 0) @@ -434,7 +434,7 @@ namespace Admin.Core.Service { log.Info($"no3>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}"); await _hw_BarrelRepository.UpdateAsync(barrel); - bool r = await UpdatePlanCompletedQuantity(plcList,exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error); + bool r = await UpdatePlanCompletedQuantity(plcList, exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error); log.Info("超重-称量完成:" + r); if (r) { @@ -468,26 +468,26 @@ namespace Admin.Core.Service } else { - log.Error("检量称状态显示未完成"); - return 110;//检量称状态显示未完成 + log.Error("执行批次未获取"); + return 110;//执行批次未获取 } } else { - log.Error("PLC连接失败"); - return 110;//PLC连接失败 + log.Error("检量称状态显示未完成"); + return 110;//检量称状态显示未完成 } } else { - log.Error("执行批次未获取"); - return 8;//执行批次未获取 + log.Error("PLC连接失败"); + return 8;//PLC连接失败 } } catch (Exception ex) { log.Error(ex.Message); - + return 10;//异常报错 } finally @@ -539,22 +539,22 @@ namespace Admin.Core.Service /// 计划号 /// 完成数量 /// - public async Task UpdatePlanCompletedQuantity(PlcModel mode, string planId, int quantity, int state, DateTime date, decimal totalWeight, decimal totalError) + public async Task UpdatePlanCompletedQuantity(PlcModel mode, string planId, int quantity, int state, DateTime date, decimal totalWeight, decimal totalError) { try { - var planList= await _planRepository.QueryAsync(); + var planList = await _planRepository.QueryAsync(); if (planList == null) return false; - var plan= planList.FirstOrDefault(d=>d.Plan_Id== planId); + var plan = planList.FirstOrDefault(d => d.Plan_Id == planId); if (plan == null) return false; - plan.Real_Num = mode.plc.ReadInt16("DB110.DBW212"); + plan.Real_Num = mode.plc.ReadInt16("DB110.DBW212"); plan.End_Date = date.ToString(); plan.Plan_State = state; plan.Plan_TotalWeight = totalWeight; plan.Plan_TotalError = totalError; plan.Plan_StateText = StateToShow(state); - var result= await _planRepository.UpdateAsync(plan); + var result = await _planRepository.UpdateAsync(plan); return result; } catch (Exception) @@ -637,12 +637,7 @@ namespace Admin.Core.Service public int GetTcheckBatch(PlcModel model) { int tb = 0; - int i = 0; - do - { - tb = model.plc.ReadInt16("DB110.DBW212"); - i++; - } while (i >3); + tb = model.plc.ReadInt16("DB110.DBW212"); log.Info("获取批次:" + tb); return tb; } @@ -691,7 +686,7 @@ namespace Admin.Core.Service return messageModel; } xl_weigh Weigh = xlList.FirstOrDefault(d => d.Material_ID == hw_Barrel.Material_KeyID); - + if (Weigh != null) { var material = await _xl_materialRepository.FirstAsync(d => d.ID == Weigh.Material_ID); @@ -721,9 +716,9 @@ namespace Admin.Core.Service /// public async Task xlInsertMaterial( string id, - string materialCode, - string materialName, - int isEnable, + string materialCode, + string materialName, + int isEnable, DateTime createDatetime) { try @@ -792,11 +787,11 @@ namespace Admin.Core.Service bool result = await _xl_materialRepository.UpdateAsync(xl_m, $"ID = '{id}'"); return result; } - catch (Exception e) + catch (Exception e) { throw; } - + } ///