From 6a529d1b09b894d622fcb1a359c8713150b08ed9 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Wed, 27 Dec 2023 08:56:32 +0800 Subject: [PATCH] new --- .../Jobs/Job_OldBoxFoamStore_Quartz.cs | 624 ++++++++++++++++++ .../QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs | 115 ++-- Aucma.Core.HwPLc/IPlc.cs | 2 +- Aucma.Core.HwPLc/Impl/MelsecPlc.cs | 4 +- Aucma.Core.HwPLc/Impl/SiemensPlc.cs | 5 + .../ViewModels/FoamPlanPageViewModel.cs | 116 ++++ .../ViewModels/MainWindowViewModel.cs | 5 + .../ViewModels/QuantityIssuedViewModel.cs | 145 ++++ .../ViewModels/SplitPlanViewModel.cs | 418 ++++++++++++ .../Views/FoamPlanPageView.xaml | 291 ++++++++ .../Views/FoamPlanPageView.xaml.cs | 30 + Aucma.Core.OldBoxFoam/Views/MainWindow.xaml | 3 +- .../Views/QuantityIssuedView.xaml | 106 +++ .../Views/QuantityIssuedView.xaml.cs | 24 + .../Views/SplitPlanView.xaml | 202 ++++++ .../Views/SplitPlanView.xaml.cs | 49 ++ Aucma.Core.OldBoxFoam/appsettings.json | 6 +- Aucma.Core.RunPlc/RunPlcService.cs | 32 +- 18 files changed, 2110 insertions(+), 67 deletions(-) create mode 100644 Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs create mode 100644 Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs create mode 100644 Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs create mode 100644 Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs create mode 100644 Aucma.Core.OldBoxFoam/Views/FoamPlanPageView.xaml create mode 100644 Aucma.Core.OldBoxFoam/Views/FoamPlanPageView.xaml.cs create mode 100644 Aucma.Core.OldBoxFoam/Views/QuantityIssuedView.xaml create mode 100644 Aucma.Core.OldBoxFoam/Views/QuantityIssuedView.xaml.cs create mode 100644 Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml create mode 100644 Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml.cs diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs new file mode 100644 index 00000000..128748b5 --- /dev/null +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs @@ -0,0 +1,624 @@ +using Admin.Core.IService.ISys; +using Admin.Core.IService; +using Quartz; +using System; +using System.Threading.Tasks; +using log4net; +using Admin.Core.Common; +using System.Linq; +using Admin.Core.Model.Model_New; +using Aucma.Core.HwPLc; +using System.Collections.Generic; +using Admin.Core.Model; + +/// +/// 老发泡数据采集 +/// +namespace Admin.Core.Tasks +{ + public class Job_OldBoxFoamStore_Quartz : JobBase, IJob + { + #region 事件 + /// + /// 发泡线新事件 + /// + /// + public delegate Task RefreshBoxFoamDataDelegate(); + public static event RefreshBoxFoamDataDelegate RefreshBoxFoamDataDelegateEvent; + /// + /// 老发泡线更新事件 + /// + /// + public delegate Task RefreshOldBoxFoamDataDelegate(List list); + public static event RefreshOldBoxFoamDataDelegate RefreshOldBoxFoamDataDelegateEvent; + /// + /// 老泡前库更新事件 + /// + /// + public delegate Task RefreshOldBoxFoamTypeDataDelegate(List list); + public static event RefreshOldBoxFoamTypeDataDelegate RefreshOldBoxFoamTypeDataDelegateEvent; + + #endregion + + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); + + private readonly IOldBoxFoamTypeServices _oldBoxFoamTypeServices; + private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; + + public Job_OldBoxFoamStore_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, + IOldBoxFoamTypeServices oldBoxFoamTypeServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + { + _SysTasksQzService = SysTasksQzService; + _oldBoxFoamTypeServices = oldBoxFoamTypeServices; + _oldBoxFoamDataServices = oldBoxFoamDataServices; + } + + public async Task Execute(IJobExecutionContext context) + { + //await ExecuteJob(context, async () => await OldBoxFoamDataRun(context));//发泡线 + await ExecuteJob(context, async () => await OldBoxFoamStoreDataRun(context)); + } + + /// + /// 发泡线 + /// + /// + /// + public async Task OldBoxFoamDataRun(IJobExecutionContext context) + { + await OldBoxFoamData(); + } + + public async Task OldBoxFoamStoreDataRun(IJobExecutionContext context) + { + await OldBoxFoamStoreData(); + } + + #region PLC 老泡前库任务处理表 + /// + /// PLC 任务处理表 + /// + /// 仓库编码 + /// 物料编码 + /// + public async Task OldBoxFoamStoreData() + { + try + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldTypePlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + var taskList = await _oldBoxFoamTypeServices.QueryAsync(); + int i = taskList.Count(); + foreach (var item in taskList) + { + await UpdateRealOldBoxFoamTypeData(obj, item); + i--; + if (i==0) + { + var list = await _oldBoxFoamTypeServices.QueryAsync(); + RefreshOldBoxFoamTypeDataDelegateEvent?.Invoke(list); + } + + } + } + } + catch (Exception ex) + { + logHelper.Error($"入库数据处理异常:{ex.Message}"); + } + } + + /// + /// 泡前库更新 + /// + /// + /// + /// + private async Task UpdateRealOldBoxFoamTypeData(PlcModel obj, OldBoxFoamType item) + { + try + { + #region 更新PLC数据 + if (item.ObjId == 1) + { + int amount = 0; + + var str = $"{obj.plc.ReadInt16("L101")}{obj.plc.ReadInt16("L102")}{obj.plc.ReadInt16("L103")}"; + if (str.IsNotEmptyOrNull()) + { + int r=Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount=1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2010"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 2) + { + int amount = 0; + var str = obj.plc.ReadInt16("L201").ToString() + obj.plc.ReadInt16("L202").ToString() + obj.plc.ReadInt16("L303").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + amount = r; + break; + } + item.Boxtype = obj.plc.ReadString("D2020"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 3) + { + int amount = 0; + var str = obj.plc.ReadInt16("L301").ToString() + obj.plc.ReadInt16("L302").ToString() + obj.plc.ReadInt16("L303").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2030"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 4) + { + int amount = 0; + var str = obj.plc.ReadInt16("L401").ToString() + obj.plc.ReadInt16("L402").ToString() + obj.plc.ReadInt16("L403").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2040"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 5) + { + int amount = 0; + var str = obj.plc.ReadInt16("L501").ToString() + obj.plc.ReadInt16("L502").ToString() + obj.plc.ReadInt16("L503").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2010"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 6) + { + int amount = 0; + var str = obj.plc.ReadInt16("L601").ToString() + obj.plc.ReadInt16("L602").ToString() + obj.plc.ReadInt16("L603").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2020"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 7) + { + int amount = 0; + var str = obj.plc.ReadInt16("L701").ToString() + obj.plc.ReadInt16("L702").ToString() + obj.plc.ReadInt16("L703").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2030"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 8) + { + int amount = 0; + var str = obj.plc.ReadInt16("L801").ToString() + obj.plc.ReadInt16("L802").ToString() + obj.plc.ReadInt16("L803").ToString(); + if (str.IsNotEmptyOrNull()) + { + int r = Convert.ToInt32(str); + switch (r) + { + case 0: + amount = 0; + break; + case 1: + amount = 1; + break; + case 11: + amount = 2; + break; + case 111: + amount = 3; + break; + default: + break; + } + item.Boxtype = obj.plc.ReadString("D2040"); + item.Storeamount = amount; + item.UpdatedTime = DateTime.Now; + } + } + #endregion + bool result = await _oldBoxFoamTypeServices.UpdateAsync(item); + if (result) + { + //var list = await _oldBoxFoamTypeServices.QueryAsync(); + //RefreshOldBoxFoamTypeDataDelegateEvent?.Invoke(list); + } + else + { + // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); + } + } + catch (Exception ex) + { + logHelper.Error($"更新老箱体发泡数据失败"); + } + + return await Task.FromResult(item); + } + #endregion + + #region 老泡线体夹具任务处理表 + + public async Task OldBoxFoamData() + { + var list = await _oldBoxFoamDataServices.QueryAsync(); + int i = list.Count(); + foreach (var item in list) + { + UpdateRealOldBoxFoamData(item); + i--; + if (i == 0) + { + List old = await _oldBoxFoamDataServices.QueryAsync(); + RefreshOldBoxFoamDataDelegateEvent?.Invoke(old); + } + } + } + + private async void UpdateRealOldBoxFoamData(OldBoxFoamData item) + { + if (item.ObjId == 1) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + var type1 = $"{obj.plc.ReadInt32("D3140")}"; + if (type1.ToString()!="0") + { + item.Fixtureboxtype = type1; + } + //var type2 = $"{obj.plc.ReadInt16("D3141")}"; + //if (type1.ToString() != "0") + //{ + // item.Fixtureboxtype = item.Fixtureboxtype+type2; + //} + //string type = $"{obj.plc.ReadInt16("D3140")}{obj.plc.ReadInt16("D3141")}"; + //item.Fixtureboxtype = type; + if (obj.plc.ReadBool("Y0F0")) + { + item.Fixturestatus = "手动"; + } + else if (obj.plc.ReadBool("Y0F1")) + { + item.Fixturestatus = "手动"; + } + else if (obj.plc.ReadBool("Y110")) + { + item.Fixturestatus = "停止"; + } + item.Production = obj.plc.ReadInt16("D182"); + item.CuringTimeSettingValue = obj.plc.ReadInt16("D910").ToString(); + item.ActualValue = obj.plc.ReadInt16("T3").ToString(); + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 2) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + //string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3141")}"; + //item.Fixtureboxtype = type; + + var type1 = $"{obj.plc.ReadInt32("D3142")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + + if (obj.plc.ReadBool("Y0F5")) + { + item.Fixturestatus = "手动"; + } + if (obj.plc.ReadBool("Y0F6")) + { + item.Fixturestatus = "手动"; + } + if (obj.plc.ReadBool("Y111")) + { + item.Fixturestatus = "停止"; + } + item.Production = obj.plc.ReadInt16("D183"); + item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); + item.ActualValue = obj.plc.ReadInt16("T13").ToString(); + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 3) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + //string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3143")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3144")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + if (obj.plc.ReadBool("Y0FA")) + { + item.Fixturestatus = "手动"; + } + if (obj.plc.ReadBool("Y0FB")) + { + item.Fixturestatus = "手动"; + } + if (obj.plc.ReadBool("Y112")) + { + item.Fixturestatus = "停止"; + } + item.Production = obj.plc.ReadInt16("D184"); + item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); + item.ActualValue = obj.plc.ReadInt16("T23").ToString(); + item.UpdatedTime = DateTime.Now; + } + } + if (item.ObjId == 4) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + // string type = $"{obj.plc.ReadInt16("D3144")}{obj.plc.ReadInt16("D3145")}"; + var type1 = $"{obj.plc.ReadInt32("D3146")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + item.Production = obj.plc.ReadInt16("D185"); + item.CuringTimeSettingValue = obj.plc.ReadInt16("D913").ToString(); + item.ActualValue = obj.plc.ReadInt16("T33").ToString(); + item.UpdatedTime = DateTime.Now; + } + var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + if (objStatus != null) { + if (objStatus.plc.ReadBool("Y100")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y101")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y113")) + { + item.Fixturestatus = "停止"; + } + + } + } + if (item.ObjId == 5) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + //string type = $"{obj.plc.ReadInt16("D3150")}{obj.plc.ReadInt16("D3151")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3148")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + item.Production = obj.plc.ReadInt16("D186"); + item.CuringTimeSettingValue = obj.plc.ReadInt16("D913").ToString(); + item.ActualValue = obj.plc.ReadInt16("T43").ToString(); + item.UpdatedTime = DateTime.Now; + } + + var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + if (objStatus != null&& objStatus.plc.IsConnected) + { + if (objStatus.plc.ReadBool("Y105")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y106")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y114")) + { + item.Fixturestatus = "停止"; + } + + } + } + if (item.ObjId == 6) + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + if (obj.plc.IsConnected) + { + //string type = $"{obj.plc.ReadInt16("D3152")}{obj.plc.ReadInt16("D3143")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3150")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + else + { + item.Fixtureboxtype = ""; + } + item.CuringTimeSettingValue = obj.plc.ReadInt16("D915").ToString(); + item.Production = obj.plc.ReadInt16("D187"); + item.UpdatedTime = DateTime.Now; + } + var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + if (objStatus != null) + { + if (objStatus.plc.ReadBool("Y10A")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y10B")) + { + item.Fixturestatus = "手动"; + } + if (objStatus.plc.ReadBool("Y115")) + { + item.Fixturestatus = "停止"; + } + item.ActualValue = objStatus.plc.ReadInt16("T53").ToString(); + + } + } + + bool result = await _oldBoxFoamDataServices.UpdateAsync(item); + if (result) + { + //var list = await _oldBoxFoamTypeServices.QueryAsync(); + //RefreshOldBoxFoamDataDelegateEvent?.Invoke(list); + } + else + { + // RefreshOldBoxFoamDataDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); + } + } + #endregion + } +} diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs index 086ca77e..3fd21514 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs @@ -56,7 +56,7 @@ namespace Admin.Core.Tasks public async Task Execute(IJobExecutionContext context) { await ExecuteJob(context, async () => await OldBoxFoamDataRun(context));//发泡线 - await ExecuteJob(context, async () => await OldBoxFoamStoreDataRun(context)); + //await ExecuteJob(context, async () => await OldBoxFoamStoreDataRun(context)); } /// /// 发泡线 @@ -241,7 +241,7 @@ namespace Admin.Core.Tasks if (item.ObjId == 5) { int amount = 0; - var str = obj.plc.ReadInt16("L101").ToString() + obj.plc.ReadInt16("L102").ToString() + obj.plc.ReadInt16("L103").ToString(); + var str = obj.plc.ReadInt16("L501").ToString() + obj.plc.ReadInt16("L502").ToString() + obj.plc.ReadInt16("L503").ToString(); if (str.IsNotEmptyOrNull()) { int r = Convert.ToInt32(str); @@ -270,7 +270,7 @@ namespace Admin.Core.Tasks if (item.ObjId == 6) { int amount = 0; - var str = obj.plc.ReadInt16("L201").ToString() + obj.plc.ReadInt16("L202").ToString() + obj.plc.ReadInt16("L203").ToString(); + var str = obj.plc.ReadInt16("L601").ToString() + obj.plc.ReadInt16("L602").ToString() + obj.plc.ReadInt16("L603").ToString(); if (str.IsNotEmptyOrNull()) { int r = Convert.ToInt32(str); @@ -299,7 +299,7 @@ namespace Admin.Core.Tasks if (item.ObjId == 7) { int amount = 0; - var str = obj.plc.ReadInt16("L301").ToString() + obj.plc.ReadInt16("L302").ToString() + obj.plc.ReadInt16("L303").ToString(); + var str = obj.plc.ReadInt16("L701").ToString() + obj.plc.ReadInt16("L702").ToString() + obj.plc.ReadInt16("L703").ToString(); if (str.IsNotEmptyOrNull()) { int r = Convert.ToInt32(str); @@ -328,7 +328,7 @@ namespace Admin.Core.Tasks if (item.ObjId == 8) { int amount = 0; - var str = obj.plc.ReadInt16("L401").ToString() + obj.plc.ReadInt16("L402").ToString() + obj.plc.ReadInt16("L403").ToString(); + var str = obj.plc.ReadInt16("L801").ToString() + obj.plc.ReadInt16("L802").ToString() + obj.plc.ReadInt16("L803").ToString(); if (str.IsNotEmptyOrNull()) { int r = Convert.ToInt32(str); @@ -401,8 +401,18 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3140")}{obj.plc.ReadInt16("D3141")}"; - item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3140")}"; + if (type1.ToString()!="0") + { + item.Fixtureboxtype = type1; + } + //var type2 = $"{obj.plc.ReadInt16("D3141")}"; + //if (type1.ToString() != "0") + //{ + // item.Fixtureboxtype = item.Fixtureboxtype+type2; + //} + //string type = $"{obj.plc.ReadInt16("D3140")}{obj.plc.ReadInt16("D3141")}"; + //item.Fixtureboxtype = type; if (obj.plc.ReadBool("Y0F0")) { item.Fixturestatus = "手动"; @@ -415,18 +425,11 @@ namespace Admin.Core.Tasks { item.Fixturestatus = "停止"; } + item.Production = obj.plc.ReadInt16("D182"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D910").ToString(); item.ActualValue = obj.plc.ReadInt16("T3").ToString(); item.UpdatedTime = DateTime.Now; } - var objProduction = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); - if (objProduction == null) { - item.Production = 0; - } - else - { - item.Production = objProduction.plc.ReadInt16("D181"); - } } if (item.ObjId == 2) { @@ -434,8 +437,15 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3141")}"; - item.Fixtureboxtype = type; + //string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3141")}"; + //item.Fixtureboxtype = type; + + var type1 = $"{obj.plc.ReadInt32("D3142")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + if (obj.plc.ReadBool("Y0F5")) { item.Fixturestatus = "手动"; @@ -448,19 +458,11 @@ namespace Admin.Core.Tasks { item.Fixturestatus = "停止"; } + item.Production = obj.plc.ReadInt16("D183"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T13").ToString(); item.UpdatedTime = DateTime.Now; } - var objProduction = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); - if (objProduction == null) - { - item.Production = 0; - } - else if (objProduction != null&& objProduction.plc.IsConnected) - { - item.Production = objProduction.plc.ReadInt16("D183"); - } } if (item.ObjId == 3) { @@ -468,8 +470,13 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3143")}"; - item.Fixtureboxtype = type; + //string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3143")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3144")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } if (obj.plc.ReadBool("Y0FA")) { item.Fixturestatus = "手动"; @@ -482,20 +489,11 @@ namespace Admin.Core.Tasks { item.Fixturestatus = "停止"; } - + item.Production = obj.plc.ReadInt16("D184"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T23").ToString(); item.UpdatedTime = DateTime.Now; } - var objProduction = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); - if (objProduction == null) - { - item.Production = 0; - } - else - { - item.Production = objProduction.plc.ReadInt16("D184"); - } } if (item.ObjId == 4) { @@ -503,9 +501,13 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3144")}{obj.plc.ReadInt16("D3145")}"; - item.Fixtureboxtype = type; - + // string type = $"{obj.plc.ReadInt16("D3144")}{obj.plc.ReadInt16("D3145")}"; + var type1 = $"{obj.plc.ReadInt32("D3146")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + item.Production = obj.plc.ReadInt16("D185"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D913").ToString(); item.ActualValue = obj.plc.ReadInt16("T33").ToString(); item.UpdatedTime = DateTime.Now; @@ -524,7 +526,7 @@ namespace Admin.Core.Tasks { item.Fixturestatus = "停止"; } - item.Production = objStatus.plc.ReadInt16("D185"); + } } if (item.ObjId == 5) @@ -533,8 +535,14 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3150")}{obj.plc.ReadInt16("D3151")}"; - item.Fixtureboxtype = type; + //string type = $"{obj.plc.ReadInt16("D3150")}{obj.plc.ReadInt16("D3151")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3148")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + item.Production = obj.plc.ReadInt16("D186"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D913").ToString(); item.ActualValue = obj.plc.ReadInt16("T43").ToString(); item.UpdatedTime = DateTime.Now; @@ -555,7 +563,7 @@ namespace Admin.Core.Tasks { item.Fixturestatus = "停止"; } - item.Production = objStatus.plc.ReadInt16("D186"); + } } if (item.ObjId == 6) @@ -564,10 +572,19 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { - string type = $"{obj.plc.ReadInt16("D3152")}{obj.plc.ReadInt16("D3143")}"; - item.Fixtureboxtype = type; + //string type = $"{obj.plc.ReadInt16("D3152")}{obj.plc.ReadInt16("D3143")}"; + //item.Fixtureboxtype = type; + var type1 = $"{obj.plc.ReadInt32("D3150")}"; + if (type1.ToString() != "0") + { + item.Fixtureboxtype = type1; + } + else + { + item.Fixtureboxtype = ""; + } item.CuringTimeSettingValue = obj.plc.ReadInt16("D915").ToString(); - + item.Production = obj.plc.ReadInt16("D187"); item.UpdatedTime = DateTime.Now; } var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); @@ -586,7 +603,7 @@ namespace Admin.Core.Tasks item.Fixturestatus = "停止"; } item.ActualValue = objStatus.plc.ReadInt16("T53").ToString(); - item.Production = objStatus.plc.ReadInt16("D187"); + } } diff --git a/Aucma.Core.HwPLc/IPlc.cs b/Aucma.Core.HwPLc/IPlc.cs index 71ad19e5..cc16c35f 100644 --- a/Aucma.Core.HwPLc/IPlc.cs +++ b/Aucma.Core.HwPLc/IPlc.cs @@ -31,7 +31,7 @@ namespace Aucma.Core.HwPLc /// /// /// - byte[] ReadBytes(string address); + byte[] ReadBytes(string address, ushort len); /// /// 读取bool /// diff --git a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs index 8c08dfaa..b548723d 100644 --- a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs +++ b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs @@ -124,12 +124,12 @@ namespace Aucma.Core.HwPLc /// /// /// - public byte[] ReadBytes(string address) + public byte[] ReadBytes(string address,ushort len) { byte[] bytes = null; try { - OperateResult read = melsecMcNet.Read(address, 26); + OperateResult read = melsecMcNet.Read(address, len); if (read.IsSuccess) { byte[] code = new byte[read.Content.Length - 2]; diff --git a/Aucma.Core.HwPLc/Impl/SiemensPlc.cs b/Aucma.Core.HwPLc/Impl/SiemensPlc.cs index f4e260d9..4dbe3f50 100644 --- a/Aucma.Core.HwPLc/Impl/SiemensPlc.cs +++ b/Aucma.Core.HwPLc/Impl/SiemensPlc.cs @@ -498,6 +498,11 @@ namespace Aucma.Core.HwPLc } return false; } + + public byte[] ReadBytes(string address, ushort len) + { + throw new NotImplementedException(); + } #endregion } } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs new file mode 100644 index 00000000..d5fc4892 --- /dev/null +++ b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs @@ -0,0 +1,116 @@ +using Admin.Core.IService; +using Aucma.Core.OldBoxFoam.Views; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Aucma.Core.OldBoxFoam.ViewModels +{ + /** + * 发泡计划 + * + * */ + public partial class FoamPlanPageViewModel : ObservableObject + { + protected readonly IBoxFoamPlanServices? _boxFoamPlanServices; + public FoamPlanPageViewModel() + { + _boxFoamPlanServices = App.ServiceProvider.GetService(); + WeakReferenceMessenger.Default.Register(this, Recive); + InitData(); + } + + public async void InitData() + { + var task =await _boxFoamPlanServices.QueryAsync(); + if (task == null) return; + task.OrderBy(d=>d.ObjId); + foreach (var item in task) + { + Id.Add(item.ObjId); + MaterialCode.Add(item.MaterialCode); + MaterialName.Add(item.MaterialName); + PlanAmount.Add(item.PlanAmount); + } + } + + #region MyRegion + private ObservableCollection _id = new ObservableCollection(); + public ObservableCollection Id + { + get => _id; + set => SetProperty(ref _id, value); + } + private ObservableCollection _materialCode = new ObservableCollection(); + public ObservableCollection MaterialCode + { + get => _materialCode; + set => SetProperty(ref _materialCode, value); + } + private ObservableCollection _materialName = new ObservableCollection(); + public ObservableCollection MaterialName + { + get => _materialName; + set => SetProperty(ref _materialName, value); + } + private ObservableCollection _planAmount = new ObservableCollection(); + public ObservableCollection PlanAmount + { + get => _planAmount; + set => SetProperty(ref _planAmount, value); + } + #endregion + + [RelayCommand] + public void AddPlan(string objId) + { + SplitPlanView plan = new SplitPlanView(objId); + plan.Show(); + } + + [RelayCommand] + public async void ClearPlan(string objId) + { + int id=int.Parse(objId); + var obj=await _boxFoamPlanServices.FirstAsync(d=>d.ObjId== id); + obj.MaterialCode = ""; + obj.MaterialName = ""; + obj.PlanAmount = 0; + var result= await _boxFoamPlanServices.UpdateAsync(obj); + if (result) + { + ClearData(); + MessageBox.Show("清除计划成功!", "系统提醒"); + } + else + { + MessageBox.Show("清除计划失败!", "系统提醒"); + } + } + + + private void Recive(object recipient, string message) + { + if (message == "RefreshTask") + { + ClearData(); + } + } + public void ClearData() + { + Id.Clear(); + MaterialCode.Clear(); + MaterialName.Clear(); + PlanAmount.Clear(); + InitData(); + } + } +} diff --git a/Aucma.Core.OldBoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/MainWindowViewModel.cs index 3d4bf6ba..fed9a432 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/MainWindowViewModel.cs @@ -201,6 +201,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels OldWarehousePageView oldWarehousePage = new OldWarehousePageView(); UserContent = oldWarehousePage; break; + case "FoamPlanPage": + FoamPlanPageView foamPlanPage = new FoamPlanPageView(); + UserContent = foamPlanPage; + break; + default: break; } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs new file mode 100644 index 00000000..42b355d2 --- /dev/null +++ b/Aucma.Core.OldBoxFoam/ViewModels/QuantityIssuedViewModel.cs @@ -0,0 +1,145 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Aucma.Core.OldBoxFoam.Models; +using Aucma.Core.OldBoxFoam.Models; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; +using log4net; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; +using System.Windows; + +namespace Aucma.Core.OldBoxFoam.ViewModels +{ + public partial class QuantityIssuedViewModel : ObservableObject + { + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(QuantityIssuedViewModel)); + private IBaseBomInfoServices _bomInfoServices; + private IBaseSpaceDetailServices _spaceDetailServices; + protected readonly IExecutePlanInfoServices? _executePlanInfoServices; + protected readonly IBoxFoamPlanServices? _boxFoamPlanServices; + #region 构造函数 + public QuantityIssuedViewModel(ProductPlanInfoModel productPlanInfo, string objId) + { + _boxFoamPlanServices = App.ServiceProvider.GetService(); + _planInfo = productPlanInfo; + _objId = objId; + } + #endregion + + #region 属性 + private ProductPlanInfoModel _planInfo = new ProductPlanInfoModel(); + public ProductPlanInfoModel PlanInfo + { + get => _planInfo; + set => SetProperty(ref _planInfo, value); + } + private string _TransmitAmount = string.Empty; + public string TransmitAmount + { + get => _TransmitAmount; + set => SetProperty(ref _TransmitAmount, value); + } + + private string _objId = string.Empty; + public string ObjId + { + get => _objId; + set => SetProperty(ref _objId, value); + } + #endregion + + #region 清除 + /// + /// 清除 + /// + [RelayCommand] + private void ClearTransmitAmount() + { + string amount = _TransmitAmount.ToString(); + if (amount.Length > 0) + { + TransmitAmount = amount.Substring(0, amount.Length - 1); + } + } + #endregion + + #region KeypadButton + [RelayCommand] + private void KeypadButton(object obj) + { + var info = obj as string; + + TransmitAmount += info; + } + #endregion + + #region 关闭 + /// + /// 关闭 + /// + /// + [RelayCommand] + private void CloseWindow(object parameter) + { + var window = parameter as Window; + if (window != null) + { + window.Close(); + } + } + #endregion + + #region 保存数据 + /// + /// 保存数据 + /// + [RelayCommand] + private void AddPlanInfo() + { + var productPlanInfo = _planInfo; + if (_planInfo != null) + { + var task = _boxFoamPlanServices.FirstAsync(d => d.ObjId ==int.Parse(_objId)).Result; + if (task != null) + { + task.MaterialCode = _planInfo.MaterialCode; + task.MaterialName = _planInfo.MaterialName; + task.PlanAmount = Convert.ToInt32(TransmitAmount); + var result = _boxFoamPlanServices.UpdateAsync(task).Result; + if (result) + { + MessageBox.Show("任务添加成功!", "系统提醒"); + WeakReferenceMessenger.Default.Send("RefreshTask");//刷新任务界面 + } + else + { + MessageBox.Show("任务添加失败!", "系统提醒"); + } + } + } + else + { + BoxFoamPlan plan = new BoxFoamPlan(); + plan.MaterialCode = _planInfo.MaterialCode; + plan.MaterialName = _planInfo.MaterialName; + plan.PlanAmount = Convert.ToInt32(TransmitAmount); + var result = _boxFoamPlanServices.AddAsync(plan).Result; + if (result > 0) + { + MessageBox.Show("任务添加成功!", "系统提醒"); + WeakReferenceMessenger.Default.Send("RefreshTask");//刷新任务界面 + } + else + { + MessageBox.Show("任务添加失败!", "系统提醒"); + } + MessageBox.Show("任务添加失败,加载为空", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); + + } + } + #endregion + } +} diff --git a/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs new file mode 100644 index 00000000..79fee37d --- /dev/null +++ b/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs @@ -0,0 +1,418 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Admin.Core.IService; +using log4net; +using Microsoft.Extensions.DependencyInjection; +using Admin.Core.Model; +using Castle.Core.Internal; +using CommunityToolkit.Mvvm.Messaging; +using Admin.Core.Common; +using Aucma.Core.OldBoxFoam.Common; +using Aucma.Core.OldBoxFoam.Models; +using Aucma.Core.OldBoxFoam.Views; + +namespace Aucma.Core.OldBoxFoam.ViewModels +{ + public partial class SplitPlanViewModel : ObservableObject + { + private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SplitPlanViewModel)); + protected readonly IProductPlanInfoServices? _productPlanInfoServices; + //protected readonly ISmTaskExecutionServices? _smTaskExecutionServices; + protected readonly IExecutePlanInfoServices? _executePlanInfoServices; + private AppConfigHelper appConfig = new AppConfigHelper(); + + public SplitPlanViewModel(string objId) + { + _productPlanInfoServices = App.ServiceProvider.GetService(); + _executePlanInfoServices = App.ServiceProvider.GetService(); + Task.WaitAll(LoadData()); + //加载快捷方式 + SaveSearchCriteria(); + WeakReferenceMessenger.Default.Register(this, SaveSearchCriteria); + _objId = objId; + } + + #region 加载DataGrid数据 + private async Task LoadData() + { + MaterialDataGrid.Clear(); + int i = 1; + string station = Appsettings.app("StoreInfo", "StationCode"); + var planlist = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + foreach (var item in planlist) + { + int residue = 0; + if (execList == null) residue = 0; + else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount); + MaterialDataGrid.Add(new ProductPlanInfoModel() + { + No = i, + PlanCode = item.PlanCode, + MaterialCode = item.MaterialCode, + MaterialName = item.MaterialName, + OrderCode = item.OrderCode, + PlanAmount = item.PlanAmount, + ResidueAmount = item.PlanAmount - item.CompleteAmount, + SpliteResidueAmount = item.PlanAmount - residue, + StartDate = item.BeginTime + }); + i++; + } + } + + private async Task LoadData(string obj) + { + int i = 1; + string station = Appsettings.app("StoreInfo", "StationCode"); + var planlist = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + var queryList = planlist.Where(d=>d.OrderCode.Contains(obj)|| d.MaterialCode.Contains(obj) || d.MaterialName.Contains(obj)); + var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + foreach (var item in queryList) + { + int residue = 0; + if (execList == null) residue = 0; + else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount); + MaterialDataGrid.Add(new ProductPlanInfoModel() + { + No = i, + PlanCode = item.PlanCode, + MaterialCode = item.MaterialCode, + MaterialName = item.MaterialName, + OrderCode = item.OrderCode, + PlanAmount = item.PlanAmount, + ResidueAmount = item.PlanAmount - item.CompleteAmount, + SpliteResidueAmount = item.PlanAmount - residue, + StartDate = item.BeginTime + }); + i++; + } + } + #endregion + + #region 初始化datagrid + private ObservableCollection materialDataGrid = new ObservableCollection(); + public ObservableCollection MaterialDataGrid + { + get => materialDataGrid; + set => SetProperty(ref materialDataGrid, value); + } + #endregion + + #region 查询 + /// + /// 查询 + /// + [RelayCommand] + private async Task QueryPlan(string obj) + { + if (obj.IsNullOrEmpty()) + { + System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () => + { + MaterialDataGrid.Clear(); + await LoadData(); + })); + return; + } + MaterialDataGrid.Clear(); + await LoadData(obj); + } + #endregion + + #region 创建任务 + /// + /// 创建任务 + /// + [RelayCommand] + private async Task CreateTask(string obj) + { + if (string.IsNullOrEmpty(obj)) + { + MessageBox.Show("请选中需要拆分的计划!", "系统提醒"); + return; + } + string plan_code = SelectedCells.PlanCode; + string order_code = SelectedCells.OrderCode; + string material_code = SelectedCells.MaterialCode; + string material_name = SelectedCells.MaterialName; + int plan_amount = SelectedCells.PlanAmount; + + var list = await _executePlanInfoServices.QueryAsync(d=>d.ProductLineCode.Equals("1001")); + ExecutePlanInfo task=new ExecutePlanInfo(); + task.ExecutePlanCode = Guid.NewGuid().ToString(); + task.ProductPlanCode = plan_code; + task.OrderCode = order_code; + task.MaterialCode = material_code; + task.MaterialName = material_name; + task.ProductLineCode = "1001";//计划工位 + if (list.Count == 0) + task.ExecuteOrder = 1; + if (list.Count != 0) + task.ExecuteOrder = list.Max(d => d.ExecuteOrder) + 1; + + task.ExecuteMethod = 1;//不做要求,系统自动确定 + task.ExecuteStatus = 1; + task.PlanAmount = SelectedCells.SpliteResidueAmount; + task.CompleteAmount = 0; + task.CreatedTime = DateTime.Now; + var result = await _executePlanInfoServices.AddAsync(task); + if (result>0) + { + MessageBox.Show("计划拆分成功!","系统提醒"); + WeakReferenceMessenger.Default.Send("Refresh");//刷新窗口 + CloseWindow(); + } + else + { + MessageBox.Show("计划拆分失败,请检查后重试!", "系统提醒"); + } + } + #endregion + + #region 获取当前行数据 赋值到textbox + private ProductPlanInfoModel selectedCells; + public ProductPlanInfoModel SelectedCells + { + get { return selectedCells; } + set + { + selectedCells = value; + SetProperty(ref selectedCells, value); + } + } + #endregion + + #region 关闭当前窗口 + /// + /// 关闭当前窗口 + /// + public void CloseWindow() + { + WeakReferenceMessenger.Default.Send("close"); + } + #endregion + + #region 参数定义 + private string _objId = string.Empty; + public string ObjId + { + get => _objId; + set => SetProperty(ref _objId, value); + } + + private string _search = string.Empty; + public string Search + { + get => _search; + set => SetProperty(ref _search, value); + } + /// + /// 下拉框 + /// + public string _materialTypeCombox; + public string MaterialTypeCombox + { + get => _materialTypeCombox; + set => SetProperty(ref _materialTypeCombox, value); + } + + #region 多选按钮 + /// + /// 多选按钮 + /// + public int _radioButtonStatus; + public int RadioButtonStatus + { + get => _radioButtonStatus; + set => SetProperty(ref _radioButtonStatus, value); + } + #endregion + + private ObservableCollection _configurations = new ObservableCollection(); + public ObservableCollection Configurations + { + get => _configurations; + set => SetProperty(ref _configurations, value); + } + + private ProductPlanInfoModel selectedDataItem; + public ProductPlanInfoModel SelectedDataItem + { + get => selectedDataItem; + set => SetProperty(ref selectedDataItem, value); + } + #endregion + + #region 重置 + /// + /// 重置 + /// + [RelayCommand] + public void Reset() + { + LoadData(); + + Search = string.Empty; + MaterialTypeCombox = string.Empty; + this.LoadData(); + } + #endregion + + #region 搜索条件设置 + /// + /// 搜索条件设置 + /// + [RelayCommand] + public async Task SearchCriteriaSet() + { + SearchCriteriaView searchCriteriaWindow = new SearchCriteriaView(); + bool? dialogResult = searchCriteriaWindow.ShowDialog(); + if (dialogResult == false) // 用户点击了“取消”按钮或关闭窗口 + { + await LoadData(); + } + } + #endregion + + #region 查询快捷查询方式 + + private void SaveSearchCriteria(object recipient, string message) + { + if (message== "RefreshSearchItems") + { + Configurations = new ObservableCollection(); + var searchItems = appConfig.searchItems; + var split = searchItems.Split('%'); + + foreach (var item in split) + { + if (!string.IsNullOrEmpty(item)) + { + Configurations.Add(item); + } + } + } + + } + private void SaveSearchCriteria() + { + Configurations = new ObservableCollection(); + var searchItems = appConfig.searchItems; + var split = searchItems.Split('%'); + + foreach (var item in split) + { + if (!string.IsNullOrEmpty(item)) + { + Configurations.Add(item); + } + } + } + #endregion + + #region 双击事件 + public void MouseClick(object obj) + { + var info = SelectedDataItem as ProductPlanInfoModel; + if (info != null) + { + info.PlanType = _radioButtonStatus; + QuantityIssuedView quantityIssuedWindow = new QuantityIssuedView(info, ObjId); + quantityIssuedWindow.ShowDialog(); + } + + } + + /// + /// 鼠标双击事件 + /// + [RelayCommand] + public void DoubleMouseClick() + { + MessageBox.Show("双击事件"); + } + #endregion + + #region 快捷查询 + /// + /// 快捷查询 + /// + /// + /// + [RelayCommand] + public async Task RadioButton(string selectedOption) + { + string productLineCode = Appsettings.app("StoreInfo", "ProductLineCode"); + List planInfos = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(productLineCode) && d.MaterialName.Contains(selectedOption)); + if (planInfos != null) + { + if (planInfos.Count > 0) + { + MaterialDataGrid.Clear(); + int i = 1; + + var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(productLineCode)); + foreach (var item in planInfos) + { + int residue = 0; + if (execList == null) + { + residue = 0; + } + else + { + residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount); + } + + MaterialDataGrid.Add(new ProductPlanInfoModel() + { + No = i, + PlanCode = item.PlanCode, + MaterialCode = item.MaterialCode, + MaterialName = item.MaterialName, + OrderCode = item.OrderCode, + PlanAmount = item.PlanAmount, + ResidueAmount = item.PlanAmount - item.CompleteAmount, + SpliteResidueAmount = item.PlanAmount - residue, + StartDate = item.BeginTime + }); + i++; + } + } + } + } + + #endregion + + #region 按钮 + /// + /// 按钮 + /// + /// + [RelayCommand] + public void UpdateRadioButtonStatus(string status) + { + if (status== "status1") + { + _radioButtonStatus = 1; + } + if (status == "status2") + { + _radioButtonStatus = 2; + } + if (status == "status3") + { + _radioButtonStatus = 3; + } + } + #endregion + } +} diff --git a/Aucma.Core.OldBoxFoam/Views/FoamPlanPageView.xaml b/Aucma.Core.OldBoxFoam/Views/FoamPlanPageView.xaml new file mode 100644 index 00000000..fc8058b6 --- /dev/null +++ b/Aucma.Core.OldBoxFoam/Views/FoamPlanPageView.xaml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +