提交代码

This commit is contained in:
hehaibing-1996
2024-06-29 17:30:54 +08:00
parent 5ea25c477c
commit 344158c722
43 changed files with 1148 additions and 98 deletions

View File

@ -21,7 +21,7 @@
<!--字体-->
<FontFamily x:Key="IconFont">pack://application,,,/货架标准上位机;component/Fonts/#iconfont</FontFamily>
<!--字符串-->
<sys:String x:Key="AboutInfo1">卓越盟讯</sys:String>
<sys:String x:Key="AboutInfo1">金川数智</sys:String>
<sys:String x:Key="AboutInfo2">智造未来</sys:String>
</ResourceDictionary>
</Application.Resources>

View File

@ -29,7 +29,10 @@ namespace 货架标准上位机
/// 日志目录
/// </summary>
public static readonly string LogDir = Path.Combine(AppDir, "logs");
/// <summary>
/// 资源目录
/// </summary>
public static readonly string ResourcesDir = Path.Combine(AppDir, "Resources");
/// <summary>
/// 运行主程序
/// </summary>
@ -46,6 +49,10 @@ namespace 货架标准上位机
/// 帮助文档路径
/// </summary>
public static readonly string DocPath = Path.Combine(DataDir, "操作说明书.docx");
/// <summary>
/// 打印模板
/// </summary>
public static readonly string PrintTemplatePath = Path.Combine(ResourcesDir, "物料条码.btw");
static object lockConfig = new object();
static JsConfig config;

View File

@ -15,5 +15,9 @@ namespace 货架标准上位机
/// 前端当前登录的用户名
/// </summary>
public static string CurrentUser { get; set; } = "未登录";
public static bool IsScanGenarateMatInfoWindowOpen { get; set; } = false;
public static MatBaseInoScanGenarateMatInfoView ScanGenarateMatInfoWindow { get; set; } = null;
}
}

View File

@ -68,6 +68,21 @@ namespace 货架标准上位机
/// </summary>
public string ElectronicSiloPush { get; set; }
#endregion
#region
//固定码
public string ChangelessCode { get; set; }
//预留码
public string ReservedCode { get; set; }
//正则 物料编码
public string RegexMatCode { get; set; }
//正则 物料数量
public string RegexMatQty { get; set; }
//正则 物料批次
public string RegexMatBatch { get; set; }
#endregion
}
public class JsSysConfig

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -39,7 +39,11 @@ namespace 货架标准上位机
/// <summary>
/// Api接口调用
/// </summary>
Api
Api,
/// <summary>
/// WebSocket通信
/// </summary>
WebSocket
}
/// <summary>

View File

@ -9,6 +9,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using .Api;
@ -46,6 +47,20 @@ namespace 货架标准上位机.ViewModel
}
#endregion
}
public ICommand BarcodePrintTemplateCommand { get => new DelegateCommand(BarcodePrintTemplate); }
public void BarcodePrintTemplate()
{
try
{
Folder.OpenFolderAndSelectedFile(LocalFile.PrintTemplatePath);
}
catch (Exception)
{
Growl.Error("打开文件夹失败。");
}
}
}
public class DeviceReadModel : BindableBase

View File

@ -57,7 +57,7 @@ namespace 货架标准上位机.ViewModel
/// </summary>
public void ClearTextInfo()
{
TextBoxLog.ClearLog();
TextBoxLog.ClearLog("selfCheck");
}
public ICommand ClearTextErrCommand { get => new DelegateCommand(ClearTextErr); }
/// <summary>

View File

