去掉录像机录像、药箱号按钮后添加对应人名,去掉相关多线程发指令,去掉开线程跳转页面

This commit is contained in:
maqiao 2024-11-26 15:05:37 +08:00
parent 74c688bc07
commit 5e27e28a96
16 changed files with 508 additions and 218 deletions

View File

@ -103,7 +103,7 @@ namespace DM_Weight
// 组态屏工具
//containerRegistry.RegisterSingleton<ScreenUtil>();
// 录像机
containerRegistry.RegisterSingleton<CHKFunction>();
//containerRegistry.RegisterSingleton<CHKFunction>();
containerRegistry.Register<IDialogService, MaterialDialogService>();

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace DM_Weight.Converter
{
internal class DrawerContentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//int iLength = value[0].ToString().Length;
//int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength-3));
//int SelectedDrawerNo = int.Parse(value[1].ToString());
//return ButtonDrawerNo == SelectedDrawerNo;
if (value!=null)
{
string name = value.ToString();
string num = parameter.ToString();
if (!string.IsNullOrEmpty(name))
{
return num + " " + name;
}
else
return num;
}
else if(!string.IsNullOrEmpty(parameter.ToString()))
{
return parameter.ToString();
}
else
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -4,19 +4,25 @@ using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace DM_Weight.Converter
{
internal class DrawerSelectConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
int iLength = value[0].ToString().Length;
int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength-3));
int SelectedDrawerNo = int.Parse(value[1].ToString());
return ButtonDrawerNo == SelectedDrawerNo;
if (!string.IsNullOrEmpty(values[0].ToString()) && values[0].ToString().Length >= 1)
{
int iLength = values[0].ToString().Length;
int ButtonDrawerNo = int.Parse(values[0].ToString().Substring(0, 1));
int SelectedDrawerNo = int.Parse(values[1].ToString());
return ButtonDrawerNo == SelectedDrawerNo;
}
return
false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)

View File

@ -208,5 +208,9 @@ namespace DM_Weight.Models
private string _drugSpec;
[SugarColumn(ColumnName = "drug_manu_no")]
public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
private string _belongUserName;
[SugarColumn(IsIgnore =true)]
public string BelongUserName { get => _belongUserName;set=>SetProperty(ref _belongUserName, value); }
}
}

View File

