change-MvCodeHelper修复扫码器初始化连接所有扫码器

change - 所有appsetting文件扫码器配置提取
change - 合并条码绑定接收条码逻辑
add - 分垛上位机配置货道界面,入库业务类
dev
liuwf 1 year ago
parent 7f173b2bed
commit e711d124c4

@ -87,7 +87,9 @@ namespace Admin.Core.Model
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_TYPE")]
public string MaterialType { get; set; }
/// <summary>
/// 夹具箱型
/// </summary>
[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; }
/// <summary>
///分垛使用字段,箱体入库旋转角度(90,180,270)
/// </summary>
[SugarColumn(ColumnName = "ROTATION_RANGE")]
public int RotationRange { get; set; }
/// <summary>
/// 分垛使用字段,是否大产品占两个货道1-是0-否
/// </summary>
[SugarColumn(ColumnName = "IS_TWO_SPACE")]
public int IsTwoSpace { get; set; }
/// <summary>
/// 分垛使用字段,记录同型号上次入的货道如FD01_002
/// </summary>
[SugarColumn(ColumnName = "LAST_SPACE")]
public string LastSpace { get; set; }
}
}

@ -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();

@ -190,12 +190,15 @@
},
"Scanner": { //
"Enabled": true
},
"Scanner1": { //1
}
},
"ScannerServer": [
{
"Id": 1,
"Ip": "10.10.93.46",
"Name": "扫码器1"
}
},
],
"PLCServer": [
{
"Id": 1,

@ -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<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
public IndexPageViewModel()
{
try
@ -67,28 +69,27 @@ namespace Aucma.Core.CodeBinding.ViewModels
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
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)
/// <summary>
/// 接收扫码器传输的条码扫码器ip
/// </summary>
/// <param name="code1"></param>
/// <param name="scannerIp"></param>
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)
{

@ -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

@ -190,12 +190,15 @@
},
"Scanner": { //
"Enabled": false
},
"Scanner1": { //1
}
},
"ScannerServer": [
{
"Id": 1,
"Ip": "192.168.1.19",
"Name": "扫码器1"
}
},
],
"PLCServer": [
{
"Id": 1,

@ -78,6 +78,9 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Views\HandPalletizWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\PalletizPageView.xaml.cs">
<SubType>Code</SubType>
</Compile>
@ -87,6 +90,9 @@
<Compile Update="Views\SearchCriteriaView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\SelectType.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\StatisticsPageView.xaml.cs">
<SubType>Code</SubType>
</Compile>

@ -7,6 +7,9 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Page Update="Views\HandPalletizWindow.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\PalletizPageView.xaml">
<SubType>Designer</SubType>
</Page>
@ -22,6 +25,9 @@
<Page Update="Views\SearchCriteriaView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\SelectType.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\SplitPlanView.xaml">
<SubType>Designer</SubType>
</Page>

@ -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
{
/// <summary>
///分垛入库业务处理
/// </summary>
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 扫码入库处理
/// <summary>
///
/// </summary>
/// <param name="SNCode">成品码</param>
/// <param name="scannerIp">扫码器ip</param>
/// <returns></returns>
public async Task InStore(string SNCode,string scannerIp)
{
List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
}
#endregion
}
}

@ -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
{
/// <summary>
/// 货道模型
/// </summary>
public class SpaceModel : ObservableObject
{
/// <summary>
/// 货道编号
/// </summary>
public string SpaceCode { get; set; }
/// <summary>
/// 货道名称
/// </summary>
public string? SpaceName { get; set; }
/// <summary>
/// 仓库编号
/// </summary>
public string? StoreCode { get; set; }
/// <summary>
/// 产品编码
/// </summary>
public string? MaterialType { get; set; }
/// <summary>
/// 产品名称
/// </summary>
public string? typeNameA { get; set; }
/// <summary>
/// 转向角度
/// </summary>
public int? RotationRange { get; set; }
/// <summary>
/// 是否占两道
/// </summary>
public int? IsTwoSpace { get; set; }
}
}

@ -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<string>(obj => HandPalletizCommandExecute());
InitEveryDayMethod();
}
#region 扫描信息
@ -123,7 +125,20 @@ namespace Aucma.Core.Palletiz.ViewModels
Achievement.Add(column2);
}
/// <summary>
/// 手动分垛
/// </summary>
public RelayCommand<string> HandPalletizCommand { get; set; }
private void HandPalletizCommandExecute()
{
HandPalletizWindow handPalletizPage = new HandPalletizWindow();
handPalletizPage.ShowDialog();
}
#region 日产量柱状图
/// <summary>