@ -29,6 +29,7 @@ using WCS.BLL.DbModels;
using WCS.Model.ApiModel.MatBaseInfo;
using System.Security.Cryptography;
using Ping9719.WpfEx;
using System.Diagnostics.Eventing.Reader;
namespace .ViewModel
{
@ -81,41 +82,59 @@ namespace 货架标准上位机.ViewModel
if (scanner.TempCode.EndsWith("\r"))//结束符 TODO结束符是否需要自定义 现场配置
{
scanner.TempCode = scanner.TempCode.Replace("\r", string.Empty).Replace("\n", string.Empty);
try
//金川项目-扫物料码生成本地物料码流程
if (LocalStatic.IsScanGenarateMatInfoWindowOpen)
{
//TO DO 配置项进行配置正则表达式
//数据处理
//获取配置文件的正则表达式
var configModuleCodePattern = LocalFile.Config.ModuleCodePattern;
string ModuleCodePattern = string.IsNullOrEmpty(configModuleCodePattern) ? "^[ABCD][0-9]{2}-R[0-9]{1,2}C[0-9]{1,2}$" : configModuleCodePattern;
var isModuleCode = Regex.IsMatch(scanner.TempCode, ModuleCodePattern);
if (isModuleCode)
try
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为货架码【{scanner.TempCode}】", LogsType.Scanner);
ModuleCodeProcess(scanner);
LocalStatic.ScanGenarateMatInfoWindow.viewModel.ParsingBarcode(scanner.TempCode);
}
else if (scanner.TempCode == "shelfGoOutInStore")
catch (Exception ex)
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为结束入库码【{scanner.TempCode}】", LogsType.Scanner);
ShelfGoOutInstoreProcess(scanner);
var message = "物料扫码发生异常:" + ex.Message;
Logs.Write(message, LogsType.Scanner);
}
//TODO 增加正则表达式进行判断是否扫到的是物料码
else
finally
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为物料码【{scanner.TempCode}】", LogsType.Scanner);
MatSnProcess(scanner);
scanner.TempCode = string.Empty;
}
}
catch (Exception ex)
{
var message = "入库扫码枪扫码发生异常:" + ex.Message;
}
finally
{
//不管入库成功与否 认为本次扫码完毕 清空暂存数据
scanner.TempCode = string.Empty;
}
else
//入库流程的情况下
try
{
//数据处理
//获取配置文件的正则表达式
var configModuleCodePattern = LocalFile.Config.ModuleCodePattern;
string ModuleCodePattern = string.IsNullOrEmpty(configModuleCodePattern) ? "^[ABCD][0-9]{2}-R[0-9]{1,2}C[0-9]{1,2}$" : configModuleCodePattern;
var isModuleCode = Regex.IsMatch(scanner.TempCode, ModuleCodePattern);
if (isModuleCode)
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为货架码【{scanner.TempCode}】", LogsType.Scanner);
ModuleCodeProcess(scanner);
}
else if (scanner.TempCode == "shelfGoOutInStore")
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为结束入库码【{scanner.TempCode}】", LogsType.Scanner);
ShelfGoOutInstoreProcess(scanner);
}
//TODO 增加正则表达式进行判断是否扫到的是物料码
else
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为物料码【{scanner.TempCode}】", LogsType.Scanner);
MatSnProcess(scanner);
}
}
catch (Exception ex)
{
var message = "入库扫码枪扫码发生异常:" + ex.Message;
Logs.Write(message, LogsType.Scanner);
}
finally
{
//不管入库成功与否 认为本次扫码完毕 清空暂存数据
scanner.TempCode = string.Empty;
}
}
}
@ -343,6 +362,15 @@ namespace 货架标准上位机.ViewModel
Growl.Warning(ex.Message);
}
}
public ICommand ClearTextInfoCommand { get => new DelegateCommand(ClearTextInfo); }
/// <summary>
/// 清除信息文本
/// </summary>
public void ClearTextInfo()
{
TextBoxLog.ClearLog("InstoreLog");
}
#endregion
}
}

View File

@ -384,6 +384,28 @@ namespace 货架标准上位机.ViewModel
var generateWindow = new MatBaseInoGenarateMatInfoView(matBaseInfo);
var result = generateWindow.ShowDialog();
}
public ICommand BtnScanPrintCommand { get => new DelegateCommand(BtnScanPrint); }
public async void BtnScanPrint()
{
try
{
var generateWindow = new MatBaseInoScanGenarateMatInfoView();
LocalStatic.IsScanGenarateMatInfoWindowOpen = true;
LocalStatic.ScanGenarateMatInfoWindow = generateWindow;
var result = generateWindow.ShowDialog();
}
catch (Exception ex)
{
}
finally
{
LocalStatic.IsScanGenarateMatInfoWindowOpen = false;
}
}
#endregion
#region PageOperation

