湘潭手术室交接柜修改手麻传单子操作核销

This commit is contained in:
maqiao 2024-11-22 18:03:37 +08:00
parent af6f066719
commit 4cf2de08e1
12 changed files with 555 additions and 316 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings> <connectionStrings>
<!-- 数据库连接字符串 --> <!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />--> <!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xx_xiangchang2;userid=root;password=root" /> <add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_jiaojie_xx;userid=root;password=root" />
</connectionStrings> </connectionStrings>
<!--<runtime> <!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!-- --><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -29,7 +29,7 @@
<!--2023/7/13 药房代码 有则写无则空 --> <!--2023/7/13 药房代码 有则写无则空 -->
<add key="storage" value="159" /> <add key="storage" value="" />
<!-- 登录模式 1单人登录2双人登录 --> <!-- 登录模式 1单人登录2双人登录 -->
<add key="loginMode" value="1" /> <add key="loginMode" value="1" />
<!-- 登录顺序,指定先登录的人的名称有效值只有在登录模式等于2时才会生效 发药人【operator】审核人【reviewer】 --> <!-- 登录顺序,指定先登录的人的名称有效值只有在登录模式等于2时才会生效 发药人【operator】审核人【reviewer】 -->

View File

@ -1,4 +1,5 @@
using System; using SqlSugar.Extensions;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@ -13,6 +14,10 @@ namespace DM_Weight.Converter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if(parameter==null)
{
return value.ObjToBool();
}
string str=value.ToString(); string str=value.ToString();
return !(str == parameter.ToString()); return !(str == parameter.ToString());
} }

View File

