From 90856101128f4b9e9fc7461d84c2621ce2bd7675 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 19 Apr 2024 12:24:53 +0800 Subject: [PATCH] =?UTF-8?q?change-AB=E5=85=A5=E5=BA=93=E6=96=B9=E5=90=91?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=9C=80=E8=A6=81=E5=88=A4=E6=96=ADplc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/offLineBusiness.cs | 3 +- Aucma.Core.ProductOffLine/Config/AppConfig.cs | 21 +- .../ViewModels/QualityPageViewModel.cs | 239 +++++++++++++++--- .../Views/QualityPageView.xaml | 6 +- .../Views/QualityPageView.xaml.cs | 13 +- Aucma.Core.ProductOffLine/appsettings.json | 8 +- 6 files changed, 249 insertions(+), 41 deletions(-) diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index d358e2ce..02b519b4 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -132,7 +132,7 @@ namespace Aucma.Core.ProductOffLine.Business HandSendPlcWindow.SendPlcPassEvent += DownLoadPassFlag; TouchSocketService.ReceiveCodeDelegateEvent += ReceiveAndConsumption; TouchSocketService.NoReadReceiveEvent += NoRead; - + } #region 变量定义 /// @@ -143,6 +143,7 @@ namespace Aucma.Core.ProductOffLine.Business #endregion + /// /// TCP接收NoRead提醒 /// diff --git a/Aucma.Core.ProductOffLine/Config/AppConfig.cs b/Aucma.Core.ProductOffLine/Config/AppConfig.cs index 8d3c988b..5c3a0882 100644 --- a/Aucma.Core.ProductOffLine/Config/AppConfig.cs +++ b/Aucma.Core.ProductOffLine/Config/AppConfig.cs @@ -80,6 +80,25 @@ namespace Aucma.Core.ProductOffLine.Config set { iniHelper.IniWriteValue("system", "PassWord", value); } } - + /// + ///分垛模式,1手动,2自动,默认手动 + /// + public string SelectedMaterialType + { + get { return iniHelper.IniReadValue("system", "SelectedMaterialType"); } + set { iniHelper.IniWriteValue("system", "SelectedMaterialType", value); } + } + + + /// + ///去往分垛库方向,A库为1,B库为2,老线默认B库2,新线默认A库1 + /// + public string PalletizDirection + { + get { return iniHelper.IniReadValue("system", "PalletizDirection"); } + set { iniHelper.IniWriteValue("system", "PalletizDirection", value); } + } + + } } diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs index b0de67a9..758189a3 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs @@ -1,7 +1,9 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Service; +using Aucma.Core.HwPLc; using Aucma.Core.ProductOffLine.Business; +using Aucma.Core.ProductOffLine.Config; using Aucma.Core.ProductOffLine.Models; using Aucma.Core.ProductOffLine.Views; using CommunityToolkit.Mvvm.ComponentModel; @@ -31,20 +33,50 @@ namespace Aucma.Core.ProductOffLine.ViewModels private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; OffLineBusiness offLineBusiness = OffLineBusiness.Instance; private IndexPageView firstPage = new IndexPageView();//首页 + private AppConfig appConfig = AppConfig.Instance; private DirectionEditView directionEditView = new DirectionEditView(); - private SelectQualityView selectQualityView = new SelectQualityView(); + private SelectQualityView selectQualityView = new SelectQualityView(); public QualityPageViewModel() { UserContent1 = directionEditView; UserContent2 = selectQualityView; + DirectionInit(); + + // 传入库方向 offLineBusiness.getDirectioneEvent += getInstoreDirection; QualityPageView.getAllQualityEvent += test; _baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService(); _baseMaterialInfoServices = App.ServiceProvider.GetService(); - + init(); - + + } + + // 初始化界面分垛模式及分垛方向 + private void DirectionInit() + { + + + + #region 默认方向 + if (appConfig.PalletizDirection == "1") + { + _isSelectedOptionA = true; + _isSelectedOptionB = false; + } + else if (appConfig.PalletizDirection == "2") + { + _isSelectedOptionA = false; + _isSelectedOptionB = true; + } + else + { + _isSelectedOptionA = true; + _isSelectedOptionB = true; + appConfig.PalletizDirection = "1"; + } + #endregion } /// @@ -61,7 +93,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels if (SelectedMaterialType != null && SelectedMaterialType.Content.ToString() == "自动模式") { BaseMaterialInfo info = _baseMaterialInfoServices.Query(x => x.MaterialCode == materialType).FirstOrDefault(); - if (info != null&& !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向 + if (info != null && !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向 { direction = info.InboundDirection; } @@ -100,19 +132,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels public async Task> test() { List list = await _baseQualityInspectionItemInfoServices.query(); - + return list; } public async void init() { await _baseQualityInspectionItemInfoServices.query(); - //Task.Run(() => - //{ - // Thread.Sleep(5000); - // string A = getInstoreDirection("9001001802"); - // Console.WriteLine(A); - //}); + } List materialComplateInfos = new List(); @@ -136,24 +163,57 @@ namespace Aucma.Core.ProductOffLine.ViewModels } } } - #region 单选框 + + + + private bool _isSelectedOptionA; public bool IsSelectedOptionA { get { return _isSelectedOptionA; } set { - if (_isSelectedOptionA != value) - { - _isSelectedOptionA = value; - OnPropertyChanged(nameof(IsSelectedOptionA)); - // 如果选择了A选项,将B选项设为false - if (_isSelectedOptionA) + if (value) + { + var result = MessageBox.Show("确认切换A库方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.Yes) { - IsSelectedOptionB = false; + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + // obj = null; + if (obj != null) + { + bool flag = obj.plc.ReadBool("B100A"); + if (flag) + { + _isSelectedOptionA = value; + OnPropertyChanged(nameof(IsSelectedOptionA)); + appConfig.PalletizDirection = "1"; + // 如果选择了A选项,将B选项设为false + if (_isSelectedOptionA) + { + IsSelectedOptionB = false; + } + MessageBox.Show("切换成功"); + } + else + { + MessageBox.Show("切换失败,请检查提升机及二楼平台是否残留箱体或数据!"); + } + } + else + { + MessageBox.Show("Plc连接失败,请检查连接!"); + } } } + else + { + _isSelectedOptionA = value; + OnPropertyChanged(nameof(IsSelectedOptionA)); + } + + } } @@ -163,22 +223,143 @@ namespace Aucma.Core.ProductOffLine.ViewModels get { return _isSelectedOptionB; } set { - if (_isSelectedOptionB != value) - { - _isSelectedOptionB = value; - OnPropertyChanged(nameof(IsSelectedOptionB)); - // 如果选择了B选项,将A选项设为false - if (_isSelectedOptionB) + if (value) + { + var result = MessageBox.Show("确认切换B方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.Yes) { - IsSelectedOptionA = false; + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + // obj = null; + if (obj != null) + { + bool flag = obj.plc.ReadBool("B100A"); + if (flag) + { + + _isSelectedOptionB = value; + OnPropertyChanged(nameof(IsSelectedOptionB)); + appConfig.PalletizDirection = "2"; + // 如果选择了B选项,将A选项设为false + if (_isSelectedOptionB) + { + IsSelectedOptionA = false; + } + MessageBox.Show("切换成功"); + } + else + { + MessageBox.Show("切换失败,请检查提升机及二楼平台是否残留箱体或数据!"); + } + } + else + { + MessageBox.Show("Plc连接失败,请检查连接!"); + } } } + else + { + _isSelectedOptionB = value; + OnPropertyChanged(nameof(IsSelectedOptionB)); + } + + } } - #endregion - + + //#region 单选框 + //private bool _isSelectedOptionA; + //public bool IsSelectedOptionA + //{ + // get { return _isSelectedOptionA; } + // set + // { + // if (_isSelectedOptionA != value) + // { + // MessageBoxResult result = MessageBox.Show("确认切换方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); + // if (result == MessageBoxResult.Yes) + // { + // // 读取plc点位判断能否切换 + // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + // if (obj != null) + // { + // bool flag = obj.plc.ReadBool("B100A"); + // if (flag) + // { + // _isSelectedOptionA = value; + // OnPropertyChanged(nameof(IsSelectedOptionA)); + + // // 如果选择了A选项,将B选项设为false + // if (_isSelectedOptionA) + // { + // IsSelectedOptionB = false; + // } + // } + // else + // { + // MessageBox.Show("请检查提升机及二楼平台是否残留箱体或数据!"); + // } + + // } + // else + // { + // MessageBox.Show("Plc连接失败,请检查连接!"); + // } + + // } + + // } + // } + //} + + //private bool _isSelectedOptionB; + //public bool IsSelectedOptionB + //{ + // get { return _isSelectedOptionB; } + // set + // { + // if (_isSelectedOptionB != value) + // { + // MessageBoxResult result = MessageBox.Show("确认切换方向吗?","确认", MessageBoxButton.YesNo, MessageBoxImage.Question); + // if (result == MessageBoxResult.Yes) + // { + // // 读取plc点位判断能否切换 + + // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + // if (obj != null) + // { + // bool flag = obj.plc.ReadBool("B100A"); + // if (flag) + // { + // _isSelectedOptionB = value; + // OnPropertyChanged(nameof(IsSelectedOptionB)); + + // // 如果选择了B选项,将A选项设为false + // if (_isSelectedOptionB) + // { + // IsSelectedOptionA = false; + // } + // } + // else + // { + // MessageBox.Show("请检查提升机及二楼平台是否残留箱体或数据!"); + // } + // } + // else + // { + // MessageBox.Show("Plc连接失败,请检查连接!"); + // } + + // } + + // } + // } + //} + //#endregion + + #endregion @@ -190,7 +371,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels [RelayCommand] private void ExecQuery(object obj) { - + } #endregion } diff --git a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml index b565b541..ecb2004f 100644 --- a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml @@ -70,12 +70,12 @@ - - + + - + diff --git a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml.cs b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml.cs index ff0d9a18..3e1b3743 100644 --- a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml.cs +++ b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml.cs @@ -1,6 +1,7 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Service; +using Aucma.Core.ProductOffLine.Config; using Aucma.Core.ProductOffLine.ViewModels; using Microsoft.Extensions.DependencyInjection; using System; @@ -27,17 +28,23 @@ namespace Aucma.Core.ProductOffLine.Views { public delegate Task> getAllQuality(); public static event getAllQuality getAllQualityEvent; - + private AppConfig appConfig = AppConfig.Instance; public QualityPageView() { InitializeComponent(); + + QualityPageViewModel viewmodel = new QualityPageViewModel(); this.DataContext = viewmodel; - + + + + } - + + } } diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json index 79d9eee6..23da4e30 100644 --- a/Aucma.Core.ProductOffLine/appsettings.json +++ b/Aucma.Core.ProductOffLine/appsettings.json @@ -229,10 +229,10 @@ "EquipName": "成品下线Plc", "PlcType": "Melsec", "Enabled": true, - //"IP": "127.0.0.1", - //"Port": 6000 - "IP": "10.10.92.70", - "Port": 2015 + "IP": "127.0.0.1", + "Port": 6000 + //"IP": "10.10.92.70", + // "Port": 2015 } ],