View File

@ -0,0 +1,376 @@
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using .Api;
using .Tool;
using .Views.Controls;
namespace .ViewModel
{
public class MatBaseInoScanGenarateMatInfoViewModel : BindableBase
{
public MatBaseInoScanGenarateMatInfoViewModel()
{
}
#region Property
private string matCode;
public string MatCode
{
get => matCode; set
{
SetProperty(ref matCode, value);
}
}
private string matName;
public string MatName
{
get => matName;
set { SetProperty(ref matName, value); }
}
private string matSpec;
public string MatSpec
{
get => matSpec;
set { SetProperty(ref matSpec, value); }
}
private int matQty;
public int MatQty
{
get => matQty;
set { SetProperty(ref matQty, value); }
}
private int totalPan = 1;
public int TotalPan
{
get => totalPan; set
{
SetProperty(ref totalPan, value);
UpdateMatSN();
}
}
private string matBatch;
public string MatBatch
{
get => matBatch;
set
{
SetProperty(ref matBatch, value);
UpdateMatSN();
}
}
private string reservedCode;
public string ReservedCode
{
get => reservedCode; set
{
SetProperty(ref reservedCode, value);
UpdateMatSN();
}
}
private string changelessCode;
public string ChangelessCode
{
get => changelessCode; set
{
SetProperty(ref changelessCode, value);
UpdateMatSN();
}
}
private List<string> matSNs = new List<string>();
public List<string> MatSNs { get => matSNs; set { SetProperty(ref matSNs, value); } }
private string matSNsStr;
public string MatSNsStr
{
get => matSNsStr;
set { SetProperty(ref matSNsStr, value); }
}
public MatBaseInfoModel MatBaseInfo { get; set; } = null;
public List<MatInfoModel> MatInfos { get; set; } = null;
#endregion
#region Command
//public ICommand BtnGenerateCommand { get => new DelegateCommand(BtnGenerate); }
//public void BtnGenerate()
//{
// #region 调用接口获取物料 MatBaseInfo
// try
// {
// var body = new JinChuanCommitMatInfoRequest()
// {
// MatId = MatBaseInfo.Id,
// CurrentSerilNumber = MatBaseInfo.SerialNumber,
// MatBatch = MatBatch,
// MatQty = MatQty,
// TotalPan = totalPan,
// CurrentMatSn = MatSNs,
// DeviceType = LocalFile.Config.DeviceType,
// UserName = LocalStatic.CurrentUser,
// };
// var Result = ApiHelp.GetDataFromHttp<ResponseBase<List<MatInfoModel>>>(LocalFile.Config.ApiIpHost + "matBaseInfo/JinChuanCommitMatInfo", body, "POST");
// if (Result != null && Result.Code == 200 && Result.Data != null)
// {
// MatInfos = Result.Data;
// MatSNs = MatSNs + " 已生成";
// Growl.Success("生成成功!");
// }
// else
// {
// if (Result != null && !string.IsNullOrEmpty(Result.Message))
// {
// HandyControl.Controls.MessageBox.Show(Result.Message);
// }
// else
// HandyControl.Controls.MessageBox.Show("操作失败,请重试!");
// }
// }
// catch (Exception ex)
// {
// Growl.Warning(ex.Message);
// }
// #endregion
//}
public ICommand BtnGeneratePrintCommand { get => new DelegateCommand(BtnGeneratePrint); }
public void BtnGeneratePrint()
{
#region MatBaseInfo
try
{
var body = new JinChuanCommitMatInfoRequest()
{
MatId = MatBaseInfo.Id,
CurrentSerilNumber = MatBaseInfo.SerialNumber,
MatBatch = MatBatch,
MatQty = MatQty,
TotalPan = TotalPan,
CurrentMatSn = MatSNs,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseBase<List<MatInfoModel>>>(LocalFile.Config.ApiIpHost + "matBaseInfo/JinChuanCommitMatInfo", body, "POST");
if (Result != null && Result.Code == 200 && Result.Data != null && Result.Data.Count != 0)
{
MatInfos = Result.Data;
MatSNsStr = MatSNsStr + " 已生成";
Task.Run(() =>
{
ProcessDialog process = null;
Dialog dia = null;
var totalCount = MatInfos.Count;
int currentCount = 0;
App.Current.Dispatcher.Invoke(() =>
{
process = new ProcessDialog();
dia = Dialog.Show(process);
});
foreach (var matInfo in MatInfos)
{
PrintTender.PrintTag(new PrintClass()
{
MatSn = matInfo.MatSN,
MatName = matInfo.MatName,
MatCode = matInfo.MatCode,
MatBatch = matInfo.MatBatch,
MatQty = matInfo.MatQty.ToString(),
MatSpec = matInfo.MatSpec,
});
currentCount++;
if (process != null)
process.viewModel.ProcessValue = Convert.ToInt32(((decimal)currentCount / totalCount) * 100);
}
App.Current.Dispatcher.Invoke(() =>
{
dia.Close();
dia.Collapse();
});
#region
try
{
var body = new PrintedMatInfoRequest()
{
PrintedMatInfoIds = MatInfos.Select(t => t.Id).ToList(),
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result11 = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "matBaseInfo/printedMatInfo", body, "POST");
if (Result11 != null && Result11.Code == 200)
{
MatSNsStr = MatSNsStr + " 已打印";
//回传成功
}
else
{
//回传失败
Logs.Write("回传“打印成功”失败");
}
}
catch (Exception ex)
{
Logs.Write("回传“打印成功”失败:" + ex.Message);
}
#endregion
});
}
else
{
if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
HandyControl.Controls.MessageBox.Show(Result.Message);
}
else
HandyControl.Controls.MessageBox.Show("操作失败,请重试!");
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
}
#endregion
public void ParsingBarcode(string input)
{
#region
// 提取第一个字段 CPN物料编码
//string firstField = Regex.Match(input, @"^[0-9,a-z,A-Z, ]{9}{").Value;
string firstField = Regex.Match(input, LocalFile.Config.RegexMatCode).Value;
MatCode = firstField.Replace("{", "").Replace(" ", "");
try
{
// 第二个字段 数量
//string secondField = Regex.Match(input, @"{[1-9][0]{2,5}[ ]{").Value;
string secondField = Regex.Match(input, LocalFile.Config.RegexMatQty).Value;
MatQty = Convert.ToInt32(secondField.Replace("{", "").Replace(" ", ""));
}
catch
{
Growl.Warning("数量解析失败!请重试或手动输入");
}
// 第三个字段 批次
//string thirdField = Regex.Match(input, @"{[0-9, ]{5}{").Value;
string thirdField = Regex.Match(input, LocalFile.Config.RegexMatBatch).Value;
MatBatch = thirdField.Replace("{", "").Replace(" ", ""); ;
#endregion
//调用接口获取物料信息
#region MatBaseInfo
try
{
var body = new JinChuanGenerateMatInfoRequest()
{
MatCode = MatCode,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseBase<MatBaseInfoModel>>(LocalFile.Config.ApiIpHost + "matBaseInfo/JinChuanGenerateMatInfo", body, "POST");
if (Result != null && Result.Code == 200 && Result.Data != null)
{
MatBaseInfo = Result.Data;
MatName = MatBaseInfo.MatName;
MatSpec = MatBaseInfo.MatSpec;
MatBaseInfo.SerialNumber++;
GenerateMatSN();
}
else
{
if (Result == null && !string.IsNullOrEmpty(Result.Message))
{
HandyControl.Controls.MessageBox.Show(Result.Message);
}
else
HandyControl.Controls.MessageBox.Show("接口调用失败,请重试!");
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
}
public void UpdateMatSN()
{
if (MatSNs != null && totalPan > 1)
{
MatSNs.Clear();
for (int i = 0; i < TotalPan; i++)
{
var newMatSn = ChangelessCode + MatCode + ReservedCode + MatBatch + (MatBaseInfo.SerialNumber + i).ToString("000");
MatSNs.Add(newMatSn);
}
if (MatSNs == null || MatSNs.Count == 0)
{
MatSNsStr = string.Empty;
}
else if (MatSNs.Count == 1)
{
MatSNsStr = MatSNs[0].ToString();
}
else
{
MatSNsStr = MatSNs[0].ToString() + "\r\n~" + MatSNs[MatSNs.Count - 1].ToString();
}
}
}
public void GenerateMatSN()
{
MatSNs.Clear();
for (int i = 0; i < TotalPan; i++)
{
var newMatSn = ChangelessCode + MatCode + ReservedCode + MatBatch + (MatBaseInfo.SerialNumber + i).ToString("000");
MatSNs.Add(newMatSn);
}
if (MatSNs == null || MatSNs.Count == 0)
{
MatSNsStr = string.Empty;
}
else if (MatSNs.Count == 1)
{
MatSNsStr = MatSNs[0].ToString();
}
else
{
MatSNsStr = MatSNs[0].ToString() + "\r\n~" + MatSNs[MatSNs.Count - 1].ToString();
}
}
}
}

View File

@ -1,17 +1,23 @@
using HandyControl.Controls;
using Ping9719.WpfEx.Mvvm;
using QRCoder;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.OutStore;
using .Api;
using .Views.Controls;
namespace .ViewModels
{
@ -302,6 +308,17 @@ namespace 货架标准上位机.ViewModels
return;
}
//判断是否是信息化货架
if (selectedOutOrder.ShelfTypeName == "信息化货架")
{
Growl.Info("请使用PDA进行出库");
//生成二维码
var qrCodeImage = GenerateQRCode(selectedOutOrder.Id.ToString() + "," + selectedOutOrder.OrderNumber);
//展示二维码
Dialog.Show(new ImageDialog(qrCodeImage));
return;
}
#region
var body = new GetOutOrderDetailRequest()
{
@ -340,6 +357,29 @@ namespace 货架标准上位机.ViewModels
}
}
public BitmapImage GenerateQRCode(string data)
{
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, true);
// 将System.Drawing.Bitmap转换为System.Windows.Media.Imaging.BitmapImage
using (var memoryStream = new MemoryStream())
{
// 假设Bitmap的Save方法支持Png格式通常是这样
qrCodeImage.Save(memoryStream, ImageFormat.Png);
memoryStream.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memoryStream;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
// 返回BitmapImage
return bitmapImage;
}
}
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
public void BtnPause()
{

View File

@ -16,6 +16,8 @@
<GroupBox Header="调试功能" Margin="3" Style="{StaticResource GroupBoxTab}">
<StackPanel Orientation="Horizontal">
<Button Margin="5,3" Padding="30,0" Name="resetShelf" Content="货架状态初始化" Command="{Binding ResetAllShelfCommand}"></Button>
<Button Margin="5,3" Padding="30,0" Content="打开打印模板路径" Command="{Binding BarcodePrintTemplateCommand}"></Button>
</StackPanel>
</GroupBox>

View File

@ -6,8 +6,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
d:DesignHeight="737" d:DesignWidth="1192" LoadedVisibleFirst="LoadedVisible">
mc:Ignorable="d"
d:DesignHeight="737" d:DesignWidth="1192"
LoadedVisibleFirst="LoadedVisible"
Loaded="UserControlBase_Loaded"
>
<Border Margin="0" Background="AliceBlue" CornerRadius="3" Padding="0">
<Grid>
@ -79,7 +82,7 @@
<TextBlock Grid.Row="2" Grid.Column="4" Margin="5"
VerticalAlignment="Center" HorizontalAlignment="Right"
Text="物料条码" FontSize="18" ></TextBlock>
Text="物 料 SN" FontSize="18" ></TextBlock>
<TextBox Grid.Row="2" Grid.Column="5" Text="{Binding MatSN}"
VerticalAlignment="Center" HorizontalAlignment="Left"
FontSize="18" MinWidth="120" ></TextBox>

View File

@ -32,9 +32,14 @@ namespace 货架标准上位机
private void LoadedVisible(object sender, EventArgs e)
{
viewModel.InitMatCode();
viewModel.BtnReset();
viewModel.BtnSearchReset();
}
private void UserControlBase_Loaded(object sender, RoutedEventArgs e)
{
viewModel.InitMatCode();
}
}
}

View File

@ -263,16 +263,11 @@
</StackPanel>
</TabItem.Header>
<TabControl Margin="5" Style="{StaticResource TabControlBaseStyle.MouseOver}">
<TabItem Header="PLC">
<TabItem Header="调试">
<hc:TransitioningContentControl TransitionMode="Fade">
<View:DeviceView Margin="0,5"/>
</hc:TransitioningContentControl>
</TabItem>
<TabItem Header="扫码枪">
<hc:TransitioningContentControl TransitionMode="Fade">
<pi:TextBoxScanner Style="{StaticResource TextBoxExtend.Multi}" hc:InfoElement.Placeholder="鼠标点击此处激活" hc:InfoElement.Title="码信息" hc:InfoElement.TitlePlacement="Top" AutoClear="NextClear" IsAutoFocus="True"></pi:TextBoxScanner>
</hc:TransitioningContentControl>
</TabItem>
</TabControl>
</TabItem>

View File

@ -131,11 +131,17 @@
<Button MinHeight="40" FontSize="18" Margin="5"
Content="&#xe7f8;生成&amp;打印" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnPrintCommand}"
Foreground="WhiteSmoke"
Background="DarkOrange"
>
Foreground="WhiteSmoke"
Background="DarkOrange">
</Button>
<Button MinHeight="40" FontSize="18" Margin="5"
Content="&#xe7f8;扫描生成打印" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnScanPrintCommand}"
Foreground="WhiteSmoke"
Background="BlueViolet">
</Button>
</StackPanel>
<DataGrid Grid.Row="1"