@ -15,7 +15,7 @@ namespace DM_Weight.Converter
int status = int.Parse(value.ToString()); int status = int.Parse(value.ToString());
if (parameter.ToString() == "EnableState") if (parameter.ToString() == "EnableState")
{ {
if (status == 0) if (status == 1)
{ {
return true; return true;
} }

View File

@ -178,7 +178,7 @@ namespace DM_Weight.Models
/// <summary> /// <summary>
/// /// 添加值1药师已确认2管理已核对处方
/// 默认值: 0 /// 默认值: 0
///</summary> ///</summary>
private int? _dmStatus; private int? _dmStatus;

View File

@ -151,7 +151,7 @@ namespace DM_Weight.ViewModels
{ {
if (channelStock != null) if (channelStock != null)
{ {
if (channelStock.ChannelLst.State == 0) if (channelStock.ChannelLst.State == 1)
{ {
channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected; channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
} }

View File

@ -16,7 +16,9 @@ using System.Configuration;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -25,6 +27,7 @@ namespace DM_Weight.ViewModels
public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{ {
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel)); private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
System.Timers.Timer CheckBoxStatusTimer;
private int _pageNum = 1; private int _pageNum = 1;
public int PageNum public int PageNum
@ -120,6 +123,44 @@ namespace DM_Weight.ViewModels
private OrderInfo _selectOrderInfo; private OrderInfo _selectOrderInfo;
public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); } public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); }
#region 18
private bool _IsEnabled1 = true;
public bool IsEnabled1 { get => _IsEnabled1; set => SetProperty(ref _IsEnabled1, value); }
private bool _IsEnabled2 = true;
public bool IsEnabled2 { get => _IsEnabled2; set => SetProperty(ref _IsEnabled2, value); }
private bool _IsEnabled3 = true;
public bool IsEnabled3 { get => _IsEnabled3; set => SetProperty(ref _IsEnabled3, value); }
private bool _IsEnabled4 = true;
public bool IsEnabled4 { get => _IsEnabled4; set => SetProperty(ref _IsEnabled4, value); }
private bool _IsEnabled5 = true;
public bool IsEnabled5 { get => _IsEnabled5; set => SetProperty(ref _IsEnabled5, value); }
private bool _IsEnabled6 = true;
public bool IsEnabled6 { get => _IsEnabled6; set => SetProperty(ref _IsEnabled6, value); }
private bool _IsEnabled7 = true;
public bool IsEnabled7 { get => _IsEnabled7; set => SetProperty(ref _IsEnabled7, value); }
private bool _IsEnabled8 = true;
public bool IsEnabled8 { get => _IsEnabled8; set => SetProperty(ref _IsEnabled8, value); }
private bool _IsEnabled9 = true;
public bool IsEnabled9 { get => _IsEnabled9; set => SetProperty(ref _IsEnabled9, value); }
private bool _IsEnabled10 = true;
public bool IsEnabled10 { get => _IsEnabled10; set => SetProperty(ref _IsEnabled10, value); }
private bool _IsEnabled11 = true;
public bool IsEnabled11 { get => _IsEnabled11; set => SetProperty(ref _IsEnabled11, value); }
private bool _IsEnabled12 = true;
public bool IsEnabled12 { get => _IsEnabled12; set => SetProperty(ref _IsEnabled12, value); }
private bool _IsEnabled13 = true;
public bool IsEnabled13 { get => _IsEnabled13; set => SetProperty(ref _IsEnabled13, value); }
private bool _IsEnabled14 = true;
public bool IsEnabled14 { get => _IsEnabled14; set => SetProperty(ref _IsEnabled14, value); }
private bool _IsEnabled15 = true;
public bool IsEnabled15 { get => _IsEnabled15; set => SetProperty(ref _IsEnabled15, value); }
private bool _IsEnabled16 = true;
public bool IsEnabled16 { get => _IsEnabled16; set => SetProperty(ref _IsEnabled16, value); }
private bool _IsEnabled17 = true;
public bool IsEnabled17 { get => _IsEnabled17; set => SetProperty(ref _IsEnabled17, value); }
private bool _IsEnabled18 = true;
public bool IsEnabled18 { get => _IsEnabled18; set => SetProperty(ref _IsEnabled18, value); }
#endregion
private Brush _button1Color = Brushes.White; private Brush _button1Color = Brushes.White;
public Brush Button1Color public Brush Button1Color
@ -267,7 +308,7 @@ namespace DM_Weight.ViewModels
//.InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString()) //.InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
.WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate) .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
.WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"]) .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
.Where(oi => oi.DmStatus == 0) .Where(oi => oi.DmStatus == 1)
.Where(oi => oi.HisDispFlag == 0) .Where(oi => oi.HisDispFlag == 0)
.Where(oi => oi.CancelFlag == 0) .Where(oi => oi.CancelFlag == 0)
.Where(oi => oi.DoctorCode == currentDrawerUser) .Where(oi => oi.DoctorCode == currentDrawerUser)
@ -483,7 +524,7 @@ namespace DM_Weight.ViewModels
{ {
SqlSugarHelper.Db.Updateable(new OrderInfo() SqlSugarHelper.Db.Updateable(new OrderInfo()
{ {
DmStatus = 1, DmStatus = 2,
OrderNo = oi.OrderNo OrderNo = oi.OrderNo
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand(); }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
@ -664,13 +705,12 @@ namespace DM_Weight.ViewModels
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = $"所选处方对应药品批次效期无库存{empChannelStock}", Message = $"所选单子中对应药品批次效期无效{empChannelStock}",
Type = MsgType.ERROR, Type = MsgType.ERROR,
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}"); logger.Info($"所选单子对应药品批次效期无效{empChannelStock}");
throw new Exception("事务回滚"); throw new Exception("事务回滚");
return false;
} }
return true; return true;
}); });
@ -679,7 +719,7 @@ namespace DM_Weight.ViewModels
RequestData(); RequestData();
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "所选处方已核对完成", Message = "所选单子已核对完成",
Type = MsgType.SUCCESS, Type = MsgType.SUCCESS,
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -688,7 +728,7 @@ namespace DM_Weight.ViewModels
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "处方核对失败!", Message = "核对失败!",
Type = MsgType.ERROR, Type = MsgType.ERROR,
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -699,7 +739,7 @@ namespace DM_Weight.ViewModels
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "请勾选要核对的处方数据", Message = "请勾选要核对数据",
Type = MsgType.ERROR Type = MsgType.ERROR
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -738,13 +778,82 @@ namespace DM_Weight.ViewModels
//记录开药箱日志 //记录开药箱日志
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand(); SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
//设置对应药箱按钮可用状态
SetIsEnableStatus(DrawerNo, false);
//_eventAggregator.GetEvent<BoxOpenStatusEvent>().Publish();
CheckBoxStatusTimer = new System.Timers.Timer();
CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
CheckBoxStatusTimer.Interval = 3000;
CheckBoxStatusTimer.Start();
//设置对应药箱按钮可用状态
//SetIsEnableStatus(DrawerNo, false);
}
}
private void SetIsEnableStatus(int drawerNO, bool status)
{
switch (drawerNO)
{
case 0:
IsEnabled1 = status;
break;
case 1:
IsEnabled2 = status;
break;
case 2:
IsEnabled3 = status;
break;
case 3:
IsEnabled4 = status;
break;
case 4:
IsEnabled5 = status;
break;
case 5:
IsEnabled6 = status;
break;
case 6:
IsEnabled7 = status;
break;
case 7:
IsEnabled8 = status;
break;
case 8:
IsEnabled9 = status;
break;
case 9:
IsEnabled10 = status;
break;
case 10:
IsEnabled11 = status;
break;
case 11:
IsEnabled12 = status;
break;
case 12:
IsEnabled13 = status;
break;
case 13:
IsEnabled14 = status;
break;
case 14:
IsEnabled15 = status;
break;
case 15:
IsEnabled16 = status;
break;
case 16:
IsEnabled17 = status;
break;
case 17:
IsEnabled18 = status;
break;
} }
} }
public void OnNavigatedTo(NavigationContext navigationContext) public void OnNavigatedTo(NavigationContext navigationContext)
{ {
RequestData(); RequestData();
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
} }
public bool IsNavigationTarget(NavigationContext navigationContext) public bool IsNavigationTarget(NavigationContext navigationContext)
@ -754,9 +863,26 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext) public void OnNavigatedFrom(NavigationContext navigationContext)
{ {
// 取消消息订阅
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
} }
private void GetAllBoxState(object sender, ElapsedEventArgs e)
{
//查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱
if (DrawerNo >= 0)
{
bool[] boolArrs = { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };// ModbusHelper.GetInstance().GetAllBoxState();
bool allFalse = Array.TrueForAll(boolArrs, b => b == false);
if (allFalse)
{
CheckBoxStatusTimer.Stop();
}
for (int i = 0; i < boolArrs.Length; i++)
{
//设置对应药箱按钮可用状态
SetIsEnableStatus(i, !boolArrs[i]);
}
}
}
//void DoMyPrismEvent(DeviceMsg msg) //void DoMyPrismEvent(DeviceMsg msg)
//{ //{
// switch (msg.EventType) // switch (msg.EventType)

