From a334e19dd09220ea68abccbeee908734c466ea38 Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 13 Jan 2024 12:01:57 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=BF=AE=E5=A4=8D=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E6=9E=AA=E7=A9=BA=E6=95=B0=E6=8D=AE=E4=B8=8D=E9=87=87?= =?UTF-8?q?=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/CollectionFoamMachine.cs | 4 ++-- .../Business/CollectionFoamMachine.cs | 13 ++++++++++++- .../ViewModels/FoamMachinesPageViewModel.cs | 15 +++++---------- Aucma.Core.DoorFoam/Views/RealTimePageView.xaml | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs index 625e33a3..f09d80d8 100644 --- a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs +++ b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs @@ -90,7 +90,7 @@ namespace Aucma.Core.BoxFoam.Business //程序启动缓存没数据查数据库 if (!tempKeys.ContainsKey(kvPair.Key)) { - BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode && x.StationNumber == "1005").OrderByDescending(x => x.CreateTime).FirstOrDefault(); if (record == null) { kvPair.Value.ProductLineCode = "CX_02"; @@ -114,7 +114,7 @@ namespace Aucma.Core.BoxFoam.Business // 设备状态变化,更新设备状态 if (kvPair.Value.SystemStatus!= tempKeys[kvPair.Key].SystemStatus) { - BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System.Equals(kvPair.Value.System) && x.ProductLineCode.Equals(kvPair.Value.ProductLineCode) && x.GunCode.Equals(kvPair.Value.GunCode)).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System.Equals(kvPair.Value.System) && x.ProductLineCode.Equals(kvPair.Value.ProductLineCode) && x.GunCode.Equals(kvPair.Value.GunCode) && x.StationNumber == "1005").OrderByDescending(x => x.CreateTime).FirstOrDefault(); if (record != null) { record.SystemStatus = kvPair.Value.SystemStatus; diff --git a/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs b/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs index 6f482fb7..00ab7f54 100644 --- a/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs +++ b/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs @@ -87,7 +87,7 @@ namespace Aucma.Core.DoorFoam.Business //程序启动缓存没数据查数据库 if (!tempKeys.ContainsKey(kvPair.Key)) { - BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode && kvPair.Value.StationNumber == "1004").OrderByDescending(x => x.CreateTime).FirstOrDefault(); + BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode && x.StationNumber == "1004").OrderByDescending(x => x.CreateTime).FirstOrDefault(); if (record == null) { kvPair.Value.ProductLineCode = "CX_02"; @@ -106,6 +106,17 @@ namespace Aucma.Core.DoorFoam.Business int b = _lastShotRecordServices.AddAsync(kvPair.Value).Result; RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value); } + // 设备状态变化,更新设备状态 + if (kvPair.Value.SystemStatus != tempKeys[kvPair.Key].SystemStatus) + { + BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System.Equals(kvPair.Value.System) && x.ProductLineCode.Equals(kvPair.Value.ProductLineCode) && x.GunCode.Equals(kvPair.Value.GunCode) && x.StationNumber == "1004").OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (record != null) + { + record.SystemStatus = kvPair.Value.SystemStatus; + bool flag = _lastShotRecordServices.UpdateAsync(record).Result; + } + + } } diff --git a/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs b/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs index d68e98a6..4079768c 100644 --- a/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs +++ b/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs @@ -222,7 +222,7 @@ namespace Aucma.Core.DoorFoam.ViewModels { LastShotRecordDataGrid.Clear(); - int i = 1; + // var list = await _boxLastShotRecordServices.QueryAsync(); // list.OrderByDescending(d => d.CreateTime).Take(30); @@ -232,15 +232,10 @@ namespace Aucma.Core.DoorFoam.ViewModels if (item.System == "1") { system = "1系统"; } if (item.System == "2") { system = "2系统"; } LastShotRecordModel model = new LastShotRecordModel(); - if (LastShotRecordDataGrid.Count() == 0) - { - model.No = 1; - } - else - { - model.No = LastShotRecordDataGrid.Count() + 1; - } - model.No = i; + + model.No = LastShotRecordDataGrid.Count() + 1; + + model.System = system; model.GunHead = item.GunCode; model.PolInjectionpressure = item.PolHp; diff --git a/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml b/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml index 0ee1b008..dd3d9114 100644 --- a/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml +++ b/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml @@ -181,7 +181,7 @@ - +