View File

@ -64,7 +64,7 @@
<TextBox Name="txtTotalCount" MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
InputScope="Number"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewTextInput="txtMatBatch_PreviewTextInput"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>

View File

@ -56,11 +56,6 @@ namespace 货架标准上位机
Growl.Warning("【物料批次】请输入数字!");
txtMatBatch.Focus();
return;
//正则表达式
//匹配年周
//^\d{ 4}\d{ 1,2}$
//匹配年月日
//^\d{ 4} (0[1 - 9] | 1[0 - 2])(0[1 - 9] | [12]\d | 3[01])$
}
var matQty = txtMatQty.Text.Trim();

View File

@ -0,0 +1,107 @@
<Window
xmlns:pi="https://github.com/ping9719/wpfex"
x:Class="货架标准上位机.MatBaseInoScanGenarateMatInfoView"
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"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Height="400" Width="340" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
<Border BorderBrush="Gray" Background="WhiteSmoke" CornerRadius="5" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock FontSize="22" Name="Title" Text="{Binding Title, FallbackValue= 扫描生成物料条码}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Margin="-5,-1"
Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityConverter}}"
Style="{StaticResource ButtonIcon}"
hc:IconElement.Geometry="{StaticResource CloseGeometry}" HorizontalAlignment="Right"
VerticalAlignment="Top" Click="closeClick"/>
<StackPanel Margin="5,0" Grid.Row="1" >
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="两位固定码:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding ChangelessCode}"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="物料编码:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Text="{Binding MatCode}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="物料名称:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Text="{Binding MatName}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="物料规格:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Text="{Binding MatSpec}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="两位预留码:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding ReservedCode}"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="物料批次:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding MatBatch}"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="物料数量:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox Name="txtMatQty" MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding MatQty}"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="打印盘数:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox Name="txtTotalCount"
MinWidth="200" MaxWidth="200" FontSize="15"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
PreviewTextInput="txtMatBatch_PreviewTextInput"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding TotalPan}"
Style="{StaticResource TextBoxExtend}">
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="{Binding MatSNsStr}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</StackPanel>
</StackPanel>
<StackPanel Margin="5" x:Name="spacingPanel" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<!--<Button Margin="5" Command="{Binding BtnGenerateCommand}" MinHeight="30" FontSize="15" Content="生成" Name="btnOk" />-->
<Button Margin="5" x:Name="BtnGeneratePrint" Command="{Binding BtnGeneratePrintCommand}" MinHeight="30" FontSize="15" Content="生成并打印" />
<Button Margin="5" MinHeight="30" FontSize="15" Content="关 闭" Click="closeClick"/>
</StackPanel>
</Grid>
</Border>
</Window>

