feat - 添加状态提醒,添加关闭提醒

master
SoulStar 1 month ago
parent d5af7afeba
commit bf57a6cb97

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d"
Title="新宝龙输送带RFID数字化系统" WindowStartupLocation="CenterScreen" WindowState="Maximized" Height="1020" Width="1420" Topmost="False" Loaded="Window_Loaded" Closing="Window_Closing" Icon="/NOVOTON.ico">
Title="新宝龙输送带RFID数字化系统" WindowStartupLocation="CenterScreen" WindowState="Maximized" Height="1080" Width="1920" Topmost="False" Loaded="Window_Loaded" Closing="Window_Closing" Icon="/NOVOTON.ico">
<!--<Window.Background>
<ImageBrush ImageSource="/Templates/image/background.jpg" />
</Window.Background>-->

@ -74,6 +74,16 @@ namespace SlnMesnac.WPF
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
var result = System.Windows.MessageBox.Show("确认要关闭系统吗?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result != MessageBoxResult.OK)
{
e.Cancel = true;
return;
}
else
{
e.Cancel = false;
}
Log.Information("系统关闭!");
}

@ -92,12 +92,34 @@
</DataTrigger>
</Style.Triggers>
</Style>
<!-- 生产中状态样式 -->
<Style x:Key="ProducingTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="#00C851"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<!-- 成功状态样式 -->
<Style x:Key="StateTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="#00C851"/>
<Setter Property="FontWeight" Value="Bold"/>
<Style.Triggers>
<DataTrigger Binding="{Binding CurrentState}" Value="空闲">
<Setter Property="Foreground" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding CurrentState}" Value="盘点中">
<Setter Property="Foreground" Value="#00C851"/>
</DataTrigger>
<DataTrigger Binding="{Binding CurrentState}" Value="写入中">
<Setter Property="Foreground" Value="Blue"/>
</DataTrigger>
<DataTrigger Binding="{Binding CurrentState}" Value="写入中">
<Setter Property="Foreground" Value="Blue"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
@ -138,8 +160,10 @@
<!--<Button
Content="查询" Width="200" Visibility="Hidden" FontSize="20" Command="{Binding GetOrderInfoCommand}" CommandParameter="{Binding Name,ElementName=Search}"
Background="#009999" Margin="0 0 100 0"/>-->
<TextBlock Text="上次写入状态:" FontSize="15" Foreground="White" Margin="0,0,8,0"/>
<TextBlock Text="{Binding LastWriteState,Mode=TwoWay}" FontSize="15" Style="{StaticResource SuccessTextStyle}" Margin="0,0,8,0"/>
<TextBlock Text="现状态:" FontSize="15" Foreground="White" Margin="0,0,8,0"/>
<TextBlock Text="{Binding CurrentState,Mode=TwoWay}" FontSize="15" Style="{StaticResource StateTextStyle}" Margin="0,0,8,0"/>
<!--<TextBlock Text="上次写入状态:" FontSize="15" Foreground="White" Margin="0,0,8,0"/>
<TextBlock Text="{Binding LastWriteState,Mode=TwoWay}" FontSize="15" Style="{StaticResource SuccessTextStyle}" Margin="0,0,8,0"/>-->
<!--<TextBlock Text="成功" FontSize="15" Style="{StaticResource SuccessTextStyle}" Margin="0,0,8,0"/>-->
</StackPanel>