@ -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<IBaseSpaceInfoServices>();
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<BaseSpaceInfo> _spaces = new ObservableCollection<BaseSpaceInfo>();
public ObservableCollection<BaseSpaceInfo> 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()

@ -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
{
/// <summary>
/// 委托,关闭窗口
/// </summary>
/// <param name="message"></param>
public delegate void close();
public event close closeEvent;
/// <summary>
/// 刷新货道页面
/// </summary>
/// <param name="message"></param>
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<object> MouseClickCommand { get; set; }
private string spaceCodes = string.Empty;
private AppConfigHelper appConfig = new AppConfigHelper();
public SelectTypeViewModel()
{
}
public SelectTypeViewModel(BaseSpaceInfo space)
{
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
SpaceInfo = space;
QueryCommand = new RelayCommand(searchData);
SaveCommand = new RelayCommand(updateDirection);
deleteCommand = new RelayCommand(deleteModel);
SearchCriteriaSetCommand = new RelayCommand(SearchCriteriaSet);
MouseClickCommand = new RelayCommand<object>(MouseClick);
materialDataGrid = new ObservableCollection<BaseMaterialInfo>();
// SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria;
//加载快捷方式
SaveSearchCriteria();
Load(space);
}
private BaseSpaceInfo spaceInfo = new BaseSpaceInfo();
public BaseSpaceInfo SpaceInfo
{
get { return spaceInfo; }
set => SetProperty(ref spaceInfo, value);
}
#region 快捷查询
/// <summary>
/// 快捷查询
/// </summary>
/// <param name="selectedOption"></param>
/// <returns></returns>
[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<string>();
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<BaseMaterialInfo> materialDataGrid;
public ObservableCollection<BaseMaterialInfo> 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;
}
}
/// <summary>
/// 单选框
/// </summary>
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<string> _configurations = new ObservableCollection<string>();
public ObservableCollection<string> Configurations
{
get => _configurations;
set => SetProperty(ref _configurations, value);
}
/// <summary>
/// 搜索条件设置
/// </summary>
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());
}
}
/// <summary>
/// 给货道设置型号,转向角度等
/// </summary>
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());
}
}
/// <summary>
/// 大产品占据两条货道,更新另一条货道
/// </summary>
/// <param name="spaceInfo"></param>
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);
}
}
///<summary>
///条件查询型号
/// </summary>
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);
}
}
}
}

@ -0,0 +1,86 @@
<Window x:Class="Aucma.Core.Palletiz.Views.HandPalletizWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" WindowStartupLocation="CenterScreen" FontFamily="Microsoft YaHei"
Title="手动分垛" Height="600" Width="800" Name="window" Background="White"
ResizeMode="NoResize" Topmost="True">
<Border Margin="5" Background="#1254AB" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" >
<TextBlock Text="手动分垛" FontSize="25" Foreground="#FFFFFF" Margin="10,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="所属仓库:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,50,0" VerticalAlignment="Center" />
<Button x:Name="btn_A" Content="A 库" FontSize="20" Background="Lime" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Cursor="Hand" Click="btn_A_Click" >
</Button>
<Button x:Name="btn_B" Content="B 库" FontSize="20" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Margin="20" Click="btn_B_Click">
</Button>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="目的货道:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,50,0" VerticalAlignment="Center" />
<Button x:Name="btn_space1" Content="1" FontSize="18" Background="Lime" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="0 0 10 0" Click="btn_space1_Click">
</Button>
<Button x:Name="btn_space2" Content="2" FontSize="18" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="10" Click="btn_space2_Click">
</Button>
<Button x:Name="btn_space3" Content="3" FontSize="18" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="10" Click="btn_space3_Click">
</Button>
<Button x:Name="btn_space4" Content="4" FontSize="18" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="10" Click="btn_space4_Click">
</Button>
<Button x:Name="btn_space5" Content="5" FontSize="18" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="10" Click="btn_space5_Click">
</Button>
<Button x:Name="btn_space6" Content="6" FontSize="18" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="45" RenderTransformOrigin="0.5,0.5" Margin="10" Click="btn_space6_Click">
</Button>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="货道分流:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,50,0" VerticalAlignment="Center" />
<Button x:Name="btn_left" Content="左 道" FontSize="20" Background="Lime" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Click="btn_left_Click" >
</Button>
<Button x:Name="btn_right" Content="右 道" FontSize="20" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Margin="20" Click="btn_right_Click">
</Button>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="转向角度:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,50,0" VerticalAlignment="Center" />
<Button x:Name="btn_range90" Content="90度" FontSize="20" Background="Lime" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Click="btn_range90_Click" >
</Button>
<Button x:Name="btn_range180" Content="180度" FontSize="20" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Margin="20" Click="btn_range180_Click">
</Button>
<Button x:Name="btn_range270" Content="270度" FontSize="20" Background="DarkCyan" BorderBrush="#FF36B5C1" Foreground="white" Height="50" Width="103" RenderTransformOrigin="0.5,0.5" Click="btn_range270_Click" >
</Button>
</StackPanel>
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Content="保 存" FontSize="20" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="0,0,10,0" Height="50" Width="100" Click="Button_Click" />
<Button Content="取 消" FontSize="20" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=window}" Background="#FF9900" Foreground="white" Margin="10,0,0,0" Height="50" BorderBrush="#FF9900" Width="100" Click="Button_Click_1" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
</Window>

@ -0,0 +1,187 @@
using Admin.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Aucma.Core.Palletiz.Views
{
/// <summary>
/// DirectionItemWindow.xaml 的交互逻辑
/// </summary>
public partial class HandPalletizWindow : Window
{
private string store = "A";
private int space = 1;
/// <summary>
/// 货道分流
/// </summary>
private string spaceDirection = "左";
/// <summary>
/// 转向角度
/// </summary>
private int range = 90;
public HandPalletizWindow()
{
InitializeComponent();
}
#region 所属仓库选择
private void btn_A_Click(object sender, RoutedEventArgs e)
{
this.btn_A.Background = Brushes.Lime;
this.btn_B.Background = Brushes.DarkCyan;
store = "A";
}
private void btn_B_Click(object sender, RoutedEventArgs e)
{
this.btn_A.Background = Brushes.DarkCyan;
this.btn_B.Background = Brushes.Lime;
store = "B";
}
#endregion
#region 目的货道选择
private void btn_space1_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.Lime;
btn_space2.Background = Brushes.DarkCyan;
btn_space3.Background = Brushes.DarkCyan;
btn_space4.Background = Brushes.DarkCyan;
btn_space5.Background = Brushes.DarkCyan;
btn_space6.Background = Brushes.DarkCyan;
space = 1;
}
private void btn_space2_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.DarkCyan;
btn_space2.Background = Brushes.Lime;
btn_space3.Background = Brushes.DarkCyan;
btn_space4.Background = Brushes.DarkCyan;
btn_space5.Background = Brushes.DarkCyan;
btn_space6.Background = Brushes.DarkCyan;
space = 2;
}
private void btn_space3_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.DarkCyan;
btn_space2.Background = Brushes.DarkCyan;
btn_space3.Background = Brushes.Lime;
btn_space4.Background = Brushes.DarkCyan;
btn_space5.Background = Brushes.DarkCyan;
btn_space6.Background = Brushes.DarkCyan;
space = 3;
}
private void btn_space4_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.DarkCyan;
btn_space2.Background = Brushes.DarkCyan;
btn_space3.Background = Brushes.DarkCyan;
btn_space4.Background = Brushes.Lime;
btn_space5.Background = Brushes.DarkCyan;
btn_space6.Background = Brushes.DarkCyan;
space = 4;
}
private void btn_space5_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.DarkCyan;
btn_space2.Background = Brushes.DarkCyan;
btn_space3.Background = Brushes.DarkCyan;
btn_space4.Background = Brushes.DarkCyan;
btn_space5.Background = Brushes.Lime;
btn_space6.Background = Brushes.DarkCyan;
space = 5;
}
private void btn_space6_Click(object sender, RoutedEventArgs e)
{
btn_space1.Background = Brushes.DarkCyan;
btn_space2.Background = Brushes.DarkCyan;
btn_space3.Background = Brushes.DarkCyan;
btn_space4.Background = Brushes.DarkCyan;
btn_space5.Background = Brushes.DarkCyan;
btn_space6.Background = Brushes.Lime;
space = 6;
}
#endregion
#region 货道分流选择
private void btn_left_Click(object sender, RoutedEventArgs e)
{
btn_left.Background = Brushes.Lime;
btn_right.Background = Brushes.DarkCyan;
spaceDirection = "左";
}
private void btn_right_Click(object sender, RoutedEventArgs e)
{
btn_left.Background = Brushes.DarkCyan;
btn_right.Background = Brushes.Lime;
spaceDirection = "右";
}
#endregion
#region 转向角度设置Brushes.DarkCyan
private void btn_range90_Click(object sender, RoutedEventArgs e)
{
btn_range90.Background = Brushes.Lime;
btn_range180.Background = Brushes.DarkCyan;
btn_range270.Background = Brushes.DarkCyan;
range = 90;
}
private void btn_range180_Click(object sender, RoutedEventArgs e)
{
btn_range90.Background = Brushes.DarkCyan;
btn_range180.Background = Brushes.Lime;
btn_range270.Background = Brushes.DarkCyan;
range = 180;
}
private void btn_range270_Click(object sender, RoutedEventArgs e)
{
btn_range90.Background = Brushes.DarkCyan;
btn_range180.Background = Brushes.DarkCyan;
btn_range270.Background = Brushes.Lime;
range = 270;
}
#endregion
private void Button_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine(store);
Console.WriteLine(space);
Console.WriteLine(spaceDirection);
Console.WriteLine(range);
//下发plc分垛信号
return;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.window.Close();
}
}
}

@ -159,6 +159,10 @@
<Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="5">
<TextBlock Text="255" Foreground="White" FontSize="40" FontWeight="Bold"/>
</Border>
<Border Grid.Row="3" Grid.RowSpan="2" Grid.Column="5">
<Button Content="手动分垛" x:Name="hand" FontSize="20" Width="150" VerticalAlignment="Center" Command="{Binding HandPalletizCommand}" />
</Border>
</Grid>
</Border>
<Border Grid.Row="1">

