交接柜补药添加批次信息;开药箱流程调整;添加登录设置
This commit is contained in:
parent
a60c914fc5
commit
fe12169e25
|
@ -30,10 +30,14 @@ namespace DM_Weight.Converter
|
|||
{
|
||||
return "未取药";
|
||||
}
|
||||
else
|
||||
if(status == 1)
|
||||
{
|
||||
return "已取药待入库";
|
||||
}
|
||||
if(status==2)
|
||||
{
|
||||
return "正在入库";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -85,12 +85,17 @@ namespace DM_Weight.Models
|
|||
///</summary>
|
||||
[SugarColumn(ColumnName = "board_type")]
|
||||
public int BoardType { get; set; }
|
||||
private int? _state = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// 默认值: 1(用于标识毒麻柜是否给交接柜补药:0未补,1已补)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "state")]
|
||||
public int? State { get; set; }
|
||||
public int? State
|
||||
{
|
||||
get => _state;
|
||||
set { SetProperty(ref _state, value); }
|
||||
}
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool IsSelected { get; set; }
|
||||
|
@ -208,5 +213,11 @@ namespace DM_Weight.Models
|
|||
[SugarColumn(IsIgnore =true)]
|
||||
public string OrderNos { get; set; }
|
||||
|
||||
//交接柜加药数量
|
||||
[SugarColumn(ColumnName = "col_no1")]
|
||||
public int AddToJJNum { get; set; }
|
||||
//需要加药数量
|
||||
[SugarColumn(ColumnName = "col_no2")]
|
||||
public int NeedNum { get; set; }
|
||||
}
|
||||
}
|
|
@ -11,46 +11,45 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Speech.Synthesis;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DM_Weight.Port
|
||||
{
|
||||
public class ModbusHelper
|
||||
{
|
||||
private static ModbusHelper instance;
|
||||
private ModbusIpMaster master;
|
||||
private Socket socket;
|
||||
private TcpClient client;
|
||||
private static ModbusHelper instance;
|
||||
private static readonly object objLock = new object();
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
|
||||
public static bool BoxOperate { get; set; }
|
||||
public ModbusHelper()
|
||||
{
|
||||
if (ConfigurationManager.AppSettings["test"] == null || !(ConfigurationManager.AppSettings["test"].ToString().Equals("Y")))
|
||||
{
|
||||
socket = MakeKeepALiveSocket();
|
||||
client = new TcpClient();
|
||||
client.Client = socket;
|
||||
master = ModbusIpMaster.CreateIp(client);
|
||||
}
|
||||
|
||||
}
|
||||
public static ModbusHelper GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
lock (objLock)
|
||||
{
|
||||
if (instance == null)
|
||||
//lock (objLock)
|
||||
//{
|
||||
// if (instance == null)
|
||||
instance = new ModbusHelper();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
private void SetModusIpMaster()
|
||||
{
|
||||
Debug.WriteLine("SetModusIpMaster");
|
||||
logger.Info("SetModusIpMaster");
|
||||
socket = MakeKeepALiveSocket();
|
||||
client = new TcpClient();
|
||||
client.Client = socket;
|
||||
|
@ -59,25 +58,28 @@ namespace DM_Weight.Port
|
|||
|
||||
public bool[] GetAllBoxState()
|
||||
{
|
||||
if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
|
||||
{
|
||||
return new bool[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };
|
||||
}
|
||||
bool[] bools = Policy.Handle<Exception>()
|
||||
.Retry(3, (exception, retryCount) =>
|
||||
{
|
||||
this.Dispose();
|
||||
//Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
|
||||
logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
|
||||
|
||||
Thread.Sleep(50);
|
||||
BoxOperate = false;
|
||||
this.SetModusIpMaster();
|
||||
// return TimeSpan.FromSeconds (1);
|
||||
}).Execute<bool[]>(() =>
|
||||
{
|
||||
bool[] flags = new bool[18];
|
||||
if (master == null)
|
||||
{
|
||||
this.SetModusIpMaster();
|
||||
}
|
||||
var result = master.ReadInputRegisters(1, 0x0033, 2);
|
||||
var r1 = Convert.ToString(((int)result[0] >> 14) | ((int)result[1] << 2), 2).PadLeft(18, '0');
|
||||
var r2 = r1.ToCharArray();
|
||||
Debug.WriteLine("r2=>" + string.Join(", ", r2));
|
||||
logger.Info("r2=>" + string.Join(", ", r2));
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
flags[i] = r2[17 - i] == '1' ? true : false;
|
||||
|
@ -89,16 +91,15 @@ namespace DM_Weight.Port
|
|||
}
|
||||
public bool OpenBoxDoor(int boxNum)
|
||||
{
|
||||
if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
BoxOperate = true;
|
||||
bool bFlag = false;
|
||||
Thread.Sleep(50);
|
||||
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
|
||||
{
|
||||
this.Dispose();
|
||||
//Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
|
||||
logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
|
||||
Thread.Sleep(50);
|
||||
this.SetModusIpMaster();
|
||||
//return TimeSpan.FromSeconds (1);
|
||||
})).Execute(() =>
|
||||
|
@ -145,5 +146,10 @@ namespace DM_Weight.Port
|
|||
});
|
||||
return _socket;
|
||||
}
|
||||
private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
|
||||
public static void SpeakAsync(string textinfo)
|
||||
{
|
||||
speechSynthesizer.SpeakAsync(textinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,18 +71,19 @@ namespace DM_Weight.ViewModels
|
|||
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Includes<ChannelList>(cs => cs.ChannelLst)
|
||||
.Includes<DrugInfo>(cs => cs.DrugInfo)
|
||||
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
|
||||
.OrderBy(cs => cs.Chnguid)
|
||||
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.AddToJJNum > 0)
|
||||
|
||||
.OrderBy(cs => cs.DrawerNo)
|
||||
.OrderBy(cs => cs.DrugId)
|
||||
.ToList();
|
||||
ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
|
||||
.Select(it=>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
|
||||
//ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
|
||||
// .Select(it=>
|
||||
// {
|
||||
// var ret = it.First();
|
||||
// ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
// return ret;
|
||||
// }).ToList();
|
||||
//ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
|
||||
}
|
||||
//开药箱放入药品
|
||||
public DelegateCommand OpenBoxCommand
|
||||
|
@ -92,12 +93,25 @@ namespace DM_Weight.ViewModels
|
|||
selectedStock = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
|
||||
if (selectedStock != null && selectedStock.Count > 0)
|
||||
{
|
||||
selectedStock.ForEach(cs => cs.ChannelLst.State = 2);
|
||||
|
||||
int drawerNo = 0;
|
||||
for (int i = 0; i < selectedStock.Count; i++)
|
||||
{
|
||||
if (!(drawerNo == selectedStock[i].DrawerNo))
|
||||
{
|
||||
drawerNo = selectedStock[i].DrawerNo;
|
||||
|
||||
// 保存数据 入库记录
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
{
|
||||
MachineId = "DM5",
|
||||
DrawerNo = drawerNo,
|
||||
Operator = HomeWindowViewModel.Operator?.Id,
|
||||
OperationTime = DateTime.Now,
|
||||
Type = 55,
|
||||
InvoiceId = "药箱补药",
|
||||
}).ExecuteCommand();
|
||||
_portUtil.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号药箱");
|
||||
}
|
||||
ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
|
||||
|
@ -127,21 +141,32 @@ namespace DM_Weight.ViewModels
|
|||
//更新 交接柜 库存信息
|
||||
if (selectedStock != null && selectedStock.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < selectedStock.Count; j++)
|
||||
//for (int j = 0; j < selectedStock.Count; j++)
|
||||
//{
|
||||
|
||||
// // 更新数据 交接柜 库存信息
|
||||
// ChannelStock jiaojie_it = selectedStock[j];
|
||||
// jiaojie_it.Quantity = jiaojie_it.AddToJJNum;
|
||||
// jiaojie_it.NeedNum = 0;
|
||||
// jiaojie_it.AddToJJNum = 0;
|
||||
//SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
//{
|
||||
// Quantity = jiaojie_it.AddToJJNum,
|
||||
// ManuNo = jiaojie_it.ManuNo,
|
||||
// //EffDate = it.EffDate,
|
||||
// //Id = jiaojie_it.Id,
|
||||
// DrugId=jiaojie_it.DrugId,
|
||||
// DrawerNo=jiaojie_it.DrawerNo,
|
||||
// MachineId=jiaojie_it.MachineId,
|
||||
//}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
|
||||
//}
|
||||
selectedStock.ForEach(cs =>
|
||||
{
|
||||
// 更新数据 交接柜 库存信息
|
||||
ChannelStock jiaojie_it = selectedStock[j];
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
Quantity = jiaojie_it.BaseQuantity,
|
||||
//ManuNo = it.ManuNo,
|
||||
//EffDate = it.EffDate,
|
||||
//Id = jiaojie_it.Id,
|
||||
DrugId=jiaojie_it.DrugId,
|
||||
DrawerNo=jiaojie_it.DrawerNo,
|
||||
MachineId=jiaojie_it.MachineId,
|
||||
}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
|
||||
}
|
||||
cs.Quantity = cs.AddToJJNum;
|
||||
cs.NeedNum= 0;
|
||||
cs.AddToJJNum = 0;
|
||||
});
|
||||
SqlSugarHelper.Db.Updateable(selectedStock).ExecuteCommand();
|
||||
|
||||
List<ChannelStock> jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList();
|
||||
if (jiaojie != null && jiaojie.Count > 0)
|
||||
|
@ -152,7 +177,7 @@ namespace DM_Weight.ViewModels
|
|||
ChannelList jiaojieList = new ChannelList();
|
||||
jiaojieList.State = 0;
|
||||
jiaojieList.Id = jiaojie_it.ChannelLst.Id;
|
||||
//更新交接柜状态为 已取药未入库
|
||||
//更新交接柜状态为0
|
||||
var result = SqlSugarHelper.Db.Updateable(jiaojieList)
|
||||
.UpdateColumns(it => new { it.State, it.Id }).ExecuteCommand();
|
||||
}
|
||||
|
|
|
@ -124,9 +124,15 @@ namespace DM_Weight.ViewModels
|
|||
.Includes(cs => cs.DrugInfo)
|
||||
.Where(cs => cs.MachineId.Equals("DM5"))
|
||||
.Where(cs => cs.DrawerNo == DrawerNo).ToList();
|
||||
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
Channels = list;
|
||||
Channels=list.GroupBy(cs =>cs.DrugId).Select(cs =>
|
||||
{
|
||||
var ret = cs.First();
|
||||
ret.Quantity = cs.Sum(itx => itx.Quantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -212,7 +218,9 @@ namespace DM_Weight.ViewModels
|
|||
DrugId = DrugInfo.DrugId.ToString(),
|
||||
BaseQuantity = baseQuantity,
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
MachineId = "DM5"
|
||||
MachineId = "DM5",
|
||||
AddToJJNum=0,
|
||||
NeedNum=baseQuantity
|
||||
}).ExecuteCommand();
|
||||
// 保存数据 入库记录
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace DM_Weight.ViewModels
|
|||
public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
|
||||
{
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
|
||||
System.Timers.Timer CheckBoxStatusTimer;
|
||||
// System.Timers.Timer CheckBoxStatusTimer;
|
||||
|
||||
private int _pageNum = 1;
|
||||
public int PageNum
|
||||
|
@ -50,7 +50,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private int _pageSize = 10;
|
||||
private int _pageSize = 8;
|
||||
public int PageSize
|
||||
{
|
||||
get => _pageSize;
|
||||
|
@ -334,7 +334,7 @@ namespace DM_Weight.ViewModels
|
|||
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
|
||||
if (Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
|
||||
{
|
||||
switch (DrawerNo)
|
||||
switch (DrawerNo+1)
|
||||
{
|
||||
case 1:
|
||||
_button1Color = Brushes.Yellow;
|
||||
|
@ -560,8 +560,9 @@ namespace DM_Weight.ViewModels
|
|||
continue;
|
||||
}
|
||||
cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
|
||||
cs.NeedNum =cs.NeedNum + oi._OrderDetail.Quantity;
|
||||
// 更新数据 库存信息
|
||||
SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
|
||||
SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity,it.NeedNum }).ExecuteCommand();
|
||||
|
||||
if (cs != null)
|
||||
{
|
||||
|
@ -710,11 +711,11 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = $"所选单子中对应药品批次效期无效{empChannelStock}",
|
||||
Message = $"所选单子中对应药品批次无效{empChannelStock}",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
logger.Info($"所选单子对应药品批次效期无效{empChannelStock}");
|
||||
logger.Info($"所选单子对应药品批次无效{empChannelStock}");
|
||||
throw new Exception("事务回滚");
|
||||
}
|
||||
return true;
|
||||
|
@ -762,8 +763,13 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
public bool KeepAlive => false;
|
||||
|
||||
public async void OpenBoxAction(string strDrawerNo)
|
||||
public void OpenBoxAction(string strDrawerNo)
|
||||
{
|
||||
if (ModbusHelper.BoxOperate)
|
||||
{
|
||||
Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
|
||||
return;
|
||||
}
|
||||
DrawerNo = Convert.ToInt32(strDrawerNo);
|
||||
MachineRecord machineRecord = new MachineRecord();
|
||||
machineRecord.MachineId = "DM5";
|
||||
|
@ -774,28 +780,38 @@ namespace DM_Weight.ViewModels
|
|||
machineRecord.InvoiceId = $"打开{DrawerNo + 1}号药箱";
|
||||
|
||||
|
||||
if (DrawerNo > 0)
|
||||
if (DrawerNo >= 0)
|
||||
{
|
||||
RequestData();
|
||||
Status = 1;
|
||||
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
|
||||
ModbusHelper.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
|
||||
//logger.Info($"正在打开{DrawerNo + 1}号药箱");
|
||||
//记录开药箱日志
|
||||
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
|
||||
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
|
||||
//设置对应药箱按钮可用状态
|
||||
SetIsEnableStatus(DrawerNo, false);
|
||||
//SetIsEnableStatus(DrawerNo, false);
|
||||
//_eventAggregator.GetEvent<BoxOpenStatusEvent>().Publish();
|
||||
if (CheckBoxStatusTimer is null)
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
CheckBoxStatusTimer = new System.Timers.Timer();
|
||||
}
|
||||
if (!CheckBoxStatusTimer.Enabled)
|
||||
bool loop = true;
|
||||
while (loop)
|
||||
{
|
||||
CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
|
||||
CheckBoxStatusTimer.Interval = 3000;
|
||||
CheckBoxStatusTimer.Start();
|
||||
await Task.Delay(9000);
|
||||
bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
bool state = Array.TrueForAll(boolsl, b => b == false);
|
||||
if (state)
|
||||
{
|
||||
loop = false;
|
||||
ModbusHelper.BoxOperate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModbusHelper.BoxOperate = true;
|
||||
ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
|
||||
}
|
||||
}
|
||||
});
|
||||
//设置对应药箱按钮可用状态
|
||||
//SetIsEnableStatus(DrawerNo, false);
|
||||
}
|
||||
|
@ -874,27 +890,6 @@ namespace DM_Weight.ViewModels
|
|||
public void OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
}
|
||||
private void GetAllBoxState(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
//查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱
|
||||
if (DrawerNo >= 0)
|
||||
{
|
||||
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
bool allFalse = Array.TrueForAll(boolArrs, b => b == false);
|
||||
if (allFalse)
|
||||
{
|
||||
if (CheckBoxStatusTimer.Enabled)
|
||||
{
|
||||
CheckBoxStatusTimer.Stop();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < boolArrs.Length; i++)
|
||||
{
|
||||
//设置对应药箱按钮可用状态
|
||||
SetIsEnableStatus(i, !boolArrs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//void DoMyPrismEvent(DeviceMsg msg)
|
||||
//{
|
||||
|
|
|
@ -1184,6 +1184,11 @@ namespace DM_Weight.ViewModels
|
|||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
RequestData();
|
||||
if(ModbusHelper.BoxOperate)
|
||||
{
|
||||
Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
|
||||
return;
|
||||
}
|
||||
//查询当前药师的第一个药箱号并打开该药箱
|
||||
int drawerNo = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerNo).First();
|
||||
if (drawerNo > 0)
|
||||
|
@ -1206,7 +1211,7 @@ namespace DM_Weight.ViewModels
|
|||
_portUtil.SpeakAsync($"正在打开{drawerNo}号药箱");
|
||||
logger.Info($"正在打开{drawerNo}号药箱");
|
||||
ModbusHelper.GetInstance().OpenBoxDoor(drawerNo - 1);
|
||||
SetBtnEnable(drawerNo, false);
|
||||
//SetBtnEnable(drawerNo, false);
|
||||
//if (CheckBoxStatusTimer is null)
|
||||
//{
|
||||
// CheckBoxStatusTimer = new System.Timers.Timer();
|
||||
|
@ -1225,7 +1230,26 @@ namespace DM_Weight.ViewModels
|
|||
channelList.EffDate = DateTime.Now.ToString();
|
||||
SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate }).ExecuteCommand();
|
||||
}
|
||||
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
bool loop = true;
|
||||
while (loop)
|
||||
{
|
||||
await Task.Delay(9000);
|
||||
bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
bool state = Array.TrueForAll(boolsl, b => b == false);
|
||||
if (state)
|
||||
{
|
||||
loop = false;
|
||||
ModbusHelper.BoxOperate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModbusHelper.BoxOperate = true;
|
||||
ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//private void GetAllBoxState(object sender, ElapsedEventArgs e)
|
||||
|
|
|
@ -40,11 +40,11 @@ namespace DM_Weight.ViewModels
|
|||
/// <summary>
|
||||
/// 冰箱温度
|
||||
/// </summary>
|
||||
private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
|
||||
public string WD { get => _wd; set => SetProperty(ref _wd, value); }
|
||||
System.Timers.Timer WDTimer;
|
||||
//private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
|
||||
//public string WD { get => _wd; set => SetProperty(ref _wd, value); }
|
||||
//System.Timers.Timer WDTimer;
|
||||
|
||||
System.Timers.Timer WSDTimer;
|
||||
//System.Timers.Timer WSDTimer;
|
||||
|
||||
/// <summary>
|
||||
/// 是否有冰箱抽屉
|
||||
|
@ -287,10 +287,8 @@ namespace DM_Weight.ViewModels
|
|||
//}
|
||||
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
|
||||
{
|
||||
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
bool allTrue = Array.TrueForAll(boolArrs, b => b);
|
||||
//false是关着,true是开着
|
||||
if (!allTrue)
|
||||
if (!ModbusHelper.BoxOperate)
|
||||
{
|
||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||
Operator = null;
|
||||
|
@ -300,12 +298,8 @@ namespace DM_Weight.ViewModels
|
|||
else
|
||||
{
|
||||
//还有药箱开着不能退出
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "请关闭药箱后再退出系统",
|
||||
Type = MsgType.ERROR
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
_portUtil.SpeakAsync("请关闭药箱后再退出");
|
||||
SelectedMenu = _premissionDmList[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -611,17 +605,40 @@ namespace DM_Weight.ViewModels
|
|||
// timer.Start();
|
||||
//}
|
||||
#region 温度查询定时
|
||||
int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
|
||||
if (interval > 0)
|
||||
{
|
||||
WSDTimer = new System.Timers.Timer();
|
||||
//int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
|
||||
//if (interval > 0)
|
||||
//{
|
||||
// WSDTimer = new System.Timers.Timer();
|
||||
|
||||
WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
|
||||
WSDTimer.Interval = interval;
|
||||
WSDTimer.Start();
|
||||
//WDTimer.AutoReset = true;
|
||||
//WDTimer.Enabled = true;
|
||||
// WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
|
||||
// WSDTimer.Interval = interval;
|
||||
// WSDTimer.Start();
|
||||
// //WDTimer.AutoReset = true;
|
||||
// //WDTimer.Enabled = true;
|
||||
//}
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
TemperatureHumidityInfo temp = _portUtil.GetWSD();
|
||||
if (temp != null)
|
||||
{
|
||||
SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
|
||||
{
|
||||
GroupNo = temp.GroupNo,
|
||||
Temp = temp.Temp,
|
||||
Humi = temp.Humi,
|
||||
AddTime = DateTime.Now
|
||||
}).ExecuteCommand();
|
||||
logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
|
||||
await Task.Delay(1200000);//20分钟查一次
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info("温湿度信息返回空");
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
//if (stopRecord > 0)
|
||||
//{
|
||||
|
|
|
@ -483,13 +483,13 @@ namespace DM_Weight.ViewModels
|
|||
};
|
||||
PremissionDm machineRecord= new PremissionDm
|
||||
{
|
||||
Id = 54,
|
||||
Id = 55,
|
||||
PremissionName = "操作记录",
|
||||
PremissionPath = "MachineRecordWindow",
|
||||
};
|
||||
PremissionDm wSDRecord= new PremissionDm
|
||||
{
|
||||
Id = 54,
|
||||
Id = 56,
|
||||
PremissionName = "温湿度记录",
|
||||
PremissionPath = "WSDRecordWindow",
|
||||
};
|
||||
|
@ -514,13 +514,18 @@ namespace DM_Weight.ViewModels
|
|||
// PremissionPath = "SettingWindow",
|
||||
// };
|
||||
//}
|
||||
|
||||
sysset3 = new PremissionDm
|
||||
{
|
||||
Id = 57,
|
||||
PremissionName = "登录设置",
|
||||
PremissionPath = "SettingWindow",
|
||||
};
|
||||
syssetChild.Add(sysset1);
|
||||
syssetChild.Add(sysset2);
|
||||
syssetChild.Add(sysset3);
|
||||
syssetChild.Add(settingBox);
|
||||
syssetChild.Add(machineRecord);
|
||||
syssetChild.Add(wSDRecord);
|
||||
syssetChild.Add(sysset3);
|
||||
sysset.Children = syssetChild;
|
||||
defaultAll.Add(sysset);
|
||||
#endregion
|
||||
|
|
|
@ -198,6 +198,12 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
if (DrawerNo > 0)
|
||||
{
|
||||
|
||||
if (ModbusHelper.BoxOperate)
|
||||
{
|
||||
Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
|
||||
return;
|
||||
}
|
||||
IsEnable = false;
|
||||
Status = 1;
|
||||
//_portUtil.SpeakAsync("正在打开药箱");
|
||||
|
@ -219,6 +225,26 @@ namespace DM_Weight.ViewModels
|
|||
IsEnable = true;
|
||||
Status = 0;
|
||||
}
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
bool loop = true;
|
||||
while (loop)
|
||||
{
|
||||
await Task.Delay(9000);
|
||||
bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
bool state = Array.TrueForAll(boolsl, b => b == false);
|
||||
if (state)
|
||||
{
|
||||
loop = false;
|
||||
ModbusHelper.BoxOperate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModbusHelper.BoxOperate = true;
|
||||
ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -160,8 +160,8 @@
|
|||
<DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding ManuNo}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="效期" Binding="{Binding EffDate}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="厂家" Binding="{Binding DrugInfo.Manufactory}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="药品基数" Binding="{Binding BaseQuantity}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddQuantity}"/>
|
||||
<!--<DataGridTextColumn IsReadOnly="True" Header="药品基数" Binding="{Binding BaseQuantity}"/>-->
|
||||
<DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddToJJNum}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="状态" Binding="{Binding ChannelLst.State,Converter={StaticResource StockStatusConverter},ConverterParameter=TextState}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
</Setter>
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -141,12 +142,11 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
<!--<Grid Grid.Row="1" Grid.Column="0" Margin="0 0 -100 0">-->
|
||||
<ListView Grid.Row="1" Grid.Column="0" Margin="0 0 6 0"
|
||||
<ListView Grid.Row="1" Grid.Column="0" Margin="0"
|
||||
ItemsSource="{Binding OrderInfoList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
|
||||
SelectedItem="{Binding selectOrderInfo}"
|
||||
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="13">
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="0 15 0 0">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -166,13 +166,13 @@
|
|||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="60"
|
||||
<GridViewColumn Width="80"
|
||||
Header="姓名"
|
||||
DisplayMemberBinding="{Binding PName}" />
|
||||
<GridViewColumn Width="30"
|
||||
DisplayMemberBinding="{Binding Sex}"
|
||||
Header="性别"/>
|
||||
<GridViewColumn Width="80"
|
||||
<GridViewColumn Width="60"
|
||||
DisplayMemberBinding="{Binding OrderNo}"
|
||||
Header="单号"/>
|
||||
<!--<GridViewColumn Width="240"
|
||||
|
@ -191,7 +191,7 @@
|
|||
DisplayMemberBinding="{Binding _OrderDetail.Quantity}"
|
||||
Header="数量"/>-->
|
||||
|
||||
<GridViewColumn Width="100" Header="药品名称">
|
||||
<GridViewColumn Width="180" Header="药品名称">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
|
||||
|
@ -212,7 +212,7 @@
|
|||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>-->
|
||||
<GridViewColumn Width="30" Header="数量">
|
||||
<GridViewColumn Width="42" Header="数量">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
|
||||
|
@ -224,11 +224,10 @@
|
|||
</ListView>
|
||||
<!--</Grid>-->
|
||||
<!--<Grid Grid.Column="1" Grid.Row="1" Margin="0 0 0 0" HorizontalAlignment="Right">-->
|
||||
<ListView Grid.Column="1" Grid.Row="1" Margin="0 0 0 0"
|
||||
<ListView Grid.Column="1" Grid.Row="1" Margin="0 0 3 0"
|
||||
ItemsSource="{Binding TotalDrugList,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
|
||||
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="13">
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="0 16 0 15">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -236,12 +235,12 @@
|
|||
</ListView.Resources>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
|
||||
<GridViewColumn Width="100"
|
||||
<GridViewColumn Width="180"
|
||||
DisplayMemberBinding="{Binding DrugName}"
|
||||
Header="药品名称"/>
|
||||
<GridViewColumn Width="30"
|
||||
<GridViewColumn Width="40"
|
||||
DisplayMemberBinding="{Binding TotalCount}"
|
||||
Header="合计数量"/>
|
||||
Header="合计"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
|
|
@ -151,12 +151,11 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
<!--<Grid Grid.Row="1" Grid.Column="0" Margin="0 0 -100 0">-->
|
||||
<ListView Grid.Row="1" Grid.Column="0" Margin="0 0 6 0"
|
||||
<ListView Grid.Row="1" Grid.Column="0" Margin="0"
|
||||
ItemsSource="{Binding OrderInfoList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
|
||||
SelectedItem="{Binding selectOrderInfo}"
|
||||
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="3">
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="0 15 0 0">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -176,13 +175,13 @@
|
|||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="60"
|
||||
<GridViewColumn Width="80"
|
||||
Header="姓名"
|
||||
DisplayMemberBinding="{Binding PName}" />
|
||||
<GridViewColumn Width="30"
|
||||
DisplayMemberBinding="{Binding Sex}"
|
||||
Header="性别"/>
|
||||
<GridViewColumn Width="80"
|
||||
<GridViewColumn Width="60"
|
||||
DisplayMemberBinding="{Binding OrderNo}"
|
||||
Header="单号"/>
|
||||
<!--<GridViewColumn Width="240"
|
||||
|
@ -201,7 +200,7 @@
|
|||
DisplayMemberBinding="{Binding _OrderDetail.Quantity}"
|
||||
Header="数量"/>-->
|
||||
|
||||
<GridViewColumn Width="100" Header="药品名称">
|
||||
<GridViewColumn Width="180" Header="药品名称">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
|
||||
|
@ -222,7 +221,7 @@
|
|||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>-->
|
||||
<GridViewColumn Width="30" Header="数量">
|
||||
<GridViewColumn Width="42" Header="数量">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
|
||||
|
@ -234,11 +233,10 @@
|
|||
</ListView>
|
||||
<!--</Grid>-->
|
||||
<!--<Grid Grid.Column="1" Grid.Row="1" Margin="0 0 0 0" HorizontalAlignment="Right">-->
|
||||
<ListView Grid.Column="1" Grid.Row="1" Margin="0 0 0 0"
|
||||
<ListView Grid.Column="1" Grid.Row="1" Margin="0 0 3 0"
|
||||
ItemsSource="{Binding TotalDrugList,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
|
||||
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="13">
|
||||
materialDesign:ListViewAssist.ListViewItemPadding="0 16 0 15">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -246,12 +244,12 @@
|
|||
</ListView.Resources>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
|
||||
<GridViewColumn Width="100"
|
||||
<GridViewColumn Width="180"
|
||||
DisplayMemberBinding="{Binding DrugName}"
|
||||
Header="药品名称"/>
|
||||
<GridViewColumn Width="30"
|
||||
<GridViewColumn Width="40"
|
||||
DisplayMemberBinding="{Binding TotalCount}"
|
||||
Header="合计数量"/>
|
||||
Header="合计"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
|
Loading…
Reference in New Issue