@ -136,6 +136,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
if (res)
{
MessageBox.Show("停止盘点成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
WeakReferenceMessenger.Default.Send("Cancel", "Cancel");
}
else
{
@ -168,8 +169,8 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
//调用MES接口获取生产订单信息
//MessageBox.Show("MES订单获取成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
List<MesOrderInfo> mesOrderInfos = new List<MesOrderInfo>();
//string response = "{\"code\":200,\"msg\":\"success\",\"data\":[{\"OrderNo\":\"SS075\",\"ProductCode\":\"4030502500100006\",\"ProductType\":\"钢丝带-ST-井下阻燃钢丝带\",\"ProductName\":\"输送带-井下阻燃钢丝带-ST\",\"ProductSpec\":\"1400mmST/S2500*18+8MT/MTD7.2P15N89\",\"PlanQty\":130.00,\"NextProductNo\":1}]}\r\n";
string response = await _httpclient.GetMesOrderInfo(lineno, BeginDate.ToString("yyyy-MM-dd"));
string response = "{\"code\":200,\"msg\":\"success\",\"data\":[{\"OrderNo\":\"SS076\",\"ProductCode\":\"4030502500100006\",\"ProductType\":\"钢丝带-ST-井下阻燃钢丝带\",\"ProductName\":\"输送带-井下阻燃钢丝带-ST\",\"ProductSpec\":\"1400mmST/S2500*18+8MT/MTD7.2P15N89\",\"PlanQty\":130.00,\"NextProductNo\":2}]}\r\n";
//string response = await _httpclient.GetMesOrderInfo(lineno, BeginDate.ToString("yyyy-MM-dd"));
Console.WriteLine("接收MES接口返回:"+ response);
// 反序列化
try

@ -29,6 +29,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using System.Xml.Serialization;
using TouchSocket.Core;
using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;
using Task = System.Threading.Tasks.Task;
@ -96,12 +97,30 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
}
/// <summary>
/// 当前状态 空闲 盘点中 写入中
/// </summary>
private string _CurrentState = "空闲";
public string CurrentState
{
get => _CurrentState;
set
{
if (_CurrentState != value)
{
_CurrentState = value;
RaisePropertyChanged(() => CurrentState);
}
}
}
public ProductionLineViewModel()
{
GetOrderInfoCommand = new RelayCommand<object>(t => RefreshData(t));
ChangeTypeView = App.ServiceProvider.GetService<ChangeTypeViewModel>();
// 构造函数里注册
WeakReferenceMessenger.Default.Register<Real_DataInfo>(this, RefreshOrderNo);
WeakReferenceMessenger.Default.Register<string, string>(this, "Cancel", StopMessage);
_StringChange = App.ServiceProvider.GetService<StringChange>();
_logger = App.ServiceProvider.GetService<SerilogHelper>();
appConfig = App.ServiceProvider.GetService<AppConfig>();
@ -176,6 +195,15 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
Deviceinfo.FirstOrDefault(x => x.Deviceid == real_Data.Deviceid).NextProductNo = real_Data.NextProductNo;
rfidList.FirstOrDefault(x => x.deviceid == real_Data.Deviceid).Set_BeginIdentify().GetAwaiter().GetResult();
CurrentState = "盘点中";
}
/// <summary>
/// 停止盘点消息
/// </summary>
private void StopMessage(object o, string e)
{
CurrentState = "空闲";
}
private void LoadDeviceInfo()
@ -208,44 +236,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
//Real_DataInfo real_DataInfo = new Real_DataInfo()
//{
// Name = "1",
// Deviceid = "10001",
// Connectstr = "192.168.0.1:20108",
// LineNo = "6#",
// OrderNo = "123456",
// ProductType = "整芯带",
// WriteCount = "0",
// RfidCount = "20",
// IsOnline = "未连接",
// RfidASCII = "0",
// RfidEPC = "0",
// ReadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
// WriteTime = DateTime.Now.AddSeconds(10).ToString("yyyy-MM-dd HH:mm:ss"),
// ProductStatus = "生产中",
// WriteStatus = "写入成功",
//};
//Real_DataInfo real_DataInfo2 = new Real_DataInfo()
//{
// Name = "2",
// Deviceid = "10002",
// Connectstr = "127.0.0.1:20108",
// LineNo = "7#",
// OrderNo = "123456",
// ProductType = "整芯带",
// WriteCount = "0",
// RfidCount = "20",
// IsOnline = "未连接",
// RfidASCII = "0",
// RfidEPC = "0",
// ReadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
// WriteTime = DateTime.Now.AddSeconds(10).ToString("yyyy-MM-dd HH:mm:ss"),
// ProductStatus = "生产中",
// WriteStatus = "写入成功",
//};
//real_DataInfos.Add(real_DataInfo);
//real_DataInfos.Add(real_DataInfo2);
App.Current.Dispatcher.Invoke(() =>
{
Deviceinfo.Clear();
@ -283,7 +273,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
/// <param name="tagInfos"></param>
private async void RecvIdentifyData_Instance(string iCombineId, List<TagInfo> tagInfos)
{
string info = "";
try
{
if (string.IsNullOrEmpty(Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).OrderNo))
@ -314,6 +303,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
+ DateTime.Now.ToString("yy")
+ Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).NextProductNo
+ Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).SerialNo;
CurrentState = "写入中";
//写入 三次重写
bool writeflag = await rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_Write(tagInfos[0].EPC, WriteData);
if (!writeflag)
@ -333,6 +323,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
}
}
Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).WriteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).WriteStatus = "成功";
LastWriteState = "成功";
@ -355,27 +346,22 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
};
var a = databaseService._helper.Insert(real_Readdata);
//刷新界面
//Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).RfidASCII = Encoding.ASCII.GetString(tagInfos[0].EPC);
//Deviceinfo.FirstOrDefault(x => x.Deviceid == iCombineId).ReadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//RefreshEventArgs(iCombineId, tagInfos);
AddRFIDData(iCombineId, tagInfos);
}
await Task.Run(async () =>
{
await Task.Delay(1000);
await rfidList.FirstOrDefault(x => x.deviceid == iCombineId)!.Set_BeginIdentify();
CurrentState = "盘点中";
});
}
catch (Exception e)
{
Log.Error($"读结果准备写入时异常:{e.Message}");
}
finally
{
CurrentState = "空闲";
}
}
public void RefreshEventArgs(string iCombineId, List<TagInfo> tagInfos)
{
try

Loading…
Cancel
Save