@ -9,7 +9,7 @@
<UserControl.Resources>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="30" />
<Setter Property="FontSize" Value="20" />
</Style>
<Style TargetType="DataGrid">
@ -68,35 +68,42 @@
<Setter Property="Background" Value="#0288d1" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Margin="1,1,5,5" >
<TextBlock Text="分垛库设置" FontSize="25" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" x:Name="HeightHelperPanel" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Margin="5">
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Left">
<Button Content="设置货道" Width="200" Command="{Binding AddStoreCommand}" VerticalAlignment="Stretch" HorizontalAlignment="Left" Margin="5" FontSize="18"/>
<DataGrid Grid.Row="0" ItemsSource="{Binding PlanInfoDataGrid}"
<!--<Grid Grid.Row="1">
<Button Content="设置货道" Width="200" Command="{Binding AddStoreCommand}" VerticalAlignment="Stretch" HorizontalAlignment="Left" Margin="5" FontSize="18"/>
</Grid>-->
<Border Grid.Row="2" x:Name="HeightHelperPanel" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Margin="5">
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Left">
<DataGrid Grid.Row="0" ItemsSource="{Binding Spaces}"
ColumnHeaderHeight="35" Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
Foreground="White" >
Foreground="White" SelectedItem="{Binding SelectedDataItem}" MouseLeftButtonDown="dataGrid_MouseLeftButtonDown" >
<!--修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding OrderCode}" Header="SAP订单编号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding PlanCode}" Header="产品条码" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="入库货道" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding EnterSpace}" Header="转向角度" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />-->
<DataGridTextColumn Binding="{Binding SpaceCode}" Header="货道编号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding SpaceName}" Header="货道名称" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding StoreCode}" Header="仓库编号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialType}" Header="产品编码" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding typeNameA}" Header="产品名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding RotationRange}" Header="转向角度" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding IsTwoSpace}" Header="是否大产品(占两道)" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding LastSpace}" Header="上次入货道" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Grid>
</Border>
</Grid>

@ -1,5 +1,6 @@
using Aucma.Core.Palletiz.ViewModels;
using System.Windows.Controls;
using System.Windows.Input;
namespace Aucma.Core.Palletiz.Views
{
@ -8,10 +9,16 @@ namespace Aucma.Core.Palletiz.Views
/// </summary>
public partial class PalletizPageView : UserControl
{
PalletizPageViewModel model = new PalletizPageViewModel();
public PalletizPageView()
{
InitializeComponent();
this.DataContext = new PalletizPageViewModel();
this.DataContext = model;
}
private void dataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
model.MouseClick(sender);
}
}
}

@ -0,0 +1,248 @@
<Window x:Class="Aucma.Core.Palletiz.Views.SelectType"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" FontFamily="Microsoft YaHei" WindowStartupLocation="CenterScreen"
Name="window" Background="#1254AB" Height="1000" Width="1500">
<Window.Resources>
<Style TargetType="{x:Type Slider}">
<Style.Resources>
<!-- 重写重复触发按钮的样式 -->
<Style x:Key="RepeatButtonStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Padding" Value="0" />
<Setter Property="Width" Value="30" />
</Style>
</Style.Resources>
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="SmallChange" Value="1" />
</Style>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<!--<Setter Property="Height" Value="40"/>-->
<Setter Property="FontSize" Value="16"/>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style TargetType="DataGrid">
<!--网格线颜色-->
<Setter Property="CanUserResizeColumns" Value="false"/>
<Setter Property="Background" Value="#1152AC" />
<Setter Property="BorderBrush" Value="#4285DE" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="HorizontalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#4285DE"/>
</Setter.Value>
</Setter>
<Setter Property="VerticalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#1152AC"/>
</Setter.Value>
</Setter>
</Style>
<!--列头标题栏样式-->
<Style TargetType="DataGridColumnHeader">
<!--<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>-->
<!--<Setter Property="Background" Value="#dddddd"/>
<Setter Property="Foreground" Value="Black"/>-->
<!--<Setter Property="BorderThickness" Value="1" />-->
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="BorderBrush" Value="#dddddd" />
<Setter Property="Height" Value="48"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="#4285DE"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<!--单元格样式-->
<Style TargetType="DataGridCell">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="Height" Value="40"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}" >
<ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#4285DE"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border Margin="5" Background="#1254AB" CornerRadius="1">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Grid.Column="0">
<TextBox Width="200" Height="25" Margin="10 0 0 0" Text="{Binding SearchText}" Foreground="White" VerticalAlignment="Center" FontSize="18"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Background="#007DFA" BorderBrush="#007DFA" VerticalAlignment="Center" Foreground="White" Height="30" Width="100" Margin="0 0 20 0"/>
<Button Content="配 置" Command="{Binding SearchCriteriaSetCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Margin="20,0,0,0" FontSize="18" Height="30" Width="100" BorderThickness="1" />
</StackPanel>
<!--快捷搜索型号-->
<Border Grid.Row="0" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Margin="10 0 0 0">
<TextBlock Text="快捷查询" VerticalAlignment="Center" Foreground="#FFFFFF" FontSize="18" />
</StackPanel>
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="0 5" >
<ItemsControl ItemsSource="{Binding Configurations}" Foreground="#FFFFFF">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton
Content="{Binding}"
Command="{Binding DataContext.RadioButtonCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}"
GroupName="MaterialTypeRadioButton"
Margin="25,0" FontSize="18" Foreground="#FFFFFF"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
</Grid>
</Border>
<!--计划列表-->
<Border Grid.Row="1" Grid.Column="0" BorderThickness="0" CornerRadius="5" Margin="1,1,5,5" >
<DataGrid ItemsSource="{Binding MaterialDataGrid}" Height="{Binding Path=ActualHeight, ElementName=HeightPanel}"
HorizontalAlignment="Left" VerticalAlignment="Top" AlternationCount="2" RowHeaderWidth="0"
ColumnWidth="*" AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" SelectionMode="Single"
SelectedItem="{Binding SelectedDataItem}" SelectionChanged="DataGrid_SelectionChanged">
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding MaterialCode}" Width="*" Header="产品编码" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Width="2*" Header="产品名称" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="货道编号:" FontSize="20" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox x:Name="MaterialCode1" Text="{Binding SpaceInfo.SpaceCode}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 20 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="180"/>
<TextBlock Text="货道名称:" FontSize="20" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox x:Name="MaterialCode2" Text="{Binding SpaceInfo.SpaceName}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="180"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品编码:" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox x:Name="MaterialCode" Text="{Binding PlanInfo.MaterialCode}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="150"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品型号:" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="MaterialName" Text="{Binding PlanInfo.MaterialName}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="500"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="60,0,0,0" >
<!--单选框样式-->
<StackPanel.Resources>
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<Grid Width="20" Height="20">
<Ellipse x:Name="BulletRadio" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
</Grid>
</BulletDecorator.Bullet>
<ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" RecognizesAccessKey="True"/>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="BulletRadio" Property="Fill" Value="Green"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<TextBlock Text="是否占两道: " FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<RadioButton Content="是" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" />
<RadioButton Content="否" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 50 0 " FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text="转向角度:" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20"/>
<ComboBox x:Name="rotationComboBox" FontSize="20" SelectedItem="{Binding SelectedRotation}" Width="100" Height="40">
<ComboBox.Resources>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Foreground" Value="CadetBlue"/>
<Setter Property="Background" Value="CadetBlue"/>
</Style>
</ComboBox.Resources>
<ComboBoxItem Content="0" />
<ComboBoxItem Content="90" />
<ComboBoxItem Content="180" />
<ComboBoxItem Content="270" />
</ComboBox>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="清除型号" FontSize="23" Command="{Binding deleteCommand}" Background="#FF9900" Foreground="white" BorderBrush="#FF9900" Margin="0,0,10,0" VerticalAlignment="Center" Height="70" Width="130" />
<Button Content="保 存" FontSize="23" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="20,0,10,0" Height="70" Width="130" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
</Window>

@ -0,0 +1,48 @@
using Admin.Core.Model;
using Aucma.Core.Palletiz.ViewModels;
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Aucma.Core.Palletiz.Views
{
/// <summary>
/// SelectType.xaml 的交互逻辑
/// </summary>
public partial class SelectType : Window
{
private SelectTypeViewModel viewModel = null;
public SelectType(BaseSpaceInfo space)
{
InitializeComponent();
viewModel = new SelectTypeViewModel(space);
this.DataContext = viewModel;
viewModel.closeEvent += closeWindow;
WeakReferenceMessenger.Default.Register<object>(this, Recive);
}
private void Recive(object recipient, object message)
{
this.Close();
}
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
viewModel.MouseClick(sender);
}
private void closeWindow()
{
this.Close();
}
}
}

