diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index 21d915a..d96cca2 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -192,10 +192,10 @@ namespace SlnMesnac.Business // 删除正在使用的数据库托盘号 - RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault(); - if (realPallet != null) + List realPalletList = _realPalletTaskService.Query(x => x.PalletCode == epcStr); + if (realPalletList != null && realPalletList.Count>0) { - sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand(); + sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPalletList).ExecuteCommand(); } // 写入PLC RFID号供调度使用 plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr,12); diff --git a/SlnMesnac.Config/DebugConfig.cs b/SlnMesnac.Config/DebugConfig.cs index 39c3fcc..d62e7f0 100644 --- a/SlnMesnac.Config/DebugConfig.cs +++ b/SlnMesnac.Config/DebugConfig.cs @@ -35,6 +35,15 @@ namespace SlnMesnac.Config set { iniHelper.IniWriteValue("system", "BufferWeight", value); } } + /// + ///2妤肩紦瀛樺尯鏈澶у仠鏈洪噸閲 + /// + public string MaxBufferWeight + { + get { return iniHelper.IniReadValue("system", "MaxBufferWeight"); } + set { iniHelper.IniWriteValue("system", "MaxBufferWeight", value); } + } + /// ///绯荤粺褰撳墠浣跨敤閰嶆柟妯$増 /// diff --git a/SlnMesnac.WPF/Model/RecipeManageCache.cs b/SlnMesnac.WPF/Model/RecipeManageCache.cs index fb558a7..adf0fb4 100644 --- a/SlnMesnac.WPF/Model/RecipeManageCache.cs +++ b/SlnMesnac.WPF/Model/RecipeManageCache.cs @@ -82,12 +82,24 @@ namespace SlnMesnac.WPF.Model /// - /// 褰撳墠鐩戞祴閲嶉噺 + /// 褰撳墠缂撳瓨鍖虹洃娴嬮噸閲 /// public double BufferWeight { get { return double.Parse(config.BufferWeight); } set { config.BufferWeight = value.ToString(); } } + + + /// + /// 2妤肩紦瀛樺尯鏈澶у仠鏈洪噸閲 + /// + public double MaxBufferWeight + { + get { return double.Parse(config.MaxBufferWeight); } + set { config.MaxBufferWeight = value.ToString(); } + } + + /// /// 褰撳墠浣跨敤妯$増鍚嶇О /// diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs index eb1c5b3..f1c111d 100644 --- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs +++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs @@ -151,12 +151,7 @@ namespace SlnMesnac.WPF.Page RefreshHot(machineStatusDtos); RefreshUnPack(machineStatusDtos); - App.Current.Dispatcher.BeginInvoke((Action)(() => - { - BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "鍖呰琚嬩綑閲").ConfigValue; - BufferWeightTxt.Text = recipeManageCache.BufferWeight.ToString("F2"); - })); - + RefreshWeight(); //寮鍏虫満鏃堕棿閲囬泦 machineStatusDtos.ForEach(x => OeeCollection(x)); @@ -182,6 +177,45 @@ namespace SlnMesnac.WPF.Page }); } + /// + /// 璁惧缂撳瓨鍖洪噸閲忕洃鍚強鍋滄満鎺у埗锛岀洃鍚寘瑁呰浣欓噺 + /// + private void RefreshWeight() + { + try + { + App.Current.Dispatcher.BeginInvoke((Action)(() => + { + BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "鍖呰琚嬩綑閲").ConfigValue; + BufferWeightTxt.Text = recipeManageCache.BufferWeight.ToString("F2"); + + })); + + // 鍒ゆ柇缂撳瓨鍖洪噸閲忔槸鍚﹁揪鍒拌瀹氭渶澶у硷紝濡傛灉杈惧埌骞朵笖璁惧寮鏈轰腑锛屽仠鏈 + double maxWeight = recipeManageCache.MaxBufferWeight; + double weight = recipeManageCache.BufferWeight; + bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("鎷嗗寘鏈虹郴缁熻繍琛岀姸鎬")); + if (unPackStatus && (maxWeight <= weight)) + { + // 鎵鏈夋満鍣ㄥ仠鏈 + Task.Run(() => + { + StopMachine(99); + MessageBox.Show($"璁惧缂撳瓨鍖哄綋鍓嶉噸閲:{weight},棰勮鏈澶ч噸閲忓:{maxWeight},宸茬粡瓒呴噸骞朵笖鎷嗗寘鏈鸿繍琛岋紝绯荤粺涓嬪彂鍋滄満鍛戒护!"); + _logger.LogError($"璁惧缂撳瓨鍖哄綋鍓嶉噸閲:{weight},棰勮鏈澶ч噸閲忓:{maxWeight},宸茬粡瓒呴噸骞朵笖鎷嗗寘鏈鸿繍琛岋紝绯荤粺涓嬪彂鍋滄満鍛戒护!"); + + }); + + Thread.Sleep(2000); + + } + }catch (Exception ex) + { + _logger.LogError($"RefreshWeight鍑虹幇寮傚父:{ex.Message}"); + } + + } + /// /// OEE璁惧鍏虫満閲囬泦 diff --git a/SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml b/SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml index fe678c4..55903fa 100644 --- a/SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml +++ b/SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml @@ -5,19 +5,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SlnMesnac.WPF.Page" mc:Ignorable="d" - Title="閲嶉噺璁剧疆" Height="300" Width="700" WindowStartupLocation="CenterScreen" Topmost="True" Background="Transparent"> + Title="閲嶉噺璁剧疆" Height="300" Width="700" WindowStartupLocation="CenterScreen" Topmost="True" Background="#73B0F5"> - - - public partial class InputDialogWindow : Window { + //绯荤粺棰戠巼閰嶆柟缂撳瓨 private RecipeManageCache recipeManageCache = RecipeManageCache.Instance; - + + public InputDialogWindow() { InitializeComponent(); + MaxWeightTxt.Text = recipeManageCache.MaxBufferWeight.ToString(); } + private void MaxWeightChangeButton_Click(object sender, RoutedEventArgs e) + { + bool flag = double.TryParse(MaxWeightTxt.Text,out double result); + if (flag) + { + recipeManageCache.MaxBufferWeight = result; + } + else + { + MessageBox.Show("璇疯緭鍏ュ悎鐞嗙殑閲嶉噺"); + } + } } }