From 901f4a62b5163f0a180f9d480c77ff55f88c5195 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 19 Apr 2024 14:48:34 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=B8=80=E7=BA=BF=E4=B8=8B=E7=BA=BFAB?= =?UTF-8?q?=E5=BA=93=E5=88=87=E6=8D=A2=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/offLineBusiness.cs | 6 +- .../ViewModels/QualityPageViewModel.cs | 73 +++++++++++++------ .../Views/QualityPageView.xaml | 2 +- Aucma.Core.ProductOffLine/appsettings.json | 8 +- 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index 02b519b4..f8a338a6 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -386,11 +386,7 @@ namespace Aucma.Core.ProductOffLine.Business bool plcResult = false; // 先查询分垛方向A或者B string direction = getDirectioneEvent?.Invoke(materialType); - if (direction == "") - { - //未设置方向处理,默认去A - direction = "A"; - } + plcResult = DownLoadPassFlag(ScannerNo, direction); //下发plc放行信号,分垛AB库 return plcResult; } diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs index 758189a3..9991528e 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs @@ -56,8 +56,22 @@ namespace Aucma.Core.ProductOffLine.ViewModels // 初始化界面分垛模式及分垛方向 private void DirectionInit() { - + #region 分垛模式 + if (appConfig.SelectedMaterialType == "1") + { + SelectedMaterialType = "手动模式"; + } + else if (appConfig.SelectedMaterialType == "2") + { + SelectedMaterialType = "自动模式"; + } + else + { + SelectedMaterialType = "手动模式"; + appConfig.SelectedMaterialType = "1"; + } + #endregion #region 默认方向 if (appConfig.PalletizDirection == "1") @@ -85,26 +99,28 @@ namespace Aucma.Core.ProductOffLine.ViewModels /// public String getInstoreDirection(string materialType) { + // 二线默认A库,一线默认B库 + string direction = "A"; - string direction = string.Empty; - Application.Current.Dispatcher.Invoke(() => + // 自动模式模式 + if (appConfig.SelectedMaterialType == "2") { - // 设置了入库自动模式模式 - if (SelectedMaterialType != null && SelectedMaterialType.Content.ToString() == "自动模式") + BaseMaterialInfo info = _baseMaterialInfoServices.Query(x => x.MaterialCode == materialType).FirstOrDefault(); + if (info != null && !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向 { - BaseMaterialInfo info = _baseMaterialInfoServices.Query(x => x.MaterialCode == materialType).FirstOrDefault(); - if (info != null && !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向 - { - direction = info.InboundDirection; - } - + direction = info.InboundDirection; } - else // 设置手动模式 + else // 自动模式未设置方向,按照手动模式走 { - if (IsSelectedOptionA == true) direction = "A"; - if (IsSelectedOptionB == true) direction = "B"; + direction = appConfig.PalletizDirection == "1" ? "A" : "B"; } - }); + + } + else // 设置手动模式 + { + direction = appConfig.PalletizDirection == "1" ? "A" : "B"; + } + return direction; } @@ -139,7 +155,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels public async void init() { await _baseQualityInspectionItemInfoServices.query(); - + } List materialComplateInfos = new List(); @@ -150,14 +166,26 @@ namespace Aucma.Core.ProductOffLine.ViewModels /// 分垛模式(自动模式,手动模式)SelectedMaterialType.content.tostring() /// /// private string _selectedMaterialType; - private ComboBoxItem _selectedMaterialType; - public ComboBoxItem SelectedMaterialType + private string _selectedMaterialType; + public string SelectedMaterialType { get { return _selectedMaterialType; } set { if (_selectedMaterialType != value) { + if (value == "手动模式") + { + appConfig.SelectedMaterialType = "1"; + } + else if (value == "自动模式") + { + appConfig.SelectedMaterialType = "2"; + } + else + { + appConfig.SelectedMaterialType = "1"; + } _selectedMaterialType = value; OnPropertyChanged(nameof(SelectedMaterialType)); } @@ -180,7 +208,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels if (result == MessageBoxResult.Yes) { var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); - // obj = null; + // obj = null; if (obj != null) { bool flag = obj.plc.ReadBool("B100A"); @@ -194,7 +222,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels { IsSelectedOptionB = false; } - MessageBox.Show("切换成功"); + } else { @@ -227,10 +255,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels if (value) { var result = MessageBox.Show("确认切换B方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.Yes) { var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); - // obj = null; + // obj = null; if (obj != null) { bool flag = obj.plc.ReadBool("B100A"); @@ -245,7 +274,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels { IsSelectedOptionA = false; } - MessageBox.Show("切换成功"); + } else { diff --git a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml index ecb2004f..339afe52 100644 --- a/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/QualityPageView.xaml @@ -70,7 +70,7 @@ - + diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json index 23da4e30..dde05e67 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 } ],