湘乡交接柜
This commit is contained in:
		
							parent
							
								
									469b8aebe1
								
							
						
					
					
						commit
						8252fba641
					
				| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
  <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;port=3306;database=xiangxiang;userid=root;password=root" />
 | 
			
		||||
	<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangxiang_xianchang;userid=root;password=root" />
 | 
			
		||||
  </connectionStrings>
 | 
			
		||||
	<!--<runtime>
 | 
			
		||||
		--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,124 +126,131 @@ namespace DM_Weight
 | 
			
		|||
 | 
			
		||||
            #region 取药
 | 
			
		||||
            // 处方取药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderTakeDrugNewWindow, OrderTakeDrugNewWindowViewModel>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderTakeAllDrugDialog, OrderTakeAllDrugDialogViewModel>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
			
		||||
            //交接柜补药
 | 
			
		||||
            containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderTakeDrugNewWindow, OrderTakeDrugNewWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderTakeAllDrugDialog, OrderTakeAllDrugDialogViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
			
		||||
            ////交接柜补药
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            // 处方取药模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
			
		||||
            // 调拨取药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<InvoiceOutWindow, InvoiceOutWindowViewModel>();
 | 
			
		||||
            // 调拨取药模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<InvoiceTakeDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<InvoiceTakeDialog, InvoiceTakeDialogViewModel>();
 | 
			
		||||
            // 抽屉取药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<DrawerTakeDrugWindow, DrawerTakeDrugWindowViewModel>();
 | 
			
		||||
            // 自选取药模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<SelfTakeDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SelfTakeDialog, SelfTakeDialogViewModel>();
 | 
			
		||||
            // 自选取药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SelfTakeDrugWindow, SelfTakeDrugWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
			
		||||
            //// 调拨取药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<InvoiceOutWindow, InvoiceOutWindowViewModel>();
 | 
			
		||||
            //// 调拨取药模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<InvoiceTakeDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<InvoiceTakeDialog, InvoiceTakeDialogViewModel>();
 | 
			
		||||
            //// 抽屉取药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<DrawerTakeDrugWindow, DrawerTakeDrugWindowViewModel>();
 | 
			
		||||
            //// 自选取药模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<SelfTakeDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SelfTakeDialog, SelfTakeDialogViewModel>();
 | 
			
		||||
            //// 自选取药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SelfTakeDrugWindow, SelfTakeDrugWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            //多处方取药
 | 
			
		||||
            containerRegistry.RegisterForNavigation<MultiOrderTakeDrugWindow, MultiOrderTakeDrugWindowViewModel>();
 | 
			
		||||
            containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
			
		||||
            ////多处方取药
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<MultiOrderTakeDrugWindow, MultiOrderTakeDrugWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
            ////手术排程
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SurgeryTakeWindow, SurgeryTakeWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterDialog<SurgeryTakeDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SurgeryTakeDialog, SurgeryTakeDialogViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterDialog<AddSurgeryDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<AddSurgeryDialog, AddSurgeryDialogViewModel>();
 | 
			
		||||
            //开药箱
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OpenBoxWindow, OpenBoxWindowViewModel>();
 | 
			
		||||
            //核对处方
 | 
			
		||||
            containerRegistry.RegisterForNavigation<CheckOrderWindow, CheckOrderWindowViewModel>();
 | 
			
		||||
            //管理员根据药箱进行核对处方
 | 
			
		||||
            containerRegistry.RegisterForNavigation<CheckOrderNewWindow, CheckOrderNewWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            //手术排程
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SurgeryTakeWindow, SurgeryTakeWindowViewModel>();
 | 
			
		||||
            containerRegistry.RegisterDialog<SurgeryTakeDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SurgeryTakeDialog, SurgeryTakeDialogViewModel>();
 | 
			
		||||
            containerRegistry.RegisterDialog<AddSurgeryDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<AddSurgeryDialog, AddSurgeryDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region 加药
 | 
			
		||||
            //#region 加药
 | 
			
		||||
            // 自选加药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
 | 
			
		||||
            // 调拨加药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
 | 
			
		||||
            //// 调拨加药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            // 调拨取药模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<InvoiceAddDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<InvoiceAddDialog, InvoiceAddDialogViewModel>();
 | 
			
		||||
            // 抽屉加药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<DrawerAddDrugWindow, DrawerAddDrugWindowViewModel>();
 | 
			
		||||
            // 自选加药模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<SelfAddDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
 | 
			
		||||
            //多批次抽屉加药
 | 
			
		||||
            containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
 | 
			
		||||
            //药品请领
 | 
			
		||||
            containerRegistry.RegisterForNavigation<CollectDrugWindow, CollectDrugWindowViewModel>();
 | 
			
		||||
            // 药品请领模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<CollectDrugDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<CollectDrugDialog, CollectDrugDialogViewModel>(); 
 | 
			
		||||
            //// 调拨取药模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<InvoiceAddDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<InvoiceAddDialog, InvoiceAddDialogViewModel>();
 | 
			
		||||
            //// 抽屉加药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<DrawerAddDrugWindow, DrawerAddDrugWindowViewModel>();
 | 
			
		||||
            //// 自选加药模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<SelfAddDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
 | 
			
		||||
            ////多批次抽屉加药
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
 | 
			
		||||
            ////药品请领
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<CollectDrugWindow, CollectDrugWindowViewModel>();
 | 
			
		||||
            //// 药品请领模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<CollectDrugDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<CollectDrugDialog, CollectDrugDialogViewModel>(); 
 | 
			
		||||
 | 
			
		||||
            //请领列表
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ApplyListWindow, ApplyListWindowViewModel>();
 | 
			
		||||
            //请领入库
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ApplyInStockWindow, ApplyInStockWindowViewModel>();
 | 
			
		||||
            ////请领列表
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ApplyListWindow, ApplyListWindowViewModel>();
 | 
			
		||||
            ////请领入库
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ApplyInStockWindow, ApplyInStockWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            #endregion
 | 
			
		||||
            //#endregion
 | 
			
		||||
 | 
			
		||||
            #region 还药
 | 
			
		||||
            // 还药页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnDrugWindow, ReturnDrugWindowViewModel>();
 | 
			
		||||
            // 按记录归还药品模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<ReturnDrugDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnDrugDialog, ReturnDrugDialogViewModel>();
 | 
			
		||||
            //#region 还药
 | 
			
		||||
            //// 还药页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnDrugWindow, ReturnDrugWindowViewModel>();
 | 
			
		||||
            //// 按记录归还药品模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<ReturnDrugDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnDrugDialog, ReturnDrugDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
            // 还药页面2
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnDrugWindow2, ReturnDrugWindow2ViewModel>();
 | 
			
		||||
            // 按处方归还药品模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<OrderReturnDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
			
		||||
            // 还空瓶页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
			
		||||
            //// 还药页面2
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnDrugWindow2, ReturnDrugWindow2ViewModel>();
 | 
			
		||||
            //// 按处方归还药品模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<OrderReturnDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
			
		||||
            //// 还空瓶页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            //空瓶销毁页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnEmptyDestoryWindow, ReturnEmptyDestoryWindowViewModel>();
 | 
			
		||||
            ////空瓶销毁页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnEmptyDestoryWindow, ReturnEmptyDestoryWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            // 归还空瓶模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
			
		||||
            // 空瓶销毁模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<DestoryEmptyDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<DestoryEmptyDialog, DestoryEmptyDialogViewModel>();
 | 
			
		||||
            //// 归还空瓶模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
			
		||||
            //// 空瓶销毁模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<DestoryEmptyDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<DestoryEmptyDialog, DestoryEmptyDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            #endregion
 | 
			
		||||
            //#endregion
 | 
			
		||||
 | 
			
		||||
            #region 库存管理
 | 
			
		||||
            // 库存列表页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<StockListWindow, StockListWindowViewModel>();
 | 
			
		||||
            // 库位绑定模态框
 | 
			
		||||
            containerRegistry.RegisterDialog<BindingChannelDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
 | 
			
		||||
            //同一药品多批次库位绑定
 | 
			
		||||
            containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
 | 
			
		||||
            // 库存盘点页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
 | 
			
		||||
            // 药品列表页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
 | 
			
		||||
            //#region 库存管理
 | 
			
		||||
            //// 库存列表页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<StockListWindow, StockListWindowViewModel>();
 | 
			
		||||
            //// 库位绑定模态框
 | 
			
		||||
            //containerRegistry.RegisterDialog<BindingChannelDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
 | 
			
		||||
            ////同一药品多批次库位绑定
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
 | 
			
		||||
            //// 库存盘点页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
 | 
			
		||||
            //// 药品列表页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            //交接班记录
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ChangeShiftsListWindow, ChangeShiftsListWindowViewModel>();
 | 
			
		||||
            //交接班弹窗
 | 
			
		||||
            containerRegistry.RegisterDialog<ChangeShiftsDialog>();
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
 | 
			
		||||
            ////交接班记录
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ChangeShiftsListWindow, ChangeShiftsListWindowViewModel>();
 | 
			
		||||
            ////交接班弹窗
 | 
			
		||||
            //containerRegistry.RegisterDialog<ChangeShiftsDialog>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
            containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
 | 
			
		||||
            #endregion
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
 | 
			
		||||
            //#endregion
 | 
			
		||||
 | 
			
		||||
            #region 系统设置
 | 
			
		||||
            // 用户管理页面
 | 
			
		||||
| 
						 | 
				
			
			@ -256,18 +263,22 @@ namespace DM_Weight
 | 
			
		|||
            // 系统设置
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SettingWindow, SettingWindowViewModel>();
 | 
			
		||||
            // 调试页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<DebugWindow, DebugWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<DebugWindow, DebugWindowViewModel>();
 | 
			
		||||
            //主设置页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SettingMainWindow, SettingMainWindowViewModel>();
 | 
			
		||||
            //两个冰箱抽屉设置页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<FridgeWindow, FridgeWindowViewModel>();
 | 
			
		||||
            //只有一个冰箱抽屉设置页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<FridgeOnlyWindow, FridgeOnlyWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<FridgeWindow, FridgeWindowViewModel>();
 | 
			
		||||
            ////只有一个冰箱抽屉设置页面
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<FridgeOnlyWindow, FridgeOnlyWindowViewModel>();
 | 
			
		||||
            //绑定药箱套餐
 | 
			
		||||
            containerRegistry.RegisterForNavigation<BindBoxPackageWindow, BindBoxPackageWindowViewModel>();
 | 
			
		||||
            //药箱设置
 | 
			
		||||
            containerRegistry.RegisterForNavigation<SettingBoxWindow, SettingBoxWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            // 设备记录页面
 | 
			
		||||
            containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
			
		||||
            //containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
			
		||||
 | 
			
		||||
            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Converter
 | 
			
		||||
{
 | 
			
		||||
    class BoxNumConverter : IValueConverter
 | 
			
		||||
    {
 | 
			
		||||
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            string str=value.ToString();
 | 
			
		||||
            return !(str == parameter.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,8 @@ namespace DM_Weight.Converter
 | 
			
		|||
    {
 | 
			
		||||
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            int ButtonDrawerNo = int.Parse(value[0].ToString());
 | 
			
		||||
            int iLength = value[0].ToString().Length;
 | 
			
		||||
            int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength-3));
 | 
			
		||||
            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
			
		||||
            return ButtonDrawerNo == SelectedDrawerNo;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,11 +22,11 @@ namespace DM_Weight.Converter
 | 
			
		|||
            {
 | 
			
		||||
                foreach (var item in items)
 | 
			
		||||
                {
 | 
			
		||||
                    var de = item as ChannelStock;
 | 
			
		||||
                    var de = item as OrderDetail;
 | 
			
		||||
                    total += de.Quantity;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return "总库存:" + total;
 | 
			
		||||
            return "用药总数:" + total;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Converter
 | 
			
		||||
{
 | 
			
		||||
    class OpenBoxSelectConverter : IMultiValueConverter
 | 
			
		||||
    {
 | 
			
		||||
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            int ButtonDrawerNo=0;
 | 
			
		||||
            switch (value[0].ToString())
 | 
			
		||||
            {
 | 
			
		||||
                case "开名下药箱":
 | 
			
		||||
                    ButtonDrawerNo = 0;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "开公共药箱":
 | 
			
		||||
                    ButtonDrawerNo = 1;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
			
		||||
            return ButtonDrawerNo == SelectedDrawerNo;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Converter
 | 
			
		||||
{
 | 
			
		||||
    public class OpenStatusConverter : IValueConverter
 | 
			
		||||
    {
 | 
			
		||||
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            bool status = bool.Parse(value.ToString());
 | 
			
		||||
                if (status)
 | 
			
		||||
                {
 | 
			
		||||
                    return Visibility.Visible;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    return Visibility.Collapsed;
 | 
			
		||||
                }
 | 
			
		||||
            return Visibility.Collapsed;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -123,12 +123,6 @@
 | 
			
		|||
    </None>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Page Update="Views\Dialog\InvoiceTakeDialog.xaml">
 | 
			
		||||
      <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
 | 
			
		||||
    </Page>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Folder Include="HIKVISION\" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ namespace DM_Weight.Models
 | 
			
		|||
        /// 药品id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "drug_id")]
 | 
			
		||||
        public int DrugId { get; set; }
 | 
			
		||||
        public string DrugId { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 1领入2发出3日结4总结5转结
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,13 +81,13 @@ namespace DM_Weight.Models
 | 
			
		|||
        ///  
 | 
			
		||||
        /// 默认值: 1
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "board_type")]
 | 
			
		||||
        [SugarColumn(IsIgnore =true)]
 | 
			
		||||
        public int BoardType { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: 1
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "state")]
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
        public int? State { get; set; }
 | 
			
		||||
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +101,11 @@ namespace DM_Weight.Models
 | 
			
		|||
        {
 | 
			
		||||
            get => DrawerNo + "-" + ColNo;
 | 
			
		||||
        }
 | 
			
		||||
        [SugarColumn(ColumnName ="yh_no")]
 | 
			
		||||
        public string BelongUser
 | 
			
		||||
        {
 | 
			
		||||
            get;set;
 | 
			
		||||
        }
 | 
			
		||||
        //private int _addQuantity = 0;
 | 
			
		||||
        //[SugarColumn(IsIgnore = true)]
 | 
			
		||||
        //public int AddQuantity
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -167,6 +167,19 @@ namespace DM_Weight.Models
 | 
			
		|||
                SetProperty(ref _checkQuantity, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品基数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private int _baseQuantity = 0;
 | 
			
		||||
        [SugarColumn(ColumnName = "Check_Quantity")]
 | 
			
		||||
        public int BaseQuantity
 | 
			
		||||
        {
 | 
			
		||||
            get => _baseQuantity;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _baseQuantity, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
| 
						 | 
				
			
			@ -175,6 +188,7 @@ namespace DM_Weight.Models
 | 
			
		|||
        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
			
		||||
        public DrugInfo DrugInfo { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
        public int process { get; set; } = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ namespace DM_Weight.Models
 | 
			
		|||
        /// ҩƷID 
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
			
		||||
        public long DrugId { get; set; }
 | 
			
		||||
        public string DrugId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// ƴ 
 | 
			
		||||
        ///</summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,14 +13,14 @@ namespace DM_Weight.Models
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
			
		||||
        public int Id { get; set; }
 | 
			
		||||
        //[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
			
		||||
        //public int Id { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        //[SugarColumn(ColumnName = "order_id")]
 | 
			
		||||
        //public int? OrderId { get; set; }
 | 
			
		||||
        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true)]
 | 
			
		||||
        public int? OrderId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -139,5 +139,9 @@ namespace DM_Weight.Models
 | 
			
		|||
 | 
			
		||||
        [SugarColumn(IsIgnore =true)]
 | 
			
		||||
        public string ColNo { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [Navigate(NavigateType.ManyToOne, nameof(OrderId))]
 | 
			
		||||
        public OrderInfo _OrderInfo { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
namespace DM_Weight.Models
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -8,157 +9,181 @@ namespace DM_Weight.Models
 | 
			
		|||
    /// 
 | 
			
		||||
    ///</summary>
 | 
			
		||||
    [SugarTable("order_info")]
 | 
			
		||||
    public class OrderInfo
 | 
			
		||||
    public class OrderInfo:BindableBase
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否选中
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _itemIsChecked;
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
        public bool ItemIsChecked { get; set; }
 | 
			
		||||
        public bool ItemIsChecked { get=> _itemIsChecked; set=>SetProperty(ref _itemIsChecked,value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private int _orderId;
 | 
			
		||||
        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true, IsIdentity = true)]
 | 
			
		||||
        public int OrderId { get; set; }
 | 
			
		||||
        public int OrderId { get=> _orderId; set=>SetProperty(ref _orderId,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _pharmacy;
 | 
			
		||||
        [SugarColumn(ColumnName = "pharmacy")]
 | 
			
		||||
        public string Pharmacy { get; set; }
 | 
			
		||||
        public string Pharmacy { get=>_pharmacy; set=>SetProperty(ref _pharmacy,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _orderNo;
 | 
			
		||||
        [SugarColumn(ColumnName = "order_no")]
 | 
			
		||||
        public string OrderNo { get; set; }
 | 
			
		||||
        public string OrderNo { get=> _orderNo; set=>SetProperty(ref _orderNo,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _patientId;
 | 
			
		||||
        [SugarColumn(ColumnName = "patient_id")]
 | 
			
		||||
        public string PatientId { get; set; }
 | 
			
		||||
        public string PatientId { get=> _patientId; set=>SetProperty(ref _patientId,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _pName;
 | 
			
		||||
        [SugarColumn(ColumnName = "p_name")]
 | 
			
		||||
        public string PName { get; set; }
 | 
			
		||||
        public string PName { get=> _pName; set=>SetProperty(ref _pName,value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _sex;
 | 
			
		||||
        [SugarColumn(ColumnName = "sex")]
 | 
			
		||||
        public string Sex { get; set; }
 | 
			
		||||
        public string Sex { get=> _sex; set=>SetProperty(ref _sex,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _age;
 | 
			
		||||
        [SugarColumn(ColumnName = "age")]
 | 
			
		||||
        public string Age { get; set; }
 | 
			
		||||
        public string Age { get=> _age; set=>SetProperty(ref _age,value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _idNumber;
 | 
			
		||||
        [SugarColumn(ColumnName = "id_number")]
 | 
			
		||||
        public string IdNumber { get; set; }
 | 
			
		||||
        public string IdNumber { get=> _idNumber; set=> SetProperty(ref _idNumber, value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _patientCard;
 | 
			
		||||
        [SugarColumn(ColumnName = "patient_card")]
 | 
			
		||||
        public string PatientCard { get; set; }
 | 
			
		||||
        public string PatientCard { get=> _patientCard; set=>SetProperty(ref _patientCard,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _invoiceNo;
 | 
			
		||||
        [SugarColumn(ColumnName = "invoice_no")]
 | 
			
		||||
        public string InvoiceNo { get; set; }
 | 
			
		||||
        public string InvoiceNo { get=> _invoiceNo; set=>SetProperty(ref _invoiceNo,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _patientNo;
 | 
			
		||||
        [SugarColumn(ColumnName = "patient_no")]
 | 
			
		||||
        public string PatientNo { get; set; }
 | 
			
		||||
        public string PatientNo { get=> _patientNo; set=>SetProperty(ref _patientNo,value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _doctorName;
 | 
			
		||||
        [SugarColumn(ColumnName = "doctor_name")]
 | 
			
		||||
        public string DoctorName { get; set; }
 | 
			
		||||
        public string DoctorName { get=> _doctorName; set=>SetProperty(ref _doctorName,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private DateTime _orderDate;
 | 
			
		||||
        [SugarColumn(ColumnName = "order_date")]
 | 
			
		||||
        public DateTime OrderDate { get; set; }
 | 
			
		||||
        public DateTime OrderDate { get=> _orderDate; set=>SetProperty(ref _orderDate,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private DateTime _chargeDate;
 | 
			
		||||
        [SugarColumn(ColumnName = "charge_date")]
 | 
			
		||||
        public DateTime ChargeDate { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private DateTime _recvDate;
 | 
			
		||||
        [SugarColumn(ColumnName = "recv_date")]
 | 
			
		||||
        public DateTime RecvDate { get; set; }
 | 
			
		||||
        public DateTime RecvDate { get=> _recvDate; set=>SetProperty(ref _recvDate,value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _deptName;
 | 
			
		||||
        [SugarColumn(ColumnName = "dept_name")]
 | 
			
		||||
        public string DeptName { get; set; }
 | 
			
		||||
        public string DeptName { get=> _deptName; set=>SetProperty(ref _deptName,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _disease;
 | 
			
		||||
        [SugarColumn(ColumnName = "disease")]
 | 
			
		||||
        public string Disease { get; set; }
 | 
			
		||||
        public string Disease { get=> _disease; set=>SetProperty(ref _disease,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _orderType;
 | 
			
		||||
        [SugarColumn(ColumnName = "order_type")]
 | 
			
		||||
        public string OrderType { get; set; }
 | 
			
		||||
        public string OrderType { get=> _orderType; set=>SetProperty(ref _orderType,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private string _chargeType;
 | 
			
		||||
        [SugarColumn(ColumnName = "charge_type")]
 | 
			
		||||
        public string ChargeType { get; set; }
 | 
			
		||||
        public string ChargeType { get=> _chargeType; set=>SetProperty(ref _chargeType,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private int _state;
 | 
			
		||||
        [SugarColumn(ColumnName = "state")]
 | 
			
		||||
        public int State { get; set; }
 | 
			
		||||
        public int State { get=> _state; set=>SetProperty(ref _state,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: 0
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private int? _hisDispFlag;
 | 
			
		||||
        [SugarColumn(ColumnName = "his_disp_flag")]
 | 
			
		||||
        public int? HisDispFlag { get; set; }
 | 
			
		||||
        public int? HisDispFlag { get=> _hisDispFlag; set=>SetProperty(ref _hisDispFlag,value); }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: 0
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        ///</summary>]
 | 
			
		||||
        private int? _cancelFlag;
 | 
			
		||||
        [SugarColumn(ColumnName = "cancel_flag")]
 | 
			
		||||
        public int? CancelFlag { get; set; }
 | 
			
		||||
        public int? CancelFlag { get=> _cancelFlag; set=>SetProperty(ref _cancelFlag,value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: 0
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        private int? _dmStatus;
 | 
			
		||||
        [SugarColumn(ColumnName = "dm_status")]
 | 
			
		||||
        public int? DmStatus { get; set; }
 | 
			
		||||
        public int? DmStatus { get=> _dmStatus; set=>SetProperty(ref _dmStatus,value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  
 | 
			
		||||
        /// 默认值: NULL
 | 
			
		||||
| 
						 | 
				
			
			@ -213,5 +238,21 @@ namespace DM_Weight.Models
 | 
			
		|||
        //public string Identity { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        [Navigate(NavigateType.OneToMany, nameof(OrderDetail.OrderId))]
 | 
			
		||||
        public List<OrderDetail> OrderDetailList { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //一个处方对应一种药
 | 
			
		||||
        [Navigate(NavigateType.OneToOne, nameof(OrderDetail.OrderId))]
 | 
			
		||||
        public OrderDetail _OrderDetail { get; set; }
 | 
			
		||||
 | 
			
		||||
        //处方下药品总数
 | 
			
		||||
        [SugarColumn(IsIgnore =true)]
 | 
			
		||||
        public int TotalQuantity { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //麻醉师工号
 | 
			
		||||
        [SugarColumn(ColumnName = "doctorCode")]
 | 
			
		||||
        public string DoctorCode { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +128,96 @@ namespace DM_Weight.Port
 | 
			
		|||
            DrawerNo = 0;
 | 
			
		||||
            ColNos = new int[] { };
 | 
			
		||||
        }
 | 
			
		||||
        public async void OpenBox()
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info($"打开药箱,药箱号【{DrawerNo}】");
 | 
			
		||||
            Operate = true;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                byte[] buffer = await OpenDrawer();
 | 
			
		||||
                int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
 | 
			
		||||
 | 
			
		||||
                logger.Info($"OpenDrawer{string.Join(",", r)}");
 | 
			
		||||
                if (DrawerState(r))
 | 
			
		||||
                {
 | 
			
		||||
                    statue = 1;
 | 
			
		||||
                    // 返回消息  抽屉已经打开
 | 
			
		||||
                    _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
			
		||||
                    {
 | 
			
		||||
                        EventType = util.EventType.DRAWEROPEN,
 | 
			
		||||
                        WindowName = WindowName,
 | 
			
		||||
                    });
 | 
			
		||||
                    logger.Info($"药箱【{DrawerNo}】打开成功");
 | 
			
		||||
                    await Task.Delay(200);
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    // 返回消息  抽屉打开失败
 | 
			
		||||
                    _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
			
		||||
                    {
 | 
			
		||||
                        EventType = util.EventType.OPENERROR,
 | 
			
		||||
                        WindowName = WindowName,
 | 
			
		||||
                        Message = $"药箱【{DrawerNo}】打开失败"
 | 
			
		||||
                    });
 | 
			
		||||
                    logger.Info($"药箱【{DrawerNo}】打开失败");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
			
		||||
                {
 | 
			
		||||
                    EventType = util.EventType.OPENERROR, 
 | 
			
		||||
                    Message = $"打开药箱异常{ex.Message}"
 | 
			
		||||
                });
 | 
			
		||||
                logger.Info($"打开药箱{DrawerNo}异常:{ex.Message}");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        //查询药箱状态
 | 
			
		||||
        public async void GetBoxStatus()
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (Operate)
 | 
			
		||||
                {
 | 
			
		||||
                    // 查询药箱状态
 | 
			
		||||
                    byte[] buffer = await CheckBoxStatus();
 | 
			
		||||
 | 
			
		||||
                    int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
 | 
			
		||||
 | 
			
		||||
                    logger.Info($"GetBoxStatus{string.Join(",", r)}");
 | 
			
		||||
                    // 药箱没有关闭
 | 
			
		||||
                    if (DrawerState(r))
 | 
			
		||||
                    {
 | 
			
		||||
                        // 继续监听药箱状态
 | 
			
		||||
                        await Task.Delay(200);
 | 
			
		||||
                        GetBoxStatus();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        // 返回消息  药箱已经关闭
 | 
			
		||||
                        _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
			
		||||
                        {
 | 
			
		||||
                            EventType = util.EventType.DRAWERCLOSE,
 | 
			
		||||
                        });
 | 
			
		||||
                        logger.Info($"抽屉【{DrawerNo}】已关闭");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
			
		||||
                {
 | 
			
		||||
                    EventType = util.EventType.OPENERROR,
 | 
			
		||||
                    WindowName = WindowName,
 | 
			
		||||
                    Message = $"GetBoxStatus异常:{ex.Message}"
 | 
			
		||||
                });
 | 
			
		||||
                logger.Info($"GetBoxStatus异常:{ex.Message}");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public async void Start()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -663,23 +752,29 @@ namespace DM_Weight.Port
 | 
			
		|||
            byte[] buffer = new byte[length];
 | 
			
		||||
            // try
 | 
			
		||||
            // {
 | 
			
		||||
                int _length = 0;
 | 
			
		||||
                DateTime start = DateTime.Now;
 | 
			
		||||
                DateTime end = DateTime.Now;
 | 
			
		||||
                while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
			
		||||
            int _length = 0;
 | 
			
		||||
            DateTime start = DateTime.Now;
 | 
			
		||||
            DateTime end = DateTime.Now;
 | 
			
		||||
            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
			
		||||
            {
 | 
			
		||||
                _length = serialPort.BytesToRead;
 | 
			
		||||
                end = DateTime.Now;
 | 
			
		||||
            }
 | 
			
		||||
            if (_length != length)
 | 
			
		||||
            {
 | 
			
		||||
                if (_length != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _length = serialPort.BytesToRead;
 | 
			
		||||
                    end = DateTime.Now;
 | 
			
		||||
                    byte[] _buffer = new byte[_length];
 | 
			
		||||
                    serialPort.Read(_buffer, 0, _length);
 | 
			
		||||
                    logger.Info($"交互超时回复:{Convert.ToHexString(buffer)}");
 | 
			
		||||
                }
 | 
			
		||||
                if (_length != length)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
			
		||||
                }
 | 
			
		||||
                serialPort.Read(buffer, 0, length);
 | 
			
		||||
                throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
			
		||||
            }
 | 
			
		||||
            serialPort.Read(buffer, 0, length);
 | 
			
		||||
            // }
 | 
			
		||||
            // catch (Exception ex)
 | 
			
		||||
            // {
 | 
			
		||||
                // logger.Error($"GetBufferByPort:{ex.Message}");
 | 
			
		||||
            // logger.Error($"GetBufferByPort:{ex.Message}");
 | 
			
		||||
            // }
 | 
			
		||||
            return buffer;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -751,6 +846,29 @@ namespace DM_Weight.Port
 | 
			
		|||
 | 
			
		||||
            return await GetBufferByPort(drawerSerial, 11);
 | 
			
		||||
        }
 | 
			
		||||
        // 查询药箱状态
 | 
			
		||||
        public async Task<byte[]> CheckBoxStatus()
 | 
			
		||||
        {
 | 
			
		||||
            drawerSerial.DiscardInBuffer();
 | 
			
		||||
            byte[] buffer = new byte[] { 0xaa, 0x42, 0xee };
 | 
			
		||||
            if (_drawerProtocol == 485)
 | 
			
		||||
            {
 | 
			
		||||
                if (DrawerNo > 8)
 | 
			
		||||
                {
 | 
			
		||||
                    buffer = new byte[] { 0xaa, 0x22, 0xee };
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    buffer = new byte[] { 0xaa, 0x12, 0xee };
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            logger.Info($"查询抽屉状态,串口数据:{Convert.ToHexString(buffer)}");
 | 
			
		||||
            drawerSerial.Write(buffer, 0, 3);
 | 
			
		||||
 | 
			
		||||
            return await GetBufferByPort(drawerSerial, 11);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region can总线串口操作
 | 
			
		||||
| 
						 | 
				
			
			@ -975,7 +1093,7 @@ namespace DM_Weight.Port
 | 
			
		|||
            var vlock = 321;
 | 
			
		||||
            decimal decolNO = (decimal)ColNo;
 | 
			
		||||
            var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO % 3)).ToString(), 16);
 | 
			
		||||
            byte[] buffer = new byte[] { 0xaa, (byte)channel, 5,(byte)vlock, 0x00,0x00,0x00,0xee};
 | 
			
		||||
            byte[] buffer = new byte[] { 0xaa, (byte)channel, 5, (byte)vlock, 0x00, 0x00, 0x00, 0xee };
 | 
			
		||||
            canBusSerial.Write(buffer, 0, 8);
 | 
			
		||||
            await Task.Delay(TimeSpan.FromMilliseconds(20));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -988,7 +1106,7 @@ namespace DM_Weight.Port
 | 
			
		|||
        {
 | 
			
		||||
            decimal deColNo = (decimal)ColNo;
 | 
			
		||||
            var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(deColNo / 3)).ToString(), 16);
 | 
			
		||||
            byte[] buffer = new byte[] {0xaa,(byte)channel,2,0,0,0,0,0xee };
 | 
			
		||||
            byte[] buffer = new byte[] { 0xaa, (byte)channel, 2, 0, 0, 0, 0, 0xee };
 | 
			
		||||
            canBusSerial.Write(buffer, 0, 8);
 | 
			
		||||
            return await GetBufferByPort(canBusSerial, 8);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1082,7 +1200,7 @@ namespace DM_Weight.Port
 | 
			
		|||
            {
 | 
			
		||||
 | 
			
		||||
                canBusSerial.DiscardInBuffer();
 | 
			
		||||
                int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(),16);
 | 
			
		||||
                int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(), 16);
 | 
			
		||||
                byte[] buffer = new byte[] { 0xaa, (byte)channel, 6, 0, 0, 0, 0, 0xee };
 | 
			
		||||
                buffer[3] = (byte)(quantity >> 8);
 | 
			
		||||
                buffer[4] = (byte)(quantity & 0xff);
 | 
			
		||||
| 
						 | 
				
			
			@ -1131,7 +1249,7 @@ namespace DM_Weight.Port
 | 
			
		|||
 | 
			
		||||
        #region 标签显示屏
 | 
			
		||||
        //清屏
 | 
			
		||||
        public void ClearContentMethod(int drawerNo,int colNo)
 | 
			
		||||
        public void ClearContentMethod(int drawerNo, int colNo)
 | 
			
		||||
        {
 | 
			
		||||
            decimal deColNo = colNo;
 | 
			
		||||
            var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
 | 
			
		||||
| 
						 | 
				
			
			@ -1521,7 +1639,7 @@ namespace DM_Weight.Port
 | 
			
		|||
        /// 冰箱温度设定最小
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task FridgeMinSetting(float min,int iIndex)
 | 
			
		||||
        public async Task FridgeMinSetting(float min, int iIndex)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -1560,7 +1678,7 @@ namespace DM_Weight.Port
 | 
			
		|||
        /// 冰箱温度设定最大
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task FridgeMaxSetting(float max,int iIndex)
 | 
			
		||||
        public async Task FridgeMaxSetting(float max, int iIndex)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -1605,9 +1723,9 @@ namespace DM_Weight.Port
 | 
			
		|||
            {
 | 
			
		||||
                fridgeSerial.DiscardInBuffer();
 | 
			
		||||
                byte bAddress;
 | 
			
		||||
                if (iIndex == 1 )
 | 
			
		||||
                if (iIndex == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    bAddress=0x01;
 | 
			
		||||
                    bAddress = 0x01;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
| 
						 | 
				
			
			@ -1653,7 +1771,7 @@ namespace DM_Weight.Port
 | 
			
		|||
        /// 设置冰箱温度
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<float> SetFridgeTemperature(float temperature,int iIndex)
 | 
			
		||||
        public async Task<float> SetFridgeTemperature(float temperature, int iIndex)
 | 
			
		||||
        {
 | 
			
		||||
            int tpt = (int)temperature * 10;
 | 
			
		||||
            byte Temperature = (byte)(tpt & 0xff);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,379 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class AccountWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public static AccountWindowViewModel vm;
 | 
			
		||||
        //private int _pageNum = 1;
 | 
			
		||||
        //public int PageNum
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageNum;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageNum, value);
 | 
			
		||||
        //        RequestData();
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _pageCount = 1;
 | 
			
		||||
        //public int PageCount
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageCount;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageCount, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _pageSize = 8;
 | 
			
		||||
        //public int PageSize
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageSize;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageSize, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _totalCount = 0;
 | 
			
		||||
        //public int TotalCount
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _totalCount;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _totalCount, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
        private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        private DateTime? nowDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        public DateTime? StartDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _startDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
 | 
			
		||||
 | 
			
		||||
        public DateTime? EndDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _endDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
			
		||||
                    SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _endDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 账册
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<AccountBookG2> _accountList = new();
 | 
			
		||||
 | 
			
		||||
        public List<AccountBookG2> AccountList
 | 
			
		||||
        {
 | 
			
		||||
            get => _accountList;
 | 
			
		||||
            set => SetProperty(ref _accountList, value);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<DrugInfo>? _drugInfos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfos;
 | 
			
		||||
            set => SetProperty(ref _drugInfos, value);
 | 
			
		||||
        }
 | 
			
		||||
        private DrugInfo? _drugInfo;
 | 
			
		||||
 | 
			
		||||
        public DrugInfo? DrugInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugInfo, value);
 | 
			
		||||
                //if (_drugInfo != null)
 | 
			
		||||
                //{
 | 
			
		||||
                //DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
 | 
			
		||||
                //}
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 账册类型1入2出3总结存
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<AccountType> _accountTypeList = new List<AccountType>() {
 | 
			
		||||
                new AccountType
 | 
			
		||||
                {
 | 
			
		||||
                    AccountTypeName="借入",
 | 
			
		||||
                    AccountTypeValue=1
 | 
			
		||||
                },
 | 
			
		||||
                new AccountType
 | 
			
		||||
                {
 | 
			
		||||
                    AccountTypeName="发出",
 | 
			
		||||
                    AccountTypeValue=2
 | 
			
		||||
                },
 | 
			
		||||
                new AccountType
 | 
			
		||||
                {
 | 
			
		||||
                    AccountTypeName="日结存",
 | 
			
		||||
                    AccountTypeValue=3
 | 
			
		||||
                },
 | 
			
		||||
                new AccountType
 | 
			
		||||
                {
 | 
			
		||||
                    AccountTypeName="总结存",
 | 
			
		||||
                    AccountTypeValue=4
 | 
			
		||||
                }
 | 
			
		||||
        };
 | 
			
		||||
        public List<AccountType>? AccountTypeList
 | 
			
		||||
        {
 | 
			
		||||
            get => _accountTypeList;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _accountTypeList, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private AccountType? _accountType;
 | 
			
		||||
        public AccountType AccountType
 | 
			
		||||
        {
 | 
			
		||||
            get => _accountType;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _accountType, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品类型
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<DrugType> _drugTypeList = new List<DrugType>()
 | 
			
		||||
        {
 | 
			
		||||
            new DrugType{ TypeValue=1,TypeName="精一"},
 | 
			
		||||
            new DrugType{TypeValue=2,TypeName="精二"}
 | 
			
		||||
        };
 | 
			
		||||
        public List<DrugType>? DrugTypeList
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugTypeList;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugTypeList, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugType? _drugType;
 | 
			
		||||
        public DrugType? _DrugType
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugType; set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugType, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //MachineRecordService _machineRecordService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        ////private SqlSugarScope SqlSugarHelper.Db;
 | 
			
		||||
        public AccountWindowViewModel( IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            //_machineRecordService = machineRecord;
 | 
			
		||||
            ////this.SqlSugarHelper.Db = sqlSugarScope;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            vm = this;
 | 
			
		||||
        }
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            AccountList = ReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, _DrugType == null ? 0 : _DrugType.TypeValue, DrugInfo == null ? "" : DrugInfo.DrugId.ToString() ?? "");
 | 
			
		||||
            //for (int i = 0; i < accountList.Count; i++)
 | 
			
		||||
            //{
 | 
			
		||||
            //    if (accountList[i].DrugInfo is null)
 | 
			
		||||
            //    {
 | 
			
		||||
            //        DrugInfo drug= new DrugInfo();
 | 
			
		||||
            //        drug.DrugId = accountList[i].DrugId;
 | 
			
		||||
            //        drug.DrugName = accountList[i].DrugName;
 | 
			
		||||
            //        drug.DrugSpec = accountList[i].DrugSpec;
 | 
			
		||||
            //        drug.Dosage= accountList[i].Dosage;
 | 
			
		||||
            //        drug.PackUnit= accountList[i].PackUnit;
 | 
			
		||||
            //        drug.Manufactory= accountList[i].Manufactory;
 | 
			
		||||
            //        accountList[i].DrugInfo= drug;
 | 
			
		||||
            //    }
 | 
			
		||||
            //}
 | 
			
		||||
            //ICollectionView vw = CollectionViewSource.GetDefaultView(accountList);
 | 
			
		||||
            //vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        private void GetAllDrugInfos()
 | 
			
		||||
        {
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
            DrugInfos = list;
 | 
			
		||||
            DrugInfo = list[0];
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 导出发药登记表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand DownloadOrderUser
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => {
 | 
			
		||||
                GridReportUtil.OrderUseReport(StartDate, EndDate,  DrugInfo == null ? "" : DrugInfo.DrugId.ToString() ?? "");
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 导出账册
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand DownloadAccountBook
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GridReportUtil.PrintReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, DrugInfo == null ? "" : DrugInfo.DrugId.ToString() ?? "");
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 刷新
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => true;
 | 
			
		||||
 | 
			
		||||
        public void UpdateComboBoxItems(string text)
 | 
			
		||||
        {
 | 
			
		||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
			
		||||
                        d.manufactory,d.max_stock FROM `drug_info` d";
 | 
			
		||||
            if (string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (DrugInfos != null)
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos.Clear();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //药品信息
 | 
			
		||||
            GetAllDrugInfos();
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<AccountBookG2> ReportAccountBook(DateTime? startDate, DateTime? endDate, int type,int drugType, string drug_id = "")
 | 
			
		||||
        {
 | 
			
		||||
            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
			
		||||
            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
			
		||||
            string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM3");
 | 
			
		||||
            string SQL = $@" SELECT ac.create_date as CreateDate, ac.TYPE,
 | 
			
		||||
	                     if(ac.type in(1,2),0,ac.yesterday_quantity) as YQuantity,if(ac.type in(3,4),0,ac.add_quantity) as AddQuantity,if(ac.type in(3,4),0,ac.out_quantity) as OutQuantity,
 | 
			
		||||
	                     if(ac.type in(1,2),0,ac.manu_stock) as ManuStock,ac.total_stock, -- if(ac.type in(1,2),0,ac.total_stock) as TotalStock,
 | 
			
		||||
	                     ac.invoice_no as InvoiceNo, ac.manu_no as ManuNo,ac.eff_date as EffDate,di.drug_id,di.drug_name as DrugName,di.drug_spec as DrugSpec,di.manufactory as Manufactory,di.pack_unit,di.dosage,u1.user_name as OperatorName,u2.user_name as ReviewerName
 | 
			
		||||
	                     FROM account_book_g2 ac left join drug_info di on ac.drug_id=di.drug_id left join user_list u1 on ac.user_id1=u1.id left join user_list u2 on ac.user_id2=u2.id
 | 
			
		||||
 		                    WHERE ac.machine_id='{p_machine_id}' and create_time>'{p_startDate}' AND create_time<'{p_endDate}' ";
 | 
			
		||||
            //if (!string.IsNullOrEmpty(drug_id))
 | 
			
		||||
            //{
 | 
			
		||||
            //    SQL += " AND ac.drug_id='" + drug_id + "' ";
 | 
			
		||||
            //}
 | 
			
		||||
            if (type > 0)
 | 
			
		||||
            {
 | 
			
		||||
                if (type == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    SQL += "  AND ac.add_quantity>0 ";
 | 
			
		||||
                }
 | 
			
		||||
                if (type == 2)
 | 
			
		||||
                {
 | 
			
		||||
                    SQL += " AND ac.out_quantity>0 ";
 | 
			
		||||
                }
 | 
			
		||||
                if (type == 3)
 | 
			
		||||
                {
 | 
			
		||||
                    SQL += " AND type=3 ";
 | 
			
		||||
                }
 | 
			
		||||
                if (type == 4)
 | 
			
		||||
                {
 | 
			
		||||
                    SQL += " AND type=4  ";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (drugType > 0)
 | 
			
		||||
            {
 | 
			
		||||
                SQL += $" AND di.Drug_type={drugType}";
 | 
			
		||||
            }
 | 
			
		||||
            SQL += " ORDER BY ac.create_date desc,ac.drug_id";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
 | 
			
		||||
 | 
			
		||||
            List<AccountBookG2> accountList = SqlSugarHelper.Db.SqlQueryable<AccountBookG2>(SQL)
 | 
			
		||||
                                                                         //.AddParameters(new
 | 
			
		||||
                                                                         //{
 | 
			
		||||
                                                                         //    machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                                                                         //})
 | 
			
		||||
                                                                       //.Select(it => new { o = new AccountModel(), i = new DrugInfo() })
 | 
			
		||||
                                                                       //.Select(it=>new AccountModel())
 | 
			
		||||
                                                                       //.Select("*") //让上面一行不生成sql
 | 
			
		||||
                                                                       .ToList();
 | 
			
		||||
 | 
			
		||||
            //List<AccountModel> accountList=new List<AccountModel>();
 | 
			
		||||
            return accountList;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,529 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Drawing.Printing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection.PortableExecutable;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class AddDrugControlViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
 | 
			
		||||
        private List<int> _drawerNoList = new List<int>();
 | 
			
		||||
        public static AddDrugControlViewModel vm;
 | 
			
		||||
        //凭证号
 | 
			
		||||
        //private string _pzh;
 | 
			
		||||
        //public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelList>? _channelLsts;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelList>? ChannelLsts
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelLsts;
 | 
			
		||||
            set => SetProperty(ref _channelLsts, value);
 | 
			
		||||
        }
 | 
			
		||||
        private List<ChannelStock> __channelStocks = new List<ChannelStock>();
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => __channelStocks;
 | 
			
		||||
            set => SetProperty(ref __channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock? _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock? CStock
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStock;
 | 
			
		||||
            set => SetProperty(ref _channelStock, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //private ChannelList? _channelList;
 | 
			
		||||
        //public ChannelList? ChannelLst
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _channelList;
 | 
			
		||||
        //    set => SetProperty(ref _channelList, value);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public AddDrugControlViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            vm = this;
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
 | 
			
		||||
 | 
			
		||||
        private async void selectionAction()
 | 
			
		||||
        {
 | 
			
		||||
            if (CStock != null)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("addManuno", CStock);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            CStock = null;
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "AddDrugControl")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            //ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status;
 | 
			
		||||
 | 
			
		||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 1;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _is8Drawer = true;
 | 
			
		||||
 | 
			
		||||
        public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
 | 
			
		||||
 | 
			
		||||
        private bool _is16Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _is17Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }, (DrawerNo) => Status == 0
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                Status = 1;
 | 
			
		||||
                _portUtil.SpeakAsync($"正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    //List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                    List<ChannelList> singleChannels = ChannelLsts.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
                    _portUtil.WindowName = "DrawerAddDrugWindow";
 | 
			
		||||
                    _portUtil.Operate = true;
 | 
			
		||||
                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
                    _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
                    //_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
 | 
			
		||||
                    _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
                    _portUtil.Start();
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    logger.Info($"OpenDrawer异常:{ex.Message}");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }, () => Status == 0).ObservesProperty(() => Status);
 | 
			
		||||
        }
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    foreach (ChannelList lst in ChannelLsts)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStocks.AddRange(lst.channelStocks);
 | 
			
		||||
                    }
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
 | 
			
		||||
                    if (record.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
			
		||||
                        //string InvoiceId = PZH;
 | 
			
		||||
                        //List<string> repeatList = new List<string>();
 | 
			
		||||
                        List<ChannelStock> stockRepeats = new List<ChannelStock>();
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock it = record[i];
 | 
			
		||||
                                it.ManuNo = it.drugManuNo.ManuNo;
 | 
			
		||||
                                it.EffDate = it.drugManuNo.EffDate;
 | 
			
		||||
                                if (it.Id != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    // 更新数据 库存信息
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        Quantity = it.Quantity + it.AddQuantity,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        Id = it.Id,
 | 
			
		||||
                                    }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //如果批号重复则不让添加
 | 
			
		||||
                                    List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
 | 
			
		||||
                                    if (csCount.Count > 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        //repeatList.Add(it.ManuNo);
 | 
			
		||||
                                        stockRepeats.Add(it);
 | 
			
		||||
                                        continue;
 | 
			
		||||
                                    }
 | 
			
		||||
 | 
			
		||||
                                    // 更新数据 库存信息
 | 
			
		||||
                                    SqlSugarHelper.Db.Insertable(new ChannelStock()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        Quantity = it.AddQuantity,
 | 
			
		||||
                                        Chnguid = it.Chnguid,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        DrawerNo = it.DrawerNo,
 | 
			
		||||
                                        ColNo = it.ColNo,
 | 
			
		||||
                                        DrugId = it.DrugId,
 | 
			
		||||
                                        DrawerType = it.DrawerType,
 | 
			
		||||
                                        BoardType = it.BoardType,
 | 
			
		||||
                                        Id = Guid.NewGuid().ToString(),
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                // 获取更新完库存后的药品库存
 | 
			
		||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                    .ToList();
 | 
			
		||||
 | 
			
		||||
                                // 保存数据 入库记录
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    MachineId = it.MachineId,
 | 
			
		||||
                                    DrawerNo = it.DrawerNo,
 | 
			
		||||
                                    ColNo = it.ColNo,
 | 
			
		||||
                                    DrugId = it.DrugId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    Reviewer=HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    OperationTime = DateTime.Now,
 | 
			
		||||
                                    Quantity = it.AddQuantity,
 | 
			
		||||
                                    Type = 1,
 | 
			
		||||
                                    InvoiceId = InvoiceId
 | 
			
		||||
                                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
                        ChannelStocks.Clear();
 | 
			
		||||
                        //if (record.Count == repeatList.Count)
 | 
			
		||||
                        if (stockRepeats.Count == record.Count)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = $"该抽屉已存在此药品批次{string.Join(',', stockRepeats.Select(r=>r.ManuNo).ToArray())},请选择其他批次",
 | 
			
		||||
                                Type = MsgType.ERROR
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //if (repeatList.Count > 0)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            //    {
 | 
			
		||||
                            //        Message = $"该抽屉已存在此药品批次{string.Join(',', repeatList)},请选择其他批次",
 | 
			
		||||
                            //        Type = MsgType.ERROR
 | 
			
		||||
                            //    };
 | 
			
		||||
                            //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            //}
 | 
			
		||||
                            if (f.Data)
 | 
			
		||||
                            {
 | 
			
		||||
 | 
			
		||||
                                string msg = string.Empty;
 | 
			
		||||
                                MsgType type = MsgType.SUCCESS;
 | 
			
		||||
                                //if (repeatList.Count > 0)
 | 
			
		||||
                                if (stockRepeats.Count > 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    msg = $"该抽屉下批次{string.Join(',', stockRepeats.Select(r => r.ManuNo).ToArray())}已存在,不可重复添加,其他批次加药完成,库存已更新";
 | 
			
		||||
                                    foreach(var stockRpt in stockRepeats)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        //移除重复的信息,以免更新屏显库存时更新了重复数据
 | 
			
		||||
                                        record.Remove(stockRpt);
 | 
			
		||||
 | 
			
		||||
                                    }
 | 
			
		||||
                                    type = MsgType.WARING;
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    msg = "抽屉加药完成,库存已更新";
 | 
			
		||||
                                }
 | 
			
		||||
                                // 更新屏显库存
 | 
			
		||||
                                List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                                if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    singleChannels.ForEach(it =>
 | 
			
		||||
                                    {
 | 
			
		||||
                                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
			
		||||
                                    });
 | 
			
		||||
                                }
 | 
			
		||||
                                RequestData();
 | 
			
		||||
                                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = msg,
 | 
			
		||||
                                    Type = type,
 | 
			
		||||
                                };
 | 
			
		||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = "更新库存失败",
 | 
			
		||||
                                    Type = MsgType.SUCCESS,
 | 
			
		||||
                                };
 | 
			
		||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
                        //PZH = string.Empty;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有填写加药数量",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //添加批次
 | 
			
		||||
        public void AddAction(ChannelList channelLS)
 | 
			
		||||
        {
 | 
			
		||||
            if (channelLS != null)
 | 
			
		||||
            {
 | 
			
		||||
                ChannelStock cls = new ChannelStock();
 | 
			
		||||
                DrugManuNo drugManu = new DrugManuNo();
 | 
			
		||||
                cls.DrugInfo = channelLS.Drug;
 | 
			
		||||
                if (channelLS.channelStocks.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    //drugManu = channelLS.channelStocks[0].DrugInfo.DrugManuNos[0];
 | 
			
		||||
                    cls.drugManuNo = channelLS.channelStocks[0].drugManuNo;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //drugManu= cls.DrugInfo.DrugManuNos[0];
 | 
			
		||||
                    if (cls.DrugInfo.DrugManuNos.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "该药品下没有批次,请先添加批次",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                //cls.Id = "";
 | 
			
		||||
                cls.Chnguid = channelLS.Id;
 | 
			
		||||
                cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
			
		||||
                cls.DrawerNo = channelLS.DrawerNo;
 | 
			
		||||
                cls.BoardType = channelLS.BoardType;
 | 
			
		||||
                cls.DrawerType = channelLS.DrawerType;
 | 
			
		||||
                cls.ColNo = channelLS.ColNo;
 | 
			
		||||
                cls.DrugId = channelLS.DrugId;
 | 
			
		||||
                cls.AddQuantity = 0;
 | 
			
		||||
                //string sqlStr = @"select drug_id,manu_no,manu_date,eff_date from drug_manu_no where drug_id=@drugId 
 | 
			
		||||
                //    and manu_no not in(select manu_no from channel_stock where drug_id=@drugId) ";
 | 
			
		||||
                //cls.DrugInfo.DrugManuNos=SqlSugarHelper.Db.SqlQueryable<dynamic>(sqlStr).AddParameters(new
 | 
			
		||||
                //{
 | 
			
		||||
                //    drugId = channelLS.DrugId
 | 
			
		||||
                //})
 | 
			
		||||
                //.Select(it => new DrugManuNo()).ToList();
 | 
			
		||||
                List<ChannelStock> stockList = new List<ChannelStock>();
 | 
			
		||||
                stockList.AddRange(channelLS.channelStocks);
 | 
			
		||||
                stockList.Add(cls);
 | 
			
		||||
                channelLS.channelStocks = stockList;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public void FindDrawerCount()
 | 
			
		||||
        {
 | 
			
		||||
            int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
			
		||||
            Is8Drawer = count < 9;
 | 
			
		||||
            Is16Drawer = count >= 16;
 | 
			
		||||
            Is17Drawer = count > 16;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelList> queryData = SqlSugarHelper.Db.Queryable<ChannelList>()
 | 
			
		||||
                .Includes(cl => cl.Drug, di => di.DrugManuNos)
 | 
			
		||||
                .Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
 | 
			
		||||
                .Where(cl => cl.DrawerNo == DrawerNo)
 | 
			
		||||
                .Where(cl => cl.DrawerType == 1)
 | 
			
		||||
                .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .Where(cl => cl.DrugId != null)
 | 
			
		||||
                .OrderBy(cl => cl.ColNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            ChannelLsts = queryData.Select(cl =>
 | 
			
		||||
            {
 | 
			
		||||
                cl.channelStocks = cl.channelStocks.Select(cs =>
 | 
			
		||||
                {
 | 
			
		||||
                    cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
 | 
			
		||||
                    return cs;
 | 
			
		||||
                }).ToList();
 | 
			
		||||
                return cl;
 | 
			
		||||
            }).ToList();
 | 
			
		||||
            //ChannelLsts = new ObservableCollection<ChannelList>(queryData);
 | 
			
		||||
            ChannelLsts.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            _eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
 | 
			
		||||
            FindDrawerCount();
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
            _eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,949 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class AddSurgeryDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public string Title => "录入手术";
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord> machineRecordList;
 | 
			
		||||
        public List<MachineRecord> MachineRecordList { get => machineRecordList; set => SetProperty(ref machineRecordList, value); }
 | 
			
		||||
 | 
			
		||||
        private SolidColorBrush _colorBrush;
 | 
			
		||||
 | 
			
		||||
        public SolidColorBrush SnackbarBackground
 | 
			
		||||
        {
 | 
			
		||||
            get => _colorBrush;
 | 
			
		||||
            set => SetProperty(ref _colorBrush, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
			
		||||
 | 
			
		||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
			
		||||
        {
 | 
			
		||||
            get => _snackbarMessageQueue;
 | 
			
		||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static List<Dictionary<int, string>> keyValuePairs = new List<Dictionary<int, string>>()
 | 
			
		||||
        {
 | 
			
		||||
            new Dictionary<int, string>(){ {0,"男"} },new Dictionary<int, string>(){ { 1, "女" } }
 | 
			
		||||
        };
 | 
			
		||||
        public List<Dictionary<int, string>> SexKeyValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return keyValuePairs; }
 | 
			
		||||
            set { SetProperty(ref keyValuePairs, value); }
 | 
			
		||||
        }
 | 
			
		||||
        private Dictionary<int, string> _selectedSex = keyValuePairs[0];
 | 
			
		||||
        public Dictionary<int, string> SelectedSex
 | 
			
		||||
        {
 | 
			
		||||
            get => _selectedSex;
 | 
			
		||||
            set => SetProperty(ref _selectedSex, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private SurgicalSchedule surgicalSchedule = new SurgicalSchedule();
 | 
			
		||||
        
 | 
			
		||||
        public SurgicalSchedule _SurgicalSchedule
 | 
			
		||||
        {
 | 
			
		||||
            get => surgicalSchedule;
 | 
			
		||||
            set => SetProperty(ref surgicalSchedule, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 5;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        List<ChannelStock> ReturnStockLst;
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private MachineRecord selectedRecord;
 | 
			
		||||
        public MachineRecord SelectedRecord { get => selectedRecord; set => SetProperty(ref selectedRecord, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public AddSurgeryDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            surgicalSchedule.ScheduleTime= DateTime.Now;
 | 
			
		||||
            _SurgicalSchedule.Indate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            MachineRecordList = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Includes<SurgicalScheduleDetail>(mr => mr._SurgicalScheduleDetailLst)
 | 
			
		||||
                .Where(mr => mr.Type == 2)
 | 
			
		||||
                .Where(mr => mr.Status < 2)
 | 
			
		||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (mr) => mr.DrugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (mr) => mr.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                .OrderBy(mr => mr.OperationTime)
 | 
			
		||||
               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
            MachineRecordList.ForEach(mr => mr.HasCheckNum = mr._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity));
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 选中行事件
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (SelectedRecord != null && selectedRecord.Id != null)
 | 
			
		||||
                {
 | 
			
		||||
                    MachineRecordList = MachineRecordList.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == SelectedRecord.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                            if (x.IsSelected)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (SelectedRecord._SurgicalScheduleDetailLst != null && SelectedRecord._SurgicalScheduleDetailLst.Count > 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    //已经核销数
 | 
			
		||||
                                    int HasCheckNum = SelectedRecord._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
			
		||||
                                    x.CheckQuantity = SelectedRecord.Quantity - HasCheckNum;
 | 
			
		||||
                                    x.ReturnQuantity1 = SelectedRecord.Quantity - HasCheckNum - x.CheckQuantity;
 | 
			
		||||
                                    x.ReturnQuantity2 = HasCheckNum + x.CheckQuantity;
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    x.CheckQuantity = SelectedRecord.Quantity;
 | 
			
		||||
                                    x.ReturnQuantity1 = 0;
 | 
			
		||||
                                    x.ReturnQuantity2 = SelectedRecord.Quantity;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                x.CheckQuantity = 0;
 | 
			
		||||
                                x.ReturnQuantity1 = 0;
 | 
			
		||||
                                x.ReturnQuantity2 = 0;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 保存并核销
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand AddSurgeryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!string.IsNullOrEmpty(_SurgicalSchedule.OperationId))
 | 
			
		||||
                {
 | 
			
		||||
                    //检查是否有该手术号,手术号不能重复
 | 
			
		||||
                   int iCount=  SqlSugarHelper.Db.Queryable<SurgicalSchedule>().Where(ss => ss.OperationId == _SurgicalSchedule.OperationId).Count();
 | 
			
		||||
                    if(iCount>0)
 | 
			
		||||
                    {
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("该手术号已添加,请勿重复创建");
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity > 0).ToList();
 | 
			
		||||
                    if (RecordsLst.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        //string operationId = Guid.NewGuid().ToString();
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new SurgicalSchedule()
 | 
			
		||||
                            {
 | 
			
		||||
                                PName = _SurgicalSchedule.PName,
 | 
			
		||||
                                Sex = SelectedSex.ContainsKey(0) is true ? SelectedSex[0] : SelectedSex[1],
 | 
			
		||||
                                Age = _SurgicalSchedule.Age,
 | 
			
		||||
                                IdNumber = _SurgicalSchedule.IdNumber,
 | 
			
		||||
                                OpRoomCode = _SurgicalSchedule.OpRoomCode,
 | 
			
		||||
                                OpRoomName = _SurgicalSchedule.OpRoomName,
 | 
			
		||||
                                OperationId = _SurgicalSchedule.OperationId,
 | 
			
		||||
                                ScheduleTime = _SurgicalSchedule.ScheduleTime,
 | 
			
		||||
                                InsertTime=DateTime.Now,
 | 
			
		||||
                                Indiagnosis=_SurgicalSchedule.Indiagnosis,
 | 
			
		||||
                                Indate=_SurgicalSchedule.Indate,
 | 
			
		||||
                                DmStatus = 1,
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            for (int i = 0; i < RecordsLst.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new SurgicalScheduleDetail()
 | 
			
		||||
                                {
 | 
			
		||||
                                    OperationId = _SurgicalSchedule.OperationId,
 | 
			
		||||
                                    GetRecordId = RecordsLst[i].Id,
 | 
			
		||||
                                    Quantity = RecordsLst[i].CheckQuantity,
 | 
			
		||||
                                    DrugId = RecordsLst[i].DrugId,
 | 
			
		||||
                                    ManuNo = RecordsLst[i].ManuNo,
 | 
			
		||||
                                    EffDate = RecordsLst[i].EffDate.ToString(),
 | 
			
		||||
                                    InsertUserId = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                                int hasQuantity = RecordsLst[i]._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
			
		||||
                                int dmStatus = 0;
 | 
			
		||||
                                //已经全部挂上钩,修改dm_machine_record状态为完成
 | 
			
		||||
                                //if (hasQuantity + RecordsLst[i].CheckQuantity == RecordsLst[i].Quantity)
 | 
			
		||||
                                //{
 | 
			
		||||
                                //    dmStatus = 2;
 | 
			
		||||
                                //}
 | 
			
		||||
                                //else
 | 
			
		||||
                                {
 | 
			
		||||
                                    dmStatus = 1;
 | 
			
		||||
                                }
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    Status = dmStatus,
 | 
			
		||||
                                    Id = RecordsLst[i].Id
 | 
			
		||||
                                }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                        if (f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "核销完成",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            // 关闭当前窗口
 | 
			
		||||
                            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("核销异常,未核销数据");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        int iRet = SqlSugarHelper.Db.Insertable(new SurgicalSchedule()
 | 
			
		||||
                        {
 | 
			
		||||
                            PName = _SurgicalSchedule.PName,
 | 
			
		||||
                            Sex = SelectedSex.ContainsKey(0) is true ? SelectedSex[0] : SelectedSex[1],
 | 
			
		||||
                            Age = _SurgicalSchedule.Age,
 | 
			
		||||
                            IdNumber = _SurgicalSchedule.IdNumber,
 | 
			
		||||
                            OpRoomCode = _SurgicalSchedule.OpRoomCode,
 | 
			
		||||
                            OpRoomName = _SurgicalSchedule.OpRoomName,
 | 
			
		||||
                            OperationId = _SurgicalSchedule.OperationId,
 | 
			
		||||
                            ScheduleTime= _SurgicalSchedule.ScheduleTime,
 | 
			
		||||
                            Indiagnosis = _SurgicalSchedule.Indiagnosis,
 | 
			
		||||
                            Indate = _SurgicalSchedule.Indate,
 | 
			
		||||
                            InsertTime = DateTime.Now,
 | 
			
		||||
                            DmStatus = 0,
 | 
			
		||||
                            HisState=1
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iRet > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "手术录入成功,未核销药品",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            // 关闭当前窗口
 | 
			
		||||
                            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("手术录入失败");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("手术号不能为空");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 全部归还(还药、还空瓶)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand ReturnCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity == 0).ToList();
 | 
			
		||||
                ReturnStockLst = new List<ChannelStock>();
 | 
			
		||||
                if (RecordsLst.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    //待还药的记录
 | 
			
		||||
                    List<MachineRecord> ReturnDrugLst = RecordsLst.Where(rl => rl.ReturnQuantity1 > 0).ToList();
 | 
			
		||||
                    //待还空瓶的记录
 | 
			
		||||
                    List<MachineRecord> ReturnEmptyLst = RecordsLst.Where(rl => rl.ReturnQuantity2 > 0).ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < ReturnDrugLst.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                               .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                                               .Where(cs => cs.DrugId == ReturnDrugLst[i].DrugId)
 | 
			
		||||
                                               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                               .Where(cs => cs.ManuNo == ReturnDrugLst[i].ManuNo)
 | 
			
		||||
                                               .OrderBy(cs => cs.Quantity).First();
 | 
			
		||||
                        if (queryData != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            queryData.AddQuantity = ReturnDrugLst[i].ReturnQuantity1;
 | 
			
		||||
                            queryData.MachineRecordId = ReturnDrugLst[i].Id;
 | 
			
		||||
                            ReturnStockLst.Add(queryData);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    for (int j = 0; j < ReturnEmptyLst.Count; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                              .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                                              .Where(cs => cs.DrugId == ReturnEmptyLst[j].DrugId)
 | 
			
		||||
                                              .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                              //.Where(cs => cs.ManuNo == ReturnEmptyLst[j].ManuNo)
 | 
			
		||||
                                              .Where(cs => cs.DrawerType == 2)
 | 
			
		||||
                                              .OrderBy(cs => cs.Quantity).First();
 | 
			
		||||
                        if (queryData != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            queryData.ReturnQuantity = ReturnEmptyLst[j].ReturnQuantity2;
 | 
			
		||||
                            queryData.MachineRecordId = ReturnEmptyLst[j].Id;
 | 
			
		||||
                            ReturnStockLst.Add(queryData);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (ReturnStockLst != null && ReturnStockLst.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        ReturnStockLst = ReturnStockLst.OrderBy(cls => cls.DrawerNo).ToList();
 | 
			
		||||
                        //还药时AddQuantity有值;还空瓶时ReturnQuantity有值
 | 
			
		||||
                        enumerable = ReturnStockLst.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                        enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                        enumerator.MoveNext();
 | 
			
		||||
                        Status = 1;
 | 
			
		||||
                        OpenOneByOne();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("选中数据未绑定库位,请先进行绑定库位");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量不为0");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 刷新
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "SurgeryTakeWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
 | 
			
		||||
                                //保存数据
 | 
			
		||||
 | 
			
		||||
                                //TakeFinish();
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
            string drugName = channelStocks[0].DrugInfo.DrugName;
 | 
			
		||||
 | 
			
		||||
            int drugQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
 | 
			
		||||
            int emptyQuantity = channelStocks.Sum(cs => cs.ReturnQuantity);
 | 
			
		||||
            string speakTxt = $"正在打开{DrawerNo}号抽屉,请将{drugName}的";
 | 
			
		||||
            if (drugQuantity > 0)
 | 
			
		||||
            {
 | 
			
		||||
                speakTxt += $"{drugQuantity}个药放入抽屉!";
 | 
			
		||||
            }
 | 
			
		||||
            if (emptyQuantity > 0)
 | 
			
		||||
            {
 | 
			
		||||
                speakTxt += $"{emptyQuantity}个空瓶放入抽屉!";
 | 
			
		||||
            }
 | 
			
		||||
            _portUtil.SpeakAsync(speakTxt);
 | 
			
		||||
 | 
			
		||||
            //List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            //singleChannels.ForEach(it =>
 | 
			
		||||
            //{
 | 
			
		||||
            //    try
 | 
			
		||||
            //    {
 | 
			
		||||
 | 
			
		||||
            //        _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
            //    }
 | 
			
		||||
            //    catch (Exception ex)
 | 
			
		||||
            //    {
 | 
			
		||||
            //        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
            //        {
 | 
			
		||||
            //            Message = $"打开抽屉异常{ex.Message}",
 | 
			
		||||
            //            Type = MsgType.ERROR,
 | 
			
		||||
            //        };
 | 
			
		||||
            //        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            //    }
 | 
			
		||||
            //});
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "SurgeryTakeWindow";
 | 
			
		||||
            _portUtil.BoardType = channelStocks.Count > 0 ? channelStocks[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = channelStocks.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
			
		||||
        //完成
 | 
			
		||||
        private void TakeFinish()
 | 
			
		||||
        {
 | 
			
		||||
            IsFinishClick = true;
 | 
			
		||||
            bool bRet = false;
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < ReturnStockLst.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock it = ReturnStockLst[i];
 | 
			
		||||
                    int quantity = 0;
 | 
			
		||||
                    if (it.AddQuantity > 0)  //还药
 | 
			
		||||
                    {
 | 
			
		||||
                        quantity = it.AddQuantity;
 | 
			
		||||
                        bRet = ReturnDrug(it);
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        quantity = it.ReturnQuantity;
 | 
			
		||||
                        bRet = ReturnEmpty(it);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!bRet)
 | 
			
		||||
                    {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    // 更新屏显库存
 | 
			
		||||
                    if (it.BoardType == 5)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + quantity);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "操作完成,库存已更新",
 | 
			
		||||
                        Type = MsgType.SUCCESS,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    // 关闭当前窗口
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                }
 | 
			
		||||
                return bRet;
 | 
			
		||||
            });
 | 
			
		||||
            if (!f.IsSuccess || !f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("库存更新失败!");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            Status = 0;
 | 
			
		||||
            IsFinishClick = false;
 | 
			
		||||
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 还药
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool ReturnDrug(ChannelStock stock)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    string InvoiceId = "RETURN_" + CurrentTimeMillis(); ;
 | 
			
		||||
                    MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
			
		||||
                    // 更新数据 库存信息
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                    {
 | 
			
		||||
                        Quantity = stock.Quantity + stock.AddQuantity,
 | 
			
		||||
                        Id = stock.Id,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
                    // 获取更新完库存后的药品库存
 | 
			
		||||
                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                        .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                        .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
			
		||||
                        .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                        .ToList();
 | 
			
		||||
                    // 更新数据 取药记录 设置还药数量、状态 
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        ReturnQuantity1 = recordInfo.ReturnQuantity1 + stock.AddQuantity,
 | 
			
		||||
                        Id = recordInfo.Id,
 | 
			
		||||
                        Status = (recordInfo.CanReturnQuantity - stock.AddQuantity) == 0 ? 2 : 1,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    // 保存数据 还药记录
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = stock.MachineId,
 | 
			
		||||
                        DrawerNo = stock.DrawerNo,
 | 
			
		||||
                        ColNo = stock.ColNo,
 | 
			
		||||
                        DrugId = stock.DrugId,
 | 
			
		||||
                        ManuNo = stock.ManuNo,
 | 
			
		||||
                        EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Quantity = stock.AddQuantity,
 | 
			
		||||
                        Type = 31,
 | 
			
		||||
                        InvoiceId = InvoiceId,
 | 
			
		||||
                        GetId = stock.MachineRecordId
 | 
			
		||||
                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    //保存账册
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                        Type = 1,
 | 
			
		||||
                        Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                        InvoiceNo = InvoiceId,
 | 
			
		||||
                        ManuNo = stock.ManuNo,
 | 
			
		||||
                        EffDate = stock.EffDate,
 | 
			
		||||
                        AddQuantity = stock.AddQuantity,
 | 
			
		||||
                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                        CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    //修改凌晨生成的日结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 3)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.ManuNo == stock.ManuNo)
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Day != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + stock.AddQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                        int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                            Type = 3,
 | 
			
		||||
                            ManuNo = stock.ManuNo,
 | 
			
		||||
                            EffDate = stock.EffDate,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = stock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = stock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "日结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iDayResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入日结存数据{stock.DrugId}-{stock.ManuNo}-{stock.EffDate}-{stock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //修改凌晨生成的总结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 4)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Total != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + stock.AddQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                        int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                            Type = 4,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = stock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = stock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "总结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iTotalResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入总结存数据{stock.DrugId}-{stock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                if (f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                throw;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 还空瓶
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool ReturnEmpty(ChannelStock stock)
 | 
			
		||||
        {
 | 
			
		||||
            string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                // 更新数据 库存信息
 | 
			
		||||
                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                {
 | 
			
		||||
                    Quantity = stock.Quantity + stock.ReturnQuantity,
 | 
			
		||||
                    Id = stock.Id,
 | 
			
		||||
                }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                // 获取更新完库存后的药品库存
 | 
			
		||||
                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
 | 
			
		||||
                MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
			
		||||
 | 
			
		||||
                // 更新数据 取药记录 设置还药数量、状态
 | 
			
		||||
                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                {
 | 
			
		||||
                    ReturnQuantity2 = stock.ReturnQuantity,
 | 
			
		||||
                    Id = recordInfo.Id,
 | 
			
		||||
                    Status = 2,
 | 
			
		||||
                }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                // 保存数据 还药空瓶记录
 | 
			
		||||
                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                {
 | 
			
		||||
                    MachineId = stock.MachineId,
 | 
			
		||||
                    DrawerNo = stock.DrawerNo,
 | 
			
		||||
                    ColNo = stock.ColNo,
 | 
			
		||||
                    DrugId = stock.DrugId,
 | 
			
		||||
                    ManuNo = stock.ManuNo,
 | 
			
		||||
                    EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                    OperationTime = DateTime.Now,
 | 
			
		||||
                    Quantity = stock.ReturnQuantity, //ReturnQuantity,
 | 
			
		||||
                    Type = 32,
 | 
			
		||||
                    InvoiceId = InvoiceId,
 | 
			
		||||
                    GetId = stock.MachineRecordId
 | 
			
		||||
                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                return true;
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            if (!f.IsSuccess || !f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 取消
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinishCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(TakeFinish);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            // 关闭当前窗口
 | 
			
		||||
            //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class AddToJiaoJieWindowViewModel
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,821 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ApplyInStockWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private List<DrugPleaseClaim> _drugPleaseClaimList = new();
 | 
			
		||||
 | 
			
		||||
        public List<DrugPleaseClaim> _DrugPleaseClaimList { get { return _drugPleaseClaimList; } set { SetProperty(ref _drugPleaseClaimList, value); } }
 | 
			
		||||
 | 
			
		||||
        private DrugPleaseClaim? selectDrugPleaseClaim;
 | 
			
		||||
 | 
			
		||||
        public DrugPleaseClaim? SelectDrugPleaseClaim
 | 
			
		||||
        {
 | 
			
		||||
            get { return selectDrugPleaseClaim; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref selectDrugPleaseClaim, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "drugPleaseNo",
 | 
			
		||||
                Name = "请领单号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private List<ChannelStock> _channelStocks = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _addChannels = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> AddChannels { get { return _addChannels; } set { SetProperty(ref _addChannels, value); } }
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceInWindowViewModel));
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        public ApplyInStockWindowViewModel(PortUtil portUtil, IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
        }
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
        private string WindowName = "ApplyInStockWindowViewModel";
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        private async void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                strNames += name;
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
            
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开{DrawerNo}号抽屉,请加药{strNames},数量共计{sumQuantity}");
 | 
			
		||||
            List<ChannelStock> singleChannels = new List<ChannelStock>();
 | 
			
		||||
            for (int i = 0; i < channelStocks.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
 | 
			
		||||
                singleChannels.Add(copy);
 | 
			
		||||
            }
 | 
			
		||||
            singleChannels = singleChannels.GroupBy(it => new
 | 
			
		||||
            {
 | 
			
		||||
                it.DrawerNo,
 | 
			
		||||
                it.ColNo
 | 
			
		||||
            }).Select(it =>
 | 
			
		||||
            {
 | 
			
		||||
                var ret = it.First();
 | 
			
		||||
                ret.Quantity = it.Sum(itx => itx.Quantity);
 | 
			
		||||
                ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
 | 
			
		||||
                return ret;
 | 
			
		||||
            }).ToList().FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = WindowName;
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            //_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
            {
 | 
			
		||||
                List<ChannelStock> ChannelLst = new List<ChannelStock>();
 | 
			
		||||
                for (int i = 0; i < channelStocks.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
 | 
			
		||||
                    singleChannels.Add(copy);
 | 
			
		||||
                }
 | 
			
		||||
                ChannelLst = ChannelLst.Where(it => it.BoardType != 1)
 | 
			
		||||
                                                                        .GroupBy(it => it.ColNo)
 | 
			
		||||
                                                                        .Select(it =>
 | 
			
		||||
                                                                        {
 | 
			
		||||
                                                                            var ret = it.First();
 | 
			
		||||
                                                                            ret.Quantity = it.Sum(itx => itx.Quantity);
 | 
			
		||||
                                                                            ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
 | 
			
		||||
                                                                            return ret;
 | 
			
		||||
                                                                        }).ToList();
 | 
			
		||||
                // 发送加药数量
 | 
			
		||||
                singleChannels.ForEach(it =>
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < singleChannels.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock it = singleChannels[i];
 | 
			
		||||
                    _portUtil.ClearCount(it.DrawerNo, it.ColNo);
 | 
			
		||||
                    await Task.Delay(50);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
 | 
			
		||||
        public void GetChannelByInvoice()
 | 
			
		||||
        {
 | 
			
		||||
            ChannelStocks.Clear();
 | 
			
		||||
            //InOutInvoices.Clear();
 | 
			
		||||
            List<ChannelStock> csList = new List<ChannelStock>();
 | 
			
		||||
            if (SelectDrugPleaseClaim != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (SelectDrugPleaseClaim.GetQuantity == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    if (SelectDrugPleaseClaim._DrugManuNos is null)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "药品没有批次效期信息!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    //请领单里只有一种药
 | 
			
		||||
                    List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(SelectDrugPleaseClaim._DrugManuNos);
 | 
			
		||||
                    drugManuInfoList.ForEach(dm => dm.DrugId = SelectDrugPleaseClaim.DrugId);
 | 
			
		||||
                    for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugPleaseManuNo drugPleaseManuNo = drugManuInfoList[i];
 | 
			
		||||
 | 
			
		||||
                        ChannelStock q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                        .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                        .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.EffDate), cs => cs.EffDate.Equals(drugPleaseManuNo.EffDate))
 | 
			
		||||
                        .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.ManuNo), cs => cs.ManuNo.Equals(drugPleaseManuNo.ManuNo))
 | 
			
		||||
                        .Where(cs => cs.DrugId == drugPleaseManuNo.DrugId)
 | 
			
		||||
                        .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                        .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                        .OrderBy(cs => cs.DrugId)
 | 
			
		||||
                        .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                        .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                        .First();
 | 
			
		||||
                        if (q is null)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "药品没有绑定库位信息!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        q.AddQuantity = drugPleaseManuNo.Quantity;
 | 
			
		||||
 | 
			
		||||
                        csList.Add(q);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //请领单里有多种药
 | 
			
		||||
                    List<DrugPleaseClaim> pleaseClaimList = SqlSugarHelper.Db.Queryable<DrugPleaseClaim>().Includes<DrugInfo>(dpc => dpc.DrugInfo).Where(dpc => dpc.PleaseNo == SelectDrugPleaseClaim.PleaseNo).ToList();
 | 
			
		||||
                    if (pleaseClaimList != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        foreach (DrugPleaseClaim item in pleaseClaimList)
 | 
			
		||||
                        {
 | 
			
		||||
                            List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(item._DrugManuNos);
 | 
			
		||||
                            drugManuInfoList.ForEach(dm => dm.DrugId = item.DrugId);
 | 
			
		||||
                            for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugPleaseManuNo drugPleaseManuNo = drugManuInfoList[i];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                List<ChannelStock>? q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                                .Where(cs => cs.DrugId != null)
 | 
			
		||||
                                .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.EffDate), cs => cs.EffDate.Equals(drugPleaseManuNo.EffDate))
 | 
			
		||||
                                .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.ManuNo), cs => cs.ManuNo.Equals(drugPleaseManuNo.ManuNo))
 | 
			
		||||
                                .Where(cs => cs.DrugId == drugPleaseManuNo.DrugId)
 | 
			
		||||
                                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                .OrderBy(cs => cs.DrugId)
 | 
			
		||||
                                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
                                if (q != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    q[0].AddQuantity = drugPleaseManuNo.Quantity;
 | 
			
		||||
                                    q.ForEach(csq => csq.PleaseClaim = item);
 | 
			
		||||
 | 
			
		||||
                                    csList.AddRange(q);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ICollectionView vw = CollectionViewSource.GetDefaultView(csList);
 | 
			
		||||
            vw.GroupDescriptions.Add(new PropertyGroupDescription("PleaseClaim"));
 | 
			
		||||
            ChannelStocks = csList;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            _DrugPleaseClaimList.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
 | 
			
		||||
            var sb = new StringBuilder();
 | 
			
		||||
            sb.Append("SELECT i.please_no,i.do_date,i.totalQuantity,count(1) as get_quantity,drug_manu_no,machine_id,i.drug_id from drug_please_claim i inner join ");
 | 
			
		||||
            sb.Append(" ( select c.drug_id as drug_id from channel_stock c where c.machine_id = 'DM3' group by c.drug_id ) di  on di.drug_id = i.drug_id WHERE state=@State and type=@Type ");
 | 
			
		||||
 | 
			
		||||
            if (OrderDate != null)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and DATE_FORMAT(i.do_date,'%Y-%m-%d') = @CreateTime ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(SearchValue))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.please_no = @please_no ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["department"]))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.department = @department ");
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append("  GROUP BY i.please_no");
 | 
			
		||||
            sb.Append(" order by i.do_date ");
 | 
			
		||||
            _DrugPleaseClaimList = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
			
		||||
                .AddParameters(new
 | 
			
		||||
                {
 | 
			
		||||
                    State = 2,
 | 
			
		||||
                    Type = 32,
 | 
			
		||||
                    CreateTime = OrderDate,
 | 
			
		||||
                    please_no = SearchValue,
 | 
			
		||||
                    department = ConfigurationManager.AppSettings["department"]
 | 
			
		||||
                })
 | 
			
		||||
            .Select(it => new DrugPleaseClaim())
 | 
			
		||||
                .Select("*")
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenInvoiceAdd
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                bool flag = true;
 | 
			
		||||
 | 
			
		||||
                AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
 | 
			
		||||
 | 
			
		||||
                enumerable = AddChannels.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                OpenDrawer(AddChannels);
 | 
			
		||||
            }, () => SelectDrugPleaseClaim != null).ObservesProperty(() => SelectDrugPleaseClaim);
 | 
			
		||||
        }
 | 
			
		||||
        private void OpenDrawer(List<ChannelStock> AddChannels)
 | 
			
		||||
        {
 | 
			
		||||
            if (Status == 0)
 | 
			
		||||
            {
 | 
			
		||||
                if (AddChannels == null || AddChannels.Count <= 0)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请输入入库数量",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                int totalNum = AddChannels.Sum(add => add.AddQuantity);
 | 
			
		||||
                //if (totalNum != SelectedInvoice.Quantity)
 | 
			
		||||
                //{
 | 
			
		||||
                //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                //    {
 | 
			
		||||
                //        Message = "各批次添加数量要与调拨单药品总数一致!",
 | 
			
		||||
                //        Type = MsgType.ERROR,
 | 
			
		||||
                //    };
 | 
			
		||||
                //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                //    return;
 | 
			
		||||
                //}
 | 
			
		||||
                enumerator.MoveNext();
 | 
			
		||||
                Status = 1;
 | 
			
		||||
                OpenOneByOne();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        public DelegateCommand TakeFinish { get => new DelegateCommand(TakeFinishAction); }
 | 
			
		||||
 | 
			
		||||
        private void TakeFinishAction()
 | 
			
		||||
        {
 | 
			
		||||
            if (!_isFinishClick)
 | 
			
		||||
            {
 | 
			
		||||
                _isFinishClick = true;
 | 
			
		||||
                List<ChannelStock> record = ChannelStocks.ToList();
 | 
			
		||||
                string InvoiceId = SelectDrugPleaseClaim.PleaseNo;
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new DrugPleaseClaim()
 | 
			
		||||
                    {
 | 
			
		||||
                        State = 3,
 | 
			
		||||
                        PleaseNo = SelectDrugPleaseClaim.PleaseNo
 | 
			
		||||
                    }).UpdateColumns(it => new { it.State }).WhereColumns(it => new { it.PleaseNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        ChannelStock it = record[i];
 | 
			
		||||
                        if (it.BoardType == 6 && it.PosNo == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (it.Id != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                Quantity = it.Quantity + it.AddQuantity,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        //else
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    //如果批号重复则不让添加
 | 
			
		||||
                        //    List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity > 0).ToList();
 | 
			
		||||
                        //    if (csCount.Count > 0)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        //repeatList.Add(it.ManuNo);
 | 
			
		||||
                        //        //stockRepeats.Add(it);
 | 
			
		||||
                        //        continue;
 | 
			
		||||
                        //    }
 | 
			
		||||
                        //    //查询现有库位中是否有库存为0的记录,如果有直接update
 | 
			
		||||
                        //    ChannelStock recordHistory = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).First();
 | 
			
		||||
                        //    if (recordHistory != null && recordHistory.Id != null)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock()
 | 
			
		||||
                        //        {
 | 
			
		||||
                        //            Quantity = it.AddQuantity,
 | 
			
		||||
                        //            ManuNo = it.ManuNo,
 | 
			
		||||
                        //            EffDate = it.EffDate
 | 
			
		||||
                        //        }).Where(item => item.Id == recordHistory.Id).ExecuteCommand();
 | 
			
		||||
                        //    }
 | 
			
		||||
                        //    else
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        // 更新数据 库存信息
 | 
			
		||||
                        //        SqlSugarHelper.Db.Insertable(new ChannelStock()
 | 
			
		||||
                        //        {
 | 
			
		||||
                        //            Quantity = it.AddQuantity,
 | 
			
		||||
                        //            Chnguid = it.Chnguid,
 | 
			
		||||
                        //            ManuNo = it.ManuNo,
 | 
			
		||||
                        //            EffDate = it.EffDate,
 | 
			
		||||
                        //            DrawerNo = it.DrawerNo,
 | 
			
		||||
                        //            ColNo = it.ColNo,
 | 
			
		||||
                        //            DrugId = it.DrugId,
 | 
			
		||||
                        //            DrawerType = it.DrawerType,
 | 
			
		||||
                        //            BoardType = it.BoardType,
 | 
			
		||||
                        //            Id = Guid.NewGuid().ToString(),
 | 
			
		||||
                        //            MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                        //        }).ExecuteCommand();
 | 
			
		||||
                        //    }
 | 
			
		||||
                        //}
 | 
			
		||||
                        // 获取更新完库存后的药品库存
 | 
			
		||||
                        List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                            .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                            .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                            .ToList();
 | 
			
		||||
 | 
			
		||||
                        // 保存数据 出/入库记录
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                        {
 | 
			
		||||
                            MachineId = it.MachineId,
 | 
			
		||||
                            DrawerNo = it.DrawerNo,
 | 
			
		||||
                            ColNo = it.ColNo,
 | 
			
		||||
                            DrugId = it.DrugId,
 | 
			
		||||
                            ManuNo = it.ManuNo,
 | 
			
		||||
                            EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                            Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            OperationTime = DateTime.Now,
 | 
			
		||||
                            Quantity = it.AddQuantity,
 | 
			
		||||
                            Type = 1,
 | 
			
		||||
                            InvoiceId = InvoiceId,
 | 
			
		||||
                            //StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
			
		||||
                            //ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
 | 
			
		||||
                            //SupplierDept = SelectedInvoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
 | 
			
		||||
                            //ReceiveDept = SelectedInvoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        int iIndex = Array.IndexOf(ConfigurationManager.AppSettings["colloctedId"].Split(','), SelectDrugPleaseClaim.MachineId.ToString());
 | 
			
		||||
                        string dept = ConfigurationManager.AppSettings["colloctedId"].Split(',')[iIndex - 1].ToString();
 | 
			
		||||
 | 
			
		||||
                        //保存账册
 | 
			
		||||
                        int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                            Type = 1,
 | 
			
		||||
                            Department = dept,
 | 
			
		||||
                            OrderNo = SelectDrugPleaseClaim.PleaseNo,
 | 
			
		||||
                            ManuNo = it.ManuNo,
 | 
			
		||||
                            EffDate = it.EffDate,
 | 
			
		||||
                            AddQuantity = it.AddQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            //CreateTime = DateTime.Now,
 | 
			
		||||
                            InvoiceNo = SelectDrugPleaseClaim.PleaseNo
 | 
			
		||||
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                        .Where(ab => ab.Type == 3)
 | 
			
		||||
                        .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                        .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                        if (accountBookG2Day != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                            int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type=3,
 | 
			
		||||
                                ManuNo=it.ManuNo,
 | 
			
		||||
                                EffDate=it.EffDate,
 | 
			
		||||
                                YQuantity=0,
 | 
			
		||||
                                ManuStock= it.AddQuantity,
 | 
			
		||||
                                TotalStock= it.AddQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "日结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iDayResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                        .Where(ab => ab.Type == 4)
 | 
			
		||||
                        .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                        if (accountBookG2Total != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                            int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type = 4,
 | 
			
		||||
                                YQuantity = 0,
 | 
			
		||||
                                ManuStock = it.AddQuantity,
 | 
			
		||||
                                TotalStock = it.AddQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "总结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iTotalResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    return true;
 | 
			
		||||
                });
 | 
			
		||||
                if (f.Data)
 | 
			
		||||
                {
 | 
			
		||||
                    // 更新屏显库存
 | 
			
		||||
                    //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                    List<ChannelStock> singleChannels = record.Where(it => it.BoardType == 5)
 | 
			
		||||
                                                                    .GroupBy(it => new { it.DrawerNo, it.ColNo })
 | 
			
		||||
                                                                    .Select(it =>
 | 
			
		||||
                                                                    {
 | 
			
		||||
                                                                        var ret = it.First();
 | 
			
		||||
                                                                        //ret.Quantity = it.Sum(itx => itx.Quantity);
 | 
			
		||||
                                                                        //ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
 | 
			
		||||
                                                                        return ret;
 | 
			
		||||
                                                                    })
 | 
			
		||||
                                                                    .ToList();
 | 
			
		||||
                    if (singleChannels != null && singleChannels.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < singleChannels.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            //if (singleChannels[i].BoardType == 5)
 | 
			
		||||
                            //{
 | 
			
		||||
                            List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                                                .Where(cs => cs.MachineId == singleChannels[i].MachineId)
 | 
			
		||||
                                                                .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
 | 
			
		||||
                                                                .Where(cs => cs.ColNo == singleChannels[i].ColNo)
 | 
			
		||||
                                                                .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                                                                .OrderBy(cs => cs.EffDate).ToList();
 | 
			
		||||
                            int totalQuantity = channelStockEffDate.Sum(it => it.Quantity);
 | 
			
		||||
 | 
			
		||||
                            //将库位多批次的总库存数更新标签
 | 
			
		||||
                            _portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity);
 | 
			
		||||
                            Thread.Sleep(200);
 | 
			
		||||
                            _portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
 | 
			
		||||
                            Thread.Sleep(200);
 | 
			
		||||
                            _portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
 | 
			
		||||
                            Thread.Sleep(200);
 | 
			
		||||
                            _portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
 | 
			
		||||
                            //}
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "操作完成,库存已更新",
 | 
			
		||||
                        Type = MsgType.SUCCESS,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                if (!f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    logger.Info($"调拨入库,库存更新失败!{f.ErrorMessage}");
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "库存更新失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                Status = 0;
 | 
			
		||||
                _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand CancleTake { get => new DelegateCommand(CancelTakeAction); }
 | 
			
		||||
 | 
			
		||||
        private void CancelTakeAction()
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
            Status = 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,202 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ApplyListWindowViewModel : BindableBase, INavigationAware
 | 
			
		||||
    {
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 请领单状态
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<DrugPleaseState> _drugPleaseStateList = new List<DrugPleaseState>() {
 | 
			
		||||
                new DrugPleaseState
 | 
			
		||||
                {
 | 
			
		||||
                    StateName="已创建",
 | 
			
		||||
                    StateValue=0
 | 
			
		||||
                },
 | 
			
		||||
                new DrugPleaseState
 | 
			
		||||
                {
 | 
			
		||||
                    StateName="审核通过",
 | 
			
		||||
                    StateValue=1
 | 
			
		||||
                },
 | 
			
		||||
                new DrugPleaseState
 | 
			
		||||
                {
 | 
			
		||||
                    StateName="已出库",
 | 
			
		||||
                    StateValue=2
 | 
			
		||||
                },
 | 
			
		||||
                new DrugPleaseState
 | 
			
		||||
                {
 | 
			
		||||
                    StateName="已入库",
 | 
			
		||||
                    StateValue=3
 | 
			
		||||
                }
 | 
			
		||||
        };
 | 
			
		||||
        public List<DrugPleaseState>? DrugPleaseStateList
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugPleaseStateList;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugPleaseStateList, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private DrugPleaseState? _drugPleaseState;
 | 
			
		||||
        public DrugPleaseState _DrugPleaseState
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugPleaseState;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugPleaseState, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        } 
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 处方、请领中间表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private List<CollectDrug> _collectDrugLst;
 | 
			
		||||
        public List<CollectDrug> CollectDrugLst
 | 
			
		||||
        {
 | 
			
		||||
            get => _collectDrugLst; set { SetProperty(ref _collectDrugLst, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private CollectDrug _selectCollectDrug;
 | 
			
		||||
        public CollectDrug SelectCollectDrug { get => _selectCollectDrug; set { SetProperty(ref _selectCollectDrug, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            if (CollectDrugLst != null)
 | 
			
		||||
            {
 | 
			
		||||
                CollectDrugLst.Clear();
 | 
			
		||||
            }
 | 
			
		||||
            CollectDrugLst = SqlSugarHelper.Db.Queryable<CollectDrug>()
 | 
			
		||||
                           .Includes<DrugPleaseClaim>(cd => cd.drugPleaseClaim)
 | 
			
		||||
                           .Includes<DrugInfo>(cd => cd.drugInfo)
 | 
			
		||||
                           .InnerJoin<DrugPleaseClaim>((cd,dp)=>cd.DrugPleaseClaimId==dp.PleaseNo)
 | 
			
		||||
                           .Where(cd => cd.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cd) => cd.drugInfo.DrugId.ToString() == SearchValue)
 | 
			
		||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cd) => cd.drugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                           .WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
 | 
			
		||||
                           .GroupBy(cd=>cd.DrugPleaseClaimId)
 | 
			
		||||
                           .GroupBy(cd => cd.DrugId)
 | 
			
		||||
                           .OrderByDescending(cd => cd.Createdate)
 | 
			
		||||
                           .OrderByDescending(cd => cd.DrugId)
 | 
			
		||||
                           .ToList();
 | 
			
		||||
            if (CollectDrugLst != null && CollectDrugLst.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < CollectDrugLst.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    CollectDrugLst[i].ManuNoList = new List<DrugPleaseManuNo>();
 | 
			
		||||
                    DrugPleaseClaim drugManuNoStr = SqlSugarHelper.Db.Queryable<DrugPleaseClaim>().Where(dp => dp.PleaseNo == CollectDrugLst[i].DrugPleaseClaimId && dp.DrugId == CollectDrugLst[i].DrugId).First();
 | 
			
		||||
 | 
			
		||||
                    CollectDrugLst[i].Quantity = drugManuNoStr.GetQuantity;
 | 
			
		||||
                    if (!string.IsNullOrEmpty(drugManuNoStr._DrugManuNos))
 | 
			
		||||
                    {
 | 
			
		||||
                        CollectDrugLst[i].ManuNoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(drugManuNoStr._DrugManuNos);
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 刷新
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,76 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class BindBoxDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public string Title =>"药箱药品绑定";
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 0;
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drawerNo, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private List<DrugInfo>? _drugInfos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfos;
 | 
			
		||||
            set => SetProperty(ref _drugInfos, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static BindBoxDialogViewModel vm;
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            if (parameters.ContainsKey("DrawerNo"))
 | 
			
		||||
            {
 | 
			
		||||
                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateComboBoxItems(string text)
 | 
			
		||||
        {
 | 
			
		||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
			
		||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
			
		||||
            if (string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (DrugInfos != null)
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos.Clear();
 | 
			
		||||
            }
 | 
			
		||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,419 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class BindBoxPackageWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public static BindBoxPackageWindowViewModel vm;
 | 
			
		||||
        private int _drawerNo = 1;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private SolidColorBrush _colorBrush;
 | 
			
		||||
 | 
			
		||||
        public SolidColorBrush SnackbarBackground
 | 
			
		||||
        {
 | 
			
		||||
            get => _colorBrush;
 | 
			
		||||
            set => SetProperty(ref _colorBrush, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
			
		||||
 | 
			
		||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
			
		||||
        {
 | 
			
		||||
            get => _snackbarMessageQueue;
 | 
			
		||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock>? _channels;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? Channels
 | 
			
		||||
        {
 | 
			
		||||
            get => _channels;
 | 
			
		||||
            set => SetProperty(ref _channels, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock Channel
 | 
			
		||||
        {
 | 
			
		||||
            get { return _channelStock; }
 | 
			
		||||
            set { SetProperty(ref _channelStock, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<DrugInfo>? _drugInfos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfos;
 | 
			
		||||
            set => SetProperty(ref _drugInfos, value);
 | 
			
		||||
        }
 | 
			
		||||
        private DrugInfo? _drugInfo;
 | 
			
		||||
 | 
			
		||||
        public DrugInfo? DrugInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugInfo, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //药品基数
 | 
			
		||||
        private string _baseQuantity;
 | 
			
		||||
        public string BaseQuantity { get => _baseQuantity; set { SetProperty(ref _baseQuantity, value); } }
 | 
			
		||||
 | 
			
		||||
        private bool _isEnable = true;
 | 
			
		||||
        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
        public int Status { get => _status; set { SetProperty(ref _status, value); } }  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
        //抽屉号列表
 | 
			
		||||
        public static List<int> iList = new List<int>();
 | 
			
		||||
        //第几个抽屉号
 | 
			
		||||
        public static int iNumber = 1;
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public BindBoxPackageWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            vm = this;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            Channels?.Clear();
 | 
			
		||||
            BaseQuantity = "";
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase)
 | 
			
		||||
                .Includes(cs => cs.DrugInfo)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals("DM5"))
 | 
			
		||||
                .Where(cs => cs.DrawerNo == DrawerNo).ToList();
 | 
			
		||||
            if (list != null && list.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                Channels = list;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestDrug();
 | 
			
		||||
            RequestData();
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        private void RequestDrug()
 | 
			
		||||
        {
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
            DrugInfos = list;
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand BindingDrug
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(BindDrugAction);
 | 
			
		||||
        }
 | 
			
		||||
        //绑定
 | 
			
		||||
        private void BindDrugAction()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (DrugInfo == null || BaseQuantity == null)
 | 
			
		||||
            {
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("请选择药品并输入药品基数");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            int baseQuantity;
 | 
			
		||||
            if (!int.TryParse(BaseQuantity, out baseQuantity))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("药品基数请输入正确的整数");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (Channels != null)
 | 
			
		||||
            {
 | 
			
		||||
                int iNum = Channels.Where(cs => cs.DrugId == DrugInfo.DrugId.ToString()).Count();
 | 
			
		||||
                if (iNum > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("该药品已在药箱绑定,请选择其他药品");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
                SqlSugarHelper.Db.Insertable(new ChannelStock()
 | 
			
		||||
                {
 | 
			
		||||
                    DrawerNo = DrawerNo,
 | 
			
		||||
                    DrugId = DrugInfo.DrugId.ToString(),
 | 
			
		||||
                    BaseQuantity = baseQuantity,
 | 
			
		||||
                    Id = Guid.NewGuid().ToString(),
 | 
			
		||||
                    MachineId = "DM5"
 | 
			
		||||
                }).ExecuteCommand();
 | 
			
		||||
                // 保存数据 入库记录
 | 
			
		||||
                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                {
 | 
			
		||||
                    MachineId = "DM5",
 | 
			
		||||
                    DrawerNo = DrawerNo,
 | 
			
		||||
                    DrugId = DrugInfo.DrugId.ToString(),
 | 
			
		||||
                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                    OperationTime = DateTime.Now,
 | 
			
		||||
                    Quantity = baseQuantity,
 | 
			
		||||
                    Type = 55,
 | 
			
		||||
                    InvoiceId = "绑定药箱",
 | 
			
		||||
                }).ExecuteCommand();
 | 
			
		||||
                return true;
 | 
			
		||||
            });
 | 
			
		||||
            if (f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("药品已绑定药箱");
 | 
			
		||||
                RequestDrug();
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateComboBoxItems(string text)
 | 
			
		||||
        {
 | 
			
		||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
			
		||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
			
		||||
            if (string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (DrugInfos != null)
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos.Clear();
 | 
			
		||||
            }
 | 
			
		||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //解绑
 | 
			
		||||
        public DelegateCommand RemoveBinding
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => RemoveBindingAction());
 | 
			
		||||
        }
 | 
			
		||||
        private void RemoveBindingAction()
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (Channels == null)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("所选药箱中无可解绑药品");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                if (Channel != null)
 | 
			
		||||
                {
 | 
			
		||||
                    //解绑选定行的单个药品
 | 
			
		||||
                    SqlSugarHelper.Db.Deleteable(Channel).ExecuteCommand();
 | 
			
		||||
                    // 保存数据 入库记录
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = DrawerNo,
 | 
			
		||||
                        DrugId = Channel.DrugId.ToString(),
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Quantity = Channel.Quantity,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "解绑药箱单个药品",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //解绑药箱下的所有药品
 | 
			
		||||
                    Channels.ForEach(item =>
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        SqlSugarHelper.Db.Deleteable(item).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        // 保存数据 入库记录
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                        {
 | 
			
		||||
                            MachineId = "DM5",
 | 
			
		||||
                            DrawerNo = DrawerNo,
 | 
			
		||||
                            DrugId = item.DrugId.ToString(),
 | 
			
		||||
                            Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            OperationTime = DateTime.Now,
 | 
			
		||||
                            Quantity = item.Quantity,
 | 
			
		||||
                            Type = 55,
 | 
			
		||||
                            InvoiceId = "绑定药箱全部药品",
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                RequestDrug();
 | 
			
		||||
                RequestData();
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("解绑操作异常");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //刷新
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(RequestData);
 | 
			
		||||
        }
 | 
			
		||||
        //打开全部药箱
 | 
			
		||||
        public DelegateCommand OpenBox
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => OpenBoxAction());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenBoxAction()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
			
		||||
                .Select(cl => cl.DrawerNo).ToList();
 | 
			
		||||
            if (iList.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                IsEnable = false;
 | 
			
		||||
                Status = 1;
 | 
			
		||||
                _portUtil.SpeakAsync("正在打开药箱");
 | 
			
		||||
                _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                iNumber++;
 | 
			
		||||
                _portUtil.OpenBox();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            switch (msg.EventType)
 | 
			
		||||
            {
 | 
			
		||||
                // 药箱打开
 | 
			
		||||
                case EventType.DRAWEROPEN:
 | 
			
		||||
                    //记录开药箱日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (iNumber < iList.Count)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                        iNumber++;
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
                        _portUtil.OpenBox();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        iNumber = 0;
 | 
			
		||||
                        _portUtil.GetBoxStatus();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                // 药箱关闭
 | 
			
		||||
                case EventType.DRAWERCLOSE:
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱关闭",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (Status == 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    IsEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
                // 打开失败
 | 
			
		||||
                case EventType.OPENERROR:
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = msg.Message,
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                    IsEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开失败",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,407 +0,0 @@
 | 
			
		|||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class BindingChannelDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public static BindingChannelDialogViewModel vm;
 | 
			
		||||
        public string Title => "库位绑定";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private SolidColorBrush _colorBrush;
 | 
			
		||||
 | 
			
		||||
        public SolidColorBrush SnackbarBackground
 | 
			
		||||
        {
 | 
			
		||||
            get => _colorBrush;
 | 
			
		||||
            set => SetProperty(ref _colorBrush, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
			
		||||
 | 
			
		||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
			
		||||
        {
 | 
			
		||||
            get => _snackbarMessageQueue;
 | 
			
		||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        PortUtil _portUtil;
 | 
			
		||||
        //ScreenUtil _screenUtil;
 | 
			
		||||
 | 
			
		||||
        public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
 | 
			
		||||
            )
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            //_screenUtil = screenUtil;
 | 
			
		||||
            vm = this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drawerNo, value);
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugInfo? _drugInfo;
 | 
			
		||||
 | 
			
		||||
        public DrugInfo? DrugInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugInfo, value);
 | 
			
		||||
                if (_drugInfo != null)
 | 
			
		||||
                {
 | 
			
		||||
                    //DrugManuNos = _drugInfo.DrugManuNos;
 | 
			
		||||
                    DrugManuNos = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(m => m.DrugId == _drugInfo.DrugId.ToString()).ToList();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<DrugInfo>? _drugInfos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfos;
 | 
			
		||||
            set => SetProperty(ref _drugInfos, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugManuNo? _drugManuNo;
 | 
			
		||||
 | 
			
		||||
        public DrugManuNo? DrugManuNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugManuNo;
 | 
			
		||||
            set => SetProperty(ref _drugManuNo, value);
 | 
			
		||||
        }
 | 
			
		||||
        private List<DrugManuNo>? _drugManuNos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugManuNo>? DrugManuNos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugManuNos;
 | 
			
		||||
            set => SetProperty(ref _drugManuNos, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock>? _channels;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? Channels
 | 
			
		||||
        {
 | 
			
		||||
            get => _channels;
 | 
			
		||||
            set => SetProperty(ref _channels, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 9;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GetAllDrugInfos()
 | 
			
		||||
        {
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
            DrugInfos = list;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GetChannelsByDrawerNo()
 | 
			
		||||
        {
 | 
			
		||||
            Channels?.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                .WhereIF(DrawerNo > 0, cs => cs.DrawerNo == DrawerNo)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            Channels = list;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            if (parameters.ContainsKey("DrawerNo"))
 | 
			
		||||
            {
 | 
			
		||||
                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
			
		||||
            }
 | 
			
		||||
            GetAllDrugInfos();
 | 
			
		||||
            GetChannelsByDrawerNo();
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BindingDrug
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
 | 
			
		||||
 | 
			
		||||
                if (SelectChannels.All(it => it.DrawerType != 1))
 | 
			
		||||
                {
 | 
			
		||||
                    if (SelectChannels.Count == 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (DrugInfo != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
 | 
			
		||||
                            if (count == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                var item = SelectChannels[0];
 | 
			
		||||
 | 
			
		||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
			
		||||
                                {
 | 
			
		||||
                                    item.PosNo = 0;
 | 
			
		||||
                                }
 | 
			
		||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
 | 
			
		||||
                                GetChannelsByDrawerNo();
 | 
			
		||||
 | 
			
		||||
                                if (item.BoardType == 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
			
		||||
                                    // 向显示屏写入库位信息
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                                }
 | 
			
		||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                                SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (DrugInfo != null && DrugManuNo != null)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        var c = SelectChannels.Count;
 | 
			
		||||
 | 
			
		||||
                        if (c > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            SelectChannels.ForEach(async (item) =>
 | 
			
		||||
                            {
 | 
			
		||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
			
		||||
                                {
 | 
			
		||||
                                    item.PosNo = 0;
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
			
		||||
                                item.ManuNo = DrugManuNo.ManuNo;
 | 
			
		||||
                                item.DrugInfo = DrugInfo;
 | 
			
		||||
                                item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                                if (item.BoardType == 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
			
		||||
                                    // 向显示屏写入库位信息
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                                }
 | 
			
		||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
			
		||||
                            });
 | 
			
		||||
                            GetChannelsByDrawerNo();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RemoveBinding
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
 | 
			
		||||
                var c = SelectChannels.Count;
 | 
			
		||||
                if (c > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    SelectChannels.ForEach(async item =>
 | 
			
		||||
                    {
 | 
			
		||||
                        item.DrugId = null;
 | 
			
		||||
                        item.ManuNo = null;
 | 
			
		||||
                        item.EffDate = null;
 | 
			
		||||
                        item.DrugInfo = null;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                        if (item.BoardType == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            // 清除显示屏库位信息
 | 
			
		||||
                            _portUtil.ClearContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                            await Task.Delay(200);
 | 
			
		||||
                            _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        //_screenUtil.SetStockInfo(item, 1);
 | 
			
		||||
                    });
 | 
			
		||||
                    GetChannelsByDrawerNo();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("所选库位中无可解绑库位【库位还存在药品】");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
        string message = string.Empty;
 | 
			
		||||
        private void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "BindingChannelDialog")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        if (message != msg.Message)
 | 
			
		||||
                        {
 | 
			
		||||
                            message = msg.Message;
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UpdateComboBoxItems(string text)
 | 
			
		||||
        {
 | 
			
		||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
			
		||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
			
		||||
            if(string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if(DrugInfos!=null)
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos.Clear();
 | 
			
		||||
            }
 | 
			
		||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,484 +0,0 @@
 | 
			
		|||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Reflection.Metadata.Ecma335;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class BindingChannelNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public static BindingChannelNewDialogViewModel vm;
 | 
			
		||||
        public string Title => "库位绑定";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private SolidColorBrush _colorBrush;
 | 
			
		||||
 | 
			
		||||
        public SolidColorBrush SnackbarBackground
 | 
			
		||||
        {
 | 
			
		||||
            get => _colorBrush;
 | 
			
		||||
            set => SetProperty(ref _colorBrush, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
			
		||||
 | 
			
		||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
			
		||||
        {
 | 
			
		||||
            get => _snackbarMessageQueue;
 | 
			
		||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        PortUtil _portUtil;
 | 
			
		||||
        //ScreenUtil _screenUtil;
 | 
			
		||||
 | 
			
		||||
        public BindingChannelNewDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
 | 
			
		||||
            )
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            //_screenUtil = screenUtil;
 | 
			
		||||
            vm = this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drawerNo, value);
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugInfo? _drugInfo;
 | 
			
		||||
 | 
			
		||||
        public DrugInfo? DrugInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfo;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _drugInfo, value);
 | 
			
		||||
                //if (_drugInfo != null)
 | 
			
		||||
                //{
 | 
			
		||||
                //    DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
 | 
			
		||||
                //}
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //拼音码对应药品实体
 | 
			
		||||
        //private DrugInfo? _durgInfo_for_py;
 | 
			
		||||
        //public DrugInfo? DrugInfo_Py
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _durgInfo_for_py;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
 | 
			
		||||
        //        SetProperty(ref _durgInfo_for_py, value);
 | 
			
		||||
        //        if (_durgInfo_for_py != null)
 | 
			
		||||
        //        {
 | 
			
		||||
        //            DrugInfos = GetDrugByDrugPY(_durgInfo_for_py.PyCode);
 | 
			
		||||
        //        }
 | 
			
		||||
        //        else
 | 
			
		||||
        //        {
 | 
			
		||||
        //            DrugInfos = GetDrugByDrugPY("");
 | 
			
		||||
        //        }
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //#region 根据药品拼音码查询药品名称
 | 
			
		||||
        //private List<DrugInfo> GetDrugByDrugPY(string pycode)
 | 
			
		||||
        //{
 | 
			
		||||
        //    List<DrugInfo> DrugList = null;
 | 
			
		||||
        //    if (!string.IsNullOrEmpty(pycode))
 | 
			
		||||
        //    {
 | 
			
		||||
        //        DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        //    }
 | 
			
		||||
        //    else
 | 
			
		||||
        //    {
 | 
			
		||||
        //        DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        //    }
 | 
			
		||||
        //    return DrugList;
 | 
			
		||||
        //}
 | 
			
		||||
        //private List<DrugInfo>? _drugInfos_py;
 | 
			
		||||
        //public List<DrugInfo>? DrugInfos_PY
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _drugInfos_py;
 | 
			
		||||
        //    set => SetProperty(ref _drugInfos_py, value);
 | 
			
		||||
        //}
 | 
			
		||||
        //#endregion 根据药品拼音码查询药品名称
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<DrugInfo>? _drugInfos;
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugInfos;
 | 
			
		||||
            set => SetProperty(ref _drugInfos, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //private DrugManuNo? _drugManuNo;
 | 
			
		||||
 | 
			
		||||
        //public DrugManuNo? DrugManuNo
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _drugManuNo;
 | 
			
		||||
        //    set => SetProperty(ref _drugManuNo, value);
 | 
			
		||||
        //}
 | 
			
		||||
        //private List<DrugManuNo>? _drugManuNos;
 | 
			
		||||
 | 
			
		||||
        //public List<DrugManuNo>? DrugManuNos
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _drugManuNos;
 | 
			
		||||
        //    set => SetProperty(ref _drugManuNos, value);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelList>? _channels;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelList>? Channels
 | 
			
		||||
        {
 | 
			
		||||
            get => _channels;
 | 
			
		||||
            set => SetProperty(ref _channels, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GetAllDrugInfos()
 | 
			
		||||
        {
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
            DrugInfos = list;
 | 
			
		||||
            //DrugInfos_PY = list;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GetChannelsByDrawerNo()
 | 
			
		||||
        {
 | 
			
		||||
            Channels?.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            var list = SqlSugarHelper.Db.Queryable<ChannelList>()
 | 
			
		||||
                .Includes<DrugInfo>(cl => cl.Drug)
 | 
			
		||||
                //.Includes<ChannelStock>(cs => cs.channelStock)
 | 
			
		||||
                .WhereIF(DrawerNo > 0, cl => cl.DrawerNo == DrawerNo)
 | 
			
		||||
                .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .OrderBy(cl => cl.DrawerNo)
 | 
			
		||||
                .OrderBy(cl => cl.ColNo)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            Channels = list;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            if (parameters.ContainsKey("DrawerNo"))
 | 
			
		||||
            {
 | 
			
		||||
                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
			
		||||
            }
 | 
			
		||||
            GetAllDrugInfos();
 | 
			
		||||
            GetChannelsByDrawerNo();
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GetChannelsByDrawerNo();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BindingDrug
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected);
 | 
			
		||||
 | 
			
		||||
                if (SelectChannels.All(it => it.DrawerType != 1))
 | 
			
		||||
                {
 | 
			
		||||
                    if (SelectChannels.Count == 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (DrugInfo != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
 | 
			
		||||
                            if (count == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                var item = SelectChannels[0];
 | 
			
		||||
 | 
			
		||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
			
		||||
                                {
 | 
			
		||||
                                    item.PosNo = 0;
 | 
			
		||||
                                }
 | 
			
		||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
			
		||||
                                item.DrugSpec= DrugInfo.DrugSpec.ToString();
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
 | 
			
		||||
                                GetChannelsByDrawerNo();
 | 
			
		||||
 | 
			
		||||
                                if (item.BoardType == 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
			
		||||
                                    // 向显示屏写入库位信息
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    await Task.Delay(200);
 | 
			
		||||
                                    //_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    //await Task.Delay(200);
 | 
			
		||||
                                    //_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                    //await Task.Delay(200);
 | 
			
		||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                                }
 | 
			
		||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                                SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //if (DrugInfo != null && DrugManuNo != null)
 | 
			
		||||
                    //{
 | 
			
		||||
 | 
			
		||||
                    var c = SelectChannels.Count;
 | 
			
		||||
 | 
			
		||||
                    if (c > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < SelectChannels.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            var item = SelectChannels[i];
 | 
			
		||||
                            var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
 | 
			
		||||
                            if(channelStock.Count>0)
 | 
			
		||||
                            {
 | 
			
		||||
                                //有库存,不能解绑
 | 
			
		||||
 | 
			
		||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                                SnackbarMessageQueue.Enqueue($"库位{item.DrawerNo}-{item.ColNo}中还存在药品,不能绑定其他药品");
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
                            if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
			
		||||
                            {
 | 
			
		||||
                                item.PosNo = 0;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            item.DrugId = DrugInfo.DrugId.ToString();
 | 
			
		||||
                            //item.ManuNo = DrugManuNo.ManuNo;
 | 
			
		||||
                            item.Drug = DrugInfo;
 | 
			
		||||
                            item.DrugSpec = DrugInfo.DrugSpec.ToString();
 | 
			
		||||
                            //item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            if (item.BoardType == 5)
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WindowName = "BindingChannelDialog";
 | 
			
		||||
                                // 向显示屏写入库位信息
 | 
			
		||||
                                _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                //await Task.Delay(200);
 | 
			
		||||
                                Thread.Sleep(200);
 | 
			
		||||
                                _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                //await Task.Delay(200);
 | 
			
		||||
                                Thread.Sleep(200);
 | 
			
		||||
                                _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                //await Task.Delay(200);
 | 
			
		||||
                                Thread.Sleep(200);
 | 
			
		||||
                                //_portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
			
		||||
                                //await Task.Delay(200);
 | 
			
		||||
                                //Thread.Sleep(200);
 | 
			
		||||
                                //_portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
 | 
			
		||||
                                ////await Task.Delay(200);
 | 
			
		||||
                                //Thread.Sleep(200);
 | 
			
		||||
                                _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        GetChannelsByDrawerNo();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
 | 
			
		||||
                    }
 | 
			
		||||
                    //}
 | 
			
		||||
                    //else
 | 
			
		||||
                    //{
 | 
			
		||||
                    //    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    //    SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
 | 
			
		||||
                    //}
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RemoveBinding
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.DrugId != null);
 | 
			
		||||
                var c = SelectChannels.Count;
 | 
			
		||||
                if (c > 0)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    SelectChannels.ForEach(async item =>
 | 
			
		||||
                    {
 | 
			
		||||
                        var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
 | 
			
		||||
                        if (channelStock.Count > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                            SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品【库位还存在药品】");
 | 
			
		||||
                            //该药品下的批次还有库存则不能解绑
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        item.DrugId = null;
 | 
			
		||||
                        //item.ManuNo = null;
 | 
			
		||||
                        //item.EffDate = null;
 | 
			
		||||
                        item.Drug = null;
 | 
			
		||||
                        item.DrugSpec = null;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId,it.DrugSpec }).ExecuteCommand();
 | 
			
		||||
                        if (item.BoardType == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            // 清除显示屏库位信息
 | 
			
		||||
                            _portUtil.ClearContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                            await Task.Delay(200);
 | 
			
		||||
                            _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        //_screenUtil.SetStockInfo(item, 1);
 | 
			
		||||
                    });
 | 
			
		||||
                    GetChannelsByDrawerNo();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
        string message = string.Empty;
 | 
			
		||||
        private void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "BindingChannelDialog")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        if (message != msg.Message)
 | 
			
		||||
                        {
 | 
			
		||||
                            message = msg.Message;
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public void UpdateComboBoxItems(string text)
 | 
			
		||||
        {
 | 
			
		||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
			
		||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
			
		||||
            if (string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (DrugInfos != null)
 | 
			
		||||
            {
 | 
			
		||||
                DrugInfos.Clear();
 | 
			
		||||
            }
 | 
			
		||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,656 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ChangeShiftsDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public string Title => "交接班";
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => true;
 | 
			
		||||
        //交班人 发药人
 | 
			
		||||
        public UserList Operator { get; set; }
 | 
			
		||||
        private bool _operatorLogin = false;
 | 
			
		||||
        public bool OperatorLogin
 | 
			
		||||
        {
 | 
			
		||||
            get => _operatorLogin;
 | 
			
		||||
            set { SetProperty(ref _operatorLogin, value); }
 | 
			
		||||
        }
 | 
			
		||||
        //private _brushesOperator = Brushes.Green;
 | 
			
		||||
        //public System.Drawing.Brush BrushesOperator
 | 
			
		||||
        //{
 | 
			
		||||
        //    get=> _brushesOperator;
 | 
			
		||||
        //    set { SetProperty(ref _brushesOperator, value);}
 | 
			
		||||
        //}
 | 
			
		||||
        //交班人 审核人
 | 
			
		||||
        public UserList Reviewer { get; set; }
 | 
			
		||||
        private bool _reviewerLogin = false;
 | 
			
		||||
        public bool ReviewerLogin
 | 
			
		||||
        {
 | 
			
		||||
            get => _reviewerLogin;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _reviewerLogin, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //private System.Drawing.Brush _brushesReviewer=Brushes.Green;
 | 
			
		||||
        //public System.Drawing.Brush BrushesReviewer
 | 
			
		||||
        //{
 | 
			
		||||
        //    get=> _brushesReviewer;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _brushesReviewer, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //接班人 发药人
 | 
			
		||||
        public UserList JieOperator { get; set; }
 | 
			
		||||
        //接班人 审核人
 | 
			
		||||
        public UserList JieReviewer { get; set; }
 | 
			
		||||
 | 
			
		||||
        //当前操作人
 | 
			
		||||
        public UserList CurrentUser { get; set; }
 | 
			
		||||
        //双人登录还是单人登录
 | 
			
		||||
        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
			
		||||
        //第一个登录的是发药人还是接班人
 | 
			
		||||
        private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
 | 
			
		||||
        //验证按钮可用状态
 | 
			
		||||
        private bool _jiaoBanOk = true;
 | 
			
		||||
        public bool JiaoBanOk
 | 
			
		||||
        {
 | 
			
		||||
            get => _jiaoBanOk;
 | 
			
		||||
            set { SetProperty(ref _jiaoBanOk, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private NavigationParameters keys = new NavigationParameters();
 | 
			
		||||
 | 
			
		||||
        public bool SingleLogin
 | 
			
		||||
        {
 | 
			
		||||
            get => ReadAppSetting("loginMode") == "1";
 | 
			
		||||
            //get => loginMode == 1;
 | 
			
		||||
        }
 | 
			
		||||
        public bool MultiLogin
 | 
			
		||||
        {
 | 
			
		||||
            //get => loginMode == 2;
 | 
			
		||||
            get => ReadAppSetting("loginMode") == "2";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //private PortUtil _portUtil;
 | 
			
		||||
        private Boolean _loginBtnEnable = true;
 | 
			
		||||
        public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
 | 
			
		||||
        public string Password { get { return password; } set { SetProperty(ref password, value); } }
 | 
			
		||||
 | 
			
		||||
        public string Username { get { return username; } set { SetProperty(ref username, value); } }
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
 | 
			
		||||
 | 
			
		||||
        private string username;
 | 
			
		||||
        private string password;
 | 
			
		||||
 | 
			
		||||
        private bool _fingerMsg;
 | 
			
		||||
 | 
			
		||||
        public bool FingerMsg
 | 
			
		||||
        {
 | 
			
		||||
            get => _fingerMsg;
 | 
			
		||||
            set => SetProperty(ref _fingerMsg, value);
 | 
			
		||||
        }
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        //确认交接
 | 
			
		||||
        public DelegateCommand ShiftsCommand => new DelegateCommand(ShiftsAction);
 | 
			
		||||
        private void ShiftsAction()
 | 
			
		||||
        {
 | 
			
		||||
            if (Operator != null && !OperatorLogin)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "交班发药人需要系统验证!",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (Reviewer != null && !ReviewerLogin)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "交班审核人需要系统验证!",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (JieOperator == null && JieReviewer == null)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "接班发药人或审核需要系统验证!",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            //1验证交班人与接班人是否都已登录验证2写交接信息
 | 
			
		||||
            //if ((Operator != null || Reviewer != null) && (JieOperator != null || JieReviewer != null))
 | 
			
		||||
            //{
 | 
			
		||||
            DateTime dt = DateTime.Now;
 | 
			
		||||
            //保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
 | 
			
		||||
            //var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<HkcChangeShifts> listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
 | 
			
		||||
                  .Where(cs => cs.State == "0")
 | 
			
		||||
                  .WhereIF(Operator != null && !string.IsNullOrEmpty(Operator.UserName), cs => cs.FromOperator == Operator.UserName)
 | 
			
		||||
                  .WhereIF(Reviewer != null && !string.IsNullOrEmpty(Reviewer.UserName), cs => cs.FromRviewer == Reviewer.UserName)
 | 
			
		||||
                  .OrderByDescending(cs => cs.OptState)
 | 
			
		||||
                  .ToList();
 | 
			
		||||
 | 
			
		||||
                if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    //存在则修改,不存在则插入一条
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
 | 
			
		||||
                    {
 | 
			
		||||
                        Id = listHkcChangeShifts[0].Id,
 | 
			
		||||
                        ToOperator = JieOperator == null ? "" : JieOperator.UserName,
 | 
			
		||||
                        ToReviewer = JieReviewer == null ? "" : JieReviewer.UserName,
 | 
			
		||||
                        State = "1",
 | 
			
		||||
                        ToDate = dt
 | 
			
		||||
                    }).UpdateColumns(it => new { it.ToOperator, it.ToReviewer, it.State, it.ToDate }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
 | 
			
		||||
                    {
 | 
			
		||||
                        FromOperator = Operator == null ? "" : Operator.UserName,
 | 
			
		||||
                        FromRviewer = Reviewer == null ? "" : Reviewer.UserName,
 | 
			
		||||
                        ToOperator = JieOperator == null ? "" : JieOperator.UserName,
 | 
			
		||||
                        ToReviewer = JieReviewer == null ? "" : JieReviewer.UserName,
 | 
			
		||||
                        State = "1",
 | 
			
		||||
                        OptState = "0",
 | 
			
		||||
                        OptDate = dt,
 | 
			
		||||
                        Machineid = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
 | 
			
		||||
                {
 | 
			
		||||
                    FromOperator = JieOperator == null ? "" : JieOperator.UserName,
 | 
			
		||||
                    FromRviewer = JieReviewer == null ? "" : JieReviewer.UserName,
 | 
			
		||||
                    State = "0",
 | 
			
		||||
                    OptState = "0",
 | 
			
		||||
                    OptDate = dt,
 | 
			
		||||
                    //ToDate = dt,
 | 
			
		||||
                    Machineid = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                //插入交接班报表数据信息
 | 
			
		||||
                string strSql = @"SELECT drug.drug_name,drug.DRUG_SPEC,c.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,
 | 
			
		||||
                                    (SELECT d2.manu_stock FROM account_book_g2 d2 WHERE d2.drug_id = c.`drug_id`  and d2.manu_no=c.manu_no  AND d2.create_date  < @beforeDate
 | 
			
		||||
                                    ORDER BY d2.create_date DESC,d2.id DESC LIMIT 1) AS beforeNum
 | 
			
		||||
                                    from channel_stock		c LEFT JOIN drug_info drug on c.drug_id=drug.drug_id left JOIN	(SELECT drug_id,manu_no,
 | 
			
		||||
                                    SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1
 | 
			
		||||
                                    WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d
 | 
			
		||||
                                    on c.drug_id=d.drug_id and c.manu_no=d.manu_no WHERE c.machine_id=@machineId and c.drug_id is not NULL GROUP BY c.Drug_ID ,c.manu_no
 | 
			
		||||
                                    UNION
 | 
			
		||||
                                    SELECT drug.drug_name,drug.DRUG_SPEC,d.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,(SELECT  d2.manu_stock FROM account_book_g2 d2 WHERE d2.drug_id = d.`drug_id`  and d2.manu_no=d.manu_no  AND d2.create_date < @beforeDate
 | 
			
		||||
                                    ORDER BY d2.create_date DESC,d2.id DESC LIMIT 1) AS beforeNum from (SELECT drug_id,manu_no, SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1 
 | 
			
		||||
                                     WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d	
 | 
			
		||||
                                    LEFT JOIN drug_info drug on d.drug_id=drug.drug_id left JOIN		 channel_stock		c on c.drug_id=d.drug_id and c.manu_no=d.manu_no AND c.machine_id=@machineId GROUP BY d.Drug_ID ,d.manu_no ";
 | 
			
		||||
                List<ShiftsReport> shiftsReports = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
 | 
			
		||||
                 .AddParameters(new
 | 
			
		||||
                 {
 | 
			
		||||
                     machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
			
		||||
                     beforeDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     startDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     endDate = dt
 | 
			
		||||
                 })
 | 
			
		||||
                .Select(it => new ShiftsReport())
 | 
			
		||||
                .ToList();
 | 
			
		||||
                if (shiftsReports != null && shiftsReports.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int i = 0; i < shiftsReports.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new ShiftsReport()
 | 
			
		||||
                        {
 | 
			
		||||
                            OptDate = dt,
 | 
			
		||||
                            DrugName = shiftsReports[i].DrugName,
 | 
			
		||||
                            DrugSpec = shiftsReports[i].DrugSpec,
 | 
			
		||||
                            BeforeNum = shiftsReports[i].BeforeNum ?? 0,
 | 
			
		||||
                            GetNum = shiftsReports[i].GetNum ?? 0,
 | 
			
		||||
                            UseNum = shiftsReports[i].UseNum ?? 0,
 | 
			
		||||
                            ManuNo = shiftsReports[i].ManuNo,
 | 
			
		||||
                            Surplus = shiftsReports[i].Surplus ?? 0,
 | 
			
		||||
                            FromOperator = Operator == null ? "" : Operator.Nickname,
 | 
			
		||||
                            FromReviewer = Reviewer == null ? "" : Reviewer.Nickname,
 | 
			
		||||
                            ToOperator = JieOperator == null ? "" : JieOperator.Nickname,
 | 
			
		||||
                            ToReviewer = JieReviewer == null ? "" : JieReviewer.Nickname,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return true;
 | 
			
		||||
            });
 | 
			
		||||
            if (f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "交接班操作完成!",
 | 
			
		||||
                    Type = MsgType.SUCCESS,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            }
 | 
			
		||||
            if (!f.IsSuccess)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "交接班操作失败!",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
            //}
 | 
			
		||||
            //else
 | 
			
		||||
            //{
 | 
			
		||||
            //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
            //    {
 | 
			
		||||
            //        Message = "交接班需要交班人与接班人全部系统验证!",
 | 
			
		||||
            //        Type = MsgType.ERROR,
 | 
			
		||||
            //    };
 | 
			
		||||
            //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            //}
 | 
			
		||||
        }
 | 
			
		||||
        //用户名密码登录
 | 
			
		||||
        public DelegateCommand LoginCommand => new DelegateCommand(LoginAction);
 | 
			
		||||
 | 
			
		||||
        //清空
 | 
			
		||||
        public DelegateCommand ClearCommand => new DelegateCommand(ClearAction);
 | 
			
		||||
        private void ClearAction()
 | 
			
		||||
        {
 | 
			
		||||
            Username = string.Empty;
 | 
			
		||||
            Password = string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void LoginAction()
 | 
			
		||||
        {
 | 
			
		||||
            Login();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Login()
 | 
			
		||||
        {
 | 
			
		||||
            LoginBtnEnable = false;
 | 
			
		||||
            if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
 | 
			
		||||
            {
 | 
			
		||||
                UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
			
		||||
                                    .Includes<RoleDm>(u => u.Role)
 | 
			
		||||
                                   .InnerJoin<RoleDm>((u, r) => u.RoleId == r.Id)
 | 
			
		||||
                                   .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
 | 
			
		||||
 | 
			
		||||
                if (userList == null)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "无此用户",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    Username = string.Empty;
 | 
			
		||||
                    Password = string.Empty;
 | 
			
		||||
                }
 | 
			
		||||
                else if (userList.Role == null)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "用户还未设置权限,请联系管理员",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    Username = string.Empty;
 | 
			
		||||
                    Password = string.Empty;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (userList.PassWord == MD5.GetMD5Hash(Password))
 | 
			
		||||
                    {
 | 
			
		||||
                        Username = string.Empty;
 | 
			
		||||
                        Password = string.Empty;
 | 
			
		||||
                        HkcChangeShifts changeOperator = GetOperator();
 | 
			
		||||
                        if (changeOperator != null)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            if (userList.UserName == changeOperator.FromOperator&&!OperatorLogin)
 | 
			
		||||
                            {
 | 
			
		||||
 | 
			
		||||
                                Operator = userList;
 | 
			
		||||
                                RaisePropertyChanged("Operator");
 | 
			
		||||
                                //交班人的发药人登录
 | 
			
		||||
                                OperatorLogin = true;
 | 
			
		||||
                                if (((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieOperator != null && JieReviewer != null)
 | 
			
		||||
                                { JiaoBanOk = false; }
 | 
			
		||||
                            }
 | 
			
		||||
                            else if (userList.UserName == changeOperator.FromRviewer&&!ReviewerLogin)
 | 
			
		||||
                            {
 | 
			
		||||
                                //交班人的审核人登录
 | 
			
		||||
                                Reviewer = userList;
 | 
			
		||||
                                RaisePropertyChanged("Reviewer");
 | 
			
		||||
                                ReviewerLogin = true;
 | 
			
		||||
                                if (((Operator != null && OperatorLogin) || (Operator == null)) && JieOperator != null && JieReviewer != null)
 | 
			
		||||
                                { JiaoBanOk = false; }
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                if (keys.ContainsKey("operator"))
 | 
			
		||||
                                {
 | 
			
		||||
                                    //if (userList.UserName == (JieOperator == null ? "" : JieOperator.UserName))
 | 
			
		||||
                                    //{
 | 
			
		||||
                                    //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                    //    {
 | 
			
		||||
                                    //        Message = "接班发药人不能与审核人相同",
 | 
			
		||||
                                    //        Type = MsgType.ERROR
 | 
			
		||||
                                    //    };
 | 
			
		||||
                                    //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                                    //}
 | 
			
		||||
                                    //else
 | 
			
		||||
                                    {
 | 
			
		||||
                                        keys.Add("reviewer", userList);
 | 
			
		||||
                                        JieReviewer = userList;
 | 
			
		||||
                                        RaisePropertyChanged("JieReviewer");
 | 
			
		||||
                                        if (((Operator != null && OperatorLogin) || (Operator == null)) && ((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieOperator != null)
 | 
			
		||||
                                        { JiaoBanOk = false; }
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //if (userList.UserName == (JieReviewer == null ? "" : JieReviewer.UserName))
 | 
			
		||||
                                    //{
 | 
			
		||||
                                    //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                    //    {
 | 
			
		||||
                                    //        Message = "接班发药人不能与审核人相同",
 | 
			
		||||
                                    //        Type = MsgType.ERROR
 | 
			
		||||
                                    //    };
 | 
			
		||||
                                    //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                                    //}
 | 
			
		||||
                                    //else
 | 
			
		||||
                                    {
 | 
			
		||||
                                        keys.Add("operator", userList);
 | 
			
		||||
                                        JieOperator = userList;
 | 
			
		||||
                                        RaisePropertyChanged("JieOperator");
 | 
			
		||||
                                        if (((Operator != null && OperatorLogin) || (Operator == null)) && ((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieReviewer != null)
 | 
			
		||||
                                        { JiaoBanOk = false; }
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "密码错误",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Password = string.Empty;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请输入账号或密码",
 | 
			
		||||
                    Type = MsgType.ERROR
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
            LoginBtnEnable = true;
 | 
			
		||||
        }
 | 
			
		||||
        //void SetUser(UserList user)
 | 
			
		||||
        //{
 | 
			
		||||
        //    // 双人登录模式
 | 
			
		||||
        //    {
 | 
			
		||||
        //        // 如果已经录入了发药人,已经有一个用户登录
 | 
			
		||||
        //        if (keys.ContainsKey("operator"))
 | 
			
		||||
        //        {
 | 
			
		||||
        //            if (keys.GetValue<UserList>("operator").Id != user.Id)
 | 
			
		||||
        //            {
 | 
			
		||||
        //                keys.Add("reviewer", user);
 | 
			
		||||
        //                JieReviewer = user;
 | 
			
		||||
        //                RaisePropertyChanged("JieReviewer");
 | 
			
		||||
        //            }
 | 
			
		||||
        //            else
 | 
			
		||||
        //            {
 | 
			
		||||
        //                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
        //                {
 | 
			
		||||
        //                    Message = "该发药人账号已登录,请输入不同账号",
 | 
			
		||||
        //                    Type = MsgType.ERROR
 | 
			
		||||
        //                };
 | 
			
		||||
        //                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
        //            }
 | 
			
		||||
        //        }
 | 
			
		||||
        //        // 如果已经录入了审核人, 已经有一个用户登录
 | 
			
		||||
        //        else if (keys.ContainsKey("reviewer"))
 | 
			
		||||
        //        {
 | 
			
		||||
        //            if (keys.GetValue<UserList>("reviewer").Id != user.Id)
 | 
			
		||||
        //            {
 | 
			
		||||
        //                keys.Add("operator", user);
 | 
			
		||||
        //                JieOperator = user;
 | 
			
		||||
        //                RaisePropertyChanged("JieOperator");
 | 
			
		||||
        //            }
 | 
			
		||||
        //            else
 | 
			
		||||
        //            {
 | 
			
		||||
        //                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
        //                {
 | 
			
		||||
        //                    Message = "该审核人账号已登录,请输入不同账号",
 | 
			
		||||
        //                    Type = MsgType.ERROR
 | 
			
		||||
        //                };
 | 
			
		||||
        //                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
        //            }
 | 
			
		||||
        //        }
 | 
			
		||||
        //        // 第一个用户登录
 | 
			
		||||
        //        else
 | 
			
		||||
        //        {
 | 
			
		||||
        //            if (firstLogin.Equals("operator"))
 | 
			
		||||
        //            {
 | 
			
		||||
        //                keys.Add("operator", user);
 | 
			
		||||
        //                JieOperator = user;
 | 
			
		||||
        //                RaisePropertyChanged("JieOperator");
 | 
			
		||||
        //            }
 | 
			
		||||
        //            else
 | 
			
		||||
        //            {
 | 
			
		||||
        //                keys.Add("reviewer", user);
 | 
			
		||||
        //                JieReviewer = user;
 | 
			
		||||
        //                RaisePropertyChanged("JieReviewer");
 | 
			
		||||
        //            }
 | 
			
		||||
        //        }
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
        void ChangeShiftsLoginEvent(FingerprintMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info(msg.ToString());
 | 
			
		||||
            if (msg.Message.Equals("CONNECT"))
 | 
			
		||||
            {
 | 
			
		||||
                FingerMsg = !msg.Result;
 | 
			
		||||
            }
 | 
			
		||||
            if (LoginBtnEnable)
 | 
			
		||||
            {
 | 
			
		||||
                if (msg.Message.Equals("LOGIN"))
 | 
			
		||||
                {
 | 
			
		||||
                    UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
			
		||||
                    .Includes<RoleDm>(u => u.Role)
 | 
			
		||||
                    .First(u => u.Id == msg.Id);
 | 
			
		||||
 | 
			
		||||
                    if (userList == null)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "无此用户",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        //Username = "";
 | 
			
		||||
                        //Password = "";
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (userList.Role == null)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "用户还未设置权限,请联系管理员",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        //Username = "";
 | 
			
		||||
                        //Password = "";
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        HkcChangeShifts changeOperator = GetOperator();
 | 
			
		||||
                        if (changeOperator != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (userList.UserName == changeOperator.FromOperator)
 | 
			
		||||
                            {
 | 
			
		||||
                                Operator = userList;
 | 
			
		||||
                                RaisePropertyChanged("Operator");
 | 
			
		||||
                                //交班人的发药人登录
 | 
			
		||||
                                OperatorLogin = true;
 | 
			
		||||
                                if (((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieOperator != null && JieReviewer != null)
 | 
			
		||||
                                { JiaoBanOk = false; }
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                            else if (userList.UserName == changeOperator.FromRviewer)
 | 
			
		||||
                            {
 | 
			
		||||
                                //交班人的审核人登录
 | 
			
		||||
                                Reviewer = userList;
 | 
			
		||||
                                RaisePropertyChanged("Reviewer");
 | 
			
		||||
                                ReviewerLogin = true;
 | 
			
		||||
                                if (((Operator != null && OperatorLogin) || (Operator == null)) && JieOperator != null && JieReviewer != null)
 | 
			
		||||
                                { JiaoBanOk = false; }
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                if (keys.ContainsKey("operator"))
 | 
			
		||||
                                {
 | 
			
		||||
                                    //if (userList.UserName == (JieOperator == null ? "" : JieOperator.UserName))
 | 
			
		||||
                                    //{
 | 
			
		||||
                                    //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                    //    {
 | 
			
		||||
                                    //        Message = "接班发药人不能与审核人相同",
 | 
			
		||||
                                    //        Type = MsgType.ERROR
 | 
			
		||||
                                    //    };
 | 
			
		||||
                                    //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                                    //}
 | 
			
		||||
                                    //else
 | 
			
		||||
                                    {
 | 
			
		||||
                                        keys.Add("reviewer", userList);
 | 
			
		||||
                                        JieReviewer = userList;
 | 
			
		||||
                                        RaisePropertyChanged("JieReviewer");
 | 
			
		||||
                                        if (((Operator != null && OperatorLogin) || (Operator == null)) && ((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieOperator != null)
 | 
			
		||||
                                        { JiaoBanOk = false; }
 | 
			
		||||
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                        //if (userList.UserName == (JieReviewer == null ? "" : JieReviewer.UserName))
 | 
			
		||||
                                        //{
 | 
			
		||||
                                        //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                        //    {
 | 
			
		||||
                                        //        Message = "接班发药人不能与审核人相同",
 | 
			
		||||
                                        //        Type = MsgType.ERROR
 | 
			
		||||
                                        //    };
 | 
			
		||||
                                        //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                                        //}
 | 
			
		||||
                                        //else
 | 
			
		||||
                                    {
 | 
			
		||||
                                        keys.Add("operator", userList);
 | 
			
		||||
                                        JieOperator = userList;
 | 
			
		||||
                                        RaisePropertyChanged("JieOperator");
 | 
			
		||||
                                        if (((Operator != null && OperatorLogin) || (Operator == null)) && ((Reviewer != null && ReviewerLogin) || (Reviewer == null)) && JieReviewer != null)
 | 
			
		||||
                                        { JiaoBanOk = false; }
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        ////private SqlSugarScope SqlSugarHelper.Db;
 | 
			
		||||
        public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            ////this.SqlSugarHelper.Db = sqlSugarScope;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(ChangeShiftsLoginEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            HkcChangeShifts changeOperator = GetOperator();
 | 
			
		||||
            if (changeOperator != null)
 | 
			
		||||
            {
 | 
			
		||||
                Operator = SqlSugarHelper.Db.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromOperator);
 | 
			
		||||
                Reviewer = SqlSugarHelper.Db.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromRviewer);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            FingerMsg = false;// !_fingerprintUtil.bIsConnected;
 | 
			
		||||
            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(ChangeShiftsLoginEvent);
 | 
			
		||||
        }
 | 
			
		||||
        //查询值班人信息
 | 
			
		||||
        private HkcChangeShifts GetOperator()
 | 
			
		||||
        {
 | 
			
		||||
            //查询发药人及审核人
 | 
			
		||||
            HkcChangeShifts changeOperator = SqlSugarHelper.Db.Queryable<HkcChangeShifts>().Single(change => change.State == "0");
 | 
			
		||||
            //if (changeOperator != null)
 | 
			
		||||
            //{
 | 
			
		||||
            //    Operator = SqlSugarHelper.Db.Queryable<UserList>().Single(u => u.UserName == changeOperator.FromOperator);
 | 
			
		||||
            //    Reviewer = SqlSugarHelper.Db.Queryable<UserList>().Single(u => u.UserName == changeOperator.ToOperator);
 | 
			
		||||
            //}
 | 
			
		||||
            return changeOperator;
 | 
			
		||||
        }
 | 
			
		||||
        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
 | 
			
		||||
        public string ReadAppSetting(string key)
 | 
			
		||||
        {
 | 
			
		||||
            string xPath = $"/configuration/appSettings//add[@key='{key}']";
 | 
			
		||||
            XmlDocument doc = new XmlDocument();
 | 
			
		||||
            string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
 | 
			
		||||
            doc.Load(exeFileName + ".dll.config");
 | 
			
		||||
            XmlNode node = doc.SelectSingleNode(xPath);
 | 
			
		||||
            return node.Attributes["value"].Value.ToString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,190 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ChangeShiftsListWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        public DateTime? StartDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _startDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
 | 
			
		||||
 | 
			
		||||
        public DateTime? EndDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _endDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
			
		||||
                    SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _endDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private List<HkcChangeShifts>? hkcChangeShifts;
 | 
			
		||||
 | 
			
		||||
        public List<HkcChangeShifts>? HkcChangeShifts
 | 
			
		||||
        {
 | 
			
		||||
            get { return hkcChangeShifts; }
 | 
			
		||||
            set { SetProperty(ref hkcChangeShifts, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => true;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
        //交接班
 | 
			
		||||
        public DelegateCommand ShiftsCommand => new DelegateCommand(ShiftsAction);
 | 
			
		||||
        private void ShiftsAction()
 | 
			
		||||
        {
 | 
			
		||||
            DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
            DialogServiceExtensions.ShowDialogHost(_dialogService, "ChangeShiftsDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
        }
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        //导出报表
 | 
			
		||||
        public DelegateCommand Download => new DelegateCommand(DownloadAction);
 | 
			
		||||
        private void DownloadAction()
 | 
			
		||||
        {
 | 
			
		||||
            GridReportUtil.PrintChangeShiftsReport(StartDate, EndDate);
 | 
			
		||||
        }
 | 
			
		||||
        ////private SqlSugarScope SqlSugarHelper.Db;
 | 
			
		||||
        public ChangeShiftsListWindowViewModel(IDialogService dialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = dialogService;
 | 
			
		||||
            ////this.SqlSugarHelper.Db = sqlSugarScope;
 | 
			
		||||
        }
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
			
		||||
            string sqlStr = @"SELECT c.id,c.OptDate,u.User_Name as fromoperator,u2.User_Name fromrviewer,u3.User_Name as tooperator,u4.User_Name as toreviewer,
 | 
			
		||||
                            c.todate,c.State from hkc_changeshifts c LEFT JOIN user_list u on c.fromoperator=u.user_id 
 | 
			
		||||
                            LEFT JOIN user_list u2 on c.fromrviewer=u2.user_id  LEFT JOIN user_list u3 on c.tooperator=u3.user_id  
 | 
			
		||||
                            left join user_list u4 on c.toreviewer=u4.user_id where c.machine_id=@machineId ";
 | 
			
		||||
            if (StartDate != null)
 | 
			
		||||
            {
 | 
			
		||||
                sqlStr += " and c.optdate>=@starOptDate ";
 | 
			
		||||
            }
 | 
			
		||||
            if (EndDate != null)
 | 
			
		||||
            {
 | 
			
		||||
                sqlStr += " and c.optdate<=@endOptDate ";
 | 
			
		||||
            }
 | 
			
		||||
            sqlStr += " group by c.id";
 | 
			
		||||
            HkcChangeShifts = SqlSugarHelper.Db.SqlQueryable<dynamic>(sqlStr)
 | 
			
		||||
                .AddParameters(new
 | 
			
		||||
                {
 | 
			
		||||
                    machineId = machineId,
 | 
			
		||||
                    starOptDate = StartDate,
 | 
			
		||||
                    endOptDate = EndDate
 | 
			
		||||
                })
 | 
			
		||||
                .Select(it => new HkcChangeShifts())
 | 
			
		||||
                //.Select("*")
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Query => new DelegateCommand(RequestData);
 | 
			
		||||
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,525 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 10;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //所选药箱号
 | 
			
		||||
        private int _drawerNo = 0;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private bool _isEnable = true;
 | 
			
		||||
        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
        public int Status { get => _status; set { SetProperty(ref _status, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<OrderInfo> _ordersList = new List<OrderInfo>();
 | 
			
		||||
        public List<OrderInfo> OrderInfoList
 | 
			
		||||
        {
 | 
			
		||||
            get => _ordersList;
 | 
			
		||||
            set => SetProperty(ref _ordersList, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<TotalDrug>? _totalDrugList;
 | 
			
		||||
        public List<TotalDrug>? TotalDrugList
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalDrugList;
 | 
			
		||||
            set => SetProperty(ref _totalDrugList, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo _selectOrderInfo;
 | 
			
		||||
        public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        public CheckOrderNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            if (DrawerNo > 0)
 | 
			
		||||
            {
 | 
			
		||||
                //查询当前药箱归属的药师
 | 
			
		||||
                string currentDrawerUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.DrawerNo == DrawerNo && cl.MachineId == "DM5").Select(cl => cl.BelongUser).First();
 | 
			
		||||
 | 
			
		||||
                OrderInfoList = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
                                .Includes(oi=>oi._OrderDetail,od=>od.DrugInfo)
 | 
			
		||||
                               //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase)
 | 
			
		||||
                               //.InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
                               //.InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
 | 
			
		||||
                               .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                               .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                               .Where(oi => oi.DmStatus == 0)
 | 
			
		||||
                               .Where(oi => oi.HisDispFlag == 0)
 | 
			
		||||
                               .Where(oi => oi.CancelFlag == 0)
 | 
			
		||||
                               .WhereIF(currentDrawerUser != null, oi => oi.DoctorCode == currentDrawerUser)
 | 
			
		||||
                               .OrderBy(oi => oi.OrderId)
 | 
			
		||||
                               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
                if (OrderInfoList != null && OrderInfoList.Count() > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    OrderInfoList.ForEach(oi => oi.ItemIsChecked = true);
 | 
			
		||||
                    TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi._OrderDetail.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item._OrderDetail.Quantity) }).ToList();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                TotalCount = totalCount;
 | 
			
		||||
                PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (selectOrderInfo != null)
 | 
			
		||||
                {
 | 
			
		||||
                    OrderInfoList = OrderInfoList.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.OrderNo == selectOrderInfo.OrderNo)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.ItemIsChecked = !x.ItemIsChecked;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    if (OrderInfoList != null && OrderInfoList.Count() > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi._OrderDetail.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item._OrderDetail.Quantity) }).ToList();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //确认
 | 
			
		||||
        public DelegateCommand CheckOrder
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                CheckOrderAction();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        void CheckOrderAction()
 | 
			
		||||
        {
 | 
			
		||||
            var confirmData = OrderInfoList.Where(oi => oi.ItemIsChecked == true).ToList();
 | 
			
		||||
            if (confirmData.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    string empChannelStock = string.Empty;
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < confirmData.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        OrderInfo oi = confirmData[i];
 | 
			
		||||
 | 
			
		||||
                        //更新处方状态
 | 
			
		||||
                        if (oi.DmStatus == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                            {
 | 
			
		||||
                                DmStatus = 1,
 | 
			
		||||
                                OrderNo = oi.OrderNo
 | 
			
		||||
                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
			
		||||
                            {
 | 
			
		||||
                                OrderNo = oi.OrderNo,
 | 
			
		||||
                                PatientId = oi.PatientId,
 | 
			
		||||
                                Pharmacy = oi.Pharmacy,
 | 
			
		||||
                                State = 1,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        Expression<Func<ChannelStock, bool>> updateExp = it => it.ManuNo == oi._OrderDetail.SetManuNo && it.EffDate == oi._OrderDetail.SetEffDate;
 | 
			
		||||
 | 
			
		||||
                        ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrugId == oi._OrderDetail.DrugId && cs.ManuNo == oi._OrderDetail.SetManuNo && cs.EffDate == oi._OrderDetail.SetEffDate && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).First();
 | 
			
		||||
                        if (cs == null)
 | 
			
		||||
                        {
 | 
			
		||||
                            empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate}";
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }
 | 
			
		||||
                        cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
 | 
			
		||||
                        // 更新数据 库存信息
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        if (cs != null)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                DrawerNo = cs.DrawerNo,
 | 
			
		||||
                                ColNo = cs.ColNo,
 | 
			
		||||
                                DrugId = cs.DrugId,
 | 
			
		||||
                                ManuNo = cs.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = oi._OrderDetail.Quantity,
 | 
			
		||||
                                Type = 2,
 | 
			
		||||
                                InvoiceId = oi.OrderNo
 | 
			
		||||
                                //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        //保存账册
 | 
			
		||||
                        int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = oi._OrderDetail.DrugId,
 | 
			
		||||
                            Type = 2,
 | 
			
		||||
                            Department = oi.DeptName,
 | 
			
		||||
                            OrderNo = oi.OrderNo,
 | 
			
		||||
                            ManuNo = cs.ManuNo,
 | 
			
		||||
                            EffDate = cs.EffDate,
 | 
			
		||||
                            OutQuantity = oi._OrderDetail.Quantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            CreateTime = DateTime.Now,
 | 
			
		||||
                            InvoiceNo = oi.OrderNo
 | 
			
		||||
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                        .Where(ab => ab.Type == 3)
 | 
			
		||||
                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
			
		||||
                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                        if (accountBookG2Day != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                            int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = oi._OrderDetail.DrugId,
 | 
			
		||||
                                Type = 3,
 | 
			
		||||
                                ManuNo = cs.ManuNo,
 | 
			
		||||
                                EffDate = cs.EffDate,
 | 
			
		||||
                                YQuantity = 0,
 | 
			
		||||
                                ManuStock = oi._OrderDetail.Quantity,
 | 
			
		||||
                                TotalStock = oi._OrderDetail.Quantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "日结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iDayResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                        .Where(ab => ab.Type == 4)
 | 
			
		||||
                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                        if (accountBookG2Total != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - oi._OrderDetail.Quantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                            int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = oi._OrderDetail.DrugId,
 | 
			
		||||
                                Type = 4,
 | 
			
		||||
                                YQuantity = 0,
 | 
			
		||||
                                ManuStock = oi._OrderDetail.Quantity,
 | 
			
		||||
                                TotalStock = oi._OrderDetail.Quantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "总结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iTotalResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!string.IsNullOrEmpty(empChannelStock))
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = $"所选处方对应药品批次效期无库存{empChannelStock}",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}");
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    return true;
 | 
			
		||||
                });
 | 
			
		||||
                if (f.Data)
 | 
			
		||||
                {
 | 
			
		||||
                    RequestData();
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "所选处方已核对完成",
 | 
			
		||||
                        Type = MsgType.SUCCESS,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                if (!f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "处方核对失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请勾选要核对的处方数据",
 | 
			
		||||
                    Type = MsgType.ERROR
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 选择药箱,打开药箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>(OpenBoxAction);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenBoxAction(string strDrawerNo)
 | 
			
		||||
        {
 | 
			
		||||
            DrawerNo = Convert.ToInt32(strDrawerNo);
 | 
			
		||||
            if (DrawerNo > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
                IsEnable = false;
 | 
			
		||||
                Status = 1;
 | 
			
		||||
                _portUtil.SpeakAsync("正在打开药箱");
 | 
			
		||||
                _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
                _portUtil.OpenBox();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            switch (msg.EventType)
 | 
			
		||||
            {
 | 
			
		||||
                // 药箱打开
 | 
			
		||||
                case EventType.DRAWEROPEN:
 | 
			
		||||
                    if (Status == 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 2;
 | 
			
		||||
                    }
 | 
			
		||||
                    //记录开药箱日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.GetBoxStatus();
 | 
			
		||||
                    break;
 | 
			
		||||
                // 药箱关闭
 | 
			
		||||
                case EventType.DRAWERCLOSE:
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱关闭",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (Status == 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    IsEnable = true;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
                // 打开失败
 | 
			
		||||
                case EventType.OPENERROR:
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = msg.Message,
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                    IsEnable = true; 
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开失败",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public class TotalDrug
 | 
			
		||||
    {
 | 
			
		||||
        public string DrugName { get; set; }
 | 
			
		||||
        public int TotalCount { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,476 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.Views;
 | 
			
		||||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Drawing.Printing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class CheckOrderWindowViewModel : BindableBase,INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        //private int _pageNum = 1;
 | 
			
		||||
        //public int PageNum
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageNum;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageNum, value);
 | 
			
		||||
        //        RequestData();
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _pageCount = 1;
 | 
			
		||||
        //public int PageCount
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageCount;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageCount, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _pageSize = 8;
 | 
			
		||||
        //public int PageSize
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _pageSize;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _pageSize, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private int _totalCount = 0;
 | 
			
		||||
        //public int TotalCount
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _totalCount;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _totalCount, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderWindowViewModel));
 | 
			
		||||
 | 
			
		||||
        private int _status=0;
 | 
			
		||||
 | 
			
		||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
			
		||||
 | 
			
		||||
        private bool _btnEnable=true;
 | 
			
		||||
        public bool BtnEnable { get => _btnEnable;set=>SetProperty(ref _btnEnable, value); }
 | 
			
		||||
 | 
			
		||||
        //抽屉号列表
 | 
			
		||||
        public static List<int> iList = new List<int>();
 | 
			
		||||
        //第几个抽屉号
 | 
			
		||||
        public static int iNumber = 1;
 | 
			
		||||
        private List<OrderDetail> orderDetailList=new();
 | 
			
		||||
        public List<OrderDetail> OrderDetailList
 | 
			
		||||
        { 
 | 
			
		||||
            get=> orderDetailList;
 | 
			
		||||
            set=>SetProperty(ref orderDetailList, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public CheckOrderWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand Query 
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(()=> { RequestData(); });
 | 
			
		||||
        }
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            OrderDetailList.Clear();
 | 
			
		||||
            //int totalCount = 0;
 | 
			
		||||
            List<OrderDetail> queryData = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
                .Includes<OrderInfo>(od => od._OrderInfo)
 | 
			
		||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
                .WhereIF(OrderDate != null, od => od._OrderInfo.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), od => od._OrderInfo.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(od => od._OrderInfo.DmStatus == 0)
 | 
			
		||||
                .Where(od => od._OrderInfo.HisDispFlag == 0)
 | 
			
		||||
                .Where(od => od._OrderInfo.CancelFlag == 0)
 | 
			
		||||
                //.Where(od=>od._OrderInfo.OrderNo== "202312219183416")
 | 
			
		||||
                .Where(od=>od._OrderInfo.DoctorCode== HomeWindowViewModel.Operator.UserBarcode)
 | 
			
		||||
                .OrderBy(od => od.OrderId)
 | 
			
		||||
                .ToList();
 | 
			
		||||
                //.ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            ICollectionView vw = CollectionViewSource.GetDefaultView(queryData);
 | 
			
		||||
            vw.GroupDescriptions.Add(new PropertyGroupDescription("_OrderInfo"));
 | 
			
		||||
 | 
			
		||||
            OrderDetailList = queryData;
 | 
			
		||||
            //TotalCount = totalCount;
 | 
			
		||||
            //PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        //核对确认
 | 
			
		||||
        public DelegateCommand ConfirmCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                ConfirmAction();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ConfirmAction()
 | 
			
		||||
        {
 | 
			
		||||
            //打开当前用户下的药箱
 | 
			
		||||
            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
			
		||||
                .Where(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserName)
 | 
			
		||||
                .Select(cl => cl.DrawerNo).ToList();
 | 
			
		||||
            if (iList.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.SpeakAsync("正在打开药箱");
 | 
			
		||||
                _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                iNumber++;
 | 
			
		||||
                Status = 1;
 | 
			
		||||
                _portUtil.OpenBox();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            switch (msg.EventType)
 | 
			
		||||
            {
 | 
			
		||||
                // 药箱打开
 | 
			
		||||
                case EventType.DRAWEROPEN:
 | 
			
		||||
                    BtnEnable = false;
 | 
			
		||||
                    //记录开药箱日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (iNumber < iList.Count)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                        iNumber++;
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
                        _portUtil.OpenBox();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        iNumber = 0;
 | 
			
		||||
                        _portUtil.GetBoxStatus();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                // 药箱关闭
 | 
			
		||||
                case EventType.DRAWERCLOSE:
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱关闭",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (Status == 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    BtnEnable = true;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
 | 
			
		||||
                    //减库存,生成操作记录
 | 
			
		||||
                    SaveDate();
 | 
			
		||||
 | 
			
		||||
                    break;
 | 
			
		||||
                // 打开失败
 | 
			
		||||
                case EventType.OPENERROR:
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = msg.Message,
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                    BtnEnable = true;
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开失败",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //减库存,生成操作记录
 | 
			
		||||
        private void SaveDate()
 | 
			
		||||
        {
 | 
			
		||||
            var confirmData = OrderDetailList.Where(od => od._OrderInfo.ItemIsChecked == true).ToList();
 | 
			
		||||
            if(confirmData.Count > 0 )
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    string empChannelStock=string.Empty;
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < confirmData.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        OrderDetail od = confirmData[i];
 | 
			
		||||
 | 
			
		||||
                        //更新处方状态
 | 
			
		||||
                        if(od._OrderInfo.DmStatus==0)
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                            {
 | 
			
		||||
                                DmStatus = 1,
 | 
			
		||||
                                OrderNo = od.OrderNo
 | 
			
		||||
                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
			
		||||
                            {
 | 
			
		||||
                                OrderNo = od.OrderNo,
 | 
			
		||||
                                PatientId = od._OrderInfo.PatientId,
 | 
			
		||||
                                Pharmacy = od._OrderInfo.Pharmacy,
 | 
			
		||||
                                State = 1,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        Expression<Func<ChannelStock, bool>> updateExp = it => it.ManuNo == od.SetManuNo && it.EffDate == od.SetEffDate;
 | 
			
		||||
 | 
			
		||||
                        ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs =>cs.DrugId==od.DrugId && cs.ManuNo == od.SetManuNo && cs.EffDate == od.SetEffDate && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).First();
 | 
			
		||||
                        if(cs==null)
 | 
			
		||||
                        {
 | 
			
		||||
                            empChannelStock += $"{od.OrderNo},{od.DrugId},{od.SetManuNo},{od.SetEffDate}";
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }
 | 
			
		||||
                        cs.Quantity = cs.Quantity - od.Quantity;
 | 
			
		||||
                        // 更新数据 库存信息
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        if (cs != null)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                DrawerNo = cs.DrawerNo,
 | 
			
		||||
                                ColNo = cs.ColNo,
 | 
			
		||||
                                DrugId = cs.DrugId,
 | 
			
		||||
                                ManuNo = cs.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = od.Quantity,
 | 
			
		||||
                                Type = 2,
 | 
			
		||||
                                InvoiceId = od.OrderNo
 | 
			
		||||
                                //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        //保存账册
 | 
			
		||||
                        int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = od.DrugId,
 | 
			
		||||
                            Type = 2,
 | 
			
		||||
                            Department = od._OrderInfo.DeptName,
 | 
			
		||||
                            OrderNo = od.OrderNo,
 | 
			
		||||
                            ManuNo = cs.ManuNo,
 | 
			
		||||
                            EffDate = cs.EffDate,
 | 
			
		||||
                            OutQuantity = od.Quantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            CreateTime = DateTime.Now,
 | 
			
		||||
                            InvoiceNo = od.OrderNo
 | 
			
		||||
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                        .Where(ab => ab.Type == 3)
 | 
			
		||||
                        .Where(ab => ab.DrugId == od.DrugId)
 | 
			
		||||
                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                        if (accountBookG2Day != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - od.Quantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                            int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = od.DrugId,
 | 
			
		||||
                                Type = 3,
 | 
			
		||||
                                ManuNo = cs.ManuNo,
 | 
			
		||||
                                EffDate = cs.EffDate,
 | 
			
		||||
                                YQuantity = 0,
 | 
			
		||||
                                ManuStock = od.Quantity,
 | 
			
		||||
                                TotalStock = od.Quantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "日结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iDayResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入日结存数据{od.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                        .Where(ab => ab.Type == 4)
 | 
			
		||||
                        .Where(ab => ab.DrugId == od.DrugId)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                        if (accountBookG2Total != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - od.Quantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                            int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = od.DrugId,
 | 
			
		||||
                                Type = 4,
 | 
			
		||||
                                YQuantity = 0,
 | 
			
		||||
                                ManuStock = od.Quantity,
 | 
			
		||||
                                TotalStock = od.Quantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                InvoiceNo = "总结存"
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            if (iTotalResult <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                logger.Info($"未写入总结存数据{od.DrugId}-{od.Quantity}");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if(!string.IsNullOrEmpty(empChannelStock))
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = $"所选处方对应药品批次效期无库存{empChannelStock}",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}");
 | 
			
		||||
                    }
 | 
			
		||||
                    return true;
 | 
			
		||||
                });
 | 
			
		||||
                if (f.Data)
 | 
			
		||||
                {
 | 
			
		||||
                    RequestData();
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "所选处方已核对完成",
 | 
			
		||||
                        Type = MsgType.SUCCESS,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                if (!f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "处方核对失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请勾选要核对的处方数据",
 | 
			
		||||
                    Type = MsgType.ERROR
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,231 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection.PortableExecutable;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class CollectDrugDialogViewModel : BindableBase, IDialogAware
 | 
			
		||||
    {
 | 
			
		||||
        public string Title => "请领申请确认";
 | 
			
		||||
 | 
			
		||||
        //请领数量
 | 
			
		||||
        private int _quantityCount;
 | 
			
		||||
        public int QuantityCount { get { return _quantityCount; } set { SetProperty(ref _quantityCount, value); } }
 | 
			
		||||
 | 
			
		||||
        //交处方张数
 | 
			
		||||
        private int _orderCount;
 | 
			
		||||
        public int OrderCount { get { return _orderCount; } set { SetProperty(ref _orderCount, value); } }
 | 
			
		||||
 | 
			
		||||
        //空瓶数量
 | 
			
		||||
        //private int _emptyCount;
 | 
			
		||||
        //public int EmptyCount { get { return _emptyCount; } set { SetProperty(ref _emptyCount, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        static string[] strColloctedId=ConfigurationManager.AppSettings["colloctedId"].Split(',');
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = strColloctedId[1] is null?"":strColloctedId[1],
 | 
			
		||||
                Name = strColloctedId[0]is null?"":strColloctedId[0]
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code =  strColloctedId[1] is null?"":strColloctedId[3],
 | 
			
		||||
                Name = strColloctedId[0]is null?"":strColloctedId[2]
 | 
			
		||||
            } 
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<CollectDrug> _beforeGroupcollectDrugList;
 | 
			
		||||
        public List<CollectDrug> BeforeGroupCollectDrugList
 | 
			
		||||
        {
 | 
			
		||||
            get { return _beforeGroupcollectDrugList; }
 | 
			
		||||
            set { SetProperty(ref _beforeGroupcollectDrugList, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<CollectDrug> _collectDrugList;
 | 
			
		||||
        public List<CollectDrug> CollectDrugList
 | 
			
		||||
        {
 | 
			
		||||
            get { return _collectDrugList; }
 | 
			
		||||
            set { SetProperty(ref _collectDrugList, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public CollectDrugDialogViewModel(IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            BeforeGroupCollectDrugList = parameters.GetValue<List<CollectDrug>>("ApplyDrug");
 | 
			
		||||
 | 
			
		||||
            QuantityCount = BeforeGroupCollectDrugList.Sum(ap => ap.Quantity);
 | 
			
		||||
            OrderCount = BeforeGroupCollectDrugList.Count;
 | 
			
		||||
 | 
			
		||||
            CollectDrugList = BeforeGroupCollectDrugList.GroupBy(cd => cd.DrugId).Select(cd => new CollectDrug
 | 
			
		||||
            {
 | 
			
		||||
                DrugName = cd.Aggregate("", (Ccurrent, collectdrug) => collectdrug.DrugName),
 | 
			
		||||
                Quantity = cd.Sum(cd => cd.Quantity),
 | 
			
		||||
                DrugSpec = cd.Max(cd => cd.DrugSpec),
 | 
			
		||||
                Manufactory = cd.Max(cd => cd.Manufactory),
 | 
			
		||||
                DrugId=cd.Max(cd=>cd.DrugId)
 | 
			
		||||
            }).ToList();
 | 
			
		||||
 | 
			
		||||
            //EmptyCount = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand CreateApply
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(CreateApplyMethod);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 生成请领单
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void CreateApplyMethod()
 | 
			
		||||
        {
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
                string pleaseNo = DateTime.Now.ToString("yyyyMMddHHmmss");
 | 
			
		||||
                if (CollectDrugList != null && CollectDrugList.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int d = 0; d < CollectDrugList.Count; d++)
 | 
			
		||||
                    {
 | 
			
		||||
                        CollectDrug groupDrug= CollectDrugList[d];
 | 
			
		||||
                        //保存请领申请表
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new DrugPleaseClaim()
 | 
			
		||||
                        {
 | 
			
		||||
                            GetQuantity = groupDrug.Quantity,// QuantityCount,
 | 
			
		||||
                            ReturnPrQuantity = OrderCount,
 | 
			
		||||
                            Type = 32,
 | 
			
		||||
                            State = 0,
 | 
			
		||||
                            MachineId = SelectedItem.Code,
 | 
			
		||||
                            ApplyUser = HomeWindowViewModel.Operator.Id,
 | 
			
		||||
                            ReviewUser = HomeWindowViewModel.Reviewer == null ? 0 : HomeWindowViewModel.Reviewer.Id,
 | 
			
		||||
                            DoDate = DateTime.Now,
 | 
			
		||||
                            Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
 | 
			
		||||
                            PleaseNo = pleaseNo,
 | 
			
		||||
                            DrugId = groupDrug.DrugId,
 | 
			
		||||
                            TotalQuantity= QuantityCount
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < BeforeGroupCollectDrugList.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    CollectDrug collectDrug = BeforeGroupCollectDrugList[i];
 | 
			
		||||
 | 
			
		||||
                    //修改处方表里的 药品请领状态(0未请领;1已请领)
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                    {
 | 
			
		||||
                        ApplyStatus = 1,
 | 
			
		||||
                        OrderNo = collectDrug.OrderNo,
 | 
			
		||||
                        MachineId= ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                    }).UpdateColumns(it => new { it.ApplyStatus }).Where(it => it.OrderNo == collectDrug.OrderNo).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    //保存处方、请领申请中间表
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new CollectDrug()
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugPleaseClaimId = pleaseNo,
 | 
			
		||||
                        OrderNo = collectDrug.OrderNo,
 | 
			
		||||
                        DrugId = collectDrug.DrugId,
 | 
			
		||||
                        Createdate = DateTime.Now,
 | 
			
		||||
                        Status = 0,
 | 
			
		||||
                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                        CurrentMachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                        //ConfigurationManager.AppSettings["colloctedId"].ToString(),
 | 
			
		||||
                        Quantity = collectDrug.Quantity
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
            if (f.IsSuccess)
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请领单已生成!",
 | 
			
		||||
                    Type = MsgType.SUCCESS,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请领单生成失败!",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,324 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Drawing.Printing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reactive.Joins;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Channels;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class CollectDrugWindowViewModel : BindableBase,INavigationAware,IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private List<CollectDrug> _collectDrugs = new();
 | 
			
		||||
 | 
			
		||||
        public List<CollectDrug> CollectDrugs { get { return _collectDrugs; } set { SetProperty(ref _collectDrugs, value); } }
 | 
			
		||||
 | 
			
		||||
        private CollectDrug _selectCollectDrugs;
 | 
			
		||||
        public CollectDrug selectCollectDrug { get { return _selectCollectDrugs; } set { SetProperty(ref _selectCollectDrugs, value); } }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public CollectDrugWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = dialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        //private void BindSelectCollect(CollectDrug collectDrug)
 | 
			
		||||
        //{
 | 
			
		||||
        //    if (SelectCollects == null)
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SelectCollects = new List<CollectDrug>();
 | 
			
		||||
        //    }
 | 
			
		||||
        //    if (SelectCollects.Contains(collectDrug))
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SelectCollects.Remove(collectDrug);
 | 
			
		||||
        //    }
 | 
			
		||||
        //    else
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SelectCollects.Add(collectDrug);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 选中处方的请领药品
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        //private List<CollectDrug> _selectCollects;
 | 
			
		||||
        //public List<CollectDrug> SelectCollects
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return _selectCollects; }
 | 
			
		||||
        //    set { SetProperty(ref _selectCollects, value); }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        void RequestData_for_SurgicalShedule()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            List<CollectDrug> queryData = SqlSugarHelper.Db.Queryable<SurgicalSchedule>()
 | 
			
		||||
         .InnerJoin<SurgicalScheduleDetail>((oi, od) => oi.OperationId == od.OperationId)
 | 
			
		||||
         .InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
 | 
			
		||||
         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (oi, od, di) => di.DrugId.ToString() == SearchValue)
 | 
			
		||||
         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (oi, od, di) => di.DrugName.Contains(SearchValue))
 | 
			
		||||
         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (oi, od, di) => di.PyCode.Contains(SearchValue))
 | 
			
		||||
         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (oi, od, di) => di.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
         .Where(oi => oi.DmStatus == 1)
 | 
			
		||||
         .Where(oi => oi.HisState == 1)
 | 
			
		||||
         .GroupBy(oi => oi.ScheduleTime)
 | 
			
		||||
         .Select((oi, od, di) => new CollectDrug
 | 
			
		||||
         {
 | 
			
		||||
             PatientId = oi.PatientId,
 | 
			
		||||
             PName = oi.PName,
 | 
			
		||||
             Sex = oi.Sex,
 | 
			
		||||
             Age = oi.Age,
 | 
			
		||||
             IdNumber = oi.IdNumber,
 | 
			
		||||
             OrderNo = oi.OperationId,
 | 
			
		||||
             //DeptName = oi.DeptName,
 | 
			
		||||
             DrugName = di.DrugName,
 | 
			
		||||
             Quantity = od.Quantity,
 | 
			
		||||
             DrugSpec = di.DrugSpec,
 | 
			
		||||
             Manufactory = di.Manufactory,
 | 
			
		||||
             DrugId = di.DrugId.ToString(),
 | 
			
		||||
         }).ToList();
 | 
			
		||||
            CollectDrugs = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
 | 
			
		||||
            List<CollectDrug> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
          .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
          .InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
 | 
			
		||||
          .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (oi, od, di) => di.DrugId.ToString() == SearchValue)
 | 
			
		||||
          .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (oi, od, di) => di.DrugName.Contains(SearchValue))
 | 
			
		||||
          .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (oi, od, di) => di.PyCode.Contains(SearchValue))
 | 
			
		||||
          .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (oi, od, di) => di.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
          .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
          .Where(oi => oi.DmStatus == 1)
 | 
			
		||||
          .Where(oi => oi.HisDispFlag == 0)
 | 
			
		||||
          .Where(oi => oi.CancelFlag == 0) 
 | 
			
		||||
          .Where(oi=>oi.ApplyStatus==0)
 | 
			
		||||
          .Where(oi => oi.Pharmacy.Equals(ConfigurationManager.AppSettings["storage"] ?? ""))
 | 
			
		||||
          .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
          .Select((oi, od, di) => new CollectDrug
 | 
			
		||||
          {
 | 
			
		||||
              PatientId = oi.PatientId,
 | 
			
		||||
              PName = oi.PName,
 | 
			
		||||
              Sex = oi.Sex,
 | 
			
		||||
              Age = oi.Age,
 | 
			
		||||
              IdNumber = oi.IdNumber,
 | 
			
		||||
              OrderNo = oi.OrderNo,
 | 
			
		||||
              DeptName = oi.DeptName,
 | 
			
		||||
              DrugName = di.DrugName,
 | 
			
		||||
              Quantity = od.Quantity,
 | 
			
		||||
              DrugSpec = di.DrugSpec,
 | 
			
		||||
              Manufactory = di.Manufactory,
 | 
			
		||||
              DrugId=di.DrugId.ToString(),
 | 
			
		||||
          }).ToList();
 | 
			
		||||
         // .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            //.ToList();
 | 
			
		||||
            CollectDrugs = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (selectCollectDrug != null)
 | 
			
		||||
                {
 | 
			
		||||
                    CollectDrugs = CollectDrugs.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.OrderNo == selectCollectDrug.OrderNo)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 生成请领单
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand CreateApplyOrder
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(OpenCreateApplyDialog);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenCreateApplyDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (CollectDrugs != null)
 | 
			
		||||
            {
 | 
			
		||||
                List<CollectDrug> selectCollect = CollectDrugs.Where(cd => cd.IsSelected).ToList();
 | 
			
		||||
                if (selectCollect.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                    await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("ApplyDrug", selectCollect);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "CollectDrugDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "未选择任何数据,请先选择数据信息!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        { 
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    internal class CollectionViewGroupInternal
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,40 +0,0 @@
 | 
			
		|||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class DebugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,304 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection.PortableExecutable;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Channels;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Threading;
 | 
			
		||||
using static Unity.Storage.RegistrationSet;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class DestoryEmptyDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public string Title => "空瓶取出";
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord> _machineRecords = new();
 | 
			
		||||
 | 
			
		||||
        public List<MachineRecord> _MachineRecords
 | 
			
		||||
        {
 | 
			
		||||
            get => _machineRecords;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _machineRecords, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private MachineRecord _machineRecord = new();
 | 
			
		||||
 | 
			
		||||
        public MachineRecord _MachineRecord
 | 
			
		||||
        {
 | 
			
		||||
            get => _machineRecord;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _machineRecord, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock _ChannelStock
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStock;
 | 
			
		||||
            set => SetProperty(ref _channelStock, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public DestoryEmptyDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "DrawerTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            _ChannelStock.TakeQuantity = msg.Quantitys[_ChannelStock.ColNo - 1];
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            ChannelStock _record = parameters.GetValue<ChannelStock>("channel");
 | 
			
		||||
            _ChannelStock = _record;
 | 
			
		||||
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Where(mr => mr.DrugId == _ChannelStock.DrugId)
 | 
			
		||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .Where(mr => mr.Type == 32)
 | 
			
		||||
                //.Where(mr => mr.Status != 2)
 | 
			
		||||
                .Where(mr=>mr.IsDestroy==0)
 | 
			
		||||
                .OrderByDescending(mr => mr.OperationTime)
 | 
			
		||||
                .OrderBy(mr => mr.Id)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            _MachineRecords = queryData;
 | 
			
		||||
        }
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (_MachineRecord != null && _MachineRecord.Quantity > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _MachineRecords = _MachineRecords.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == _MachineRecord.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    //dialogParameters.Add("channel", Channel);
 | 
			
		||||
                    //DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 空瓶销毁
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand DestoryEmptyCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
                    //IEnumerable<string> strDrugName = _MachineRecords.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
                    //string strNames = string.Empty;
 | 
			
		||||
                    //foreach (string name in strDrugName)
 | 
			
		||||
                    //{
 | 
			
		||||
                    //    if (!strNames.Contains(name))
 | 
			
		||||
                    //    {
 | 
			
		||||
                    //        strNames += name + ";";
 | 
			
		||||
                    //    }
 | 
			
		||||
                    //}
 | 
			
		||||
                    int sumQuantity = _MachineRecords.FindAll(it => it.IsSelected).Sum(cs => cs.Quantity);
 | 
			
		||||
                    _portUtil.SpeakAsync($"正在打开 {_ChannelStock.DrawerNo} 号抽屉,请取出空瓶 {_ChannelStock.DrugInfo.DrugName} ,数量共计 {sumQuantity}");
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
                    _portUtil.WindowName = "DrawerTakeDrugWindow";
 | 
			
		||||
                    _portUtil.BoardType = _ChannelStock.BoardType;
 | 
			
		||||
                    _portUtil.ColNos=new int[] { _ChannelStock.ColNo };
 | 
			
		||||
                    _portUtil.DrawerNo = _ChannelStock.DrawerNo;
 | 
			
		||||
                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
 | 
			
		||||
                    ;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand TakeFinish {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<MachineRecord> records = _MachineRecords.FindAll(it => it.IsSelected).ToList();
 | 
			
		||||
                if (records != null && records.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < records.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            MachineRecord record = records[i];
 | 
			
		||||
 | 
			
		||||
                            //修改库存数量
 | 
			
		||||
                            _ChannelStock.Quantity = _ChannelStock.Quantity - record.Quantity;
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(_ChannelStock).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            //修改记录表中状态
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(record).ReSetValue(mr =>
 | 
			
		||||
                            {
 | 
			
		||||
                                mr.IsDestroy = 1;
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            //记录销毁明细 
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new DestoryDetail()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                Operatorid = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewerid = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                RecordId = record.Id,
 | 
			
		||||
                                //OrderId = ChannelStock.ManuNo,
 | 
			
		||||
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        RequestData();
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "取出完成",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "取出失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请选择要取空瓶的数据",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,431 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Threading;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class DrawerAddDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
 | 
			
		||||
        private List<int> _drawerNoList = new List<int>();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock>? _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        public DrawerAddDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "DrawerAddDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status;
 | 
			
		||||
 | 
			
		||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 1;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _is8Drawer = true;
 | 
			
		||||
 | 
			
		||||
        public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
 | 
			
		||||
 | 
			
		||||
        private bool _is16Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _is17Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }, (DrawerNo) => Status == 0
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                Status = 1;
 | 
			
		||||
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    IEnumerable<string> strDrugName = ChannelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
                    string strNames = string.Empty;
 | 
			
		||||
                    foreach (string name in strDrugName)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (!strNames.Contains(name))
 | 
			
		||||
                        {
 | 
			
		||||
                            strNames += name + ";   ;";
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    int sumQuantity = ChannelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
                    _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计{sumQuantity}");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    _portUtil.WindowName = "DrawerAddDrugWindow";
 | 
			
		||||
                    _portUtil.Operate = true;
 | 
			
		||||
                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
                    _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
                    _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
                    _portUtil.Start();
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    logger.Info($"OpenDrawer异常:{ex.Message}");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }, () => Status == 0).ObservesProperty(() => Status);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
 | 
			
		||||
                    if (record.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock it = record[i];
 | 
			
		||||
                                it.ManuNo = it.drugManuNo.ManuNo;
 | 
			
		||||
                                it.EffDate = it.drugManuNo.EffDate;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                // 更新数据 库存信息
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                {
 | 
			
		||||
                                    Quantity = it.Quantity + it.AddQuantity,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    Id = it.Id,
 | 
			
		||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                // 获取更新完库存后的药品库存
 | 
			
		||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                    .ToList();
 | 
			
		||||
 | 
			
		||||
                                // 保存数据 入库记录
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    MachineId = it.MachineId,
 | 
			
		||||
                                    DrawerNo = it.DrawerNo,
 | 
			
		||||
                                    ColNo = it.ColNo,
 | 
			
		||||
                                    DrugId = it.DrugId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    OperationTime = DateTime.Now,
 | 
			
		||||
                                    Quantity = it.AddQuantity,
 | 
			
		||||
                                    Type = 1,
 | 
			
		||||
                                    InvoiceId = InvoiceId
 | 
			
		||||
                                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                //保存账册
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 1,
 | 
			
		||||
                                    Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                    InvoiceNo = InvoiceId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    AddQuantity = it.AddQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                //修改凌晨生成的日结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 3)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 3,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.AddQuantity,
 | 
			
		||||
                                        TotalStock = it.AddQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "日结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iDayResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                //修改凌晨生成的总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 4,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.AddQuantity,
 | 
			
		||||
                                        TotalStock = it.AddQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "总结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iTotalResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
                            RequestData();
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "抽屉加药完成,库存已更新",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "更新库存失败",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有填写加药数量",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public void FindDrawerCount()
 | 
			
		||||
        {
 | 
			
		||||
            int count = 0;
 | 
			
		||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
			
		||||
            {
 | 
			
		||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            Is8Drawer = count < 9;
 | 
			
		||||
            Is16Drawer = count >= 16;
 | 
			
		||||
            Is17Drawer = count > 16;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
               .Includes(cs => cs.DrugInfo, di => di.DrugManuNos)
 | 
			
		||||
               .Where(cs => cs.DrawerNo == DrawerNo)
 | 
			
		||||
               .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
               .Where(cs => cs.DrugId != null)
 | 
			
		||||
               .OrderBy(cs => cs.ColNo)
 | 
			
		||||
               .ToList();
 | 
			
		||||
            ChannelStocks = queryData.Select(cs =>
 | 
			
		||||
            {
 | 
			
		||||
                cs.drugManuNo = cs.DrugInfo.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
 | 
			
		||||
                return cs;
 | 
			
		||||
            }).ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            FindDrawerCount();
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,430 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Threading;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class DrawerTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerTakeDrugWindowViewModel));
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks = new List<ChannelStock>();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.WindowName == "DrawerTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStocks.ForEach(it => it.TakeQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status;
 | 
			
		||||
 | 
			
		||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
			
		||||
 | 
			
		||||
        private int _drawerNo = 1;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _is8Drawer = true;
 | 
			
		||||
 | 
			
		||||
        public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
 | 
			
		||||
 | 
			
		||||
        private bool _is16Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _is17Drawer = false;
 | 
			
		||||
 | 
			
		||||
        public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }, (DrawerNo) => Status == 0
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
                    IEnumerable<string> strDrugName = ChannelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
                    string strNames = string.Empty;
 | 
			
		||||
                    foreach (string name in strDrugName)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (!strNames.Contains(name))
 | 
			
		||||
                        {
 | 
			
		||||
                            strNames += name + ";";
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    int sumQuantity = ChannelStocks.Sum(cs => cs.TakeQuantity);
 | 
			
		||||
                    _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
			
		||||
 | 
			
		||||
                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
                    _portUtil.WindowName = "DrawerTakeDrugWindow";
 | 
			
		||||
                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
                    _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
                    _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
 | 
			
		||||
                    ;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
 | 
			
		||||
                    logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
 | 
			
		||||
                    if (record.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock it = record[i];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                // 更新数据 库存信息
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                {
 | 
			
		||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    Id = it.Id,
 | 
			
		||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                // 获取更新完库存后的药品库存
 | 
			
		||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                    .ToList();
 | 
			
		||||
 | 
			
		||||
                                // 保存数据 出库记录
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    MachineId = it.MachineId,
 | 
			
		||||
                                    DrawerNo = it.DrawerNo,
 | 
			
		||||
                                    ColNo = it.ColNo,
 | 
			
		||||
                                    DrugId = it.DrugId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    OperationTime = DateTime.Now,
 | 
			
		||||
                                    Quantity = it.TakeQuantity,
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    InvoiceId = InvoiceId
 | 
			
		||||
                                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                //保存账册
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                    InvoiceNo = InvoiceId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    OutQuantity = it.TakeQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                //修改凌晨生成的日结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 3)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 3,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "日结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iDayResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                //修改凌晨生成的总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 4,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "总结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iTotalResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
                            RequestData();
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "抽屉取药完成,库存已更新",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "抽屉取药完成,库存更新失败!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有填写取药数量",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public void FindDrawerCount()
 | 
			
		||||
        {
 | 
			
		||||
            int count = 0;
 | 
			
		||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
			
		||||
            {
 | 
			
		||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
			
		||||
            }
 | 
			
		||||
            Is8Drawer = count < 9;
 | 
			
		||||
            Is16Drawer = count >= 16;
 | 
			
		||||
            Is17Drawer = count > 16;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .Includes(cs => cs.DrugInfo)
 | 
			
		||||
                .Where(cs => cs.DrawerNo == DrawerNo)
 | 
			
		||||
                .Where(cs => cs.DrugId != null)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            ChannelStocks = queryData;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            FindDrawerCount();
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求, 不让走
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,485 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using log4net;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using static Unity.Storage.RegistrationSet;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class DrugListWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public DrugListWindowViewModel(IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<DrugInfo> _drugInfos;
 | 
			
		||||
        public List<DrugInfo> DrugInfos
 | 
			
		||||
        {
 | 
			
		||||
            get { return _drugInfos; }
 | 
			
		||||
            set { SetProperty(ref _drugInfos, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugInfo _selectedDrug = new();
 | 
			
		||||
        public DrugInfo SelectedDrug
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return _selectedDrug;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _selectedDrug, value);
 | 
			
		||||
                    GetManuNos();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _selectedDrug, new());
 | 
			
		||||
                    Manunos = null;
 | 
			
		||||
                    SelectedDrug.drugBase = new();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<DrugManuNo> _manunos;
 | 
			
		||||
        public List<DrugManuNo> Manunos
 | 
			
		||||
        {
 | 
			
		||||
            get { return _manunos; }
 | 
			
		||||
            set { SetProperty(ref _manunos, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DrugManuNo _selectedManuno = new DrugManuNo();
 | 
			
		||||
        public DrugManuNo SelectedManuno
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedManuno; }
 | 
			
		||||
            set { SetProperty(ref _selectedManuno, value ?? new()); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand AddDrugCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    //查询最大药品id并+1赋值给新增药品
 | 
			
		||||
                    long maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
 | 
			
		||||
                    SelectedDrug.DrugId = maxDrugId + 1;
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(SelectedDrug).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new DrugBase()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = SelectedDrug.DrugId.ToString(),
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
			
		||||
                            BaseQuantity = SelectedDrug.drugBase.BaseQuantity
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "新增成功",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "新增失败",
 | 
			
		||||
                            Type = MsgType.INFO,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    RequestData();
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    ILog logger = LogManager.GetLogger(typeof(DrugListWindowViewModel));
 | 
			
		||||
                    logger.Info($"添加数据异常:{ex.ToString()}");
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"添加数据异常:{ex.ToString()}",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }, () => SelectedDrug.DrugId <= 0).ObservesProperty(() => SelectedDrug);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand EditDrugCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    if (SelectedDrug.drugBase == null || SelectedDrug.drugBase.BaseId == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        SqlSugarHelper.Db.Insertable(new DrugBase()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = SelectedDrug.DrugId.ToString(),
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
			
		||||
                            BaseQuantity = SelectedDrug.drugBase.BaseQuantity
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //查询药品基数是否存在,存在则修改不存在则新增
 | 
			
		||||
                        DrugBase drugBase = SqlSugarHelper.Db.Queryable<DrugBase>()
 | 
			
		||||
                                       .Where(db => db.BaseId == SelectedDrug.drugBase.BaseId).First();
 | 
			
		||||
                        if (drugBase == null)
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new DrugBase()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = SelectedDrug.DrugId.ToString(),
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
			
		||||
                                BaseQuantity = SelectedDrug.drugBase.BaseQuantity
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new DrugBase() { BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).UpdateColumns(bs => new { bs.BaseQuantity }).Where(bs => bs.BaseId == SelectedDrug.drugBase.BaseId).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                if (f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "修改完成",
 | 
			
		||||
                        Type = MsgType.INFO,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "修改失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand AddManuCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
 | 
			
		||||
                    {
 | 
			
		||||
                        string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
			
		||||
                        int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
 | 
			
		||||
                        if (repeatCount > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "批次重复,请勿重复添加!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SelectedManuno.Id = Guid.NewGuid().ToString();
 | 
			
		||||
                            SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
 | 
			
		||||
                            SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
			
		||||
                            int iResult = SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand();
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg();
 | 
			
		||||
                            if (iResult > 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = "保存成功!",
 | 
			
		||||
                                    Type = MsgType.SUCCESS,
 | 
			
		||||
                                };
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = "保存失败!",
 | 
			
		||||
                                    Type = MsgType.SUCCESS,
 | 
			
		||||
                                };
 | 
			
		||||
                            }
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        //GetManuNos();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "请输入批次及效期!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"添加失败{ex.Message}",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand EditManuCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
			
		||||
                    int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
 | 
			
		||||
                    if (repeatCount > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "批次重复,请勿重复添加!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand(); 
 | 
			
		||||
                        GetManuNos();
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "修改成功!",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "修改失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            }, () => !string.IsNullOrEmpty(SelectedManuno.DrugId)).ObservesProperty(() => SelectedManuno);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void GetManuNos()
 | 
			
		||||
        {
 | 
			
		||||
            Manunos = SqlSugarHelper.Db.Queryable<DrugManuNo>()
 | 
			
		||||
                .WhereIF(SelectedDrug != null, (di) => di.DrugId.Equals(SelectedDrug.DrugId))
 | 
			
		||||
                .Select(di => di)
 | 
			
		||||
                .ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            DrugInfos = SqlSugarHelper.Db.Queryable<DrugInfo>()
 | 
			
		||||
                .Includes(di => di.drugBase)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (di) => di.DrugId.ToString().Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (di) => di.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (di) => di.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                //.Select(di => di)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            foreach (DrugInfo di in DrugInfos)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (di.drugBase == null)
 | 
			
		||||
                {
 | 
			
		||||
                    di.drugBase = new DrugBase();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +94,16 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    if(string.IsNullOrEmpty(UserList.UserBarcode))
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = $"工号不能为空",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    // 修改密码
 | 
			
		||||
                    if (OnlyPassword)
 | 
			
		||||
                    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,224 +0,0 @@
 | 
			
		|||
using DM_Weight.Common;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class FridgeOnlyWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
 | 
			
		||||
    {
 | 
			
		||||
        //温度区间
 | 
			
		||||
        private string _temperatureRange = CommonClass.ReadAppSetting("temperatureRange").ToString();
 | 
			
		||||
        public string TemperatureRange
 | 
			
		||||
        {
 | 
			
		||||
            get => _temperatureRange;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _temperatureRange, value);
 | 
			
		||||
                //更新配置文件中冰箱温度区间
 | 
			
		||||
                CommonClass.SaveAppSetting("temperatureRange", _temperatureRange);
 | 
			
		||||
            }
 | 
			
		||||
        } 
 | 
			
		||||
        private float defaultValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
 | 
			
		||||
        //温度值
 | 
			
		||||
        private float _temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
 | 
			
		||||
        public float TemperatureValue
 | 
			
		||||
        {
 | 
			
		||||
            get => _temperatureValue;
 | 
			
		||||
            set => SetProperty(ref _temperatureValue, value);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据冰箱温度控制保存按钮是否可点击
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _isInvalid;
 | 
			
		||||
        public bool IsInvalid
 | 
			
		||||
        {
 | 
			
		||||
            get => _isInvalid;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _isInvalid, value);
 | 
			
		||||
                BtnIsEnable = !IsInvalid;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据冰箱温度控制保存按钮是否可用
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _btnIsEnable = true;
 | 
			
		||||
        public bool BtnIsEnable
 | 
			
		||||
        {
 | 
			
		||||
            get => _btnIsEnable;
 | 
			
		||||
            set => SetProperty(ref _btnIsEnable, value);
 | 
			
		||||
        }
 | 
			
		||||
        //冰箱状态:true关;false开
 | 
			
		||||
        private bool _fridgeState;
 | 
			
		||||
        public bool FridgeState
 | 
			
		||||
        {
 | 
			
		||||
            get => _fridgeState;
 | 
			
		||||
            set => SetProperty(ref _fridgeState, value);
 | 
			
		||||
        }
 | 
			
		||||
        //报警状态:true关;false开
 | 
			
		||||
        private bool _alarmState;
 | 
			
		||||
        public bool AlarmState
 | 
			
		||||
        {
 | 
			
		||||
            get => _alarmState;
 | 
			
		||||
            set => SetProperty(ref _alarmState, value);
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        private int _defaultLoginMode;//1开0关
 | 
			
		||||
 | 
			
		||||
        private int _defaultAlarmMode;//1开0关
 | 
			
		||||
 | 
			
		||||
        private float retTemperature = Convert.ToSingle(ConfigurationManager.AppSettings["temperatureValue"]);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public FridgeOnlyWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 保存按钮
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        private async void SaveAction()
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.FridgeOperate = true;
 | 
			
		||||
 | 
			
		||||
                //设置温度值验证不通过则直接返回不保存
 | 
			
		||||
                //获取冰箱温度
 | 
			
		||||
                //if (_fridgeState != _defaultLoginMode.Equals(1))
 | 
			
		||||
                //{
 | 
			
		||||
                //    ConfigurationManager.RefreshSection("FridgeState");
 | 
			
		||||
                //发送冰箱使能/失能指令
 | 
			
		||||
                if (_fridgeState)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeOff(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridegOpen(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState", "1");
 | 
			
		||||
                }  
 | 
			
		||||
                //发送警报使能/失能指令
 | 
			
		||||
                if (_alarmState)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOff(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOn(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState", "1");
 | 
			
		||||
                }  
 | 
			
		||||
                //设定冰箱1温度区间
 | 
			
		||||
                string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
 | 
			
		||||
                string[] newRange = TemperatureRange.Split('-');
 | 
			
		||||
                if (range.Length >= 2)
 | 
			
		||||
                {
 | 
			
		||||
                    bool bMix = float.TryParse(range[0], out float Min);
 | 
			
		||||
                    bool bMax = float.TryParse(range[1], out float Max);
 | 
			
		||||
 | 
			
		||||
                    if (bMix && bMax)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (Min != Convert.ToSingle(newRange[0]))
 | 
			
		||||
                        {
 | 
			
		||||
                            //设定冰箱温度最小值
 | 
			
		||||
                            await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]), 1);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (Max != Convert.ToSingle(newRange[1]))
 | 
			
		||||
                        {
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                            //设定冰箱温度最大值
 | 
			
		||||
                            await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                 
 | 
			
		||||
 | 
			
		||||
                _portUtil.FridgeOperate = false;
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = $"保存成功",
 | 
			
		||||
                    Type = MsgType.SUCCESS
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); 
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = $"保存异常{ex.ToString}",
 | 
			
		||||
                    Type = MsgType.ERROR
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                _portUtil.FridgeOperate = false;
 | 
			
		||||
            }
 | 
			
		||||
        } 
 | 
			
		||||
        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
 | 
			
		||||
        public int ReadAppSetting(string key)
 | 
			
		||||
        {
 | 
			
		||||
            string xPath = "/configuration/appSettings//add[@key='" + key + "']";
 | 
			
		||||
            XmlDocument doc = new XmlDocument();
 | 
			
		||||
            string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
 | 
			
		||||
            doc.Load(exeFileName + ".dll.config");
 | 
			
		||||
            XmlNode node = doc.SelectSingleNode(xPath);
 | 
			
		||||
            return Convert.ToInt32(node.Attributes["value"].Value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _fridgeState = ReadAppSetting("FridgeState").Equals(0);
 | 
			
		||||
            _defaultLoginMode = ReadAppSetting("FridgeState");
 | 
			
		||||
            _defaultAlarmMode = ReadAppSetting("AlarmState");
 | 
			
		||||
            _alarmState = ReadAppSetting("AlarmState").Equals(0);
 | 
			
		||||
 | 
			
		||||
            GetTemperature();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        } 
 | 
			
		||||
        //获取冰箱温度值,如有更改则保存更改
 | 
			
		||||
        private async Task GetTemperature()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            //float retT = await _portUtil.GetFridgeTemperature();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,345 +0,0 @@
 | 
			
		|||
using DM_Weight.Common;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class FridgeWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
 | 
			
		||||
    {
 | 
			
		||||
        //温度区间
 | 
			
		||||
        private string _temperatureRange = CommonClass.ReadAppSetting("temperatureRange").ToString();
 | 
			
		||||
        public string TemperatureRange
 | 
			
		||||
        {
 | 
			
		||||
            get => _temperatureRange;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _temperatureRange, value);
 | 
			
		||||
                //更新配置文件中冰箱温度区间
 | 
			
		||||
                CommonClass.SaveAppSetting("temperatureRange", _temperatureRange);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //冰箱2温度区间
 | 
			
		||||
        private string _temperatureRange2 = CommonClass.ReadAppSetting("temperatureRange2").ToString();
 | 
			
		||||
        public string TemperatureRange2
 | 
			
		||||
        {
 | 
			
		||||
            get => _temperatureRange2;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _temperatureRange2, value);
 | 
			
		||||
                //更新配置文件中冰箱温度区间
 | 
			
		||||
                CommonClass.SaveAppSetting("temperatureRange2", _temperatureRange2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private float defaultValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
 | 
			
		||||
        //温度值
 | 
			
		||||
        private float _temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
 | 
			
		||||
        public float TemperatureValue
 | 
			
		||||
        {
 | 
			
		||||
            get => _temperatureValue;
 | 
			
		||||
            set => SetProperty(ref _temperatureValue, value);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据冰箱温度控制保存按钮是否可点击
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _isInvalid;
 | 
			
		||||
        public bool IsInvalid
 | 
			
		||||
        {
 | 
			
		||||
            get => _isInvalid;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _isInvalid, value);
 | 
			
		||||
                BtnIsEnable = !IsInvalid;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据冰箱温度控制保存按钮是否可用
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _btnIsEnable = true;
 | 
			
		||||
        public bool BtnIsEnable
 | 
			
		||||
        {
 | 
			
		||||
            get => _btnIsEnable;
 | 
			
		||||
            set => SetProperty(ref _btnIsEnable, value);
 | 
			
		||||
        }
 | 
			
		||||
        //冰箱状态:true关;false开
 | 
			
		||||
        private bool _fridgeState;
 | 
			
		||||
        public bool FridgeState
 | 
			
		||||
        {
 | 
			
		||||
            get => _fridgeState;
 | 
			
		||||
            set => SetProperty(ref _fridgeState, value);
 | 
			
		||||
        }
 | 
			
		||||
        //报警状态:true关;false开
 | 
			
		||||
        private bool _alarmState;
 | 
			
		||||
        public bool AlarmState
 | 
			
		||||
        {
 | 
			
		||||
            get => _alarmState;
 | 
			
		||||
            set => SetProperty(ref _alarmState, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //冰箱2状态:true关;false开
 | 
			
		||||
        private bool _fridgeState2;
 | 
			
		||||
        public bool FridgeState2
 | 
			
		||||
        {
 | 
			
		||||
            get => _fridgeState2;
 | 
			
		||||
            set => SetProperty(ref _fridgeState2, value);
 | 
			
		||||
        }
 | 
			
		||||
        //冰箱2报警状态:true关;false开
 | 
			
		||||
        private bool _alarmState2;
 | 
			
		||||
        public bool AlarmState2
 | 
			
		||||
        {
 | 
			
		||||
            get => _alarmState2;
 | 
			
		||||
            set => SetProperty(ref _alarmState2, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _defaultLoginMode;//1开0关
 | 
			
		||||
 | 
			
		||||
        private int _defaultAlarmMode;//1开0关
 | 
			
		||||
 | 
			
		||||
        private float retTemperature = Convert.ToSingle(ConfigurationManager.AppSettings["temperatureValue"]);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public FridgeWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 保存按钮
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        private async void SaveAction()
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.FridgeOperate = true;
 | 
			
		||||
 | 
			
		||||
                //设置温度值验证不通过则直接返回不保存
 | 
			
		||||
                //获取冰箱温度
 | 
			
		||||
                //if (_fridgeState != _defaultLoginMode.Equals(1))
 | 
			
		||||
                //{
 | 
			
		||||
                //    ConfigurationManager.RefreshSection("FridgeState");
 | 
			
		||||
                //发送冰箱使能/失能指令
 | 
			
		||||
                if (_fridgeState)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeOff(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridegOpen(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState", "1");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //冰箱2  发送冰箱使能/失能指令
 | 
			
		||||
                if (_fridgeState2)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeOff(2);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState2", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridegOpen(2);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("FridgeState2", "1");
 | 
			
		||||
                }
 | 
			
		||||
                //}
 | 
			
		||||
                //温度报警设定
 | 
			
		||||
                //if (AlarmState != _defaultAlarmMode.Equals(1))
 | 
			
		||||
                //{
 | 
			
		||||
                //发送警报使能/失能指令
 | 
			
		||||
                if (_alarmState)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOff(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOn(1);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState", "1");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //冰箱2 发送警报使能/失能指令
 | 
			
		||||
                if (_alarmState2)
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOff(2);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState2", "0");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    await _portUtil.FridgeAlarmOn(2);
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    CommonClass.SaveAppSetting("AlarmState2", "1");
 | 
			
		||||
                }
 | 
			
		||||
                //}
 | 
			
		||||
 | 
			
		||||
                //if (retTemperature != TemperatureValue)
 | 
			
		||||
                //{
 | 
			
		||||
                //    //设定冰箱温度
 | 
			
		||||
                //    await _portUtil.SetFridgeTemperature(TemperatureValue);
 | 
			
		||||
 | 
			
		||||
                //    CommonClass.SaveAppSetting("temperatureValue", TemperatureValue.ToString());
 | 
			
		||||
                //}
 | 
			
		||||
                //设定冰箱1温度区间
 | 
			
		||||
                string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
 | 
			
		||||
                string[] newRange = TemperatureRange.Split('-');
 | 
			
		||||
                if (range.Length >= 2)
 | 
			
		||||
                {
 | 
			
		||||
                    bool bMix = float.TryParse(range[0], out float Min);
 | 
			
		||||
                    bool bMax = float.TryParse(range[1], out float Max);
 | 
			
		||||
 | 
			
		||||
                    if (bMix && bMax)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (Min != Convert.ToSingle(newRange[0]))
 | 
			
		||||
                        {
 | 
			
		||||
                            //设定冰箱温度最小值
 | 
			
		||||
                            await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (Max != Convert.ToSingle(newRange[1]))
 | 
			
		||||
                        {
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                            //设定冰箱温度最大值
 | 
			
		||||
                            await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //设定冰箱2温度区间
 | 
			
		||||
                string[] range2 = ConfigurationManager.AppSettings["temperatureRange2"].Split('-');
 | 
			
		||||
                string[] newRange2 = TemperatureRange2.Split('-');
 | 
			
		||||
                if (range2.Length >= 2)
 | 
			
		||||
                {
 | 
			
		||||
                    bool bMix = float.TryParse(range2[0], out float Min);
 | 
			
		||||
                    bool bMax = float.TryParse(range2[1], out float Max);
 | 
			
		||||
 | 
			
		||||
                    if (bMix && bMax)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (Min != Convert.ToSingle(newRange2[0]))
 | 
			
		||||
                        {
 | 
			
		||||
                            //设定冰箱温度最小值
 | 
			
		||||
                            await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange2[0]), 2);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (Max != Convert.ToSingle(newRange2[1]))
 | 
			
		||||
                        {
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                            //设定冰箱温度最大值
 | 
			
		||||
                            await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange2[1]), 2);
 | 
			
		||||
                            Thread.Sleep(100);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                _portUtil.FridgeOperate = false;
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = $"保存成功",
 | 
			
		||||
                    Type = MsgType.SUCCESS
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                //_fridgeState = ReadAppSetting("FridgeState").Equals(1);
 | 
			
		||||
                //_defaultLoginMode = ReadAppSetting("FridgeState");
 | 
			
		||||
                //_defaultAlarmMode = ReadAppSetting("AlarmState");
 | 
			
		||||
                //_alarmState = ReadAppSetting("AlarmState").Equals(1);
 | 
			
		||||
                //_temperatureRange = CommonClass.ReadAppSetting("temperatureRange");
 | 
			
		||||
                //_temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = $"保存异常{ex.ToString}",
 | 
			
		||||
                    Type = MsgType.ERROR
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                _portUtil.FridgeOperate = false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public FridgeWindowViewModel()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
 | 
			
		||||
        public int ReadAppSetting(string key)
 | 
			
		||||
        {
 | 
			
		||||
            string xPath = "/configuration/appSettings//add[@key='" + key + "']";
 | 
			
		||||
            XmlDocument doc = new XmlDocument();
 | 
			
		||||
            string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
 | 
			
		||||
            doc.Load(exeFileName + ".dll.config");
 | 
			
		||||
            XmlNode node = doc.SelectSingleNode(xPath);
 | 
			
		||||
            return Convert.ToInt32(node.Attributes["value"].Value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _fridgeState = ReadAppSetting("FridgeState").Equals(0);
 | 
			
		||||
            _defaultLoginMode = ReadAppSetting("FridgeState");
 | 
			
		||||
            _defaultAlarmMode = ReadAppSetting("AlarmState");
 | 
			
		||||
            _alarmState = ReadAppSetting("AlarmState").Equals(0);
 | 
			
		||||
 | 
			
		||||
            GetTemperature();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        //{
 | 
			
		||||
        //    GetTemperature();
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        //{
 | 
			
		||||
        //    return true;
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        //{
 | 
			
		||||
        //}
 | 
			
		||||
        //获取冰箱温度值,如有更改则保存更改
 | 
			
		||||
        private async Task GetTemperature()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            //float retT = await _portUtil.GetFridgeTemperature();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,453 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.Views;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class InvoiceAddDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceAddDialogViewModel));
 | 
			
		||||
        public string Title => "调拨加药";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private string WindowName = "InvoiceAddWindow";
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        public InvoiceAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
        private Invoice? _invoic;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public Invoice? Invoice
 | 
			
		||||
        {
 | 
			
		||||
            get => _invoic;
 | 
			
		||||
            set => SetProperty(ref _invoic, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            List<ChannelStock> channelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
			
		||||
            Invoice o = parameters.GetValue<Invoice>("invoice");
 | 
			
		||||
            Invoice = o;
 | 
			
		||||
            ChannelStocks = channelStocks;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
            enumerator = enumerable.GetEnumerator();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name + "  ;  ";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计 {sumQuantity}个");
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = WindowName;
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
            {
 | 
			
		||||
                // 发送加药数量
 | 
			
		||||
                singleChannels.ForEach(it =>
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < singleChannels.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock it = singleChannels[i];
 | 
			
		||||
                    _portUtil.ClearCount(it.DrawerNo, it.ColNo);
 | 
			
		||||
                    await Task.Delay(50);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
			
		||||
                    string InvoiceId = Invoice.InvoiceNo;
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(new InOutInvoice()
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 1,
 | 
			
		||||
                            InvoiceNo = Invoice.InvoiceNo
 | 
			
		||||
                        }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStock it = record[i];
 | 
			
		||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
			
		||||
                            }
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                Quantity = it.Quantity + it.AddQuantity,
 | 
			
		||||
                                PosNo = 1,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
			
		||||
                            // 获取更新完库存后的药品库存
 | 
			
		||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
 | 
			
		||||
                            // 保存数据 出/入库记录
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = it.MachineId,
 | 
			
		||||
                                DrawerNo = it.DrawerNo,
 | 
			
		||||
                                ColNo = it.ColNo,
 | 
			
		||||
                                DrugId = it.DrugId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = it.AddQuantity,
 | 
			
		||||
                                Type = 1,
 | 
			
		||||
                                InvoiceId = InvoiceId
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            //保存账册
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type = 1,
 | 
			
		||||
                                Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                InvoiceNo = InvoiceId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                AddQuantity = it.AddQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            //修改凌晨生成的日结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 3)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 3,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.AddQuantity,
 | 
			
		||||
                                    TotalStock = it.AddQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "日结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iDayResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            //修改凌晨生成的总结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 4,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.AddQuantity,
 | 
			
		||||
                                    TotalStock = it.AddQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "总结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iTotalResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            singleChannels.ForEach(it =>
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "操作完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "库存更新失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,384 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Markup;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class InvoiceInWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceInWindowViewModel));
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
 | 
			
		||||
 | 
			
		||||
        public InvoiceInWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "invoiceNo",
 | 
			
		||||
                Name = "凭证单号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Invoice? _selectedInvoice;
 | 
			
		||||
 | 
			
		||||
        public Invoice? SelectedInvoice
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedInvoice; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedInvoice, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<Invoice> _invoices = new();
 | 
			
		||||
 | 
			
		||||
        public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<InOutInvoice> _inOutInvoices = new();
 | 
			
		||||
 | 
			
		||||
        public List<InOutInvoice> InOutInvoices { get { return _inOutInvoices; } set { SetProperty(ref _inOutInvoices, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _addChannels = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> AddChannels { get { return _addChannels; } set { SetProperty(ref _addChannels, value); } }
 | 
			
		||||
 | 
			
		||||
        public void GetChannelByInvoice()
 | 
			
		||||
        {
 | 
			
		||||
            ChannelStocks.Clear();
 | 
			
		||||
            InOutInvoices.Clear();
 | 
			
		||||
            List<ChannelStock> i = new List<ChannelStock>();
 | 
			
		||||
            if (SelectedInvoice != null)
 | 
			
		||||
            {
 | 
			
		||||
                var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
			
		||||
                                .Includes<DrugInfo>(i => i.DrugInfo)
 | 
			
		||||
                                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
 | 
			
		||||
                                .Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
                foreach (var invoice in invoices)
 | 
			
		||||
                {
 | 
			
		||||
                    List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == invoice.DrugId)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                    .OrderBy(cs => cs.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                    .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
                    for (int j = 0; j < q.Count;j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock item = q[j];
 | 
			
		||||
                        if(j == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            item.AddQuantity = invoice.quantity;
 | 
			
		||||
                        }
 | 
			
		||||
                        item.Invoice = invoice;
 | 
			
		||||
                        i.Add(item);
 | 
			
		||||
                    }
 | 
			
		||||
                    InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoice);
 | 
			
		||||
                    InOutInvoices.Add(copy);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ICollectionView vw = CollectionViewSource.GetDefaultView(i);
 | 
			
		||||
            vw.GroupDescriptions.Add(new PropertyGroupDescription("Invoice"));
 | 
			
		||||
            ChannelStocks = i;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenInvoiceAdd
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                bool flag = true;
 | 
			
		||||
                for (int i = 0; i < InOutInvoices.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    InOutInvoice invoices = InOutInvoices[i];
 | 
			
		||||
                    if (invoices.quantity != ChannelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
 | 
			
		||||
                    {
 | 
			
		||||
                        flag = false;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (flag)
 | 
			
		||||
                {
 | 
			
		||||
                    AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
 | 
			
		||||
                    AddChannels.Sort((a, b) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            return a.ColNo - b.ColNo;
 | 
			
		||||
                        }
 | 
			
		||||
                        return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                    });
 | 
			
		||||
                    OpenOrderDialog();
 | 
			
		||||
                } else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "库位添加数量小于应添加数量",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            },() => SelectedInvoice !=null).ObservesProperty(() => SelectedInvoice);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedInvoice != null && SelectedInvoice.Status == 0)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("invoice", SelectedInvoice);
 | 
			
		||||
                dialogParameters.Add("ChannelStocks", AddChannels);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceAddDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                SelectedInvoice = null;
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            Invoices.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
 | 
			
		||||
            var sb = new StringBuilder();
 | 
			
		||||
            sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
			
		||||
            sb.Append(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
			
		||||
            sb.Append(" left join pharmacy_info p1 on p1.pharmacy = i.in_pharmacy_id");
 | 
			
		||||
            sb.Append(" left join pharmacy_info p2 on p2.pharmacy = i.out_pharmacy_id");
 | 
			
		||||
            sb.Append(" where i.status=@Status ");
 | 
			
		||||
            sb.Append(" and i.type!=@type ");
 | 
			
		||||
            sb.Append(" and i.cancel_flag=@CancelFlag ");
 | 
			
		||||
            if (OrderDate != null)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.invoice_date = @CreateTime ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(SearchValue))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.invoice_no = @InvoiceNo ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.in_pharmacy_id = @OutPharmacyId ");
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append(" group by i.invoice_no");
 | 
			
		||||
            sb.Append(" order by i.invoice_date ");
 | 
			
		||||
            Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
			
		||||
                .AddParameters(new
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 0,
 | 
			
		||||
                    type = 2,
 | 
			
		||||
                    CancelFlag = 0,
 | 
			
		||||
                    CreateTime = OrderDate,
 | 
			
		||||
                    InvoiceNo = SearchValue,
 | 
			
		||||
                    OutPharmacyId = ConfigurationManager.AppSettings["storage"]
 | 
			
		||||
                })
 | 
			
		||||
                .Select(it => new Invoice())
 | 
			
		||||
                .Select("*")
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,270 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class InvoiceOutWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
        public InvoiceOutWindowViewModel(IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "invoiceNo",
 | 
			
		||||
                Name = "凭证单号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Invoice? _selectedInvoice;
 | 
			
		||||
 | 
			
		||||
        public Invoice? SelectedInvoice
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedInvoice; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedInvoice, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<Invoice> _invoices = new();
 | 
			
		||||
 | 
			
		||||
        public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedInvoice != null && SelectedInvoice.Status == 0)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("invoice", SelectedInvoice);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                SelectedInvoice = null;
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            Invoices.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
 | 
			
		||||
            var sb = new StringBuilder();
 | 
			
		||||
            sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
			
		||||
            sb.Append(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
			
		||||
            sb.Append(" left join pharmacy_info p1 on p1.pharmacy = i.in_pharmacy_id");
 | 
			
		||||
            sb.Append(" left join pharmacy_info p2 on p2.pharmacy = i.out_pharmacy_id");
 | 
			
		||||
            sb.Append(" where i.status=@Status ");
 | 
			
		||||
            sb.Append(" and i.type!=@type ");
 | 
			
		||||
            sb.Append(" and i.cancel_flag=@CancelFlag ");
 | 
			
		||||
            if (OrderDate != null)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.invoice_date = @CreateTime ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(SearchValue))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.invoice_no = @InvoiceNo ");
 | 
			
		||||
            }
 | 
			
		||||
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]))
 | 
			
		||||
            {
 | 
			
		||||
                sb.Append(" and i.out_pharmacy_id = @OutPharmacyId ");
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append(" group by i.invoice_no");
 | 
			
		||||
            sb.Append(" order by i.invoice_date ");
 | 
			
		||||
            Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
			
		||||
                .AddParameters(new
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 0,
 | 
			
		||||
                    type = 1,
 | 
			
		||||
                    CancelFlag = 0,
 | 
			
		||||
                    CreateTime = OrderDate,
 | 
			
		||||
                    InvoiceNo = SearchValue,
 | 
			
		||||
                    OutPharmacyId = ConfigurationManager.AppSettings["storage"]
 | 
			
		||||
                })
 | 
			
		||||
                .Select(it => new Invoice())
 | 
			
		||||
                .Select("*")
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,524 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using Microsoft.Xaml.Behaviors;
 | 
			
		||||
using NetTaste;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class InvoiceTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceTakeDialogViewModel));
 | 
			
		||||
        public string Title => "调拨出库";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
        public InvoiceTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "InvoiceTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Invoice? _invoic;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public Invoice? Invoice
 | 
			
		||||
        {
 | 
			
		||||
            get => _invoic;
 | 
			
		||||
            set => SetProperty(ref _invoic, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<InOutInvoice> invoices { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            Invoice o = parameters.GetValue<Invoice>("invoice");
 | 
			
		||||
            Invoice = o;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
			
		||||
                .Includes<DrugInfo>(i => i.DrugInfo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
 | 
			
		||||
                .Where(i => i.InvoiceNo == Invoice.InvoiceNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
            List<string> msg = new List<string>();
 | 
			
		||||
            for (int i = 0; i < invoices.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                InOutInvoice invoice = invoices[i];
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == invoice.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
			
		||||
                int TakeQ = invoice.quantity;
 | 
			
		||||
                // 说明数量足够
 | 
			
		||||
                if (total >= TakeQ)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock stock = HasQChannels[j];
 | 
			
		||||
                        if (TakeQ > stock.Quantity)
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = stock.Quantity;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ -= stock.Quantity;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = TakeQ;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ = 0;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    msg.Add($"药品【{invoice.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (msg.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                channelStocks.Sort((a, b) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        return a.ColNo - b.ColNo;
 | 
			
		||||
                    }
 | 
			
		||||
                    return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                });
 | 
			
		||||
                ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                    enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name + "  ;  ";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}"); 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "InvoiceTakeDrugWindow";
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
			
		||||
                    if (record.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string InvoiceId = Invoice.InvoiceNo;
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new InOutInvoice()
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 1,
 | 
			
		||||
                                InvoiceNo = Invoice.InvoiceNo
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock it = record[i];
 | 
			
		||||
                                // 更新数据 库存信息
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                {
 | 
			
		||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    Id = it.Id,
 | 
			
		||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                // 获取更新完库存后的药品库存
 | 
			
		||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                    .ToList();
 | 
			
		||||
 | 
			
		||||
                                // 保存数据 出库记录
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    MachineId = it.MachineId,
 | 
			
		||||
                                    DrawerNo = it.DrawerNo,
 | 
			
		||||
                                    ColNo = it.ColNo,
 | 
			
		||||
                                    DrugId = it.DrugId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    OperationTime = DateTime.Now,
 | 
			
		||||
                                    Quantity = it.TakeQuantity,
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    InvoiceId = InvoiceId
 | 
			
		||||
                                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                //保存账册
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                    InvoiceNo = InvoiceId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    OutQuantity = it.TakeQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                //修改凌晨生成的日结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 3)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 3,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "日结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iDayResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                //修改凌晨生成的总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 4,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "总结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iTotalResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
                            // 更新屏显库存
 | 
			
		||||
                            List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                            {
 | 
			
		||||
                                singleChannels.ForEach(it =>
 | 
			
		||||
                                {
 | 
			
		||||
                                    _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                                });
 | 
			
		||||
                            }
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "调拨取药完成,库存已更新",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "调拨取药完成,库存更新失败!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有填写取药数量",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
			
		|||
 | 
			
		||||
                                        .Includes<RoleDm>(u => u.Role)
 | 
			
		||||
 | 
			
		||||
                                        .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
 | 
			
		||||
                                        .First(u => u.UserName == username && ("DM3".Equals(u.MachineId) || ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId)));
 | 
			
		||||
                    if (userList == null)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,209 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using gregn6Lib;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class MachineRecordWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        public DateTime? StartDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _startDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0 ));
 | 
			
		||||
                } else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23,59,59);
 | 
			
		||||
 | 
			
		||||
        public DateTime? EndDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _endDate;
 | 
			
		||||
            set{
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
			
		||||
                    SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _endDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }  
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _type;
 | 
			
		||||
 | 
			
		||||
        public int Type
 | 
			
		||||
        {
 | 
			
		||||
            get { return _type; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _type, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord>? machineRecords;
 | 
			
		||||
 | 
			
		||||
        public List<MachineRecord>? MachineRecords
 | 
			
		||||
        {
 | 
			
		||||
            get { return machineRecords; }
 | 
			
		||||
            set { SetProperty(ref machineRecords, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public MachineRecordWindowViewModel()
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Download
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GridReportUtil.PrintReportMechineRecord(Type, StartDate, EndDate);
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand DownloadAccountBook
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GridReportUtil.PrintReportAccountBook(StartDate, EndDate);
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        void ReportInitialize()
 | 
			
		||||
        {
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //取出Type决定页面显示内容
 | 
			
		||||
            Type = navigationContext.Parameters.GetValue<int>("Type");
 | 
			
		||||
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
			
		||||
            MachineRecords = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Where(mr => mr.MachineId == machineId)
 | 
			
		||||
                .WhereIF(Type == 3, (mr) => new int[] { 31, 32 }.Contains(mr.Type))
 | 
			
		||||
                .WhereIF(Type != 3, (mr) => mr.Type == Type )
 | 
			
		||||
                .WhereIF(StartDate !=null, (mr) => mr.OperationTime > StartDate)
 | 
			
		||||
                .WhereIF(EndDate!=null, (mr) => mr.OperationTime < EndDate)
 | 
			
		||||
                //.Select(mr => mr)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
                //.ToList();
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,488 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class MultiOrderTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
        public string Title => "多处方取药";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public MultiOrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //多处方的处方号
 | 
			
		||||
        private string _multiOrderNo = "处方号:";
 | 
			
		||||
        public string MultiOrderNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _multiOrderNo;
 | 
			
		||||
            set => SetProperty(ref _multiOrderNo, value);
 | 
			
		||||
        }
 | 
			
		||||
        private ObservableCollection<OrderInfo>? _orderInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public ObservableCollection<OrderInfo>? OrderInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderInfo;
 | 
			
		||||
            set => SetProperty(ref _orderInfo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            OrderInfo = parameters.GetValue<ObservableCollection<OrderInfo>>("orderInfo");
 | 
			
		||||
            MultiOrderNo += string.Join(",   ", OrderInfo.Select(o => o.OrderNo));
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
              //.Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
              .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
              .Where(od => OrderInfo.Select(o => o.OrderNo).Contains(od.OrderNo)).GroupBy(od=>od.DrugId)
 | 
			
		||||
 | 
			
		||||
              .Select(od=>new OrderDetail { DrugId=od.DrugId,SetEffDate=od.SetEffDate,SetManuNo=od.SetManuNo, Quantity=SqlFunc.AggregateSum(od.Quantity) })
 | 
			
		||||
 | 
			
		||||
                //.Where(od => od.OrderNo. OrderInfo.OrderNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
            List<string> msg = new List<string>();
 | 
			
		||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDetail orderDetail = orderDetails[i];
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
			
		||||
                int TakeQ = orderDetail.Quantity;
 | 
			
		||||
                int multiTakeQ = orderDetail.Quantity;
 | 
			
		||||
                List<ChannelStock> multiTake = new List<ChannelStock>();
 | 
			
		||||
                //multiTakeQ = orderDetails.Where(c => c.DrugId == orderDetail.DrugId).Sum(c => c.Quantity);
 | 
			
		||||
                // 说明数量足够
 | 
			
		||||
                if (total >= multiTakeQ)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock stock = HasQChannels[j];
 | 
			
		||||
 | 
			
		||||
                        if (TakeQ > stock.Quantity)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            //#region 存在该库存且库存数量大于待取数量则把取药数量加上
 | 
			
		||||
                            //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
 | 
			
		||||
                            //if (varChannelStock != null && varChannelStock.Count > 0)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
 | 
			
		||||
                            //    break;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //#endregion
 | 
			
		||||
                            stock.TakeQuantity = stock.Quantity;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ -= stock.Quantity;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            //#region 存在该库存且库存数量大于待取数量则把取药数量加上
 | 
			
		||||
                            //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
 | 
			
		||||
                            //if (varChannelStock != null && varChannelStock.Count > 0)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
 | 
			
		||||
                            //    break;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //#endregion
 | 
			
		||||
                            stock.TakeQuantity = TakeQ;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ = 0;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                    msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (msg.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                channelStocks.Sort((a, b) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        return a.ColNo - b.ColNo;
 | 
			
		||||
                    }
 | 
			
		||||
                    return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                });
 | 
			
		||||
                ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                    enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"打开抽屉异常{ex.Message}",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
			
		||||
 | 
			
		||||
                    //根据处方单数量分别更新处方状态、写记录信息
 | 
			
		||||
                    if (OrderInfo.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        for (int j = 0; j < OrderInfo.Count; j++)
 | 
			
		||||
                        {
 | 
			
		||||
                            string InvoiceId = OrderInfo[j].OrderNo;
 | 
			
		||||
                            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                            {
 | 
			
		||||
                                //SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                                //{
 | 
			
		||||
                                //    DmStatus = 1,
 | 
			
		||||
                                //    OrderNo = OrderInfo[j].OrderNo
 | 
			
		||||
                                //}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
			
		||||
                                {
 | 
			
		||||
                                    OrderNo = OrderInfo[j].OrderNo,
 | 
			
		||||
                                    PatientId = OrderInfo[j].PatientId,
 | 
			
		||||
                                    Pharmacy = OrderInfo[j].Pharmacy,
 | 
			
		||||
                                    State = 1,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
			
		||||
                                });
 | 
			
		||||
                                for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                                {
 | 
			
		||||
 | 
			
		||||
                                    List<OrderDetail> orderDet = SqlSugarHelper.Db.Queryable<OrderDetail>().Where(od => od.OrderNo == OrderInfo[j].OrderNo && od.DrugId == record[i].DrugId).ToList();
 | 
			
		||||
                                    //该对方没有这个药,跳出循环
 | 
			
		||||
                                    if (orderDet == null || orderDet.Count <= 0)
 | 
			
		||||
                                        continue;
 | 
			
		||||
                                    int orderTakeQuantity = orderDet[0].Quantity;
 | 
			
		||||
                                    ChannelStock it = record[i];
 | 
			
		||||
                                    // 更新数据 库存信息
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        Id = it.Id,
 | 
			
		||||
                                    }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                    // 获取更新完库存后的药品库存
 | 
			
		||||
                                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                        .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                        .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                        .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                        .ToList();
 | 
			
		||||
 | 
			
		||||
                                    // 保存数据 出库记录
 | 
			
		||||
                                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        MachineId = it.MachineId,
 | 
			
		||||
                                        DrawerNo = it.DrawerNo,
 | 
			
		||||
                                        ColNo = it.ColNo,
 | 
			
		||||
                                        DrugId = it.DrugId,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        OperationTime = DateTime.Now,
 | 
			
		||||
                                        Quantity = orderTakeQuantity,
 | 
			
		||||
                                        Type = 2,
 | 
			
		||||
                                        InvoiceId = InvoiceId
 | 
			
		||||
                                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                //更新处方状态
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DmStatus = 1,
 | 
			
		||||
                                    OrderNo = OrderInfo[j].OrderNo
 | 
			
		||||
                                }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
                                return true;
 | 
			
		||||
                            });
 | 
			
		||||
                            if (f.Data)
 | 
			
		||||
                            {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                //});
 | 
			
		||||
                                // 更新屏显库存
 | 
			
		||||
                                List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                                if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    singleChannels.ForEach(it =>
 | 
			
		||||
                                    {
 | 
			
		||||
                                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                                    });
 | 
			
		||||
                                }
 | 
			
		||||
                                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = "抽屉取药完成,库存已更新",
 | 
			
		||||
                                    Type = MsgType.SUCCESS,
 | 
			
		||||
                                };
 | 
			
		||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            }
 | 
			
		||||
                            if (!f.IsSuccess)
 | 
			
		||||
                            {
 | 
			
		||||
                                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                                {
 | 
			
		||||
                                    Message = "抽屉取药完成,库存更新失败!",
 | 
			
		||||
                                    Type = MsgType.ERROR,
 | 
			
		||||
                                };
 | 
			
		||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,380 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class MultiOrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        public static MultiOrderTakeDrugWindowViewModel vm;
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public MultiOrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
            vm = this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //public static ObservableCollection<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        //{
 | 
			
		||||
        //    new OrderTakeSelect
 | 
			
		||||
        //    {
 | 
			
		||||
        //        Code = "OrderNo",
 | 
			
		||||
        //        Name = "处方号"
 | 
			
		||||
        //    },
 | 
			
		||||
        //    new OrderTakeSelect
 | 
			
		||||
        //    {
 | 
			
		||||
        //        Code = "PatientId",
 | 
			
		||||
        //        Name = "患者编号"
 | 
			
		||||
        //    }
 | 
			
		||||
        //};
 | 
			
		||||
 | 
			
		||||
        //private ObservableCollection<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        //public ObservableCollection<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return _orderTakeSelects; }
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        ///// <summary>
 | 
			
		||||
        ///// 查询条件 查询字段
 | 
			
		||||
        ///// </summary>
 | 
			
		||||
        //public OrderTakeSelect SelectedItem
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return _selectedItem; }
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _selectedItem, value);
 | 
			
		||||
        //        RequestData();
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        //private OrderInfo? _selectedOrder;
 | 
			
		||||
 | 
			
		||||
        //public OrderInfo? SelectedOrder
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return _selectedOrder; }
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _selectedOrder, value);
 | 
			
		||||
 | 
			
		||||
        //        //OpenOrderDialog();
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        ///// <summary>
 | 
			
		||||
        ///// 查询条件 查询字段值
 | 
			
		||||
        ///// </summary>
 | 
			
		||||
        //public string? SearchValue
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return _searchValue; }
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //        SetProperty(ref _searchValue, value);
 | 
			
		||||
        //        RequestData();
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///全选
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool _allChecked = false;
 | 
			
		||||
        public bool IsAllChecked
 | 
			
		||||
        {
 | 
			
		||||
            get { return _allChecked; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _allChecked, value);
 | 
			
		||||
                if (!IsItemCheck)
 | 
			
		||||
                {
 | 
			
		||||
                    RequestData();
 | 
			
		||||
                    //根据全选或反选设置其后的选中状态
 | 
			
		||||
                    OrderInfos.ToList().ForEach(oi => oi.ItemIsChecked = _allChecked);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    IsItemCheck = false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool _isItemCheck = false;
 | 
			
		||||
        public bool IsItemCheck
 | 
			
		||||
        {
 | 
			
		||||
            get => _isItemCheck;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _isItemCheck, value);
 | 
			
		||||
                if (OrderInfos.ToList().Where(od => od.ItemIsChecked == false).Count() <= 0)
 | 
			
		||||
                {
 | 
			
		||||
                    IsAllChecked = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //private bool _itemIsChecked = false;
 | 
			
		||||
        //public bool ItemIsChecked
 | 
			
		||||
        //{
 | 
			
		||||
        //    get => _itemIsChecked;
 | 
			
		||||
        //    set
 | 
			
		||||
        //    {
 | 
			
		||||
        //         SetProperty(ref _itemIsChecked, value);
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
        //多处方取药
 | 
			
		||||
        public DelegateCommand BtnTakeOrder { get => new DelegateCommand(TakeByMultiOrder); }
 | 
			
		||||
        private void TakeByMultiOrder()
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfos = new ObservableCollection<OrderInfo>(OrderInfos.Where(o => o.ItemIsChecked == true).ToList());
 | 
			
		||||
            if (OrderInfos != null && OrderInfos.Count() > 0)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                //await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("orderInfo", OrderInfos);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "MultiOrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                //请勾选要取药的处方信息
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请勾选要取药的处方信息",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
            IsAllChecked = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ObservableCollection<OrderInfo> _orderInfos = new();
 | 
			
		||||
 | 
			
		||||
        public ObservableCollection<OrderInfo> OrderInfos
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderInfos; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderInfos, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //部门
 | 
			
		||||
        private ObservableCollection<OrderDepartment> _orderDepartments = new ObservableCollection<OrderDepartment>();
 | 
			
		||||
        public ObservableCollection<OrderDepartment> OrderDepartments
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderDepartments;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderDepartments, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderDepartment _orderDepartment = new OrderDepartment();
 | 
			
		||||
        public OrderDepartment OrderDepartment
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderDepartment;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderDepartment, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            //SelectedOrder = null;
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfos.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            //string SearchValue = null;
 | 
			
		||||
            //if (SearchValue != null)
 | 
			
		||||
            //{
 | 
			
		||||
            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
			
		||||
            //}
 | 
			
		||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                .WhereIF(!(OrderDepartment.DeptName.Equals("全部")), oi => oi.DeptName == OrderDepartment.DeptName)
 | 
			
		||||
                //.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(oi => oi.DmStatus == 0)
 | 
			
		||||
                .Where(oi => oi.HisDispFlag == 0)
 | 
			
		||||
                .Where(oi => oi.CancelFlag == 0)
 | 
			
		||||
                .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
                .Select(oi => oi)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            //.ToList();
 | 
			
		||||
            OrderInfos = new ObservableCollection<OrderInfo>(queryData);
 | 
			
		||||
 | 
			
		||||
            if (OrderDepartments.Where(d => d.DeptName == "全部").ToList().Count <= 0)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDepartment deptDefault = new OrderDepartment();
 | 
			
		||||
                deptDefault.DeptName = "全部";
 | 
			
		||||
                OrderDepartments.Add(deptDefault);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            var orderDeparts = queryData.GroupBy(o=>o.DeptName).ToList();
 | 
			
		||||
            for (int i = 0; i < orderDeparts.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDepartment dept = new OrderDepartment();
 | 
			
		||||
                if (orderDeparts[i].Key != null && orderDeparts[i].Key != string.Empty&& OrderDepartments.Where(d => d.DeptName == orderDeparts[i].Key).ToList().Count<=0)
 | 
			
		||||
                {
 | 
			
		||||
                    dept.DeptName = orderDeparts[i].Key;
 | 
			
		||||
                    OrderDepartments.Add(dept);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            //if (msg.EventType == EventType.CODESCAN)
 | 
			
		||||
            //{
 | 
			
		||||
            //    SearchValue = msg.Code;
 | 
			
		||||
            //}
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,204 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Threading;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OpenBoxWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _drawerNo = -1;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int status = 0;
 | 
			
		||||
        public int Status { get => status; set => SetProperty(ref status, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //开名下药箱按钮的显示状态
 | 
			
		||||
        private bool _selfEnable = true;
 | 
			
		||||
        public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); }
 | 
			
		||||
 | 
			
		||||
        //开公共药箱按钮的显示状态
 | 
			
		||||
        private bool _publicEnable = true;
 | 
			
		||||
        public bool PublicEnable { get => _publicEnable; set => SetProperty(ref _publicEnable, value); }
 | 
			
		||||
 | 
			
		||||
        //公共药箱状态
 | 
			
		||||
        private int _publicStatus = 0;
 | 
			
		||||
        public int PublicStatus { get => _publicStatus;set=>SetProperty(ref _publicStatus, value); }
 | 
			
		||||
        //名下药箱状态
 | 
			
		||||
        private int _selfStatus = 0;
 | 
			
		||||
        public int SelfStatus { get => _publicStatus;set=>SetProperty(ref _publicStatus,value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //抽屉号列表
 | 
			
		||||
        public static List<int> iList = new List<int>();
 | 
			
		||||
        //第几个抽屉号
 | 
			
		||||
        public static int iNumber = 1;
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public OpenBoxWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand<string> OpenBoxDelegate
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                switch (this.DrawerNo)
 | 
			
		||||
                {
 | 
			
		||||
                    case 0:
 | 
			
		||||
                        PublicEnable = false;
 | 
			
		||||
                        PublicStatus=1; 
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 1:
 | 
			
		||||
                        SelfEnable = false;
 | 
			
		||||
                        SelfStatus = 1;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
                SearchBox();
 | 
			
		||||
            }
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        private void SearchBox()
 | 
			
		||||
        {
 | 
			
		||||
            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerNo)
 | 
			
		||||
                .WhereIF(this.DrawerNo==0,cl=> cl.BelongUser == HomeWindowViewModel.Operator.UserName)
 | 
			
		||||
                .Select(cl => cl.DrawerNo).ToList();
 | 
			
		||||
            if (iList.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.SpeakAsync("正在打开药箱");
 | 
			
		||||
                _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                iNumber++;
 | 
			
		||||
                _portUtil.OpenBox();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            switch (msg.EventType)
 | 
			
		||||
            {
 | 
			
		||||
                // 药箱打开
 | 
			
		||||
                case EventType.DRAWEROPEN:
 | 
			
		||||
                    //记录开药箱日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (iNumber < iList.Count)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.DrawerNo = iList[iNumber];
 | 
			
		||||
                        iNumber++;
 | 
			
		||||
                        if(PublicStatus==1)
 | 
			
		||||
                        {
 | 
			
		||||
                            PublicStatus = 2;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SelfStatus = 2;
 | 
			
		||||
                        }
 | 
			
		||||
                        _portUtil.OpenBox();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        iNumber = 0;
 | 
			
		||||
                        _portUtil.GetBoxStatus();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                // 药箱关闭
 | 
			
		||||
                case EventType.DRAWERCLOSE:
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱关闭",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (PublicStatus == 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        PublicStatus = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        SelfStatus = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    PublicEnable = true;
 | 
			
		||||
                    SelfEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
                // 打开失败
 | 
			
		||||
                case EventType.OPENERROR:
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = msg.Message,
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                    PublicEnable = true;
 | 
			
		||||
                    SelfEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    PublicStatus = 0;
 | 
			
		||||
                    SelfStatus = 0;
 | 
			
		||||
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开失败",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,512 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Microsoft.Xaml.Behaviors;
 | 
			
		||||
using NetTaste;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderReturnDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderReturnDialogViewModel));
 | 
			
		||||
        public string Title => "处方退药";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public OrderReturnDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "ReturnDrug1Window")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                            //channelStocks.ForEach(it => it.ReturnQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _orderInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? OrderInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderInfo;
 | 
			
		||||
            set => SetProperty(ref _orderInfo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
			
		||||
            OrderInfo = o;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
            List<string> msg = new List<string>();
 | 
			
		||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDetail orderDetail = orderDetails[i];
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
 | 
			
		||||
                // 有库位
 | 
			
		||||
                if (HasQChannels.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock singleChannel = HasQChannels.Find(it => (it.BoardType == 2 && (25 - it.Quantity >= orderDetail.Quantity)));
 | 
			
		||||
                    ChannelStock otherChannel = HasQChannels.Find(it => it.BoardType != 2);
 | 
			
		||||
                    if ((singleChannel ?? otherChannel) != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        //(singleChannel ?? otherChannel).TakeQuantity = orderDetail.Quantity;
 | 
			
		||||
                        (singleChannel ?? otherChannel).ReturnQuantity = orderDetail.Quantity;
 | 
			
		||||
                        channelStocks.Add(singleChannel ?? otherChannel);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】现有库位不足以放置药品");
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】无库位");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (msg.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                channelStocks.Sort((a, b) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        return a.ColNo - b.ColNo;
 | 
			
		||||
                    }
 | 
			
		||||
                    return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                });
 | 
			
		||||
                ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                    enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
            //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = singleChannels.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = singleChannels.Sum(cs => cs.ReturnQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开{DrawerNo}号抽屉,请加药{strNames},数量共计{sumQuantity}个");
 | 
			
		||||
 | 
			
		||||
            // 发送还药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity + it.TakeQuantity);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "ReturnDrug1Window";
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    //List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
			
		||||
                    //if (record.Count > 0)
 | 
			
		||||
                    //{
 | 
			
		||||
                    string InvoiceId = OrderInfo.OrderNo;
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                        {
 | 
			
		||||
                            DmStatus = 0,
 | 
			
		||||
                            OrderNo = OrderInfo.OrderNo
 | 
			
		||||
                        }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
                        for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStock it = record[i];
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                //Quantity = it.Quantity + it.TakeQuantity,
 | 
			
		||||
                                Quantity = it.Quantity + it.ReturnQuantity,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                            // 获取更新完库存后的药品库存
 | 
			
		||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
 | 
			
		||||
                            // 保存数据 还药记录
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = it.MachineId,
 | 
			
		||||
                                DrawerNo = it.DrawerNo,
 | 
			
		||||
                                ColNo = it.ColNo,
 | 
			
		||||
                                DrugId = it.DrugId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                //Quantity = it.TakeQuantity,
 | 
			
		||||
                                Quantity = it.ReturnQuantity,
 | 
			
		||||
                                Type = 31,
 | 
			
		||||
                                InvoiceId = InvoiceId
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            //保存账册
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type = 1,
 | 
			
		||||
                                Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                InvoiceNo = InvoiceId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                AddQuantity = it.ReturnQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            //修改凌晨生成的日结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 3)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.ReturnQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 3,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.ReturnQuantity,
 | 
			
		||||
                                    TotalStock = it.ReturnQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "日结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iDayResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            //修改凌晨生成的总结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.ReturnQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 4,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.ReturnQuantity,
 | 
			
		||||
                                    TotalStock = it.ReturnQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "总结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iTotalResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            singleChannels.ForEach(it =>
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "处方退药完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                    //}
 | 
			
		||||
                    //else
 | 
			
		||||
                    //{
 | 
			
		||||
                    //    _isFinishClick = false;
 | 
			
		||||
                    //    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    //    {
 | 
			
		||||
                    //        Message = "没有填写取药数量",
 | 
			
		||||
                    //        Type = MsgType.ERROR
 | 
			
		||||
                    //    };
 | 
			
		||||
                    //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    //}
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,636 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderTakeAllDrugDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
        public string Title => "处方取药";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public OrderTakeAllDrugDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _orderInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? OrderInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderInfo;
 | 
			
		||||
            set => SetProperty(ref _orderInfo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<OrderInfo> orderInfos { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        string orderDate;
 | 
			
		||||
        OrderTakeSelect selectedItem;
 | 
			
		||||
        string? searchValue;
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            orderDate = parameters.GetValue<string>("OrderDate");
 | 
			
		||||
            selectedItem = parameters.GetValue<OrderTakeSelect>("SelectedItem");
 | 
			
		||||
            searchValue = parameters.GetValue<string>("SearchValue");
 | 
			
		||||
            //OrderInfo = o;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
                      .InnerJoin<OrderInfo>((od, oi) => oi.DmStatus == 0 && oi.HisDispFlag == 0 && oi.CancelFlag == 0 && od.OrderNo == oi.OrderNo)
 | 
			
		||||
                      .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, oi, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                      .WhereIF(orderDate != null, (od, oi) => oi.OrderDate.ToString("yyyy-MM-dd") == orderDate)
 | 
			
		||||
                      .WhereIF(!String.IsNullOrEmpty(searchValue) && selectedItem.Code.Equals("OrderNo"), (od, oi) => oi.OrderNo == searchValue)
 | 
			
		||||
                      .WhereIF(!String.IsNullOrEmpty(searchValue) && selectedItem.Code.Equals("PatientId"), (od, oi) => oi.PatientId == searchValue)
 | 
			
		||||
                      .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), (od, oi) => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                      .Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
                      .ToList();
 | 
			
		||||
                if (orderDetails == null || orderDetails.Count <= 0)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "没有处方数据",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                IEnumerable<IGrouping<string, OrderDetail>> groupOrderDetails = orderDetails.GroupBy(it => it.DrugId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
                List<string> msg = new List<string>();
 | 
			
		||||
 | 
			
		||||
                foreach (var orderGroup in groupOrderDetails)
 | 
			
		||||
                {
 | 
			
		||||
                    int quantity = orderGroup.Sum(it => it.Quantity);
 | 
			
		||||
                    foreach (var orderDetail in orderGroup)
 | 
			
		||||
                    {
 | 
			
		||||
                        List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                         .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                         .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                         .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                         .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                         .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
			
		||||
                         .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
			
		||||
                         .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
			
		||||
                         .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                         .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                         .ToList();
 | 
			
		||||
                        int total = HasQChannels.Sum(it => it.Quantity);
 | 
			
		||||
                        int TakeQ = quantity;
 | 
			
		||||
                        // 说明数量足够
 | 
			
		||||
                        if (total >= TakeQ)
 | 
			
		||||
                        {
 | 
			
		||||
                            for (int j = 0; TakeQ > 0; j++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock stock = HasQChannels[j];
 | 
			
		||||
                                if (TakeQ > stock.Quantity)
 | 
			
		||||
                                {
 | 
			
		||||
                                    stock.TakeQuantity = stock.Quantity;
 | 
			
		||||
                                    channelStocks.Add(stock);
 | 
			
		||||
                                    TakeQ -= stock.Quantity;
 | 
			
		||||
                                    orderDetail.DrawerNo += stock.DrawerNo + ",";
 | 
			
		||||
                                    orderDetail.ColNo += stock.ColNo + ",";
 | 
			
		||||
                                    orderDetail.SetManuNo += stock.ManuNo + ",";
 | 
			
		||||
                                    orderDetail.SetEffDate += stock.EffDate + ",";
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    stock.TakeQuantity = TakeQ;
 | 
			
		||||
                                    channelStocks.Add(stock);
 | 
			
		||||
                                    TakeQ = 0;
 | 
			
		||||
                                    orderDetail.DrawerNo += stock.DrawerNo + ",";
 | 
			
		||||
                                    orderDetail.ColNo += stock.ColNo + ",";
 | 
			
		||||
                                    orderDetail.SetManuNo += stock.ManuNo + ",";
 | 
			
		||||
                                    orderDetail.SetEffDate += stock.EffDate + ",";
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (msg.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                    //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    channelStocks.Sort((a, b) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            return a.ColNo - b.ColNo;
 | 
			
		||||
                        }
 | 
			
		||||
                        return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                    });
 | 
			
		||||
                    ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Info($"处方取药异常:{ex.Message}");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                    enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name + ";";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"打开抽屉异常{ex.Message}",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
 | 
			
		||||
                    if (orderDetails == null || orderDetails.Count <= 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有处方数据",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    IEnumerable<IGrouping<string, OrderDetail>> enumerableOrderDetails = orderDetails.GroupBy(it => it.OrderNo);
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < ChannelStocks.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStock it = ChannelStocks[i];
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        foreach (var orderGroup in enumerableOrderDetails)
 | 
			
		||||
                        {
 | 
			
		||||
                            int iQuantity = 0;
 | 
			
		||||
                            foreach (var orderDetail in orderGroup)
 | 
			
		||||
                            {
 | 
			
		||||
                                OrderInfo orderInfo = SqlSugarHelper.Db.Queryable<OrderInfo>().Where(oi => oi.OrderNo == orderDetail.OrderNo).First();
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DmStatus = 1,
 | 
			
		||||
                                    OrderNo = orderDetail.OrderNo
 | 
			
		||||
                                }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
			
		||||
                                {
 | 
			
		||||
                                    OrderNo = orderDetail.OrderNo,
 | 
			
		||||
                                    PatientId = orderDetail.PatientId,
 | 
			
		||||
                                    Pharmacy = orderInfo.Pharmacy,
 | 
			
		||||
                                    State = 1,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
			
		||||
                                });
 | 
			
		||||
                                //查询药品对应库存表的库位及批次、效期信息
 | 
			
		||||
                                List<ChannelStock> stockList= ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId).OrderBy(cs=>cs.EffDate).ToList();
 | 
			
		||||
                                int iOrderDetailQuantity = -1;
 | 
			
		||||
                                string manuNo = string.Empty;
 | 
			
		||||
                                string effDate = string.Empty;
 | 
			
		||||
                                int drawerNo = 0;
 | 
			
		||||
                                int colNo = 0;
 | 
			
		||||
                                if (stockList.Count> 1)
 | 
			
		||||
                                {
 | 
			
		||||
                                    iOrderDetailQuantity = orderDetail.Quantity;
 | 
			
		||||
                                    for (int i = 0; i < stockList.Count; i++)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        if (iOrderDetailQuantity>0&&stockList[i].Quantity- iOrderDetailQuantity > 0)
 | 
			
		||||
                                        {
 | 
			
		||||
                                            stockList[i].Quantity = stockList[i].Quantity - iOrderDetailQuantity;
 | 
			
		||||
                                            break;
 | 
			
		||||
                                        }
 | 
			
		||||
                                        else
 | 
			
		||||
                                        {
 | 
			
		||||
                                            iOrderDetailQuantity = iOrderDetailQuantity - stockList[i].Quantity;
 | 
			
		||||
                                            stockList[i].Quantity = 0;
 | 
			
		||||
                                            if(iOrderDetailQuantity==0)
 | 
			
		||||
                                            {
 | 
			
		||||
                                                manuNo = stockList[i].ManuNo;
 | 
			
		||||
                                                effDate = stockList[i].EffDate;
 | 
			
		||||
                                                drawerNo = stockList[i].DrawerNo;
 | 
			
		||||
                                                colNo= stockList[i].ColNo;
 | 
			
		||||
                                                break;
 | 
			
		||||
                                            }
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                ChannelStock cs = null;
 | 
			
		||||
                                if (iOrderDetailQuantity==0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    cs = ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId && cs.ManuNo == manuNo&&cs.EffDate==effDate&&cs.DrawerNo==drawerNo&&cs.ColNo==colNo).OrderBy(cs => cs.EffDate).FirstOrDefault();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    cs = ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId && cs.Quantity > 0).OrderBy(cs => cs.EffDate).FirstOrDefault();
 | 
			
		||||
                                }
 | 
			
		||||
                               
 | 
			
		||||
                                if (cs != null)
 | 
			
		||||
                                {
 | 
			
		||||
 | 
			
		||||
                                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        DrawerNo = cs.DrawerNo,
 | 
			
		||||
                                        ColNo = cs.ColNo,
 | 
			
		||||
                                        DrugId = cs.DrugId,
 | 
			
		||||
                                        ManuNo = cs.ManuNo,
 | 
			
		||||
                                        EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        OperationTime = DateTime.Now,
 | 
			
		||||
                                        Quantity = orderDetail.Quantity,
 | 
			
		||||
                                        Type = 2,
 | 
			
		||||
                                        InvoiceId = orderDetail.OrderNo
 | 
			
		||||
                                        //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                //保存账册
 | 
			
		||||
                                int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    Department = orderInfo.DeptName,
 | 
			
		||||
                                    OrderNo = orderDetail.OrderNo,
 | 
			
		||||
                                    ManuNo = cs.ManuNo,
 | 
			
		||||
                                    EffDate = cs.EffDate,
 | 
			
		||||
                                    OutQuantity = orderDetail.Quantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    CreateTime = DateTime.Now,
 | 
			
		||||
                                    InvoiceNo = orderDetail.OrderNo
 | 
			
		||||
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                                .Where(ab => ab.Type == 3)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - orderDetail.Quantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
			
		||||
                                        Type = 3,
 | 
			
		||||
                                        ManuNo = cs.ManuNo,
 | 
			
		||||
                                        EffDate = cs.EffDate,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = orderDetail.Quantity,
 | 
			
		||||
                                        TotalStock = orderDetail.Quantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "日结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iDayResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入日结存数据{orderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - orderDetail.Quantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
			
		||||
                                        Type = 4,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = orderDetail.Quantity,
 | 
			
		||||
                                        TotalStock = orderDetail.Quantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "总结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iTotalResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入总结存数据{orderDetail.DrugId}-{orderDetail.Quantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType == 5);
 | 
			
		||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            singleChannels.ForEach(it =>
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "抽屉取药完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "抽屉取药完成,库存更新失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "正在操作,请稍后",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,545 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using Microsoft.Xaml.Behaviors;
 | 
			
		||||
using NetTaste;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using DM_Weight.HIKVISION;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
        public string Title => "处方取药";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _orderInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? OrderInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderInfo;
 | 
			
		||||
            set => SetProperty(ref _orderInfo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
			
		||||
            OrderInfo = o;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
            List<string> msg = new List<string>();
 | 
			
		||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDetail orderDetail = orderDetails[i];
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
			
		||||
                int TakeQ = orderDetail.Quantity;
 | 
			
		||||
                // 说明数量足够
 | 
			
		||||
                if (total >= TakeQ)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock stock = HasQChannels[j];
 | 
			
		||||
                        if (TakeQ > stock.Quantity)
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = stock.Quantity;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ -= stock.Quantity;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = TakeQ;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ = 0;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (msg.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                channelStocks.Sort((a, b) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        return a.ColNo - b.ColNo;
 | 
			
		||||
                    }
 | 
			
		||||
                    return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                });
 | 
			
		||||
                ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                    enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name+";";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"打开抽屉异常{ex.Message}",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
			
		||||
                    if (record.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string InvoiceId = OrderInfo.OrderNo;
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
			
		||||
                            {
 | 
			
		||||
                                DmStatus = 1,
 | 
			
		||||
                                OrderNo = OrderInfo.OrderNo
 | 
			
		||||
                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
			
		||||
                            {
 | 
			
		||||
                                OrderNo = OrderInfo.OrderNo,
 | 
			
		||||
                                PatientId = OrderInfo.PatientId,
 | 
			
		||||
                                Pharmacy = OrderInfo.Pharmacy,
 | 
			
		||||
                                State = 1,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
			
		||||
                            });
 | 
			
		||||
 | 
			
		||||
                            for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock it = record[i];
 | 
			
		||||
                                // 更新数据 库存信息
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                                {
 | 
			
		||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    Id = it.Id,
 | 
			
		||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                                // 获取更新完库存后的药品库存
 | 
			
		||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                    .ToList();
 | 
			
		||||
 | 
			
		||||
                                // 保存数据 出库记录
 | 
			
		||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                                {
 | 
			
		||||
                                    MachineId = it.MachineId,
 | 
			
		||||
                                    DrawerNo = it.DrawerNo,
 | 
			
		||||
                                    ColNo = it.ColNo,
 | 
			
		||||
                                    DrugId = it.DrugId,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    OperationTime = DateTime.Now,
 | 
			
		||||
                                    Quantity = it.TakeQuantity,
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    InvoiceId = InvoiceId
 | 
			
		||||
                                    //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                                //保存账册
 | 
			
		||||
                                int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 2,
 | 
			
		||||
                                    Department = OrderInfo.DeptName,
 | 
			
		||||
                                    OrderNo = OrderInfo.OrderNo,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    OutQuantity = it.TakeQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    CreateTime = DateTime.Now,
 | 
			
		||||
                                    InvoiceNo = OrderInfo.OrderNo
 | 
			
		||||
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 3)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 3,
 | 
			
		||||
                                        ManuNo = it.ManuNo,
 | 
			
		||||
                                        EffDate = it.EffDate,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "日结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if(iDayResult<=0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                //修改凌晨生成的日结存与总结存数据
 | 
			
		||||
                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                        Type = 4,
 | 
			
		||||
                                        YQuantity = 0,
 | 
			
		||||
                                        ManuStock = it.TakeQuantity,
 | 
			
		||||
                                        TotalStock = it.TakeQuantity,
 | 
			
		||||
                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                        InvoiceNo = "总结存"
 | 
			
		||||
                                    }).ExecuteCommand();
 | 
			
		||||
                                    if (iTotalResult <= 0)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
                            // 更新屏显库存
 | 
			
		||||
                            List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5);
 | 
			
		||||
                            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                            {
 | 
			
		||||
                                singleChannels.ForEach(it =>
 | 
			
		||||
                                {
 | 
			
		||||
                                    _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                                });
 | 
			
		||||
                            }
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "抽屉取药完成,库存已更新",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "抽屉取药完成,库存更新失败!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        _isFinishClick = false;
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "没有填写取药数量",
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,295 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderTakeDrugNewWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
        public OrderTakeDrugNewWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "OrderNo",
 | 
			
		||||
                Name = "处方号"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PatientId",
 | 
			
		||||
                Name = "患者编号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _selectedOrder;
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? SelectedOrder
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedOrder; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedOrder, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderInfo> _orderInfos = new();
 | 
			
		||||
 | 
			
		||||
        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeNewDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            SelectedOrder = null;
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        //取药按钮事件
 | 
			
		||||
        public DelegateCommand TakeDrug
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => {
 | 
			
		||||
                if(OrderInfos is null|| OrderInfos.Count<=0)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "没有处方数据",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    return;                
 | 
			
		||||
                }
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("OrderDate", OrderDate);
 | 
			
		||||
                dialogParameters.Add("SelectedItem", SelectedItem);
 | 
			
		||||
                dialogParameters.Add("SearchValue", SearchValue);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeAllDrugDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfos.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            //string SearchValue = null;
 | 
			
		||||
            //if (SearchValue != null)
 | 
			
		||||
            //{
 | 
			
		||||
            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
			
		||||
            //}
 | 
			
		||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(oi => oi.DmStatus == 0)
 | 
			
		||||
                .Where(oi => oi.HisDispFlag == 0)
 | 
			
		||||
                .Where(oi => oi.CancelFlag == 0)
 | 
			
		||||
                .Where(oi => oi.Pharmacy.Equals(ConfigurationManager.AppSettings["storage"] ?? ""))
 | 
			
		||||
                .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
                .Select(oi => oi)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            //.ToList();
 | 
			
		||||
            OrderInfos = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.EventType == EventType.CODESCAN)
 | 
			
		||||
            {
 | 
			
		||||
                SearchValue = msg.Code;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,275 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Drawing.Printing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
        public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "OrderNo",
 | 
			
		||||
                Name = "处方号"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PatientId",
 | 
			
		||||
                Name = "患者编号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _selectedOrder;
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? SelectedOrder
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedOrder; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedOrder, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderInfo> _orderInfos = new();
 | 
			
		||||
 | 
			
		||||
        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            SelectedOrder = null;
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfos.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            //string SearchValue = null;
 | 
			
		||||
            //if (SearchValue != null)
 | 
			
		||||
            //{
 | 
			
		||||
            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
			
		||||
            //}
 | 
			
		||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(oi => oi.DmStatus == 0)
 | 
			
		||||
                .Where(oi => oi.HisDispFlag == 0)
 | 
			
		||||
                .Where(oi => oi.CancelFlag == 0)
 | 
			
		||||
                .Where(oi=>oi.Pharmacy.Equals(ConfigurationManager.AppSettings["storage"] ?? ""))
 | 
			
		||||
                .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
                .Select(oi => oi)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            //.ToList();
 | 
			
		||||
            OrderInfos = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.EventType == EventType.CODESCAN)
 | 
			
		||||
            {
 | 
			
		||||
                SearchValue = msg.Code;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,185 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class OrderTakeNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
        public string Title => "处方取药";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public OrderTakeNewDialogViewModel(IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _orderInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? OrderInfo
 | 
			
		||||
        {
 | 
			
		||||
            get => _orderInfo;
 | 
			
		||||
            set => SetProperty(ref _orderInfo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
			
		||||
            OrderInfo = o;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
			
		||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
			
		||||
            List<string> msg = new List<string>();
 | 
			
		||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                OrderDetail orderDetail = orderDetails[i];
 | 
			
		||||
 | 
			
		||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                    .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
			
		||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
			
		||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
			
		||||
                    .OrderBy(cs => cs.EffDate)
 | 
			
		||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
			
		||||
                int TakeQ = orderDetail.Quantity;
 | 
			
		||||
                // 说明数量足够
 | 
			
		||||
                if (total >= TakeQ)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock stock = HasQChannels[j];
 | 
			
		||||
                        if (TakeQ > stock.Quantity)
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = stock.Quantity;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ -= stock.Quantity;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            stock.TakeQuantity = TakeQ;
 | 
			
		||||
                            channelStocks.Add(stock);
 | 
			
		||||
                            TakeQ = 0;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (msg.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                channelStocks.Sort((a, b) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        return a.ColNo - b.ColNo;
 | 
			
		||||
                    }
 | 
			
		||||
                    return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                });
 | 
			
		||||
                ChannelStocks = channelStocks;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
       
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,36 +0,0 @@
 | 
			
		|||
using Prism.Mvvm;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    [Serializable]
 | 
			
		||||
    public class PremissionViewModel: BindableBase
 | 
			
		||||
    {
 | 
			
		||||
        private int _id;
 | 
			
		||||
        private string _premissionName;
 | 
			
		||||
        private string _premissionPath;
 | 
			
		||||
        private string _premissionImage;
 | 
			
		||||
        private List<PremissionViewModel> _children = new List<PremissionViewModel>();
 | 
			
		||||
 | 
			
		||||
        public int Id { get => _id; set => SetProperty(ref _id, value); }
 | 
			
		||||
        public string PremissionName { get => _premissionName; set => SetProperty(ref _premissionName, value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 菜单路径 
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        public string PremissionPath { get => _premissionPath; set => SetProperty(ref _premissionPath, value); }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 图片source 
 | 
			
		||||
        ///</summary>
 | 
			
		||||
        public string PremissionImage { get => _premissionImage; set => SetProperty(ref _premissionImage, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public List<PremissionViewModel> Children { get => _children; set => SetProperty(ref _children, value); }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,422 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnDrugDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(ReturnDrugDialogViewModel));
 | 
			
		||||
        public string Title => "归还药品(记录)";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private string WindowName = "ReturnDrug1Window";
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        private MachineRecord _machineRecord;
 | 
			
		||||
        public MachineRecord MachineRecord
 | 
			
		||||
        {
 | 
			
		||||
            get { return _machineRecord; }
 | 
			
		||||
            set { SetProperty(ref _machineRecord, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public ReturnDrugDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        try
 | 
			
		||||
                        {
 | 
			
		||||
                            if (Status == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                ReturnQuantity = msg.Quantitys[ChannelStock.ColNo - 1];
 | 
			
		||||
 | 
			
		||||
                                logger.Info($"抽屉【{ChannelStock.DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        catch (Exception e)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Error(e);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock ChannelStock
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStock;
 | 
			
		||||
            set => SetProperty(ref _channelStock, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _returnQuantity;
 | 
			
		||||
 | 
			
		||||
        public int ReturnQuantity
 | 
			
		||||
        {
 | 
			
		||||
            get => _returnQuantity;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value < 0)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new ArgumentException("还药数量不能是负数");
 | 
			
		||||
                }
 | 
			
		||||
                if (value > MachineRecord.CanReturnQuantity)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new ArgumentException("还药数量超出");
 | 
			
		||||
                }
 | 
			
		||||
                SetProperty(ref _returnQuantity, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
 | 
			
		||||
            MachineRecord _record = parameters.GetValue<MachineRecord>("record");
 | 
			
		||||
            MachineRecord = _record;
 | 
			
		||||
            ReturnQuantity = MachineRecord.CanReturnQuantity;
 | 
			
		||||
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .Where(cs => cs.DrugId == MachineRecord.DrugId)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .WhereIF(MachineRecord.ManuNo != null, cs => cs.ManuNo == MachineRecord.ManuNo)
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            ChannelStocks = queryData;
 | 
			
		||||
            if (ChannelStocks.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                ChannelStock = ChannelStocks[0];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (ChannelStock != null)
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
 | 
			
		||||
                    //_portUtil.SpeakAsync("正在打开" + ChannelStock.DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    _portUtil.SpeakAsync($"正在打开 {ChannelStock.DrawerNo} 号抽屉,请加药 {MachineRecord.DrugInfo.DrugName} ,数量共计 {ReturnQuantity}个");
 | 
			
		||||
 | 
			
		||||
                    _portUtil.WindowName = WindowName;
 | 
			
		||||
                    _portUtil.BoardType = ChannelStock.BoardType;
 | 
			
		||||
                    _portUtil.ColNos = new int[] { ChannelStock.ColNo };
 | 
			
		||||
                    _portUtil.DrawerNo = ChannelStock.DrawerNo;
 | 
			
		||||
                    _portUtil.Start();
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请选择退还药品要放入的库位!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }, () => Status == 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                IsFinishClick = true;
 | 
			
		||||
                string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    // 更新数据 库存信息
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                    {
 | 
			
		||||
                        Quantity = ChannelStock.Quantity + ReturnQuantity,
 | 
			
		||||
                        Id = ChannelStock.Id,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    // 获取更新完库存后的药品库存
 | 
			
		||||
                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                        .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
 | 
			
		||||
                        .Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
 | 
			
		||||
                        .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                        .ToList();
 | 
			
		||||
                    // 更新数据 取药记录 设置还药数量、状态
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        ReturnQuantity1 = MachineRecord.ReturnQuantity1 + ReturnQuantity,
 | 
			
		||||
                        Id = MachineRecord.Id,
 | 
			
		||||
                        Status = (MachineRecord.CanReturnQuantity - ReturnQuantity) == 0 ? 2 : 1,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    // 保存数据 还药记录
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = ChannelStock.MachineId,
 | 
			
		||||
                        DrawerNo = ChannelStock.DrawerNo,
 | 
			
		||||
                        ColNo = ChannelStock.ColNo,
 | 
			
		||||
                        DrugId = ChannelStock.DrugId,
 | 
			
		||||
                        ManuNo = ChannelStock.ManuNo,
 | 
			
		||||
                        EffDate = !String.IsNullOrEmpty(ChannelStock.EffDate) ? DateTime.ParseExact(ChannelStock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Quantity = ReturnQuantity,
 | 
			
		||||
                        Type = 31,
 | 
			
		||||
                        InvoiceId = InvoiceId,
 | 
			
		||||
                        GetId = MachineRecord.Id
 | 
			
		||||
                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    //保存账册
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugId = Convert.ToInt32(ChannelStock.DrugId),
 | 
			
		||||
                        Type = 1,
 | 
			
		||||
                        Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                        InvoiceNo = InvoiceId,
 | 
			
		||||
                        ManuNo = ChannelStock.ManuNo,
 | 
			
		||||
                        EffDate = ChannelStock.EffDate,
 | 
			
		||||
                        AddQuantity = ReturnQuantity,
 | 
			
		||||
                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                        CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    //修改凌晨生成的日结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 3)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.ManuNo == ChannelStock.ManuNo)
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Day != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + ChannelStock.ReturnQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                        int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(ChannelStock.DrugId),
 | 
			
		||||
                            Type = 3,
 | 
			
		||||
                            ManuNo = ChannelStock.ManuNo,
 | 
			
		||||
                            EffDate = ChannelStock.EffDate,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = ChannelStock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = ChannelStock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "日结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iDayResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入日结存数据{ChannelStock.DrugId}-{ChannelStock.ManuNo}-{ChannelStock.EffDate}-{ChannelStock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //修改凌晨生成的总结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 4)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Total != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + ChannelStock.ReturnQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                        int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(ChannelStock.DrugId),
 | 
			
		||||
                            Type = 4,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = ChannelStock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = ChannelStock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "总结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iTotalResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入总结存数据{ChannelStock.DrugId}-{ChannelStock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    return true;
 | 
			
		||||
                });
 | 
			
		||||
                if (f.Data)
 | 
			
		||||
                {
 | 
			
		||||
                    // 更新屏显库存
 | 
			
		||||
                    if (ChannelStock.BoardType == 5)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "操作完成,库存已更新",
 | 
			
		||||
                        Type = MsgType.SUCCESS,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                if (!f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "库存更新失败!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
                Status = 0;
 | 
			
		||||
                IsFinishClick = false;
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
 | 
			
		||||
            }, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                IsFinishClick = false;
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            }, () => Status == 0).ObservesProperty(() => Status);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,254 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnDrugWindow2ViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //刷新
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
        public ReturnDrugWindow2ViewModel(IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "OrderNo",
 | 
			
		||||
                Name = "处方号"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PatientId",
 | 
			
		||||
                Name = "患者编号"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderTakeSelects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _orderTakeSelects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderInfo? _selectedOrder;
 | 
			
		||||
 | 
			
		||||
        public OrderInfo? SelectedOrder
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedOrder; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedOrder, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OrderDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _orderDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _orderDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<OrderInfo> _orderInfos = new();
 | 
			
		||||
 | 
			
		||||
        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            //if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
			
		||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1 && SelectedOrder.HisDispFlag == 1)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderReturnDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                SelectedOrder = null;
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            OrderInfos.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
			
		||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
			
		||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
			
		||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(oi => oi.DmStatus == 1)
 | 
			
		||||
                .Where(oi => oi.HisDispFlag == 1)
 | 
			
		||||
                .Where(oi => oi.CancelFlag == 1)
 | 
			
		||||
                .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
                .Select(oi => oi)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            //.ToList();
 | 
			
		||||
            OrderInfos = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,216 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
        public ReturnDrugWindowViewModel(IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
        }
 | 
			
		||||
        //刷新
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private MachineRecord? _selectedRecord;
 | 
			
		||||
 | 
			
		||||
        public MachineRecord? SelectedRecord
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedRecord; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedRecord, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _queryDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  处方日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string QueryDate
 | 
			
		||||
        {
 | 
			
		||||
            get { return _queryDate; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _queryDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _queryDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord> _machineRecords = new();
 | 
			
		||||
 | 
			
		||||
        public List<MachineRecord> MachineRecords { get { return _machineRecords; } set { SetProperty(ref _machineRecords, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedRecord != null)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("record", SelectedRecord);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnDrugDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                SelectedRecord = null;
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Where(mr => mr.Type == 2)
 | 
			
		||||
                .Where(mr => mr.Status < 2)
 | 
			
		||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (mr) => mr.DrugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (mr) => mr.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                .OrderBy(mr => mr.OperationTime)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            MachineRecords = queryData;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,310 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnEmptyDestoryWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private List<ChannelStock>? _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? Channels
 | 
			
		||||
        {
 | 
			
		||||
            get { return _channelStocks; }
 | 
			
		||||
            set { SetProperty(ref _channelStocks, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock Channel
 | 
			
		||||
        {
 | 
			
		||||
            get { return _channelStock; }
 | 
			
		||||
            set { SetProperty(ref _channelStock, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        public DateTime? StartDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _startDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
 | 
			
		||||
 | 
			
		||||
        public DateTime? EndDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _endDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
			
		||||
                    SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _endDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public ReturnEmptyDestoryWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = dialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (Channel != null && Channel.DrugId == null)
 | 
			
		||||
                {
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("DrawerNo", Channel.DrawerNo);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else if (Channel != null && Channel.CanReturnQuantity > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Channels = Channels.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == Channel.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    //dialogParameters.Add("channel", Channel);
 | 
			
		||||
                    //DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> csList = new List<ChannelStock>();
 | 
			
		||||
 | 
			
		||||
        //销毁
 | 
			
		||||
        public DelegateCommand DestoryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Channels != null && Channels.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    csList = Channels.FindAll(it => it.IsSelected && it.Quantity > 0).ToList();
 | 
			
		||||
                    if (csList != null && csList.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                        //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                        //List<string> msg = new List<string>();
 | 
			
		||||
                        //msg.Add("确认");
 | 
			
		||||
                        //msg.Add("确认要销毁吗?");
 | 
			
		||||
                        //dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                        //DialogServiceExtensions.ShowDialogHost(_dialogService, "ConfirmMessageDialog", dialogParameters, DestoryDialogResult, "RootDialog");
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
                            for (int i = 0; i < csList.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock channelStock = csList[i];
 | 
			
		||||
                                channelStock.Quantity = 0;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(channelStock).ExecuteCommand();
 | 
			
		||||
                                MachineRecord machines = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                                 //.InnerJoin<ChannelStock>((mr, cs) => mr.DrugId == cs.DrugId)
 | 
			
		||||
                                 //.Where(mr => mr.DrugId.Contains(csList.Select(it => it.DrugId).ToList()) && mr.Type = 32)
 | 
			
		||||
                                 .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                 .Where(mr => mr.DrugId == channelStock.DrugId)
 | 
			
		||||
                                 .Where(mr => mr.Type == 32)
 | 
			
		||||
                                 .First();
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(machines).ReSetValue(mr =>
 | 
			
		||||
                                {
 | 
			
		||||
                                    mr.IsDestroy = 1;
 | 
			
		||||
                                    mr.TakeUser = HomeWindowViewModel.Operator?.Id.ToString();
 | 
			
		||||
                                    mr.DestoryReviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString();
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                         
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            RequestData();
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "销毁完成",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "销毁失败!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "未勾选要销毁的数据或勾选的数据库存为0",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "没有要操作销毁的数据",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //空瓶销毁(根据还的空瓶)
 | 
			
		||||
        public DelegateCommand DestoryEmptyCommand { get => new DelegateCommand(DestoryEmptyAction); }
 | 
			
		||||
        private void DestoryEmptyAction()
 | 
			
		||||
        {
 | 
			
		||||
            //List<ChannelStock> records = Channels.FindAll(it => it.IsSelected).ToList();
 | 
			
		||||
            //if (records.Count > 0)
 | 
			
		||||
            if (Channel != null && Channel.DrugId != null && Channel.Quantity > 0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("channel", Channel);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "DestoryEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请选择有库存的数据",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //导出回收销毁记录
 | 
			
		||||
        public DelegateCommand DownloadRecordCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => {
 | 
			
		||||
 | 
			
		||||
                GridReportUtil.PrintEmptyDestoryReport(StartDate, EndDate);
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            Channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .LeftJoin<DrugInfo>((cs, di) => cs.DrugId == di.DrugId.ToString())
 | 
			
		||||
                .Where((cs) => cs.DrawerType != 1).Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"])
 | 
			
		||||
                .Where(cs=>cs.Quantity>0)
 | 
			
		||||
                .Select((cs, di) => new ChannelStock
 | 
			
		||||
                {
 | 
			
		||||
                    CanReturnQuantity = SqlFunc.Subqueryable<MachineRecord>().Where(mr => mr.DrugId == cs.DrugId && mr.MachineId == ConfigurationManager.AppSettings["machineId"]).Where(mr => mr.Type == 2).Where(mr => mr.Status != 2).Select(mr => SqlFunc.IsNull(SqlFunc.AggregateSumNoNull(mr.Quantity - mr.ReturnQuantity1 - mr.ReturnQuantity2), 0)),
 | 
			
		||||
                    DrugInfo = new DrugInfo
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugId = di.DrugId,
 | 
			
		||||
                        DrugName = di.DrugName,
 | 
			
		||||
                        DrugSpec = di.DrugSpec,
 | 
			
		||||
                        Manufactory = di.Manufactory,
 | 
			
		||||
                        PackUnit = di.PackUnit,
 | 
			
		||||
                    },
 | 
			
		||||
                    Quantity = cs.Quantity
 | 
			
		||||
                }, true)
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList()
 | 
			
		||||
                ;
 | 
			
		||||
            _ = Channels.Count;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,385 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.Views;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnEmptyDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(ReturnEmptyDialogViewModel));
 | 
			
		||||
        public string Title => "归还空瓶(记录)";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private string WindowName = "ReturnEmpty1Window";
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public ReturnEmptyDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 2;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3;
 | 
			
		||||
                            if(ChannelStock.DrawerType == 3)
 | 
			
		||||
                            {
 | 
			
		||||
                                ReturnQuantity = msg.Quantitys[0];
 | 
			
		||||
                                logger.Info($"抽屉【{ChannelStock.DrawerNo}】回收库位药品数量增加【{msg.Quantitys[0]}】");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            ReturnQuantity = msg.Quantitys[0];
 | 
			
		||||
                            logger.Info($"抽屉【{ChannelStock.DrawerNo}】回收库位药品数量增加【{msg.Quantitys[0]}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _returnQuantity;
 | 
			
		||||
 | 
			
		||||
        public int ReturnQuantity
 | 
			
		||||
        {
 | 
			
		||||
            get => _returnQuantity;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value < 0)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new ArgumentException("还药数量不能是负数");
 | 
			
		||||
                }
 | 
			
		||||
                //if (value > MachineRecord.CanReturnQuantity)
 | 
			
		||||
                //{
 | 
			
		||||
                //    throw new ArgumentException("还药数量超出");
 | 
			
		||||
                //}
 | 
			
		||||
                SetProperty(ref _returnQuantity, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord> _machineRecords = new();
 | 
			
		||||
 | 
			
		||||
        public List<MachineRecord> MachineRecords
 | 
			
		||||
        {
 | 
			
		||||
            get => _machineRecords;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _machineRecords, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private MachineRecord _machineRecord = new();
 | 
			
		||||
 | 
			
		||||
        public MachineRecord _MachineRecord
 | 
			
		||||
        {
 | 
			
		||||
            get => _machineRecord;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _machineRecord, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock ChannelStock
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStock;
 | 
			
		||||
            set => SetProperty(ref _channelStock, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
 | 
			
		||||
            ChannelStock _record = parameters.GetValue<ChannelStock>("channel");
 | 
			
		||||
            ChannelStock = _record;
 | 
			
		||||
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Where(mr => mr.DrugId == ChannelStock.DrugId)
 | 
			
		||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                .Where(mr => mr.Type == 2)
 | 
			
		||||
                .Where(mr => mr.Status != 2)
 | 
			
		||||
                .OrderByDescending(mr => mr.OperationTime)
 | 
			
		||||
                .OrderBy(mr => mr.Id)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            MachineRecords = queryData;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (_MachineRecord != null && _MachineRecord.Quantity > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    MachineRecords = MachineRecords.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == _MachineRecord.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    //dialogParameters.Add("channel", Channel);
 | 
			
		||||
                    //DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (ChannelStock != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (Status == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (ChannelStock.DrawerType == 3 && ChannelStock.BoardType == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 3 ;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            Status = 1;
 | 
			
		||||
                            _portUtil.SpeakAsync("正在打开" + ChannelStock.DrawerNo + "号抽屉");
 | 
			
		||||
                            _portUtil.WindowName = WindowName;
 | 
			
		||||
                            _portUtil.ColNos = new int[] { ChannelStock.ColNo };
 | 
			
		||||
                            _portUtil.DrawerNo = ChannelStock.DrawerNo;
 | 
			
		||||
                            _portUtil.DrawerType = ChannelStock.DrawerType;
 | 
			
		||||
                            _portUtil.BoardType = ChannelStock.BoardType;
 | 
			
		||||
                            _portUtil.Start();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请选择退还药品要放入的库位!",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                IsFinishClick = true;
 | 
			
		||||
                List<MachineRecord> records = MachineRecords.FindAll(it => it.IsSelected).ToList();
 | 
			
		||||
                if (records.Count > 0 && records.Sum(it => it.Quantity - it.ReturnQuantity1)  == ReturnQuantity)
 | 
			
		||||
                {
 | 
			
		||||
                    string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        // 更新数据 库存信息
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                        {
 | 
			
		||||
                            Quantity = ChannelStock.Quantity + ReturnQuantity,
 | 
			
		||||
                            Id = ChannelStock.Id,
 | 
			
		||||
                        }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        // 获取更新完库存后的药品库存
 | 
			
		||||
                        List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                            .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
 | 
			
		||||
                            .Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
 | 
			
		||||
                            .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                            .ToList();
 | 
			
		||||
 | 
			
		||||
                        for (int i = 0; i < records.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            MachineRecord _MachineRecord = records[i];
 | 
			
		||||
                            // 更新数据 取药记录 设置还药数量、状态
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                ReturnQuantity2 = _MachineRecord.Quantity - _MachineRecord.ReturnQuantity1,
 | 
			
		||||
                                Id = _MachineRecord.Id,
 | 
			
		||||
                                Status = 2,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            // 保存数据 还药空瓶记录
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = ChannelStock.MachineId,
 | 
			
		||||
                                DrawerNo = ChannelStock.DrawerNo,
 | 
			
		||||
                                ColNo = ChannelStock.ColNo,
 | 
			
		||||
                                DrugId = ChannelStock.DrugId,
 | 
			
		||||
                                ManuNo = ChannelStock.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(ChannelStock.EffDate) ? DateTime.ParseExact(ChannelStock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = _MachineRecord.Quantity, //ReturnQuantity,
 | 
			
		||||
                                Type = 32,
 | 
			
		||||
                                InvoiceId = InvoiceId,
 | 
			
		||||
                                GetId = _MachineRecord.Id
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        if (ChannelStock.BoardType == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "操作完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "库存更新失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    IsFinishClick = false;
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
                } else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "选择的归还数目与实际数目不符",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    IsFinishClick = false;
 | 
			
		||||
                }
 | 
			
		||||
            }, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                IsFinishClick = false;
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,364 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Reflection.PortableExecutable;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class ReturnEmptyWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock>? _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? Channels
 | 
			
		||||
        {
 | 
			
		||||
            get { return _channelStocks; }
 | 
			
		||||
            set { SetProperty(ref _channelStocks, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ChannelStock _channelStock;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock Channel
 | 
			
		||||
        {
 | 
			
		||||
            get { return _channelStock; }
 | 
			
		||||
            set { SetProperty(ref _channelStock, value); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
 | 
			
		||||
 | 
			
		||||
        public DateTime? StartDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _startDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _startDate, value);
 | 
			
		||||
                }
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
 | 
			
		||||
 | 
			
		||||
        public DateTime? EndDate
 | 
			
		||||
        {
 | 
			
		||||
            get => _endDate;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null)
 | 
			
		||||
                {
 | 
			
		||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
			
		||||
                    SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _endDate, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public ReturnEmptyWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = dialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (Channel != null && Channel.DrugId == null)
 | 
			
		||||
                {
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("DrawerNo", Channel.DrawerNo);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else if (Channel != null && Channel.CanReturnQuantity > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Channels = Channels.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == Channel.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    //dialogParameters.Add("channel", Channel);
 | 
			
		||||
                    //DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //还空瓶
 | 
			
		||||
        public DelegateCommand ReturnEmptyCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //List<ChannelStock> records = Channels.FindAll(it => it.IsSelected).ToList();
 | 
			
		||||
                //if (records.Count > 0)
 | 
			
		||||
                if (Channel != null && Channel.DrugId == null)
 | 
			
		||||
                {
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("DrawerNo", Channel.DrawerNo);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else if(Channel!=null&&Channel.CanReturnQuantity>0)
 | 
			
		||||
                {
 | 
			
		||||
                    
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("channel", Channel);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请选择要还的空瓶",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> csList = new List<ChannelStock>();
 | 
			
		||||
 | 
			
		||||
        //销毁
 | 
			
		||||
        public DelegateCommand DestoryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Channels != null && Channels.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    csList = Channels.FindAll(it => it.IsSelected && it.Quantity > 0).ToList();
 | 
			
		||||
                    if (csList != null && csList.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
                        //DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                        //List<string> msg = new List<string>();
 | 
			
		||||
                        //msg.Add("确认");
 | 
			
		||||
                        //msg.Add("确认要销毁吗?");
 | 
			
		||||
                        //dialogParameters.Add("msgInfo", msg);
 | 
			
		||||
                        //DialogServiceExtensions.ShowDialogHost(_dialogService, "ConfirmMessageDialog", dialogParameters, DestoryDialogResult, "RootDialog");
 | 
			
		||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        {
 | 
			
		||||
                            for (int i = 0; i < csList.Count; i++)
 | 
			
		||||
                            {
 | 
			
		||||
                                ChannelStock channelStock = csList[i];
 | 
			
		||||
                                channelStock.Quantity = 0;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(channelStock).ExecuteCommand();
 | 
			
		||||
                                MachineRecord machines = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                                 //.InnerJoin<ChannelStock>((mr, cs) => mr.DrugId == cs.DrugId)
 | 
			
		||||
                                 //.Where(mr => mr.DrugId.Contains(csList.Select(it => it.DrugId).ToList()) && mr.Type = 32)
 | 
			
		||||
                                 .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                                 .Where(mr => mr.DrugId == channelStock.DrugId)
 | 
			
		||||
                                 .Where(mr => mr.Type == 32)
 | 
			
		||||
                                 .First();
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(machines).ReSetValue(mr =>
 | 
			
		||||
                                {
 | 
			
		||||
                                    mr.IsDestroy = 1;
 | 
			
		||||
                                    mr.TakeUser = HomeWindowViewModel.Operator?.Id.ToString();
 | 
			
		||||
                                    mr.DestoryReviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString();
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            return true;
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        //csList.ForEach(it => it.Quantity = 0);
 | 
			
		||||
                        //var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    SqlSugarHelper.Db.Updateable(csList).ExecuteCommand();
 | 
			
		||||
                        //    string[] str = new string[csList.Count];
 | 
			
		||||
                        //    str = csList.Select(t => t.DrugId).ToArray();
 | 
			
		||||
                        //    List<MachineRecord> machines = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                        //     //.InnerJoin<ChannelStock>((mr, cs) => mr.DrugId == cs.DrugId)
 | 
			
		||||
                        //     //.Where(mr => mr.DrugId.Contains(csList.Select(it => it.DrugId).ToList()) && mr.Type = 32)
 | 
			
		||||
                        //     .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                        //     .In(mr => mr.DrugId, str)
 | 
			
		||||
                        //     .Where(mr => mr.Type == 32)
 | 
			
		||||
                        //     .ToList();
 | 
			
		||||
                        //    SqlSugarHelper.Db.Updateable(machines).ReSetValue(mr =>
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        mr.IsDestroy = 1;
 | 
			
		||||
                        //    }).ExecuteCommand();
 | 
			
		||||
                        //    return true;
 | 
			
		||||
                        //});
 | 
			
		||||
                        if (f.Data)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            RequestData();
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "销毁完成",
 | 
			
		||||
                                Type = MsgType.SUCCESS,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!f.IsSuccess)
 | 
			
		||||
                        {
 | 
			
		||||
                            AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                            {
 | 
			
		||||
                                Message = "销毁失败!",
 | 
			
		||||
                                Type = MsgType.ERROR,
 | 
			
		||||
                            };
 | 
			
		||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "未勾选要销毁的数据或勾选的数据库存为0",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "没有要操作销毁的数据",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //空瓶销毁(根据还的空瓶)
 | 
			
		||||
        public DelegateCommand DestoryEmptyCommand { get => new DelegateCommand(DestoryEmptyAction); }
 | 
			
		||||
        private void DestoryEmptyAction()
 | 
			
		||||
        {
 | 
			
		||||
            //List<ChannelStock> records = Channels.FindAll(it => it.IsSelected).ToList();
 | 
			
		||||
            //if (records.Count > 0)
 | 
			
		||||
            if (Channel != null && Channel.DrugId != null&&Channel.Quantity>0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("channel", Channel);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "DestoryEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                {
 | 
			
		||||
                    Message = "请选择有库存的数据",
 | 
			
		||||
                    Type = MsgType.ERROR,
 | 
			
		||||
                };
 | 
			
		||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //导出回收销毁记录
 | 
			
		||||
        public DelegateCommand DownloadRecordCommand { get => new DelegateCommand(() => {
 | 
			
		||||
 | 
			
		||||
            GridReportUtil.PrintEmptyDestoryReport(StartDate, EndDate);
 | 
			
		||||
 | 
			
		||||
        }); } 
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Query
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            //查询表格数据
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            Channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .LeftJoin<DrugInfo>((cs, di) => cs.DrugId == di.DrugId.ToString())
 | 
			
		||||
                .Where((cs) => cs.DrawerType != 1).Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"])
 | 
			
		||||
                .Select((cs, di) => new ChannelStock
 | 
			
		||||
                {
 | 
			
		||||
                    CanReturnQuantity = SqlFunc.Subqueryable<MachineRecord>().Where(mr => mr.DrugId == cs.DrugId && mr.MachineId == ConfigurationManager.AppSettings["machineId"]).Where(mr => mr.Type == 2).Where(mr => mr.Status != 2).Select(mr => SqlFunc.IsNull(SqlFunc.AggregateSumNoNull(mr.Quantity - mr.ReturnQuantity1 - mr.ReturnQuantity2), 0)),
 | 
			
		||||
                    DrugInfo = new DrugInfo
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugId = di.DrugId,
 | 
			
		||||
                        DrugName = di.DrugName,
 | 
			
		||||
                        DrugSpec = di.DrugSpec,
 | 
			
		||||
                        Manufactory = di.Manufactory,
 | 
			
		||||
                        PackUnit = di.PackUnit,
 | 
			
		||||
                    },
 | 
			
		||||
                    Quantity = cs.Quantity
 | 
			
		||||
                }, true)
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList()
 | 
			
		||||
                ;
 | 
			
		||||
            _ = Channels.Count;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -104,34 +104,37 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                    // 父菜单
 | 
			
		||||
                    PremissionDm p = AllPremissions.ToList().Find(it2 => it2.Id == it.Id);
 | 
			
		||||
                    int index = AllPremissions.ToList().FindIndex(it2 => it2.Id == it.Id);
 | 
			
		||||
 | 
			
		||||
                    if (p != null && p.Children != null && it != null && it.Children != null && p.Children.Count == it.Children.Count)
 | 
			
		||||
                    if (p != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        AllPremissions.RemoveAt(index);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        if (p.Id != 6)
 | 
			
		||||
                        if (p != null && p.Children != null && it != null && it.Children != null && p.Children.Count == it.Children.Count)
 | 
			
		||||
                        {
 | 
			
		||||
                            it.Children.ToList().ForEach(it3 =>
 | 
			
		||||
                            AllPremissions.RemoveAt(index);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            if (p.Id != 6)
 | 
			
		||||
                            {
 | 
			
		||||
                                int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
 | 
			
		||||
                                //if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i)
 | 
			
		||||
                                if (p.Children.Count > 0 && i >= 0 && p.Children[i] != null)
 | 
			
		||||
                                it.Children.ToList().ForEach(it3 =>
 | 
			
		||||
                                {
 | 
			
		||||
                                    AllPremissions.ElementAt(index).Children.RemoveAt(i);
 | 
			
		||||
                                    int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
 | 
			
		||||
                                    //if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i)
 | 
			
		||||
                                    if (p.Children.Count > 0 && i >= 0 && p.Children[i] != null)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        AllPremissions.ElementAt(index).Children.RemoveAt(i);
 | 
			
		||||
                                    }
 | 
			
		||||
                                });
 | 
			
		||||
                                if (p.Children.Count == 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    AllPremissions.RemoveAt(index);
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                            if (p.Children.Count == 0)
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                AllPremissions.RemoveAt(index);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            AllPremissions.RemoveAt(index);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
 | 
			
		||||
| 
						 | 
				
			
			@ -177,18 +180,35 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            //    PremissionName = "处方取药",
 | 
			
		||||
            //    PremissionPath = "OrderTakeDrugNewWindow",
 | 
			
		||||
            //};    
 | 
			
		||||
            PremissionDm quyao1 = new PremissionDm
 | 
			
		||||
 | 
			
		||||
            //开药箱
 | 
			
		||||
            PremissionDm openBox = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 11,
 | 
			
		||||
                PremissionName = "交接柜补药",
 | 
			
		||||
                PremissionPath = "AddToJiaoJieWindow",
 | 
			
		||||
                PremissionName = "开药箱",
 | 
			
		||||
                PremissionPath = "OpenBoxWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm quyao2 = new PremissionDm
 | 
			
		||||
            //核对处方
 | 
			
		||||
            PremissionDm checkOrder = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 12,
 | 
			
		||||
                PremissionName = "调拨出库",
 | 
			
		||||
                PremissionPath = "InvoiceOutWindow",
 | 
			
		||||
                PremissionName = "核对处方",
 | 
			
		||||
                //PremissionPath = "CheckOrderWindow",
 | 
			
		||||
                PremissionPath = "CheckOrderNewWindow",
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            //PremissionDm quyao1 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 11,
 | 
			
		||||
            //    PremissionName = "交接柜补药",
 | 
			
		||||
            //    PremissionPath = "AddToJiaoJieWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm quyao2 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 12,
 | 
			
		||||
            //    PremissionName = "调拨出库",
 | 
			
		||||
            //    PremissionPath = "InvoiceOutWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            PremissionDm quyao3 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 13,
 | 
			
		||||
| 
						 | 
				
			
			@ -219,11 +239,13 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            quyaoChild.Add(quyao1);
 | 
			
		||||
            quyaoChild.Add(quyao2);
 | 
			
		||||
            quyaoChild.Add(quyao3);
 | 
			
		||||
            quyaoChild.Add(quyao4);
 | 
			
		||||
            quyaoChild.Add(quyao5);
 | 
			
		||||
            //quyaoChild.Add(quyao1);
 | 
			
		||||
            //quyaoChild.Add(quyao2);
 | 
			
		||||
            //quyaoChild.Add(quyao3);
 | 
			
		||||
            //quyaoChild.Add(quyao4);
 | 
			
		||||
            //quyaoChild.Add(quyao5);
 | 
			
		||||
            quyaoChild.Add(openBox);
 | 
			
		||||
            quyaoChild.Add(checkOrder);
 | 
			
		||||
            quyao.Children = quyaoChild;
 | 
			
		||||
            defaultAll.Add(quyao);
 | 
			
		||||
            #endregion
 | 
			
		||||
| 
						 | 
				
			
			@ -288,15 +310,15 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                PremissionName = "请领入库",
 | 
			
		||||
                PremissionPath = "ApplyInStockWindow",
 | 
			
		||||
            };
 | 
			
		||||
            jiayaoChild.Add(jiayao1);
 | 
			
		||||
            jiayaoChild.Add(jiayao2);
 | 
			
		||||
            jiayaoChild.Add(jiayao3);
 | 
			
		||||
            jiayaoChild.Add(jiayao6);
 | 
			
		||||
            jiayaoChild.Add(jiayao7);
 | 
			
		||||
            jiayaoChild.Add(jiayao8);
 | 
			
		||||
            jiayaoChild.Add(jiayao4);
 | 
			
		||||
            jiayao.Children = jiayaoChild;
 | 
			
		||||
            defaultAll.Add(jiayao);
 | 
			
		||||
            //jiayaoChild.Add(jiayao1);
 | 
			
		||||
            //jiayaoChild.Add(jiayao2);
 | 
			
		||||
            //jiayaoChild.Add(jiayao3);
 | 
			
		||||
            //jiayaoChild.Add(jiayao6);
 | 
			
		||||
            //jiayaoChild.Add(jiayao7);
 | 
			
		||||
            //jiayaoChild.Add(jiayao8);
 | 
			
		||||
            //jiayaoChild.Add(jiayao4);
 | 
			
		||||
            //jiayao.Children = jiayaoChild;
 | 
			
		||||
            //defaultAll.Add(jiayao);
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 还药菜单
 | 
			
		||||
            PremissionDm huanyao = new PremissionDm
 | 
			
		||||
| 
						 | 
				
			
			@ -342,65 +364,65 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            //    PremissionName = "手术核销",
 | 
			
		||||
            //    PremissionPath = "SurgeryTakeWindow"
 | 
			
		||||
            //};
 | 
			
		||||
            huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
			
		||||
            huanyaoChild.Add(huanyao2);
 | 
			
		||||
            //huanyaoChild.Add(surgery);
 | 
			
		||||
            huanyaoChild.Add(huanyao3);
 | 
			
		||||
            huanyao.Children = huanyaoChild;
 | 
			
		||||
            defaultAll.Add(huanyao);
 | 
			
		||||
            //huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
			
		||||
            //huanyaoChild.Add(huanyao2);
 | 
			
		||||
            ////huanyaoChild.Add(surgery);
 | 
			
		||||
            //huanyaoChild.Add(huanyao3);
 | 
			
		||||
            //huanyao.Children = huanyaoChild;
 | 
			
		||||
            //defaultAll.Add(huanyao);
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 库存管理菜单 
 | 
			
		||||
            PremissionDm kuguan = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 4,
 | 
			
		||||
                PremissionName = "库存管理",
 | 
			
		||||
                PremissionImage = "/Images/TbKuc.png",
 | 
			
		||||
            };
 | 
			
		||||
            ObservableCollection<PremissionDm> kuguanChild = new ObservableCollection<PremissionDm>();
 | 
			
		||||
            PremissionDm kuguan1 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 41,
 | 
			
		||||
                PremissionName = "库存列表",
 | 
			
		||||
                PremissionPath = "StockListWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm kuguan2 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 42,
 | 
			
		||||
                PremissionName = "库存盘点",
 | 
			
		||||
                PremissionPath = "CheckStockWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm kuguan3 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 43,
 | 
			
		||||
                PremissionName = "盘点记录",
 | 
			
		||||
                PremissionPath = "CheckRecordWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm kuguan4 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 44,
 | 
			
		||||
                PremissionName = "药品列表",
 | 
			
		||||
                PremissionPath = "DrugListWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm kuguan5 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 45,
 | 
			
		||||
                PremissionName = "交接班记录",
 | 
			
		||||
                PremissionPath = "ChangeShiftsListWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm kuguan6 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 46,
 | 
			
		||||
                PremissionName = "账册",
 | 
			
		||||
                PremissionPath = "AccountWindow",
 | 
			
		||||
            };
 | 
			
		||||
            kuguanChild.Add(kuguan1);
 | 
			
		||||
            kuguanChild.Add(kuguan2);
 | 
			
		||||
            kuguanChild.Add(kuguan4);
 | 
			
		||||
            kuguanChild.Add(kuguan6);
 | 
			
		||||
            kuguanChild.Add(kuguan3);
 | 
			
		||||
            kuguanChild.Add(kuguan5);
 | 
			
		||||
            kuguan.Children = kuguanChild;
 | 
			
		||||
            defaultAll.Add(kuguan);
 | 
			
		||||
            //PremissionDm kuguan = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 4,
 | 
			
		||||
            //    PremissionName = "库存管理",
 | 
			
		||||
            //    PremissionImage = "/Images/TbKuc.png",
 | 
			
		||||
            //};
 | 
			
		||||
            //ObservableCollection<PremissionDm> kuguanChild = new ObservableCollection<PremissionDm>();
 | 
			
		||||
            //PremissionDm kuguan1 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 41,
 | 
			
		||||
            //    PremissionName = "库存列表",
 | 
			
		||||
            //    PremissionPath = "StockListWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm kuguan2 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 42,
 | 
			
		||||
            //    PremissionName = "库存盘点",
 | 
			
		||||
            //    PremissionPath = "CheckStockWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm kuguan3 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 43,
 | 
			
		||||
            //    PremissionName = "盘点记录",
 | 
			
		||||
            //    PremissionPath = "CheckRecordWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm kuguan4 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 44,
 | 
			
		||||
            //    PremissionName = "药品列表",
 | 
			
		||||
            //    PremissionPath = "DrugListWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm kuguan5 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 45,
 | 
			
		||||
            //    PremissionName = "交接班记录",
 | 
			
		||||
            //    PremissionPath = "ChangeShiftsListWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //PremissionDm kuguan6 = new PremissionDm
 | 
			
		||||
            //{
 | 
			
		||||
            //    Id = 46,
 | 
			
		||||
            //    PremissionName = "账册",
 | 
			
		||||
            //    PremissionPath = "AccountWindow",
 | 
			
		||||
            //};
 | 
			
		||||
            //kuguanChild.Add(kuguan1);
 | 
			
		||||
            //kuguanChild.Add(kuguan2);
 | 
			
		||||
            //kuguanChild.Add(kuguan4);
 | 
			
		||||
            //kuguanChild.Add(kuguan6);
 | 
			
		||||
            //kuguanChild.Add(kuguan3);
 | 
			
		||||
            //kuguanChild.Add(kuguan5);
 | 
			
		||||
            //kuguan.Children = kuguanChild;
 | 
			
		||||
            //defaultAll.Add(kuguan);
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 系统设置菜单
 | 
			
		||||
            PremissionDm sysset = new PremissionDm
 | 
			
		||||
| 
						 | 
				
			
			@ -422,30 +444,43 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                PremissionName = "角色管理",
 | 
			
		||||
                PremissionPath = "RoleManagerWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm sysset3;
 | 
			
		||||
            if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
			
		||||
            PremissionDm sysset3 = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                //有冰箱,需要冰箱设置(两个冰箱)
 | 
			
		||||
                sysset3 = new PremissionDm
 | 
			
		||||
                {
 | 
			
		||||
                    Id = 53,
 | 
			
		||||
                    PremissionName = "设置",
 | 
			
		||||
                    PremissionPath = "SettingMainWindow",
 | 
			
		||||
                };
 | 
			
		||||
                Id = 53,
 | 
			
		||||
                PremissionName = "绑定药品",
 | 
			
		||||
                PremissionPath = "BindBoxPackageWindow",
 | 
			
		||||
            };
 | 
			
		||||
            PremissionDm settingBox = new PremissionDm
 | 
			
		||||
            {
 | 
			
		||||
                Id = 54,
 | 
			
		||||
                PremissionName = "药箱设置",
 | 
			
		||||
                PremissionPath = "SettingBoxWindow",
 | 
			
		||||
            };
 | 
			
		||||
            //PremissionDm sysset3;
 | 
			
		||||
            //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
			
		||||
            //{
 | 
			
		||||
            //    //有冰箱,需要冰箱设置(两个冰箱)
 | 
			
		||||
            //    sysset3 = new PremissionDm
 | 
			
		||||
            //    {
 | 
			
		||||
            //        Id = 53,
 | 
			
		||||
            //        PremissionName = "设置",
 | 
			
		||||
            //        PremissionPath = "SettingMainWindow",
 | 
			
		||||
            //    };
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                sysset3 = new PremissionDm
 | 
			
		||||
                {
 | 
			
		||||
                    Id = 53,
 | 
			
		||||
                    PremissionName = "设置",
 | 
			
		||||
                    PremissionPath = "SettingWindow",
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
            //}
 | 
			
		||||
            //else
 | 
			
		||||
            //{
 | 
			
		||||
            //    sysset3 = new PremissionDm
 | 
			
		||||
            //    {
 | 
			
		||||
            //        Id = 53,
 | 
			
		||||
            //        PremissionName = "设置",
 | 
			
		||||
            //        PremissionPath = "SettingWindow",
 | 
			
		||||
            //    };
 | 
			
		||||
            //}
 | 
			
		||||
            syssetChild.Add(sysset1);
 | 
			
		||||
            syssetChild.Add(sysset2);
 | 
			
		||||
            syssetChild.Add(sysset3);
 | 
			
		||||
            syssetChild.Add(settingBox);
 | 
			
		||||
            sysset.Children = syssetChild;
 | 
			
		||||
            defaultAll.Add(sysset);
 | 
			
		||||
            #endregion
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,445 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.Views;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SelfAddDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddDialogViewModel));
 | 
			
		||||
        public string Title => "自选加药";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private string WindowName = "SelfAddWindow";
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        public SelfAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            List<ChannelStock> channelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
			
		||||
            ChannelStocks = channelStocks;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
            enumerator = enumerable.GetEnumerator();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
            //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计 {sumQuantity}");
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
            _portUtil.WindowName = WindowName;
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
            {
 | 
			
		||||
                // 发送加药数量
 | 
			
		||||
                singleChannels.ForEach(it =>
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < singleChannels.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock it = singleChannels[i];
 | 
			
		||||
                    _portUtil.ClearCount(it.DrawerNo, it.ColNo);
 | 
			
		||||
                    await Task.Delay(50);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
			
		||||
                    string InvoiceId = "SELF_" + CurrentTimeMillis();
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStock it = record[i];
 | 
			
		||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
			
		||||
                            }
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                Quantity = it.Quantity + it.AddQuantity,
 | 
			
		||||
                                PosNo = 1,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
			
		||||
                            // 获取更新完库存后的药品库存
 | 
			
		||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
 | 
			
		||||
                            // 保存数据 出/入库记录
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = it.MachineId,
 | 
			
		||||
                                DrawerNo = it.DrawerNo,
 | 
			
		||||
                                ColNo = it.ColNo,
 | 
			
		||||
                                DrugId = it.DrugId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = it.AddQuantity,
 | 
			
		||||
                                Type = 1,
 | 
			
		||||
                                InvoiceId = InvoiceId
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            //保存账册
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type = 1,
 | 
			
		||||
                                Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                InvoiceNo = InvoiceId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                AddQuantity = it.AddQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            //修改凌晨生成的日结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 3)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 3,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.AddQuantity,
 | 
			
		||||
                                    TotalStock = it.AddQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "日结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iDayResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            //修改凌晨生成的总结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 4,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.AddQuantity,
 | 
			
		||||
                                    TotalStock = it.AddQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "总结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iTotalResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            singleChannels.ForEach(it =>
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "操作完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "库存更新失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,201 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SelfAddWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        public SelfAddWindowViewModel(IDialogService DialogService,IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenSelfDialog
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<ChannelStock> addChannels = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
 | 
			
		||||
                if (addChannels.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    addChannels.Sort((a, b) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            return a.ColNo - b.ColNo;
 | 
			
		||||
                        }
 | 
			
		||||
                        return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                    });
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("ChannelStocks", addChannels);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfAddDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请填写加药数量",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void RequestChannelData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                .Where(cs => cs.DrugId != null)
 | 
			
		||||
                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                .OrderBy(cs => cs.DrugId)
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            ChannelStocks = queryData;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestChannelData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,417 +0,0 @@
 | 
			
		|||
using log4net;
 | 
			
		||||
using log4net.Repository.Hierarchy;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Speech.Synthesis;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using DM_Weight.HIKVISION;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SelfTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(SelfTakeDialogViewModel));
 | 
			
		||||
        public string Title => "自选取药";
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
			
		||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
 | 
			
		||||
        private string WindowName = "SelfTakeWindow";
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public SelfTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName.Equals(WindowName))
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks;
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            List<ChannelStock> channelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
			
		||||
            ChannelStocks = channelStocks;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
            enumerator = enumerable.GetEnumerator();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenDrawer
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    enumerator.MoveNext();
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    OpenOneByOne();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                if (!strNames.Contains(name))
 | 
			
		||||
                {
 | 
			
		||||
                    strNames += name+"  ;  ";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
			
		||||
            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            singleChannels.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
            });
 | 
			
		||||
            _portUtil.WindowName = WindowName;
 | 
			
		||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinish
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (!_isFinishClick)
 | 
			
		||||
                {
 | 
			
		||||
                    _isFinishClick = true;
 | 
			
		||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
			
		||||
                    string InvoiceId = "SELF_" + CurrentTimeMillis();
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int i = 0; i < record.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ChannelStock it = record[i];
 | 
			
		||||
                            // 更新数据 库存信息
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                            {
 | 
			
		||||
                                Quantity = it.Quantity - it.TakeQuantity,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                Id = it.Id,
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
			
		||||
                            // 获取更新完库存后的药品库存
 | 
			
		||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
			
		||||
                                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                                .ToList();
 | 
			
		||||
 | 
			
		||||
                            // 保存数据 出/入库记录
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                MachineId = it.MachineId,
 | 
			
		||||
                                DrawerNo = it.DrawerNo,
 | 
			
		||||
                                ColNo = it.ColNo,
 | 
			
		||||
                                DrugId = it.DrugId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                OperationTime = DateTime.Now,
 | 
			
		||||
                                Quantity = it.TakeQuantity,
 | 
			
		||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                Type = 2,
 | 
			
		||||
                                InvoiceId = InvoiceId
 | 
			
		||||
                                //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            //保存账册
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                            {
 | 
			
		||||
                                DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                Type = 2,
 | 
			
		||||
                                Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                                InvoiceNo = InvoiceId,
 | 
			
		||||
                                ManuNo = it.ManuNo,
 | 
			
		||||
                                EffDate = it.EffDate,
 | 
			
		||||
                                OutQuantity = it.TakeQuantity,
 | 
			
		||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
                            //修改凌晨生成的日结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 3)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 3,
 | 
			
		||||
                                    ManuNo = it.ManuNo,
 | 
			
		||||
                                    EffDate = it.EffDate,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.TakeQuantity,
 | 
			
		||||
                                    TotalStock = it.TakeQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "日结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iDayResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            //修改凌晨生成的总结存数据
 | 
			
		||||
                            AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                                int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                                {
 | 
			
		||||
                                    DrugId = Convert.ToInt32(it.DrugId),
 | 
			
		||||
                                    Type = 4,
 | 
			
		||||
                                    YQuantity = 0,
 | 
			
		||||
                                    ManuStock = it.TakeQuantity,
 | 
			
		||||
                                    TotalStock = it.TakeQuantity,
 | 
			
		||||
                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                                    InvoiceNo = "总结存"
 | 
			
		||||
                                }).ExecuteCommand();
 | 
			
		||||
                                if (iTotalResult <= 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return true;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
			
		||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
			
		||||
                        {
 | 
			
		||||
                            singleChannels.ForEach(it =>
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "操作完成,库存已更新",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "库存更新失败!",
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                    _isFinishClick = false;
 | 
			
		||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Status != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _portUtil.ResetData();
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
                }
 | 
			
		||||
                //DialogParameters parameters = new DialogParameters();
 | 
			
		||||
                //parameters.Add("",);
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,192 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SelfTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        public SelfTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator= eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock> _channelStocks = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand OpenSelfDialog
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<ChannelStock> takeChannels = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
			
		||||
                if (takeChannels.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    takeChannels.Sort((a, b) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            return a.ColNo - b.ColNo;
 | 
			
		||||
                        }
 | 
			
		||||
                        return a.DrawerNo - b.DrawerNo;
 | 
			
		||||
                    });
 | 
			
		||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                    dialogParameters.Add("ChannelStocks", takeChannels);
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请填写取药数量",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            {
 | 
			
		||||
                RequestChannelData();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void RequestChannelData()
 | 
			
		||||
        {
 | 
			
		||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                .Where(cs => cs.DrugId != null)
 | 
			
		||||
                .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                .Where(cs => cs.Quantity > 0)
 | 
			
		||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                .OrderBy(cs => cs.DrugId)
 | 
			
		||||
                .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
                .OrderBy(cs => cs.ColNo)
 | 
			
		||||
                .ToList();
 | 
			
		||||
            ChannelStocks = queryData;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestChannelData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,291 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SettingBoxWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _drawerNo = 0;
 | 
			
		||||
 | 
			
		||||
        public int DrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => _drawerNo;
 | 
			
		||||
            set => SetProperty(ref _drawerNo, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool _isEnable = true;
 | 
			
		||||
        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
        public int Status { get => _status; set { SetProperty(ref _status, value); } }
 | 
			
		||||
 | 
			
		||||
        //选择用户 控件的Visibility值
 | 
			
		||||
        private object _userStatus = Visibility.Collapsed;
 | 
			
		||||
        public object UserStatus
 | 
			
		||||
        {
 | 
			
		||||
            get => _userStatus;
 | 
			
		||||
            set => SetProperty(ref _userStatus, value);
 | 
			
		||||
        }
 | 
			
		||||
        public static List<BoxType> StaticBoxType = new()
 | 
			
		||||
        {
 | 
			
		||||
            new BoxType() { TypeValue = 1, TypeName = "公共药箱" },
 | 
			
		||||
            new BoxType() { TypeValue = 0, TypeName = "归属药师" }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        //药箱类型
 | 
			
		||||
        private List<BoxType> _boxTypes = StaticBoxType;
 | 
			
		||||
        public List<BoxType> BoxTypeList
 | 
			
		||||
        {
 | 
			
		||||
            get => _boxTypes;
 | 
			
		||||
            set => SetProperty(ref _boxTypes, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private BoxType _boxTypeSelectedItem = StaticBoxType[0];
 | 
			
		||||
        public BoxType BoxTypeSelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get => _boxTypeSelectedItem;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value != null && value.TypeValue == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    //药箱为公共药箱,把药师信息隐藏
 | 
			
		||||
                    UserStatus = Visibility.Collapsed;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    //药箱为药师药箱
 | 
			
		||||
                    UserStatus = Visibility.Visible;
 | 
			
		||||
                }
 | 
			
		||||
                SetProperty(ref _boxTypeSelectedItem, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static List<BindUserList> StaticUserList = SqlSugarHelper.Db.Queryable<UserList>().Where(us => us.MachineId == "DM3").Select(us => new BindUserList() { UserId =Convert.ToInt32(us.UserBarcode), UserName = us.Nickname }).ToList();
 | 
			
		||||
        //药师
 | 
			
		||||
        private List<BindUserList> _userLists = StaticUserList;
 | 
			
		||||
        public List<BindUserList> UserLists
 | 
			
		||||
        {
 | 
			
		||||
            get => _userLists;
 | 
			
		||||
            set => SetProperty(ref _userLists, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private BindUserList _userListSelectedItem = StaticUserList[0];
 | 
			
		||||
        public BindUserList UserListSelectedItem { get => _userListSelectedItem; set => SetProperty(ref _userListSelectedItem, value); }
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public SettingBoxWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        private void BindBoxTypeList()
 | 
			
		||||
        {
 | 
			
		||||
            BoxTypeList.Clear();
 | 
			
		||||
            BoxTypeList = new List<BoxType>() { new BoxType() { TypeValue = 0, TypeName = "归属药师" }, new BoxType() { TypeValue = 1, TypeName = "公共药箱" } };
 | 
			
		||||
        }
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        //点击药箱
 | 
			
		||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
			
		||||
            {
 | 
			
		||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
			
		||||
                ChannelList cnl = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo.ToString() == DrawerNo).First();
 | 
			
		||||
                if (cnl != null && cnl.DrawerType != null)
 | 
			
		||||
                {
 | 
			
		||||
                    BoxType currentBoxType = StaticBoxType.Where(sbt => sbt.TypeValue == cnl.DrawerType).FirstOrDefault();
 | 
			
		||||
                    if (currentBoxType != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        BoxTypeSelectedItem = currentBoxType;
 | 
			
		||||
                        if (BoxTypeSelectedItem.TypeValue == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            //药箱归属药师,把药师信息显示出来
 | 
			
		||||
                            UserStatus = Visibility.Visible;
 | 
			
		||||
                            UserListSelectedItem = StaticUserList.Where(sul => sul.UserId.ToString() == cnl.BelongUser).FirstOrDefault();
 | 
			
		||||
                            if (UserListSelectedItem == null && StaticUserList != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                UserListSelectedItem = StaticUserList[0];
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //药箱为公共药箱,把药师信息隐藏
 | 
			
		||||
                            UserStatus = Visibility.Collapsed;
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        //打开药箱
 | 
			
		||||
        public DelegateCommand OpenBox
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (DrawerNo > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    IsEnable = false;
 | 
			
		||||
                    Status = 1;
 | 
			
		||||
                    _portUtil.SpeakAsync("正在打开药箱");
 | 
			
		||||
                    _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
                    _portUtil.OpenBox();
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand SaveSetting
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (DrawerNo > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelList channelList=SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs=>cs.DrawerNo== DrawerNo&&cs.MachineId=="DM5").First();
 | 
			
		||||
                    if(BoxTypeSelectedItem!=null)
 | 
			
		||||
                    {
 | 
			
		||||
                        if(BoxTypeSelectedItem.TypeValue==0&&UserListSelectedItem!=null)
 | 
			
		||||
                        {
 | 
			
		||||
                            //药箱 归属药师
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelList() {BelongUser= UserListSelectedItem.UserId.ToString(),DrawerType= BoxTypeSelectedItem.TypeValue ,Id= channelList.Id }).UpdateColumns(cl=>new {cl.BelongUser,cl.DrawerType}).ExecuteCommand();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            //药箱属于公共药箱
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new ChannelList() {DrawerType= BoxTypeSelectedItem.TypeValue ,Id= channelList.Id }).UpdateColumns(cl=>new {cl.DrawerType}).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    //提示请选择药箱
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = $"未选择药箱,请先选择药箱",
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            switch (msg.EventType)
 | 
			
		||||
            {
 | 
			
		||||
                // 药箱打开
 | 
			
		||||
                case EventType.DRAWEROPEN:
 | 
			
		||||
                    if (Status == 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 2;
 | 
			
		||||
                    }
 | 
			
		||||
                    //记录开药箱日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.GetBoxStatus();
 | 
			
		||||
                    break;
 | 
			
		||||
                // 药箱关闭
 | 
			
		||||
                case EventType.DRAWERCLOSE:
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱关闭",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    if (Status == 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        Status = 3;
 | 
			
		||||
                    }
 | 
			
		||||
                    IsEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
                // 打开失败
 | 
			
		||||
                case EventType.OPENERROR:
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = msg.Message,
 | 
			
		||||
                        Type = MsgType.ERROR
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
 | 
			
		||||
                    IsEnable = true;
 | 
			
		||||
                    DrawerNo = -1;
 | 
			
		||||
                    Status = 0;
 | 
			
		||||
 | 
			
		||||
                    //记录药箱操作日志
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = "DM5",
 | 
			
		||||
                        DrawerNo = _portUtil.DrawerNo,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Type = 55,
 | 
			
		||||
                        InvoiceId = "药箱打开失败",
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    _portUtil.Operate = false;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 药箱类型
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class BoxType
 | 
			
		||||
    {
 | 
			
		||||
        public int TypeValue { get; set; }
 | 
			
		||||
        public string TypeName { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class BindUserList
 | 
			
		||||
    {
 | 
			
		||||
        public int UserId { get; set; }
 | 
			
		||||
        public string UserName { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,229 +0,0 @@
 | 
			
		|||
using Prism.Commands;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.Report;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class StockListWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public StockListWindowViewModel(IDialogService dialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = dialogService;
 | 
			
		||||
        }
 | 
			
		||||
        private ChannelStock? _selectedChannel;
 | 
			
		||||
 | 
			
		||||
        public ChannelStock? SelectedChannel
 | 
			
		||||
        {
 | 
			
		||||
            get => _selectedChannel;
 | 
			
		||||
            set => SetProperty(ref _selectedChannel, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<ChannelStock>? _channelStocks = new();
 | 
			
		||||
 | 
			
		||||
        public List<ChannelStock>? ChannelStocks
 | 
			
		||||
        {
 | 
			
		||||
            get => _channelStocks;
 | 
			
		||||
            set => SetProperty(ref _channelStocks, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BindingChannelDialog
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
			
		||||
                {
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelNewDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
                RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand Download
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                GridReportUtil.PrintReportStock();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<DrugInfo>? _drugs = new();
 | 
			
		||||
 | 
			
		||||
        public List<DrugInfo>? Drugs
 | 
			
		||||
        {
 | 
			
		||||
            get => _drugs;
 | 
			
		||||
            set => SetProperty(ref _drugs, value);
 | 
			
		||||
        }
 | 
			
		||||
        private DrugInfo? _drug;
 | 
			
		||||
 | 
			
		||||
        public DrugInfo? Drug
 | 
			
		||||
        {
 | 
			
		||||
            get => _drug;
 | 
			
		||||
            set => SetProperty(ref _drug, value);
 | 
			
		||||
        }
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            //ChannelStocks.Clear();
 | 
			
		||||
            //List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
            //    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
            //    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
            //    .Where(cs =>cs.DrugId != null)
 | 
			
		||||
            //    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
 | 
			
		||||
            //    .WhereIF(!String.IsNullOrEmpty(SearchValue),cs => cs.DrugInfo.DrugName == SearchValue)
 | 
			
		||||
            //    .OrderBy(cs => cs.DrugId)
 | 
			
		||||
            //    .OrderBy(cs => cs.DrawerNo)
 | 
			
		||||
            //    .OrderBy(cs => cs.ColNo)
 | 
			
		||||
            //    .ToList();
 | 
			
		||||
 | 
			
		||||
            //ICollectionView vw = CollectionViewSource.GetDefaultView(q);
 | 
			
		||||
            //vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
 | 
			
		||||
            //ChannelStocks = q;
 | 
			
		||||
 | 
			
		||||
            ChannelStocks.Clear();
 | 
			
		||||
 | 
			
		||||
            List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
 | 
			
		||||
                .Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue), di => di.DrugName == SearchValue)
 | 
			
		||||
              .Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null))
 | 
			
		||||
              .OrderBy(cs => cs.DrugId)
 | 
			
		||||
              .ToList();
 | 
			
		||||
            Drugs = q;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,859 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.Port;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using log4net;
 | 
			
		||||
using MaterialDesignThemes.Wpf;
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Channels;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SurgeryTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
			
		||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
			
		||||
        public string Title => "手术核销";
 | 
			
		||||
 | 
			
		||||
        private SurgicalSchedule _surgicalSchedule;
 | 
			
		||||
        public SurgicalSchedule _SurgicalSchedule { get => _surgicalSchedule; set => SetProperty(ref _surgicalSchedule, value); }
 | 
			
		||||
 | 
			
		||||
        private List<MachineRecord> machineRecordList;
 | 
			
		||||
        public List<MachineRecord> MachineRecordList { get => machineRecordList; set => SetProperty(ref machineRecordList, value); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugName",
 | 
			
		||||
                Name = "药品名称"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "PyCode",
 | 
			
		||||
                Name = "拼音码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugBarcode",
 | 
			
		||||
                Name = "药品条码"
 | 
			
		||||
            },
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "DrugId",
 | 
			
		||||
                Name = "药品编码"
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
			
		||||
 | 
			
		||||
        public List<OrderTakeSelect> Selects
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selects; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selects, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
			
		||||
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 9;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _status = 0;
 | 
			
		||||
 | 
			
		||||
        public int Status
 | 
			
		||||
        {
 | 
			
		||||
            get => _status; set => SetProperty(ref _status, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private SolidColorBrush _colorBrush;
 | 
			
		||||
 | 
			
		||||
        public SolidColorBrush SnackbarBackground
 | 
			
		||||
        {
 | 
			
		||||
            get => _colorBrush;
 | 
			
		||||
            set => SetProperty(ref _colorBrush, value);
 | 
			
		||||
        }
 | 
			
		||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
			
		||||
 | 
			
		||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
			
		||||
        {
 | 
			
		||||
            get => _snackbarMessageQueue;
 | 
			
		||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<ChannelStock> ReturnStockLst;
 | 
			
		||||
 | 
			
		||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
			
		||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
			
		||||
 | 
			
		||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OrderTakeSelect SelectedItem
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedItem; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedItem, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private MachineRecord selectedRecord;
 | 
			
		||||
        public MachineRecord SelectedRecord { get => selectedRecord; set => SetProperty(ref selectedRecord, value); }
 | 
			
		||||
 | 
			
		||||
        private PortUtil _portUtil;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        public SurgeryTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _portUtil = portUtil;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public event Action<IDialogResult> RequestClose;
 | 
			
		||||
 | 
			
		||||
        public bool CanCloseDialog()
 | 
			
		||||
        {
 | 
			
		||||
            return Status == 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogClosed()
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            SurgicalSchedule ss = parameters.GetValue<SurgicalSchedule>("SurgeryInfo");
 | 
			
		||||
            _SurgicalSchedule = ss;
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
        public async void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            MachineRecordList = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
			
		||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
			
		||||
                .Includes<UserList>(mr => mr.User)
 | 
			
		||||
                .Includes<SurgicalScheduleDetail>(mr => mr._SurgicalScheduleDetailLst)
 | 
			
		||||
                .Where(mr => mr.Type == 2)
 | 
			
		||||
                .Where(mr => mr.Status < 2)
 | 
			
		||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (mr) => mr.DrugInfo.PyCode.Contains(SearchValue))
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (mr) => mr.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                .OrderBy(mr => mr.OperationTime)
 | 
			
		||||
               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
 | 
			
		||||
            MachineRecordList.ForEach(mr => mr.HasCheckNum = mr._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity));
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand BtnCloseCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                // 关闭当前窗口
 | 
			
		||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 选中行事件
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand RowSelected
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (SelectedRecord != null && selectedRecord.Id != null)
 | 
			
		||||
                {
 | 
			
		||||
                    MachineRecordList = MachineRecordList.Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (x.Id == SelectedRecord.Id)
 | 
			
		||||
                        {
 | 
			
		||||
                            x.IsSelected = !x.IsSelected;
 | 
			
		||||
                            if (x.IsSelected)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (SelectedRecord._SurgicalScheduleDetailLst != null && SelectedRecord._SurgicalScheduleDetailLst.Count > 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    //已经核销数
 | 
			
		||||
                                    int HasCheckNum = SelectedRecord._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
			
		||||
                                    x.CheckQuantity = SelectedRecord.Quantity - HasCheckNum;
 | 
			
		||||
                                    x.ReturnQuantity1 = SelectedRecord.Quantity - HasCheckNum - x.CheckQuantity;
 | 
			
		||||
                                    x.ReturnQuantity2 = HasCheckNum + x.CheckQuantity;
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    x.CheckQuantity = SelectedRecord.Quantity;
 | 
			
		||||
                                    x.ReturnQuantity1 = 0;
 | 
			
		||||
                                    x.ReturnQuantity2 = SelectedRecord.Quantity;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                x.CheckQuantity = 0;
 | 
			
		||||
                                x.ReturnQuantity1 = 0;
 | 
			
		||||
                                x.ReturnQuantity2 = 0;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return x;
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 确认核销
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand AddSurgeryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity > 0).ToList();
 | 
			
		||||
                if (_SurgicalSchedule != null && RecordsLst.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    string operationId = _SurgicalSchedule.OperationId;
 | 
			
		||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(new SurgicalSchedule()
 | 
			
		||||
                        {
 | 
			
		||||
                            DmStatus = 1,
 | 
			
		||||
                            Id = _SurgicalSchedule.Id
 | 
			
		||||
                        }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
			
		||||
                        for (int i = 0; i < RecordsLst.Count; i++)
 | 
			
		||||
                        {
 | 
			
		||||
                            SqlSugarHelper.Db.Insertable(new SurgicalScheduleDetail()
 | 
			
		||||
                            {
 | 
			
		||||
                                OperationId = operationId,
 | 
			
		||||
                                GetRecordId = RecordsLst[i].Id,
 | 
			
		||||
                                Quantity = RecordsLst[i].CheckQuantity,
 | 
			
		||||
                                DrugId = RecordsLst[i].DrugId,
 | 
			
		||||
                                ManuNo = RecordsLst[i].ManuNo,
 | 
			
		||||
                                EffDate = RecordsLst[i].EffDate.ToString(),
 | 
			
		||||
                                InsertUserId = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                            int hasQuantity = RecordsLst[i]._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
			
		||||
                            int dmStatus = 0;
 | 
			
		||||
                            //已经全部挂上钩,修改dm_machine_record状态为完成
 | 
			
		||||
                            //if (hasQuantity + RecordsLst[i].CheckQuantity == RecordsLst[i].Quantity)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    dmStatus = 2;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //else
 | 
			
		||||
                            {
 | 
			
		||||
                                dmStatus = 1;
 | 
			
		||||
                            }
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = dmStatus,
 | 
			
		||||
                                Id = RecordsLst[i].Id
 | 
			
		||||
                            }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.IsSuccess)
 | 
			
		||||
                    {
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = "核销完成",
 | 
			
		||||
                            Type = MsgType.SUCCESS,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        RequestData();
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        logger.Info($"核销异常");
 | 
			
		||||
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("核销异常!");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量为0");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 全部归还(还药、还空瓶)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand ReturnCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity == 0).ToList();
 | 
			
		||||
                ReturnStockLst = new List<ChannelStock>();
 | 
			
		||||
                if (RecordsLst.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    //待还药的记录
 | 
			
		||||
                    List<MachineRecord> ReturnDrugLst = RecordsLst.Where(rl => rl.ReturnQuantity1 > 0).ToList();
 | 
			
		||||
                    //待还空瓶的记录
 | 
			
		||||
                    List<MachineRecord> ReturnEmptyLst = RecordsLst.Where(rl => rl.ReturnQuantity2 > 0).ToList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < ReturnDrugLst.Count; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                               .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                                               .Where(cs => cs.DrugId == ReturnDrugLst[i].DrugId)
 | 
			
		||||
                                               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                               .Where(cs => cs.ManuNo == ReturnDrugLst[i].ManuNo)
 | 
			
		||||
                                               .OrderBy(cs => cs.Quantity).First();
 | 
			
		||||
                        if (queryData != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            queryData.AddQuantity = ReturnDrugLst[i].ReturnQuantity1;
 | 
			
		||||
                            queryData.MachineRecordId = ReturnDrugLst[i].Id;
 | 
			
		||||
                            ReturnStockLst.Add(queryData);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    for (int j = 0; j < ReturnEmptyLst.Count; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                                              .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
			
		||||
                                              .Where(cs => cs.DrugId == ReturnEmptyLst[j].DrugId)
 | 
			
		||||
                                              .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
			
		||||
                                              //.Where(cs => cs.ManuNo == ReturnEmptyLst[j].ManuNo)
 | 
			
		||||
                                              .Where(cs => cs.DrawerType == 2)
 | 
			
		||||
                                              .OrderBy(cs => cs.Quantity).First();
 | 
			
		||||
                        if (queryData != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            queryData.ReturnQuantity = ReturnEmptyLst[j].ReturnQuantity2;
 | 
			
		||||
                            queryData.MachineRecordId = ReturnEmptyLst[j].Id;
 | 
			
		||||
                            ReturnStockLst.Add(queryData);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (ReturnStockLst != null && ReturnStockLst.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        ReturnStockLst = ReturnStockLst.OrderBy(cls => cls.DrawerNo).ToList();
 | 
			
		||||
                        //还药时AddQuantity有值;还空瓶时ReturnQuantity有值
 | 
			
		||||
                        enumerable = ReturnStockLst.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
			
		||||
                        enumerator = enumerable.GetEnumerator();
 | 
			
		||||
                        enumerator.MoveNext();
 | 
			
		||||
                        Status = 1;
 | 
			
		||||
                        OpenOneByOne();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                        SnackbarMessageQueue.Enqueue("选中数据未绑定库位,请先进行绑定库位");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量不为0");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 刷新
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (msg.WindowName == "SurgeryTakeWindow")
 | 
			
		||||
            {
 | 
			
		||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
                int DrawerNo = grouping.Key;
 | 
			
		||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
 | 
			
		||||
                switch (msg.EventType)
 | 
			
		||||
                {
 | 
			
		||||
                    // 抽屉打开
 | 
			
		||||
                    case EventType.DRAWEROPEN:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 1)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 抽屉关闭
 | 
			
		||||
                    case EventType.DRAWERCLOSE:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (channelStocks[0].process == 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
			
		||||
                            }
 | 
			
		||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
			
		||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
			
		||||
                            if (enumerator.MoveNext())
 | 
			
		||||
                            {
 | 
			
		||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
			
		||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
			
		||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Thread.Sleep(50);
 | 
			
		||||
                                }
 | 
			
		||||
                                OpenOneByOne();
 | 
			
		||||
                            }
 | 
			
		||||
                            // 已经全部取出
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                Status = 3;
 | 
			
		||||
 | 
			
		||||
                                //保存数据
 | 
			
		||||
 | 
			
		||||
                                //TakeFinish();
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 数量变化
 | 
			
		||||
                    case EventType.UPDATEQUANTITY:
 | 
			
		||||
                        if (Status == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    // 打开失败
 | 
			
		||||
                    case EventType.OPENERROR:
 | 
			
		||||
                        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                        {
 | 
			
		||||
                            Message = msg.Message,
 | 
			
		||||
                            Type = MsgType.ERROR,
 | 
			
		||||
                        };
 | 
			
		||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                        Status = 0;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenOneByOne()
 | 
			
		||||
        {
 | 
			
		||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
			
		||||
            int DrawerNo = grouping.Key;
 | 
			
		||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
			
		||||
            channelStocks.ForEach(it => it.process = 1);
 | 
			
		||||
 | 
			
		||||
            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
			
		||||
            string strNames = string.Empty;
 | 
			
		||||
            foreach (string name in strDrugName)
 | 
			
		||||
            {
 | 
			
		||||
                strNames += name;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
             
 | 
			
		||||
 | 
			
		||||
            int drugQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
			
		||||
 | 
			
		||||
            int emptyQuantity = channelStocks.Sum(cs => cs.ReturnQuantity);
 | 
			
		||||
            string speakTxt = $"正在打开{DrawerNo}号抽屉,请将{strNames}的";
 | 
			
		||||
            if (drugQuantity > 0)
 | 
			
		||||
            {
 | 
			
		||||
                speakTxt += $"共计{drugQuantity}个药放入抽屉!";
 | 
			
		||||
            }
 | 
			
		||||
            if (emptyQuantity > 0)
 | 
			
		||||
            {
 | 
			
		||||
                speakTxt += $"共计{emptyQuantity}个空瓶放入抽屉!";
 | 
			
		||||
            }
 | 
			
		||||
            _portUtil.SpeakAsync(speakTxt);
 | 
			
		||||
 | 
			
		||||
            //List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
			
		||||
 | 
			
		||||
            // 发送取药数量
 | 
			
		||||
            //singleChannels.ForEach(it =>
 | 
			
		||||
            //{
 | 
			
		||||
            //    try
 | 
			
		||||
            //    {
 | 
			
		||||
 | 
			
		||||
            //        _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
			
		||||
            //    }
 | 
			
		||||
            //    catch (Exception ex)
 | 
			
		||||
            //    {
 | 
			
		||||
            //        AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
            //        {
 | 
			
		||||
            //            Message = $"打开抽屉异常{ex.Message}",
 | 
			
		||||
            //            Type = MsgType.ERROR,
 | 
			
		||||
            //        };
 | 
			
		||||
            //        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
            //    }
 | 
			
		||||
            //});
 | 
			
		||||
 | 
			
		||||
            _portUtil.WindowName = "SurgeryTakeWindow";
 | 
			
		||||
            _portUtil.BoardType = channelStocks.Count > 0 ? channelStocks[0].BoardType : 1;
 | 
			
		||||
            _portUtil.ColNos = channelStocks.Select(it => it.ColNo).ToArray();
 | 
			
		||||
            _portUtil.DrawerNo = DrawerNo;
 | 
			
		||||
            _portUtil.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private bool _isFinishClick = false;
 | 
			
		||||
 | 
			
		||||
        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
			
		||||
        //完成
 | 
			
		||||
        private void TakeFinish()
 | 
			
		||||
        {
 | 
			
		||||
            IsFinishClick = true;
 | 
			
		||||
            bool bRet = false;
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < ReturnStockLst.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ChannelStock it = ReturnStockLst[i];
 | 
			
		||||
                    int quantity = 0;
 | 
			
		||||
                    if (it.AddQuantity > 0)  //还药
 | 
			
		||||
                    {
 | 
			
		||||
                        quantity = it.AddQuantity;
 | 
			
		||||
                        bRet = ReturnDrug(it);
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        quantity = it.ReturnQuantity;
 | 
			
		||||
                        bRet = ReturnEmpty(it);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!bRet)
 | 
			
		||||
                    {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    // 更新屏显库存
 | 
			
		||||
                    if (it.BoardType == 5)
 | 
			
		||||
                    {
 | 
			
		||||
                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + quantity);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
			
		||||
                    SnackbarMessageQueue.Enqueue("操作完成,库存已更新!");
 | 
			
		||||
                }
 | 
			
		||||
                return bRet;
 | 
			
		||||
            });
 | 
			
		||||
            if (!f.IsSuccess || !f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
			
		||||
                SnackbarMessageQueue.Enqueue("库存更新失败!");
 | 
			
		||||
            }
 | 
			
		||||
            Status = 0;
 | 
			
		||||
            IsFinishClick = false;
 | 
			
		||||
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 还药
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool ReturnDrug(ChannelStock stock)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
                {
 | 
			
		||||
                    string InvoiceId = "RETURN_" + CurrentTimeMillis(); 
 | 
			
		||||
                    MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
			
		||||
                    // 更新数据 库存信息
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                    {
 | 
			
		||||
                        Quantity = stock.Quantity + stock.AddQuantity,
 | 
			
		||||
                        Id = stock.Id,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
                    // 获取更新完库存后的药品库存
 | 
			
		||||
                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                        .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                        .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
			
		||||
                        .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                        .ToList();
 | 
			
		||||
                    // 更新数据 取药记录 设置还药数量、状态 
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        ReturnQuantity1 = recordInfo.ReturnQuantity1 + stock.AddQuantity,
 | 
			
		||||
                        Id = recordInfo.Id,
 | 
			
		||||
                        Status = (recordInfo.CanReturnQuantity - stock.AddQuantity) == 0 ? 2 : 1,
 | 
			
		||||
                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    // 保存数据 还药记录
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                    {
 | 
			
		||||
                        MachineId = stock.MachineId,
 | 
			
		||||
                        DrawerNo = stock.DrawerNo,
 | 
			
		||||
                        ColNo = stock.ColNo,
 | 
			
		||||
                        DrugId = stock.DrugId,
 | 
			
		||||
                        ManuNo = stock.ManuNo,
 | 
			
		||||
                        EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        OperationTime = DateTime.Now,
 | 
			
		||||
                        Quantity = stock.AddQuantity,
 | 
			
		||||
                        Type = 31,
 | 
			
		||||
                        InvoiceId = InvoiceId,
 | 
			
		||||
                        GetId = stock.MachineRecordId
 | 
			
		||||
                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                    //保存账册
 | 
			
		||||
                    SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                    {
 | 
			
		||||
                        DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                        Type = 1,
 | 
			
		||||
                        Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
			
		||||
                        InvoiceNo = InvoiceId,
 | 
			
		||||
                        ManuNo = stock.ManuNo,
 | 
			
		||||
                        EffDate = stock.EffDate,
 | 
			
		||||
                        AddQuantity = stock.AddQuantity,
 | 
			
		||||
                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                        CreateTime = DateTime.Now
 | 
			
		||||
 | 
			
		||||
                    }).ExecuteCommand();
 | 
			
		||||
                    //修改凌晨生成的日结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 3)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.ManuNo == stock.ManuNo)
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Day != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + stock.AddQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
			
		||||
                        int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                            Type = 3,
 | 
			
		||||
                            ManuNo = stock.ManuNo,
 | 
			
		||||
                            EffDate = stock.EffDate,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = stock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = stock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "日结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iDayResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入日结存数据{stock.DrugId}-{stock.ManuNo}-{stock.EffDate}-{stock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //修改凌晨生成的总结存数据
 | 
			
		||||
                    AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 4)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Total != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + stock.AddQuantity;
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
			
		||||
                        int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
			
		||||
                        {
 | 
			
		||||
                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
			
		||||
                            Type = 4,
 | 
			
		||||
                            YQuantity = 0,
 | 
			
		||||
                            ManuStock = stock.ReturnQuantity,
 | 
			
		||||
                            TotalStock = stock.ReturnQuantity,
 | 
			
		||||
                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
			
		||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
			
		||||
                            InvoiceNo = "总结存"
 | 
			
		||||
                        }).ExecuteCommand();
 | 
			
		||||
                        if (iTotalResult <= 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            logger.Info($"未写入总结存数据{stock.DrugId}-{stock.AddQuantity}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                if (f.IsSuccess)
 | 
			
		||||
                {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                throw;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 还空瓶
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private bool ReturnEmpty(ChannelStock stock)
 | 
			
		||||
        {
 | 
			
		||||
            string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
			
		||||
            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                // 更新数据 库存信息
 | 
			
		||||
                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
			
		||||
                {
 | 
			
		||||
                    Quantity = stock.Quantity + stock.ReturnQuantity,
 | 
			
		||||
                    Id = stock.Id,
 | 
			
		||||
                }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                // 获取更新完库存后的药品库存
 | 
			
		||||
                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
			
		||||
                    .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
			
		||||
                    .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
			
		||||
                    .Where(cs => cs.DrawerType == 1)
 | 
			
		||||
                    .ToList();
 | 
			
		||||
 | 
			
		||||
                MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
			
		||||
 | 
			
		||||
                // 更新数据 取药记录 设置还药数量、状态
 | 
			
		||||
                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
			
		||||
                {
 | 
			
		||||
                    ReturnQuantity2 = stock.ReturnQuantity,
 | 
			
		||||
                    Id = recordInfo.Id,
 | 
			
		||||
                    Status = 2,
 | 
			
		||||
                }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                // 保存数据 还药空瓶记录
 | 
			
		||||
                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
			
		||||
                {
 | 
			
		||||
                    MachineId = stock.MachineId,
 | 
			
		||||
                    DrawerNo = stock.DrawerNo,
 | 
			
		||||
                    ColNo = stock.ColNo,
 | 
			
		||||
                    DrugId = stock.DrugId,
 | 
			
		||||
                    ManuNo = stock.ManuNo,
 | 
			
		||||
                    EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
			
		||||
                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
			
		||||
                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
			
		||||
                    OperationTime = DateTime.Now,
 | 
			
		||||
                    Quantity = stock.ReturnQuantity, //ReturnQuantity,
 | 
			
		||||
                    Type = 32,
 | 
			
		||||
                    InvoiceId = InvoiceId,
 | 
			
		||||
                    GetId = stock.MachineRecordId
 | 
			
		||||
                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
			
		||||
                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                return true;
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            if (!f.IsSuccess || !f.Data)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public long CurrentTimeMillis()
 | 
			
		||||
        {
 | 
			
		||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 取消
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand CancleTake
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                _portUtil.ResetData();
 | 
			
		||||
                Status = 0;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        // 完成按钮
 | 
			
		||||
        public DelegateCommand TakeFinishCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(TakeFinish);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,230 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.select;
 | 
			
		||||
using DM_Weight.util;
 | 
			
		||||
using Prism.Commands;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using Prism.Mvvm;
 | 
			
		||||
using Prism.Regions;
 | 
			
		||||
using Prism.Services.Dialogs;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.ViewModels
 | 
			
		||||
{
 | 
			
		||||
    public class SurgeryTakeWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
			
		||||
    {
 | 
			
		||||
        private int _pageNum = 1;
 | 
			
		||||
        public int PageNum
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageNum;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageNum, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageCount = 1;
 | 
			
		||||
        public int PageCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _pageSize = 8;
 | 
			
		||||
        public int PageSize
 | 
			
		||||
        {
 | 
			
		||||
            get => _pageSize;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _pageSize, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _totalCount = 0;
 | 
			
		||||
        public int TotalCount
 | 
			
		||||
        {
 | 
			
		||||
            get => _totalCount;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _totalCount, value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        IDialogService _dialogService;
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
 | 
			
		||||
        private DelegateCommand _rowSelected;
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public SurgeryTakeWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            _dialogService = DialogService;
 | 
			
		||||
            _eventAggregator = eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
			
		||||
        {
 | 
			
		||||
            new OrderTakeSelect
 | 
			
		||||
            {
 | 
			
		||||
                Code = "OrderNo",
 | 
			
		||||
                Name = "手术号"
 | 
			
		||||
            }
 | 
			
		||||
        }; 
 | 
			
		||||
        private SurgicalSchedule? _selectedSurgicalSchedule;
 | 
			
		||||
 | 
			
		||||
        public SurgicalSchedule? SelectedSurgicalSchedule
 | 
			
		||||
        {
 | 
			
		||||
            get { return _selectedSurgicalSchedule; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _selectedSurgicalSchedule, value);
 | 
			
		||||
 | 
			
		||||
                //OpenOrderDialog();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private string _scheduleTime = DateTime.Now.ToString("yyyy-MM-dd");
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件  手术计划开始时间
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ScheduleTime
 | 
			
		||||
        {
 | 
			
		||||
            get { return _scheduleTime; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (!String.IsNullOrEmpty(value))
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _scheduleTime, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SetProperty(ref _scheduleTime, value);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string? _searchValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询条件 查询字段值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _searchValue; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetProperty(ref _searchValue, value);
 | 
			
		||||
                RequestData();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<SurgicalSchedule> _surgicalSchedule = new();
 | 
			
		||||
 | 
			
		||||
        public List<SurgicalSchedule> _SurgicalSchedule { get { return _surgicalSchedule; } set { SetProperty(ref _surgicalSchedule, value); } }
 | 
			
		||||
 | 
			
		||||
        public bool KeepAlive => false;
 | 
			
		||||
 | 
			
		||||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            if (SelectedSurgicalSchedule != null && SelectedSurgicalSchedule.DmStatus == 0 && SelectedSurgicalSchedule.HisState == 1)
 | 
			
		||||
            {
 | 
			
		||||
                // 此处延时1毫秒,等待页面渲染
 | 
			
		||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
			
		||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
			
		||||
                dialogParameters.Add("SurgeryInfo", SelectedSurgicalSchedule);
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "SurgeryTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
			
		||||
        {
 | 
			
		||||
            // 委托   被动执行     被子窗口执行
 | 
			
		||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
			
		||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
			
		||||
            //{
 | 
			
		||||
            SelectedSurgicalSchedule = null;
 | 
			
		||||
            RequestData();
 | 
			
		||||
            //}
 | 
			
		||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
			
		||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
			
		||||
        {
 | 
			
		||||
            continuationCallback(true);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 录入手术
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DelegateCommand AddSurgeryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() => {
 | 
			
		||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "AddSurgeryDialog", null, DoDialogResult, "RootDialog");
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DelegateCommand QueryCommand
 | 
			
		||||
        {
 | 
			
		||||
            get => new DelegateCommand(() =>
 | 
			
		||||
            {
 | 
			
		||||
                RequestData();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestData()
 | 
			
		||||
        {
 | 
			
		||||
            _SurgicalSchedule.Clear();
 | 
			
		||||
            int totalCount = 0;
 | 
			
		||||
            List<SurgicalSchedule> queryData = SqlSugarHelper.Db.Queryable<SurgicalSchedule>()
 | 
			
		||||
                .WhereIF(ScheduleTime != null, ss => ss.ScheduleTime.ToString("yyyy-MM-dd") == ScheduleTime)
 | 
			
		||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue), ss => ss.OperationId == SearchValue) 
 | 
			
		||||
                .Where(ss => ss.DmStatus == 0)
 | 
			
		||||
                .Where(ss => ss.HisState == 1) 
 | 
			
		||||
                .GroupBy(ss => ss.OperationId)
 | 
			
		||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
			
		||||
            _SurgicalSchedule = queryData;
 | 
			
		||||
            TotalCount = totalCount;
 | 
			
		||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
			
		||||
        } 
 | 
			
		||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            // 取消消息订阅
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
			
		||||
        }
 | 
			
		||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
			
		||||
        {
 | 
			
		||||
            if (msg.EventType == EventType.CODESCAN)
 | 
			
		||||
            {
 | 
			
		||||
                SearchValue = msg.Code;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
			
		||||
        {
 | 
			
		||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
			
		||||
            RequestData();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,244 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.AccountWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style> 
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="1.5*" />
 | 
			
		||||
                <ColumnDefinition Width="1.5*" />
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="5*"/>
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <DatePicker
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                SelectedDate="{Binding StartDate, TargetNullValue=''}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="开始时间"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
			
		||||
            />
 | 
			
		||||
            <DatePicker
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                SelectedDate="{Binding EndDate}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="结束时间"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
			
		||||
            />
 | 
			
		||||
            <!--<ComboBox
 | 
			
		||||
                    Margin="12 0 0 0"
 | 
			
		||||
                    Grid.Column="2"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName"
 | 
			
		||||
                />-->
 | 
			
		||||
            <!--<ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="2"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称/拼音码/药品编码"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName" IsEditable="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />-->
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="2"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品类型"
 | 
			
		||||
                    ItemsSource="{Binding DrugTypeList}"
 | 
			
		||||
                    SelectedItem="{Binding _DrugType}"
 | 
			
		||||
                    DisplayMemberPath="TypeName" IsEditable="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="12 0 0 0"
 | 
			
		||||
                    Grid.Column="3"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="账册类型"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding AccountTypeList}"
 | 
			
		||||
                    SelectedItem="{Binding AccountType}"
 | 
			
		||||
                    DisplayMemberPath="AccountTypeName"
 | 
			
		||||
                />
 | 
			
		||||
            <StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    ToolTip="导出" Command="{Binding DownloadOrderUser}">
 | 
			
		||||
                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                        <materialDesign:PackIcon Kind="download" />
 | 
			
		||||
                        <TextBlock Text="导出发药登记表" />
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    ToolTip="导出" Command="{Binding DownloadAccountBook}">
 | 
			
		||||
                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                        <materialDesign:PackIcon Kind="download" />
 | 
			
		||||
                        <TextBlock Text="导出账册" />
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <DataGrid x:Name="dgv1"
 | 
			
		||||
                Grid.Row="1"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
			
		||||
                ItemsSource="{Binding AccountList}"
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                IsSynchronizedWithCurrentItem="True"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False" >
 | 
			
		||||
            <DataGrid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                    <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                    <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                    <Setter Property="Height" Value="56" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                    <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
                </Style>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                            <Setter Property="Background" Value="Transparent"/>
 | 
			
		||||
                            <!--<Setter Property="HorizontalAlignment" Value="Left"/>-->
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </DataGrid.Resources>
 | 
			
		||||
            <DataGrid.Columns>
 | 
			
		||||
                <DataGridTextColumn Width="80"
 | 
			
		||||
                        Binding="{Binding CreateDate}"
 | 
			
		||||
                        Header="日期"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="150"
 | 
			
		||||
                        Binding="{Binding DrugName}"
 | 
			
		||||
                        Header="药品名称"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="130"
 | 
			
		||||
                        Binding="{Binding DrugSpec}"
 | 
			
		||||
                        Header="规格"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="200"
 | 
			
		||||
                        Binding="{Binding Manufactory}"
 | 
			
		||||
                        Header="厂家"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding InvoiceNo}"
 | 
			
		||||
                        Header="凭证号"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="130"
 | 
			
		||||
                        Binding="{Binding ManuNo}"
 | 
			
		||||
                        Header="批号"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding EffDate, StringFormat='yy/MM/dd'}"
 | 
			
		||||
                        Header="有效期"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding YQuantity}"
 | 
			
		||||
                        Header="上日结存"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding AddQuantity}"
 | 
			
		||||
                        Header="借入数"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding OutQuantity}"
 | 
			
		||||
                        Header="发出数"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding ManuStock}"
 | 
			
		||||
                        Header="批次结存"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding TotalStock}"
 | 
			
		||||
                        Header="总结存"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding OperatorName}"
 | 
			
		||||
                        Header="发药人"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="75"
 | 
			
		||||
                        Binding="{Binding ReviewerName}"
 | 
			
		||||
                        Header="复核人"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <!--<DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding SupplierDept}"
 | 
			
		||||
                        Header="供应单位"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding ReceiveDept}"
 | 
			
		||||
                        Header="领用部门"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
			
		||||
 | 
			
		||||
            </DataGrid.Columns>
 | 
			
		||||
        </DataGrid>
 | 
			
		||||
 | 
			
		||||
        <!--<pagination:Pagination Grid.Row="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />-->
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,395 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.AddDrugControl"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:QuantityCountConverter x:Key="QuantityCountConverter" />
 | 
			
		||||
        <convert:BoardTypeConverter x:Key="BoardTypeConverter" />
 | 
			
		||||
        <convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
 | 
			
		||||
        <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        <convert:InputQuantityConverter x:Key="InputQuantityConverter" />
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="Auto" />
 | 
			
		||||
            <ColumnDefinition Width="Auto" />
 | 
			
		||||
            <ColumnDefinition />
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
        <Grid Margin="0" Grid.Column="0"  Width="280" Height="570"  Visibility="{Binding Is8Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
 | 
			
		||||
            <Grid.Background>
 | 
			
		||||
                <ImageBrush ImageSource="/Images/box.png" />
 | 
			
		||||
            </Grid.Background>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="200" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Grid.Row="1">
 | 
			
		||||
                <Grid.RowDefinitions>
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                </Grid.RowDefinitions>
 | 
			
		||||
                <Grid.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="#00a0ea" />
 | 
			
		||||
                        <Setter Property="BorderBrush" Value="#00a0ea" />
 | 
			
		||||
                        <Style.Triggers>
 | 
			
		||||
                            <Trigger Property="IsMouseOver" Value="True">
 | 
			
		||||
                                <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                                <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                            </Trigger>
 | 
			
		||||
                            <DataTrigger Value="True">
 | 
			
		||||
                                <DataTrigger.Binding>
 | 
			
		||||
                                    <MultiBinding Converter="{StaticResource DrawerSelectConverter}">
 | 
			
		||||
                                        <Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
 | 
			
		||||
                                        <Binding Path="DrawerNo" />
 | 
			
		||||
                                    </MultiBinding>
 | 
			
		||||
                                </DataTrigger.Binding>
 | 
			
		||||
                                <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                                <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                            </DataTrigger>
 | 
			
		||||
                        </Style.Triggers>
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </Grid.Resources>
 | 
			
		||||
                <Button Grid.Row="0" Width="210" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
 | 
			
		||||
                <Button Grid.Row="1" Width="210" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
 | 
			
		||||
                <Button Grid.Row="2" Width="210" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
 | 
			
		||||
                <Button Grid.Row="3" Width="210" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
 | 
			
		||||
                <Button Grid.Row="4" Width="210" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
 | 
			
		||||
                <Button Grid.Row="5" Width="210" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
 | 
			
		||||
                <Button Grid.Row="6" Width="210" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
 | 
			
		||||
                <Button Grid.Row="7" Width="210" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
 | 
			
		||||
 | 
			
		||||
            </Grid>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Margin="0" Grid.Column="1" Width="300" Height="570" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
 | 
			
		||||
            <Grid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="#00a0ea" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="#00a0ea" />
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsMouseOver" Value="True">
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                        <DataTrigger Value="True">
 | 
			
		||||
                            <DataTrigger.Binding>
 | 
			
		||||
                                <MultiBinding Converter="{StaticResource DrawerSelectConverter}">
 | 
			
		||||
                                    <Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
 | 
			
		||||
                                    <Binding Path="DrawerNo" />
 | 
			
		||||
                                </MultiBinding>
 | 
			
		||||
                            </DataTrigger.Binding>
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </DataTrigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </Grid.Resources>
 | 
			
		||||
            <Grid.Background>
 | 
			
		||||
                <ImageBrush ImageSource="/Images/box-16.jpg" />
 | 
			
		||||
            </Grid.Background>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="200" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Margin="10 0 0 0"  Visibility="{Binding Is17Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Row="0">
 | 
			
		||||
                <Button  Width="110" Content="17" HorizontalAlignment="Left" Command="{Binding UpdateDrawerNo}" CommandParameter="17" />
 | 
			
		||||
            </Grid>
 | 
			
		||||
 | 
			
		||||
            <Grid Grid.Row="1">
 | 
			
		||||
                <Grid.RowDefinitions>
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                </Grid.RowDefinitions>
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
                <Button Grid.Row="0" Grid.Column="0" Width="120" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
 | 
			
		||||
                <Button Grid.Row="1" Grid.Column="0" Width="120" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
 | 
			
		||||
                <Button Grid.Row="2" Grid.Column="0" Width="120" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
 | 
			
		||||
                <Button Grid.Row="3" Grid.Column="0" Width="120" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
 | 
			
		||||
                <Button Grid.Row="4" Grid.Column="0" Width="120" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
 | 
			
		||||
                <Button Grid.Row="5" Grid.Column="0" Width="120" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
 | 
			
		||||
                <Button Grid.Row="6" Grid.Column="0" Width="120" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
 | 
			
		||||
                <Button Grid.Row="7" Grid.Column="0" Width="120" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
 | 
			
		||||
 | 
			
		||||
                <Button Grid.Row="0" Grid.Column="1" Width="120" Content="9" Command="{Binding UpdateDrawerNo}" CommandParameter="9" />
 | 
			
		||||
                <Button Grid.Row="1" Grid.Column="1" Width="120" Content="10" Command="{Binding UpdateDrawerNo}" CommandParameter="10" />
 | 
			
		||||
                <Button Grid.Row="2" Grid.Column="1" Width="120" Content="11" Command="{Binding UpdateDrawerNo}" CommandParameter="11" />
 | 
			
		||||
                <Button Grid.Row="3" Grid.Column="1" Width="120" Content="12" Command="{Binding UpdateDrawerNo}" CommandParameter="12" />
 | 
			
		||||
                <Button Grid.Row="4" Grid.Column="1" Width="120" Content="13" Command="{Binding UpdateDrawerNo}" CommandParameter="13" />
 | 
			
		||||
                <Button Grid.Row="5" Grid.Column="1" Width="120" Content="14" Command="{Binding UpdateDrawerNo}" CommandParameter="14" />
 | 
			
		||||
                <Button Grid.Row="6" Grid.Column="1" Width="120" Content="15" Command="{Binding UpdateDrawerNo}" CommandParameter="15" />
 | 
			
		||||
                <Button Grid.Row="7" Grid.Column="1" Width="120" Content="16" Command="{Binding UpdateDrawerNo}" CommandParameter="16" />
 | 
			
		||||
 | 
			
		||||
            </Grid>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Column="2">
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <StackPanel Grid.Row="0" Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding OpenDrawer}"
 | 
			
		||||
                    Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="加药" />
 | 
			
		||||
 | 
			
		||||
                <!--<TextBox Text="{Binding PZH, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="凭证号"
 | 
			
		||||
                materialDesign:HintAssist.IsFloating="True" Width="100"
 | 
			
		||||
                Margin="0 0 3 0"
 | 
			
		||||
                Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
			
		||||
                />-->
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding TakeFinish}"
 | 
			
		||||
                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="完成" />
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 6 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding CancleTake}"
 | 
			
		||||
                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="取消" />
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
            <ScrollViewer  Grid.Row="1"  Margin="6">
 | 
			
		||||
                <ItemsControl 
 | 
			
		||||
                ItemsSource="{Binding ChannelLsts}"
 | 
			
		||||
                Grid.IsSharedSizeScope="True"
 | 
			
		||||
               >
 | 
			
		||||
                    <!--<ItemsControl.ItemsPanel>
 | 
			
		||||
                    <ItemsPanelTemplate>
 | 
			
		||||
                        -->
 | 
			
		||||
                    <!--<UniformGrid Columns="4" />-->
 | 
			
		||||
                    <!--
 | 
			
		||||
                    </ItemsPanelTemplate>
 | 
			
		||||
                </ItemsControl.ItemsPanel>-->
 | 
			
		||||
                    <ItemsControl.ItemTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <!--<materialDesign:Card
 | 
			
		||||
                                Background="{StaticResource MaterialDesignLightBackground}"
 | 
			
		||||
                                Margin="4"
 | 
			
		||||
                                Padding="0">-->
 | 
			
		||||
                            <Grid>
 | 
			
		||||
                                <Grid.ColumnDefinitions>
 | 
			
		||||
                                    <ColumnDefinition Width="200"/>
 | 
			
		||||
                                    <ColumnDefinition/>
 | 
			
		||||
                                </Grid.ColumnDefinitions>
 | 
			
		||||
                                <Border BorderBrush="White" BorderThickness="1">
 | 
			
		||||
                                    <StackPanel Orientation="Horizontal" Background="#31ccec" Grid.Column="0">
 | 
			
		||||
 | 
			
		||||
                                        <Grid>
 | 
			
		||||
                                            <Grid.RowDefinitions>
 | 
			
		||||
                                                <RowDefinition/>
 | 
			
		||||
                                                <RowDefinition/>
 | 
			
		||||
                                                <RowDefinition/>
 | 
			
		||||
                                            </Grid.RowDefinitions>
 | 
			
		||||
                                            <Grid.ColumnDefinitions>
 | 
			
		||||
                                                <ColumnDefinition Width="200"/>
 | 
			
		||||
                                            </Grid.ColumnDefinitions>
 | 
			
		||||
                                            <TextBlock TextWrapping="Wrap" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"  Padding="0 10 0 0 " Text="{Binding Drug.DrugName}"/>
 | 
			
		||||
 | 
			
		||||
                                            <TextBlock TextWrapping="Wrap" Grid.Row="1"  HorizontalAlignment="Center" VerticalAlignment="Center"  Padding="0 0 0 1 " Text="{Binding Drug.DrugSpec}"/>
 | 
			
		||||
                                            <Button  Grid.Row="2"   Padding="0 0 0 1 "  Style="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Click="Button_Click" CommandParameter="{Binding}">
 | 
			
		||||
 | 
			
		||||
                                                <Button.Content>
 | 
			
		||||
                                                    <Border Width="32" Height="32" CornerRadius="16" Background="CornflowerBlue" VerticalAlignment="Center" HorizontalAlignment="Center">
 | 
			
		||||
                                                        <Path Data="M0 11L22 11M11 0L11 22" Stroke="WhiteSmoke" StrokeThickness="4" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
 | 
			
		||||
                                                    </Border>
 | 
			
		||||
                                                </Button.Content>
 | 
			
		||||
                                            </Button>
 | 
			
		||||
                                        </Grid>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                    </StackPanel>
 | 
			
		||||
                                </Border>
 | 
			
		||||
                                <DataGrid
 | 
			
		||||
                Margin="0"
 | 
			
		||||
                 Grid.Column="1" 
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
			
		||||
                 ItemsSource="{Binding channelStocks}"  
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                SelectionUnit="Cell"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False">
 | 
			
		||||
                                    <DataGrid.Resources>
 | 
			
		||||
                                        <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                                            <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                                            <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                                            <Setter Property="Height" Value="56" />
 | 
			
		||||
                                            <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                                            <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
 | 
			
		||||
                                        </Style>
 | 
			
		||||
                                        <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                                            <Style.Triggers>
 | 
			
		||||
                                                <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                                                    <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                                                    <Setter Property="HorizontalAlignment" Value="Center"/>
 | 
			
		||||
                                                </Trigger>
 | 
			
		||||
                                            </Style.Triggers>
 | 
			
		||||
                                        </Style>
 | 
			
		||||
                                    </DataGrid.Resources>
 | 
			
		||||
                                    <DataGrid.Columns>
 | 
			
		||||
                                        <DataGridTextColumn Width="80"
 | 
			
		||||
                        Binding="{Binding ColNo}"
 | 
			
		||||
                        Header="库位"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                                        <DataGridTextColumn Width="180"
 | 
			
		||||
                        Binding="{Binding DrugInfo.DrugName}"
 | 
			
		||||
                        Header="药品名称"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                                        <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding DrugInfo.DrugSpec}"
 | 
			
		||||
                        Header="规格"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                                        <DataGridTemplateColumn Width="200" IsReadOnly="True"
 | 
			
		||||
                        Header="批次">
 | 
			
		||||
                                            <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                                                <DataTemplate>
 | 
			
		||||
                                                    <ComboBox
 | 
			
		||||
                                    Style="{StaticResource MaterialDesignDataGridComboBox}"                  
 | 
			
		||||
                                    ItemsSource="{Binding DrugInfo.DrugManuNos}"
 | 
			
		||||
                                    SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                                    DisplayMemberPath="ManuNo" 
 | 
			
		||||
                                    IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                                    </ComboBox>
 | 
			
		||||
                                                </DataTemplate>
 | 
			
		||||
                                            </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                                        </DataGridTemplateColumn>
 | 
			
		||||
                                        <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding drugManuNo.EffDate}"
 | 
			
		||||
                        Header="效期"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                                        <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding Quantity}"
 | 
			
		||||
                        Header="库存"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                                        <DataGridTemplateColumn Width="100"
 | 
			
		||||
                        Header="添加数量">
 | 
			
		||||
                                            <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                                                <DataTemplate>
 | 
			
		||||
                                                    <TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" IsReadOnly="{Binding BoardType, Converter={StaticResource InputQuantityConverter}}">
 | 
			
		||||
                                                        <TextBox.Text>
 | 
			
		||||
                                                            <Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
 | 
			
		||||
                                                                <Binding.ValidationRules>
 | 
			
		||||
                                                                    <ExceptionValidationRule />
 | 
			
		||||
                                                                </Binding.ValidationRules>
 | 
			
		||||
                                                            </Binding>
 | 
			
		||||
                                                        </TextBox.Text>
 | 
			
		||||
                                                    </TextBox>
 | 
			
		||||
                                                </DataTemplate>
 | 
			
		||||
                                            </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                                        </DataGridTemplateColumn>
 | 
			
		||||
 | 
			
		||||
                                    </DataGrid.Columns>
 | 
			
		||||
                                </DataGrid>
 | 
			
		||||
                                <!--<ListView Padding="0 6 0 0"  Grid.Column="1" 
 | 
			
		||||
                                     materialDesign:ListViewAssist.ListViewItemPadding="15"
 | 
			
		||||
                                        ItemsSource="{Binding channelStocks}"  SelectedItem="{Binding channelStock}"
 | 
			
		||||
                                        materialDesign:ListViewAssist.HeaderRowBackground="#31ccec">
 | 
			
		||||
                                    <ListView.Resources>
 | 
			
		||||
                                        <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                                            <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                                            <Setter Property="Foreground" Value="white" />
 | 
			
		||||
 | 
			
		||||
                                            <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                                            <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
                                        </Style>
 | 
			
		||||
                                    </ListView.Resources>
 | 
			
		||||
                                    <ListView.View>
 | 
			
		||||
 | 
			
		||||
                                        <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                                            <GridView.Columns>
 | 
			
		||||
                                                <GridViewColumn Width="80" Header="库位" DisplayMemberBinding="{Binding ColNo}" />
 | 
			
		||||
                                                <GridViewColumn Width="130"  Header="批次">
 | 
			
		||||
                                                    <GridViewColumn.CellTemplate>
 | 
			
		||||
                                                        <DataTemplate>
 | 
			
		||||
                                                            <ComboBox Style="{StaticResource MaterialDesignComboBox}"                  
 | 
			
		||||
                                                                    ItemsSource="{Binding DrugInfo.DrugManuNos}" SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                                                                    DisplayMemberPath="ManuNo" IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
 | 
			
		||||
                                                            </ComboBox>
 | 
			
		||||
                                                        </DataTemplate>
 | 
			
		||||
                                                    </GridViewColumn.CellTemplate>
 | 
			
		||||
                                                </GridViewColumn>
 | 
			
		||||
                                                <GridViewColumn Width="130" Header="效期" DisplayMemberBinding="{Binding drugManuNo.EffDate}" />
 | 
			
		||||
                                                <GridViewColumn Width="80" Header="库存" DisplayMemberBinding="{Binding Quantity}" />
 | 
			
		||||
                                                <GridViewColumn Width="80" Header="添加数量">
 | 
			
		||||
                                                    <GridViewColumn.CellTemplate>
 | 
			
		||||
                                                        <DataTemplate>
 | 
			
		||||
                                                            <TextBox  Width="80" Padding="10" Grid.Column="1"
 | 
			
		||||
                                                                    Text="{Binding AddQuantity}"
 | 
			
		||||
                                                                    materialDesign:HintAssist.Hint="添加数量"
 | 
			
		||||
                                                                    Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"/>
 | 
			
		||||
                                                        </DataTemplate>
 | 
			
		||||
                                                    </GridViewColumn.CellTemplate>
 | 
			
		||||
                                                </GridViewColumn>
 | 
			
		||||
                                            </GridView.Columns>
 | 
			
		||||
                                        </GridView>
 | 
			
		||||
                                    </ListView.View>
 | 
			
		||||
                                </ListView>-->
 | 
			
		||||
                            </Grid>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </ItemsControl.ItemTemplate>
 | 
			
		||||
                </ItemsControl>
 | 
			
		||||
            </ScrollViewer>
 | 
			
		||||
        </Grid>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,41 +0,0 @@
 | 
			
		|||
using DM_Weight.Models;
 | 
			
		||||
using DM_Weight.msg;
 | 
			
		||||
using DM_Weight.ViewModels;
 | 
			
		||||
using Prism.Events;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// AddDrugControl.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class AddDrugControl : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        IEventAggregator _eventAggregator;
 | 
			
		||||
        public AddDrugControl(IEventAggregator eventAggregator)
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            _eventAggregator= eventAggregator;
 | 
			
		||||
        }
 | 
			
		||||
        private void Button_Click(object sender, RoutedEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            Button btn = (Button)sender;
 | 
			
		||||
            ChannelList cls = (ChannelList)btn.CommandParameter;
 | 
			
		||||
            //vms.AddAction(cls);
 | 
			
		||||
            _eventAggregator.GetEvent<AddDrugEvent>().Publish(cls);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.AddToJiaoJieWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
			
		||||
    <Grid>
 | 
			
		||||
            
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// AddToJiaoJieWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class AddToJiaoJieWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public AddToJiaoJieWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,278 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.ApplyInStockWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <!--<Grid.Resources>
 | 
			
		||||
        <CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
 | 
			
		||||
            <CollectionViewSource.GroupDescriptions>
 | 
			
		||||
                <PropertyGroupDescription PropertyName="DrugInfo" />
 | 
			
		||||
            </CollectionViewSource.GroupDescriptions>
 | 
			
		||||
        </CollectionViewSource>
 | 
			
		||||
        </Grid.Resources>-->
 | 
			
		||||
        <Grid.Resources>
 | 
			
		||||
            <convert:GroupSumConverter x:Key="GroupSumConverter" />
 | 
			
		||||
            <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        </Grid.Resources>
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="4*" />
 | 
			
		||||
            <ColumnDefinition Width="6*"/>
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
        <Grid Grid.Column="0" >
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition Width="3*" />
 | 
			
		||||
                    <ColumnDefinition Width="3*" />
 | 
			
		||||
                    <ColumnDefinition Width="4*" />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
                <ComboBox
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                SelectedItem="{Binding SelectedItem}"
 | 
			
		||||
                DisplayMemberPath="Name"
 | 
			
		||||
                ItemsSource="{Binding OrderTakeSelects}"
 | 
			
		||||
                />
 | 
			
		||||
                <TextBox
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                Text="{Binding SearchValue, UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
			
		||||
                materialDesign:HintAssist.IsFloating="True"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
			
		||||
                <DatePicker
 | 
			
		||||
                Grid.Column="2"
 | 
			
		||||
                SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                SelectedDateFormat="Short"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="日期"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
			
		||||
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <ListView Grid.Row="1"
 | 
			
		||||
                    ItemsSource="{Binding _DrugPleaseClaimList}"
 | 
			
		||||
                    SelectedItem="{Binding SelectDrugPleaseClaim}"
 | 
			
		||||
                    materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
                    materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
                    materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                <ListView.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </ListView.Resources>
 | 
			
		||||
                <i:Interaction.Triggers>
 | 
			
		||||
                    <i:EventTrigger EventName="SelectionChanged">
 | 
			
		||||
                        <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
			
		||||
                    </i:EventTrigger>
 | 
			
		||||
                </i:Interaction.Triggers>
 | 
			
		||||
                <ListView.View>
 | 
			
		||||
                    <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                        <GridViewColumn Width="110"
 | 
			
		||||
                        Header="请领单号"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PleaseNo}"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        Header="时间"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DoDate, StringFormat=yyyy-MM-dd}" />
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding GetQuantity}"
 | 
			
		||||
                        Header="药品种类"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding TotalQuantity}"
 | 
			
		||||
                        Header="药品总数"/>
 | 
			
		||||
                        <!--<GridViewColumn
 | 
			
		||||
                        DisplayMemberBinding="{Binding Status}"
 | 
			
		||||
                        Header="状态"/>-->
 | 
			
		||||
                    </GridView>
 | 
			
		||||
                </ListView.View>
 | 
			
		||||
            </ListView>
 | 
			
		||||
 | 
			
		||||
            <pagination:Pagination Grid.Row="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Column="1" Margin="10 0 0 0">
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="61" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 6 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Command="{Binding OpenInvoiceAdd}"
 | 
			
		||||
                    Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    Content="入库"
 | 
			
		||||
                    />
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding TakeFinish}"
 | 
			
		||||
                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="完成" />
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 6 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding CancleTake}"
 | 
			
		||||
                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="取消" />
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 6 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Command="{Binding QueryCommand}"
 | 
			
		||||
                    ToolTip="刷新">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
            <DataGrid
 | 
			
		||||
                Grid.Row="1"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15" 
 | 
			
		||||
                 ItemsSource="{Binding ChannelStocks}"
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                IsSynchronizedWithCurrentItem="True"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False">
 | 
			
		||||
                <DataGrid.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                        <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                        <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                        <Setter Property="Height" Value="56" />
 | 
			
		||||
                        <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                        <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
                    </Style>
 | 
			
		||||
                    <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                        <Style.Triggers>
 | 
			
		||||
                            <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                                <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                                <Setter Property="HorizontalAlignment" Value="Left"/>
 | 
			
		||||
                            </Trigger>
 | 
			
		||||
                        </Style.Triggers>
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </DataGrid.Resources>
 | 
			
		||||
                <!--GroupStyle to group data-->
 | 
			
		||||
                <!--<DataGrid.GroupStyle>
 | 
			
		||||
                    <GroupStyle>
 | 
			
		||||
                        --><!--Group DataItems into DataGroup--><!--
 | 
			
		||||
                        <GroupStyle.ContainerStyle>
 | 
			
		||||
                            <Style TargetType="{x:Type GroupItem}">
 | 
			
		||||
                                <Setter Property="Template">
 | 
			
		||||
                                    <Setter.Value>
 | 
			
		||||
                                        <ControlTemplate TargetType="{x:Type GroupItem}">
 | 
			
		||||
                                            <Expander IsExpanded="True"
 | 
			
		||||
                                                  materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
 | 
			
		||||
                                                <Expander.Header >
 | 
			
		||||
                                                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                                                        <TextBlock Text="{Binding Path=Name.DrugInfo.DrugName,StringFormat=药品:{0},}" FontWeight="Bold" />
 | 
			
		||||
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugInfo.DrugSpec,StringFormat=规格:{0},}" />
 | 
			
		||||
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugInfo.Manufactory,StringFormat=厂家:{0},}" />
 | 
			
		||||
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />
 | 
			
		||||
 | 
			
		||||
                                                        --><!--<TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />--><!--
 | 
			
		||||
 | 
			
		||||
                                                    </StackPanel>
 | 
			
		||||
                                                </Expander.Header>
 | 
			
		||||
                                                <ItemsPresenter/>
 | 
			
		||||
                                            </Expander>
 | 
			
		||||
                                        </ControlTemplate>
 | 
			
		||||
                                    </Setter.Value>
 | 
			
		||||
                                </Setter>
 | 
			
		||||
                            </Style>
 | 
			
		||||
                        </GroupStyle.ContainerStyle>
 | 
			
		||||
 | 
			
		||||
                    </GroupStyle>
 | 
			
		||||
                </DataGrid.GroupStyle>-->
 | 
			
		||||
                <DataGrid.Columns>
 | 
			
		||||
                    <DataGridTextColumn Width="100" Header="药品" 
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.DrugName}">                        
 | 
			
		||||
                    </DataGridTextColumn>
 | 
			
		||||
                    <DataGridTextColumn Width="100" Header="规格" 
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.DrugSpec}">                        
 | 
			
		||||
                    </DataGridTextColumn>
 | 
			
		||||
                    <DataGridTextColumn Width="180" Header="厂家" 
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.Manufactory}">                        
 | 
			
		||||
                    </DataGridTextColumn>
 | 
			
		||||
                    <DataGridTextColumn Width="60"
 | 
			
		||||
                        Binding="{Binding Location}"
 | 
			
		||||
                        Header="库位"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                    <DataGridTextColumn  Width="80"
 | 
			
		||||
                        Binding="{Binding ManuNo}"
 | 
			
		||||
                        Header="批次"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                    <DataGridTextColumn  Width="100"
 | 
			
		||||
                        Binding="{Binding EffDate}"
 | 
			
		||||
                        Header="效期"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                    <DataGridTextColumn  Width="100"
 | 
			
		||||
                        Binding="{Binding Quantity}"
 | 
			
		||||
                        Header="库存"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                    <DataGridTemplateColumn Width="80"
 | 
			
		||||
                        Header="添加数量">
 | 
			
		||||
                        <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                            <DataTemplate>
 | 
			
		||||
                                <TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
 | 
			
		||||
                                    <TextBox.Text>
 | 
			
		||||
                                        <Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
 | 
			
		||||
                                            <Binding.ValidationRules>
 | 
			
		||||
                                                <ExceptionValidationRule />
 | 
			
		||||
                                            </Binding.ValidationRules>
 | 
			
		||||
                                        </Binding>
 | 
			
		||||
                                    </TextBox.Text>
 | 
			
		||||
                                </TextBox>
 | 
			
		||||
                            </DataTemplate>
 | 
			
		||||
                        </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn>
 | 
			
		||||
                </DataGrid.Columns>
 | 
			
		||||
            </DataGrid>
 | 
			
		||||
        </Grid>
 | 
			
		||||
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,309 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.ApplyListWindow" 
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter" 
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:ApplyListConverter x:Key="ApplyListConverter" />
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.Resources>
 | 
			
		||||
            <CollectionViewSource x:Key="GroupedDataList" Source="{Binding CollectDrugLst}">
 | 
			
		||||
                <CollectionViewSource.GroupDescriptions>
 | 
			
		||||
                    <PropertyGroupDescription PropertyName="drugPleaseClaim" />
 | 
			
		||||
                </CollectionViewSource.GroupDescriptions>
 | 
			
		||||
            </CollectionViewSource>
 | 
			
		||||
        </Grid.Resources>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="1*" />
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="5*"/>
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                SelectedItem="{Binding SelectedItem}"
 | 
			
		||||
                DisplayMemberPath="Name"
 | 
			
		||||
                ItemsSource="{Binding Selects}"
 | 
			
		||||
                />
 | 
			
		||||
            <TextBox
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                Text="{Binding SearchValue}"
 | 
			
		||||
                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="12 0 0 0"
 | 
			
		||||
                    Grid.Column="2"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="请领单状态"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugPleaseStateList}"
 | 
			
		||||
                    SelectedItem="{Binding _DrugPleaseState}"
 | 
			
		||||
                    DisplayMemberPath="StateName"
 | 
			
		||||
                />
 | 
			
		||||
            <StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <DataGrid
 | 
			
		||||
                Grid.Row="1"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
			
		||||
                ItemsSource="{Binding Source={StaticResource GroupedDataList}}"
 | 
			
		||||
                SelectedItem="SelectDrugPleaseClaim"
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                IsSynchronizedWithCurrentItem="True"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False">
 | 
			
		||||
            <DataGrid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                    <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                    <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                    <Setter Property="Height" Value="56" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                    <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
                </Style>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                            <Setter Property="HorizontalAlignment" Value="Left"/>
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </DataGrid.Resources>
 | 
			
		||||
            <!--GroupStyle to group data-->
 | 
			
		||||
            <DataGrid.GroupStyle>
 | 
			
		||||
                <GroupStyle>
 | 
			
		||||
                    <!--Group DataItems into DataGroup-->
 | 
			
		||||
                    <GroupStyle.ContainerStyle>
 | 
			
		||||
                        <Style TargetType="{x:Type GroupItem}">
 | 
			
		||||
                            <Setter Property="Template">
 | 
			
		||||
                                <Setter.Value>
 | 
			
		||||
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
 | 
			
		||||
                                        <Expander IsExpanded="True"
 | 
			
		||||
                                                  materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
 | 
			
		||||
                                            <Expander.Header >
 | 
			
		||||
 | 
			
		||||
                                                <StackPanel Orientation="Horizontal">
 | 
			
		||||
                                                    <TextBlock Text="{Binding Path=Name.PleaseNo,StringFormat=请领单号:{0},}" FontWeight="Bold" />
 | 
			
		||||
                                                    <TextBlock Text="{Binding Path=Name.TotalQuantity,StringFormat=请领数量:{0},}" FontWeight="Bold" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.ReturnPrQuantity,StringFormat=处方张数:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.DoDate,StringFormat=请领时间:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.MachineId,Converter={StaticResource ApplyListConverter},ConverterParameter=machineId,StringFormat=请领药房:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.ApplyUser,Converter={StaticResource ApplyListConverter}, ConverterParameter=UserId, StringFormat=申请人:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.ReviewUser,Converter={StaticResource ApplyListConverter}, ConverterParameter=UserId,StringFormat=复核人:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.State,Converter={StaticResource ApplyListConverter}, ConverterParameter=PleaseStatus}" />
 | 
			
		||||
 | 
			
		||||
                                                </StackPanel>
 | 
			
		||||
                                            </Expander.Header>
 | 
			
		||||
                                            <ItemsPresenter/>
 | 
			
		||||
                                        </Expander>
 | 
			
		||||
                                    </ControlTemplate>
 | 
			
		||||
                                </Setter.Value>
 | 
			
		||||
                            </Setter>
 | 
			
		||||
                        </Style>
 | 
			
		||||
                    </GroupStyle.ContainerStyle>
 | 
			
		||||
 | 
			
		||||
                </GroupStyle>
 | 
			
		||||
            </DataGrid.GroupStyle>
 | 
			
		||||
            <DataGrid.Columns>
 | 
			
		||||
                <!--<DataGridTextColumn Width="180"
 | 
			
		||||
                        Binding="{Binding OrderNo}"
 | 
			
		||||
                        Header="处方号"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
			
		||||
                <DataGridTextColumn Width="180"
 | 
			
		||||
                        Binding="{Binding drugInfo.DrugName}"
 | 
			
		||||
                        Header="药品名称"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="130"
 | 
			
		||||
                        Binding="{Binding drugInfo.DrugSpec}"
 | 
			
		||||
                        Header="规格"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="241"
 | 
			
		||||
                        Binding="{Binding drugInfo.Manufactory}"
 | 
			
		||||
                        Header="厂家"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="80"  Header="请领数"
 | 
			
		||||
                                    Binding="{Binding Quantity}" 
 | 
			
		||||
                                    IsReadOnly="True"
 | 
			
		||||
                                    ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}">
 | 
			
		||||
                </DataGridTextColumn>
 | 
			
		||||
                
 | 
			
		||||
                <!--<DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding CurrentMachineId}"
 | 
			
		||||
                        Header="当前所在"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="80"
 | 
			
		||||
                        Binding="{Binding Status,Converter={StaticResource ApplyListConverter}, ConverterParameter=OrderStatus}"
 | 
			
		||||
                        Header="状态"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
			
		||||
 | 
			
		||||
                <DataGridTemplateColumn Header="批次" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="ManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
 | 
			
		||||
                <DataGridTemplateColumn Header="效期" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="EffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
 | 
			
		||||
                <DataGridTemplateColumn Header="入库数" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
            </DataGrid.Columns>
 | 
			
		||||
        </DataGrid>
 | 
			
		||||
        <!--<Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="110" />
 | 
			
		||||
                <ColumnDefinition Width="180" />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                SelectedItem="{Binding SelectedItem}"
 | 
			
		||||
                DisplayMemberPath="Name"
 | 
			
		||||
                ItemsSource="{Binding Selects}"
 | 
			
		||||
                />
 | 
			
		||||
            <TextBox
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                Text="{Binding SearchValue}"
 | 
			
		||||
                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
			
		||||
 | 
			
		||||
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center" Command="{Binding CreateApplyOrder}"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}" Content="生成请领单">
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <ListView
 | 
			
		||||
            Grid.Row="1"
 | 
			
		||||
            ItemsSource="{Binding CollectDrugs}"
 | 
			
		||||
            SelectedItem="{Binding selectCollectDrug}"
 | 
			
		||||
            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
            <ListView.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                </Style>
 | 
			
		||||
            </ListView.Resources>
 | 
			
		||||
            <i:Interaction.Triggers>
 | 
			
		||||
                <i:EventTrigger EventName="SelectionChanged">
 | 
			
		||||
                    <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
			
		||||
                </i:EventTrigger>
 | 
			
		||||
            </i:Interaction.Triggers>
 | 
			
		||||
            <ListView.View>
 | 
			
		||||
                <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                    <GridViewColumn Width="110"
 | 
			
		||||
                        Header="请领ID"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PatientId}"/>
 | 
			
		||||
                    <GridViewColumn Width="130"
 | 
			
		||||
                        Header="请领数量"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PName}" />
 | 
			
		||||
                    <GridViewColumn Width="80"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Sex}"
 | 
			
		||||
                        Header="处方张数"/>
 | 
			
		||||
                    <GridViewColumn Width="80"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Age}"
 | 
			
		||||
                        Header="类型"/>
 | 
			
		||||
                    <GridViewColumn Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding IdNumber}"
 | 
			
		||||
                        Header="状态"/>
 | 
			
		||||
                    <GridViewColumn  Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding OrderNo}"
 | 
			
		||||
                        Header="申请人"/>
 | 
			
		||||
                    <GridViewColumn Width="240"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DeptName}"
 | 
			
		||||
                        Header="复核人"/>
 | 
			
		||||
                </GridView>
 | 
			
		||||
            </ListView.View>
 | 
			
		||||
        </ListView>
 | 
			
		||||
 | 
			
		||||
        <pagination:Pagination Grid.Row="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />-->
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,227 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.BindBoxPackageWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"  
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             MinWidth="880"
 | 
			
		||||
             MinHeight="615"
 | 
			
		||||
             Width="Auto"
 | 
			
		||||
             Height="Auto"
 | 
			
		||||
             mc:Ignorable="d">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
 | 
			
		||||
        <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        <!--<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
 | 
			
		||||
        <convert:QuantityCountConverter x:Key="QuantityCountConverter"/>-->
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <!--<Grid.RowDefinitions>
 | 
			
		||||
            -->
 | 
			
		||||
        <!--<RowDefinition/>-->
 | 
			
		||||
        <!--
 | 
			
		||||
            <RowDefinition/>
 | 
			
		||||
        </Grid.RowDefinitions>-->
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="Auto" />
 | 
			
		||||
            <ColumnDefinition Width="Auto" />
 | 
			
		||||
            <ColumnDefinition />
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
        <!--<Grid Grid.Row="0" Margin="0 4 0 4" Grid.ColumnSpan="3" >
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <StackPanel HorizontalAlignment="Right" Grid.Column="2" Orientation="Horizontal">
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="绑定库位"
 | 
			
		||||
                        Content="绑定套餐"
 | 
			
		||||
                        Command="{Binding BindingDrug}"/>
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="6 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="解除绑定"
 | 
			
		||||
                        Content="解绑"
 | 
			
		||||
                        Command="{Binding RemoveBinding}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新"
 | 
			
		||||
                        Command="{Binding Query}"
 | 
			
		||||
                        Content="{materialDesign:PackIcon Refresh}"/>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
        </Grid>-->
 | 
			
		||||
        <Grid Margin="6" Grid.Column="0" Width="300" Height="570">
 | 
			
		||||
            <Grid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="#00a0ea" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="#00a0ea" />
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsMouseOver" Value="True">
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                        <DataTrigger Value="True">
 | 
			
		||||
                            <DataTrigger.Binding>
 | 
			
		||||
                                <MultiBinding Converter="{StaticResource DrawerSelectConverter}">
 | 
			
		||||
                                    <Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
 | 
			
		||||
                                    <Binding Path="DrawerNo" />
 | 
			
		||||
                                </MultiBinding>
 | 
			
		||||
                            </DataTrigger.Binding>
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </DataTrigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </Grid.Resources>
 | 
			
		||||
            <!--<Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>-->
 | 
			
		||||
 | 
			
		||||
            <Grid>
 | 
			
		||||
                <Grid.RowDefinitions>
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                </Grid.RowDefinitions>
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
                <Button Grid.Row="0" Grid.Column="0" Width="120" Content="1号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
 | 
			
		||||
                <Button Grid.Row="1" Grid.Column="0" Width="120" Content="2号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
 | 
			
		||||
                <Button Grid.Row="2" Grid.Column="0" Width="120" Content="3号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
 | 
			
		||||
                <Button Grid.Row="3" Grid.Column="0" Width="120" Content="4号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
 | 
			
		||||
                <Button Grid.Row="4" Grid.Column="0" Width="120" Content="5号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
 | 
			
		||||
                <Button Grid.Row="5" Grid.Column="0" Width="120" Content="6号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
 | 
			
		||||
                <Button Grid.Row="6" Grid.Column="0" Width="120" Content="7号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
 | 
			
		||||
                <Button Grid.Row="7" Grid.Column="0" Width="120" Content="8号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
 | 
			
		||||
 | 
			
		||||
                <Button Grid.Row="8" Grid.Column="0" Width="120" Content="9号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="9" />
 | 
			
		||||
                <Button Grid.Row="9" Grid.Column="0" Width="120" Content="10号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="10" />
 | 
			
		||||
                <Button Grid.Row="0" Grid.Column="1" Width="120" Content="11号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="11" />
 | 
			
		||||
                <Button Grid.Row="1" Grid.Column="1" Width="120" Content="12号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="12" />
 | 
			
		||||
                <Button Grid.Row="2" Grid.Column="1" Width="120" Content="13号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="13" />
 | 
			
		||||
                <Button Grid.Row="3" Grid.Column="1" Width="120" Content="14号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="14" />
 | 
			
		||||
                <Button Grid.Row="4" Grid.Column="1" Width="120" Content="15号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="15" />
 | 
			
		||||
                <Button Grid.Row="5" Grid.Column="1" Width="120" Content="16号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="16" />
 | 
			
		||||
                <Button Grid.Row="6" Grid.Column="1" Width="120" Content="17号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="17" />
 | 
			
		||||
                <Button Grid.Row="7" Grid.Column="1" Width="120" Content="18号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="18" />
 | 
			
		||||
                <Button Grid.Row="8" Grid.Column="1" Width="120" Content="19号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="19" />
 | 
			
		||||
                <Button Grid.Row="9" Grid.Column="1" Width="120" Content="20号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="20" />
 | 
			
		||||
 | 
			
		||||
            </Grid>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Column="2" Margin="6">
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
 | 
			
		||||
                <ComboBox
 | 
			
		||||
                    Margin="0 0 6 0"
 | 
			
		||||
                    Grid.Column="0"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称/拼音码"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />
 | 
			
		||||
                <TextBox
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                Text="{Binding BaseQuantity}"
 | 
			
		||||
                materialDesign:HintAssist.Hint="药品基数"
 | 
			
		||||
                Margin="16 0 32 6" Width="100"
 | 
			
		||||
                Style="{StaticResource MaterialDesignTextBoxBase}"/>
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="6 0 6 6"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="绑定库位"
 | 
			
		||||
                        Content="绑定"
 | 
			
		||||
                        Command="{Binding BindingDrug}"/>
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="6 0 6 6"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="解绑"
 | 
			
		||||
                        Content="解绑"
 | 
			
		||||
                        Command="{Binding RemoveBinding}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="6 0 6 6"
 | 
			
		||||
                        ToolTip="打开药箱"
 | 
			
		||||
                        Content="打开全部药箱"
 | 
			
		||||
                        IsEnabled="{Binding IsEnable}"
 | 
			
		||||
                        Command="{Binding OpenBox}" 
 | 
			
		||||
                        materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                        materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="0 0 6 6"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新"
 | 
			
		||||
                        Command="{Binding Query}"
 | 
			
		||||
                        Content="{materialDesign:PackIcon Refresh}"/>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
            <ListView
 | 
			
		||||
                Padding="0 6 0 0" Grid.Row="1"
 | 
			
		||||
                ItemsSource="{Binding Channels, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"                
 | 
			
		||||
                SelectedItem="{Binding Channel}"
 | 
			
		||||
                materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
                materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                <ListView.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </ListView.Resources>
 | 
			
		||||
                <ListView.View>
 | 
			
		||||
                    <GridView>
 | 
			
		||||
                        <GridViewColumn Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DrugInfo.DrugName}"
 | 
			
		||||
                        Header="药品名称"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding BaseQuantity}"
 | 
			
		||||
                        Header="药品基数"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Quantity}"
 | 
			
		||||
                        Header="药品库存"/>
 | 
			
		||||
 | 
			
		||||
                </GridView>
 | 
			
		||||
               </ListView.View>
 | 
			
		||||
            </ListView>
 | 
			
		||||
            <materialDesign:Snackbar
 | 
			
		||||
                Background="{Binding SnackbarBackground}"
 | 
			
		||||
                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
			
		||||
        </Grid>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -17,17 +17,20 @@ using System.Windows.Shapes;
 | 
			
		|||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// AccountWindow.xaml 的交互逻辑
 | 
			
		||||
    /// BindBoxPackageWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class AccountWindow : UserControl
 | 
			
		||||
    public partial class BindBoxPackageWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        AccountWindowViewModel vms;
 | 
			
		||||
        public AccountWindow()
 | 
			
		||||
 | 
			
		||||
        BindBoxPackageWindowViewModel vms;
 | 
			
		||||
        public BindBoxPackageWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
 | 
			
		||||
            vms = BindBoxPackageWindowViewModel.vm;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品名称下拉框
 | 
			
		||||
        /// 药品名称触发事件
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="sender"></param>
 | 
			
		||||
        /// <param name="e"></param>
 | 
			
		||||
| 
						 | 
				
			
			@ -42,10 +45,5 @@ namespace DM_Weight.Views
 | 
			
		|||
            TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
 | 
			
		||||
            textBox.SelectionStart = textBox.Text.Length;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            vms = AccountWindowViewModel.vm;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,136 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.ChangeShiftsListWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
        <convert:ShiftsStateConverter x:Key="ShiftsStateConverter"/>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="1.5*" />
 | 
			
		||||
                <ColumnDefinition Width="1.5*" />
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="5*"/>
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <DatePicker
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                SelectedDate="{Binding StartDate, TargetNullValue=''}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="开始时间"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
			
		||||
            />
 | 
			
		||||
            <DatePicker
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                SelectedDate="{Binding EndDate}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="结束时间"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
			
		||||
            />
 | 
			
		||||
 | 
			
		||||
            <StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    ToolTip="导出" Command="{Binding Download}">
 | 
			
		||||
                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                        <materialDesign:PackIcon Kind="download" />
 | 
			
		||||
                        <TextBlock Text="导出记录" />
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    ToolTip="交接班" Command="{Binding ShiftsCommand}">
 | 
			
		||||
                    <StackPanel Orientation="Horizontal">
 | 
			
		||||
                        <materialDesign:PackIcon Kind="CompareVertical" />
 | 
			
		||||
                        <TextBlock Text="交接班" />
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <ListView Grid.Row="1" ItemsSource="{Binding HkcChangeShifts}" 
 | 
			
		||||
                materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
 | 
			
		||||
            <ListView.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                </Style>
 | 
			
		||||
            </ListView.Resources>
 | 
			
		||||
            <ListView.View>
 | 
			
		||||
                <GridView  ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                    <GridViewColumn  Width="180"
 | 
			
		||||
                        Header="日期"
 | 
			
		||||
                        DisplayMemberBinding="{Binding OptDate, StringFormat='yyyy-MM-dd HH:mm:ss'}" />
 | 
			
		||||
                    <GridViewColumn  Width="130"
 | 
			
		||||
                        DisplayMemberBinding="{Binding FromOperator}"
 | 
			
		||||
                        Header="交班人发药人"/>
 | 
			
		||||
                    <GridViewColumn  Width="130"
 | 
			
		||||
                        DisplayMemberBinding="{Binding FromRviewer}"
 | 
			
		||||
                        Header="交班人审核人"/>
 | 
			
		||||
                    <GridViewColumn  Width="130"
 | 
			
		||||
                        DisplayMemberBinding="{Binding ToOperator}"
 | 
			
		||||
                        Header="接班人发药人"/>
 | 
			
		||||
                    <GridViewColumn  Width="130"
 | 
			
		||||
                        DisplayMemberBinding="{Binding ToReviewer}"
 | 
			
		||||
                        Header="接班人审核人"/>
 | 
			
		||||
                    <GridViewColumn  Width="180"
 | 
			
		||||
                        DisplayMemberBinding="{Binding ToDate, StringFormat='yyyy-MM-dd HH:mm:ss'}"
 | 
			
		||||
                        Header="接班日期"/>
 | 
			
		||||
                    <GridViewColumn  Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding State,Converter={StaticResource ShiftsStateConverter}}"
 | 
			
		||||
                        Header="当班状态"/>
 | 
			
		||||
                </GridView>
 | 
			
		||||
            </ListView.View>
 | 
			
		||||
        </ListView>
 | 
			
		||||
 | 
			
		||||
        <pagination:Pagination Grid.Row="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ChangeShiftsListWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class ChangeShiftsListWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public ChangeShiftsListWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,240 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.CheckOrderNewWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:OrderStatusConverter x:Key="OrderStatusConverter" />
 | 
			
		||||
        <convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
 | 
			
		||||
        <convert:BoxNumConverter x:Key="BoxNumConverter" />
 | 
			
		||||
        <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="Auto"/>
 | 
			
		||||
            <ColumnDefinition Width="*"/>
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
        <Grid  Margin="6" Grid.Column="0">
 | 
			
		||||
            <Grid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="#00a0ea" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="#00a0ea" />
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsMouseOver" Value="True">
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                        <DataTrigger Value="True">
 | 
			
		||||
                            <DataTrigger.Binding>
 | 
			
		||||
                                <MultiBinding Converter="{StaticResource DrawerSelectConverter}">
 | 
			
		||||
                                    <Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
 | 
			
		||||
                                    <Binding Path="DrawerNo" />
 | 
			
		||||
                                </MultiBinding>
 | 
			
		||||
                            </DataTrigger.Binding>
 | 
			
		||||
                            <Setter Property="Background" Value="#d1e7f5" />
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="#d1e7f5" />
 | 
			
		||||
                        </DataTrigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </Grid.Resources>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="0" Grid.Column="0" Width="120" Content="1号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="1" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=1}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="1" Grid.Column="0" Width="120" Content="2号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="2" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=2}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="2" Grid.Column="0" Width="120" Content="3号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="3" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=3}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="3" Grid.Column="0" Width="120" Content="4号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="4" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=4}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="4" Grid.Column="0" Width="120" Content="5号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="5" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=5}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="5" Grid.Column="0" Width="120" Content="6号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="6" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=6}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="6" Grid.Column="0" Width="120" Content="7号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="7" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=7}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="7" Grid.Column="0" Width="120" Content="8号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="8" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=8}"/>
 | 
			
		||||
                   
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="8" Grid.Column="0" Width="120" Content="9号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="9"   IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=9}"/>
 | 
			
		||||
            <Button Margin="0 0  3 0" Grid.Row="9" Grid.Column="0" Width="120" Content="10号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="10" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=10}"/>
 | 
			
		||||
            
 | 
			
		||||
            <Button Grid.Row="0" Grid.Column="1" Width="120" Content="11号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="11" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=11}"/>
 | 
			
		||||
            <Button Grid.Row="1" Grid.Column="1" Width="120" Content="12号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="12" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=12}"/>
 | 
			
		||||
            <Button Grid.Row="2" Grid.Column="1" Width="120" Content="13号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="13" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=13}"/>
 | 
			
		||||
            <Button Grid.Row="3" Grid.Column="1" Width="120" Content="14号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="14" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=14}"/>
 | 
			
		||||
            <Button Grid.Row="4" Grid.Column="1" Width="120" Content="15号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="15" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=15}"/>
 | 
			
		||||
            <Button Grid.Row="5" Grid.Column="1" Width="120" Content="16号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="16" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=16}"/>
 | 
			
		||||
            <Button Grid.Row="6" Grid.Column="1" Width="120" Content="17号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="17" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=17}"/>
 | 
			
		||||
            <Button Grid.Row="7" Grid.Column="1" Width="120" Content="18号药箱" Command="{Binding UpdateDrawerNo}" CommandParameter="18" IsEnabled="{Binding DrawerNo, Converter={StaticResource BoxNumConverter}, ConverterParameter=18}"/>
 | 
			
		||||
            <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}"/>
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Column="1" Margin="6">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="Auto"/>
 | 
			
		||||
                <ColumnDefinition Width="Auto"/>                
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto"/>
 | 
			
		||||
                <RowDefinition Height="Auto"/>
 | 
			
		||||
                <RowDefinition Height="Auto"/>
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Margin="0 6 0 6" Grid.Row="0" Grid.ColumnSpan="2">
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition Width="2*" />
 | 
			
		||||
                    <ColumnDefinition Width="8*" />
 | 
			
		||||
                    <ColumnDefinition Width="5*" />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
                <DatePicker
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                SelectedDateFormat="Short"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="开方日期"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
			
		||||
 | 
			
		||||
                <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        VerticalAlignment="Center" Command="{Binding CheckOrder}"
 | 
			
		||||
                        Content="确认"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}">
 | 
			
		||||
                    </Button>
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        VerticalAlignment="Center"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                        <materialDesign:PackIcon Kind="Refresh" />
 | 
			
		||||
                    </Button>
 | 
			
		||||
                </StackPanel>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid 
 | 
			
		||||
            Grid.Row="1" Grid.Column="0" Margin="0 0 6 0">
 | 
			
		||||
            <ListView
 | 
			
		||||
            ItemsSource="{Binding OrderInfoList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
 | 
			
		||||
            SelectedItem="{Binding selectOrderInfo}"
 | 
			
		||||
            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                <ListView.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </ListView.Resources>
 | 
			
		||||
                <i:Interaction.Triggers>
 | 
			
		||||
                    <i:EventTrigger EventName="SelectionChanged">
 | 
			
		||||
                        <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
			
		||||
                    </i:EventTrigger>
 | 
			
		||||
                </i:Interaction.Triggers>
 | 
			
		||||
                <ListView.View>
 | 
			
		||||
                    <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                        <GridViewColumn Header="选择" Width="50">
 | 
			
		||||
                            <GridViewColumn.CellTemplate>
 | 
			
		||||
                                <DataTemplate>
 | 
			
		||||
                                    <CheckBox IsChecked="{Binding ItemIsChecked}" />
 | 
			
		||||
                                </DataTemplate>
 | 
			
		||||
                            </GridViewColumn.CellTemplate>
 | 
			
		||||
                        </GridViewColumn>
 | 
			
		||||
                        <!--<GridViewColumn Width="100"
 | 
			
		||||
                        Header="患者ID"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PatientId}"/>-->
 | 
			
		||||
                        <GridViewColumn Width="80"
 | 
			
		||||
                        Header="姓名"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PName}" />
 | 
			
		||||
                        <GridViewColumn Width="30"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Sex}"
 | 
			
		||||
                        Header="性别"/>
 | 
			
		||||
                        <!--<GridViewColumn Width="50"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Age}"
 | 
			
		||||
                        Header="年龄"/>
 | 
			
		||||
                        <GridViewColumn Width="180"
 | 
			
		||||
                        DisplayMemberBinding="{Binding IdNumber}"
 | 
			
		||||
                        Header="身份证"/>-->
 | 
			
		||||
                        <GridViewColumn  Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding OrderNo}"
 | 
			
		||||
                        Header="处方号"/>
 | 
			
		||||
                        <!--<GridViewColumn Width="240"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DeptName}"
 | 
			
		||||
                        Header="科室"/>-->
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding _OrderDetail.DrugInfo.DrugName}"
 | 
			
		||||
                        Header="药品名称"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding  _OrderDetail.SetManuNo}"
 | 
			
		||||
                        Header="药品批次"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        DisplayMemberBinding="{Binding  _OrderDetail.SetEffDate}"
 | 
			
		||||
                        Header="药品效期"/>
 | 
			
		||||
                        <GridViewColumn Width="30"
 | 
			
		||||
                        DisplayMemberBinding="{Binding _OrderDetail.Quantity}"
 | 
			
		||||
                        Header="数量"/>
 | 
			
		||||
                    </GridView>
 | 
			
		||||
                </ListView.View>
 | 
			
		||||
            </ListView>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid Grid.Column="1" Grid.Row="1" Margin="6 0 0 0" HorizontalAlignment="Right">
 | 
			
		||||
                <ListView ItemsSource="{Binding TotalDrugList,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
 | 
			
		||||
                          materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
                          materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
                          materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                    <ListView.Resources>
 | 
			
		||||
                        <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                            <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                        </Style>
 | 
			
		||||
                    </ListView.Resources>
 | 
			
		||||
                    <ListView.View>
 | 
			
		||||
                        <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                            <GridViewColumn Width="100"
 | 
			
		||||
                                DisplayMemberBinding="{Binding DrugName}"
 | 
			
		||||
                                Header="药品名称"/>
 | 
			
		||||
                            <GridViewColumn Width="30"
 | 
			
		||||
                                DisplayMemberBinding="{Binding TotalCount}"
 | 
			
		||||
                                Header="合计数量"/>
 | 
			
		||||
                        </GridView>
 | 
			
		||||
                    </ListView.View>
 | 
			
		||||
                </ListView>
 | 
			
		||||
            </Grid>
 | 
			
		||||
 | 
			
		||||
            <pagination:Pagination Grid.Row="2" Grid.Column="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />
 | 
			
		||||
        </Grid>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -16,11 +16,11 @@ using System.Windows.Shapes;
 | 
			
		|||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ApplyInStockWindow.xaml 的交互逻辑
 | 
			
		||||
    /// CheckOrderNewWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class ApplyInStockWindow : UserControl
 | 
			
		||||
    public partial class CheckOrderNewWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public ApplyInStockWindow()
 | 
			
		||||
        public CheckOrderNewWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,207 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.CheckOrderWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter" 
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.Resources>
 | 
			
		||||
            <!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding OrderDetailList}">
 | 
			
		||||
                <CollectionViewSource.GroupDescriptions>
 | 
			
		||||
                    <PropertyGroupDescription PropertyName="_OrderInfo" />
 | 
			
		||||
                </CollectionViewSource.GroupDescriptions>
 | 
			
		||||
            </CollectionViewSource>-->
 | 
			
		||||
            <convert:GroupSumConverter x:Key="GroupSumConverter" />
 | 
			
		||||
            <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        </Grid.Resources>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition  Height="Auto" />
 | 
			
		||||
            <RowDefinition/>
 | 
			
		||||
            <RowDefinition  Height="Auto"/>
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="2*" />
 | 
			
		||||
                <ColumnDefinition Width="3*" />
 | 
			
		||||
                <ColumnDefinition Width="5*"/>
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <DatePicker
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                SelectedDateFormat="Short"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                materialDesign:HintAssist.Hint="开方日期"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
			
		||||
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button
 | 
			
		||||
                    Margin="6 0 16 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    IsEnabled="{Binding BtnEnable}"
 | 
			
		||||
                    Command="{Binding ConfirmCommand}"
 | 
			
		||||
                    Content="确认"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"/>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <DataGrid
 | 
			
		||||
                Grid.Row="1"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
			
		||||
                ItemsSource="{Binding OrderDetailList}"
 | 
			
		||||
                SelectedItem="SelectDrugPleaseClaim"
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                IsSynchronizedWithCurrentItem="True"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False">
 | 
			
		||||
            <DataGrid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                    <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                    <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                    <Setter Property="Height" Value="56" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                    <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
                </Style>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                            <Setter Property="HorizontalAlignment" Value="Left"/>
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </DataGrid.Resources>
 | 
			
		||||
            <!--GroupStyle to group data-->
 | 
			
		||||
            <DataGrid.GroupStyle>
 | 
			
		||||
                <GroupStyle>
 | 
			
		||||
                    <!--Group DataItems into DataGroup-->
 | 
			
		||||
                    <GroupStyle.ContainerStyle>
 | 
			
		||||
                        <Style TargetType="{x:Type GroupItem}">
 | 
			
		||||
                            <Setter Property="Template">
 | 
			
		||||
                                <Setter.Value>
 | 
			
		||||
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
 | 
			
		||||
                                        <Expander IsExpanded="True"
 | 
			
		||||
                                                  materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
 | 
			
		||||
                                            <Expander.Header >
 | 
			
		||||
 | 
			
		||||
                                                <StackPanel Orientation="Horizontal">
 | 
			
		||||
                                                    <CheckBox IsChecked="{Binding Path=Name.ItemIsChecked}" FontSize="24" />
 | 
			
		||||
                                                    <TextBlock Text="{Binding Path=Name.OrderNo,StringFormat=处方号:{0},}" FontWeight="Bold" />
 | 
			
		||||
                                                    <TextBlock Text="{Binding Path=Name.PatientId,StringFormat=患者ID:{0},}" FontWeight="Bold" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.PName,StringFormat=姓名:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.Sex,StringFormat=性别:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.Age,StringFormat=年龄:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Name.IdNumber,StringFormat=身份证:{0},}" />
 | 
			
		||||
                                                    <TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />
 | 
			
		||||
 | 
			
		||||
                                                </StackPanel>
 | 
			
		||||
                                            </Expander.Header>
 | 
			
		||||
                                            <ItemsPresenter/>
 | 
			
		||||
                                        </Expander>
 | 
			
		||||
                                    </ControlTemplate>
 | 
			
		||||
                                </Setter.Value>
 | 
			
		||||
                            </Setter>
 | 
			
		||||
                        </Style>
 | 
			
		||||
                    </GroupStyle.ContainerStyle>
 | 
			
		||||
 | 
			
		||||
                </GroupStyle>
 | 
			
		||||
            </DataGrid.GroupStyle>
 | 
			
		||||
            <DataGrid.Columns>
 | 
			
		||||
                <DataGridTextColumn Width="180"
 | 
			
		||||
                        Binding="{Binding DrugInfo.DrugName}"
 | 
			
		||||
                        Header="药品名称"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="130"
 | 
			
		||||
                        Binding="{Binding DrugInfo.DrugSpec}"
 | 
			
		||||
                        Header="规格"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="241"
 | 
			
		||||
                        Binding="{Binding DrugInfo.Manufactory}"
 | 
			
		||||
                        Header="厂家"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="241"
 | 
			
		||||
                        Binding="{Binding SetManuNo}"
 | 
			
		||||
                        Header="批次"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="241"
 | 
			
		||||
                        Binding="{Binding SetEffDate}"
 | 
			
		||||
                        Header="效期"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
                <DataGridTextColumn Width="241"
 | 
			
		||||
                        Binding="{Binding Quantity}"
 | 
			
		||||
                        Header="数量"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
 | 
			
		||||
                <!--<DataGridTemplateColumn Header="批次" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding SetManuNo}" DisplayMemberPath="SetManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
 | 
			
		||||
                <DataGridTemplateColumn Header="效期" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding SetEffDate}" DisplayMemberPath="SetManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
 | 
			
		||||
                <DataGridTemplateColumn Header="数量" IsReadOnly="True">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ListBox ItemsSource="{Binding Quantity}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>-->
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            </DataGrid.Columns>
 | 
			
		||||
        </DataGrid>
 | 
			
		||||
        <!--<pagination:Pagination Grid.Row="2" Grid.ColumnSpan="3"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />-->
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -16,11 +16,11 @@ using System.Windows.Shapes;
 | 
			
		|||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ApplyListWindow.xaml 的交互逻辑
 | 
			
		||||
    /// CheckOrderWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class ApplyListWindow : UserControl
 | 
			
		||||
    public partial class CheckOrderWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public ApplyListWindow()
 | 
			
		||||
        public CheckOrderWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,140 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.CollectDrugWindow"
 | 
			
		||||
              xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:OrderStatusConverter x:Key="OrderStatusConverter" />
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition /> 
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition Width="110" />
 | 
			
		||||
                <ColumnDefinition Width="180" />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                Grid.Column="0"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                SelectedItem="{Binding SelectedItem}"
 | 
			
		||||
                DisplayMemberPath="Name"
 | 
			
		||||
                ItemsSource="{Binding Selects}"
 | 
			
		||||
                />
 | 
			
		||||
            <TextBox
 | 
			
		||||
                Grid.Column="1"
 | 
			
		||||
                Text="{Binding SearchValue}"
 | 
			
		||||
                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
			
		||||
                Margin="6 0 0 0"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
			
		||||
 | 
			
		||||
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                ToolTip="刷新" Command="{Binding Query}">
 | 
			
		||||
                    <materialDesign:PackIcon
 | 
			
		||||
                    Kind="Refresh" />
 | 
			
		||||
                </Button>
 | 
			
		||||
 | 
			
		||||
                <Button
 | 
			
		||||
                Margin="0 0 6 0"
 | 
			
		||||
                VerticalAlignment="Center" Command="{Binding CreateApplyOrder}"
 | 
			
		||||
                Style="{StaticResource MaterialDesignOutlinedLightButton}" Content="生成请领单"> 
 | 
			
		||||
                </Button>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <ListView
 | 
			
		||||
            Grid.Row="1"
 | 
			
		||||
            ItemsSource="{Binding CollectDrugs}"
 | 
			
		||||
            SelectedItem="{Binding selectCollectDrug}"
 | 
			
		||||
            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
            <ListView.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                    <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                </Style>
 | 
			
		||||
            </ListView.Resources>
 | 
			
		||||
            <i:Interaction.Triggers>
 | 
			
		||||
                <i:EventTrigger EventName="SelectionChanged">
 | 
			
		||||
                    <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
			
		||||
                </i:EventTrigger>
 | 
			
		||||
            </i:Interaction.Triggers>
 | 
			
		||||
            <ListView.View>
 | 
			
		||||
                <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                    <GridViewColumn Header="选择" Width="60">
 | 
			
		||||
                        <GridViewColumn.CellTemplate>
 | 
			
		||||
                            <DataTemplate>
 | 
			
		||||
                                <CheckBox IsChecked="{Binding IsSelected}" />
 | 
			
		||||
                            </DataTemplate>
 | 
			
		||||
                        </GridViewColumn.CellTemplate>
 | 
			
		||||
                    </GridViewColumn>
 | 
			
		||||
                    <GridViewColumn Width="110"
 | 
			
		||||
                        Header="患者ID"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PatientId}"/>
 | 
			
		||||
                    <GridViewColumn Width="130"
 | 
			
		||||
                        Header="姓名"
 | 
			
		||||
                        DisplayMemberBinding="{Binding PName}" />
 | 
			
		||||
                    <GridViewColumn Width="60"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Sex}"
 | 
			
		||||
                        Header="性别"/>
 | 
			
		||||
                    <GridViewColumn Width="60"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Age}"
 | 
			
		||||
                        Header="年龄"/>
 | 
			
		||||
                    <GridViewColumn Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding IdNumber}"
 | 
			
		||||
                        Header="身份证"/>
 | 
			
		||||
                    <GridViewColumn  Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding OrderNo}"
 | 
			
		||||
                        Header="处方号"/>
 | 
			
		||||
                    <!--<GridViewColumn Width="240"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DeptName}"
 | 
			
		||||
                        Header="科室"/>-->
 | 
			
		||||
                    <GridViewColumn Width="240"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DrugName}"
 | 
			
		||||
                        Header="药品名称"/>
 | 
			
		||||
                    <GridViewColumn Width="60"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Quantity}"
 | 
			
		||||
                        Header="数量"/>
 | 
			
		||||
                </GridView>
 | 
			
		||||
            </ListView.View>
 | 
			
		||||
        </ListView> 
 | 
			
		||||
 | 
			
		||||
        <!--<pagination:Pagination Grid.Row="2"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />-->
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// CollectDrugWindow.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class CollectDrugWindow : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public CollectDrugWindow()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,23 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.DebugWindow"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             mc:Ignorable="d">
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <materialDesign:Card>
 | 
			
		||||
            <TabControl TabStripPlacement="Left" Style="{StaticResource MaterialDesignFilledTabControl}">
 | 
			
		||||
                <TabItem Header="数据库">
 | 
			
		||||
                    <TextBlock Margin="8" Text="Not filled example tab 1" />
 | 
			
		||||
                </TabItem>
 | 
			
		||||
                <TabItem Header="串口">
 | 
			
		||||
                    <TextBlock Margin="8" Text="No filled example tab 2" />
 | 
			
		||||
                </TabItem>
 | 
			
		||||
            </TabControl>
 | 
			
		||||
        </materialDesign:Card>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,130 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.Dialog.BindBoxDialog"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             MinWidth="880"
 | 
			
		||||
             MinHeight="615"
 | 
			
		||||
             Width="Auto"
 | 
			
		||||
             Height="Auto"
 | 
			
		||||
             mc:Ignorable="d">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:BoardTypeConverter x:Key="BoardTypeConverter" />
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid Background="#03a9f4" Grid.Row="0">
 | 
			
		||||
            <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
            <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭" Cursor="Hand"
 | 
			
		||||
                    >
 | 
			
		||||
                <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
            </Button>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Row="1" Margin="0 4 0 4">
 | 
			
		||||
            <Grid.ColumnDefinitions>
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
                <ColumnDefinition />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="0"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称/拼音码"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />
 | 
			
		||||
            <StackPanel HorizontalAlignment="Right"  Grid.Column="2" Orientation="Horizontal">
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="绑定库位"
 | 
			
		||||
                        Content="添加"
 | 
			
		||||
                        Command="{Binding BindingDrug}"/>
 | 
			
		||||
                <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新"
 | 
			
		||||
                        Command="{Binding Query}"
 | 
			
		||||
                        Content="{materialDesign:PackIcon Refresh}"/>
 | 
			
		||||
            </StackPanel>
 | 
			
		||||
        </Grid>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        <DataGrid
 | 
			
		||||
                Padding="0 6 0 0" Grid.Row="1"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
			
		||||
                ItemsSource="{Binding Channels}"
 | 
			
		||||
                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
			
		||||
                materialDesign:DataGridAssist.CellPadding="13"
 | 
			
		||||
                SelectionUnit="Cell"
 | 
			
		||||
                CanUserAddRows="False"
 | 
			
		||||
                AutoGenerateColumns="False">
 | 
			
		||||
            <DataGrid.Resources>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
			
		||||
                    <Setter Property="Background" Value="#31ccec" />
 | 
			
		||||
                    <Setter Property="Foreground" Value="white" />
 | 
			
		||||
                    <Setter Property="Height" Value="56" />
 | 
			
		||||
                    <Setter Property="BorderBrush" Value="white"/>
 | 
			
		||||
                    <Setter Property="BorderThickness" Value="0.6"/>
 | 
			
		||||
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
			
		||||
 | 
			
		||||
                </Style>
 | 
			
		||||
                <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
			
		||||
                    <Style.Triggers>
 | 
			
		||||
                        <Trigger Property="IsReadOnly" Value="True">
 | 
			
		||||
                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
			
		||||
                            <Setter Property="HorizontalAlignment" Value="Center"/>
 | 
			
		||||
                        </Trigger>
 | 
			
		||||
                    </Style.Triggers>
 | 
			
		||||
                </Style>
 | 
			
		||||
            </DataGrid.Resources>
 | 
			
		||||
            <DataGrid.Columns>
 | 
			
		||||
                <DataGridTemplateColumn Width="200" IsReadOnly="True"
 | 
			
		||||
                        Header="药品名称">
 | 
			
		||||
                    <DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                        <DataTemplate>
 | 
			
		||||
                            <ComboBox
 | 
			
		||||
                                    Style="{StaticResource MaterialDesignDataGridComboBox}"                  
 | 
			
		||||
                                    ItemsSource="{Binding drugInfoList}"
 | 
			
		||||
                                    SelectedItem="{Binding DrugName,UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                                    DisplayMemberPath="ManuNo" 
 | 
			
		||||
                                    IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            </ComboBox>
 | 
			
		||||
                        </DataTemplate>
 | 
			
		||||
                    </DataGridTemplateColumn.CellTemplate>
 | 
			
		||||
                </DataGridTemplateColumn>
 | 
			
		||||
                <DataGridTextColumn Width="100"
 | 
			
		||||
                        Binding="{Binding DrugInfos.drugBase.BaseQuantity}"
 | 
			
		||||
                        Header="药品基数"
 | 
			
		||||
                        IsReadOnly="True"
 | 
			
		||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
			
		||||
 | 
			
		||||
            </DataGrid.Columns>
 | 
			
		||||
        </DataGrid>
 | 
			
		||||
 | 
			
		||||
        <materialDesign:Snackbar
 | 
			
		||||
                Background="{Binding SnackbarBackground}"
 | 
			
		||||
                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -17,15 +17,15 @@ using System.Windows.Shapes;
 | 
			
		|||
namespace DM_Weight.Views.Dialog
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// BindingChannelNewDialog.xaml 的交互逻辑
 | 
			
		||||
    /// BindBoxDialog.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class BindingChannelNewDialog : UserControl
 | 
			
		||||
    public partial class BindBoxDialog : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        BindingChannelNewDialogViewModel vms;
 | 
			
		||||
        public BindingChannelNewDialog()
 | 
			
		||||
        BindBoxDialogViewModel vms;
 | 
			
		||||
        public BindBoxDialog()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            vms = BindingChannelNewDialogViewModel.vm;
 | 
			
		||||
            vms = BindBoxDialogViewModel.vm;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品名称触发事件
 | 
			
		||||
| 
						 | 
				
			
			@ -1,207 +0,0 @@
 | 
			
		|||
<UserControl xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"  x:Class="DM_Weight.Views.Dialog.BindingChannelDialog"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             MinWidth="880"
 | 
			
		||||
             MinHeight="615"
 | 
			
		||||
             Width="Auto"
 | 
			
		||||
             Height="Auto"
 | 
			
		||||
             mc:Ignorable="d" >
 | 
			
		||||
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:BoardTypeConverter x:Key="BoardTypeConverter" />
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
 | 
			
		||||
        <Grid>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Background="#03a9f4" Grid.Row="0">
 | 
			
		||||
                <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭" Cursor="Hand"
 | 
			
		||||
                    >
 | 
			
		||||
                    <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid Grid.Row="1" Margin="0 4 0 4">
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="0"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称/拼音码"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Grid.Column="1"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="批次"
 | 
			
		||||
                    ItemsSource="{Binding DrugManuNos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugManuNo}"
 | 
			
		||||
                    DisplayMemberPath="ManuNo"/>
 | 
			
		||||
                <StackPanel HorizontalAlignment="Right"  Grid.Column="2" Orientation="Horizontal">
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="绑定库位"
 | 
			
		||||
                        Content="绑定"
 | 
			
		||||
                        Command="{Binding BindingDrug}"/>
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="6 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="解除绑定"
 | 
			
		||||
                        Content="解绑"
 | 
			
		||||
                        Command="{Binding RemoveBinding}" />
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新"
 | 
			
		||||
                        Command="{Binding Query}"
 | 
			
		||||
                        Content="{materialDesign:PackIcon Refresh}"/>
 | 
			
		||||
                </StackPanel>
 | 
			
		||||
            </Grid>
 | 
			
		||||
        <ItemsControl
 | 
			
		||||
                Grid.Row="2"
 | 
			
		||||
                ItemsSource="{Binding Channels}"
 | 
			
		||||
                Grid.IsSharedSizeScope="True"
 | 
			
		||||
                Margin="12 0 12 0">
 | 
			
		||||
            <ItemsControl.ItemsPanel>
 | 
			
		||||
                <ItemsPanelTemplate>
 | 
			
		||||
                    <UniformGrid />
 | 
			
		||||
                </ItemsPanelTemplate>
 | 
			
		||||
            </ItemsControl.ItemsPanel>
 | 
			
		||||
            <ItemsControl.ItemTemplate>
 | 
			
		||||
                <DataTemplate>
 | 
			
		||||
                    <materialDesign:Card
 | 
			
		||||
                                Background="{StaticResource MaterialDesignLightBackground}"
 | 
			
		||||
                                Margin="4"
 | 
			
		||||
                                Padding="0">
 | 
			
		||||
                        <Grid>
 | 
			
		||||
                            <Grid.RowDefinitions>
 | 
			
		||||
                                <RowDefinition />
 | 
			
		||||
                                <RowDefinition />
 | 
			
		||||
                            </Grid.RowDefinitions>
 | 
			
		||||
                            <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#31ccec" >
 | 
			
		||||
                                <CheckBox
 | 
			
		||||
                                        materialDesign:CheckBoxAssist.CheckBoxSize="30"
 | 
			
		||||
                                        VerticalAlignment="Center"
 | 
			
		||||
                                        IsChecked="{Binding IsSelected}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        Style="{StaticResource MaterialDesignHeadline5TextBlock}"
 | 
			
		||||
                                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                                        Padding="8"
 | 
			
		||||
                                        Text="{Binding Location}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        Style="{StaticResource MaterialDesignHeadline5TextBlock}"
 | 
			
		||||
                                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                                        Padding="8"
 | 
			
		||||
                                        HorizontalAlignment="Right">
 | 
			
		||||
                                    <TextBlock.Text>
 | 
			
		||||
                                        <MultiBinding Converter="{StaticResource BoardTypeConverter}">
 | 
			
		||||
                                            <Binding Path="BoardType" />
 | 
			
		||||
                                            <Binding Path="DrawerType" />
 | 
			
		||||
                                        </MultiBinding>
 | 
			
		||||
                                    </TextBlock.Text>
 | 
			
		||||
                                </TextBlock>
 | 
			
		||||
                            </StackPanel>
 | 
			
		||||
                            <Grid Grid.Row="1" x:Name="Border">
 | 
			
		||||
                                <Grid.RowDefinitions>
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                </Grid.RowDefinitions>
 | 
			
		||||
                                <Grid.ColumnDefinitions>
 | 
			
		||||
                                    <ColumnDefinition Width="Auto" />
 | 
			
		||||
                                    <ColumnDefinition />
 | 
			
		||||
                                </Grid.ColumnDefinitions>
 | 
			
		||||
                                <Grid.Resources>
 | 
			
		||||
                                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignSubtitle1TextBlock}">
 | 
			
		||||
                                        <Setter Property="Padding" Value="6" />
 | 
			
		||||
                                    </Style>
 | 
			
		||||
                                </Grid.Resources>
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="药品:" />
 | 
			
		||||
                                <StackPanel
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Orientation="Horizontal">
 | 
			
		||||
                                    <TextBlock Text="{Binding DrugInfo.DrugName}" />
 | 
			
		||||
                                    <TextBlock
 | 
			
		||||
                                            Visibility="{Binding Quantity, Converter={StaticResource NotZeroToVisibilityConverter}}"
 | 
			
		||||
                                            Text="{Binding Quantity, StringFormat=({0})}" />
 | 
			
		||||
                                </StackPanel>
 | 
			
		||||
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="批次:" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        Text="{Binding ManuNo}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="2"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="效期:" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="2"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        Text="{Binding EffDate}" />
 | 
			
		||||
                            </Grid>
 | 
			
		||||
                        </Grid>
 | 
			
		||||
                    </materialDesign:Card>
 | 
			
		||||
                    <DataTemplate.Triggers>
 | 
			
		||||
                        <DataTrigger Binding="{Binding IsSelected}" Value="True">
 | 
			
		||||
                            <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
 | 
			
		||||
                            <Setter TargetName="Border" Property="Background" Value="#90caf9" />
 | 
			
		||||
                            <Setter Property="RenderTransform">
 | 
			
		||||
                                <Setter.Value>
 | 
			
		||||
                                    <ScaleTransform  ScaleX="0.95" ScaleY="0.95" />
 | 
			
		||||
                                </Setter.Value>
 | 
			
		||||
                            </Setter>
 | 
			
		||||
                        </DataTrigger>
 | 
			
		||||
                    </DataTemplate.Triggers>
 | 
			
		||||
                </DataTemplate>
 | 
			
		||||
            </ItemsControl.ItemTemplate>
 | 
			
		||||
        </ItemsControl>
 | 
			
		||||
 | 
			
		||||
        <pagination:Pagination Grid.Row="3"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />
 | 
			
		||||
        <materialDesign:Snackbar
 | 
			
		||||
                Background="{Binding SnackbarBackground}"
 | 
			
		||||
                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
			
		||||
        </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,47 +0,0 @@
 | 
			
		|||
using DM_Weight.ViewModels;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views.Dialog
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// BindingChannelDialog.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class BindingChannelDialog : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        BindingChannelDialogViewModel vms;
 | 
			
		||||
        public BindingChannelDialog()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            vms = BindingChannelDialogViewModel.vm;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 药品名称触发事件
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="sender"></param>
 | 
			
		||||
        /// <param name="e"></param>
 | 
			
		||||
        private void ComboBox_KeyUp(object sender, KeyEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            ComboBox comboBox = sender as ComboBox;
 | 
			
		||||
            vms.UpdateComboBoxItems(comboBox.Text);
 | 
			
		||||
            if(this.vms.DrugInfos.Count>0)
 | 
			
		||||
            {
 | 
			
		||||
                comboBox.IsDropDownOpen= true;
 | 
			
		||||
            }
 | 
			
		||||
            TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
 | 
			
		||||
            textBox.SelectionStart = textBox.Text.Length;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,230 +0,0 @@
 | 
			
		|||
<UserControl xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"  x:Class="DM_Weight.Views.Dialog.BindingChannelNewDialog"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             MinWidth="880"
 | 
			
		||||
             MinHeight="479"
 | 
			
		||||
             Width="Auto"
 | 
			
		||||
             Height="Auto"
 | 
			
		||||
             mc:Ignorable="d" >
 | 
			
		||||
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:BoardTypeConverter x:Key="BoardTypeConverter" />
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
 | 
			
		||||
        <Grid>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <!--<RowDefinition Height="Auto" />-->
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Background="#03a9f4" Grid.Row="0">
 | 
			
		||||
                <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭" Cursor="Hand"
 | 
			
		||||
                    >
 | 
			
		||||
                    <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid Grid.Row="1" Margin="0 4 0 4">
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
            <!--<ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="0"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="拼音码"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos_PY}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo_Py}"
 | 
			
		||||
                    DisplayMemberPath="PyCode"
 | 
			
		||||
                />
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="1"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName"
 | 
			
		||||
                />-->
 | 
			
		||||
            <ComboBox
 | 
			
		||||
                    Margin="6 0 6 0"
 | 
			
		||||
                    Grid.Column="0"
 | 
			
		||||
                    materialDesign:HintAssist.Hint="药品名称/拼音码"
 | 
			
		||||
                    IsEditable="True"
 | 
			
		||||
                    ItemsSource="{Binding DrugInfos}"
 | 
			
		||||
                    SelectedItem="{Binding DrugInfo}"
 | 
			
		||||
                    DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
 | 
			
		||||
                />
 | 
			
		||||
            <StackPanel HorizontalAlignment="Right"  Grid.Column="3" Orientation="Horizontal">
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="绑定库位"
 | 
			
		||||
                        Content="绑定"
 | 
			
		||||
                        Command="{Binding BindingDrug}"/>
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="6 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="解除绑定"
 | 
			
		||||
                        Content="解绑"
 | 
			
		||||
                        Command="{Binding RemoveBinding}" />
 | 
			
		||||
                    <Button
 | 
			
		||||
                        Margin="0 0 6 0"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="刷新"
 | 
			
		||||
                        Command="{Binding Query}"
 | 
			
		||||
                        Content="{materialDesign:PackIcon Refresh}"/>
 | 
			
		||||
                </StackPanel>
 | 
			
		||||
            </Grid>
 | 
			
		||||
        <ItemsControl
 | 
			
		||||
                Grid.Row="2"
 | 
			
		||||
                ItemsSource="{Binding Channels}"
 | 
			
		||||
                Grid.IsSharedSizeScope="True"
 | 
			
		||||
                Margin="12 0 12 0">
 | 
			
		||||
            <ItemsControl.ItemsPanel>
 | 
			
		||||
                <ItemsPanelTemplate>
 | 
			
		||||
                    <UniformGrid Columns="4" />
 | 
			
		||||
                </ItemsPanelTemplate>
 | 
			
		||||
            </ItemsControl.ItemsPanel>
 | 
			
		||||
            <ItemsControl.ItemTemplate>
 | 
			
		||||
                <DataTemplate>
 | 
			
		||||
                    <materialDesign:Card
 | 
			
		||||
                                Background="{StaticResource MaterialDesignLightBackground}"
 | 
			
		||||
                                Margin="4"
 | 
			
		||||
                                Padding="0">
 | 
			
		||||
                        <Grid>
 | 
			
		||||
                            <Grid.RowDefinitions>
 | 
			
		||||
                                <RowDefinition />
 | 
			
		||||
                                <RowDefinition />
 | 
			
		||||
                            </Grid.RowDefinitions>
 | 
			
		||||
                            <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#31ccec" >
 | 
			
		||||
                                <CheckBox
 | 
			
		||||
                                        materialDesign:CheckBoxAssist.CheckBoxSize="30"
 | 
			
		||||
                                        VerticalAlignment="Center"
 | 
			
		||||
                                        IsChecked="{Binding IsSelected}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        Style="{StaticResource MaterialDesignHeadline5TextBlock}"
 | 
			
		||||
                                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                                        Padding="8"
 | 
			
		||||
                                        Text="{Binding Location}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        Style="{StaticResource MaterialDesignHeadline5TextBlock}"
 | 
			
		||||
                                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                                        Padding="8"
 | 
			
		||||
                                        HorizontalAlignment="Right">
 | 
			
		||||
                                    <TextBlock.Text>
 | 
			
		||||
                                        <MultiBinding Converter="{StaticResource BoardTypeConverter}">
 | 
			
		||||
                                            <Binding Path="BoardType" />
 | 
			
		||||
                                            <Binding Path="DrawerType" />
 | 
			
		||||
                                        </MultiBinding>
 | 
			
		||||
                                    </TextBlock.Text>
 | 
			
		||||
                                </TextBlock>
 | 
			
		||||
                            </StackPanel>
 | 
			
		||||
                            <Grid Grid.Row="1" x:Name="Border">
 | 
			
		||||
                                <Grid.RowDefinitions>
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                    <RowDefinition />
 | 
			
		||||
                                </Grid.RowDefinitions>
 | 
			
		||||
                                <Grid.ColumnDefinitions>
 | 
			
		||||
                                    <ColumnDefinition Width="Auto" />
 | 
			
		||||
                                    <ColumnDefinition />
 | 
			
		||||
                                </Grid.ColumnDefinitions>
 | 
			
		||||
                                <Grid.Resources>
 | 
			
		||||
                                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignSubtitle1TextBlock}">
 | 
			
		||||
                                        <Setter Property="Padding" Value="6" />
 | 
			
		||||
                                    </Style>
 | 
			
		||||
                                </Grid.Resources>
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="药品:" />
 | 
			
		||||
                                <StackPanel
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Orientation="Horizontal">
 | 
			
		||||
                                    <TextBlock Text="{Binding Drug.DrugName}" />
 | 
			
		||||
                                    <!--<TextBlock
 | 
			
		||||
                                            Visibility="{Binding Quantity, Converter={StaticResource NotZeroToVisibilityConverter}}"
 | 
			
		||||
                                            Text="{Binding Quantity, StringFormat=({0})}" />-->
 | 
			
		||||
                                </StackPanel>
 | 
			
		||||
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="规格:" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        Text="{Binding DrugSpec}" />
 | 
			
		||||
 | 
			
		||||
                                <!--<TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="批次:" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="1"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        Text="{Binding ManuNo}" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="2"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="效期:" />
 | 
			
		||||
                                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="2"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        Text="{Binding EffDate}" />-->
 | 
			
		||||
                            </Grid>
 | 
			
		||||
                        </Grid>
 | 
			
		||||
                    </materialDesign:Card>
 | 
			
		||||
                    <DataTemplate.Triggers>
 | 
			
		||||
                        <DataTrigger Binding="{Binding IsSelected}" Value="True">
 | 
			
		||||
                            <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
 | 
			
		||||
                            <Setter TargetName="Border" Property="Background" Value="#90caf9" />
 | 
			
		||||
                            <Setter Property="RenderTransform">
 | 
			
		||||
                                <Setter.Value>
 | 
			
		||||
                                    <ScaleTransform  ScaleX="0.95" ScaleY="0.95" />
 | 
			
		||||
                                </Setter.Value>
 | 
			
		||||
                            </Setter>
 | 
			
		||||
                        </DataTrigger>
 | 
			
		||||
                    </DataTemplate.Triggers>
 | 
			
		||||
                </DataTemplate>
 | 
			
		||||
            </ItemsControl.ItemTemplate>
 | 
			
		||||
        </ItemsControl>
 | 
			
		||||
 | 
			
		||||
        <pagination:Pagination Grid.Row="3"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />
 | 
			
		||||
        <materialDesign:Snackbar
 | 
			
		||||
                Background="{Binding SnackbarBackground}"
 | 
			
		||||
                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
			
		||||
        </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,163 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.Dialog.ChangeShiftsDialog"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:BoardTypeConverter x:Key="BoardTypeConverter" />
 | 
			
		||||
        <convert:ForeColorConverter x:Key="ForeColorConverter"/>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="5*"/>
 | 
			
		||||
            <ColumnDefinition Width="5*"/>
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
        <Grid Background="#03a9f4" Grid.Row="0" Grid.ColumnSpan="2">
 | 
			
		||||
            <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 0 16 0" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
            <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭" Cursor="Hand"
 | 
			
		||||
                    >
 | 
			
		||||
                <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
            </Button>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Row="1">
 | 
			
		||||
            <materialDesign:Card>
 | 
			
		||||
                <Grid>
 | 
			
		||||
                    <Grid.RowDefinitions>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                    </Grid.RowDefinitions>
 | 
			
		||||
                    <TextBlock Grid.Row="0" Margin="15,10,60,5" Text="验证方式1:账号密码验证" Foreground="#31ccec" FontWeight="Bold" FontSize="14"/>
 | 
			
		||||
                    <TextBox  Margin="15,5,15,5" 
 | 
			
		||||
                            Grid.Row="1"
 | 
			
		||||
                            x:Name="account" Foreground="Gray"
 | 
			
		||||
                            Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}"
 | 
			
		||||
                            Style="{StaticResource MaterialDesignOutlinedTextBox}"
 | 
			
		||||
                            VerticalAlignment="Top"
 | 
			
		||||
                            AcceptsReturn="False"
 | 
			
		||||
                            TextWrapping="Wrap" 
 | 
			
		||||
                            materialDesign:HintAssist.Hint="账号" />
 | 
			
		||||
                    <PasswordBox Margin="15,5,15,5" 
 | 
			
		||||
                            Grid.Row="2"
 | 
			
		||||
                            x:Name="PasswordBox" Foreground="Gray"
 | 
			
		||||
                            materialDesign:PasswordBoxAssist.Password="{Binding Password, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
 | 
			
		||||
                            Style="{StaticResource MaterialDesignOutlinedPasswordBox}"
 | 
			
		||||
                            VerticalAlignment="Top"
 | 
			
		||||
                            materialDesign:HintAssist.Hint="密码" />
 | 
			
		||||
                    <StackPanel Grid.Row="3"
 | 
			
		||||
                            Grid.Column="1">
 | 
			
		||||
                        <Grid Margin="2,2,2,10">
 | 
			
		||||
                            <Grid.ColumnDefinitions>
 | 
			
		||||
                                <ColumnDefinition Width="*"></ColumnDefinition>
 | 
			
		||||
                                <ColumnDefinition Width="3*"></ColumnDefinition>
 | 
			
		||||
                                <ColumnDefinition Width="*"></ColumnDefinition>
 | 
			
		||||
                                <ColumnDefinition Width="3*"></ColumnDefinition>
 | 
			
		||||
                                <ColumnDefinition Width="*"></ColumnDefinition>
 | 
			
		||||
                            </Grid.ColumnDefinitions>
 | 
			
		||||
                            <Button
 | 
			
		||||
                                    Grid.Column="1"
 | 
			
		||||
                                    Style="{StaticResource MaterialDesignRaisedButton}"
 | 
			
		||||
                                    materialDesign:ButtonAssist.CornerRadius="5"
 | 
			
		||||
                                    Command="{ Binding LoginCommand }"
 | 
			
		||||
                                    Background="#42a5f5" IsEnabled="{Binding JiaoBanOk}"
 | 
			
		||||
                                    BorderBrush="#42a5f5" Cursor="Hand"  IsDefault="True"  Content="验证"/>
 | 
			
		||||
                            <Button
 | 
			
		||||
                                Grid.Column="3"
 | 
			
		||||
                                Style="{StaticResource MaterialDesignRaisedLightButton}"
 | 
			
		||||
                                Background="#7986cb"
 | 
			
		||||
                                BorderBrush="#7986cb"
 | 
			
		||||
                                materialDesign:ButtonAssist.CornerRadius="5" Cursor="Hand" IsCancel="true" 
 | 
			
		||||
                                Command="{ Binding ClearCommand }" >
 | 
			
		||||
                                <TextBlock Foreground="{DynamicResource MaterialDesignPaper}" Text="清空" />
 | 
			
		||||
                            </Button>
 | 
			
		||||
                        </Grid>
 | 
			
		||||
                    </StackPanel>
 | 
			
		||||
                </Grid> 
 | 
			
		||||
            </materialDesign:Card>
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <Grid Grid.Row="1" Grid.Column="1" >
 | 
			
		||||
            <materialDesign:Card>
 | 
			
		||||
                <Grid> 
 | 
			
		||||
                    <Grid.RowDefinitions>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                        <RowDefinition/>
 | 
			
		||||
                    </Grid.RowDefinitions> 
 | 
			
		||||
 | 
			
		||||
                    <TextBlock Grid.Row="0" Margin="15,10,15,0" Text="验证方式2:屏幕外右侧指纹验证" Foreground="#31ccec" FontWeight="Bold" FontSize="14" />
 | 
			
		||||
 | 
			
		||||
                    <StackPanel Grid.Row="1">
 | 
			
		||||
                        <Grid>
 | 
			
		||||
                            <Grid.RowDefinitions>
 | 
			
		||||
                                <RowDefinition/>
 | 
			
		||||
                                <RowDefinition/>
 | 
			
		||||
                                <RowDefinition/>
 | 
			
		||||
                                <RowDefinition/>
 | 
			
		||||
                            </Grid.RowDefinitions>
 | 
			
		||||
                            <Grid.ColumnDefinitions>
 | 
			
		||||
                                <ColumnDefinition/>
 | 
			
		||||
                                <ColumnDefinition/>
 | 
			
		||||
                            </Grid.ColumnDefinitions>
 | 
			
		||||
                            <TextBlock Grid.Row="0" Text="交班人 发药人:" Grid.Column="0"  HorizontalAlignment="Right" Margin="0 15 0 5"
 | 
			
		||||
                    FontSize="14" Foreground="#31ccec" FontWeight="Bold"/>
 | 
			
		||||
                            <TextBlock  Grid.Row="0" Grid.Column="1" Margin="5 15 0 5" Foreground="{Binding OperatorLogin,Converter={StaticResource ForeColorConverter}}"
 | 
			
		||||
                            FontSize="14"
 | 
			
		||||
                            FontWeight="Bold"
 | 
			
		||||
                            Text="{Binding Operator.Nickname, UpdateSourceTrigger=PropertyChanged}" />
 | 
			
		||||
 | 
			
		||||
                            <TextBlock  Grid.Row="1"  Text="审核人:" Grid.Column="0" HorizontalAlignment="Right" Margin="0 15 0 5"
 | 
			
		||||
                    FontSize="14" Foreground="#31ccec" FontWeight="Bold"/>
 | 
			
		||||
                            <TextBlock Grid.Column="1" Margin="5 15 0 5"  Foreground="{Binding ReviewerLogin,Converter={StaticResource ForeColorConverter}}"
 | 
			
		||||
                            FontSize="14"
 | 
			
		||||
                            FontWeight="Bold" 
 | 
			
		||||
                            Grid.Row="1" Text="{Binding Reviewer.Nickname, UpdateSourceTrigger=PropertyChanged}" />
 | 
			
		||||
 | 
			
		||||
                            <TextBlock  Grid.Row="2" Text="接班人 发药人:" Grid.Column="0"  HorizontalAlignment="Right" Margin="0 15 0 5"
 | 
			
		||||
                    FontSize="14" Foreground="#31ccec" FontWeight="Bold"/>
 | 
			
		||||
                            <TextBlock Grid.Column="2" Margin="5 15 0 5"
 | 
			
		||||
                            FontSize="14"
 | 
			
		||||
                            FontWeight="Bold" TextAlignment="Left" HorizontalAlignment="Left"
 | 
			
		||||
                            Foreground="#3ECFED"
 | 
			
		||||
                            Grid.Row="2" Text="{Binding JieOperator.Nickname, UpdateSourceTrigger=PropertyChanged}" />
 | 
			
		||||
 | 
			
		||||
                            <TextBlock Grid.Row="3" Text="审核人:" Grid.Column="0"  HorizontalAlignment="Right" Margin="0 15 0 5"
 | 
			
		||||
                    FontSize="14" Foreground="#31ccec" FontWeight="Bold"/>
 | 
			
		||||
                            <TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="5 15 0 5"
 | 
			
		||||
                            FontSize="14"
 | 
			
		||||
                            FontWeight="Bold"
 | 
			
		||||
                            Foreground="#3ECFED"
 | 
			
		||||
                            Grid.Row="3" Text="{Binding JieReviewer.Nickname, UpdateSourceTrigger=PropertyChanged}" />
 | 
			
		||||
                        </Grid>
 | 
			
		||||
                    </StackPanel> 
 | 
			
		||||
                </Grid>
 | 
			
		||||
            </materialDesign:Card> 
 | 
			
		||||
        </Grid>
 | 
			
		||||
        <materialDesign:Card Grid.Row="2" Grid.ColumnSpan="2" Margin="10">
 | 
			
		||||
            <Button
 | 
			
		||||
                                    Style="{StaticResource MaterialDesignRaisedButton}"
 | 
			
		||||
                                    materialDesign:ButtonAssist.CornerRadius="5"
 | 
			
		||||
                                    Command="{ Binding ShiftsCommand }"
 | 
			
		||||
                                    Background="#42a5f5"
 | 
			
		||||
                                    BorderBrush="#42a5f5" Cursor="Hand"  IsDefault="True"  Content="确认交接"/>
 | 
			
		||||
        </materialDesign:Card>
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views.Dialog
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ChangeShiftsDialog.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class ChangeShiftsDialog : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public ChangeShiftsDialog()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,145 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.Dialog.CollectDrugDialog"
 | 
			
		||||
              xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
			
		||||
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <materialDesign:Card Padding="0">
 | 
			
		||||
        <Grid>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Background="#03a9f4" Grid.Row="0">
 | 
			
		||||
                <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭"
 | 
			
		||||
                    >
 | 
			
		||||
                    <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid Grid.Row="1" x:Name="Border" Margin="0 10 10 0">
 | 
			
		||||
                <Grid.RowDefinitions>
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                </Grid.RowDefinitions>
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
                <Grid.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignSubtitle1TextBlock}">
 | 
			
		||||
                        <Setter Property="Padding" Value="6" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </Grid.Resources>
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="0"
 | 
			
		||||
                                        Text="请领数量:" />
 | 
			
		||||
                <StackPanel
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="1"
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Orientation="Horizontal">
 | 
			
		||||
                    <TextBlock Text="{Binding QuantityCount}" />
 | 
			
		||||
                </StackPanel>
 | 
			
		||||
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="2"
 | 
			
		||||
                                        Text="交处方张数:" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Left"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="3"
 | 
			
		||||
                                        Text="{Binding OrderCount}" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                                        HorizontalAlignment="Right"
 | 
			
		||||
                                        Grid.Row="0"
 | 
			
		||||
                                        Grid.Column="4"
 | 
			
		||||
                                        Text="请领药库:" />
 | 
			
		||||
                <ComboBox Grid.Column="5"  Width="80" Height="50" FontFamily="微软雅黑"
 | 
			
		||||
                    Margin="0 0 0 5"  HorizontalAlignment="Left"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
			
		||||
                    SelectedItem="{Binding SelectedItem}"
 | 
			
		||||
                    DisplayMemberPath="Name"
 | 
			
		||||
                    ItemsSource="{Binding Selects}"/>
 | 
			
		||||
                <Button Width="130" Height="50"
 | 
			
		||||
                        Margin="6 0 6 3" Grid.Row="0" Grid.Column="6"
 | 
			
		||||
                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                        ToolTip="确认并生成"
 | 
			
		||||
                        Content="确认并生成"
 | 
			
		||||
                        Command="{Binding CreateApply}" />
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <ListView
 | 
			
		||||
            Grid.Row="2"
 | 
			
		||||
            ItemsSource="{Binding CollectDrugList}" 
 | 
			
		||||
            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                <ListView.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </ListView.Resources>
 | 
			
		||||
                <ListView.View>
 | 
			
		||||
                    <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                        <GridViewColumn Width="200"
 | 
			
		||||
                        Header="药品名称"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DrugName}"/>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                        Header="规格"
 | 
			
		||||
                        DisplayMemberBinding="{Binding DrugSpec}" />
 | 
			
		||||
                        <GridViewColumn Width="280"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Manufactory}"
 | 
			
		||||
                        Header="厂家"/>
 | 
			
		||||
                        <GridViewColumn Width="80"
 | 
			
		||||
                        DisplayMemberBinding="{Binding Quantity}"
 | 
			
		||||
                        Header="数量"/>
 | 
			
		||||
                        <!--<GridViewColumn  Width="200"
 | 
			
		||||
                        DisplayMemberBinding="{Binding OrderNo}"
 | 
			
		||||
                        Header="处方号"/>-->
 | 
			
		||||
                    </GridView>
 | 
			
		||||
                </ListView.View>
 | 
			
		||||
            </ListView>
 | 
			
		||||
 | 
			
		||||
            <!--<pagination:Pagination Grid.Row="3"
 | 
			
		||||
                                   CurrentPage="{Binding PageNum}"
 | 
			
		||||
                                   PageSize="{Binding PageSize}"
 | 
			
		||||
                                   TotalPages="{Binding TotalCount}"
 | 
			
		||||
                                   InfoTextIsEnabel="True"
 | 
			
		||||
                                />-->
 | 
			
		||||
        </Grid>
 | 
			
		||||
 | 
			
		||||
    </materialDesign:Card>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views.Dialog
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// CollectDrugDialog.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class CollectDrugDialog : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public CollectDrugDialog()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,213 +0,0 @@
 | 
			
		|||
<UserControl x:Class="DM_Weight.Views.Dialog.DestoryEmptyDialog"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
			
		||||
             xmlns:prism="http://prismlibrary.com/"
 | 
			
		||||
             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
			
		||||
             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
			
		||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
			
		||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
			
		||||
             mc:Ignorable="d"
 | 
			
		||||
              MinWidth="880"
 | 
			
		||||
             MaxHeight="500"
 | 
			
		||||
             Width="Auto"
 | 
			
		||||
             Height="Auto">
 | 
			
		||||
    <UserControl.Resources>
 | 
			
		||||
        <convert:StatusConverter x:Key="StatusConverter" />
 | 
			
		||||
        <convert:InputQuantityConverter x:Key="InputQuantityConverter" />
 | 
			
		||||
        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
			
		||||
            <Style.Setters>
 | 
			
		||||
                <Setter Property="Height">
 | 
			
		||||
                    <Setter.Value>55</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Background">
 | 
			
		||||
                    <Setter.Value>#31ccec</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
                <Setter Property="Foreground">
 | 
			
		||||
                    <Setter.Value>white</Setter.Value>
 | 
			
		||||
                </Setter>
 | 
			
		||||
            </Style.Setters>
 | 
			
		||||
        </Style>
 | 
			
		||||
    </UserControl.Resources>
 | 
			
		||||
    <materialDesign:Card Padding="0">
 | 
			
		||||
        <Grid>
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
                <RowDefinition Height="50" />
 | 
			
		||||
                <RowDefinition Height="5*" />
 | 
			
		||||
                <RowDefinition Height="Auto" />
 | 
			
		||||
            </Grid.RowDefinitions>
 | 
			
		||||
            <Grid Background="#03a9f4" Grid.Row="0">
 | 
			
		||||
                <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
 | 
			
		||||
                <Button
 | 
			
		||||
                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
			
		||||
                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
			
		||||
                        HorizontalAlignment="Right"
 | 
			
		||||
                        Command="{Binding BtnCloseCommand}"
 | 
			
		||||
                        ToolTip="关闭"
 | 
			
		||||
                    >
 | 
			
		||||
                    <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
			
		||||
                </Button>
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <Grid Grid.Row="1">
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition Width="2*" />
 | 
			
		||||
                    <ColumnDefinition Width="3*" />
 | 
			
		||||
                    <ColumnDefinition Width="2*" />
 | 
			
		||||
                    <ColumnDefinition Width="*" />
 | 
			
		||||
                    <ColumnDefinition Width="2*" />
 | 
			
		||||
                    <ColumnDefinition Width="2*" />
 | 
			
		||||
                    <ColumnDefinition Width="3*" />
 | 
			
		||||
                    <ColumnDefinition Width="*" />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="0"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Right"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="药品:" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="1"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Left"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="{Binding _ChannelStock.DrugInfo.DrugName}" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="2"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Right"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="规格:" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="3"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Left"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="{Binding _ChannelStock.DrugInfo.DrugSpec}" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="4"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Right"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="厂家:" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="5"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Left"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="{Binding _ChannelStock.DrugInfo.Manufactory}" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="6"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Right"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="可取空瓶数:" />
 | 
			
		||||
                <TextBlock
 | 
			
		||||
                      Grid.Column="7"
 | 
			
		||||
                      Margin="16 0 16 8"
 | 
			
		||||
                      VerticalAlignment="Center"
 | 
			
		||||
                      HorizontalAlignment="Left"
 | 
			
		||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
			
		||||
                      Text="{Binding _ChannelStock.Quantity}" />
 | 
			
		||||
            </Grid>
 | 
			
		||||
            <ListView
 | 
			
		||||
                Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Visible"
 | 
			
		||||
                ItemsSource="{Binding _MachineRecords}"
 | 
			
		||||
                SelectedItem="{Binding _MachineRecord}"
 | 
			
		||||
                materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
			
		||||
                materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
			
		||||
                materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
			
		||||
                <ListView.Resources>
 | 
			
		||||
                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
			
		||||
                        <Setter Property="Foreground" Value="White" />
 | 
			
		||||
                    </Style>
 | 
			
		||||
                </ListView.Resources>
 | 
			
		||||
 | 
			
		||||
                <i:Interaction.Triggers>
 | 
			
		||||
                    <i:EventTrigger EventName="SelectionChanged">
 | 
			
		||||
                        <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
			
		||||
                    </i:EventTrigger>
 | 
			
		||||
                </i:Interaction.Triggers>
 | 
			
		||||
                <ListView.View>
 | 
			
		||||
                    <GridView   ColumnHeaderContainerStyle="{StaticResource st}">
 | 
			
		||||
                        <GridViewColumn Header="选择" Width="100">
 | 
			
		||||
                            <GridViewColumn.CellTemplate>
 | 
			
		||||
                                <DataTemplate>
 | 
			
		||||
                                    <CheckBox IsChecked="{Binding IsSelected}" />
 | 
			
		||||
                                </DataTemplate>
 | 
			
		||||
                            </GridViewColumn.CellTemplate>
 | 
			
		||||
                        </GridViewColumn>
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                            Header="操作人"
 | 
			
		||||
                            DisplayMemberBinding="{Binding User.Nickname}"/>
 | 
			
		||||
                        <GridViewColumn Width="150"
 | 
			
		||||
                            Header="时间"
 | 
			
		||||
                            DisplayMemberBinding="{Binding OperationTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" />
 | 
			
		||||
                        <GridViewColumn Width="100"
 | 
			
		||||
                            DisplayMemberBinding="{Binding Quantity}"
 | 
			
		||||
                            Header="数量"/>
 | 
			
		||||
                        <GridViewColumn Width="150"
 | 
			
		||||
                            DisplayMemberBinding="{Binding ManuNo}"
 | 
			
		||||
                            Header="批次"/>
 | 
			
		||||
                        <GridViewColumn Width="150"
 | 
			
		||||
                            DisplayMemberBinding="{Binding EffDate, StringFormat=yyyy-MM-dd}"
 | 
			
		||||
                            Header="效期"/>
 | 
			
		||||
                    </GridView>
 | 
			
		||||
                </ListView.View>
 | 
			
		||||
            </ListView>
 | 
			
		||||
 | 
			
		||||
            <Grid Grid.Row="3">
 | 
			
		||||
                <Grid.RowDefinitions>
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                    <RowDefinition />
 | 
			
		||||
                </Grid.RowDefinitions>
 | 
			
		||||
                <Grid.ColumnDefinitions>
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                    <ColumnDefinition />
 | 
			
		||||
                </Grid.ColumnDefinitions>
 | 
			
		||||
                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center">
 | 
			
		||||
 | 
			
		||||
                    <Button
 | 
			
		||||
                            Margin="2"
 | 
			
		||||
                            Style="{StaticResource MaterialDesignOutlinedLightButton}"           
 | 
			
		||||
                            Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
			
		||||
                            materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
			
		||||
                            materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"                
 | 
			
		||||
                            Content="取空瓶"
 | 
			
		||||
                            Command="{Binding DestoryEmptyCommand}">
 | 
			
		||||
                    </Button>
 | 
			
		||||
 | 
			
		||||
                    <Button
 | 
			
		||||
                    Margin="0 0 3 0"
 | 
			
		||||
                    VerticalAlignment="Center"
 | 
			
		||||
                    Command="{Binding TakeFinish}"
 | 
			
		||||
                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
			
		||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                    Content="完成" />
 | 
			
		||||
                    
 | 
			
		||||
                    
 | 
			
		||||
                    <Button
 | 
			
		||||
                            Margin="2"
 | 
			
		||||
                            Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
			
		||||
                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
			
		||||
                            Content="取消"
 | 
			
		||||
                            Command="{Binding CancleTake}" />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                </StackPanel>
 | 
			
		||||
 | 
			
		||||
            </Grid>
 | 
			
		||||
        </Grid>
 | 
			
		||||
    </materialDesign:Card>
 | 
			
		||||
</UserControl>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace DM_Weight.Views.Dialog
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// DestoryEmptyDialog.xaml 的交互逻辑
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class DestoryEmptyDialog : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public DestoryEmptyDialog()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue