From c815ab1bb3d0f33de725ff2b9ca0d4de5ee89bbe Mon Sep 17 00:00:00 2001 From: liuwf Date: Tue, 9 Jan 2024 15:20:22 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BF=AE=E6=94=B9=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aucma.Core.BoxFoam/appsettings.json | 10 +- .../ViewModels/IndexPageViewModel.cs | 112 +++++++++++------- .../Views/IndexPageView.xaml | 2 +- 3 files changed, 73 insertions(+), 51 deletions(-) diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 6b386026..6eb8669d 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -202,7 +202,7 @@ "EquipName": "泡前库Plc", "PlcType": "Siemens", "Enabled": true, - "IP": "127.0.0.1", + "IP": "10.10.93.41", "Port": 102 }, { @@ -210,16 +210,16 @@ "EquipName": "foamLine1Plc", "PlcType": "Siemens", "Enabled": true, - "IP": "127.0.0.1", - "Port": 103 + "IP": "10.10.93.21", + "Port": 102 }, { "Id": 3, "EquipName": "foamLine2Plc", "PlcType": "Siemens", "Enabled": true, - "IP": "127.0.0.1", - "Port": 104 + "IP": "10.10.93.1", + "Port": 102 }, { "Id": 4, diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index 6f3ba2fd..40208211 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -54,6 +54,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels System.Timers.Timer timer = new System.Timers.Timer(1000 * 1);//界面刷新定时器 private readonly IBaseBomInfoServices? _baseBomInfoServices; private OffLineBusiness offLineBusiness = OffLineBusiness.Instance; + private static double aaa = 100.0; int a = 0; public IndexPageViewModel() { @@ -63,6 +64,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels InitEveryDayMethod(); // 刷新界面信息 RefreshPageListen(); + } @@ -270,6 +272,9 @@ namespace Aucma.Core.ProductOffLine.ViewModels /// public void RefreshPage(object source, System.Timers.ElapsedEventArgs e) { + InitEveryDayMethod(); + + if (OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag == true) { ModelToPage(OffLineBusiness.TempOffLineInfo1); @@ -308,53 +313,69 @@ namespace Aucma.Core.ProductOffLine.ViewModels private async void InitEveryDayMethod() { - LoadData(); - List listTime = await _baseBomInfoServices.getWorkTime(); - if (listTime == null) return; - // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime) - // List hourAmount = _offLineInfoServices.QueryCharts1("CX_01"); - - List list = await _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime); - if (list == null) return; - var hourList = list.Where(x => int.Parse(x.hour) >= listTime[0].startTime.Hour && int.Parse(x.hour) <= listTime[11].startTime.Hour && x.productLineCode.Equals("CX_02")); - - List xList = new List(); - ChartValues achievement2 = new ChartValues(); - foreach (var item in hourList) - { - xList.Add(item.hour); - achievement2.Add(item.Amount); - } - //for (int i = 0; i < 12; i++) - //{ - // // xList.Add(list[i].time.Substring(11, 2) + ":00"); - // achievement2.Add(list[i].Amount); - //} - var column2 = new ColumnSeries(); - column2.DataLabels = true; - column2.Title = "产量"; - column2.Values = achievement2; - column2.Foreground = Brushes.White; - Achievement.Add(column2); - ProductionHourList = xList; - - - ChartValues achievement = new ChartValues(); - Random random = new Random(); - for (int i = 0; i < 5; i++) + await App.Current.Dispatcher.BeginInvoke((Action)(() => { - achievement.Add(random.Next(60, 100)); - } + LoadData(); + List listTime = _baseBomInfoServices.getWorkTime().Result; + if (listTime == null) return; + // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime) + // List hourAmount = _offLineInfoServices.QueryCharts1("CX_01"); + + List list = _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime).Result; + if (list == null) return; + var hourList = list.Where(x => int.Parse(x.hour) >= listTime[0].startTime.Hour && int.Parse(x.hour) <= listTime[11].startTime.Hour && x.productLineCode.Equals("CX_02")); + + List xList = new List(); + ChartValues achievement2 = new ChartValues(); + foreach (var item in hourList) + { + xList.Add(item.hour); + achievement2.Add(item.Amount); + } - var column = new ColumnSeries(); - column.DataLabels = true; - column.Title = "型号"; - column.Values = achievement; - column.Foreground = Brushes.White; - ModelStatistics.Add(column); - MaterialNameList = new List() + + + var column2 = new ColumnSeries(); + column2.DataLabels = true; + column2.Title = "产量"; + column2.Values = achievement2; + column2.Foreground = Brushes.White; + // Achievement.Clear(); + //Achievement.Add(column2); + if (Achievement.Count > 0) + { + for (int i = 0; i < hourList.Count(); i++) + { + Achievement.FirstOrDefault().Values[i] = hourList.ElementAt(i).Amount; + } + } + else + { + Achievement.Add(column2); + } + + ProductionHourList = xList; + + + ChartValues achievement = new ChartValues(); + Random random = new Random(); + for (int i = 0; i < 5; i++) + { + achievement.Add(random.Next(60, 100)); + } + + var column = new ColumnSeries(); + column.DataLabels = true; + column.Title = "型号"; + column.Values = achievement; + column.Foreground = Brushes.White; + + ModelStatistics.Clear(); + MaterialNameList = null; + ModelStatistics.Add(column); + MaterialNameList = new List() { "SC-230,11W/H成品", "SC-439,箱体", @@ -362,9 +383,10 @@ namespace Aucma.Core.ProductOffLine.ViewModels "SC-439,背板", "SC-439VAM,元气森林,C", }; - } - + })); + + } //private async void InitEveryDayMethod() //{ // LoadData(); diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml index 83347bf3..efd55c02 100644 --- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml @@ -244,7 +244,7 @@ - +