@ -82,7 +82,7 @@
"Enabled": true,
"HitRate": 50,
//"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_scada;Password=aucma;",
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=C##aucma_scada;Password=aucma;",
"ProviderName": "System.Data.SqlClient"
},
{
@ -90,7 +90,7 @@
"DBType": 3,
"Enabled": true,
"HitRate": 40,
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_mes;Password=aucma;",
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=c##aucma_mes;Password=aucma;",
"ProviderName": "System.Data.SqlClient"
}
],
@ -172,25 +172,51 @@
},
"Scanner": { //
"Enabled": true
},
"Scanner1": { //1
}
},
"ScannerServer": [
{
"Id": 1,
"Ip": "192.168.1.19",
"Name": "扫码器1"
"Name": "A库扫码器1"
},
"Scanner2": { //2
{
"Id": 2,
"Ip": "192.168.1.20",
"Name": "扫码器2"
"Name": "A库扫码器2"
},
"ScannerGun": { //
"Enabled": false
{
"Id": 3,
"Ip": "192.168.1.21",
"Name": "B库扫码器1"
},
{
"Id": 4,
"Ip": "192.168.1.22",
"Name": "B库扫码器2"
},
{
"Id": 5,
"Ip": "192.168.1.23",
"Name": "B库扫码器3"
}
},
],
"PLCServer": [
{
"Id": 1,
"EquipName": "分垛库Plc",
"EquipName": "A库Plc",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1",
"Port": 6000
},
{
"Id": 2,
"EquipName": "B库Plc",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1",
"Port": 6001
}
],
"IpRateLimiting": {

@ -6,6 +6,7 @@ using Admin.Core.Service;
using Aucma.Core.HwPLc;
using Aucma.Core.ProductOffLine;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.Scanner;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -46,6 +47,8 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
// public OffLineBusiness(){}
#region 变量定义
private readonly List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
/// <summary>
/// 扫码器1扫到条码的临时数据
/// </summary>
@ -132,8 +135,9 @@ namespace Aucma.Core.ProductOffLine.Business
public void MaterialBarScan(string code,string scannerIp)
{
try
{
int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器
{
ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
int ScannerNo = model.Id; // 确定是哪个扫码器
log.Info("扫码器ip:" + scannerIp + "编号:[" + ScannerNo + "]扫描到条码:" + code);
string materialType = "";

@ -201,18 +201,22 @@
"Scanner": { //
"Enabled": true
},
"Scanner1": { //1
"ScannerGun": { //
"Enabled": false
}
},
"ScannerServer": [
{
"Id": 1,
"Ip": "192.168.1.19",
"Name": "扫码器1"
},
"Scanner2": { //2
{
"Id": 2,
"Ip": "192.168.1.20",
"Name": "扫码器2"
},
"ScannerGun": { //
"Enabled": false
}
},
],
"PLCServer": [
{
"Id": 1,

@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\Admin.Core.Common\Admin.Core.Common.csproj" />
<ProjectReference Include="..\Aucma.Core.PLc\Aucma.Core.PLc.csproj" />
</ItemGroup>
<ItemGroup>

@ -1,5 +1,5 @@
using Admin.Core.Common;
using Aucma.Core.PLc;
using log4net;
using MvCodeReaderSDKNet;
using NPOI.SS.Formula.Functions;
@ -35,14 +35,9 @@ namespace Aucma.Core.Scanner
/// code1扫码信息刷新
/// </summary>
/// <param name="Code1"></param>
public delegate void ReceiveCode1(string code1);
public static event ReceiveCode1? ReceiveCode1Event;
/// <summary>
/// code2扫码信息刷新,记录表更新
/// </summary>
/// <param name="Code1"></param>
public delegate void ReceiveCode2(string code2);
public static event ReceiveCode2? ReceiveCode2Event;
public delegate void BindingReceiveCode(string code,string ip);
public static event BindingReceiveCode? BindingReceiveCodeEvent;
#endregion
#region 成品下线上位机委托事件
@ -50,7 +45,7 @@ namespace Aucma.Core.Scanner
/// code扫码信息刷新
/// </summary>
/// <param name="Code1"></param>
public delegate void ReceiveCode(string code, int scannerNo);
public delegate void ReceiveCode(string code, string ip);
public static event ReceiveCode? ReceiveCodeEvent;
public static bool m_bGrabbing = true;
#endregion
@ -108,7 +103,11 @@ namespace Aucma.Core.Scanner
{
try
{
// log.Info("获取扫码器设备列表,进入DeviceListAcq()方法");
List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
if (allScanners == null || allScanners.Count == 0) return;
// log.Info("获取扫码器设备列表,进入DeviceListAcq()方法");
System.GC.Collect();
m_stDeviceList.nDeviceNum = 0;
// 获取设备列表
@ -138,8 +137,12 @@ namespace Aucma.Core.Scanner
// 获取ip
string ip = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8) + "." + (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
// Console.WriteLine($"打印扫码设备信息,下标:{i}IP{ip}");
// log.Info("扫码器设备[" + i + "],ip:" + ip);
ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == ip);
if(model==null)
{
// 如果没有在配置文件配置该相机,不连接它,避免占用其他上位机相机
continue;
}
// 创建第i个设备
stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
nRet = m_cMyDevice.MV_CODEREADER_CreateHandle_NET(ref stDevInfo);//创建设备
@ -169,39 +172,7 @@ namespace Aucma.Core.Scanner
//添加到集合
m_cMyDevices.Add(m_cMyDevice, ip);
/**
nRet = m_cMyDevice.MV_CODEREADER_OpenDevice_NET();//打开设备
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
log.Error("打开第" + i + "个扫码器设备失败,销毁设备,ip:" + ip);
m_cMyDevice.MV_CODEREADER_DestroyHandle_NET();
return;
}
else
{
m_cMyDevices.Add(m_cMyDevice, ip);
log.Info("打开第" + i + "个扫码器设备成功,ip:" + ip);
}
// ch:设置触发模式为off || en:set trigger mode as off
if (MvCodeReader.MV_CODEREADER_OK != m_cMyDevice.MV_CODEREADER_SetEnumValue_NET("TriggerMode", 0))
{
log.Error("设置第" + i + "个扫码器设备触发模式失败ip:" + ip);
return;
}
log.Info("第" + i + "个扫码器设备设置采集连续模式成功ip:" + ip);
// ch:开启抓图 | en:start grab
nRet = m_cMyDevice.MV_CODEREADER_StartGrabbing_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
log.Error("设置第" + i + "个扫码器设备开启抓图失败ip:" + ip);
return;
}
log.Info("*****************************************************************");
log.Info("第" + i + "个扫码器设备创建打开开启连续抓图设置成功ip:" + ip);
**/
}
}
}
@ -266,13 +237,13 @@ namespace Aucma.Core.Scanner
if (hashmap.Value.Equals(Appsettings.app("Middleware", "Scanner1", "Ip")))
{
#region 条码绑定业务处理
ReceiveCode1Event?.Invoke(strCode);
// ReceiveCode1Event?.Invoke(strCode);
#endregion
}
else if (hashmap.Value.Equals(Appsettings.app("Middleware", "Scanner2", "Ip"))) // 扫码器2处理扫码器2的业务
{
#region 条码绑定业务处理
ReceiveCode2Event?.Invoke(strCode);
// ReceiveCode2Event?.Invoke(strCode);
#endregion
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.Scanner
{
/// <summary>
/// 扫码器实体
/// </summary>
public class ScannerModel
{
/// <summary>
/// 编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 扫码器ip
/// </summary>
public string Ip { get; set; }
/// <summary>
/// 扫码器名称
/// </summary>
public string Name { get; set; }
}
}
Loading…
Cancel
Save