@ -12,6 +12,7 @@ using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DM_Weight.Port
@ -24,7 +25,7 @@ namespace DM_Weight.Port
private static ModbusHelper instance;
private static readonly object objLock = new object();
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
public ModbusHelper()
private ModbusHelper()
{
socket = MakeKeepALiveSocket();
client = new TcpClient();
@ -62,6 +63,7 @@ namespace DM_Weight.Port
this.Dispose();
//Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
Thread.Sleep(50);
this.SetModusIpMaster();
// return TimeSpan.FromSeconds (1);
}).Execute<bool[]>(() =>
@ -76,6 +78,7 @@ namespace DM_Weight.Port
flags[i] = r2[17 - i] == '1' ? true : false;
}
logger.Info($"获取所有箱子门状态返回:{string.Join(',',flags)}");
Thread.Sleep(50);
return flags;
});
return bools;
@ -88,6 +91,7 @@ namespace DM_Weight.Port
this.Dispose();
//Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
Thread.Sleep(50);
this.SetModusIpMaster();
//return TimeSpan.FromSeconds (1);
})).Execute(() =>

View File

@ -230,7 +230,7 @@ namespace DM_Weight.Port
logger.Info($"进行抽屉操作抽屉号【{DrawerNo}】类型【{BoardType}】库位【{string.Join(",", ColNos)}】窗口【{WindowName}】");
Operate = true;
//开始录像
_chkFunction.HIKStartDVRRecord();
//_chkFunction.HIKStartDVRRecord();
logger.Info($"时间:{DateTime.Now}");
try
{
@ -683,8 +683,8 @@ namespace DM_Weight.Port
private readonly IEventAggregator _eventAggregator;
private CHKFunction _chkFunction;
public PortUtil(IEventAggregator eventAggregator, CHKFunction chkFunction)
//private CHKFunction _chkFunction;
public PortUtil(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
//try
@ -761,7 +761,7 @@ namespace DM_Weight.Port
{
logger.Error("温湿度串口打开错误" + e.Message);
}
_chkFunction = chkFunction;
//_chkFunction = chkFunction;
}

View File

@ -399,7 +399,7 @@ namespace DM_Weight.ViewModels
//iNumber++;
}
ModbusHelper.GetInstance().GetAllBoxState();
//ModbusHelper.GetInstance().GetAllBoxState();
if (Status == 2)
{
Status = 3;

View File

@ -238,8 +238,111 @@ namespace DM_Weight.ViewModels
_eventAggregator = eventAggregator;
}
private string? _searchValue;
#region
private string _btn1User;
public string Btn1User { get => _btn1User; set => SetProperty(ref _btn1User, value); }
private string _btn2User;
public string Btn2User { get => _btn2User; set => SetProperty(ref _btn2User, value); }
private string _btn3User;
public string Btn3User { get => _btn3User; set => SetProperty(ref _btn3User, value); }
private string _btn4User;
public string Btn4User { get => _btn4User; set => SetProperty(ref _btn4User, value); }
private string _btn5User;
public string Btn5User { get => _btn5User; set => SetProperty(ref _btn5User, value); }
private string _btn6User;
public string Btn6User { get => _btn6User; set => SetProperty(ref _btn6User, value); }
private string _btn7User;
public string Btn7User { get => _btn7User; set => SetProperty(ref _btn7User, value); }
private string _btn8User;
public string Btn8User { get => _btn8User; set => SetProperty(ref _btn8User, value); }
private string _btn9User;
public string Btn9User { get => _btn9User; set => SetProperty(ref _btn9User, value); }
private string _btn10User;
public string Btn10User { get => _btn10User; set => SetProperty(ref _btn10User, value); }
private string _btn11User;
public string Btn11User { get => _btn11User; set => SetProperty(ref _btn11User, value); }
private string _btn12User;
public string Btn12User { get => _btn12User; set => SetProperty(ref _btn12User, value); }
private string _btn13User;
public string Btn13User { get => _btn13User; set => SetProperty(ref _btn13User, value); }
private string _btn14User;
public string Btn14User { get => _btn14User; set => SetProperty(ref _btn14User, value); }
private string _btn15User;
public string Btn15User { get => _btn15User; set => SetProperty(ref _btn15User, value); }
private string _btn16User;
public string Btn16User { get => _btn16User; set => SetProperty(ref _btn16User, value); }
private string _btn17User;
public string Btn17User { get => _btn17User; set => SetProperty(ref _btn17User, value); }
private string _btn18User;
public string Btn18User { get => _btn18User; set => SetProperty(ref _btn18User, value); }
#endregion
#region
private void SetBtnUser(int drawerNo, string name)
{
//查询药箱归属并将名字显示出来
switch (drawerNo)
{
case 1:
Btn1User = name;
break;
case 2:
Btn2User = name;
break;
case 3:
Btn3User = name;
break;
case 4:
Btn4User = name;
break;
case 5:
Btn5User = name;
break;
case 6:
Btn6User = name;
break;
case 7:
Btn7User = name;
break;
case 8:
Btn8User = name;
break;
case 9:
Btn9User = name;
break;
case 10:
Btn10User = name;
break;
case 11:
Btn11User = name;
break;
case 12:
Btn12User = name;
break;
case 13:
Btn13User = name;
break;
case 14:
Btn14User = name;
break;
case 15:
Btn15User = name;
break;
case 16:
Btn16User = name;
break;
case 17:
Btn17User = name;
break;
case 18:
Btn18User = name;
break;
}
}
#endregion
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
@ -716,7 +819,7 @@ namespace DM_Weight.ViewModels
public bool KeepAlive => false;
public async void OpenBoxAction(string strDrawerNo)
public void OpenBoxAction(string strDrawerNo)
{
DrawerNo = Convert.ToInt32(strDrawerNo);
MachineRecord machineRecord = new MachineRecord();
@ -734,7 +837,6 @@ namespace DM_Weight.ViewModels
RequestData();
Status = 1;
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
logger.Info($"正在打开{DrawerNo + 1}号药箱");
//记录开药箱日志
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
@ -744,6 +846,18 @@ namespace DM_Weight.ViewModels
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
List<ChannelList> listCls = SqlSugarHelper.Db.Queryable<ChannelList>()
.LeftJoin<UserList>((cl, ul) => ul.UserBarcode == cl.BelongUser)
.Where(cl => cl.MachineId == "DM5")
.GroupBy(cl=>cl.DrawerNo)
.Select((cl, ul) => new ChannelList { DrawerNo = cl.DrawerNo, BelongUserName = ul.Nickname }).ToList();
if (listCls != null && listCls.Count>0)
{
for (int i = 0; i < listCls.Count; i++)
{
SetBtnUser(listCls[i].DrawerNo, listCls[i].BelongUserName);
}
}
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
}

View File

@ -79,7 +79,7 @@ namespace DM_Weight.ViewModels
//抽屉号列表
public static List<int> iList = new List<int>();
//第几个抽屉号
public static int iNumber = 1;
//public static int iNumber = 1;
private List<OrderDetail> orderDetailList=new();
public List<OrderDetail> OrderDetailList
{
@ -126,13 +126,13 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
}
public DelegateCommand Query
{
@ -184,99 +184,98 @@ namespace DM_Weight.ViewModels
if (iList.Count > 0)
{
_portUtil.SpeakAsync("正在打开药箱");
_portUtil.DrawerNo = iList[iNumber];
iNumber++;
_portUtil.DrawerNo = iList[0];
Status = 1;
_portUtil.OpenBox();
}
}
void DoMyPrismEvent(DeviceMsg msg)
{
switch (msg.EventType)
{
// 药箱打开
case EventType.DRAWEROPEN:
BtnEnable = false;
//记录开药箱日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = _portUtil.DrawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = "药箱打开",
}).ExecuteCommand();
//void DoMyPrismEvent(DeviceMsg msg)
//{
// switch (msg.EventType)
// {
// // 药箱打开
// case EventType.DRAWEROPEN:
// BtnEnable = false;
// //记录开药箱日志
// SqlSugarHelper.Db.Insertable(new MachineRecord()
// {
// MachineId = "DM5",
// DrawerNo = _portUtil.DrawerNo,
// Operator = HomeWindowViewModel.Operator?.Id,
// OperationTime = DateTime.Now,
// Type = 55,
// InvoiceId = "药箱打开",
// }).ExecuteCommand();
if (iNumber < iList.Count)
{
_portUtil.DrawerNo = iList[iNumber];
iNumber++;
if (Status == 1)
{
Status = 2;
}
_portUtil.OpenBox();
}
else
{
iNumber = 0;
_portUtil.GetBoxStatus();
}
break;
// 药箱关闭
case EventType.DRAWERCLOSE:
//记录药箱操作日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = _portUtil.DrawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = "药箱关闭",
}).ExecuteCommand();
// if (iNumber < iList.Count)
// {
// _portUtil.DrawerNo = iList[iNumber];
// iNumber++;
// if (Status == 1)
// {
// Status = 2;
// }
// _portUtil.OpenBox();
// }
// else
// {
// iNumber = 0;
// _portUtil.GetBoxStatus();
// }
// break;
// // 药箱关闭
// case EventType.DRAWERCLOSE:
// //记录药箱操作日志
// SqlSugarHelper.Db.Insertable(new MachineRecord()
// {
// MachineId = "DM5",
// DrawerNo = _portUtil.DrawerNo,
// Operator = HomeWindowViewModel.Operator?.Id,
// OperationTime = DateTime.Now,
// Type = 55,
// InvoiceId = "药箱关闭",
// }).ExecuteCommand();
if (Status == 2)
{
Status = 3;
}
BtnEnable = true;
_portUtil.Operate = false;
// if (Status == 2)
// {
// Status = 3;
// }
// BtnEnable = true;
// _portUtil.Operate = false;
//减库存,生成操作记录
SaveDate();
// //减库存,生成操作记录
// SaveDate();
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// break;
// // 打开失败
// case EventType.OPENERROR:
// AlertMsg alertMsg = new AlertMsg
// {
// Message = msg.Message,
// Type = MsgType.ERROR
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
BtnEnable = true;
Status = 0;
_portUtil.Operate = false;
// BtnEnable = true;
// Status = 0;
// _portUtil.Operate = false;
//记录药箱操作日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = _portUtil.DrawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = "药箱打开失败",
}).ExecuteCommand();
_portUtil.Operate = false;
break;
}
}
// //记录药箱操作日志
// SqlSugarHelper.Db.Insertable(new MachineRecord()
// {
// MachineId = "DM5",
// DrawerNo = _portUtil.DrawerNo,
// Operator = HomeWindowViewModel.Operator?.Id,
// OperationTime = DateTime.Now,
// Type = 55,
// InvoiceId = "药箱打开失败",
// }).ExecuteCommand();
// _portUtil.Operate = false;
// break;
// }
//}
//减库存,生成操作记录
private void SaveDate()
{

View File

@ -344,16 +344,16 @@ namespace DM_Weight.ViewModels
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
public bool KeepAlive => false;
private PortUtil _portUtil;
private CHKFunction _chkFunction;
//private CHKFunction _chkFunction;
IEventAggregator _eventAggregator;
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator, CHKFunction cHKFunction)
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_regionManager = iRegionManager;
_dialogService = dialogService;
_container = container;
this._eventAggregator = eventAggregator;
_chkFunction = cHKFunction;
//_chkFunction = cHKFunction;
}
public DelegateCommand<string> OpenFingerDialog
@ -453,7 +453,7 @@ namespace DM_Weight.ViewModels
// }
//}
//保存温湿度信息
private async void GetWSD(object sender, ElapsedEventArgs e)
private void GetWSD(object sender, ElapsedEventArgs e)
{
TemperatureHumidityInfo temp = _portUtil.GetWSD();
if (temp != null)
@ -568,7 +568,7 @@ namespace DM_Weight.ViewModels
FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
//int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
//if (autoExit > 0)
//{
// System.Timers.Timer timer = new System.Timers.Timer();
@ -623,25 +623,25 @@ namespace DM_Weight.ViewModels
//WDTimer.Enabled = true;
}
#endregion
if (stopRecord > 0)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += (sender, e) =>
{
//if (stopRecord > 0)
//{
// System.Timers.Timer timer = new System.Timers.Timer();
// timer.Interval = 1000;
// timer.Elapsed += (sender, e) =>
// {
//指定时间内无人操作鼠标键盘则停止录像
if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
{
_chkFunction.HIKStopDVRRecord();
}
};
timer.Start();
}
logger.Info($"当前时间:{DateTime.Now}\r\n获取录像机的时间");
//获取录像机的时间
_chkFunction.HIK_DVR_TIME();
_chkFunction.HIKStartDVRRecord();
// //指定时间内无人操作鼠标键盘则停止录像
// if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
// {
// _chkFunction.HIKStopDVRRecord();
// }
// };
// timer.Start();
//}
//logger.Info($"当前时间:{DateTime.Now}\r\n获取录像机的时间");
////获取录像机的时间
//_chkFunction.HIK_DVR_TIME();
//_chkFunction.HIKStartDVRRecord();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
@ -658,7 +658,7 @@ namespace DM_Weight.ViewModels
}
private void SetLoginOut()
{
_chkFunction.HIKStopDVRRecord();
//_chkFunction.HIKStopDVRRecord();
Operator = null;
Reviewer = null;
Application.Current.Dispatcher.Invoke(() =>

View File

@ -65,7 +65,6 @@ namespace DM_Weight.ViewModels
private FingerprintUtil _fingerprintUtil;
private PortUtil _portUtil;
private CHKFunction _chkFunction;
public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
public string Password { get { return password; } set { SetProperty(ref password, value); } }
@ -115,11 +114,10 @@ namespace DM_Weight.ViewModels
// _regionManager = regionManager;
// _eventAggregator = eventAggregator;
//}
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, CHKFunction chcFunction)
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
{
//_fingerprintUtil = fingerprintUtil;
_portUtil = portUtil;
_chkFunction= chcFunction;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
}
@ -259,10 +257,10 @@ _exitCommand ??= new DelegateCommand(Exit);
{
//添加参数,键值对格式
keys.Add("operator", user);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
//}));
}
// 双人登录模式
else
@ -275,10 +273,10 @@ _exitCommand ??= new DelegateCommand(Exit);
keys.Add("reviewer", user);
Reviewer = user;
RaisePropertyChanged("Reviewer");
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
//}));
}
else
@ -299,10 +297,10 @@ _exitCommand ??= new DelegateCommand(Exit);
keys.Add("operator", user);
Operator = user;
RaisePropertyChanged("Operator");
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
//}));
}
else
@ -360,14 +358,14 @@ _exitCommand ??= new DelegateCommand(Exit);
void Exit()
{
_chkFunction.HIKLoginOut();
//_chkFunction.HIKLoginOut();
Process.GetCurrentProcess().Kill();
Environment.Exit(0);
}
void LoginEvent(FingerprintMsg msg)
{
logger.Info(msg.ToString());
logger.Info(msg.ToString()+ "LoginBtnEnable:"+ LoginBtnEnable);
if (msg.Message.Equals("CONNECT"))
{
FingerMsg = !msg.Result;

View File

@ -65,9 +65,9 @@ namespace DM_Weight.ViewModels
private FingerprintUtil _fingerprintUtil;
IRegionManager _regionManager;
IUnityContainer _container;
private CHKFunction _cHKFunction;
//private CHKFunction _cHKFunction;
private readonly ILog logger = LogManager.GetLogger(typeof(PortUtil));
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, CHKFunction cHKFunction)
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil)
{
//_portUtil = portUtil;
this.eventAggregator = eventAggregator;
@ -75,15 +75,15 @@ namespace DM_Weight.ViewModels
_fingerprintUtil = fingerprintUtil;
_regionManager = regionManager;
_container = container;
_cHKFunction = cHKFunction;
//_cHKFunction = cHKFunction;
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_container.RegisterType<object, LoginWindow>("LoginWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
_regionManager.RegisterViewWithRegion("MainRegion", "LoginWindow");
}));
//}));
}

