麻醉师确认页面按钮保存单子状态

This commit is contained in:
maqiao 2024-11-28 10:09:37 +08:00
parent e74cd29702
commit 79f6ec12fa
6 changed files with 63 additions and 52 deletions

View File

@ -124,5 +124,6 @@
<add key="wsdSerialPort" value="COM1"/> <add key="wsdSerialPort" value="COM1"/>
<!--温度查询定时执行时间--> <!--温度查询定时执行时间-->
<add key="Interval" value="60000"/> <add key="Interval" value="60000"/>
<add key="test" value="Y"/>
</appSettings> </appSettings>
</configuration> </configuration>

View File

@ -13,10 +13,11 @@ 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)
{ {
int iLength = value[0].ToString().Length; //int iLength = value[0].ToString().Length;
int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength-3)); int iLength = value[0].ToString().IndexOf("号药箱");
int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength));
int SelectedDrawerNo = int.Parse(value[1].ToString()); int SelectedDrawerNo = int.Parse(value[1].ToString());
return ButtonDrawerNo == SelectedDrawerNo+1; return ButtonDrawerNo == SelectedDrawerNo;
} }
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)

View File

@ -56,6 +56,10 @@ namespace DM_Weight.Port
public bool[] GetAllBoxState() 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>() bool[] bools = Policy.Handle<Exception>()
.Retry(3, (exception, retryCount) => .Retry(3, (exception, retryCount) =>
{ {
@ -82,6 +86,10 @@ namespace DM_Weight.Port
} }
public bool OpenBoxDoor(int boxNum) public bool OpenBoxDoor(int boxNum)
{ {
if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
{
return true;
}
bool bFlag=false; bool bFlag=false;
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) => Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
{ {

View File

@ -775,7 +775,7 @@ namespace DM_Weight.ViewModels
RequestData(); RequestData();
Status = 1; Status = 1;
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱"); _portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
logger.Info($"正在打开{DrawerNo + 1}号药箱"); //logger.Info($"正在打开{DrawerNo + 1}号药箱");
//记录开药箱日志 //记录开药箱日志
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand(); SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);

View File

@ -24,7 +24,7 @@ namespace DM_Weight.ViewModels
internal class CheckSelfOrderWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime internal class CheckSelfOrderWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{ {
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel)); private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
System.Timers.Timer CheckBoxStatusTimer; //System.Timers.Timer CheckBoxStatusTimer;
private int _drawerType = -1; private int _drawerType = -1;
public int DrawerType public int DrawerType
@ -755,16 +755,16 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand(); SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
SetBtnEnable(DrawerNo + 1, false); SetBtnEnable(DrawerNo + 1, false);
if (CheckBoxStatusTimer is null) //if (CheckBoxStatusTimer is null)
{ //{
CheckBoxStatusTimer = new System.Timers.Timer(); // CheckBoxStatusTimer = new System.Timers.Timer();
} //}
if (!CheckBoxStatusTimer.Enabled) //if (!CheckBoxStatusTimer.Enabled)
{ //{
CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState); // CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
CheckBoxStatusTimer.Interval = 3000; // CheckBoxStatusTimer.Interval = 3000;
CheckBoxStatusTimer.Start(); // CheckBoxStatusTimer.Start();
} //}
//记录药箱打开时间 //记录药箱打开时间
ChannelList channelList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == DrawerNo + 1).First(); ChannelList channelList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == DrawerNo + 1).First();
if (channelList != null && (channelList.EffDate is null || Convert.ToDateTime(channelList.EffDate).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) if (channelList != null && (channelList.EffDate is null || Convert.ToDateTime(channelList.EffDate).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")))
@ -890,6 +890,7 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() => get => new DelegateCommand(() =>
{ {
GetUseBox(); GetUseBox();
CheckOrderAction();
}); });
} }
@ -1112,7 +1113,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);
@ -1204,16 +1205,16 @@ namespace DM_Weight.ViewModels
logger.Info($"正在打开{drawerNo}号药箱"); logger.Info($"正在打开{drawerNo}号药箱");
ModbusHelper.GetInstance().OpenBoxDoor(drawerNo - 1); ModbusHelper.GetInstance().OpenBoxDoor(drawerNo - 1);
SetBtnEnable(drawerNo, false); SetBtnEnable(drawerNo, false);
if (CheckBoxStatusTimer is null) //if (CheckBoxStatusTimer is null)
{ //{
CheckBoxStatusTimer = new System.Timers.Timer(); // CheckBoxStatusTimer = new System.Timers.Timer();
} //}
if (!CheckBoxStatusTimer.Enabled) //if (!CheckBoxStatusTimer.Enabled)
{ //{
CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState); // CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
CheckBoxStatusTimer.Interval = 3000; // CheckBoxStatusTimer.Interval = 3000;
CheckBoxStatusTimer.Start(); // CheckBoxStatusTimer.Start();
} //}
//记录药箱打开时间 //记录药箱打开时间
ChannelList channelList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == drawerNo).First(); ChannelList channelList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == drawerNo).First();
if (channelList != null && (channelList.EffDate is null || Convert.ToDateTime(channelList.EffDate).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) if (channelList != null && (channelList.EffDate is null || Convert.ToDateTime(channelList.EffDate).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")))
@ -1225,24 +1226,24 @@ namespace DM_Weight.ViewModels
} }
} }
private void GetAllBoxState(object sender, ElapsedEventArgs e) //private void GetAllBoxState(object sender, ElapsedEventArgs e)
{ //{
//查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱 // //查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱
if (DrawerNo >= 0) // if (DrawerNo >= 0)
{ // {
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState(); // bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
bool allFalse = Array.TrueForAll(boolArrs, b => b == false); // bool allFalse = Array.TrueForAll(boolArrs, b => b == false);
if (allFalse) // if (allFalse)
{ // {
if (CheckBoxStatusTimer.Enabled) // if (CheckBoxStatusTimer.Enabled)
{ // {
CheckBoxStatusTimer.Stop(); // CheckBoxStatusTimer.Stop();
} // }
} // }
//设置对应药箱按钮可用状态 // //设置对应药箱按钮可用状态
SetBtnEnable(DrawerNo, !boolArrs[DrawerNo]); // SetBtnEnable(DrawerNo, !boolArrs[DrawerNo]);
} // }
} //}
public bool IsNavigationTarget(NavigationContext navigationContext) public bool IsNavigationTarget(NavigationContext navigationContext)
{ {

View File

@ -33,7 +33,7 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid Margin="6" Grid.Column="0"> <Grid Margin="6" Grid.Column="0">
<Grid.Resources> <Grid.Resources>
@ -156,7 +156,7 @@
SelectedItem="{Binding selectOrderInfo}" SelectedItem="{Binding selectOrderInfo}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec" materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10" materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13"> materialDesign:ListViewAssist.ListViewItemPadding="3">
<ListView.Resources> <ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}"> <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" /> <Setter Property="Foreground" Value="White" />
@ -176,13 +176,13 @@
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="80" <GridViewColumn Width="60"
Header="姓名" Header="姓名"
DisplayMemberBinding="{Binding PName}" /> DisplayMemberBinding="{Binding PName}" />
<GridViewColumn Width="30" <GridViewColumn Width="30"
DisplayMemberBinding="{Binding Sex}" DisplayMemberBinding="{Binding Sex}"
Header="性别"/> Header="性别"/>
<GridViewColumn Width="100" <GridViewColumn Width="80"
DisplayMemberBinding="{Binding OrderNo}" DisplayMemberBinding="{Binding OrderNo}"
Header="单号"/> Header="单号"/>
<!--<GridViewColumn Width="240" <!--<GridViewColumn Width="240"
@ -201,28 +201,28 @@
DisplayMemberBinding="{Binding _OrderDetail.Quantity}" DisplayMemberBinding="{Binding _OrderDetail.Quantity}"
Header="数量"/>--> Header="数量"/>-->
<GridViewColumn Width="100" Header="药品名称"> <GridViewColumn Width="80" Header="药品名称">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox> <ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="100" Header="药品批次"> <GridViewColumn Width="80" Header="药品批次">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="SetManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox> <ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="SetManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="100" Header="药品效期"> <GridViewColumn Width="80" Header="药品效期">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="SetEffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox> <ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="SetEffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="100" Header="数量"> <GridViewColumn Width="40" Header="数量">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox> <ListBox ItemsSource="{Binding OrderDetailList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>