View File

@ -2,6 +2,7 @@
using DM_Weight.msg; using DM_Weight.msg;
using DM_Weight.Port; using DM_Weight.Port;
using DM_Weight.util; using DM_Weight.util;
using DM_Weight.Views;
using log4net; using log4net;
using Prism.Commands; using Prism.Commands;
using Prism.Events; using Prism.Events;
@ -52,7 +53,7 @@ namespace DM_Weight.ViewModels
} }
} }
private int _pageSize = 10; private int _pageSize = 8;
public int PageSize public int PageSize
{ {
get => _pageSize; get => _pageSize;
@ -81,12 +82,12 @@ namespace DM_Weight.ViewModels
} }
//开名下药箱按钮的显示状态 //开名下药箱按钮的显示状态
private bool _selfEnable = false; //private bool _selfEnable = false;
public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); } //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); } //public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, value); }
//开公共药箱按钮的显示状态 //开公共药箱按钮的显示状态
@ -433,80 +434,102 @@ namespace DM_Weight.ViewModels
{ {
case 1: case 1:
Button1Enable = true; Button1Enable = true;
SelfEnable=true; //SelfEnable=true;
break; break;
case 2: case 2:
Button2Enable = true; Button2Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 3: case 3:
Button3Enable = true; Button3Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 4: case 4:
Button4Enable = true; Button4Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 5: case 5:
Button5Enable = true; Button5Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 6: case 6:
Button6Enable = true; Button6Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 7: case 7:
Button7Enable = true; Button7Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 8: case 8:
Button8Enable = true; Button8Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 9: case 9:
Button9Enable = true; Button9Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 10: case 10:
Button10Enable = true; Button10Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 11: case 11:
Button11Enable = true; Button11Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 12: case 12:
Button12Enable = true; Button12Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 13: case 13:
Button13Enable = true; Button13Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 14: case 14:
Button14Enable = true; Button14Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 15: case 15:
Button15Enable = true; Button15Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 16: case 16:
Button16Enable = true; Button16Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 17: case 17:
Button17Enable = true; Button17Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
case 18: case 18:
Button18Enable = true; Button18Enable = true;
SelfEnable = true; //SelfEnable = true;
break; break;
default: default:
break; break;
} }
} }
//打开某个药箱时不可点击其他药箱按钮避免保存数据时减错药箱库存(确认或取消后按钮即可用)
private void SetAllBtnEnableFalse()
{
Button1Enable = false;
Button2Enable = false;
Button3Enable = false;
Button4Enable = false;
Button5Enable = false;
Button6Enable = false;
Button7Enable = false;
Button8Enable = false;
Button9Enable = false;
Button10Enable = false;
Button11Enable = false;
Button12Enable = false;
Button13Enable = false;
Button14Enable = false;
Button15Enable = false;
Button16Enable = false;
Button17Enable = false;
Button18Enable = false;
}
IEventAggregator _eventAggregator; IEventAggregator _eventAggregator;
private PortUtil _portUtil; private PortUtil _portUtil;
@ -536,6 +559,7 @@ namespace DM_Weight.ViewModels
{ {
//查询当前药箱归属的药师 //查询当前药箱归属的药师
ChannelList currentList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.DrawerNo == DrawerNo + 1 && cl.MachineId == "DM5").First();//.Select(cl => cl.BelongUser).First(); ChannelList currentList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.DrawerNo == DrawerNo + 1 && cl.MachineId == "DM5").First();//.Select(cl => cl.BelongUser).First();
DrawerType = currentList.DrawerType;
string currentDrawerUser = currentList.BelongUser; string currentDrawerUser = currentList.BelongUser;
OrderInfoList = SqlSugarHelper.Db.Queryable<OrderInfo>() OrderInfoList = SqlSugarHelper.Db.Queryable<OrderInfo>()
.Includes(oi => oi.OrderDetailList, od => od.DrugInfo) .Includes(oi => oi.OrderDetailList, od => od.DrugInfo)
@ -632,6 +656,7 @@ namespace DM_Weight.ViewModels
{ {
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) if (chlList != null && chlList.Count > 0)
{ {
for (int i = 0; i < chlList.Count; i++) for (int i = 0; i < chlList.Count; i++)
@ -641,6 +666,7 @@ namespace DM_Weight.ViewModels
{ {
SetBtnColor(chl.DrawerNo); SetBtnColor(chl.DrawerNo);
} }
//DrawerType== 1为公共药箱 //DrawerType== 1为公共药箱
if (chl.DrawerType == 1) if (chl.DrawerType == 1)
{ {
@ -648,6 +674,10 @@ namespace DM_Weight.ViewModels
} }
if (!string.IsNullOrEmpty(chl.BelongUser) && chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode) if (!string.IsNullOrEmpty(chl.BelongUser) && chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode)
{ {
if (DrawerType == -1)
{
DrawerType = chl.DrawerType;
}
SetBtnEnable(chl.DrawerNo); SetBtnEnable(chl.DrawerNo);
} }
} }
@ -692,90 +722,113 @@ namespace DM_Weight.ViewModels
public async void OpenBoxAction(string strDrawerNo) public async void OpenBoxAction(string strDrawerNo)
{ {
DrawerNo = Convert.ToInt32(strDrawerNo); DrawerNo = Convert.ToInt32(strDrawerNo);
DrawerType = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == Convert.ToInt32(strDrawerNo)).Select(cl => cl.DrawerType).First(); //DrawerType = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == Convert.ToInt32(strDrawerNo)).Select(cl => cl.DrawerType).First();
SelfEnable = true; //SelfEnable = true;
//int listSelfState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5") //int listSelfState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
// .WhereIf(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First(); // .WhereIf(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
int listDrawerState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType) //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(); // .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
if (DrawerType == 1) //公共药箱
{
if (listDrawerState == 0)
{
SelfContent = "还公共药箱";
}
else
{
SelfContent = "取公共药箱";
}
} DrawerNo = Convert.ToInt32(strDrawerNo);
else MachineRecord machineRecord = new MachineRecord();
{ machineRecord.MachineId = "DM5";
if (listDrawerState == 0) machineRecord.DrawerNo = DrawerNo;
{ machineRecord.Operator = HomeWindowViewModel.Operator?.Id;
SelfContent = "还名下药箱"; machineRecord.OperationTime = DateTime.Now;
} machineRecord.Type = 55;
else machineRecord.InvoiceId = $"打开{DrawerNo + 1}号药箱";
{
SelfContent = "取名下药箱";
}
if (DrawerNo > 0)
{
DrawerNo -= 1;
RequestData();
Status = 1;
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
logger.Info($"正在打开{DrawerNo + 1}号药箱");
//记录开药箱日志
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
} }
//if (DrawerType == 1) //公共药箱
//{
// if (listDrawerState == 0)
// {
// SelfContent = "还公共药箱";
// }
// else
// {
// SelfContent = "取公共药箱";
// }
//}
//else
//{
// if (listDrawerState == 0)
// {
// SelfContent = "还名下药箱";
// }
// else
// {
// SelfContent = "取名下药箱";
// }
//}
} }
public DelegateCommand<string> OpenBoxDelegate //public DelegateCommand<string> OpenBoxDelegate
{ //{
get => new DelegateCommand<string>((DrawerType) => // get => new DelegateCommand<string>((DrawerType) =>
{ // {
SearchBox(); // SearchBox();
} // }
); // );
} //}
private void SearchBox() //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();
// .Select(cl => cl.DrawerNo).ToList();
if (iList.Count > 0)
{
//_portUtil.SpeakAsync("正在打开药箱");
//_portUtil.DrawerNo = iList[iNumber];
//iNumber++;
//_portUtil.OpenBox();
for (int i = 0; i < iList.Count; i++) // SetAllBtnEnableFalse();
{ // iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
ChannelList channelList = iList[i]; // .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).ToList();
//记录开药箱日志 // // .Select(cl => cl.DrawerNo).ToList();
SqlSugarHelper.Db.Insertable(new MachineRecord() // if (iList.Count > 0)
{ // {
MachineId = "DM5", // //_portUtil.SpeakAsync("正在打开药箱");
DrawerNo = channelList.DrawerNo, // //_portUtil.DrawerNo = iList[iNumber];
Operator = HomeWindowViewModel.Operator?.Id, // //iNumber++;
OperationTime = DateTime.Now, // //_portUtil.OpenBox();
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();
_portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱"); // for (int i = 0; i < iList.Count; i++)
logger.Info($"正在打开{channelList.DrawerNo}号药箱"); // {
ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1); // ChannelList channelList = iList[i];
Thread.Sleep(1000); // //记录开药箱日志
} // 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();
SelfStatus = 0; // _portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱");
PublicEnable = true; // logger.Info($"正在打开{channelList.DrawerNo}号药箱");
SelfEnable = true; // ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1);
DrawerType = -1; // }
}
} // SelfStatus = 0;
// PublicEnable = true;
// //SelfEnable = true;
// DrawerType = -1;
// }
//}
public DelegateCommand RowSelected public DelegateCommand RowSelected
{ {
get => new DelegateCommand(() => get => new DelegateCommand(() =>
@ -820,13 +873,15 @@ namespace DM_Weight.ViewModels
void CheckOrderAction() void CheckOrderAction()
{ {
SetBtnEnable(DrawerNo);
var confirmData = OrderInfoList.Where(oi => oi.ItemIsChecked == true).ToList(); var confirmData = OrderInfoList.Where(oi => oi.ItemIsChecked == true).ToList();
if (confirmData.Count > 0) if (confirmData.Count > 0)
{ {
var f = SqlSugarHelper.Db.UseTran(() => var f = SqlSugarHelper.Db.UseTran(() =>
{ {
string empChannelStock = string.Empty; //string empChannelStock = string.Empty;
for (int i = 0; i < confirmData.Count; i++) for (int i = 0; i < confirmData.Count; i++)
{ {
@ -851,181 +906,184 @@ namespace DM_Weight.ViewModels
}); });
} }
//Expression<Func<ChannelStock, bool>> updateExp = it => it.ManuNo == oi._OrderDetail.SetManuNo && it.EffDate == oi._OrderDetail.SetEffDate; #region 1
for (int j = 0; j < oi.OrderDetailList.Count; j++) //for (int j = 0; j < oi.OrderDetailList.Count; j++)
{ //{
oi._OrderDetail = oi.OrderDetailList[j]; // oi._OrderDetail = oi.OrderDetailList[j];
int drawerNo = DrawerNo + 1; // int drawerNo = DrawerNo + 1;
ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>() // ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.DrugId == oi._OrderDetail.DrugId // .Where(cs => cs.DrugId == oi._OrderDetail.DrugId
&& cs.ManuNo == oi._OrderDetail.SetManuNo // && cs.ManuNo == oi._OrderDetail.SetManuNo
&& cs.EffDate == oi._OrderDetail.SetEffDate // && cs.EffDate == oi._OrderDetail.SetEffDate
&& cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5") // && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5")
&& cs.DrawerNo == drawerNo).First(); // && cs.DrawerNo == drawerNo).First();
if (cs == null) // if (cs == null)
{ // {
empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate};"; // empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate};";
continue; // continue;
} // }
cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity; // cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
// 更新数据 库存信息 // // 更新数据 库存信息
SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand(); // SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
if (cs != null) // if (cs != null)
{ // {
SqlSugarHelper.Db.Insertable(new MachineRecord() // SqlSugarHelper.Db.Insertable(new MachineRecord()
{ // {
MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), // MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
DrawerNo = cs.DrawerNo, // DrawerNo = cs.DrawerNo,
ColNo = cs.ColNo, // ColNo = cs.ColNo,
DrugId = cs.DrugId, // DrugId = cs.DrugId,
ManuNo = cs.ManuNo, // ManuNo = cs.ManuNo,
EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, // EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id, // Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id, // Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now, // OperationTime = DateTime.Now,
Quantity = oi._OrderDetail.Quantity, // Quantity = oi._OrderDetail.Quantity,
Type = 2, // Type = 2,
InvoiceId = oi.OrderNo // InvoiceId = oi.OrderNo
//, StockQuantity = nowChannels.Sum(it => it.Quantity) // //, StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand(); // }).ExecuteCommand();
#region 使 // #region 记录 注射剂使用与交接记录报表
//查询发药时间 // //查询发药时间
//MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2) // //MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2)
//.OrderByDescending(mr => mr.OperationTime) // //.OrderByDescending(mr => mr.OperationTime)
//.First(); // //.First();
//string retUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo) // //string retUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo)
//.Select(cl => cl.BelongUser).First(); // //.Select(cl => cl.BelongUser).First();
RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable<RejectionReport>().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First(); // RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable<RejectionReport>().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First();
//发药信息 // //发药信息
//RejectionReport rejectionReport = new RejectionReport(); // //RejectionReport rejectionReport = new RejectionReport();
//rejectionReport.SendDate = SendMachineRecord.OperationTime; // //rejectionReport.SendDate = SendMachineRecord.OperationTime;
//rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); // //rejectionReport.SendUser = SendMachineRecord.Operator.ToString();
//rejectionReport.ReceiveUser = retUser; // //rejectionReport.ReceiveUser = retUser;
rejectionReport.RealNum = cs.BaseQuantity; // rejectionReport.RealNum = cs.BaseQuantity;
//还药信息 // //还药信息
rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity; // rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity;
rejectionReport.EmptyNum = oi._OrderDetail.Quantity; // rejectionReport.EmptyNum = oi._OrderDetail.Quantity;
rejectionReport.ReturnTime = DateTime.Now.ToString(); // rejectionReport.ReturnTime = DateTime.Now.ToString();
rejectionReport.ReturnUser = rejectionReport.SendUser; // rejectionReport.ReturnUser = rejectionReport.SendUser;
rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); // rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString();
rejectionReport.DrugId = oi._OrderDetail.DrugId; // rejectionReport.DrugId = oi._OrderDetail.DrugId;
rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName; // rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName;
rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec; // rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec;
rejectionReport.OperationTime = DateTime.Now; // rejectionReport.OperationTime = DateTime.Now;
int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); // int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand();
#endregion // #endregion
} // }
//保存账册 // //保存账册
int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() // int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
{ // {
DrugId = oi._OrderDetail.DrugId, // DrugId = oi._OrderDetail.DrugId,
Type = 2, // Type = 2,
Department = oi.DeptName, // Department = oi.DeptName,
OrderNo = oi.OrderNo, // OrderNo = oi.OrderNo,
ManuNo = cs.ManuNo, // ManuNo = cs.ManuNo,
EffDate = cs.EffDate, // EffDate = cs.EffDate,
OutQuantity = oi._OrderDetail.Quantity, // OutQuantity = oi._OrderDetail.Quantity,
UserId1 = HomeWindowViewModel.Operator?.Id, // UserId1 = HomeWindowViewModel.Operator?.Id,
UserId2 = HomeWindowViewModel.Reviewer?.Id, // UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), // MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), // CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now, // CreateTime = DateTime.Now,
InvoiceNo = oi.OrderNo // InvoiceNo = oi.OrderNo
}).ExecuteCommand(); // }).ExecuteCommand();
//修改凌晨生成的日结存与总结存数据 // //修改凌晨生成的日结存与总结存数据
AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>() // AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
.Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) // .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
.Where(ab => ab.Type == 3) // .Where(ab => ab.Type == 3)
.Where(ab => ab.DrugId == oi._OrderDetail.DrugId) // .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
.Where(ab => ab.ManuNo == cs.ManuNo) // .Where(ab => ab.ManuNo == cs.ManuNo)
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); // .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
if (accountBookG2Day != null) // if (accountBookG2Day != null)
{ // {
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity; // accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand(); // SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
} // }
else // else
{ // {
//生成日结存时可能没有该库位的绑定信息,需要写入日结存 // //生成日结存时可能没有该库位的绑定信息,需要写入日结存
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() // int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
{ // {
DrugId = oi._OrderDetail.DrugId, // DrugId = oi._OrderDetail.DrugId,
Type = 3, // Type = 3,
ManuNo = cs.ManuNo, // ManuNo = cs.ManuNo,
EffDate = cs.EffDate, // EffDate = cs.EffDate,
YQuantity = 0, // YQuantity = 0,
ManuStock = oi._OrderDetail.Quantity, // ManuStock = oi._OrderDetail.Quantity,
TotalStock = oi._OrderDetail.Quantity, // TotalStock = oi._OrderDetail.Quantity,
UserId1 = HomeWindowViewModel.Operator?.Id, // UserId1 = HomeWindowViewModel.Operator?.Id,
UserId2 = HomeWindowViewModel.Reviewer?.Id, // UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), // MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), // CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存" // InvoiceNo = "日结存"
}).ExecuteCommand(); // }).ExecuteCommand();
if (iDayResult <= 0) // if (iDayResult <= 0)
{ // {
logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}"); // logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
} // }
} // }
//修改凌晨生成的日结存与总结存数据 // //修改凌晨生成的日结存与总结存数据
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>() // AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
.Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) // .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
.Where(ab => ab.Type == 4) // .Where(ab => ab.Type == 4)
.Where(ab => ab.DrugId == oi._OrderDetail.DrugId) // .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); // .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
if (accountBookG2Total != null) // if (accountBookG2Total != null)
{ // {
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - oi._OrderDetail.Quantity; // accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - oi._OrderDetail.Quantity;
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand(); // SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
} // }
else // else
{ // {
//生成总结存时可能没有该库位的绑定信息,需要写入总结存 // //生成总结存时可能没有该库位的绑定信息,需要写入总结存
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() // int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
{ // {
DrugId = oi._OrderDetail.DrugId, // DrugId = oi._OrderDetail.DrugId,
Type = 4, // Type = 4,
YQuantity = 0, // YQuantity = 0,
ManuStock = oi._OrderDetail.Quantity, // ManuStock = oi._OrderDetail.Quantity,
TotalStock = oi._OrderDetail.Quantity, // TotalStock = oi._OrderDetail.Quantity,
UserId1 = HomeWindowViewModel.Operator?.Id, // UserId1 = HomeWindowViewModel.Operator?.Id,
UserId2 = HomeWindowViewModel.Reviewer?.Id, // UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), // MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), // CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "总结存" // InvoiceNo = "总结存"
}).ExecuteCommand(); // }).ExecuteCommand();
if (iTotalResult <= 0) // if (iTotalResult <= 0)
{ // {
logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}"); // logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}");
} // }
} // }
//}
#endregion
}
}
if (!string.IsNullOrEmpty(empChannelStock))
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"所选处方对应药品批次效期无库存{empChannelStock}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}");
throw new Exception("事务回滚");
return false;
} }
//if (!string.IsNullOrEmpty(empChannelStock))
//{
// AlertMsg alertMsg = new AlertMsg
// {
// Message = $"所选处方对应药品批次效期无库存{empChannelStock}",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}");
// throw new Exception("事务回滚");
// return false;
//}
return true; return true;
}); });
if (f.Data) if (f.Data)
@ -1033,7 +1091,7 @@ namespace DM_Weight.ViewModels
RequestData(); RequestData();
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "所选处方已核对完成", Message = "所选单子已核对完成",
Type = MsgType.SUCCESS, Type = MsgType.SUCCESS,
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -1042,7 +1100,7 @@ namespace DM_Weight.ViewModels
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "处方核对失败!", Message = "核对失败!",
Type = MsgType.ERROR, Type = MsgType.ERROR,
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -1053,17 +1111,48 @@ namespace DM_Weight.ViewModels
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {
Message = "请勾选要核对的处方数据", Message = "请勾选要核对的数据",
Type = MsgType.ERROR Type = MsgType.ERROR
}; };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
} }
} }
//取消
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
public void OnNavigatedTo(NavigationContext navigationContext) public void OnNavigatedTo(NavigationContext navigationContext)
{ {
RequestData(); RequestData();
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent); //查询当前药师的第一个药箱号并打开该药箱
int drawerNo = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerNo).First();
if (drawerNo > 0)
{
DrawerNo = drawerNo;
//进入页面打开当前用户的第一个药箱
//记录开药箱日志
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = drawerNo,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Type = 55,
InvoiceId = $"打开{drawerNo}号药箱",
//OptionType = SelfContent.Substring(0, 1) == "取" ? 0 : 1
}).ExecuteCommand();
_portUtil.SpeakAsync($"正在打开{drawerNo}号药箱");
logger.Info($"正在打开{drawerNo}号药箱");
ModbusHelper.GetInstance().OpenBoxDoor(drawerNo - 1);
}
} }
public bool IsNavigationTarget(NavigationContext navigationContext) public bool IsNavigationTarget(NavigationContext navigationContext)