View File

@ -0,0 +1,73 @@
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using .Api;
using .Tool;
using .ViewModel;
using .Views.Controls;
namespace
{
public partial class MatBaseInoScanGenarateMatInfoView : System.Windows.Window
{
public MatBaseInoScanGenarateMatInfoViewModel viewModel = new MatBaseInoScanGenarateMatInfoViewModel();
public MatBaseInoScanGenarateMatInfoView()
{
InitializeComponent();
this.DataContext = viewModel;
viewModel.ChangelessCode = LocalFile.Config.ChangelessCode;
viewModel.ReservedCode = LocalFile.Config.ReservedCode;
this.Topmost = true;
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
private void btnOk_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
this.DialogResult = true;
this.Close();
}
private void closeClick(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void txtMatBatch_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = !IsInputNumberAllowed(e.Text);
}
private bool IsInputNumberAllowed(string text)
{
Regex regex = new Regex("^[0-9]+$"); // 只允许数字
return regex.IsMatch(text);
}
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
txtMatQty.Focus();
Thread.Sleep(1);
txtTotalCount.Focus();
}
}
}
}

View File

@ -23,27 +23,39 @@ namespace 货架标准上位机
{
lock (flag)
{
warnings.Add(WarningWindow.Show(warningModel.WarningMessage, "报警信息", warningModel));
Logs.Write($"【添加报警信息弹窗】报警类型:{warningModel.WarningType} 报警信息:{warningModel.WarningMessage} Guid:{warningModel.Guid}", LogsType.WebSocket);
Application.Current.Dispatcher.Invoke(new Action(() =>
{
warnings.Add(WarningWindow.Show(warningModel.WarningMessage, "报警信息", warningModel));
}));
}
}
public static void RemoveWarning(Guid guid)
{
lock(flag)
lock (flag)
{
try
{
var warning = warnings.Where(t => t.warning.Guid == guid).First();
Application.Current.Dispatcher.Invoke(new Action(() =>
var warningWindow = warnings.Where(t => t.warning.Guid == guid).First();
if (warningWindow != null)
{
warning?.Close();
warnings.Remove(warning);
}));
Logs.Write($"【移除报警信息弹窗】报警类型:{warningWindow.warning.WarningType} 报警信息:{warningWindow.warning.WarningMessage} Guid:{warningWindow.warning.Guid}", LogsType.WebSocket);
Application.Current.Dispatcher.Invoke(new Action(() =>
{
warningWindow?.Close();
warnings.Remove(warningWindow);
}));
}
else
{
Logs.Write($"【移除报警信息弹窗失败】Guid为:{guid}的窗体未找到!");
}
}
catch
{
catch
{
}
}
}

View File

@ -25,6 +25,11 @@
"FirstSendRecommendedBarCode": "http://192.168.2.23:9213/integrate/inOut/firstsetPush",
//盟讯公司配置-后续发料获取要料单明细
"ElectronicSiloPush": "http://192.168.2.23:9213/integrate/inOut/electronicSiloPush",
"ChangelessCode": "11",
"ReservedCode": "09",
"RegexMatCode": "^[0-9,a-z,A-Z, ]{9}{",
"RegexMatQty": "{[1-9]{1,3}[0]{2,6}[ ]{",
"RegexMatBatch": "{[0-9, ]{5}{",
//系统配置
"Sys": {
//是否保存登录历史

View File

@ -131,6 +131,9 @@
</ItemGroup>
<ItemGroup>
<Page Update="Views\MatBaseInoScanGenarateMatInfoView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\ShelfInfoAddOrUpdateView.xaml">
<SubType>Designer</SubType>
</Page>