From 6a493fd46cabff74fed3fa1c360c4a883b9f2d38 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 7 Jan 2024 13:50:17 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=8F=AD=E7=BB=84=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Api/Admin.Core.Model.xml | 7 +- .../Model_New/BoxFoamDataRecord.cs | 4 +- Admin.Core.Model/Model_New/BoxFoamplan.cs | 8 +- .../ViewModels/FoamPlanPageViewModel.cs | 67 +- .../ViewModels/OldBoxFoamPageViewModel.cs | 599 ++++++++++++------ .../ViewModels/QuantityIssuedViewModel.cs | 1 + Aucma.Core.OldBoxFoam/Views/MainWindow.xaml | 2 +- 7 files changed, 483 insertions(+), 205 deletions(-) diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index e92cb60d..20e9c342 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -1398,7 +1398,7 @@ - 主键 + 主键SEQ_BOX_FOAMDATARECORD @@ -1661,6 +1661,11 @@ 计划完成数量 + + + 工位编号 + + 获取发泡机最后一枪记录 diff --git a/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs b/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs index fb63bbe7..aa296707 100644 --- a/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs +++ b/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs @@ -14,9 +14,9 @@ namespace Admin.Core.Model public class BoxFoamDataRecord { /// - /// 主键 + /// 主键SEQ_BOX_FOAMDATARECORD /// - [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)] + [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true, OracleSequenceName = "SEQ_BOX_FOAMDATARECORD")] public int Obj_Id { get; set; } /// /// 产线 1、2 diff --git a/Admin.Core.Model/Model_New/BoxFoamplan.cs b/Admin.Core.Model/Model_New/BoxFoamplan.cs index 67b3a2e0..979d7d81 100644 --- a/Admin.Core.Model/Model_New/BoxFoamplan.cs +++ b/Admin.Core.Model/Model_New/BoxFoamplan.cs @@ -60,6 +60,12 @@ namespace Admin.Core.Model /// 计划完成数量 /// [SugarColumn(ColumnName = "COMPLATE_AMOUNT")] - public int CompleteAmount { get; set; } + public int CompleteAmount { get; set; } + + /// + /// 工位编号 + /// + [SugarColumn(ColumnName = "STATION_CODE")] + public string StationCode { get;set; } } } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs index b2ccf148..424d1e94 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs @@ -41,7 +41,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels { while (true) { - + App.Current.Dispatcher.BeginInvoke((Action)(() => { InitData(); @@ -50,7 +50,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels Thread.Sleep(1000 * 5); }; }); - + } @@ -77,12 +77,13 @@ namespace Aucma.Core.OldBoxFoam.ViewModels ListItems1.Clear(); ListItems.Clear(); int count = 0; - DateTime now=DateTime.Now; - CurrentTeamTime time = _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now).Result; - if (time == null) return; - if (time.TeamName.Equals("早班")) + + DateTime now = DateTime.Now; + + // 判断当前是否是白班时间段 + if (now.Hour >= 8 && now.Hour < 20) { - List list = _boxFoamPlanServices.QueryAsync(d=>d.ShiftType==1).Result; + List list = _boxFoamPlanServices.QueryAsync(d => d.ShiftType == 1).Result; if (list == null) return; foreach (BoxFoamPlan item in list) { @@ -95,12 +96,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels model.DifferenceValue = item.PlanAmount - item.CompleteAmount; model.ObjId = item.ObjId; ListItems.Add(model); - + } } - if (time.TeamName.Equals("晚班")) + else { - List list = _boxFoamPlanServices.QueryAsync(d => d.ShiftType == 1).Result; if (list == null) return; foreach (BoxFoamPlan item in list) @@ -113,11 +113,54 @@ namespace Aucma.Core.OldBoxFoam.ViewModels model.ComplateAmount = item.CompleteAmount; model.DifferenceValue = item.PlanAmount - item.CompleteAmount; model.ObjId = item.ObjId; - + ListItems1.Add(model); } } - + + #region 原逻辑 Delete By wenjy 2024-01-07 12:24:00 + //DateTime now=DateTime.Now; + //CurrentTeamTime time = _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now).Result; + //if (time == null) return; + //if (time.TeamName.Equals("早班")) + //{ + // List list = _boxFoamPlanServices.QueryAsync(d=>d.ShiftType==1).Result; + // if (list == null) return; + // foreach (BoxFoamPlan item in list) + // { + // BoxFoamPlanModel model = new BoxFoamPlanModel(); + // model.No = ++count; + // model.MaterialCode = item.MaterialCode; + // model.MaterialName = item.MaterialName; + // model.PlanAmount = item.PlanAmount; + // model.ComplateAmount = item.CompleteAmount; + // model.DifferenceValue = item.PlanAmount - item.CompleteAmount; + // model.ObjId = item.ObjId; + // ListItems.Add(model); + + // } + //} + //if (time.TeamName.Equals("晚班")) + //{ + + // List list = _boxFoamPlanServices.QueryAsync(d => d.ShiftType == 1).Result; + // if (list == null) return; + // foreach (BoxFoamPlan item in list) + // { + // BoxFoamPlanModel model = new BoxFoamPlanModel(); + // model.No = ++count; + // model.MaterialCode = item.MaterialCode; + // model.MaterialName = item.MaterialName; + // model.PlanAmount = item.PlanAmount; + // model.ComplateAmount = item.CompleteAmount; + // model.DifferenceValue = item.PlanAmount - item.CompleteAmount; + // model.ObjId = item.ObjId; + + // ListItems1.Add(model); + // } + //} + #endregion + } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs index ac916ed3..7f1fa0d5 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs @@ -10,6 +10,7 @@ using Aucma.Core.OldBoxFoam.Models; using CommunityToolkit.Mvvm.ComponentModel; using log4net; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Extensions; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -65,6 +66,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels // Thread.Sleep(1000 * 5); // collection.startCollect(); //}); + + DayShiftInfoCut(); + NightShiftInfoCut(); } #region 初始化加载数据 @@ -247,11 +251,6 @@ namespace Aucma.Core.OldBoxFoam.ViewModels //{ // ShiftChange(productLineCode); //} - - if(time == null) - { - ShiftChange(productLineCode); - } } catch (Exception ex) { @@ -347,218 +346,442 @@ namespace Aucma.Core.OldBoxFoam.ViewModels await _boxFoamPlanServices.UpdateAsync(planList); } } - - private async void ExecHourData(string productLineCode) + #endregion + #region 原计划完工逻辑 Delete By wenjy 2024-01-07 10:11:00 + //private async void ExecHourData(string productLineCode) + //{ + // try + // { + // List bList = new List(); + + + // var collectionList = Collection.listFixtureStatus; + // if (collectionList.Count == 0) return; + // OldBoxFoamOnLoad(collectionList); + // bList.AddRange(collectionList); + // List bfds = await _oldBoxFoamDataServices.QueryAsync(); + // List spaceList = await _oldBoxFoamTypeServices.QueryAsync(); + // List planList = await _boxFoamPlanServices.QueryAsync(); + // for (int j = 0; j < bList.Count; j++) + // { + // try + // { + // OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bList[j].FixtureBoxType); + // //根据夹具找货道,根据货道找物料 + // if (space != null) + // { + // BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount); + // if (plan != null) + // { + // int complateAmount = 0; + // //更新小时数据 + // BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); + // if (bfd != null) + // { + // //更新计划数量 + // complateAmount = bList[j].Yield - bfd.Production; + // UpdateBoxData(bList[j], bfd); + // } + // else + // { + // SaveBoxData(productLineCode, bList[j]); + // } + // plan.CompleteAmount = plan.CompleteAmount + complateAmount; + // await _boxFoamPlanServices.UpdateAsync(plan); + // } + // else + // { + // //更新小时数据 + // BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); + // if (bfd != null) + // { + // UpdateBoxData(bList[j], bfd); + // } + // else + // { + // SaveBoxData(productLineCode, bList[j]); + // } + // } + // } + // else + // { + // //更新小时数据 + // BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); + // if (bfd != null) + // { + // UpdateBoxData(bList[j], bfd); + // } + // else + // { + // SaveBoxData(productLineCode, bList[j]); + // } + // } + // } + // catch { } + + // } + // } + // catch (Exception ex) + // { + // Console.WriteLine(ex.Message); + // } + //} + + //private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd) + //{ + // int hour = GetTeamHour(DateTime.Now).Seq; + // switch (hour) + // { + // case 1: + // bfd.AnHour = item.Yield - bfd.Production; + // break; + // case 2: + // bfd.TwoHour = item.Yield - bfd.Production; + // break; + // case 3: + // bfd.ThreeHour = item.Yield - bfd.Production; + // break; + // case 4: + // bfd.FourHour = item.Yield - bfd.Production; + // break; + // case 5: + // bfd.FiveHour = item.Yield - bfd.Production; + // break; + // case 6: + // bfd.SixHour = item.Yield - bfd.Production; + // break; + // case 7: + // bfd.SevenHour = item.Yield - bfd.Production; + // break; + // case 8: + // bfd.EightHour = item.Yield - bfd.Production; + // break; + // case 9: + // bfd.NineHour = item.Yield - bfd.Production; + // break; + // case 10: + // bfd.TenHour = item.Yield - bfd.Production; + // break; + // case 11: + // bfd.ElevenHour = item.Yield - bfd.Production; + // break; + // case 12: + // bfd.TwelveHour = item.Yield - bfd.Production; + // break; + // default: + // break; + // } + + // bfd.Production = item.Yield; + + // await _oldBoxFoamDataServices.UpdateAsync(bfd); + //} + + //private async void SaveBoxData(string productLineCode, FixtureStatus item) + //{ + // BoxFoamData bfdata = new BoxFoamData(); + // bfdata.MainId = item.ObjId; + // bfdata.ProductLineCode = productLineCode; + // bfdata.Fixtureboxtype = item.FixtureBoxType; + // bfdata.Fixturestatus = item.Status; + // bfdata.Production = item.Yield; + // bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString(); + // bfdata.ActualValue = item.RealCuringTime.ToString(); + // int hour = GetTeamHour(DateTime.Now).Seq; + // switch (hour) + // { + // case 1: + // bfdata.AnHour = item.Yield = bfdata.Production; + // break; + // case 2: + // bfdata.TwoHour = item.Yield = bfdata.Production; + // break; + // case 3: + // bfdata.ThreeHour = item.Yield = bfdata.Production; + // break; + // case 4: + // bfdata.FourHour = item.Yield = bfdata.Production; + // break; + // case 5: + // bfdata.FiveHour = item.Yield = bfdata.Production; + // break; + // case 6: + // bfdata.SixHour = item.Yield = bfdata.Production; + // break; + // case 7: + // bfdata.SevenHour = item.Yield = bfdata.Production; + // break; + // case 8: + // bfdata.EightHour = item.Yield = bfdata.Production; + // break; + // case 9: + // bfdata.NineHour = item.Yield = bfdata.Production; + // break; + // case 10: + // bfdata.TenHour = item.Yield = bfdata.Production; + // break; + // case 11: + // bfdata.ElevenHour = item.Yield = bfdata.Production; + // break; + // case 12: + // bfdata.TwelveHour = item.Yield = bfdata.Production; + // break; + // default: + // break; + // } + // bfdata.MainId = item.ObjId; + // await _oldBoxFoamDataServices.AddAsync(bfdata); + //} + + //public CurrentTeamTimeView GetTeamHour() + //{ + // DateTime now = DateTime.Now; + // var list = _sysUserInfoServices.GetTeamData().Result; + // if (list != null) + // { + // //var obj = list.FirstOrDefault().EndTime.ToString("HH:mm"); + // var view = list.FirstOrDefault(); + // return view; + // } + // return null; + //} + + //public CurrentTeamTimeView GetTeamHour(DateTime now) + //{ + // var obj = _sysUserInfoServices.GetTeamData(now).Result; + // if (obj != null) + // { + // return obj; + // } + // return null; + //} + #endregion + + /// + /// 白班信息切换 + /// + private void DayShiftInfoCut() { - try - { - List bList = new List(); - - - var collectionList = Collection.listFixtureStatus; - if (collectionList.Count == 0) return; - OldBoxFoamOnLoad(collectionList); - bList.AddRange(collectionList); - List bfds = await _oldBoxFoamDataServices.QueryAsync(); - List spaceList = await _oldBoxFoamTypeServices.QueryAsync(); - List planList = await _boxFoamPlanServices.QueryAsync(); - for (int j = 0; j < bList.Count; j++) - { - try - { - OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bList[j].FixtureBoxType); - //根据夹具找货道,根据货道找物料 - if (space != null) - { - BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount); - if (plan != null) - { - int complateAmount = 0; - //更新小时数据 - BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); - if (bfd != null) - { - //更新计划数量 - complateAmount = bList[j].Yield - bfd.Production; - UpdateBoxData(bList[j], bfd); - } - else - { - SaveBoxData(productLineCode, bList[j]); - } - plan.CompleteAmount = plan.CompleteAmount + complateAmount; - await _boxFoamPlanServices.UpdateAsync(plan); - } - else - { - //更新小时数据 - BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); - if (bfd != null) - { - UpdateBoxData(bList[j], bfd); - } - else - { - SaveBoxData(productLineCode, bList[j]); - } - } - } - else - { - //更新小时数据 - BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId); - if (bfd != null) - { - UpdateBoxData(bList[j], bfd); - } - else - { - SaveBoxData(productLineCode, bList[j]); - } - } - } - catch { } + DateTime now = DateTime.Now; - } - } - catch (Exception ex) + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 08, 00, 00); + + if (now > scheduledTime) { - Console.WriteLine(ex.Message); + scheduledTime = scheduledTime.AddDays(1); } + TimeSpan timeToGo = scheduledTime - now; + int dueTime = (int)timeToGo.TotalMilliseconds; + + System.Timers.Timer timer = new System.Timers.Timer(); + timer.Elapsed += DayShiftTimerCallback; + timer.AutoReset = true; + timer.Interval = dueTime; + timer.Start(); } - private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd) + private void DayShiftTimerCallback(object sender, ElapsedEventArgs e) { - int hour = GetTeamHour(DateTime.Now).Seq; - switch (hour) + Console.WriteLine("切换为白班!"); + + UpdateShiftInfo(1); + + #region 重新定义Timer,进行第二天执行 + DateTime now = DateTime.Now; + + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 08, 00, 00); + + if (now > scheduledTime) { - case 1: - bfd.AnHour = item.Yield - bfd.Production; - break; - case 2: - bfd.TwoHour = item.Yield - bfd.Production; - break; - case 3: - bfd.ThreeHour = item.Yield - bfd.Production; - break; - case 4: - bfd.FourHour = item.Yield - bfd.Production; - break; - case 5: - bfd.FiveHour = item.Yield - bfd.Production; - break; - case 6: - bfd.SixHour = item.Yield - bfd.Production; - break; - case 7: - bfd.SevenHour = item.Yield - bfd.Production; - break; - case 8: - bfd.EightHour = item.Yield - bfd.Production; - break; - case 9: - bfd.NineHour = item.Yield - bfd.Production; - break; - case 10: - bfd.TenHour = item.Yield - bfd.Production; - break; - case 11: - bfd.ElevenHour = item.Yield - bfd.Production; - break; - case 12: - bfd.TwelveHour = item.Yield - bfd.Production; - break; - default: - break; + scheduledTime = scheduledTime.AddDays(1); } - bfd.Production = item.Yield; + TimeSpan timeToGo = scheduledTime - now; + int dueTime = (int)timeToGo.TotalMilliseconds; - await _oldBoxFoamDataServices.UpdateAsync(bfd); + System.Timers.Timer timer = (System.Timers.Timer)sender; + timer.Elapsed += DayShiftTimerCallback; + timer.AutoReset = true; + timer.Interval = dueTime; + timer.Start(); + #endregion } - private async void SaveBoxData(string productLineCode, FixtureStatus item) + /// + /// 夜班班组切换 + /// + private void NightShiftInfoCut() { - BoxFoamData bfdata = new BoxFoamData(); - bfdata.MainId = item.ObjId; - bfdata.ProductLineCode = productLineCode; - bfdata.Fixtureboxtype = item.FixtureBoxType; - bfdata.Fixturestatus = item.Status; - bfdata.Production = item.Yield; - bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString(); - bfdata.ActualValue = item.RealCuringTime.ToString(); - int hour = GetTeamHour(DateTime.Now).Seq; - switch (hour) + DateTime now = DateTime.Now; + + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00); + + if (now > scheduledTime) { - case 1: - bfdata.AnHour = item.Yield = bfdata.Production; - break; - case 2: - bfdata.TwoHour = item.Yield = bfdata.Production; - break; - case 3: - bfdata.ThreeHour = item.Yield = bfdata.Production; - break; - case 4: - bfdata.FourHour = item.Yield = bfdata.Production; - break; - case 5: - bfdata.FiveHour = item.Yield = bfdata.Production; - break; - case 6: - bfdata.SixHour = item.Yield = bfdata.Production; - break; - case 7: - bfdata.SevenHour = item.Yield = bfdata.Production; - break; - case 8: - bfdata.EightHour = item.Yield = bfdata.Production; - break; - case 9: - bfdata.NineHour = item.Yield = bfdata.Production; - break; - case 10: - bfdata.TenHour = item.Yield = bfdata.Production; - break; - case 11: - bfdata.ElevenHour = item.Yield = bfdata.Production; - break; - case 12: - bfdata.TwelveHour = item.Yield = bfdata.Production; - break; - default: - break; + scheduledTime = scheduledTime.AddDays(1); } - bfdata.MainId = item.ObjId; - await _oldBoxFoamDataServices.AddAsync(bfdata); + TimeSpan timeToGo = scheduledTime - now; + int dueTime = (int)timeToGo.TotalMilliseconds; + + System.Timers.Timer timer = new System.Timers.Timer(); + timer.Elapsed += NightShiftTimerCallback; + timer.AutoReset = true; + timer.Interval = dueTime; + timer.Start(); } - public CurrentTeamTimeView GetTeamHour() + private void NightShiftTimerCallback(object sender, ElapsedEventArgs e) { + Console.WriteLine("切换为夜班!"); + + UpdateShiftInfo(2); + + #region 重新定义Timer,进行第二天执行 DateTime now = DateTime.Now; - var list = _sysUserInfoServices.GetTeamData().Result; - if (list != null) + + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00); + + if (now > scheduledTime) { - //var obj = list.FirstOrDefault().EndTime.ToString("HH:mm"); - var view = list.FirstOrDefault(); - return view; + scheduledTime = scheduledTime.AddDays(1); } - return null; + + TimeSpan timeToGo = scheduledTime - now; + int dueTime = (int)timeToGo.TotalMilliseconds; + + System.Timers.Timer timer = (System.Timers.Timer)sender; + timer.Elapsed += NightShiftTimerCallback; + timer.AutoReset = true; + timer.Interval = dueTime; + timer.Start(); + #endregion } - public CurrentTeamTimeView GetTeamHour(DateTime now) + /// + /// 班组切换 + /// + /// 班组类型:1-白班;2-夜班 + private void UpdateShiftInfo(int shiftType) { - var obj = _sysUserInfoServices.GetTeamData(now).Result; - if (obj != null) + log.Warn($"{(shiftType == 1 ? "白班" :"夜班")}班组切换,开始处理切换逻辑"); + try { - return obj; - } - return null; - } + //下发PLC清空产量信号 + #region 清空PLC产量 + var obj1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteInt16("M216", "1");//换班 数据清空 + log.Warn($"班组切换清空A区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteInt16("M216", "1");//换班 数据清空 + log.Warn($"班组切换清空B区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + var obj3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3")); + if (obj3 != null) + { + if (obj3.plc.IsConnected) + { + var flag = obj3.plc.WriteInt16("M216", "1");//换班 数据清空 + log.Warn($"班组切换清空C区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + var obj4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4")); + if (obj4 != null) + { + if (obj4.plc.IsConnected) + { + var flag = obj4.plc.WriteInt16("M216", "1");//换班 数据清空 + log.Warn($"班组切换清空D区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + #endregion + //小时统计报表数据存至记录表,清空小时统计报表 - #endregion + var hourDataList = _oldBoxFoamDataServices.Query(x => x.ProductLineCode == "CX_01" && x.StationCode == "1005"); + List hourRecordList = new List(); + if (hourDataList != null) + { + foreach (var item in hourDataList) + { + BoxFoamDataRecord hourRecord = new BoxFoamDataRecord(); + hourRecord.OrderCode = item.OrderCode; + hourRecord.ProductLineCode = item.ProductLineCode; + hourRecord.Fixturestatus = item.Production; + hourRecord.CuringTimeSettingValue = item.CuringTimeSettingValue; + hourRecord.ActualValue = item.ActualValue; + hourRecord.AnHour = item.AnHour; + hourRecord.TwoHour = item.TwoHour; + hourRecord.ThreeHour = item.ThreeHour; + hourRecord.FourHour = item.FourHour; + hourRecord.FiveHour = item.FiveHour; + hourRecord.SixHour = item.SixHour; + hourRecord.SevenHour = item.SevenHour; + hourRecord.EightHour = item.EightHour; + hourRecord.NineHour = item.NineHour; + hourRecord.TenHour = item.TenHour; + hourRecord.ElevenHour = item.ElevenHour; + hourRecord.TwelveHour = item.TwelveHour; + hourRecord.BoxFixturesideplate = item.BoxFixturesideplate; + hourRecord.BoxClosebetatemperature = item.BoxClosebetatemperature; + hourRecord.BoxBeat = item.BoxBeat; + hourRecord.CreateTime = DateTime.Now; + hourRecordList.Add(hourRecord); + + bool deleteFlag = _oldBoxFoamDataServices.DeleteAsync(item).Result; + if (deleteFlag) + { + log.Warn($"{item.Fixtureboxtype}:小时数据清除成功"); + } + else + { + log.Warn($"{item.Fixtureboxtype}:小时数据清除失败"); + } + } + } + int addFlag = _boxFoamDataRecordServices.AddAsync(hourRecordList).Result; + if (addFlag > 0) + { + log.Warn("班组切换小时数据记录保存成功"); + } + else + { + log.Warn("班组切换小时数据记录保存失败"); + } + //当班计划,班组计划设为0 + var planInfoList = _boxFoamPlanServices.Query(x => x.ProductLineCode == "CX_01" && x.StationCode == "1005"); + if (planInfoList != null) + { + foreach (var plan in planInfoList) + { + plan.ShiftType = 0; + bool updateFlag = _boxFoamPlanServices.UpdateAsync(plan).Result; + if (updateFlag) + { + log.Warn($"计划:{plan.OrderCode},班组切换标识更新成功"); + } + else + { + log.Warn($"计划:{plan.OrderCode},班组切换标识更新失败"); + } + } + } + }catch(Exception ex) + { + log.Warn($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,切换逻辑处理异常:{ex.Message}"); + } + } } } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs index 0e0da571..cfda263c 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs @@ -107,6 +107,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels plan.MaterialName = _planInfo.MaterialName; plan.PlanAmount = Convert.ToInt32(TransmitAmount); plan.ProductLineCode = "CX_01"; + plan.StationCode = "1005"; plan.UpdateTime = DateTime.Now; plan.CreateTime = DateTime.Now; plan.OrderCode = _planInfo.OrderCode; diff --git a/Aucma.Core.OldBoxFoam/Views/MainWindow.xaml b/Aucma.Core.OldBoxFoam/Views/MainWindow.xaml index 551b040b..d2a263df 100644 --- a/Aucma.Core.OldBoxFoam/Views/MainWindow.xaml +++ b/Aucma.Core.OldBoxFoam/Views/MainWindow.xaml @@ -43,7 +43,7 @@ - +