From 08e3af418efa91b132e4b0bff0cc9e065f0cfc9f Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Sat, 30 Dec 2023 12:52:59 +0800 Subject: [PATCH] new --- Aucma.Core.HwPLc/Impl/MelsecPlc.cs | 2 +- .../ViewModels/OldBoxFoamPageViewModel.cs | 56 +++++++++++++------ 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs index 4ac238a4..a6648ecc 100644 --- a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs +++ b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs @@ -76,7 +76,7 @@ namespace Aucma.Core.HwPLc /// public bool Connect(string iP, int port) { - melsecMcNet.IpAddress = iP;//正式环境开启 + //melsecMcNet.IpAddress = iP;//正式环境开启 melsecMcNet.Port = port; // 如果网络不太理想,配置了两个端口,一个有问题,立即切换另一个的话,可以配置如下的代码 diff --git a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs index 01a85dc7..45ad9d2b 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -361,37 +362,43 @@ namespace Aucma.Core.OldBoxFoam.ViewModels collection.startCollect(); bLis = collection.listFixtureStatus; if (bLis.Count == 0) return; - + int total = 0; + List bfds = await _oldBoxFoamDataServices.QueryAsync(); + List spaceList = await _oldBoxFoamTypeServices.QueryAsync(); + List < BoxFoamPlan> planList = await _boxFoamPlanServices.QueryAsync(); for (int j = 0; j < bLis.Count; j++) { - OldBoxFoamType space = await _oldBoxFoamTypeServices.FirstAsync(d => d.Boxtype == bLis[j].FixtureBoxType); + OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bLis[j].FixtureBoxType); //根据夹具找货道,根据货道找物料 if (space != null) { - BoxFoamPlan plan = _boxFoamPlanServices.FirstAsync(d => d.MaterialCode == space.MaterialCode).Result; + BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount); if (plan != null) { - plan.CompleteAmount = plan.CompleteAmount + 1; - await _boxFoamPlanServices.UpdateAsync(plan); + int complateAmount = 0; //更新小时数据 - BoxFoamData bfd = await _oldBoxFoamDataServices.FirstAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); if (bfd != null) { UpdateBoxData(bLis[j], bfd); + //更新计划数量 + complateAmount = bLis[j].Yield - bfd.Production; } else { SaveBoxData(productLineCode, bLis[j]); } + plan.CompleteAmount = plan.CompleteAmount + complateAmount; + await _boxFoamPlanServices.UpdateAsync(plan); } else { //更新小时数据 - List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); - if (bfd.Count > 0) + //List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + if (bfd!=null) { - var obj = bfd.FirstOrDefault(); - UpdateBoxData(bLis[j], obj); + UpdateBoxData(bLis[j], bfd); } else @@ -403,11 +410,12 @@ namespace Aucma.Core.OldBoxFoam.ViewModels else { //更新小时数据 - List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); - if (bfd.Count > 0) + //List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + if (bfd != null) { - var obj = bfd.FirstOrDefault(); - UpdateBoxData(bLis[j], obj); + UpdateBoxData(bLis[j], bfd); } else { @@ -420,13 +428,12 @@ namespace Aucma.Core.OldBoxFoam.ViewModels { Console.WriteLine(ex.Message); } - } private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd) { - - switch (GetTeamHour().Seq) + int hour = GetTeamHour(DateTime.Now).Seq; + switch (hour) { case 1: bfd.AnHour = item.Yield - bfd.Production; @@ -467,7 +474,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels default: break; } + bfd.Production = item.Yield; + await _oldBoxFoamDataServices.UpdateAsync(bfd); } @@ -481,7 +490,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels bfdata.Production = item.Yield; bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString(); bfdata.ActualValue = item.RealCuringTime.ToString(); - switch (GetTeamHour().Seq) + int hour = GetTeamHour(DateTime.Now).Seq; + switch (hour) { case 1: bfdata.AnHour = item.Yield = bfdata.Production; @@ -538,5 +548,15 @@ namespace Aucma.Core.OldBoxFoam.ViewModels } return null; } + + public CurrentTeamTimeView GetTeamHour(DateTime now) + { + var obj = _sysUserInfoServices.GetTeamData(now).Result; + if (obj != null) + { + return obj; + } + return null; + } } }