View File

@ -11,6 +11,7 @@ using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Text;
using System.Threading;
@ -42,7 +43,7 @@ namespace DM_Weight.ViewModels
public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); }
//名下药箱按钮显示内容
private string _selfContent="打开药箱";
private string _selfContent = "打开药箱";
public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, value); }
@ -60,8 +61,47 @@ namespace DM_Weight.ViewModels
//名下药箱状态
private int _selfStatus = 0;
public int SelfStatus { get => _selfStatus; set => SetProperty(ref _selfStatus, value); }
#region
private string _btn1User;
public string Btn1User { get => _btn1User; set => SetProperty(ref _btn1User, value); }
private string _btn2User;
public string Btn2User { get => _btn2User; set => SetProperty(ref _btn2User, value); }
private string _btn3User;
public string Btn3User { get => _btn3User; set => SetProperty(ref _btn3User, value); }
private string _btn4User;
public string Btn4User { get => _btn4User; set => SetProperty(ref _btn4User, value); }
private string _btn5User;
public string Btn5User { get => _btn5User; set => SetProperty(ref _btn5User, value); }
private string _btn6User;
public string Btn6User { get => _btn6User; set => SetProperty(ref _btn6User, value); }
private string _btn7User;
public string Btn7User { get => _btn7User; set => SetProperty(ref _btn7User, value); }
private string _btn8User;
public string Btn8User { get => _btn8User; set => SetProperty(ref _btn8User, value); }
private string _btn9User;
public string Btn9User { get => _btn9User; set => SetProperty(ref _btn9User, value); }
private string _btn10User;
public string Btn10User { get => _btn10User; set => SetProperty(ref _btn10User, value); }
private string _btn11User;
public string Btn11User { get => _btn11User; set => SetProperty(ref _btn11User, value); }
private string _btn12User;
public string Btn12User { get => _btn12User; set => SetProperty(ref _btn12User, value); }
private string _btn13User;
public string Btn13User { get => _btn13User; set => SetProperty(ref _btn13User, value); }
private string _btn14User;
public string Btn14User { get => _btn14User; set => SetProperty(ref _btn14User, value); }
private string _btn15User;
public string Btn15User { get => _btn15User; set => SetProperty(ref _btn15User, value); }
private string _btn16User;
public string Btn16User { get => _btn16User; set => SetProperty(ref _btn16User, value); }
private string _btn17User;
public string Btn17User { get => _btn17User; set => SetProperty(ref _btn17User, value); }
private string _btn18User;
public string Btn18User { get => _btn18User; set => SetProperty(ref _btn18User, value); }
#endregion
//抽屉号列表
public static List<ChannelList> iList = new List<ChannelList>();
public static ChannelList iList = new ChannelList();
//第几个抽屉号
//public static int iNumber = 1;
private PortUtil _portUtil;
@ -418,10 +458,74 @@ namespace DM_Weight.ViewModels
break;
}
}
#region
private void SetBtnUser(int drawerNo, string name)
{
//查询药箱归属并将名字显示出来
switch (drawerNo)
{
case 1:
Btn1User = name;
break;
case 2:
Btn2User = name;
break;
case 3:
Btn3User = name;
break;
case 4:
Btn4User = name;
break;
case 5:
Btn5User = name;
break;
case 6:
Btn6User = name;
break;
case 7:
Btn7User = name;
break;
case 8:
Btn8User = name;
break;
case 9:
Btn9User = name;
break;
case 10:
Btn10User = name;
break;
case 11:
Btn11User = name;
break;
case 12:
Btn12User = name;
break;
case 13:
Btn13User = name;
break;
case 14:
Btn14User = name;
break;
case 15:
Btn15User = name;
break;
case 16:
Btn16User = name;
break;
case 17:
Btn17User = name;
break;
case 18:
Btn18User = name;
break;
}
}
#endregion
void RequestData()
{
List<ChannelList> chlList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First();
List<ChannelList> chlList = SqlSugarHelper.Db.Queryable<ChannelList>()
.Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First();
if (chlList != null && chlList.Count > 0)
{
for (int i = 0; i < chlList.Count; i++)
@ -435,8 +539,21 @@ namespace DM_Weight.ViewModels
if (chl.DrawerType == 1)
{
SetBtnEnable(chl.DrawerNo);
SetBtnUser(chl.DrawerNo, "公共药箱");
}
if (!string.IsNullOrEmpty(chl.BelongUser)&& chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode)
else
{
if (chl != null && chl.BelongUser != null)
{
string userName = SqlSugarHelper.Db.Queryable<UserList>().Where(ul => ul.UserBarcode == chl.BelongUser).First().Nickname;
SetBtnUser(chl.DrawerNo, userName);
}
else
{
SetBtnUser(chl.DrawerNo, "");
}
}
if (!string.IsNullOrEmpty(chl.BelongUser) && chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode)
{
SetBtnEnable(chl.DrawerNo);
}
@ -496,40 +613,39 @@ namespace DM_Weight.ViewModels
}
private void SearchBox()
{
iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
.WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).ToList();
iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType && cl.DrawerNo == DrawerNo)
.WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).First();
// .Select(cl => cl.DrawerNo).ToList();
if (iList.Count > 0)
if (iList != null)
{
//_portUtil.SpeakAsync("正在打开药箱");
//_portUtil.DrawerNo = iList[iNumber];
//iNumber++;
//_portUtil.OpenBox();
for (int i = 0; i < iList.Count; i++)
//for (int i = 0; i < iList.Count; i++)
//{
ChannelList channelList = iList;
//记录开药箱日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
ChannelList channelList = iList[i];
//记录开药箱日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = channelList.DrawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = $"打开{iList[i].DrawerNo}号药箱",
OptionType= SelfContent.Substring(0,1)=="取"? 0:1
}).ExecuteCommand();
//记录药箱打开时间
channelList.EffDate = DateTime.Now.ToString();
channelList.DrawerState = SelfContent.Substring(0, 1) == "取" ? 0 : 1;
SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand();
MachineId = "DM5",
DrawerNo = channelList.DrawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = $"打开{DrawerNo}号药箱",
OptionType = SelfContent.Substring(0, 1) == "取" ? 0 : 1
}).ExecuteCommand();
//记录药箱打开时间
channelList.EffDate = DateTime.Now.ToString();
channelList.DrawerState = SelfContent.Substring(0, 1) == "取" ? 0 : 1;
SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand();
_portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱");
logger.Info($"正在打开{channelList.DrawerNo}号药箱");
ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1);
Thread.Sleep(1000);
}
_portUtil.SpeakAsync($"正在打开{DrawerNo}号药箱");
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo - 1);
//Thread.Sleep(1000);
//}
SelfStatus = 0;
PublicEnable = true;

View File

@ -14,6 +14,7 @@
<UserControl.Resources>
<convert:OrderStatusConverter x:Key="OrderStatusConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
<convert:DrawerContentConverter x:Key="DrawerContentConverter" />
<convert:BoxNumConverter x:Key="BoxNumConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<Style x:Key="st" TargetType="GridViewColumnHeader">
@ -74,26 +75,26 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="0" Width="120" Content="1号药箱" Background="{Binding Button1Color}" Command="{Binding UpdateDrawerNo,ConverterParameter=1}" CommandParameter="1" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=0}"/>
<Button Margin="0 0 3 0" Grid.Row="1" Grid.Column="0" Width="120" Content="2号药箱" Background="{Binding Button2Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=1}"/>
<Button Margin="0 0 3 0" Grid.Row="2" Grid.Column="0" Width="120" Content="3号药箱" Background="{Binding Button3Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=2}"/>
<Button Margin="0 0 3 0" Grid.Row="3" Grid.Column="0" Width="120" Content="4号药箱" Background="{Binding Button4Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=3}"/>
<Button Margin="0 0 3 0" Grid.Row="4" Grid.Column="0" Width="120" Content="5号药箱" Background="{Binding Button5Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=4}"/>
<Button Margin="0 0 3 0" Grid.Row="5" Grid.Column="0" Width="120" Content="6号药箱" Background="{Binding Button6Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=5}"/>
<Button Margin="0 0 3 0" Grid.Row="6" Grid.Column="0" Width="120" Content="7号药箱" Background="{Binding Button7Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=6}"/>
<Button Margin="0 0 3 0" Grid.Row="7" Grid.Column="0" Width="120" Content="8号药箱" Background="{Binding Button8Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=7}"/>
<Button Margin="6 0 6 0" Grid.Row="0" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn1User,Converter={StaticResource DrawerContentConverter},ConverterParameter=1号药箱}" Background="{Binding Button1Color}" Command="{Binding UpdateDrawerNo,ConverterParameter=1}" CommandParameter="1" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=0}"/>
<Button Margin="0 0 3 0" Grid.Row="1" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn2User,Converter={StaticResource DrawerContentConverter},ConverterParameter=2号药箱}" Background="{Binding Button2Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=1}"/>
<Button Margin="0 0 3 0" Grid.Row="2" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn3User,Converter={StaticResource DrawerContentConverter},ConverterParameter=3号药箱}" Background="{Binding Button3Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=2}"/>
<Button Margin="0 0 3 0" Grid.Row="3" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn4User,Converter={StaticResource DrawerContentConverter},ConverterParameter=4号药箱}" Background="{Binding Button4Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=3}"/>
<Button Margin="0 0 3 0" Grid.Row="4" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn5User,Converter={StaticResource DrawerContentConverter},ConverterParameter=5号药箱}" Background="{Binding Button5Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=4}"/>
<Button Margin="0 0 3 0" Grid.Row="5" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn6User,Converter={StaticResource DrawerContentConverter},ConverterParameter=6号药箱}" Background="{Binding Button6Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=5}"/>
<Button Margin="0 0 3 0" Grid.Row="6" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn7User,Converter={StaticResource DrawerContentConverter},ConverterParameter=7号药箱}" Background="{Binding Button7Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=6}"/>
<Button Margin="0 0 3 0" Grid.Row="7" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn8User,Converter={StaticResource DrawerContentConverter},ConverterParameter=8号药箱}" Background="{Binding Button8Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=7}"/>
<Button Margin="0 0 3 0" Grid.Row="8" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn9User,Converter={StaticResource DrawerContentConverter},ConverterParameter=9号药箱}" Background="{Binding Button9Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="9" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=8}"/>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn10User,Converter={StaticResource DrawerContentConverter},ConverterParameter=10号药箱}" Background="{Binding Button10Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="10" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=9}"/>
<Button Margin="0 0 3 0" Grid.Row="8" Grid.Column="0" Width="120" Content="9号药箱" Background="{Binding Button9Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="9" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=8}"/>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="1" Width="120" Content="10号药箱" Background="{Binding Button10Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="10" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=9}"/>
<Button Grid.Row="1" Grid.Column="1" Width="120" Content="11号药箱" Background="{Binding Button11Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=10}"/>
<Button Grid.Row="2" Grid.Column="1" Width="120" Content="12号药箱" Background="{Binding Button12Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=11}"/>
<Button Grid.Row="3" Grid.Column="1" Width="120" Content="13号药箱" Background="{Binding Button13Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=12}"/>
<Button Grid.Row="4" Grid.Column="1" Width="120" Content="14号药箱" Background="{Binding Button14Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=13}"/>
<Button Grid.Row="5" Grid.Column="1" Width="120" Content="15号药箱" Background="{Binding Button15Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=14}"/>
<Button Grid.Row="6" Grid.Column="1" Width="120" Content="16号药箱" Background="{Binding Button16Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=15}"/>
<Button Grid.Row="7" Grid.Column="1" Width="120" Content="17号药箱" Background="{Binding Button17Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=16}"/>
<Button Grid.Row="8" Grid.Column="1" Width="120" Content="18号药箱" Background="{Binding Button18Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=17}"/>
<Button Grid.Row="1" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn11User,Converter={StaticResource DrawerContentConverter},ConverterParameter=11号药箱}" Background="{Binding Button11Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=10}"/>
<Button Grid.Row="2" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn12User,Converter={StaticResource DrawerContentConverter},ConverterParameter=12号药箱}" Background="{Binding Button12Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=11}"/>
<Button Grid.Row="3" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn13User,Converter={StaticResource DrawerContentConverter},ConverterParameter=13号药箱}" Background="{Binding Button13Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=12}"/>
<Button Grid.Row="4" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn14User,Converter={StaticResource DrawerContentConverter},ConverterParameter=14号药箱}" Background="{Binding Button14Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=13}"/>
<Button Grid.Row="5" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn15User,Converter={StaticResource DrawerContentConverter},ConverterParameter=15号药箱}" Background="{Binding Button15Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=14}"/>
<Button Grid.Row="6" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn16User,Converter={StaticResource DrawerContentConverter},ConverterParameter=16号药箱}" Background="{Binding Button16Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=15}"/>
<Button Grid.Row="7" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn17User,Converter={StaticResource DrawerContentConverter},ConverterParameter=17号药箱}" Background="{Binding Button17Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=16}"/>
<Button Grid.Row="8" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn18User,Converter={StaticResource DrawerContentConverter},ConverterParameter=18号药箱}" Background="{Binding Button18Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=17}"/>
<!--<Button Grid.Row="8" Grid.Column="1" Width="120" Content="19号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="19" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=19}"/>
<Button Grid.Row="9" Grid.Column="1" Width="120" Content="20号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="20" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=20}"/>-->