View File

@ -165,7 +165,7 @@ namespace DM_Weight.ViewModels
{ {
Id = 1, Id = 1,
//PremissionName = "取药", //PremissionName = "取药",
PremissionName = "操作药箱", PremissionName = "药箱操作",
PremissionImage = "/Images/TbQyao.png", PremissionImage = "/Images/TbQyao.png",
}; };
ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>(); ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
@ -190,16 +190,16 @@ namespace DM_Weight.ViewModels
// PremissionPath = "OpenBoxWindow", // PremissionPath = "OpenBoxWindow",
//}; //};
//开药箱 //开药箱
PremissionDm openBox = new PremissionDm //PremissionDm openBox = new PremissionDm
{ //{
Id = 11, // Id = 11,
PremissionName = "开药箱", // PremissionName = "开药箱",
PremissionPath = "OpenBoxNewWindow", // PremissionPath = "OpenBoxNewWindow",
}; //};
//开药箱核对名下单子 //开药箱核对名下单子
PremissionDm openBoxWithOrder = new PremissionDm PremissionDm openBoxWithOrder = new PremissionDm
{ {
Id = 14, Id = 11,
PremissionName = "操作药箱", PremissionName = "操作药箱",
PremissionPath = "CheckSelfOrderWindow", PremissionPath = "CheckSelfOrderWindow",
}; };
@ -267,7 +267,7 @@ namespace DM_Weight.ViewModels
//quyaoChild.Add(quyao3); //quyaoChild.Add(quyao3);
//quyaoChild.Add(quyao4); //quyaoChild.Add(quyao4);
//quyaoChild.Add(quyao5); //quyaoChild.Add(quyao5);
quyaoChild.Add(openBox); //quyaoChild.Add(openBox);
quyaoChild.Add(checkOrder); quyaoChild.Add(checkOrder);
quyaoChild.Add(addition); quyaoChild.Add(addition);
quyaoChild.Add(openBoxWithOrder); quyaoChild.Add(openBoxWithOrder);

