From e711d124c4212c8659ff5c38fa79a2e3c59bc381 Mon Sep 17 00:00:00 2001 From: liuwf Date: Thu, 25 Jan 2024 17:28:47 +0800 Subject: [PATCH] =?UTF-8?q?change-MvCodeHelper=E4=BF=AE=E5=A4=8D=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E5=99=A8=E5=88=9D=E5=A7=8B=E5=8C=96=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=89=AB=E7=A0=81=E5=99=A8=20change=20-=20?= =?UTF-8?q?=E6=89=80=E6=9C=89appsetting=E6=96=87=E4=BB=B6=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E5=99=A8=E9=85=8D=E7=BD=AE=E6=8F=90=E5=8F=96=20change?= =?UTF-8?q?=20-=20=E5=90=88=E5=B9=B6=E6=9D=A1=E7=A0=81=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E6=9D=A1=E7=A0=81=E9=80=BB=E8=BE=91=20add=20?= =?UTF-8?q?-=20=E5=88=86=E5=9E=9B=E4=B8=8A=E4=BD=8D=E6=9C=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B4=A7=E9=81=93=E7=95=8C=E9=9D=A2=EF=BC=8C=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E4=B8=9A=E5=8A=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Model/Model_New/BaseSpaceInfo.cs | 19 +- .../ViewModels/BeforeFoamingPageModelView.cs | 1 + Aucma.Core.BoxFoam/appsettings.json | 9 +- .../ViewModels/IndexPageViewModel.cs | 70 +-- Aucma.Core.CodeBinding/appsettings.json | 22 +- Aucma.Core.DoorFoam/appsettings.json | 9 +- .../Aucma.Core.Palletiz.csproj | 6 + .../Aucma.Core.Palletiz.csproj.user | 6 + .../Business/InstoreBusiness.cs | 48 ++ Aucma.Core.Palletiz/Models/SpaceModel.cs | 46 ++ .../ViewModels/IndexPageViewModel.cs | 21 +- .../ViewModels/PalletizPageViewModel.cs | 62 ++- .../ViewModels/SelectTypeViewModel.cs | 415 ++++++++++++++++++ .../Views/HandPalletizWindow.xaml | 86 ++++ .../Views/HandPalletizWindow.xaml.cs | 187 ++++++++ Aucma.Core.Palletiz/Views/IndexPageView.xaml | 4 + .../Views/PalletizPageView.xaml | 35 +- .../Views/PalletizPageView.xaml.cs | 9 +- Aucma.Core.Palletiz/Views/SelectType.xaml | 248 +++++++++++ Aucma.Core.Palletiz/Views/SelectType.xaml.cs | 48 ++ Aucma.Core.Palletiz/appsettings.json | 48 +- .../Business/offLineBusiness.cs | 8 +- Aucma.Core.ProductOffLine/appsettings.json | 16 +- Aucma.Core.Scanner/Aucma.Core.Scanner.csproj | 1 + Aucma.Core.Scanner/Helper/MvCodeHelper.cs | 67 +-- Aucma.Core.Scanner/ScannerModel.cs | 27 ++ 26 files changed, 1385 insertions(+), 133 deletions(-) create mode 100644 Aucma.Core.Palletiz/Business/InstoreBusiness.cs create mode 100644 Aucma.Core.Palletiz/Models/SpaceModel.cs create mode 100644 Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs create mode 100644 Aucma.Core.Palletiz/Views/HandPalletizWindow.xaml create mode 100644 Aucma.Core.Palletiz/Views/HandPalletizWindow.xaml.cs create mode 100644 Aucma.Core.Palletiz/Views/SelectType.xaml create mode 100644 Aucma.Core.Palletiz/Views/SelectType.xaml.cs create mode 100644 Aucma.Core.Scanner/ScannerModel.cs diff --git a/Admin.Core.Model/Model_New/BaseSpaceInfo.cs b/Admin.Core.Model/Model_New/BaseSpaceInfo.cs index 908966e6..d196dd2d 100644 --- a/Admin.Core.Model/Model_New/BaseSpaceInfo.cs +++ b/Admin.Core.Model/Model_New/BaseSpaceInfo.cs @@ -87,7 +87,9 @@ namespace Admin.Core.Model /// [SugarColumn(ColumnName = "MATERIAL_TYPE")] public string MaterialType { get; set; } - + /// + /// 夹具箱型 + /// [SugarColumn(ColumnName ="BOXTYPE")] public string BoxType { get; set; } @@ -146,5 +148,20 @@ namespace Admin.Core.Model [SugarColumn(ColumnName = "TYPE_NAME_C")] public string typeNameC { get; set; } + /// + ///分垛使用字段,箱体入库旋转角度(90,180,270) + /// + [SugarColumn(ColumnName = "ROTATION_RANGE")] + public int RotationRange { get; set; } + /// + /// 分垛使用字段,是否大产品占两个货道,1-是;0-否 + /// + [SugarColumn(ColumnName = "IS_TWO_SPACE")] + public int IsTwoSpace { get; set; } + /// + /// 分垛使用字段,记录同型号上次入的货道,如FD01_002 + /// + [SugarColumn(ColumnName = "LAST_SPACE")] + public string LastSpace { get; set; } } } diff --git a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs index d4c92f46..d53a8e9e 100644 --- a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs +++ b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs @@ -97,6 +97,7 @@ namespace Aucma.Core.BoxFoam.ViewModels string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode==storeCode).Result;//仓库 + if (baseSpaceInfolist == null) return; Shapes.Clear(); diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 2a51672d..17b2dabd 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -190,12 +190,15 @@ }, "Scanner": { //扫码器 "Enabled": true - }, - "Scanner1": { //扫码器1 + } + }, + "ScannerServer": [ + { + "Id": 1, "Ip": "10.10.93.46", "Name": "扫码器1" } - }, + ], "PLCServer": [ { "Id": 1, diff --git a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs index 7ccdb350..96eb5ac6 100644 --- a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs @@ -35,6 +35,7 @@ using Microsoft.IdentityModel.Logging; using static Npgsql.Replication.PgOutput.Messages.RelationMessage; using Aucma.Core.HwPLc; using System.Windows.Documents; +using Admin.Core.Common; /* * 首页信息 */ @@ -55,8 +56,9 @@ namespace Aucma.Core.CodeBinding.ViewModels // 静态变量存code2 private static string code2Str = string.Empty; + //配置文件扫码器列表 + private readonly List allScanners = Appsettings.app("ScannerServer").ToList(); - public IndexPageViewModel() { try @@ -67,28 +69,27 @@ namespace Aucma.Core.CodeBinding.ViewModels _printBarCodeServices = App.ServiceProvider.GetService(); _iMaterialCompletionServices = App.ServiceProvider.GetService(); - MvCodeHelper.ReceiveCode1Event += receiveCode1; - MvCodeHelper.ReceiveCode2Event += receiveCode2; - + MvCodeHelper.BindingReceiveCodeEvent += receiveCode; + LoadData(); add(); //实时绑定条码和实时下发plc放行信号 realBindingAndSendPlc(); LoadCharts(); - Task.Run(() => - { - while (true) - { + //Task.Run(() => + //{ + // while (true) + // { - Random result = new Random(); - Thread.Sleep(20000); - receiveCode1("B24010181060282920"+ result.Next(100,999)); - Thread.Sleep(1000); - receiveCode2("16160030000000910"+ result.Next(100, 999)); - } + // Random result = new Random(); + // Thread.Sleep(20000); + // receiveCode1("B24010181060282920"+ result.Next(100,999)); + // Thread.Sleep(1000); + // receiveCode2("16160030000000910"+ result.Next(100, 999)); + // } - }); + //}); } catch (Exception ex) @@ -373,13 +374,31 @@ namespace Aucma.Core.CodeBinding.ViewModels - - private async void receiveCode1(string code1) + /// + /// 接收扫码器传输的条码,扫码器ip + /// + /// + /// + private async void receiveCode(string code1,string scannerIp) { - log.Info("扫描到MES条码:" + code1); - // 全局变量赋值,SN码扫描后使用 - code1Str = code1; - RefreshCode1(code1); + + ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp); + if(model.Id==1) + { + log.Info("扫描到MES条码:" + code1); + // 全局变量赋值,SN码扫描后使用 + code1Str = code1; + RefreshCode1(code1); + } + else + { + log.Info("扫描到成品条码:" + code1); + // 1.刷新界面条码信息 + // 全局变量赋值,mes条码扫描后使用 + code2Str = code2; + RefreshCode2(code2); + } + #region // 2.创建任务更新数据库条码1 // CodeBindingRecord codeRecord = new CodeBindingRecord(); @@ -400,15 +419,6 @@ namespace Aucma.Core.CodeBinding.ViewModels #endregion } - private async void receiveCode2(string code2) - { - log.Info("扫描到成品条码:" + code1); - // 1.刷新界面条码信息 - // 全局变量赋值,SN码扫描后使用 - code2Str = code2; - RefreshCode2(code2); - } - private void RefreshCode1(string code1) { diff --git a/Aucma.Core.CodeBinding/appsettings.json b/Aucma.Core.CodeBinding/appsettings.json index 93f51ffb..4f23e6ee 100644 --- a/Aucma.Core.CodeBinding/appsettings.json +++ b/Aucma.Core.CodeBinding/appsettings.json @@ -192,18 +192,22 @@ "Scanner": { //扫码器 "Enabled": true }, - "Scanner1": { //扫码器1 - "Ip": "169.254.91.169", - "Name": "扫码器1" - }, - "Scanner2": { //扫码器2 - "Ip": "192.168.1.20", - "Name": "扫码器2" - }, "ScannerGun": { //扫码枪 "Enabled": true } }, + "ScannerServer": [ + { + "Id": 1, + "Ip": "169.254.91.169", + "Name": "mes扫码器" + }, + { + "Id": 2, + "Ip": "192.168.1.20", + "Name": "sn扫码器" + } + ], "PLCServer": [ { "Id": 1, @@ -213,7 +217,7 @@ "IP": "127.0.0.1", "Port": 6000 } - + ], "IpRateLimiting": { "EnableEndpointRateLimiting": false, //False: globally executed, true: executed for each diff --git a/Aucma.Core.DoorFoam/appsettings.json b/Aucma.Core.DoorFoam/appsettings.json index ae220806..5e6a15c8 100644 --- a/Aucma.Core.DoorFoam/appsettings.json +++ b/Aucma.Core.DoorFoam/appsettings.json @@ -190,12 +190,15 @@ }, "Scanner": { //扫码器 "Enabled": false - }, - "Scanner1": { //扫码器1 + } + }, + "ScannerServer": [ + { + "Id": 1, "Ip": "192.168.1.19", "Name": "扫码器1" } - }, + ], "PLCServer": [ { "Id": 1, diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj index 3f3aff86..b37e4967 100644 --- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj +++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj @@ -78,6 +78,9 @@ + + Code + Code @@ -87,6 +90,9 @@ Code + + Code + Code diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user index 77bfa98d..3aa82189 100644 --- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user +++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user @@ -7,6 +7,9 @@ + + Designer + Designer @@ -22,6 +25,9 @@ Designer + + Designer + Designer diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs new file mode 100644 index 00000000..3a35be8e --- /dev/null +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -0,0 +1,48 @@ +using Admin.Core.Common; +using Aucma.Core.Scanner; +using log4net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.Palletiz.Business +{ + /// + ///分垛入库业务处理 + /// + public class InstoreBusiness + { + #region 单例实现 + private static readonly InstoreBusiness lazy = new InstoreBusiness(); + public static InstoreBusiness Instance + { + get + { + return lazy; + } + } + #endregion + + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(InstoreBusiness)); + + public void test() + { + + } + #region 扫码入库处理 + /// + /// + /// + /// 成品码 + /// 扫码器ip + /// + public async Task InStore(string SNCode,string scannerIp) + { + List allScanners = Appsettings.app("ScannerServer").ToList(); + ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp); + } + #endregion + } +} \ No newline at end of file diff --git a/Aucma.Core.Palletiz/Models/SpaceModel.cs b/Aucma.Core.Palletiz/Models/SpaceModel.cs new file mode 100644 index 00000000..0a30aa3c --- /dev/null +++ b/Aucma.Core.Palletiz/Models/SpaceModel.cs @@ -0,0 +1,46 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.Palletiz.Models +{ + /// + /// 货道模型 + /// + public class SpaceModel : ObservableObject + { + /// + /// 货道编号 + /// + public string SpaceCode { get; set; } + /// + /// 货道名称 + /// + public string? SpaceName { get; set; } + /// + /// 仓库编号 + /// + public string? StoreCode { get; set; } + /// + /// 产品编码 + /// + public string? MaterialType { get; set; } + /// + /// 产品名称 + /// + public string? typeNameA { get; set; } + /// + /// 转向角度 + /// + public int? RotationRange { get; set; } + /// + /// 是否占两道 + /// + public int? IsTwoSpace { get; set; } + + + } +} diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs index 11365412..c2dfebf1 100644 --- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs @@ -5,6 +5,8 @@ using LiveCharts.Wpf; using LiveCharts; using System.Collections.Generic; using System.Windows.Media; +using CommunityToolkit.Mvvm.Input; +using Aucma.Core.Palletiz.Views; /* * 成品分垛入库首页信息 @@ -22,8 +24,8 @@ namespace Aucma.Core.Palletiz.ViewModels //MaterialName = "SC-AUCMA-农夫山泉,SC"; //OrderNo = "8512365486"; //BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss"); - - InitEveryDayMethod(); + HandPalletizCommand = new RelayCommand(obj => HandPalletizCommandExecute()); + InitEveryDayMethod(); } #region 扫描信息 @@ -123,7 +125,20 @@ namespace Aucma.Core.Palletiz.ViewModels Achievement.Add(column2); } - + + + /// + /// 手动分垛 + /// + public RelayCommand HandPalletizCommand { get; set; } + + private void HandPalletizCommandExecute() + { + HandPalletizWindow handPalletizPage = new HandPalletizWindow(); + handPalletizPage.ShowDialog(); + + } + #region 日产量柱状图 /// diff --git a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs index 0af2b444..c0ee1154 100644 --- a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs @@ -1,17 +1,75 @@ -using Aucma.Core.Palletiz.Views; +using Admin.Core.IService; +using Admin.Core.Model; +using Aucma.Core.Palletiz.Models; +using Aucma.Core.Palletiz.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using log4net; +using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Aucma.Core.Palletiz.ViewModels { public partial class PalletizPageViewModel : ObservableObject { - public PalletizPageViewModel() { } + private static readonly log4net.ILog log = LogManager.GetLogger(typeof(PalletizPageViewModel)); + private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices; + + + public PalletizPageViewModel() { + _baseSpaceInfoServices = App.ServiceProvider.GetService(); + LoadDataGrid(); + SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; + } + public void LoadDataGrid() + { + Spaces.Clear(); + var spaceList = _baseSpaceInfoServices.Query(X => X.StoreCode.Contains("FDK")).OrderBy(x=>x.ObjId); + foreach(BaseSpaceInfo space in spaceList) + { + Spaces.Add(space); + } + + } + + #region 初始化 + private ObservableCollection _spaces = new ObservableCollection(); + public ObservableCollection Spaces + { + get => _spaces; + set => SetProperty(ref _spaces, value); + } + #endregion + + + public void MouseClick(object obj) + { + + var info = SelectedDataItem as BaseSpaceInfo; + if (info != null) + { + SelectType direct = new SelectType(info); + direct.ShowDialog(); + } + + } + + private BaseSpaceInfo selectedDataItem; + public BaseSpaceInfo SelectedDataItem + { + get { return selectedDataItem; } + set + { + selectedDataItem = value; + OnPropertyChanged(); + } + } [RelayCommand] public void AddStore() diff --git a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs new file mode 100644 index 00000000..866b3f9b --- /dev/null +++ b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs @@ -0,0 +1,415 @@ +using Admin.Core.Common; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +using Aucma.Core.Palletiz.Common; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; +using log4net; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Logging; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Aucma.Core.Palletiz.ViewModels +{ + public partial class SelectTypeViewModel : ObservableObject + { + + /// + /// 委托,关闭窗口 + /// + /// + public delegate void close(); + public event close closeEvent; + + /// + /// 刷新货道页面 + /// + /// + public delegate void RefreshPage(); + public static event RefreshPage RefreshPageEvent; + + + public RelayCommand QueryCommand { get; set; } + public RelayCommand deleteCommand { get; set; } + public RelayCommand SaveCommand { get; set; } + + public RelayCommand SearchCriteriaSetCommand { get; set; } + + + + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices)); + + + private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; + + private readonly IBaseSpaceInfoServices _baseSpaceInfoServices; + + public RelayCommand MouseClickCommand { get; set; } + + private string spaceCodes = string.Empty; + private AppConfigHelper appConfig = new AppConfigHelper(); + + public SelectTypeViewModel() + { + + } + public SelectTypeViewModel(BaseSpaceInfo space) + { + _baseSpaceInfoServices = App.ServiceProvider.GetService(); + _baseMaterialInfoServices = App.ServiceProvider.GetService(); + SpaceInfo = space; + QueryCommand = new RelayCommand(searchData); + SaveCommand = new RelayCommand(updateDirection); + deleteCommand = new RelayCommand(deleteModel); + SearchCriteriaSetCommand = new RelayCommand(SearchCriteriaSet); + + MouseClickCommand = new RelayCommand(MouseClick); + materialDataGrid = new ObservableCollection(); + // SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria; + + //加载快捷方式 + SaveSearchCriteria(); + + Load(space); + + } + + private BaseSpaceInfo spaceInfo = new BaseSpaceInfo(); + public BaseSpaceInfo SpaceInfo + { + get { return spaceInfo; } + set => SetProperty(ref spaceInfo, value); + } + + + #region 快捷查询 + /// + /// 快捷查询 + /// + /// + /// + [RelayCommand] + public async Task RadioButton(string selectedOption) + { + string productLineCode = Appsettings.app("StationInfo", "StationCode"); + MaterialDataGrid.Clear(); + string station = Appsettings.app("StationInfo", "StationCode"); + if (!string.IsNullOrEmpty(selectedOption)) + { + var infos = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialSubclass == "200" && x.MaterialName.Contains(selectedOption)); + MaterialDataGrid.Clear(); + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo info in infos) + { + MaterialDataGrid.Add(info); + } + }); + } + + } + + #endregion + 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); + } + } + } + + //11 + public async void Load(BaseSpaceInfo space) + { + var infos = await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass== "200"); + MaterialDataGrid.Clear(); + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo info in infos) + { + MaterialDataGrid.Add(info); + } + }); + // 加载页面单选框和下拉框 + if (space != null) + { + if (space.IsTwoSpace == 1) + { + IsSelectedOptionA = true; + } + else + { + IsSelectedOptionB = true; + } + + planInfo.MaterialCode = space.MaterialType; + planInfo.MaterialName = space.typeNameA; + + if (SelectedRotation == null) + { + SelectedRotation = new ComboBoxItem { Content = "0" }; + } + + } + } + + private ObservableCollection materialDataGrid; + + public ObservableCollection MaterialDataGrid + { + get { return materialDataGrid; } + set => SetProperty(ref materialDataGrid, value); + } + //111 + private BaseMaterialInfo selectedDataItem; + public BaseMaterialInfo SelectedDataItem + { + get { return selectedDataItem; } + set => SetProperty(ref selectedDataItem, value); + + } + + // 111 + public void MouseClick(object obj) + { + + var info = SelectedDataItem; + if (info != null) + { + PlanInfo = info; + SpaceInfo.MaterialType = info.MaterialCode; + SpaceInfo.typeNameA = info.MaterialName; + } + } + /// + /// 单选框 + /// + private ComboBoxItem selectedRotation; + public ComboBoxItem SelectedRotation + { + get { return selectedRotation; } + set + { + + SetProperty(ref selectedRotation, value); + //selectedRotation = value; + //set => SetProperty(ref selectedRotation, value); + } + } + + private BaseMaterialInfo planInfo = new BaseMaterialInfo(); + public BaseMaterialInfo PlanInfo + { + get { return planInfo; } + set => SetProperty(ref planInfo, value); + } + private string searchText; + public string SearchText + { + get { return searchText; } + set => SetProperty(ref searchText, value); + } + + private ObservableCollection _configurations = new ObservableCollection(); + public ObservableCollection Configurations + { + get => _configurations; + set => SetProperty(ref _configurations, value); + } + + + /// + /// 搜索条件设置 + /// + public void SearchCriteriaSet() + { + // SearchCriteriaView searchCriteriaWindow = new SearchCriteriaView(); + // searchCriteriaWindow.ShowDialog(); + } + + + #region 单选框 + private bool _isSelectedOptionA; + public bool IsSelectedOptionA + { + get { return _isSelectedOptionA; } + set + { + if (_isSelectedOptionA != value) + { + _isSelectedOptionA = value; + OnPropertyChanged(nameof(IsSelectedOptionA)); + // 如果选择了A选项,将BC选项设为false + if (_isSelectedOptionA) + { + IsSelectedOptionB = false; + + } + } + } + } + + private bool _isSelectedOptionB; + public bool IsSelectedOptionB + { + get { return _isSelectedOptionB; } + set + { + if (_isSelectedOptionB != value) + { + _isSelectedOptionB = value; + OnPropertyChanged(nameof(IsSelectedOptionB)); + + // 如果选择了B选项,将A选项设为false + if (_isSelectedOptionB) + { + IsSelectedOptionA = false; + + } + } + } + } + + + #endregion + private async void deleteModel() + { + try + { + int tempIsTwoSpace = spaceInfo.IsTwoSpace; + spaceInfo.MaterialType = string.Empty; + spaceInfo.typeNameA = string.Empty; + spaceInfo.RotationRange = 0; + spaceInfo.IsTwoSpace = 0; + spaceInfo.LastSpace = string.Empty; + // 同步清除两条货道 + if (tempIsTwoSpace == 1) + { + updateOtherSpace(SpaceInfo); + } + + bool result = await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo); + if (result) + { + MessageBox.Show("清除型号成功!"); + } + //关闭窗口 + closeEvent?.Invoke(); + //刷新界面 + RefreshPageEvent?.Invoke(); + } + catch (Exception ex) + { + logHelper.Error(ex.Message.ToString()); + } + } + + /// + /// 给货道设置型号,转向角度等 + /// + private async void updateDirection() + { + try + { + // 转向角度 + + spaceInfo.RotationRange = int.Parse(SelectedRotation.Content.ToString()); + spaceInfo.IsTwoSpace = IsSelectedOptionA ? 1 : 0; + spaceInfo.LastSpace = string.Empty; + // 如果是大型号,将占据两条道,将两条道型号都设置为这个型号 + if (spaceInfo.IsTwoSpace == 1) + { + updateOtherSpace(spaceInfo); + } + + //if (!IsSelectedOptionA && !IsSelectedOptionB && !IsSelectedOptionC) + //{ + // MessageBox.Show("请至少选择一个型号!"); + // return; + //} + + bool result = _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo).Result; + if (result) + { + MessageBox.Show("型号设置成功"); + } + + //关闭窗口 + closeEvent?.Invoke(); + //刷新界面 + RefreshPageEvent?.Invoke(); + } + catch (Exception ex) + { + logHelper.Error(ex.Message.ToString()); + } + } + /// + /// 大产品占据两条货道,更新另一条货道 + /// + /// + private async void updateOtherSpace(BaseSpaceInfo spaceInfo) + { + // 找到当前货道匹配的另一条货道 + int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3)); + string otherSpaceCode = string.Empty; + if (num % 2 == 0) // 偶数,如7,8,当前8找7 + { + otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num - 1).ToString("D3"); + } + else + { + otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3"); + } + if (!string.IsNullOrEmpty(otherSpaceCode)) + { + BaseSpaceInfo otherSpace = _baseSpaceInfoServices.FirstAsync(x => x.SpaceCode.Equals(otherSpaceCode)).Result; + if (otherSpace == null) return; + otherSpace.MaterialType = spaceInfo.MaterialType; + otherSpace.typeNameA = spaceInfo.typeNameA; + otherSpace.RotationRange = spaceInfo.RotationRange; + otherSpace.IsTwoSpace = spaceInfo.IsTwoSpace; + otherSpace.LastSpace = spaceInfo.LastSpace; + _baseSpaceInfoServices.UpdateAsync(otherSpace); + } + } + /// + ///条件查询型号 + /// + private async void searchData() + { + if (!string.IsNullOrEmpty(searchText)) + { + var infos =await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass=="200" && (x.MaterialName.Contains(searchText) || x.MaterialCode.Contains(searchText))); + MaterialDataGrid.Clear(); + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo info in infos) + { + MaterialDataGrid.Add(info); + } + }); + } + else + { + Load(null); + } + } + } +} diff --git a/Aucma.Core.Palletiz/Views/HandPalletizWindow.xaml b/Aucma.Core.Palletiz/Views/HandPalletizWindow.xaml new file mode 100644 index 00000000..9616d87e --- /dev/null +++ b/Aucma.Core.Palletiz/Views/HandPalletizWindow.xaml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +