From c3a577c10c3386595b5d1d88c1d3e3a902b0b4e6 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Sun, 31 Dec 2023 18:26:40 +0800 Subject: [PATCH] new --- .../IRepository_New/ISysUserInfoRepository.cs | 6 + .../IService_New/ISysUserInfoServices.cs | 6 + .../Service_New/SysUserInfoServices.cs | 13 ++ .../ViewModels/FoamMonitorPageViewModel.cs | 174 +++++++++--------- .../Views/FoamMachinesPageView.xaml | 4 +- 5 files changed, 111 insertions(+), 92 deletions(-) diff --git a/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs b/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs index ee82e31e..b426642a 100644 --- a/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs +++ b/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs @@ -21,5 +21,11 @@ namespace Admin.Core.IRepository /// /// Task> GetStationData(string code); + /// + /// 根据产线查询公司、产线、工序、工位 + /// + /// + /// + Task> GetProductLineInfo(string productLineCode); } } \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/ISysUserInfoServices.cs b/Admin.Core.IService/IService_New/ISysUserInfoServices.cs index e9d3d3b4..3e72c33d 100644 --- a/Admin.Core.IService/IService_New/ISysUserInfoServices.cs +++ b/Admin.Core.IService/IService_New/ISysUserInfoServices.cs @@ -30,5 +30,11 @@ namespace Admin.Core.IService /// /// Task> GetTeamData(); + /// + /// 根据产线查询公司、工位、工序 + /// + /// + /// + Task GetProductLineInfo(string productLineCode); } } \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/SysUserInfoServices.cs b/Admin.Core.Service/Service_New/SysUserInfoServices.cs index ae5ea946..0571893f 100644 --- a/Admin.Core.Service/Service_New/SysUserInfoServices.cs +++ b/Admin.Core.Service/Service_New/SysUserInfoServices.cs @@ -5,6 +5,7 @@ using Admin.Core.Model; using Admin.Core.Model.ViewModels; using Admin.Core.Service; using log4net; +using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; using System.Linq; @@ -49,5 +50,17 @@ namespace Admin.Core.IService var obj = list.SingleOrDefault(d => d.ProductLineCode == "productLineCode"); return obj; } + /// + /// 根据产线查询 公司、产线、工序、工位 + /// + /// + /// + public async Task GetProductLineInfo(string productLineCode) + { + var list = await _sysUserInfoRepository.GetProductLineInfo(productLineCode); + if (list == null) return null; + var obj = list.SingleOrDefault(d => d.ProductlineCode == productLineCode); + return obj; + } } } \ No newline at end of file diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs index 851e7ffa..f2f46726 100644 --- a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs @@ -20,6 +20,7 @@ using System.Timers; using Aucma.Core.BoxFoam.Models; using Admin.Core.Model; using System.Threading; +using Aucma.Core.HwPLc; namespace Aucma.Core.BoxFoam.ViewModels { @@ -32,9 +33,8 @@ namespace Aucma.Core.BoxFoam.ViewModels private readonly ISysUserInfoServices _sysUserInfoServices; private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices; private readonly IBoxFoamDataRealTimeServices? _boxFoamDataRealTimeServices; - private readonly IBoxFoamDataRealTimeHistoryServices _boxFoamDataRealTimeHistoryServices; - System.Timers.Timer timer2 = new System.Timers.Timer(2000); + System.Timers.Timer timer2 = new System.Timers.Timer(5000); int totalAmount = 0; @@ -45,7 +45,7 @@ namespace Aucma.Core.BoxFoam.ViewModels _boxFoamDataRecordServices = App.ServiceProvider.GetService(); _currentTeamTimeServices = App.ServiceProvider.GetService(); _boxFoamDataRealTimeHistoryServices = App.ServiceProvider.GetService(); - // _boxFoamDataServices = App.ServiceProvider.GetService(); + _sysUserInfoServices = App.ServiceProvider.GetService(); CollectionFoamLine.RefreshBoxFoamDataDelegateEvent += InitData; timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件; @@ -287,7 +287,7 @@ namespace Aucma.Core.BoxFoam.ViewModels { try { - int total = 0; + int totalAmount = 0; if (list == null) return; FixtureName.Clear(); @@ -295,6 +295,7 @@ namespace Aucma.Core.BoxFoam.ViewModels Beat.Clear(); InternalTemperature.Clear(); OutsideTemperature.Clear(); + foreach (var item in list) { if (item.Status == 1) StatusColor.Add("Green"); @@ -328,17 +329,18 @@ namespace Aucma.Core.BoxFoam.ViewModels try { string productLineCode = Appsettings.app("StationInfo", "ProductLineCode"); - - //DateTime now = DateTime.Now; - //CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now); - //if (time != null) - //{ - ExecHourDataAsync(productLineCode); - //} - //else - //{ - // //ShiftChangeAsync(productLineCode); - //} + + DateTime now = DateTime.Now; + List timeList = await _currentTeamTimeServices.QueryAsync(d => d.StartTime <= now && d.EndTime >= now); + + if (timeList.Count>0) + { + ExecHourDataAsync(productLineCode); + } + else + { + ShiftChangeAsync(productLineCode); + } } catch (Exception ex) @@ -369,6 +371,7 @@ namespace Aucma.Core.BoxFoam.ViewModels BoxFoamDataRealTime bfd = bfds.SingleOrDefault(d => d.FixtureBoxtype == bLis[j].FixtureBoxType && d.SerialNumber == bLis[j].ObjId); if (bfd != null) { + //更新计划数量 complateAmount = bLis[j].Yield - bfd.FixtureProductioncapacity; UpdateClampData(bLis[j], bfd); @@ -419,56 +422,33 @@ namespace Aucma.Core.BoxFoam.ViewModels private async void ShiftChangeAsync(string productLineCode) { - //切换班组计划 - var currentTeamTimeList = await _sysUserInfoServices.GetTeamData(); - if (currentTeamTimeList.Count == 0) return; - var list = await _boxFoamDataRealTimeServices.QueryAsync(d => d.ProductlineCode == productLineCode); - //更新计划表操作 - CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync(); - currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName; - currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime); - currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime); - - - //可以使用Mapping 映射 - //list.ForEach(d => - //{ - // BoxFoamDataRecord record = new BoxFoamDataRecord(); - // record.OrderCode = d.OrderCode; - // record.ProductLineCode = d.ProductLineCode; - // record.Fixturestatus = d.Production; - // record.CuringTimeSettingValue = d.CuringTimeSettingValue; - // record.ActualValue = d.ActualValue; - // record.AnHour = d.AnHour; - // record.TwoHour = d.TwoHour; - // record.ThreeHour = d.ThreeHour; - // record.FourHour = d.FourHour; - // record.FiveHour = d.FiveHour; - // record.SixHour = d.SixHour; - // record.SevenHour = d.SevenHour; - // record.EightHour = d.EightHour; - // record.NineHour = d.NineHour; - // record.TenHour = d.TenHour; - // record.ElevenHour = d.ElevenHour; - // record.TwelveHour = d.TwelveHour; - // record.BoxFixturesideplate = d.BoxFixturesideplate; - // record.BoxClosebetatemperature = d.BoxClosebetatemperature; - // record.BoxBeat = d.BoxBeat; - // record.CreateTime = DateTime.Now; - //}); - - - //int result = await _boxFoamDataRecordServices.AddAsync(recordList); - //if (result > 0) - //{ - // var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); - // if (obj2 == null) { return; } - // //obj2.plc.WriteInt16("M216", "1");//换班 数据清空 - // //清空 当班计划 - // await _oldBoxFoamDataServices.DeletesAsync(list); - // await _currentTeamTimeServices.UpdateAsync(currentTeamTime); - - //} + try + { + //切换班组计划 + var currentTeamTimeList = await _sysUserInfoServices.GetTeamData(); + if (currentTeamTimeList.Count == 0) return; + var list = await _boxFoamDataRealTimeServices.QueryAsync(d => d.ProductlineCode == productLineCode); + //更新计划表操作 + CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync(); + currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName; + currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime); + currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime); + + bool result = await _currentTeamTimeServices.UpdateAsync(currentTeamTime); + if (result) + { + var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj2 == null) { return; } + + //清空 当班计划 + var realTimeList = await _boxFoamDataRealTimeHistoryServices.QueryAsync(d => d.ProductlineCode == productLineCode); + await _boxFoamDataRealTimeHistoryServices.DeletesAsync(realTimeList); + + var plan = await _boxFoamPlanServices.QueryAsync(d => d.ProductLineCode == productLineCode); + await _boxFoamPlanServices.DeletesAsync(plan); + } + } + catch { } } @@ -478,16 +458,22 @@ namespace Aucma.Core.BoxFoam.ViewModels /// public async void UpdateClampData(FixtureStatus fixtureStatus, BoxFoamDataRealTime bfd) { - bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType; - bfd.FixtureStatus = fixtureStatus.Status.ToString(); - bfd.FixtureProductioncapacity = fixtureStatus.Yield; - bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString(); - bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString(); - bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature; - bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature; - bfd.UpdatedTime = DateTime.Now; - - await _boxFoamDataRealTimeServices.UpdateAsync(bfd); + + try + { + bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType; + bfd.FixtureStatus = fixtureStatus.Status.ToString(); + bfd.FixtureProductioncapacity = fixtureStatus.Yield; + bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString(); + bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString(); + bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature; + bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature; + bfd.Beat = fixtureStatus.Yield.ToString(); + bfd.UpdatedTime = DateTime.Now; + + await _boxFoamDataRealTimeServices.UpdateAsync(bfd); + } + catch { } } #endregion @@ -497,21 +483,29 @@ namespace Aucma.Core.BoxFoam.ViewModels /// public async void SaveClampData(string productLineCode,FixtureStatus fixtureStatus) { - BoxFoamDataRealTime bfd=new BoxFoamDataRealTime(); - - bfd.ProductlineCode = productLineCode; - bfd.SerialNumber = fixtureStatus.ObjId; - bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType; - bfd.FixtureStatus = fixtureStatus.Status.ToString(); - bfd.FixtureProductioncapacity = fixtureStatus.Yield; - bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString(); - bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString(); - bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature; - bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature; - bfd.CreatedTime = DateTime.Now; - bfd.UpdatedTime = DateTime.Now; - - await _boxFoamDataRealTimeServices.AddAsync(bfd); + var obj=await _sysUserInfoServices.GetProductLineInfo(productLineCode); + if (obj!=null) + { + BoxFoamDataRealTime bfd = new BoxFoamDataRealTime(); + + bfd.PlantCode = obj.PlantCode; + bfd.ProductlineCode = productLineCode; + bfd.ProcessCode = obj.ProcessCode; + bfd.StationCode = obj.StationCode; + bfd.SerialNumber = fixtureStatus.ObjId; + bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType; + bfd.FixtureStatus = fixtureStatus.Status.ToString(); + bfd.FixtureProductioncapacity = fixtureStatus.Yield; + bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString(); + bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString(); + bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature; + bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature; + bfd.CreatedTime = DateTime.Now; + bfd.UpdatedTime = DateTime.Now; + + await _boxFoamDataRealTimeServices.AddAsync(bfd); + } + } #endregion diff --git a/Aucma.Core.BoxFoam/Views/FoamMachinesPageView.xaml b/Aucma.Core.BoxFoam/Views/FoamMachinesPageView.xaml index 86a317b9..c0b03c82 100644 --- a/Aucma.Core.BoxFoam/Views/FoamMachinesPageView.xaml +++ b/Aucma.Core.BoxFoam/Views/FoamMachinesPageView.xaml @@ -115,7 +115,7 @@ - + @@ -311,7 +311,7 @@ - +