View File

@ -74,26 +74,26 @@
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </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="0" Grid.Column="0" Width="120" Content="1号药箱" Background="{Binding Button1Color}" Command="{Binding UpdateDrawerNo,ConverterParameter=1}" CommandParameter="1" IsEnabled="{Binding IsEnabled1}"/>
<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="1" Grid.Column="0" Width="120" Content="2号药箱" Background="{Binding Button2Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding IsEnabled2}"/>
<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="2" Grid.Column="0" Width="120" Content="3号药箱" Background="{Binding Button3Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding IsEnabled3}"/>
<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="3" Grid.Column="0" Width="120" Content="4号药箱" Background="{Binding Button4Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding IsEnabled4}"/>
<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="4" Grid.Column="0" Width="120" Content="5号药箱" Background="{Binding Button5Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding IsEnabled5}"/>
<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="5" Grid.Column="0" Width="120" Content="6号药箱" Background="{Binding Button6Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding IsEnabled6}"/>
<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="6" Grid.Column="0" Width="120" Content="7号药箱" Background="{Binding Button7Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding IsEnabled7}"/>
<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="0 0 3 0" Grid.Row="7" Grid.Column="0" Width="120" Content="8号药箱" Background="{Binding Button8Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding IsEnabled8}"/>
<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="8" Grid.Column="0" Width="120" Content="9号药箱" Background="{Binding Button9Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="9" IsEnabled="{Binding IsEnabled9}"/>
<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 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 IsEnabled10}"/>
<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="1" Grid.Column="1" Width="120" Content="11号药箱" Background="{Binding Button11Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding IsEnabled11}"/>
<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="2" Grid.Column="1" Width="120" Content="12号药箱" Background="{Binding Button12Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding IsEnabled12}"/>
<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="3" Grid.Column="1" Width="120" Content="13号药箱" Background="{Binding Button13Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding IsEnabled13}"/>
<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="4" Grid.Column="1" Width="120" Content="14号药箱" Background="{Binding Button14Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding IsEnabled14}"/>
<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="5" Grid.Column="1" Width="120" Content="15号药箱" Background="{Binding Button15Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding IsEnabled15}"/>
<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="6" Grid.Column="1" Width="120" Content="16号药箱" Background="{Binding Button16Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding IsEnabled16}"/>
<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="7" Grid.Column="1" Width="120" Content="17号药箱" Background="{Binding Button17Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding IsEnabled17}"/>
<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="8" Grid.Column="1" Width="120" Content="18号药箱" Background="{Binding Button18Color}" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding IsEnabled18}"/>
<!--<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="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}"/>--> <Button Grid.Row="9" Grid.Column="1" Width="120" Content="20号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="20" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=20}"/>-->
@ -119,7 +119,7 @@
SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}" SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
SelectedDateFormat="Short" SelectedDateFormat="Short"
Margin="6 0 0 0" Margin="6 0 0 0"
materialDesign:HintAssist.Hint="开日期" materialDesign:HintAssist.Hint="开日期"
Style="{StaticResource MaterialDesignOutlinedDatePicker}" /> Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
@ -174,7 +174,7 @@
Header="性别"/> Header="性别"/>
<GridViewColumn Width="100" <GridViewColumn Width="100"
DisplayMemberBinding="{Binding OrderNo}" DisplayMemberBinding="{Binding OrderNo}"
Header="处方号"/> Header="号"/>
<!--<GridViewColumn Width="240" <!--<GridViewColumn Width="240"
DisplayMemberBinding="{Binding DeptName}" DisplayMemberBinding="{Binding DeptName}"
Header="科室"/>--> Header="科室"/>-->
@ -247,7 +247,7 @@
</ListView> </ListView>
<!--</Grid>--> <!--</Grid>-->
<pagination:Pagination Grid.Row="2" Grid.Column="2" <pagination:Pagination Grid.Row="2" Grid.ColumnSpan="2"
CurrentPage="{Binding PageNum}" CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}" PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}" TotalPages="{Binding TotalCount}"

View File

@ -119,16 +119,16 @@
SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}" SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
SelectedDateFormat="Short" SelectedDateFormat="Short"
Margin="6 0 0 0" Margin="6 0 0 0"
materialDesign:HintAssist.Hint="开日期" materialDesign:HintAssist.Hint="开日期"
Style="{StaticResource MaterialDesignOutlinedDatePicker}" /> Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Margin="0 0 6 0" Content="{Binding SelfContent}" Command="{Binding OpenBoxDelegate}" CommandParameter="0" <!--<Button Margin="0 0 6 0" Content="{Binding SelfContent}" Command="{Binding OpenBoxDelegate}" CommandParameter="0" Visibility="Collapsed"
IsEnabled="{Binding SelfEnable}" IsEnabled="{Binding SelfEnable}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}" materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}" materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"/> Style="{StaticResource MaterialDesignOutlinedLightButton}"/>-->
<Button <Button
Margin="0 0 6 0" Margin="0 0 6 0"
@ -136,6 +136,11 @@
Content="确认" Content="确认"
Style="{StaticResource MaterialDesignOutlinedLightButton}"> Style="{StaticResource MaterialDesignOutlinedLightButton}">
</Button> </Button>
<Button
Margin="2"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消"
Command="{Binding CancleTake}" Cursor="Hand" />
<Button <Button
Margin="0 0 6 0" Margin="0 0 6 0"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -179,7 +184,7 @@
Header="性别"/> Header="性别"/>
<GridViewColumn Width="100" <GridViewColumn Width="100"
DisplayMemberBinding="{Binding OrderNo}" DisplayMemberBinding="{Binding OrderNo}"
Header="处方号"/> Header="号"/>
<!--<GridViewColumn Width="240" <!--<GridViewColumn Width="240"
DisplayMemberBinding="{Binding DeptName}" DisplayMemberBinding="{Binding DeptName}"
Header="科室"/>--> Header="科室"/>-->
@ -252,7 +257,7 @@
</ListView> </ListView>
<!--</Grid>--> <!--</Grid>-->
<pagination:Pagination Grid.Row="2" Grid.Column="2" <pagination:Pagination Grid.Row="2" Grid.ColumnSpan="2"
CurrentPage="{Binding PageNum}" CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}" PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}" TotalPages="{Binding TotalCount}"

View File

@ -51,7 +51,7 @@ namespace DM_Weight.Views
} }
private void OnTimerElapsed(object sender, ElapsedEventArgs e) private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{ {
// 串口无人操作 // 药箱是否全部关闭
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState(); bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
bool allTrue = Array.TrueForAll(boolArrs, b => b == false); bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
//logger.Info($"进入自动退出定时方法{allTrue}"); //logger.Info($"进入自动退出定时方法{allTrue}");

View File

@ -0,0 +1,14 @@
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.msg
{
//药箱(开着/关着)状态
internal class BoxOpenStatusEvent: PubSubEvent
{
}
}