2024-09-19 10:28:38 +08:00
|
|
|
|
using DM_Weight.Models;
|
2024-11-28 11:20:50 +08:00
|
|
|
|
using DM_Weight.msg;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
using DM_Weight.Port;
|
|
|
|
|
using DM_Weight.util;
|
|
|
|
|
using log4net;
|
|
|
|
|
using log4net.Repository.Hierarchy;
|
|
|
|
|
using Prism.Commands;
|
|
|
|
|
using Prism.Events;
|
|
|
|
|
using Prism.Mvvm;
|
|
|
|
|
using Prism.Regions;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing.Printing;
|
|
|
|
|
using System.Linq;
|
2024-11-26 15:05:37 +08:00
|
|
|
|
using System.Security.Cryptography;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
using System.Security.Cryptography.Pkcs;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-11-28 11:20:50 +08:00
|
|
|
|
using System.Timers;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
namespace DM_Weight.ViewModels
|
|
|
|
|
{
|
2024-12-21 21:02:52 +08:00
|
|
|
|
public class OpenBoxNewWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
2024-11-28 11:20:50 +08:00
|
|
|
|
//定时查询药箱状态
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//System.Timers.Timer StateTimer = new System.Timers.Timer(5000);
|
|
|
|
|
|
2024-11-28 11:20:50 +08:00
|
|
|
|
|
2024-09-19 10:28:38 +08:00
|
|
|
|
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
|
|
|
|
|
private int _drawerType = -1;
|
|
|
|
|
|
|
|
|
|
public int DrawerType
|
|
|
|
|
{
|
|
|
|
|
get => _drawerType;
|
|
|
|
|
set => SetProperty(ref _drawerType, value);
|
|
|
|
|
}
|
|
|
|
|
//所选药箱号
|
|
|
|
|
private int _drawerNo = -1;
|
|
|
|
|
|
|
|
|
|
public int DrawerNo
|
|
|
|
|
{
|
|
|
|
|
get => _drawerNo;
|
|
|
|
|
set => SetProperty(ref _drawerNo, value);
|
|
|
|
|
}
|
|
|
|
|
//开名下药箱按钮的显示状态
|
|
|
|
|
private bool _selfEnable = false;
|
|
|
|
|
public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); }
|
|
|
|
|
|
|
|
|
|
//名下药箱按钮显示内容
|
2024-11-26 15:05:37 +08:00
|
|
|
|
private string _selfContent = "打开药箱";
|
2024-09-19 10:28:38 +08:00
|
|
|
|
public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, value); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开公共药箱按钮的显示状态
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//private bool _publicEnable = true;
|
|
|
|
|
//public bool PublicEnable { get => _publicEnable; set => SetProperty(ref _publicEnable, value); }
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
|
|
|
|
//公共药箱按钮显示内容
|
|
|
|
|
private string _publicContent;
|
|
|
|
|
public string PublicContent { get => _publicContent; set => SetProperty(ref _publicContent, value); }
|
|
|
|
|
|
|
|
|
|
//公共药箱状态
|
|
|
|
|
//private int _publicStatus = 0;
|
|
|
|
|
//public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); }
|
|
|
|
|
//名下药箱状态
|
|
|
|
|
private int _selfStatus = 0;
|
|
|
|
|
public int SelfStatus { get => _selfStatus; set => SetProperty(ref _selfStatus, value); }
|
2024-11-26 15:05:37 +08:00
|
|
|
|
|
|
|
|
|
#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
|
2024-09-19 10:28:38 +08:00
|
|
|
|
//抽屉号列表
|
2024-11-26 15:05:37 +08:00
|
|
|
|
public static ChannelList iList = new ChannelList();
|
2024-09-19 10:28:38 +08:00
|
|
|
|
//第几个抽屉号
|
|
|
|
|
//public static int iNumber = 1;
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//private PortUtil _portUtil;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
IEventAggregator _eventAggregator;
|
2024-12-16 16:44:02 +08:00
|
|
|
|
SocketHelper _socketHelper;
|
|
|
|
|
public OpenBoxNewWindowViewModel(IEventAggregator eventAggregator, SocketHelper socketHelper)
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
|
|
|
|
_eventAggregator = eventAggregator;
|
2024-12-16 16:44:02 +08:00
|
|
|
|
_socketHelper = socketHelper;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
#region 抽屉按钮
|
|
|
|
|
private Brush _button1Color = Brushes.White;
|
|
|
|
|
public Brush Button1Color
|
|
|
|
|
{
|
|
|
|
|
get => _button1Color;
|
|
|
|
|
set => SetProperty(ref _button1Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button2Color = Brushes.White;
|
|
|
|
|
public Brush Button2Color
|
|
|
|
|
{
|
|
|
|
|
get => _button2Color;
|
|
|
|
|
set => SetProperty(ref _button2Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button3Color = Brushes.White;
|
|
|
|
|
public Brush Button3Color
|
|
|
|
|
{
|
|
|
|
|
get => _button3Color;
|
|
|
|
|
set => SetProperty(ref _button3Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button4Color = Brushes.White;
|
|
|
|
|
public Brush Button4Color
|
|
|
|
|
{
|
|
|
|
|
get => _button4Color;
|
|
|
|
|
set => SetProperty(ref _button4Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button5Color = Brushes.White;
|
|
|
|
|
public Brush Button5Color
|
|
|
|
|
{
|
|
|
|
|
get => _button5Color;
|
|
|
|
|
set => SetProperty(ref _button5Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button6Color = Brushes.White;
|
|
|
|
|
public Brush Button6Color
|
|
|
|
|
{
|
|
|
|
|
get => _button6Color;
|
|
|
|
|
set => SetProperty(ref _button6Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button7Color = Brushes.White;
|
|
|
|
|
public Brush Button7Color
|
|
|
|
|
{
|
|
|
|
|
get => _button7Color;
|
|
|
|
|
set => SetProperty(ref _button7Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button8Color = Brushes.White;
|
|
|
|
|
public Brush Button8Color
|
|
|
|
|
{
|
|
|
|
|
get => _button8Color;
|
|
|
|
|
set => SetProperty(ref _button8Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button9Color = Brushes.White;
|
|
|
|
|
public Brush Button9Color
|
|
|
|
|
{
|
|
|
|
|
get => _button9Color;
|
|
|
|
|
set => SetProperty(ref _button9Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button10Color = Brushes.White;
|
|
|
|
|
public Brush Button10Color
|
|
|
|
|
{
|
|
|
|
|
get => _button10Color;
|
|
|
|
|
set => SetProperty(ref _button10Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button11Color = Brushes.White;
|
|
|
|
|
public Brush Button11Color
|
|
|
|
|
{
|
|
|
|
|
get => _button11Color;
|
|
|
|
|
set => SetProperty(ref _button11Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button12Color = Brushes.White;
|
|
|
|
|
public Brush Button12Color
|
|
|
|
|
{
|
|
|
|
|
get => _button12Color;
|
|
|
|
|
set => SetProperty(ref _button12Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button13Color = Brushes.White;
|
|
|
|
|
public Brush Button13Color
|
|
|
|
|
{
|
|
|
|
|
get => _button13Color;
|
|
|
|
|
set => SetProperty(ref _button13Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button14Color = Brushes.White;
|
|
|
|
|
public Brush Button14Color
|
|
|
|
|
{
|
|
|
|
|
get => _button14Color;
|
|
|
|
|
set => SetProperty(ref _button14Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button15Color = Brushes.White;
|
|
|
|
|
public Brush Button15Color
|
|
|
|
|
{
|
|
|
|
|
get => _button15Color;
|
|
|
|
|
set => SetProperty(ref _button15Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button16Color = Brushes.White;
|
|
|
|
|
public Brush Button16Color
|
|
|
|
|
{
|
|
|
|
|
get => _button16Color;
|
|
|
|
|
set => SetProperty(ref _button16Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button17Color = Brushes.White;
|
|
|
|
|
public Brush Button17Color
|
|
|
|
|
{
|
|
|
|
|
get => _button17Color;
|
|
|
|
|
set => SetProperty(ref _button17Color, value);
|
|
|
|
|
}
|
|
|
|
|
private Brush _button18Color = Brushes.White;
|
|
|
|
|
public Brush Button18Color
|
|
|
|
|
{
|
|
|
|
|
get => _button18Color;
|
|
|
|
|
set => SetProperty(ref _button18Color, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _button1Enable = false;
|
|
|
|
|
public bool Button1Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button1Enable;
|
|
|
|
|
set => SetProperty(ref _button1Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button2Enable = false;
|
|
|
|
|
public bool Button2Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button2Enable;
|
|
|
|
|
set => SetProperty(ref _button2Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button3Enable = false;
|
|
|
|
|
public bool Button3Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button3Enable;
|
|
|
|
|
set => SetProperty(ref _button3Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button4Enable = false;
|
|
|
|
|
public bool Button4Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button4Enable;
|
|
|
|
|
set => SetProperty(ref _button4Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button5Enable = false;
|
|
|
|
|
public bool Button5Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button5Enable;
|
|
|
|
|
set => SetProperty(ref _button5Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button6Enable = false;
|
|
|
|
|
public bool Button6Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button6Enable;
|
|
|
|
|
set => SetProperty(ref _button6Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button7Enable = false;
|
|
|
|
|
public bool Button7Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button7Enable;
|
|
|
|
|
set => SetProperty(ref _button7Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button8Enable = false;
|
|
|
|
|
public bool Button8Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button8Enable;
|
|
|
|
|
set => SetProperty(ref _button8Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button9Enable = false;
|
|
|
|
|
public bool Button9Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button9Enable;
|
|
|
|
|
set => SetProperty(ref _button9Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button10Enable = false;
|
|
|
|
|
public bool Button10Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button10Enable;
|
|
|
|
|
set => SetProperty(ref _button10Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button11Enable = false;
|
|
|
|
|
public bool Button11Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button11Enable;
|
|
|
|
|
set => SetProperty(ref _button11Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button12Enable = false;
|
|
|
|
|
public bool Button12Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button12Enable;
|
|
|
|
|
set => SetProperty(ref _button12Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button13Enable = false;
|
|
|
|
|
public bool Button13Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button13Enable;
|
|
|
|
|
set => SetProperty(ref _button13Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button14Enable = false;
|
|
|
|
|
public bool Button14Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button14Enable;
|
|
|
|
|
set => SetProperty(ref _button14Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button15Enable = false;
|
|
|
|
|
public bool Button15Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button15Enable;
|
|
|
|
|
set => SetProperty(ref _button15Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button16Enable = false;
|
|
|
|
|
public bool Button16Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button16Enable;
|
|
|
|
|
set => SetProperty(ref _button16Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button17Enable = false;
|
|
|
|
|
public bool Button17Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button17Enable;
|
|
|
|
|
set => SetProperty(ref _button17Enable, value);
|
|
|
|
|
}
|
|
|
|
|
private bool _button18Enable = false;
|
|
|
|
|
public bool Button18Enable
|
|
|
|
|
{
|
|
|
|
|
get => _button18Enable;
|
|
|
|
|
set => SetProperty(ref _button18Enable, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
public bool KeepAlive => false;
|
|
|
|
|
//设置按钮颜色
|
|
|
|
|
private void SetBtnColor(int drawerNo)
|
|
|
|
|
{
|
|
|
|
|
switch (drawerNo)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
Button1Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
Button2Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
Button3Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
Button4Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
Button5Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
Button6Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
Button7Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
Button8Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
Button9Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
2024-11-05 08:49:56 +08:00
|
|
|
|
Button10Color = Brushes.Yellow;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
break;
|
|
|
|
|
case 11:
|
2024-11-05 08:49:56 +08:00
|
|
|
|
Button11Color = Brushes.Yellow;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
Button12Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
Button13Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
Button14Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
Button15Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
Button16Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
Button17Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
Button18Color = Brushes.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//设置按钮可用状态
|
|
|
|
|
private void SetBtnEnable(int drawerNo)
|
|
|
|
|
{
|
|
|
|
|
switch (drawerNo)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
Button1Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
Button2Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
Button3Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
Button4Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
Button5Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
Button6Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
Button7Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
Button8Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
Button9Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
Button10Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
Button11Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
Button12Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
Button13Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
Button14Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
Button15Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
Button16Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
Button17Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
Button18Enable = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-26 15:05:37 +08:00
|
|
|
|
#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;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2024-11-26 15:05:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2024-09-19 10:28:38 +08:00
|
|
|
|
void RequestData()
|
|
|
|
|
{
|
2024-11-26 15:05:37 +08:00
|
|
|
|
List<ChannelList> chlList = SqlSugarHelper.Db.Queryable<ChannelList>()
|
|
|
|
|
.Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First();
|
2024-09-19 10:28:38 +08:00
|
|
|
|
if (chlList != null && chlList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < chlList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ChannelList chl = chlList[i];
|
2024-12-21 21:02:52 +08:00
|
|
|
|
if (chl != null && chl.EffDate != null)
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
|
|
|
|
SetBtnColor(chl.DrawerNo);
|
|
|
|
|
}
|
|
|
|
|
//DrawerType== 1为公共药箱
|
|
|
|
|
if (chl.DrawerType == 1)
|
|
|
|
|
{
|
|
|
|
|
SetBtnEnable(chl.DrawerNo);
|
2024-11-26 15:05:37 +08:00
|
|
|
|
SetBtnUser(chl.DrawerNo, "公共药箱");
|
|
|
|
|
}
|
|
|
|
|
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, "");
|
|
|
|
|
}
|
2024-09-19 10:28:38 +08:00
|
|
|
|
}
|
2024-11-26 15:05:37 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(chl.BelongUser) && chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode)
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
|
|
|
|
SetBtnEnable(chl.DrawerNo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择药箱,打开药箱
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DelegateCommand<string> UpdateDrawerNo
|
|
|
|
|
{
|
|
|
|
|
get => new DelegateCommand<string>(OpenBoxAction);
|
|
|
|
|
}
|
2024-11-28 11:20:50 +08:00
|
|
|
|
public void OpenBoxAction(string strDrawerNo)
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
|
|
|
|
DrawerNo = Convert.ToInt32(strDrawerNo);
|
|
|
|
|
DrawerType = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == Convert.ToInt32(strDrawerNo)).Select(cl => cl.DrawerType).First();
|
|
|
|
|
SelfEnable = true;
|
|
|
|
|
//int listSelfState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
|
|
|
|
|
// .WhereIf(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
|
|
|
|
|
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//int listDrawerState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
|
|
|
|
|
// .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
|
|
|
|
|
//if (DrawerType == 1) //公共药箱
|
|
|
|
|
//{
|
|
|
|
|
// if (listDrawerState == 0)
|
|
|
|
|
// {
|
|
|
|
|
// SelfContent = "还公共药箱";
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// SelfContent = "取公共药箱";
|
|
|
|
|
// }
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// if (listDrawerState == 0)
|
|
|
|
|
// {
|
|
|
|
|
// SelfContent = "还名下药箱";
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// SelfContent = "取名下药箱";
|
|
|
|
|
// }
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//}
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public DelegateCommand<string> OpenBoxDelegate
|
|
|
|
|
{
|
|
|
|
|
get => new DelegateCommand<string>((DrawerType) =>
|
|
|
|
|
{
|
|
|
|
|
SearchBox();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
private void SearchBox()
|
|
|
|
|
{
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//bool[] bools = ModbusHelper.GetInstance().GetAllBoxState();
|
|
|
|
|
//bool allFalse = Array.TrueForAll(bools, b => b == false);
|
|
|
|
|
//if (!allFalse)
|
2024-12-16 16:44:02 +08:00
|
|
|
|
if (_socketHelper.OpenStatus)
|
2024-12-06 17:51:01 +08:00
|
|
|
|
{
|
2025-01-04 11:32:32 +08:00
|
|
|
|
_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
|
|
|
|
|
_socketHelper.speechSynthesizer.Resume();
|
|
|
|
|
_socketHelper.SpeakAsync("请关闭药箱后再打开");
|
2024-12-06 17:51:01 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-26 15:05:37 +08:00
|
|
|
|
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();
|
2024-09-19 10:28:38 +08:00
|
|
|
|
// .Select(cl => cl.DrawerNo).ToList();
|
2024-11-26 15:05:37 +08:00
|
|
|
|
if (iList != null)
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
|
|
|
|
//_portUtil.SpeakAsync("正在打开药箱");
|
|
|
|
|
//_portUtil.DrawerNo = iList[iNumber];
|
|
|
|
|
//iNumber++;
|
|
|
|
|
//_portUtil.OpenBox();
|
|
|
|
|
|
2024-11-26 15:05:37 +08:00
|
|
|
|
//for (int i = 0; i < iList.Count; i++)
|
|
|
|
|
//{
|
|
|
|
|
ChannelList channelList = iList;
|
|
|
|
|
//记录开药箱日志
|
|
|
|
|
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
2024-09-19 10:28:38 +08:00
|
|
|
|
{
|
2024-11-26 15:05:37 +08:00
|
|
|
|
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();
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2025-01-04 11:32:32 +08:00
|
|
|
|
//ModbusHelper.SpeakAsync($"正在打开{DrawerNo}号药箱");
|
|
|
|
|
_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
|
|
|
|
|
_socketHelper.speechSynthesizer.Resume();
|
|
|
|
|
_socketHelper.SpeakAsync($"正在打开{DrawerNo}号药箱");
|
2024-12-21 21:02:52 +08:00
|
|
|
|
|
|
|
|
|
try
|
2024-11-28 11:20:50 +08:00
|
|
|
|
{
|
2025-01-02 15:59:03 +08:00
|
|
|
|
logger.Info($"发送开{DrawerNo}号药箱指令");
|
2024-12-21 21:02:52 +08:00
|
|
|
|
_socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
|
2024-12-23 09:52:48 +08:00
|
|
|
|
_socketHelper.dateTime = DateTime.Now;
|
2025-01-02 15:59:03 +08:00
|
|
|
|
logger.Info($"发开{DrawerNo}号药箱指令完成");
|
2024-12-21 21:02:52 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AlertMsg alertMsg = new AlertMsg
|
|
|
|
|
{
|
2025-01-15 18:52:59 +08:00
|
|
|
|
Message = $"网口连接异常,开药箱正在重试{ex.Message}",
|
2024-12-21 21:02:52 +08:00
|
|
|
|
Type = MsgType.ERROR,
|
|
|
|
|
};
|
|
|
|
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
|
|
|
|
return;
|
2024-11-28 11:20:50 +08:00
|
|
|
|
}
|
2024-12-16 16:44:02 +08:00
|
|
|
|
_socketHelper.OpenStatus = true;
|
2024-12-21 21:02:52 +08:00
|
|
|
|
//_socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
|
|
|
|
|
//_socketHelper.OpenStatus = true;
|
|
|
|
|
|
|
|
|
|
//int i = 10;
|
|
|
|
|
//new PromiseUtil<int>().taskAsyncLoop(500, 0, async (options, next, stop) =>
|
|
|
|
|
//{
|
|
|
|
|
// i--;
|
|
|
|
|
// if (_socketHelper.OpenStatus)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
|
|
|
|
// _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
|
2024-12-06 17:51:01 +08:00
|
|
|
|
|
2024-12-21 21:02:52 +08:00
|
|
|
|
// //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
|
|
|
|
|
// //bool state = Array.TrueForAll(boolsl, b => b == false);
|
|
|
|
|
// if (_socketHelper.OpenStatus)
|
|
|
|
|
// {
|
|
|
|
|
// if (i == 0)
|
|
|
|
|
// {
|
|
|
|
|
// ModbusHelper.SpeakAsync("请及时关闭药箱");
|
|
|
|
|
// i = 10;
|
|
|
|
|
// }
|
|
|
|
|
// next();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// stop();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// stop();
|
|
|
|
|
// }
|
|
|
|
|
//});
|
2024-12-27 18:43:29 +08:00
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
int i = 80;
|
2024-12-23 09:52:48 +08:00
|
|
|
|
int iException = 0;
|
2024-12-27 18:43:29 +08:00
|
|
|
|
new PromiseUtil<int>().taskAsyncLoop(100, 0, async (options, next, stop) =>
|
2024-12-06 17:51:01 +08:00
|
|
|
|
{
|
2024-12-21 21:02:52 +08:00
|
|
|
|
_socketHelper.IsMultiThread = true;
|
|
|
|
|
try
|
2024-12-06 17:51:01 +08:00
|
|
|
|
{
|
2024-12-16 16:44:02 +08:00
|
|
|
|
|
2024-12-21 21:02:52 +08:00
|
|
|
|
i--;
|
2024-12-16 16:44:02 +08:00
|
|
|
|
if (_socketHelper.OpenStatus)
|
2024-12-06 17:51:01 +08:00
|
|
|
|
{
|
2024-12-21 21:02:52 +08:00
|
|
|
|
|
|
|
|
|
//bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
|
|
|
|
_socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
|
|
|
|
|
|
|
|
|
|
//ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
|
|
|
|
|
//bool state = Array.TrueForAll(boolsl, b => b == false);
|
|
|
|
|
if (_socketHelper.OpenStatus)
|
|
|
|
|
{
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
2025-01-04 11:32:32 +08:00
|
|
|
|
_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
|
|
|
|
|
_socketHelper.speechSynthesizer.Resume();
|
|
|
|
|
_socketHelper.SpeakAsync("请及时关闭药箱");
|
2024-12-27 18:43:29 +08:00
|
|
|
|
i = 80;
|
2024-12-21 21:02:52 +08:00
|
|
|
|
}
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-12-16 16:44:02 +08:00
|
|
|
|
{
|
2024-12-23 09:52:48 +08:00
|
|
|
|
_socketHelper.IsMultiThread = false;
|
2025-01-04 11:32:32 +08:00
|
|
|
|
_socketHelper.dateTime = DateTime.Now;
|
2024-12-27 14:58:08 +08:00
|
|
|
|
//_socketHelper.OpenStatus = false;
|
2024-12-21 21:02:52 +08:00
|
|
|
|
stop();
|
2024-12-16 16:44:02 +08:00
|
|
|
|
}
|
2024-12-06 17:51:01 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-12-21 21:02:52 +08:00
|
|
|
|
_socketHelper.IsMultiThread = false;
|
2024-12-23 09:52:48 +08:00
|
|
|
|
_socketHelper.dateTime = DateTime.Now;
|
2024-12-27 14:58:08 +08:00
|
|
|
|
//_socketHelper.OpenStatus = false;
|
2024-12-16 16:44:02 +08:00
|
|
|
|
stop();
|
2024-12-06 17:51:01 +08:00
|
|
|
|
}
|
2024-12-23 09:52:48 +08:00
|
|
|
|
iException = 0;
|
2024-12-06 17:51:01 +08:00
|
|
|
|
}
|
2024-12-21 21:02:52 +08:00
|
|
|
|
catch (Exception ex)
|
2024-12-16 16:44:02 +08:00
|
|
|
|
{
|
2024-12-23 09:52:48 +08:00
|
|
|
|
iException++;
|
|
|
|
|
if (iException >= 3)
|
|
|
|
|
{
|
|
|
|
|
_socketHelper.OpenStatus = false;
|
|
|
|
|
}
|
2024-12-21 21:02:52 +08:00
|
|
|
|
AlertMsg alertMsg = new AlertMsg
|
|
|
|
|
{
|
2025-01-15 18:52:59 +08:00
|
|
|
|
Message = $"网口连接异常,查状态正在重试{ex.Message}",
|
2024-12-21 21:02:52 +08:00
|
|
|
|
Type = MsgType.ERROR,
|
|
|
|
|
};
|
|
|
|
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
2025-01-15 18:52:59 +08:00
|
|
|
|
logger.Info($"网口连接异常,查状态正在重试{ex.Message}");
|
2024-12-23 09:52:48 +08:00
|
|
|
|
next();
|
2024-12-16 16:44:02 +08:00
|
|
|
|
}
|
2024-12-06 17:51:01 +08:00
|
|
|
|
});
|
|
|
|
|
//StateTimer.Start();
|
2024-09-19 10:28:38 +08:00
|
|
|
|
SelfStatus = 0;
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//PublicEnable = true;
|
|
|
|
|
//SelfEnable = true;
|
2024-12-21 21:02:52 +08:00
|
|
|
|
//DrawerType = -1;
|
2024-09-19 10:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-06 17:51:01 +08:00
|
|
|
|
//private void OnTimerElapsed(object sender, ElapsedEventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
|
|
|
|
// bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
|
|
|
|
|
// logger.Info($"进入定时查询状态方法{allTrue}");
|
|
|
|
|
// if (allTrue)
|
|
|
|
|
// {
|
|
|
|
|
// //药箱全部关闭,停止查询
|
|
|
|
|
// StateTimer.Stop();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// _portUtil.SpeakAsync("药箱已打开,请及时关闭");
|
|
|
|
|
// //Console.Beep(800, 1100);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2024-12-16 16:44:02 +08:00
|
|
|
|
//void DoMyPrismEvent(DeviceMsg msg)
|
|
|
|
|
//{
|
|
|
|
|
// switch (msg.EventType)
|
|
|
|
|
// {
|
|
|
|
|
// case EventType.DRAWERCLOSE:
|
|
|
|
|
// SelfEnable = false;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2024-12-21 21:02:52 +08:00
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
|
|
{
|
|
|
|
|
// _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
|
|
|
|
|
RequestData();
|
|
|
|
|
}
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2024-12-21 21:02:52 +08:00
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-09-19 10:28:38 +08:00
|
|
|
|
|
2024-12-21 21:02:52 +08:00
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
|
|
{
|
|
|
|
|
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
|
|
|
|
|
}
|
2024-09-19 10:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|