View File

@ -1,5 +1,7 @@
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.ViewModels;
using log4net;
using log4net.Repository.Hierarchy;
using Prism.Events;
using System;
@ -27,6 +29,7 @@ namespace DM_Weight.Views
/// </summary>
public partial class HomeWindow : UserControl
{
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
IEventAggregator _eventAggregator;
@ -54,7 +57,7 @@ namespace DM_Weight.Views
// 串口无人操作
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
//logger.Info($"进入自动退出定时方法{allTrue}");
logger.Info($"进入自动退出定时方法{allTrue}");
if (allTrue)
{
idleTimer.Stop();

View File

@ -10,7 +10,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<convert:OrderStatusConverter x:Key="OrderStatusConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
<convert:DrawerContentConverter x:Key="DrawerContentConverter" />
<convert:BoxNumConverter x:Key="BoxNumConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
</UserControl.Resources>
@ -19,19 +19,19 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Margin="6" Grid.Column="0">
<Grid Grid.Column="0">
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
<Style.Triggers>
<!--<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</Trigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DrawerSelectConverter}">
<MultiBinding Converter="{StaticResource DrawerContentConverter}">
<Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
<Binding Path="DrawerNo" />
</MultiBinding>
@ -39,7 +39,7 @@
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</DataTrigger>
</Style.Triggers>
</Style.Triggers>-->
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
@ -58,26 +58,26 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="0" Width="120" Content="1号药箱" Background="{Binding Button1Color}" Command="{Binding UpdateDrawerNo,ConverterParameter=1}" CommandParameter="1" IsEnabled="{Binding Button1Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="1" Grid.Column="0" Width="120" Content="2号药箱" Background="{Binding Button2Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding Button2Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="2" Grid.Column="0" Width="120" Content="3号药箱" Background="{Binding Button3Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding Button3Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="3" Grid.Column="0" Width="120" Content="4号药箱" Background="{Binding Button4Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding Button4Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="4" Grid.Column="0" Width="120" Content="5号药箱" Background="{Binding Button5Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding Button5Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="5" Grid.Column="0" Width="120" Content="6号药箱" Background="{Binding Button6Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding Button6Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="6" Grid.Column="0" Width="120" Content="7号药箱" Background="{Binding Button7Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding Button7Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="7" Grid.Column="0" Width="120" Content="8号药箱" Background="{Binding Button8Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding Button8Enable}"/>
<Button Margin="6 0 6 0" Grid.Row="0" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn1User,Converter={StaticResource DrawerContentConverter},ConverterParameter=1号药箱}" Background="{Binding Button1Color}" Command="{Binding UpdateDrawerNo,ConverterParameter=1}" CommandParameter="1" IsEnabled="{Binding Button1Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="1" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn2User,Converter={StaticResource DrawerContentConverter},ConverterParameter=2号药箱}" Background="{Binding Button2Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding Button2Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="2" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn3User,Converter={StaticResource DrawerContentConverter},ConverterParameter=3号药箱}" Background="{Binding Button3Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding Button3Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="3" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn4User,Converter={StaticResource DrawerContentConverter},ConverterParameter=4号药箱}" Background="{Binding Button4Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding Button4Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="4" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn5User,Converter={StaticResource DrawerContentConverter},ConverterParameter=5号药箱}" Background="{Binding Button5Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding Button5Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="5" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn6User,Converter={StaticResource DrawerContentConverter},ConverterParameter=6号药箱}" Background="{Binding Button6Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding Button6Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="6" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn7User,Converter={StaticResource DrawerContentConverter},ConverterParameter=7号药箱}" Background="{Binding Button7Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding Button7Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="7" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn8User,Converter={StaticResource DrawerContentConverter},ConverterParameter=8号药箱}" Background="{Binding Button8Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding Button8Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="8" Grid.Column="0" Width="180" Height="60" Content="{Binding Btn9User,Converter={StaticResource DrawerContentConverter},ConverterParameter=9号药箱}" Background="{Binding Button9Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="9" IsEnabled="{Binding Button9Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn10User,Converter={StaticResource DrawerContentConverter},ConverterParameter=10号药箱}" Background="{Binding Button10Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="10" IsEnabled="{Binding Button10Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="8" Grid.Column="0" Width="120" Content="9号药箱" Background="{Binding Button9Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="9" IsEnabled="{Binding Button9Enable}"/>
<Button Margin="0 0 3 0" Grid.Row="0" Grid.Column="1" Width="120" Content="10号药箱" Background="{Binding Button10Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="10" IsEnabled="{Binding Button10Enable}"/>
<Button Grid.Row="1" Grid.Column="1" Width="120" Content="11号药箱" Background="{Binding Button11Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding Button11Enable}"/>
<Button Grid.Row="2" Grid.Column="1" Width="120" Content="12号药箱" Background="{Binding Button12Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding Button12Enable}"/>
<Button Grid.Row="3" Grid.Column="1" Width="120" Content="13号药箱" Background="{Binding Button13Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding Button13Enable}"/>
<Button Grid.Row="4" Grid.Column="1" Width="120" Content="14号药箱" Background="{Binding Button14Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding Button14Enable}"/>
<Button Grid.Row="5" Grid.Column="1" Width="120" Content="15号药箱" Background="{Binding Button15Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding Button15Enable}"/>
<Button Grid.Row="6" Grid.Column="1" Width="120" Content="16号药箱" Background="{Binding Button16Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding Button16Enable}"/>
<Button Grid.Row="7" Grid.Column="1" Width="120" Content="17号药箱" Background="{Binding Button17Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding Button17Enable}"/>
<Button Grid.Row="8" Grid.Column="1" Width="120" Content="18号药箱" Background="{Binding Button18Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding Button18Enable}"/>
<Button Grid.Row="1" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn11User,Converter={StaticResource DrawerContentConverter},ConverterParameter=11号药箱}" Background="{Binding Button11Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding Button11Enable}"/>
<Button Grid.Row="2" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn12User,Converter={StaticResource DrawerContentConverter},ConverterParameter=12号药箱}" Background="{Binding Button12Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding Button12Enable}"/>
<Button Grid.Row="3" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn13User,Converter={StaticResource DrawerContentConverter},ConverterParameter=13号药箱}" Background="{Binding Button13Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding Button13Enable}"/>
<Button Grid.Row="4" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn14User,Converter={StaticResource DrawerContentConverter},ConverterParameter=14号药箱}" Background="{Binding Button14Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding Button14Enable}"/>
<Button Grid.Row="5" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn15User,Converter={StaticResource DrawerContentConverter},ConverterParameter=15号药箱}" Background="{Binding Button15Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding Button15Enable}"/>
<Button Grid.Row="6" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn16User,Converter={StaticResource DrawerContentConverter},ConverterParameter=16号药箱}" Background="{Binding Button16Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding Button16Enable}"/>
<Button Grid.Row="7" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn17User,Converter={StaticResource DrawerContentConverter},ConverterParameter=17号药箱}" Background="{Binding Button17Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding Button17Enable}"/>
<Button Grid.Row="8" Grid.Column="1" Width="180" Height="60" Content="{Binding Btn18User,Converter={StaticResource DrawerContentConverter},ConverterParameter=18号药箱}" Background="{Binding Button18Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding Button18Enable}"/>
<!--<Button Grid.Row="8" Grid.Column="1" Width="120" Content="19号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="19" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=19}"/>
<Button Grid.Row="9" Grid.Column="1" Width="120" Content="20号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="20" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=20}"/>-->